Example usage for org.jfree.data.time DynamicTimeSeriesCollection DynamicTimeSeriesCollection

List of usage examples for org.jfree.data.time DynamicTimeSeriesCollection DynamicTimeSeriesCollection

Introduction

In this page you can find the example usage for org.jfree.data.time DynamicTimeSeriesCollection DynamicTimeSeriesCollection.

Prototype

public DynamicTimeSeriesCollection(int nSeries, int nMoments, RegularTimePeriod timeSample) 

Source Link

Document

Creates a new dataset.

Usage

From source file:br.com.criativasoft.opendevice.samples.ui.SimpleChart.java

public SimpleChart(final String title, final StreamConnection connection) {
    super(title);

    dataset = new DynamicTimeSeriesCollection(SERIES, COUNT, new Second());
    dataset.setTimeBase(new Second(0, 0, 0, 1, 1, Calendar.getInstance().get(Calendar.YEAR)));

    // Init.//w  ww  . j a  v  a 2  s .  c  o m
    //        for (int i = 0; i < SERIES; i++){
    //            dataset.addSeries(new float[]{0}, i, "Serie " + (i+1));
    //        }
    dataset.addSeries(new float[] { 0, 0, 0 }, 0, "Raw");
    dataset.addSeries(new float[] { 0, 0, 0 }, 1, "Software");
    dataset.addSeries(new float[] { 0, 0, 0 }, 2, "Hardware");

    this.connection = connection;

    // connection.setStreamReader(new FixedStreamReader(1));

    JFreeChart chart = createChart(dataset);

    final JButton run = new JButton(START);
    run.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {

            String cmd = e.getActionCommand();
            JButton source = (JButton) e.getSource();

            try {

                if (cmd.equals(START)) {
                    connection.addListener(SimpleChart.this);
                    if (!connection.isConnected())
                        connection.connect();

                    source.setText(STOP);
                    source.setActionCommand(STOP);
                } else {
                    connection.removeListener(SimpleChart.this);
                    source.setText(START);
                    source.setActionCommand(START);
                }

            } catch (ConnectionException e1) {
                e1.printStackTrace();
            }

        }
    });

    final JComboBox combo = new JComboBox();

    if (connection instanceof UsbConnection) {

        Collection<String> portNames = UsbConnection.listAvailablePortNames();
        for (String name : portNames) {
            combo.addItem(name);
        }

    }

    combo.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {

            Object selectedItem = combo.getSelectedItem();

        }
    });

    this.add(new ChartPanel(chart), BorderLayout.CENTER);
    JPanel btnPanel = new JPanel(new FlowLayout());
    btnPanel.add(run);
    btnPanel.add(combo);
    this.add(btnPanel, BorderLayout.SOUTH);

}

From source file:be.nbb.demetra.dfm.DfmExecViewTopComponent.java

DfmExecViewTopComponent(WorkspaceItem<VersionedDfmDocument> document, DfmController controller) {
    super(document, controller);
    initComponents();// w ww .j  a va  2  s.  c  o  m
    setToolTipText(Bundle.HINT_DfmExecViewTopComponent());

    jEditorPane1.setEditable(false);

    dataset = new DynamicTimeSeriesCollection(1, 200, new Second());
    dataset.setTimeBase(new Second());
    dataset.addSeries(new float[] {}, 0, "loglikelihood");
}

From source file:org.ewhoxford.swt.bloodpressure.ui.MeasurePageTab.java

/**
 * Creates the bp measure layout./*from  w w  w .j  a  va  2s  . com*/
 */
void createLayout() {
    fillLayout = new FillLayout();
    layoutComposite.setLayout(fillLayout);

    // this.bpMeasureSeries = new TimeSeries("BP signal");

    dataset = new DynamicTimeSeriesCollection(1, COUNT, new Second());
    dataset.setTimeBase(new Second(0, 0, 0, 1, 1, 2011));
    float[] a = { 0F };
    dataset.addSeries(a, 0, "pressure");

    //dataset.addSeries(this.bpMeasureSeries);

    final JFreeChart chart = createChart(dataset, bpMeasureXYPlot);
    frame = new ChartComposite(layoutComposite, SWT.NONE, chart, false, true, true, false, false);
    // frame.setRangeZoomable(false);
    // ChartComposite frame = new ChartComposite(layoutComposite, SWT.NONE,
    // chart, true);
    frame.setDisplayToolTips(true);
    frame.setHorizontalAxisTrace(false);
    frame.setVerticalAxisTrace(false);
    frame.setRangeZoomable(false);
    // frame.chartChanged(new );
    // getInstance and position datasets:
    data = new SerialDynamicXYDatasource();
    // SampleDynamicSeries signalSeries = new SampleDynamicSeries(data, 0,
    // "Blood Pressure");

    // register plot with plot updater observer
    plotUpdater = new MyPlotUpdater(bpMeasureXYPlot);

    data.addObserver(plotUpdater);
    // start observable datasource thread
    new Thread(data).start();

}