Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Java
 QCChart2D for Java
 Example of ChartMouseListener
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

johnbutler

23 Posts

Posted - 11 Nov 2005 :  13:28:33  Show Profile  Reply with Quote
Is there an example of just a ChartMouseListener? Specifically, how do I trap on mouse event that occur just within the graph region? Or how do I convert the Point returned in the mouseEvent from being relative to the ChartView to being relative to the graph?

What I want to do is know at what position in the x-axis did the click occur. So if the x-axis scale is from 50 to 100 and the click occurs in the middle, I need to get 75.

Edited by - johnbutler on 11 Nov 2005 14:06:25

quinncurtis

1164 Posts

Posted - 11 Nov 2005 :  15:15:23  Show Profile  Reply with Quote
Sorry, we do not have a ready made example that does what you describe.

You should be able to use a MouseInputListener object derived from DataCursor. The point p ends up with the physical coordinates of the mouse cursor at mouse pressed and mouse released.

public class CustomChartDataCursor2 extends DataCursor {
  public CustomChartDataCursor2(ChartView achartview, CartesianCoordinates thetransform,
                       int nmarkertype,
                       double rsize)
  {
        super(achartview, thetransform, nmarkertype, rsize);
  }
   
   // override mouseReleased method in order to add stuff
   public void mousePressed(MouseEvent event)
    {
   	  super.mousePressed(event);
   	  ChartPoint2D p = getLocation(ChartObj.PHYS_POS);
    }

  // override mouseReleased method in order to add stuff
   public void mouseReleased (MouseEvent event)
    {
   	  super.mouseReleased(event);
   	  ChartPoint2D p = getLocation(ChartObj.PHYS_POS);
    }
  }

.
.
.

 CustomChartDataCursor2 dataCursorObj = new CustomChartDataCursor2( gWG, pTransform1,
            ChartConstants.MARKER_NULL, 8.0);

 dataCursorObj.setDataCursorEnable(true);
 dataCursorObj.addDataCursorListener();
Go to Top of Page

quinncurtis

1164 Posts

Posted - 16 Nov 2005 :  10:30:01  Show Profile  Reply with Quote
Sorry, we do not know that answer to your question. We derived our DataCursor from the standard Java javax.swing.event.MouseInputListener, so your question really applies to that class. MouseInputListener does not provide specific functions for double click or Ctrl-click, though it is probably possible to implement them indirectly. You may be able to find some answers on generic Java programming forums. If it is critical to your application you can hire our programming services group to write some sort of custom interface for you.

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07