Esempio n. 1
0
  /* This demo code displays plot on screen using image terminal */
  private static JavaPlot JPlotTerminal(String gnuplotpath) {
    JPlot plot = new JPlot();
    plot.getJavaPlot().addPlot("sqrt(x)/x");
    plot.getJavaPlot().addPlot("x*sin(x)");
    plot.plot();

    JFrame f = new JFrame();
    f.getContentPane().add(plot);
    f.pack();
    f.setLocationRelativeTo(null);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);

    return plot.getJavaPlot();
  }
  /**
   * Do the paint. Calling the super method for all the JavaPlot magik but we first do a set of the
   * plot type we want (this will be changed all the time) and doing a plot. The plot will only be
   * done when there is atleast two entries otherwise JavaPlot crashes.
   *
   * @param g Graphics container to paint on
   */
  @Override
  public final void paint(final Graphics g) {

    if (this.dataset.size() > 1) {
      synchronized (this.dataset.getDatasetLock()) {

        // Setup the correct type
        this.dataset.setCurrentPlot(this);

        this.plot();
        super.paint(g);
      }
    }
  }