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();
  }
Exemple #2
0
 /** Fills the panel with event specific fields. */
 protected void fillPanel() {
   JLabel l;
   Box fdp = Box.createVerticalBox();
   fdp.setBorder(BorderFactory.createTitledBorder("Fundamental Diagram"));
   fdChart = makeFDChart();
   ChartPanel cp = new ChartPanel(fdChart);
   cp.setMinimumDrawWidth(100);
   cp.setMinimumDrawHeight(60);
   cp.setPreferredSize(new Dimension(250, 80));
   fdp.add(new JScrollPane(cp));
   JPanel prmp = new JPanel(new SpringLayout());
   l = new JLabel("Capacity:", JLabel.TRAILING);
   prmp.add(l);
   spinMaxFlow = new JSpinner(new SpinnerNumberModel(mf, 0, 99999, 1.0));
   spinMaxFlow.setEditor(new JSpinner.NumberEditor(spinMaxFlow, "####0.00"));
   spinMaxFlow.addChangeListener(this);
   spinMaxFlow.setName(nmSpinMaxFlow);
   l.setLabelFor(spinMaxFlow);
   prmp.add(spinMaxFlow);
   l = new JLabel("Cap.Drop:", JLabel.TRAILING);
   prmp.add(l);
   spinCapDrop = new JSpinner(new SpinnerNumberModel(drp, 0, 99999, 1.0));
   spinCapDrop.setEditor(new JSpinner.NumberEditor(spinCapDrop, "####0.00"));
   spinCapDrop.addChangeListener(this);
   spinCapDrop.setName(nmSpinCapDrop);
   l.setLabelFor(spinCapDrop);
   prmp.add(spinCapDrop);
   l = new JLabel("C.Density:", JLabel.TRAILING);
   prmp.add(l);
   spinCritDen = new JSpinner(new SpinnerNumberModel(cd, 0, 99999, 1.0));
   spinCritDen.setEditor(new JSpinner.NumberEditor(spinCritDen, "####0.00"));
   spinCritDen.addChangeListener(this);
   spinCritDen.setName(nmSpinCritDen);
   l.setLabelFor(spinCritDen);
   prmp.add(spinCritDen);
   l = new JLabel("  V:", JLabel.TRAILING);
   prmp.add(l);
   spinVff = new JSpinner(new SpinnerNumberModel(mf / cd, 0, 200, 1.0));
   spinVff.setEditor(new JSpinner.NumberEditor(spinVff, "#0.00"));
   spinVff.addChangeListener(this);
   spinVff.setName(nmSpinVff);
   l.setLabelFor(spinVff);
   prmp.add(spinVff);
   l = new JLabel("J.Density:", JLabel.TRAILING);
   prmp.add(l);
   spinJamDen = new JSpinner(new SpinnerNumberModel(jd, 0, 99999, 1.0));
   spinJamDen.setEditor(new JSpinner.NumberEditor(spinJamDen, "####0.00"));
   spinJamDen.addChangeListener(this);
   spinJamDen.setName(nmSpinJamDen);
   l.setLabelFor(spinJamDen);
   prmp.add(spinJamDen);
   l = new JLabel("  W:", JLabel.TRAILING);
   prmp.add(l);
   if (jd == cd) jd = cd + 1;
   int ulim = (int) Math.max(Math.ceil(mf / (jd - cd)), 999);
   spinWc = new JSpinner(new SpinnerNumberModel(mf / (jd - cd), 0, ulim, 1.0));
   spinWc.setEditor(new JSpinner.NumberEditor(spinWc, "#0.00"));
   spinWc.addChangeListener(this);
   spinWc.setName(nmSpinWc);
   l.setLabelFor(spinWc);
   prmp.add(spinWc);
   SpringUtilities.makeCompactGrid(prmp, 3, 4, 2, 2, 2, 2);
   fdp.add(prmp);
   // add(new JScrollPane(fdp));
   add(fdp);
   return;
 }