コード例 #1
0
ファイル: LinePlot.java プロジェクト: fjtsai/jlabgroovy
  public static void main(String[] args) {
    Plot2DPanel p2 = new Plot2DPanel();

    double[][] XYZ = new double[100][2];
    for (int j = 0; j < XYZ.length; j++) {
      XYZ[j][0] = 2 * Math.PI * (double) j / XYZ.length;
      XYZ[j][1] = Math.sin(XYZ[j][0]);
    }
    double[][] XYZ2 = new double[100][2];
    for (int j = 0; j < XYZ2.length; j++) {
      XYZ2[j][0] = 2 * Math.PI * (double) j / XYZ.length;
      XYZ2[j][1] = Math.sin(2 * XYZ2[j][0]);
    }

    p2.addLinePlot("sin", Color.RED, AbstractDrawer.DOTTED_LINE, XYZ);
    p2.setBackground(new Color(200, 0, 0));
    p2.addLinePlot("sin2", Color.BLUE, AbstractDrawer.CROSS_DOT, XYZ2);

    p2.setLegendOrientation(PlotPanel.SOUTH);
    new FrameView(p2).setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    Plot3DPanel p = new Plot3DPanel();

    XYZ = new double[100][3];
    for (int j = 0; j < XYZ.length; j++) {
      XYZ[j][0] = 2 * Math.PI * (double) j / XYZ.length;
      XYZ[j][1] = Math.sin(XYZ[j][0]);
      XYZ[j][2] = Math.sin(XYZ[j][0]) * Math.cos(XYZ[j][1]);
    }
    p.addLinePlot("toto", XYZ);

    p.setLegendOrientation(PlotPanel.SOUTH);
    new FrameView(p).setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
  }