Exemplo n.º 1
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
Exemplo n.º 2
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;
 }
 /*     */ 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;
   /*     */ }
 public static ChartPanel createPanelgraph() {
   JFreeChart chart = createChart(createDataset());
   ChartPanel panel = new ChartPanel(chart);
   panel.setFillZoomRectangle(true);
   panel.setMouseWheelEnabled(true);
   return panel;
 }
Exemplo n.º 5
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.");
    }
  }
Exemplo n.º 6
0
 /**
  * A jpanel with the chart to update the GUI of the amount of income made by the machines.
  *
  * @param IDS - The integers to display.
  * @return A jpanel with the chart inside.
  */
 private JPanel makeIncomeGraph(int[] IDS) {
   AnalyticsEngine engine = new AnalyticsEngine(IDS, manager.localVends.size());
   ChartPanel panel1 = new ChartPanel(engine.generateIncomeGraph());
   panel1.setFillZoomRectangle(true);
   JPanel p1 = new JPanel();
   p1.add(panel1);
   return p1;
 }
Exemplo n.º 7
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;
    }
  }
Exemplo n.º 9
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));
 }
Exemplo n.º 11
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);
  }
Exemplo n.º 12
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);
  }