示例#1
0
  @Override
  public JComponent getVisualisation(DataBean data) throws Exception {

    this.data = data;

    refreshAxisBoxes(data);

    List<Variable> vars = getFrame().getVariables();
    if (vars == null || vars.size() < 2) {
      if (xBox.getItemCount() >= 1) {
        xBox.setSelectedIndex(0);
      }
      if (yBox.getItemCount() >= 2) {
        yBox.setSelectedIndex(1);
      } else {
        yBox.setSelectedIndex(0);
      }
    } else {
      xBox.setSelectedItem(vars.get(0));
      yBox.setSelectedItem(vars.get(1));
    }

    xVar = (Variable) xBox.getSelectedItem();
    yVar = (Variable) yBox.getSelectedItem();

    PlotDescription description =
        new PlotDescription(data.getName(), xVar.getName(), yVar.getName());

    NumberAxis domainAxis = new NumberAxis(description.xTitle);
    domainAxis.setAutoRangeIncludesZero(false);
    NumberAxis rangeAxis = new NumberAxis(description.yTitle);
    rangeAxis.setAutoRangeIncludesZero(false);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setLinesVisible(false);
    renderer.setShapesVisible(true);
    renderer.setShape(new Ellipse2D.Float(-2, -2, 4, 4));
    renderer.setSeriesPaint(1, Color.black);

    plot = new XYPlot(new XYSeriesCollection(), domainAxis, rangeAxis, renderer);

    this.updateSelectionsFromApplication(false); // Calls also updateXYSerieses();

    JFreeChart chart = new JFreeChart(description.plotTitle, plot);

    application.addClientEventListener(this);

    selectableChartPanel = new SelectableChartPanel(chart, this);
    return selectableChartPanel;
  }
 /**
  * Sets a flag that controls whether or not lines are drawn between the items in ALL series, and
  * sends a {@link RendererChangeEvent} to all registered listeners.
  *
  * @param visible the flag.
  * @see #getLinesVisible()
  * @deprecated As of 1.0.7, use the per-series and base level settings.
  */
 public void setLinesVisible(boolean visible) {
   setLinesVisible(Boolean.valueOf(visible));
 }