@Override
  public void display(HashBasedTable<String, String, Double> data) {

    roomToCodeMapping = generateNewRoomToCodeMapping();
    dataSet = createDataSet(data);
    final JFreeChart chart = createChart(dataSet);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(1000, 540));
    createNewFrameAndSetLocation();
    currentFrame.setTitle(this.getTitle());
    currentFrame.setContentPane(chartPanel);
    currentFrame.setVisible(true);
    currentFrame.setSize(new Dimension(1020, 560));
    currentFrame.addWindowListener(this);

    if (type == MarkovDataDialog.HeatMapType.COMPARISON) {
      unscaledDifferenceSlider.setLabelTable(unscaledDifferenceSlider.createStandardLabels(5, 5));
      differenceSelectorFrame = new JFrame("Choose Size of difference");
      differenceSelectorFrame.setLayout(new BorderLayout());
      differenceSelectorFrame.add(unscaledDifferenceSlider, BorderLayout.NORTH);

      statusLabel.setHorizontalAlignment(SwingConstants.CENTER);
      statusLabel.setText("Current difference size:" + this.unscaledDifference);

      differenceSelectorFrame.add(statusLabel, BorderLayout.CENTER);

      differenceSelectorFrame.add(regenerate, BorderLayout.SOUTH);

      regenerate.addActionListener(this);

      differenceSelectorFrame.setLocation(100, 10);
      differenceSelectorFrame.setSize(300, 200);
      differenceSelectorFrame.setVisible(true);
    }
  }
Esempio n. 2
0
  protected void jComboBoxItemStateChanged() {

    try {

      XYDataset dataset;
      String yTitle;

      if (comboBox.getItemCount() != 0) {

        dataset = createDataset(comboBox.getSelectedItem().toString());
        yTitle = comboBox.getSelectedItem().toString();
      } else {
        dataset = null;
        yTitle = new String();
      }

      createChart(dataset, chartTitle, xTitle, yTitle);

      chartPanel.removeAll();

      chartPanel.setChart(chart);

      chartPanel.repaint();

    } catch (Exception e) {
    }
  }
Esempio n. 3
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. 4
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;
 }
  /**
   * This method renders a line chart of income and expense entries over 1-month intervals
   *
   * @param dataset
   * @return financesLineChart_PNL
   */
  private ChartPanel renderLineChart(XYDataset dataset) {

    // Create JFreeChart with dataSet
    JFreeChart lineChart =
        ChartFactory.createTimeSeriesChart("", "", "Amount", dataset, true, true, false);

    // Change the x-axis (time interval) format
    XYPlot plot = (XYPlot) lineChart.getPlot();
    DateAxis dateAxis = (DateAxis) plot.getDomainAxis();
    dateAxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));

    // Change the chart's visual properties
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
      XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
      renderer.setBaseShapesVisible(true);
      renderer.setBaseShapesFilled(true);
      renderer.setDrawSeriesLineAsPath(true);
    }

    // Create and format the chart panel
    ChartPanel financesLineChart_PNL =
        new ChartPanel(lineChart, 600, 250, 200, 100, 800, 300, true, true, true, true, true, true);
    financesLineChart_PNL.setSize(800, 300);

    return financesLineChart_PNL;
  }
 /*     */ 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. 7
0
 public GraficoProdotto(int id) throws Exception {
   super("Grafico PRODOTTO");
   //        GraficoProdotto.this.windowClosing(event);
   ChartPanel chartPanel = (ChartPanel) createDemoPanel(id);
   chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
   setContentPane(chartPanel);
 }
Esempio n. 8
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
Esempio n. 9
0
  public void onSimulationComplete() {
    // TODO Auto-generated method stub

    this.removeAll();

    synchronized (this) {
      chartPanel = newChart(data);
    }

    this.setLayout(new BorderLayout());
    add(chartPanel, (new BorderLayout()).CENTER);

    chartPanel.updateUI();

    File file;

    try {
      file = new File(outputpath);
    } catch (Exception e) {
      System.err.println("Graph Plugin " + label + " : Invalid output path" + e);
      return;
    }

    try {
      int width = 1920;
      int height = 1200;
      ChartUtilities.saveChartAsPNG(file, chartPanel.getChart(), width, height);
    } catch (Exception e) {
      System.out.println("Problem occurred creating chart." + label);
    }
  }
  @Override
  public void draw(
      Graphics2D g2,
      XYPlot plot,
      Rectangle2D dataArea,
      ValueAxis domainAxis,
      ValueAxis rangeAxis,
      int rendererIndex,
      PlotRenderingInfo info) {

    Rectangle2D box = chartPanel.getScreenDataArea();
    float sx = (float) plot.getDomainAxis().valueToJava2D(x, box, plot.getDomainAxisEdge());
    float maxXLim = (float) box.getWidth() - g2.getFontMetrics().stringWidth(text);
    if (sx > maxXLim) {
      sx = maxXLim;
    }
    if (sx < box.getMinX()) {
      sx = (float) box.getMinX();
    }

    float sy =
        (float)
            plot.getRangeAxis()
                .valueToJava2D(y, chartPanel.getScreenDataArea(), plot.getRangeAxisEdge());
    g2.setTransform(new AffineTransform());
    g2.setColor(color);
    g2.setFont(font);
    g2.drawString(text, sx, sy);
  }
  /**
   * 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;
 }
  private void crearImagen() {

    XYSeries serie = new XYSeries("Serie");
    Iterator<Double> iterator = ejercicio.getHistoricoSolucion().iterator();
    for (int i = 0; i < ejercicio.getHistoricoSolucion().size(); i++) {
      serie.add(i, iterator.next());
    }

    XYSeriesCollection coleccionSeries = new XYSeriesCollection();
    coleccionSeries.addSeries(serie);

    JFreeChart chart =
        ChartFactory.createXYLineChart(
            "Comportamiento Simulated Annealing",
            "Ciclo",
            "Solucion",
            coleccionSeries,
            PlotOrientation.VERTICAL,
            false,
            false,
            true);

    ChartPanel panel = new ChartPanel(chart);
    panel.setMouseZoomable(true);
    this.add(panel);
  }
Esempio n. 14
0
  /** Places all components (graphs) in the panel. */
  private void placeComponents() {
    final GridBagConstraints constraints = new GridBagConstraints();

    int numberOfComponentsPlaced = 0;
    int currXPos = 0;
    final int graphHeight = 150;
    final int graphWidth = 100;

    final Collection<String> datastreams = statisticsManager.getAvailableDatastreams();
    for (final String streamname : datastreams) {
      LOG.info("drawing stream");
      constraints.fill = GridBagConstraints.HORIZONTAL;
      constraints.weightx = 0.5;
      constraints.gridx = currXPos;
      constraints.gridy = numberOfComponentsPlaced / 2;
      constraints.insets = new Insets(10, 0, 0, 0);

      final DecoratedGraph graph =
          new DecoratedGraph((long) 10 * 60 * 1000, statisticsManager.getDatastream(streamname));
      graph.registerRelativeDatastream(server, streamname, Color.GREEN);
      graph.addServerToRefresh(server);
      final ChartPanel chartPanel = graph.getChartPanel();
      chartPanel.setPreferredSize(new Dimension(graphWidth, graphHeight));
      add(chartPanel, constraints);

      if (currXPos == 0) {
        currXPos = 1;
      } else {
        currXPos = 0;
      }
      numberOfComponentsPlaced++;
    }
  }
Esempio n. 15
0
  public void setComposite(PortfolioComposite composite) {
    this.portfolioComposite = composite;

    mainChartPanel.getPopupMenu().addSeparator();
    JMenuItem manQuote = new JMenuItem("Add a quotation");
    manQuote.addActionListener(portfolioComposite.new ManualQuotationSelectionListener());
    mainChartPanel.getPopupMenu().add(manQuote);
  }
Esempio n. 16
0
 private void init() {
   ChartPanel localChartPanel = new ChartPanel(chart, true);
   localChartPanel.setBorder(
       BorderFactory.createCompoundBorder(
           BorderFactory.createEmptyBorder(4, 4, 4, 4),
           BorderFactory.createLineBorder(Color.black)));
   add(localChartPanel);
 }
Esempio n. 17
0
 /**
  * Creates a new demo.
  *
  * @param title the frame title.
  */
 public AbsoluteAccurcyChart(final String title) {
   super(title);
   final XYDataset dataset = createDataset();
   final JFreeChart chart = createChart(dataset);
   final ChartPanel chartPanel = new ChartPanel(chart);
   chartPanel.setPreferredSize(new Dimension(900, 570));
   setContentPane(chartPanel);
 }
Esempio n. 18
0
 /**
  * Creates a new demo.
  *
  * @param title the frame title.
  */
 public LineChartDemo5(final String title) {
   super(title);
   final CategoryDataset dataset = createDataset();
   final JFreeChart chart = createChart(dataset);
   final ChartPanel chartPanel = new ChartPanel(chart);
   chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
   setContentPane(chartPanel);
 }
Esempio n. 19
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;
 }
 /**
  * Creates a new demo.
  *
  * @param title the frame title.
  */
 public HistogramDemo2(final String title) {
   super(title);
   final IntervalXYDataset dataset = createDataset();
   final JFreeChart chart = createChart(dataset);
   final ChartPanel chartPanel = new ChartPanel(chart);
   chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
   setContentPane(chartPanel);
 }
Esempio n. 21
0
 public XySplineChart(final String title, double[][] dataMatrix, String[] names) {
   super(title);
   IntervalXYDataset dataset = createDataset(dataMatrix, names);
   JFreeChart chart = createChart(dataset);
   final ChartPanel chartPanel = new ChartPanel(chart);
   chartPanel.setPreferredSize(new java.awt.Dimension(1280, 800));
   setContentPane(chartPanel);
 }
Esempio n. 22
0
 public LineChartDemo2(String s) {
   super(s);
   XYDataset xydataset = createDataset();
   JFreeChart jfreechart = createChart(xydataset);
   ChartPanel chartpanel = new ChartPanel(jfreechart);
   chartpanel.setPreferredSize(new Dimension(500, 270));
   setContentPane(chartpanel);
 }
Esempio n. 23
0
 public AccelPlot(String titulo, String eixoX, String eixoY, XYDataset dados) {
   super(titulo);
   final XYDataset dataset = dados;
   final JFreeChart chart = createChart(titulo, eixoX, eixoY, dataset);
   final ChartPanel chartPanel = new ChartPanel(chart);
   chartPanel.setPreferredSize(new java.awt.Dimension(1400, 800));
   setContentPane(chartPanel);
 }
 public StatisticalLineChartDemo1(String s) {
   super(s);
   CategoryDataset categorydataset = createDataset();
   JFreeChart jfreechart = createChart(categorydataset);
   ChartPanel chartpanel = new ChartPanel(jfreechart);
   chartpanel.setPreferredSize(new Dimension(500, 270));
   setContentPane(chartpanel);
 }
  /**
   * Constructs a new demonstration application.
   *
   * @param title the frame title.
   */
  public DynamicDataDemo3(String title) {

    super(title);

    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Time"));
    this.datasets = new TimeSeriesCollection[SUBPLOT_COUNT];

    for (int i = 0; i < SUBPLOT_COUNT; i++) {
      this.lastValue[i] = 100.0;
      TimeSeries series = new TimeSeries("Random " + i, Millisecond.class);
      this.datasets[i] = new TimeSeriesCollection(series);
      NumberAxis rangeAxis = new NumberAxis("Y" + i);
      rangeAxis.setAutoRangeIncludesZero(false);
      XYPlot subplot = new XYPlot(this.datasets[i], null, rangeAxis, new StandardXYItemRenderer());
      subplot.setBackgroundPaint(Color.lightGray);
      subplot.setDomainGridlinePaint(Color.white);
      subplot.setRangeGridlinePaint(Color.white);
      plot.add(subplot);
    }

    JFreeChart chart = new JFreeChart("Dynamic Data Demo 3", plot);
    chart.getLegend().setAnchor(Legend.EAST);
    chart.setBorderPaint(Color.black);
    chart.setBorderVisible(true);
    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 4, 4, 4, 4));
    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    axis.setFixedAutoRange(60000.0); // 60 seconds

    JPanel content = new JPanel(new BorderLayout());

    ChartPanel chartPanel = new ChartPanel(chart);
    content.add(chartPanel);

    JPanel buttonPanel = new JPanel(new FlowLayout());

    for (int i = 0; i < SUBPLOT_COUNT; i++) {
      JButton button = new JButton("Series " + i);
      button.setActionCommand("ADD_DATA_" + i);
      button.addActionListener(this);
      buttonPanel.add(button);
    }
    JButton buttonAll = new JButton("ALL");
    buttonAll.setActionCommand("ADD_ALL");
    buttonAll.addActionListener(this);
    buttonPanel.add(buttonAll);

    content.add(buttonPanel, BorderLayout.SOUTH);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 470));
    chartPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    setContentPane(content);
  }
Esempio n. 26
0
 public PeriodAxisDemo2(String s) {
   super(s);
   XYDataset xydataset = createDataset();
   JFreeChart jfreechart = createChart(xydataset);
   ChartPanel chartpanel = new ChartPanel(jfreechart);
   chartpanel.setPreferredSize(new Dimension(500, 270));
   chartpanel.setMouseZoomable(true, true);
   setContentPane(chartpanel);
 }
  public static ChartPanel createBubbleChart() {
    JFreeChart jfreechart = createChart(createXYZDataset());
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    chartpanel.setBorder(BorderFactory.createEtchedBorder());

    chartpanel.setDomainZoomable(true);
    chartpanel.setRangeZoomable(true);
    return chartpanel;
  }
Esempio n. 28
0
  public Chart(float[] data, int size) {
    super("title");

    final XYDataset dataset = createDataset(data, size);
    final JFreeChart chart = createChart(dataset);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);
  }
Esempio n. 29
0
  protected void initialize() {
    setLayout(new GridLayout(1, 1));
    seriescollection = new XYSeriesCollection();
    JFreeChart chart = createDaySeriesChartWithColors(null, seriescollection, true);
    ChartPanel chartpanel = new ChartPanel(chart, false);
    chartpanel.setMouseZoomable(true, false);

    add(chartpanel);
  }
 private ApplicationFrame createFrame(final GraphBuilder builder) {
   final ApplicationFrame frame = new ApplicationFrame(builder.windowTitle());
   final ChartPanel chartPanel = new ChartPanel(chart);
   chartPanel.setPreferredSize(new java.awt.Dimension(XDIM, YDIM));
   frame.setContentPane(chartPanel);
   frame.pack();
   RefineryUtilities.positionFrameRandomly(frame);
   return frame;
 }