Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Tools for Java
 QCChart2D for Java
 Overriding Default Behavior of DataCursor

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List

* Forum Code is ON
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]


T O P I C    R E V I E W
png Posted - 16 Oct 2014 : 17:44:26
I'm using both a DataCursor and a ChartZoom object within the same ChartView instance. How would I go about changing the default behavior of the DataCursor object so that it won't clash with the ChartZoom object when a mouse pressed event occurs?

Also, I'm trying to implement code to actively update a label that shows the current X,Y data point as the DataCursor marker is moving along the chart, but haven't able to get it working. Can you provide some sample code that demonstrates how this functionality would be handled?

3   L A T E S T    R E P L I E S    (Newest First)
quinncurtis Posted - 17 Oct 2014 : 13:06:49
The DataCursor class has no standard mode which tracks the mouseMove event, independent of the button status.

You can play around with a subclass of DataCursor. In this example the first move simulates a mouse pressed event to start the data cursor, and does NOT pass along actual mousePressed and mouseRelease events. Subsequent mouseMoved calls the standard mouse event mouseDragged method, which is what the DataCursor routine tracks. However, you may get remnants, definitely if you use it simultaneously with another MouseListener class which uses the XOR mode, such as the ChartZoom class.

 class CustomDataCursor extends DataCursor {

	   boolean firstpass = true;
	   public CustomDataCursor(ChartView achartview, CartesianCoordinates thetransform,
	                       int nmarkertype,
	                       double rsize)
	        super(achartview, thetransform, nmarkertype, rsize);
	   // override mousePressed 
	   public void mousePressed(MouseEvent event)
	   // override mouseReleased method 
	   public void mouseReleased(MouseEvent event)
	   // create a simulated mousePressed event
	   public void simulatedMousePressed(MouseEvent event)
		     try {
			    catch ( Exception  e )

		  // override mouseReleased method in order to add stuff
	   public void mouseMoved (MouseEvent event)
		   MouseEvent me = new MouseEvent(this.getChartObjComponent(),
	                  event.getModifiers() | this.getButtonMask(),
		   if (firstpass){
			   simulatedMousePressed( me);
			   firstpass = false;
		   } else 

png Posted - 17 Oct 2014 : 12:13:46
Thanks for your reply. On this same topic, is there a way to set the DataCursor so that the marker appears as the mouse is moving across the chart, rather than having to press and hold down the mouse button as it moves across the chart (its default behavior)?
quinncurtis Posted - 16 Oct 2014 : 18:04:02
You can't use both at the same time. You must have some sort of toggle (a checkbox or button) that enables one or the other, but not both. You would set the enable property of the cursor or the zoom object depending on the toggle state.

if (zoomEnable)
} else

Quinn-Curtis Forums © 2000-2018 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07