Example #1
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();
  }
Example #2
0
  /** converts data into a candlestick chart */
  public void convert() {

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