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

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

Introduction

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

Prototype

public TimeSeriesCollection() 

Source Link

Document

Constructs an empty dataset, tied to the default timezone.

Usage

From source file:ws.moor.bt.gui.charts.RawDownloadRate.java

private TimeSeriesCollection getTimeSeriesCollection() {
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(dataSource.getTimeSeries());
    dataset.addSeries(createAverageSeries(dataSource.getTimeSeries()));
    return dataset;
}

From source file:org.mwc.debrief.sensorfusion.views.MouseClickSolutionDemo.java

/**
 * @param title/*  w ww  .j  a va 2 s. c  om*/
 *            the frame title.
 */
public MouseClickSolutionDemo(final String title) {
    super(title);

    final TimeSeries s1 = new TimeSeries("Series to click");
    s1.add(new Month(2, 2001), 181.8);
    s1.add(new Month(3, 2001), 167.3);
    s1.add(new Month(4, 2001), 153.8);
    s1.add(new Month(5, 2001), 167.6);
    s1.add(new Month(6, 2001), 152.8);
    s1.add(new Month(7, 2001), 148.3);
    s1.add(new Month(8, 2001), 153.9);
    s1.add(new Month(9, 2001), 142.7);
    s1.add(new Month(10, 2001), 123.2);

    final TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(s1);

    final JFreeChart chart = ChartFactory.createTimeSeriesChart("[Alt]-click to switch orientation", // title
            "Time axis", // x-axis label
            "Value axis", // y-axis label
            dataset, // data
            false, // create legend?
            false, // generate tooltips?
            false // generate URLs?
    );

    //FIX IS HERE
    fixProblem(chart);

    final ChartPanel chartPanel = new ChartPanel(chart);

    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));

    chartPanel.addChartMouseListener(new ChartMouseListener() {
        public void chartMouseMoved(final ChartMouseEvent arg0) {
        }

        public void chartMouseClicked(final ChartMouseEvent arg0) {
            System.out.println("clicked on:" + arg0.getEntity());

            if (arg0.getTrigger().isAltDown()) {
                if (chart.getXYPlot().getOrientation() == PlotOrientation.HORIZONTAL)
                    chart.getXYPlot().setOrientation(PlotOrientation.VERTICAL);
                else
                    chart.getXYPlot().setOrientation(PlotOrientation.HORIZONTAL);
            }
        }
    });
    setContentPane(chartPanel);
}

From source file:msec.org.Tools.java

private static XYDataset createDaysDataset(ArrayList<OneDayValue> oneDayValues, GregorianCalendar startgc,
        OneAttrDaysChart chart) {//from ww  w . ja v a 2 s. c  om
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    TimeSeries timeseries = new TimeSeries(
            oneDayValues.get(0).getDate() + "-" + oneDayValues.get(oneDayValues.size() - 1).getDate());
    int sum = 0;
    int max = 0;
    int min = 0;
    Minute current = new Minute(startgc.getTime());
    for (int j = 0; j < oneDayValues.size(); j++) {
        int[] data = oneDayValues.get(j).getValues();
        //check actual length for data
        int len = data.length - 1;
        if (j == oneDayValues.size() - 1) {
            //if last day is today...
            if (oneDayValues.get(j).getDate().equals(Tools.nowString("yyyyMMdd"))) {
                for (int i = len; i >= 0; i--) {
                    if (data[i] != 0) {
                        len = i;
                        break;
                    }
                }
            }
        }
        for (int i = 0; i < len; ++i) {
            timeseries.add(current, (double) (data[i]));
            sum += data[i];
            max = Math.max(max, data[i]);
            if (min == 0)
                min = data[i];
            else if (data[i] != 0)
                min = Math.min(min, data[i]);
            current = (Minute) current.next();
        }
    }
    chart.setMax(max);
    chart.setMin(min);
    chart.setSum(sum);
    timeseriescollection.addSeries(timeseries);
    return timeseriescollection;
}

From source file:org.yccheok.jstock.gui.charting.DynamicChart.java

/** Creates new form DynamicChart */
public DynamicChart() {
    this.price = new TimeSeries("Price");
    // Sets the maximumItemAge attribute, which specifies the maximum age of data items in the series
    // (in terms of the RegularTimePeriod type used by this series). Whenever a new data value is
    // added, any data items that are older than the limit specified by maximumItemAge are automatically
    // discarded/*  www  .j a v  a 2 s  . com*/
    // Maximum 2 hours.
    this.price.setMaximumItemAge(2 * 60 * 60);

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(this.price);

    JFreeChart freeChart = ChartFactory.createTimeSeriesChart(null, null, null, dataset, false, true, false);

    freeChart.setAntiAlias(true);
    while (freeChart.getSubtitleCount() > 0) {
        freeChart.removeSubtitle(freeChart.getSubtitle(0));
    }

    // Due to limited spacing, we remove all information regarding x and y axis
    // as well.
    XYPlot plot = freeChart.getXYPlot();
    plot.getRangeAxis().setVisible(false);
    plot.getDomainAxis().setVisible(false);

    XYItemRenderer renderer1 = plot.getRenderer();
    renderer1.setBaseToolTipGenerator(
            new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                    new SimpleDateFormat("h:mm:ss a"), new DecimalFormat("0.00#")));

    org.yccheok.jstock.charting.Utils.applyChartTheme(freeChart);

    // Disable zoom.
    chartPanel = new ChartPanel(freeChart, true, true, true, false, true);
    chartPanel.setMouseZoomable(false);
}

From source file:org.squale.squaleweb.util.graph.AreaMaker.java

/**
 * Constructeur avec le titre du diagramme
 * /*from  w  ww .j av a2 s.  c  om*/
 * @param pTitle titre du diagramme (peut etre <code>null</code>)
 */
public AreaMaker(String pTitle) {
    mDataSet = new TimeSeriesCollection();
    mTitle = pTitle;
}

From source file:org.squale.squaleweb.util.graph.HistoMaker.java

/**
 * Constructeur avec le titre du diagramme
 * //from ww  w  .  ja  v a2 s  .  c o m
 * @param pTitle titre du diagramme (peut etre <code>null</code>)
 */
public HistoMaker(String pTitle) {
    mDataSet = new TimeSeriesCollection();
    mTitle = pTitle;
}

From source file:compecon.dashboard.panel.AgentsPanel.java

protected ChartPanel createAgentNumberPanel(Currency currency, Class<? extends Agent> agentType) {
    TimeSeriesCollection timeSeriesCollection = new TimeSeriesCollection();

    timeSeriesCollection.addSeries(ApplicationContext.getInstance().getModelRegistry()
            .getNationalEconomyModel(currency).numberOfAgentsModels.get(agentType).getTimeSeries());

    // in case of households
    if (Household.class.isAssignableFrom(agentType)) {
        // show retired households
        timeSeriesCollection.addSeries(ApplicationContext.getInstance().getModelRegistry()
                .getNationalEconomyModel(currency).householdsModel.retiredModel.getTimeSeries());
    }//from  ww w  . j av  a  2 s. com

    JFreeChart chart = ChartFactory.createTimeSeriesChart("# " + agentType.getSimpleName() + " Agents", "Date",
            "# Agents", (XYDataset) timeSeriesCollection, true, true, false);
    configureChart(chart);
    return new ChartPanel(chart);
}

From source file:netplot.TimeSeriesPlotPanel.java

@SuppressWarnings("deprecation")
public void addPlot() {
    int plotIndex = timeSeriesList.size();
    TimeSeries timeSeries = new TimeSeries(plotName, Millisecond.class);
    timeSeriesList.add(timeSeries);//from   www . j  a  va  2 s  .c  o  m

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(timeSeries);
    ((XYPlot) chart.getPlot()).setDataset(plotIndex, dataset);
    genericConfig(chart, (XYPlot) chart.getPlot(), plotIndex);
}

From source file:compecon.dashboard.panel.MoneyPanel.java

protected ChartPanel createKeyInterestRatesPanel() {
    TimeSeriesCollection timeSeriesCollection = new TimeSeriesCollection();

    for (Currency currency : Currency.values())
        timeSeriesCollection.addSeries(ApplicationContext.getInstance().getModelRegistry()
                .getNationalEconomyModel(currency).keyInterestRateModel.getTimeSeries());

    JFreeChart chart = ChartFactory.createTimeSeriesChart("Key Interest Rate", "Date", "Key Interest Rate",
            timeSeriesCollection, true, true, false);
    configureChart(chart);/*from  w w w  .  jav  a 2 s  . c o m*/
    return new ChartPanel(chart);
}

From source file:mediamatrix.gui.JVMMemoryProfilerPanel.java

public JVMMemoryProfilerPanel() {
    initComponents();//w w w.  j  a  v  a 2  s  .c o m
    profiler = new JVMMemoryProfiler(frequency);
    profiler.addListener(new JVMMemoryProfilerListener() {

        @Override
        public void addScore(long t, long f) {
            total.add(new Millisecond(), t);
            free.add(new Millisecond(), f);
        }
    });

    total = new TimeSeries("Total Memory");
    total.setMaximumItemCount(historyCount);
    free = new TimeSeries("Free Memory");
    free.setMaximumItemCount(historyCount);

    final TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(total);
    dataset.addSeries(free);

    final DateAxis domain = new DateAxis("Time");
    final NumberAxis range = new NumberAxis("Memory");
    domain.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    domain.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    range.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    range.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    range.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    final XYItemRenderer renderer = new DefaultXYItemRenderer();
    renderer.setSeriesPaint(0, Color.red);
    renderer.setSeriesPaint(1, Color.green);
    renderer.setBaseStroke(new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));

    final XYPlot plot = new XYPlot(dataset, domain, range, renderer);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    domain.setAutoRange(true);
    domain.setLowerMargin(0.0);
    domain.setUpperMargin(0.0);
    domain.setTickLabelsVisible(true);

    final JFreeChart chart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", Font.BOLD, 24), plot,
            true);
    chart.setBackgroundPaint(Color.white);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(Color.black)));
    chart.getLegend().setItemFont(new Font("SansSerif", Font.PLAIN, 12));

    add(chartPanel, BorderLayout.CENTER);
}