Cursor Tool

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
Turc
Newbie
Newbie
Posts: 34
Joined: Wed Feb 03, 2010 12:00 am

Cursor Tool

Post by Turc » Mon Oct 07, 2013 4:22 pm

I Initialize the cursor Tool:

Code: Select all

cursorTool = new CursorTool(this.getChart());
cursorTool.setActive(false);
cursorTool.setFollowMouse(true);
cursorTool.setStyle(CursorToolStyle.VERTICAL);
cursorTool.getPen().setStyle(DashStyle.SOLID); 
When the user clicks on the graph (mouseClicked MouseEvent), then I enable the cursor tool:

Code: Select all

if(!cursorTool.getActive())
{
      cursorTool.setXValue(e.getX());   
      cursorTool.setActive(true);         
}
The issue that I'm having is that the vertical cursor line does not appear when the user clicks on the chart, but only after the user moves the mouse. Is there any way that the vertical line can show up upon a mouse click instead of a mouse movement once it's enabled?

Thanks

Yeray
Site Admin
Site Admin
Posts: 8738
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Cursor Tool

Post by Yeray » Tue Oct 08, 2013 10:42 am

Hello Turc,

Not the MouseEvent gives you the Mouse pointer position in pixels, through the getX()/getY() functions, while the CursorTool setXValue() function expects to receive a Value on the axis scale as a parameter.
So you gave to convert the e.getX() value to the Axis scale. This seems to work fine for me here:

Code: Select all

cursorTool.setXValue(tChart1.getAxes().getBottom().calcPosPoint(e.getX()));
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Turc
Newbie
Newbie
Posts: 34
Joined: Wed Feb 03, 2010 12:00 am

Re: Cursor Tool

Post by Turc » Tue Oct 08, 2013 12:48 pm

Thank you.

Post Reply