Ejemplo n.º 1
0
  /**
   * temporal helper function
   *
   * @param dataset
   * @return
   */
  private JFreeChart createChart(TimeSeriesCollection dataset) {

    NumberAxis axis = new NumberAxis(null);
    axis.setAutoRangeIncludesZero(false);

    // parent=new CombinedRangeXYPlot(axis);

    // chart = null;

    // XYPlot plot2=new XYPlot(dataset2, new DateAxis(null), null, new StandardXYItemRenderer());
    // XYPlot subplot2=new XYPldt(dataset2, new DateAxis("Date 2"), null, )

    // parent.add(subplot1);
    // parent.add(subplot2);

    // chart=new JFreeChart(null, null, parent, false);

    chart = ChartFactory.createTimeSeriesChart(null, "", "", dataset, false, false, false);

    XYPlot plot1 = chart.getXYPlot();

    plot1.setDataset(dataset);
    plot1.setRenderer(new StandardXYItemRenderer());

    plot1.setSecondaryDataset(0, hld);
    CandlestickRenderer c1 = new CandlestickRenderer();

    // c1.setAutoWidthFactor(1.0);
    // c1.setAutoWidthGap(0.1);
    c1.setBasePaint(new Color(255, 255, 255));
    c1.setBaseOutlinePaint(new Color(255, 255, 255));

    c1.setPaint(new Color(255, 255, 255));

    c1.setUpPaint(new Color(255, 0, 0, 80));
    c1.setDownPaint(new Color(0, 255, 0, 80));

    plot1.setSecondaryRenderer(0, c1);

    // plot1.setSecondaryDataset(0, dataset2);

    XYDotRenderer xd1 = new XYDotRenderer();
    // plot1.setSecondaryRenderer(0, new AreaXYRenderer(AreaXYRenderer.AREA_AND_SHAPES));
    // plot1.setSecondaryRenderer(0, xd1);

    // chart=new JFreeChart("", null, plot1, false);

    chart.setBackgroundPaint(new Color(0, 0, 0));

    return chart;
  }
Ejemplo n.º 2
0
 /** Creates fundamental diagram chart. */
 private JFreeChart makeFDChart() {
   updateFDSeries();
   XYSeriesCollection dataset = new XYSeriesCollection();
   dataset.addSeries(ffFD);
   dataset.addSeries(cFD);
   dataset.addSeries(cdFD);
   JFreeChart chart =
       ChartFactory.createXYLineChart(
           null, // chart title
           "Density (vpm)", // x axis label
           "Flow (vph)", // y axis label
           dataset, // data
           PlotOrientation.VERTICAL,
           false, // include legend
           false, // tooltips
           false // urls
           );
   XYPlot plot = (XYPlot) chart.getPlot();
   plot.getRenderer().setSeriesPaint(0, Color.GREEN);
   plot.getRenderer().setSeriesPaint(1, Color.RED);
   plot.getRenderer().setSeriesPaint(2, Color.BLUE);
   plot.getRenderer().setStroke(new BasicStroke(2));
   return chart;
 }
Ejemplo n.º 3
0
  public ChartWindow(String title) {

    this.symbol = title;
    thisp = this;
    // initialize the main layout
    setTitle(title);
    mainpanel = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    mainpanel.setLayout(gbl);

    // build a toolbar
    //		add a plain status bar
    this.statusLine = new JLabel("Done");
    this.getContentPane().add(statusLine, BorderLayout.SOUTH);

    statusLine.setBackground(new Color(0, 0, 0));
    statusLine.setForeground(new Color(255, 255, 255));
    statusLine.setOpaque(true);

    //
    x1 = new TimeSeries("symbol", FixedMillisecond.class);
    dataset1.addSeries(x1);

    System.out.println("Populated.");

    //
    chart = createChart(dataset1);
    System.out.println("constr.");

    // chart.getXYPlot().setOrientation(PlotOrientation.VERTICAL);

    chart.setAntiAlias(false);

    chartPanel = new ChartPanel(chart);

    //

    int i = 0;
    gbc.anchor = gbc.NORTHWEST;
    gbc.fill = gbc.BOTH;
    gbc.weightx = 1;
    gbc.gridx = 0;

    gbc.weighty = 1;
    gbc.gridy = i;
    gbl.setConstraints(chartPanel, gbc);

    mainpanel.add(chartPanel);
    // System.out.println("add");
    setVisible(true);
    setSize(new Dimension(400, 300));

    // chartPanel.setPopupMenu(buildPopupMenu());
    chartPanel.setMouseZoomable(true);
    chartPanel.setHorizontalAxisTrace(true);
    chartPanel.setVerticalAxisTrace(true);
    chartPanel.setHorizontalZoom(true);

    chartPanel.setOpaque(true);
    chartPanel.setBackground(new Color(0, 0, 0));

    this.getContentPane().add(mainpanel, BorderLayout.CENTER);

    this.setSize(600, 400);
    this.toFront();
    this.show();
  }
Ejemplo n.º 4
0
  /** converts data into a candlestick chart */
  public void convert() {

    chart.setAntiAlias(false);
    chartPanel.setChart(chart);
  }