Getting the Value of intersection point for CrossHair

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
cdn
Newbie
Newbie
Posts: 29
Joined: Wed Sep 19, 2007 12:00 am

Getting the Value of intersection point for CrossHair

Post by cdn » Tue Nov 13, 2007 8:52 am

Hi:

We have implemented CrossHair feature as below -

Code: Select all

		ImageIcon img2 = new ImageIcon("images/CrossHair16.gif");
		m_bCrossHair = new SmallToggleButton(false, img2, img2,
			"CrossHair");
		ActionListener crossHair = new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (m_bCrossHair.isSelected()) {
		        	dsCrossHair.setActive(true);
					tChart2.getZoom().zoomPercent(100);
					dsCrossHair.setChart(tChart2.getChart());
			    	dsCrossHair.setFollowMouse(true);
				} else {
					dsCrossHair.setActive(false);
					tChart2.getZoom().undo();
				}
			}
		};
But, we would like to get the intersection point displayed after the mouse clicked event on the intersection point. Is this feasible? Thank you.

best regards,

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Nov 13, 2007 11:04 am

Hi cdn,

Before being able to give you a reply we will need some more information on what you are trying to achieve.

I assume that with CrossHair you mean you are using a Cursor tool, is that right? Also
But, we would like to get the intersection point displayed after the mouse clicked event on the intersection point.
It is not clear to me what you are trying to achieve here. Could you please give us some more details about what you want to obtain?

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

cdn
Newbie
Newbie
Posts: 29
Joined: Wed Sep 19, 2007 12:00 am

Post by cdn » Tue Nov 13, 2007 11:14 am

Hi:

yes, we are using "CursorTool". What we are trying to get is intersection point of Horizontal and vertical lines - only if we click the point with the mouse. The reason - otherwise there will be too many points being displayed. For example - we would like to display X date value and Y value when we click with the mouse on the intersection of crosshairs.

I hope this explanation is clear. Should you have any question, please let us know. Thanks.

best regards,

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Nov 13, 2007 11:40 am

Hi cdn,

Thanks for the information. In that case you can create the event:

Code: Select all

                tChart.addMouseListener(new java.awt.event.MouseListener() {
                    public void mouseClicked(MouseEvent e) {
                        tChartMouseListened(e);
                    }
                    public void mouseEntered(MouseEvent e) {
                    }
                    public void mouseExited(MouseEvent e) {
                    }
                    public void mousePressed(MouseEvent e) {
                    }
                    public void mouseReleased(MouseEvent e) {
                    }
                });


And implement it like this:

Code: Select all

        private void tChartMouseListened(java.awt.event.MouseEvent e)
        {
            double XVal = cursor1.getXValue();
            double YVal = cursor1.getYValue();
            
            if ( (tChart.getAxes().getBottom().calcPosPoint(e.getX())==XVal ) && 
                    (tChart.getAxes().getLeft().calcPosPoint(e.getY())==YVal) )
            {
                tChart.getHeader().setText("Intersection clicked");
            }
            else
            {
                tChart.getHeader().setText("Intersection NOT clicked");
            }
        }   
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply