Menu

point data

2004-10-14
2013-03-22
  • Nobody/Anonymous

    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.

     
    • Yann RICHET

      Yann RICHET - 2004-10-14

      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();
          }

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.