Is there a way to get the point infomation that is displayed when you click the view coordinates button, but is triggered by another event such as a mouse double click? What I really want to know is how do you get a point's coordinates from clicking that point.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there a way to get the point infomation that is displayed when you click the view coordinates button, but is triggered by another event such as a mouse double click? What I really want to know is how do you get a point's coordinates from clicking that point.
I suggest you to take the sources of jmathplot and modify it as follows in mouseClicked method in PlotPanel.java :
public void mouseClicked(MouseEvent e) {
mouseCurent[0] = e.getX();
mouseCurent[1] = e.getY();
e.consume();
mouseClick[0] = mouseCurent[0];
mouseClick[1] = mouseCurent[1];
////////////////HERE THE CODE ADDED////////////////////////
for (int i = 0; i < plots.size(); i++) {
RelativeCoord[] coords = getPlot(i).getCoords();
for (int j = 0; j < coords.length; j++)
System.out.println(coords[i]); //change here
}
////////////////////////////////////////
int[] origin;
double[] ratio;
switch (ActionMode) {
case ZOOM:
if (e.getModifiers() == 16) {
origin = new int[] { (int) (mouseCurent[0] - panelSize[0] / 4),
(int) (mouseCurent[1] - panelSize[1] / 4) };
ratio = new double[] { 0.5, 0.5 };
} else {
origin = new int[] { (int) (mouseCurent[0] - panelSize[0]),
(int) (mouseCurent[1] - panelSize[1]) };
ratio = new double[] { 2, 2 };
}
base.dilate(origin, ratio);
break;
}
repaint();
}