Example usage for org.jfree.data.time TimeSeries setMaximumItemAge

List of usage examples for org.jfree.data.time TimeSeries setMaximumItemAge

Introduction

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

Prototype

public void setMaximumItemAge(long periods) 

Source Link

Document

Sets the number of time units in the 'history' for the series.

Usage

From source file:org.jfree.chart.demo.PerformanceTest1.java

public static void main2(String as[]) {
    PerformanceTest1 performancetest1 = new PerformanceTest1("Performance Test 1");
    performancetest1.pack();//from w  ww  . j  a  v  a 2 s.  c o  m
    RefineryUtilities.centerFrameOnScreen(performancetest1);
    performancetest1.setVisible(true);
    TimeSeries timeseries = new TimeSeries("Test");
    timeseries.setMaximumItemAge(200L);
    do {
        Millisecond millisecond = new Millisecond();
        long l = System.currentTimeMillis();
        for (int i = 0; i < 200; i++) {
            millisecond = (Millisecond) millisecond.next();
            timeseries.addOrUpdate(millisecond, 1.0D);
        }

        long l1 = System.currentTimeMillis();
        performancetest1.addObservation(l1 - l);
    } while (true);
}

From source file:be.ac.ua.comp.scarletnebula.gui.Graph.java

/**
 * Register a relative datastream coming from server with name streamname
 * and formal title (a displayable name) streamtitle. This stream will be
 * displayed with Color color.// ww w  .  j  a v a 2  s  . c  o  m
 * 
 * If this datastream was already running, historical data will be taken
 * from the stream and be displayed in the graph.
 * 
 * @param server
 *            Server that generates this relative datastream
 * @param streamname
 *            The stream's short ID name (e.g. MEM)
 * @param color
 *            The color this stream will be displayed in
 */
public final void registerRelativeDatastream(final Server server, final String streamname, final Color color) {
    final ServerStatisticsManager manager = server.getServerStatistics();
    manager.addNewDatapointListener(this, streamname);

    final TimeSeries series = new TimeSeries(streamname);
    series.setMaximumItemAge(maximumAge);
    datastreams.put(streamname, series);
    dataset.addSeries(series);

    renderer.setSeriesPaint(maxSeriesID++, color);

    addListOfDatapoints(manager.getHistoricalDatapoints(streamname));
}

From source file:com.bdb.weather.display.stripchart.StripChart.java

/**
 * Add a series to either the right or left dataset.
 * //from w  ww .j  a va2s .  co m
 * @param seriesName The name of the series
 * @param mapToLeftAxis Whether this is for the left or right axis
 * @param color The color to display the line
 */
public void addSeries(String seriesName, boolean mapToLeftAxis, Color color) {
    TimeSeries timeSeries = new TimeSeries(seriesName);
    series.put(seriesName, timeSeries);
    timeSeries.setMaximumItemAge(maxSpanHours * 3600);
}

From source file:uk.co.petertribble.jangle.SnmpChart.java

/**
 * Set the maximum age of the chart. Only oids younger than this age will
 * be shown./*from w w  w.  jav a  2  s .  c  o  m*/
 *
 * @param age The required maximum age in seconds.
 */
public void setMaxAge(int age) {
    maxage = age * 1000;
    for (TimeSeries ts : tsmap.values()) {
        ts.setMaximumItemAge(maxage);
    }
}

From source file:uk.co.petertribble.jangle.SnmpChart.java

private void initialize(List<String> oids, List<String> alloids) {
    allnames = alloids;//w w  w . j  a va2s.co  m
    tsmap = new HashMap<String, TimeSeries>();
    valueMap = new HashMap<String, BigInteger>();
    dataset = new TimeSeriesCollection();
    lastsnap = 0;

    for (String oid : oids) {
        TimeSeries ts = new TimeSeries(smm.prettifyOID(oid));
        ts.setMaximumItemAge(maxage);
        dataset.addSeries(ts);
        tsmap.put(oid, ts);
        valueMap.put(oid, BigInteger.ZERO);
    }

    updateAccessory();

    String ylabel = showdelta ? SnmpResources.getString("CHART.RATE") : SnmpResources.getString("CHART.VALUE");

    chart = ChartFactory.createTimeSeriesChart(charttitle, SnmpResources.getString("CHART.TIME"), ylabel,
            dataset, true, true, false);

    setAxes();

    startLoop();
}

From source file:de.xirp.ui.widgets.panels.LiveChartComposite.java

/**
 * Adds the given key./*from  w  ww  .j a va2 s. co  m*/
 * 
 * @param key
 *          The key.
 */
private void addKey(String key) {
    TimeSeries ts = new TimeSeries(key, Millisecond.class);
    ts.setMaximumItemAge(TIME);
    keySeriesMap.put(key, ts);
    dataset.addSeries(ts);
    pool.addDatapoolReceiveListener(key, listener);
}

From source file:com.fr3ts0n.ecu.gui.application.ObdDataPlotter.java

/**
 * Setter for property graphTime.// ww w.j  ava  2 s.co m
 *
 * @param graphTime New value of property graphTime.
 */
@SuppressWarnings("rawtypes")
public synchronized void setGraphTime(int graphTime) {
    TimeSeries currSer;
    TimeSeriesCollection currDs;
    XYPlot currPlot = (XYPlot) chart.getPlot();
    this.graphTime = graphTime;
    // lop through all datasets
    for (int i = currPlot.getDatasetCount(); i >= 0; --i) {
        currDs = (TimeSeriesCollection) currPlot.getDataset(i);
        // Update all series within dataset
        Iterator it = currDs.getSeries().iterator();
        while (it.hasNext()) {
            currSer = (TimeSeries) it.next();
            currSer.setMaximumItemAge(graphTime);
        }
    }
}

From source file:org.paxle.tools.charts.impl.gui.ChartServlet.java

private JFreeChart createMemoryChart() {
    // init time series
    TimeSeries usedmemSeries = new TimeSeries("Used MEM", Minute.class);
    usedmemSeries.setMaximumItemAge(24 * 60);
    this.seriesMap.put(TSERIES_MEMORY_USAGE, usedmemSeries);

    // init collections and chart
    final TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(usedmemSeries);/*from  w w  w.java  2  s  . c o m*/

    /*
     * INIT CHART
     */
    JFreeChart chart = ChartFactory.createTimeSeriesChart(null, "Time", "Memory [MB]", dataset, true, false,
            false);

    // change axis data format
    ((DateAxis) chart.getXYPlot().getDomainAxis()).setDateFormatOverride(new SimpleDateFormat("HH:mm"));

    long maxMemory = Runtime.getRuntime().maxMemory();
    if (maxMemory != Long.MAX_VALUE) {
        ((NumberAxis) chart.getXYPlot().getRangeAxis()).setRange(0,
                (double) maxMemory / (double) (1024 * 1024));
    }

    chart.setBackgroundPaint(Color.WHITE);
    return chart;
}

From source file:org.paxle.tools.charts.impl.gui.ChartServlet.java

private JFreeChart createPPMChart() {
    /*//from  www  .j  a v  a 2 s. c  om
     * INIT TIME-SERIES 
     */
    final TimeSeriesCollection dataset = new TimeSeriesCollection();

    TimeSeries crawlerPPM = new TimeSeries("Crawler PPM", Minute.class);
    crawlerPPM.setMaximumItemAge(24 * 60);
    dataset.addSeries(crawlerPPM);
    this.seriesMap.put(TSERIES_PPM_CRAWLER, crawlerPPM);

    TimeSeries parserPPM = new TimeSeries("Parser PPM", Minute.class);
    parserPPM.setMaximumItemAge(24 * 60);
    dataset.addSeries(parserPPM);
    this.seriesMap.put(TSERIES_PPM_PARSER, parserPPM);

    TimeSeries indexerPPM = new TimeSeries("Indexer PPM", Minute.class);
    indexerPPM.setMaximumItemAge(24 * 60);
    dataset.addSeries(indexerPPM);
    this.seriesMap.put(TSERIES_PPM_INDEXER, indexerPPM);

    /*
     * INIT CHART
     */
    JFreeChart chart = ChartFactory.createTimeSeriesChart(null, "Time", "PPM", dataset, true, false, false);

    // change axis data format
    ((DateAxis) chart.getXYPlot().getDomainAxis()).setDateFormatOverride(new SimpleDateFormat("HH:mm"));
    chart.setBackgroundPaint(Color.WHITE);
    return chart;
}

From source file:org.paxle.tools.charts.impl.gui.ChartServlet.java

private JFreeChart createIndexChart() {
    // init Time-Series
    TimeSeries indexSizeSeries = new TimeSeries("Index Size", Minute.class);
    indexSizeSeries.setMaximumItemAge(24 * 60);
    this.seriesMap.put(TSERIES_INDEX_SIZE, indexSizeSeries);

    // init chart
    JFreeChart chart = ChartFactory.createTimeSeriesChart(null, "Time", "#Docs",
            new TimeSeriesCollection(indexSizeSeries), true, false, false);

    XYPlot plot = chart.getXYPlot();/*from   w ww .  j  av  a2 s  .  c o m*/

    final TimeSeriesCollection linksDataset = new TimeSeriesCollection();

    TimeSeries totalLinksSeries = new TimeSeries("Total URI", Minute.class);
    totalLinksSeries.setMaximumItemAge(24 * 60);
    linksDataset.addSeries(totalLinksSeries);
    this.seriesMap.put(TSERIES_CMD_SIZE_TOTAL, totalLinksSeries);

    TimeSeries enqueuedLinksSeries = new TimeSeries("Enqueued URI", Minute.class);
    enqueuedLinksSeries.setMaximumItemAge(24 * 60);
    linksDataset.addSeries(enqueuedLinksSeries);
    this.seriesMap.put(TSERIES_CMD_SIZE_ENQUEUD, enqueuedLinksSeries);

    NumberAxis axis2 = new NumberAxis("#Links");
    axis2.setAutoRangeIncludesZero(false);
    axis2.setNumberFormatOverride(new DecimalFormat("#,##0"));
    plot.setRangeAxis(1, axis2);
    plot.setDataset(1, linksDataset);
    plot.setRenderer(1, new StandardXYItemRenderer());
    plot.mapDatasetToRangeAxis(1, 1);

    NumberAxis axis1 = (NumberAxis) plot.getRangeAxis(0);
    axis1.setNumberFormatOverride(new DecimalFormat("#,##0"));

    // change axis date format
    ((DateAxis) plot.getDomainAxis()).setDateFormatOverride(new SimpleDateFormat("HH:mm"));
    chart.setBackgroundPaint(Color.WHITE);
    return chart;
}