Page 1 of 1

Getting the Value of intersection point for CrossHair

Posted: Tue Nov 13, 2007 8:52 am
by 7665742
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,

Posted: Tue Nov 13, 2007 11:04 am
by narcis
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.

Posted: Tue Nov 13, 2007 11:14 am
by 7665742
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,

Posted: Tue Nov 13, 2007 11:40 am
by narcis
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");
            }
        }