Esempio n. 1
0
 /**
  * Creates a panel for the demo (used by SuperDemo.java).
  *
  * @param id
  * @return A panel.
  * @throws Exception
  */
 public static JPanel createDemoPanel(int id) throws Exception {
   JFreeChart chart = createChart(createDataset(id));
   ChartPanel panel = new ChartPanel(chart);
   panel.setFillZoomRectangle(true);
   panel.setMouseWheelEnabled(true);
   return panel;
 }
  /** Creates the chart panel, puts it on display. */
  public void resetChartPanel() {

    // this is the new "insert" - elastic boundaries chart panel
    //
    paintTheChart(this.chartData.getOriginalTimeseries());

    ChartPanel chartPanel = new ChartPanel(this.chart);

    chartPanel.setMinimumDrawWidth(0);
    chartPanel.setMinimumDrawHeight(0);
    chartPanel.setMaximumDrawWidth(1920);
    chartPanel.setMaximumDrawHeight(1200);

    chartPanel.setMouseWheelEnabled(true);

    // cleanup all the content
    //
    this.removeAll();

    // put the chart on show
    //
    this.add(chartPanel);

    // not sure if I need this
    //
    validate();
    repaint();
  }
 /*     */ public static JPanel createDemoPanel() /*     */ {
   /* 197 */ JFreeChart chart = createChart(createDataset());
   /* 198 */ ChartPanel panel = new ChartPanel(chart);
   /* 199 */ panel.setFillZoomRectangle(true);
   /* 200 */ panel.setMouseWheelEnabled(true);
   /* 201 */ return panel;
   /*     */ }
Esempio n. 4
0
  private void jButton2ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton2ActionPerformed
    double newMinLifetime, newMaxLifetime;
    try {
      newMinLifetime = Double.parseDouble(jTFMinValue.getText());
      newMaxLifetime = Double.parseDouble(jTFMaxValue.getText());

      IntensImageDataset dataValuesDataset =
          new IntensImageDataset(imHeight, imWidth, new double[imWidth * imHeight]);
      for (int i = 0; i < dataValues.length; i++) {
        dataValuesDataset.SetValue(selImInd[i], dataValues[i]);
      }
      PaintScale ps = new RainbowPaintScale(newMinLifetime, newMaxLifetime);
      JFreeChart aveLifetimeChart =
          createScatChart(
              ImageUtilities.createColorCodedImage(dataValuesDataset, ps), ps, imWidth, imHeight);
      aveLifetimeChart.getXYPlot().getRangeAxis().setInverted(true);
      ChartPanel aveLifetimePanel = new ChartPanel(aveLifetimeChart);
      aveLifetimePanel.setFillZoomRectangle(true);
      aveLifetimePanel.setMouseWheelEnabled(true);
      jPImage.removeAll();
      aveLifetimePanel.setSize(jPImage.getSize());
      aveLifetimePanel.addChartMouseListener(listener);
      jPImage.add(aveLifetimePanel);
      jPImage.repaint();
    } catch (NumberFormatException ex) {
      CoreErrorMessages.selCorrChNum();
    }
  } // GEN-LAST:event_jButton2ActionPerformed
  /**
   * DOCUMENT ME!
   *
   * @throws IllegalStateException DOCUMENT ME!
   */
  private void init() {
    final String json = (String) cidsBean.getProperty("uri"); // NOI18N
    final ObjectMapper mapper = new ObjectMapper();
    final IDFCurve curve;
    try {
      curve = mapper.readValue(new StringReader(json), IDFCurve.class);
    } catch (IOException ex) {
      final String message = "cannot read idf data from uri"; // NOI18N
      LOG.error(message, ex);
      throw new IllegalStateException(message, ex);
    }

    // Create Chart
    final XYDataset dataset = createDataset(curve);
    final String name = (String) cidsBean.getProperty("name"); // NOI18N
    final String xAxisTitle = "Duration (min)";
    final String yAxisTitle = "Intensity (mm/h)";

    final JFreeChart chart = createChart(dataset, name, xAxisTitle, yAxisTitle);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setMouseZoomable(true, true);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setPopupMenu(null);
    pnlChart.add(chartPanel, BorderLayout.CENTER);
  }
 public static ChartPanel createPanelgraph() {
   JFreeChart chart = createChart(createDataset());
   ChartPanel panel = new ChartPanel(chart);
   panel.setFillZoomRectangle(true);
   panel.setMouseWheelEnabled(true);
   return panel;
 }
Esempio n. 7
0
  /**
   * @param title - tite of the window when we instantiate the BarChart
   * @param timeTaken - long: the time taken for the cleaning process since the ON button has been
   *     pressed
   * @param cellsCovered - int count of the cells that have been covered so far
   * @param time - the current system time
   */
  public BarChart(String title, long timeTaken, int cellsCovered, String time) {
    super(title);

    saveLoad = new SaveLoad();
    if (saveLoad.deserializeStatistics()) {
      System.out.println("Statistics de-serialized.");
      statistics = saveLoad.getStatistics();
      if (timeTaken != 0) {
        statistics.addCycle(timeTaken, cellsCovered, time);
      }
      saveLoad.serializeStatistics(statistics);
    } else {
      System.out.println("Statistics did not de-serialize.");
      statistics = new Statistics();
      if (timeTaken != 0) {
        statistics.addCycle(timeTaken, cellsCovered, time);
      }
      saveLoad.serializeStatistics(statistics);
    }

    if (statistics.getListOfCycles().size() > 0) {
      System.out.println("BarChart - condition for displayin the chart passed!");
      CategoryDataset dataset = createDataset();
      JFreeChart chart = createChart(dataset);
      ChartPanel chartPanel = new ChartPanel(chart);
      chartPanel.setFillZoomRectangle(true);
      chartPanel.setMouseWheelEnabled(true);
      chartPanel.setPreferredSize(new Dimension(500, 270));
      setContentPane(chartPanel);
    } else {
      JOptionPane.showMessageDialog(this, "No Statistics data. Please run the robot first.");
    }
  }
Esempio n. 8
0
 /**
  * Displays a chart in a frame.
  *
  * @param chart the chart to be displayed
  */
 private static void displayChart(JFreeChart chart) {
   // Chart panel
   ChartPanel panel = new ChartPanel(chart);
   panel.setFillZoomRectangle(true);
   panel.setMouseWheelEnabled(true);
   panel.setPreferredSize(new java.awt.Dimension(500, 270));
   // Application frame
   ApplicationFrame frame = new ApplicationFrame("Ta4j example - Indicators to chart");
   frame.setContentPane(panel);
   frame.pack();
   RefineryUtilities.centerFrameOnScreen(frame);
   frame.setVisible(true);
 }
  public static JPanel createDemoPanel() {
    JFreeChart chart;
    ChartPanel panel = null;
    try {
      chart = createChartZhu(createDatasetBar());

      panel = new ChartPanel(chart);
      panel.setFillZoomRectangle(true);
      panel.setMouseWheelEnabled(true);
      return panel;
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      return panel;
    }
  }
Esempio n. 10
0
  public ImageHistPanel(
      String name,
      double[] data,
      int[] selInd,
      int height,
      int width,
      double minVal,
      double maxVal,
      ChartMouseListener listen) {
    initComponents();
    this.dataValues = data;
    this.selImInd = selInd;
    this.imHeight = height;
    this.imWidth = width;
    this.minValue = minVal;
    this.maxValue = maxVal;
    this.jLName.setText(name);
    this.numChHist = 20;
    this.listener = listen;

    jTFChNumHist.setText(String.valueOf(numChHist));
    jTFMaxValue.setText(String.valueOf(maxValue));
    jTFMinValue.setText(String.valueOf(minValue));

    jPHist.add(updateHistPanel(data, minValue, maxValue, numChHist));

    IntensImageDataset dataValuesDataset =
        new IntensImageDataset(imHeight, imWidth, new double[imWidth * imHeight]);
    for (int i = 0; i < dataValues.length; i++) {
      dataValuesDataset.SetValue(selImInd[i], dataValues[i]);
    }
    PaintScale ps = new RainbowPaintScale(0.001, maxValue);
    JFreeChart aveLifetimeChart =
        createScatChart(
            ImageUtilities.createColorCodedImage(dataValuesDataset, ps), ps, imWidth, imHeight);
    ChartPanel aveLifetimePanel = new ChartPanel(aveLifetimeChart);
    aveLifetimePanel.setFillZoomRectangle(true);
    aveLifetimePanel.setMouseWheelEnabled(true);
    aveLifetimePanel.addChartMouseListener(listener);
    jPImage.add(aveLifetimePanel);
  }
 /**
  * Private Methode, die dem übergebenen JTabbedPane ein Stabdiagramm mit den Parametern hinzufügt.
  *
  * @param tabs JTabbedPane
  * @param daten Daten
  * @param kopfZeile Beschriftung
  * @param titel Titel
  * @param start Start der Daten
  */
 private void fuegeStabdiagrammHinzu(
     JTabbedPane tabs,
     Object[][] daten,
     Object[] kopfZeile,
     String titel,
     String reihenBeschriftung,
     String spaltenBeschriftung,
     int start) {
   CategoryDataset dataset = erstelleDatensatz(daten, kopfZeile, start);
   JFreeChart chart = erstelleDiagramm(dataset, titel, reihenBeschriftung, spaltenBeschriftung);
   ChartPanel chartPanel = new ChartPanel(chart);
   chartPanel.setFillZoomRectangle(true);
   chartPanel.setMouseWheelEnabled(true);
   chartPanel.setPreferredSize(new Dimension(500, 270));
   tabs.addTab(
       titel,
       new JScrollPane(
           chartPanel,
           JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
           JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED));
 }
Esempio n. 12
0
  private void run() {

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(800, 600);
    // This is a little shortcut that results in the window being centred
    frame.setLocationRelativeTo(null);
    frame.setTitle("Updating time series JFreeChart");

    final TimeSeriesCollection dataset = new TimeSeriesCollection();
    JFreeChart chart = createChart(dataset);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseWheelEnabled(true);

    frame.getContentPane().add(chartPanel);

    frame.setVisible(true);

    Timer timer = new Timer();
    TimerTask timerTask =
        new TimerTask() {
          @Override
          public void run() {
            // Wrap in invoke later as we'll be potentially updating the gui based on model changes
            SwingUtilities.invokeLater(
                new Runnable() {
                  @Override
                  public void run() {
                    updateChartWithNewData(dataset);
                  }
                });
          }
        };

    timer.schedule(timerTask, 1000, 1000);
  }
Esempio n. 13
0
  @Override
  public void initComponents() {
    dataset = new XYSeriesCollection();

    JFreeChart chart =
        ComponentFactory.createXYBarChart(
            K1105_SC.getValue(), K1106_SL.getValue(), dataset, (XYItemLabelGenerator) null);

    XYPlot plot = chart.getXYPlot();
    plot.setDomainPannable(true);
    plot.setRangePannable(true);
    final String scLabel = "<html>" + K1105_SC.getValue() + ": ";
    final String slLabel = "<br>" + K1106_SL.getValue() + ": ";

    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setBarAlignmentFactor(0);
    renderer.setMargin(0.2);

    renderer.setSeriesToolTipGenerator(
        0,
        new XYToolTipGenerator() {
          @Override
          public String generateToolTip(XYDataset dataset, int arg1, int arg2) {
            int scNum = (int) dataset.getXValue(arg1, arg2);
            int slCount = (int) dataset.getYValue(arg1, arg2);
            return scLabel + scNum + slLabel + slCount + "</html>";
          }
        });
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    chartPanel = new ChartPanel(chart);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setPreferredSize(PREFERRED_CHART_SIZE);
    propsPanel.add(chartPanel);
  }
Esempio n. 14
0
  private void createUI() {

    final XYPlot plot = getPlot();
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
    plot.setNoDataMessage(NO_DATA_MESSAGE);
    int confidenceDSIndex = 0;
    int regressionDSIndex = 1;
    int scatterpointsDSIndex = 2;
    plot.setDataset(confidenceDSIndex, acceptableDeviationDataset);
    plot.setDataset(regressionDSIndex, regressionDataset);
    plot.setDataset(scatterpointsDSIndex, scatterpointsDataset);

    plot.addAnnotation(r2Annotation);

    final DeviationRenderer identityRenderer = new DeviationRenderer(true, false);
    identityRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT);
    identityRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT);
    plot.setRenderer(confidenceDSIndex, identityRenderer);

    final DeviationRenderer regressionRenderer = new DeviationRenderer(true, false);
    regressionRenderer.setSeriesPaint(0, StatisticChartStyling.REGRESSION_DATA_PAINT);
    regressionRenderer.setSeriesFillPaint(0, StatisticChartStyling.REGRESSION_DATA_FILL_PAINT);
    plot.setRenderer(regressionDSIndex, regressionRenderer);

    final XYErrorRenderer scatterPointsRenderer = new XYErrorRenderer();
    scatterPointsRenderer.setDrawXError(true);
    scatterPointsRenderer.setErrorStroke(new BasicStroke(1));
    scatterPointsRenderer.setErrorPaint(StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT);
    scatterPointsRenderer.setSeriesShape(0, StatisticChartStyling.CORRELATIVE_POINT_SHAPE);
    scatterPointsRenderer.setSeriesOutlinePaint(
        0, StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT);
    scatterPointsRenderer.setSeriesFillPaint(0, StatisticChartStyling.CORRELATIVE_POINT_FILL_PAINT);
    scatterPointsRenderer.setSeriesLinesVisible(0, false);
    scatterPointsRenderer.setSeriesShapesVisible(0, true);
    scatterPointsRenderer.setSeriesOutlineStroke(0, new BasicStroke(1.0f));
    scatterPointsRenderer.setSeriesToolTipGenerator(
        0,
        (dataset, series, item) -> {
          final XYIntervalSeriesCollection collection = (XYIntervalSeriesCollection) dataset;
          final Comparable key = collection.getSeriesKey(series);
          final double xValue = collection.getXValue(series, item);
          final double endYValue = collection.getEndYValue(series, item);
          final double yValue = collection.getYValue(series, item);
          return String.format(
              "%s: mean = %6.2f, sigma = %6.2f | %s: value = %6.2f",
              getRasterName(), yValue, endYValue - yValue, key, xValue);
        });
    plot.setRenderer(scatterpointsDSIndex, scatterPointsRenderer);

    final boolean autoRangeIncludesZero = false;
    final boolean xLog = scatterPlotModel.xAxisLogScaled;
    final boolean yLog = scatterPlotModel.yAxisLogScaled;
    plot.setDomainAxis(
        StatisticChartStyling.updateScalingOfAxis(
            xLog, plot.getDomainAxis(), autoRangeIncludesZero));
    plot.setRangeAxis(
        StatisticChartStyling.updateScalingOfAxis(
            yLog, plot.getRangeAxis(), autoRangeIncludesZero));

    createUI(createChartPanel(chart), createInputParameterPanel(), bindingContext);

    plot.getDomainAxis().addChangeListener(domainAxisChangeListener);
    scatterPlotDisplay.setMouseWheelEnabled(true);
    scatterPlotDisplay.setMouseZoomable(true);
  }
Esempio n. 15
0
 public static ChartPanel createPieChart(
     String applicationTitle, String chartTitle, String[] name, double[] number) {
   ChartPanel panel = new ChartPanel(createChart(createDataset(name, number), chartTitle));
   panel.setMouseWheelEnabled(true);
   return panel;
 }
Esempio n. 16
0
  /**
   * @param windowsTitleParam The title of the window.
   * @param chartTitleParam The title of the chart panel.
   * @param xTitleParam The X-axis label.
   */
  public ExternalBasicChart(String windowsTitleParam, String chartTitleParam, String xTitleParam) {

    reportFrecuency = 1;

    menubar = new JMenuBar();
    menubar.add(createMenu());

    max = -1;

    windowsTitle = windowsTitleParam;
    chartTitle = chartTitleParam;
    xTitle = xTitleParam;

    queryNames = new ArrayList<String>();
    evaluationsCollection = new ArrayList<List<AbstractEvaluation>>();
    controlCurveColor = new HashMap<String, Color>();
    set = new HashSet<Integer>();
    setSeries = new HashSet<String>();
    colors = new ArrayList<Color>();

    chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(640, 480));
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseWheelEnabled(true);

    slider = new JSlider(JSlider.HORIZONTAL);
    slider.setPaintTicks(true);
    slider.setPaintLabels(true);
    slider.setToolTipText("Changes the report frecuency");
    slider.setSnapToTicks(true);
    slider.setMinimum(1);
    slider.setMinorTickSpacing(1);

    slider.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(javax.swing.event.ChangeEvent evt) {

            reportFrecuency = ((JSlider) evt.getSource()).getValue();

            slider.setToolTipText(String.valueOf(reportFrecuency));

            jComboBoxItemStateChanged();
          }
        });

    comboBox = new JComboBox<String>();

    comboBox.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent evt) {

            jComboBoxItemStateChanged();
          }
        });

    content = new JPanel(new BorderLayout());
    content.add(comboBox, BorderLayout.NORTH);
    content.add(chartPanel, BorderLayout.CENTER);
    content.add(slider, BorderLayout.SOUTH);

    setJMenuBar(menubar);
    setTitle(windowsTitle);
    setContentPane(this.content);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  }