List of usage examples for org.jfree.data.time TimeSeries TimeSeries
public TimeSeries(Comparable name)
From source file:com.jbombardier.reports.OldReportGenerator.java
private TimeSeries extractTimeSeries(List<Chunk> timeOrderedResults, String transactionName, Statistic statistic) {//from www . jav a 2 s . co m TimeSeries timeSeries = new TimeSeries(transactionName); for (Chunk chunk : timeOrderedResults) { timeSeries.add(new Second(new Date(chunk.getChunkStart())), chunk.getStatistics().extract(statistic)); } return timeSeries; }
From source file:com.haskins.cloudtrailviewer.feature.MetricsFeature.java
private TimeSeriesCollection generateTimeSeriesData(String service) { List<Event> serviceEvents = SERVICE_SORTED.get(service); Map<Long, List<Event>> tickEvents = new HashMap<>(); for (Event event : serviceEvents) { long second = event.getTimestamp(); List<Event> events = tickEvents.get(second); if (events == null) { events = new ArrayList<>(); }/* w w w.jav a 2s . c o m*/ events.add(event); tickEvents.put(second, events); } TimeSeries series = new TimeSeries(service); for (Map.Entry<Long, List<Event>> entry : tickEvents.entrySet()) { Second secondPeriod = new Second(new Date(entry.getKey())); secondEvents.put(secondPeriod, entry.getValue()); series.add(secondPeriod, entry.getValue().size()); } TimeSeriesCollection tsc = new TimeSeriesCollection(); tsc.addSeries(series); return tsc; }
From source file:info.financialecology.finance.utilities.datastruct.VersatileTimeSeriesCollection.java
/** * Creates new <a href="http://tinyurl.com/c37gxle"><code>TimeSeries</code></a> * objects and adds them to this collection. For each <code>name</code>, the method * generates <code>nIndices</code> time series with keys of the form * <code>name_index</code>.//from w w w. j av a 2 s . co m * <p> * @param nIndices the number of time series generated per name * @param names an arbitrary number of time series keys */ public void newIndexedSeries(int nIndices, String... names) { for (String name : names) { for (int i = 1; i <= nIndices; i++) addSeries(new TimeSeries(name + "_" + i)); } }
From source file:org.jfree.chart.demo.PriceVolumeDemo2.java
private static IntervalXYDataset createVolumeDataset() { TimeSeries timeseries = new TimeSeries("Volume"); timeseries.add(new Day(12, 4, 2007), 49646800D); timeseries.add(new Day(13, 4, 2007), 67319300D); timeseries.add(new Day(16, 4, 2007), 56840200D); timeseries.add(new Day(17, 4, 2007), 40752300D); timeseries.add(new Day(18, 4, 2007), 42533800D); timeseries.add(new Day(19, 4, 2007), 34232100D); timeseries.add(new Day(20, 4, 2007), 32437600D); timeseries.add(new Day(23, 4, 2007), 28755900D); timeseries.add(new Day(24, 4, 2007), 74503300D); timeseries.add(new Day(25, 4, 2007), 322214000D); timeseries.add(new Day(26, 4, 2007), 96141700D); timeseries.add(new Day(27, 4, 2007), 62326200D); timeseries.add(new Day(30, 4, 2007), 52334400D); timeseries.add(new Day(1, 5, 2007), 133096100D); timeseries.add(new Day(2, 5, 2007), 93874500D); timeseries.add(new Day(3, 5, 2007), 101011400D); timeseries.add(new Day(4, 5, 2007), 56629700D); timeseries.add(new Day(7, 5, 2007), 43302200D); timeseries.add(new Day(8, 5, 2007), 51456500D); timeseries.add(new Day(9, 5, 2007), 48230900D); timeseries.add(new Day(10, 5, 2007), 65536000D); timeseries.add(new Day(11, 5, 2007), 46469700D); timeseries.add(new Day(14, 5, 2007), 118580000D); timeseries.add(new Day(15, 5, 2007), 50774100D); timeseries.add(new Day(16, 5, 2007), 44590200D); timeseries.add(new Day(17, 5, 2007), 125482500D); timeseries.add(new Day(18, 5, 2007), 49987500D); timeseries.add(new Day(21, 5, 2007), 48387400D); timeseries.add(new Day(22, 5, 2007), 67992600D); timeseries.add(new Day(23, 5, 2007), 45629200D); timeseries.add(new Day(24, 5, 2007), 123288600D); timeseries.add(new Day(25, 5, 2007), 47345300D); timeseries.add(new Day(29, 5, 2007), 90454000D); timeseries.add(new Day(30, 5, 2007), 73049200D); timeseries.add(new Day(31, 5, 2007), 60395400D); timeseries.add(new Day(1, 6, 2007), 48792300D); timeseries.add(new Day(4, 6, 2007), 109972800D); timeseries.add(new Day(5, 6, 2007), 198201200D); timeseries.add(new Day(6, 6, 2007), 121415700D); timeseries.add(new Day(7, 6, 2007), 56637400D); timeseries.add(new Day(8, 6, 2007), 64116600D); timeseries.add(new Day(11, 6, 2007), 60274800D); timeseries.add(new Day(12, 6, 2007), 93451300D); timeseries.add(new Day(13, 6, 2007), 103309000D); timeseries.add(new Day(14, 6, 2007), 103135400D); timeseries.add(new Day(15, 6, 2007), 104415900D); timeseries.add(new Day(18, 6, 2007), 51506900D); timeseries.add(new Day(19, 6, 2007), 74592100D); timeseries.add(new Day(20, 6, 2007), 69027600D); timeseries.add(new Day(21, 6, 2007), 97212500D); timeseries.add(new Day(22, 6, 2007), 51612000D); timeseries.add(new Day(25, 6, 2007), 63845400D); timeseries.add(new Day(26, 6, 2007), 84818400D); timeseries.add(new Day(27, 6, 2007), 73512900D); timeseries.add(new Day(28, 6, 2007), 75275100D); timeseries.add(new Day(29, 6, 2007), 104203900D); timeseries.add(new Day(2, 7, 2007), 66540400D); timeseries.add(new Day(3, 7, 2007), 28520800D); timeseries.add(new Day(5, 7, 2007), 47176300D); timeseries.add(new Day(6, 7, 2007), 70084800D); timeseries.add(new Day(9, 7, 2007), 91630800D); timeseries.add(new Day(10, 7, 2007), 114071700D); timeseries.add(new Day(11, 7, 2007), 34217900D); timeseries.add(new Day(12, 7, 2007), 30298000D); timeseries.add(new Day(13, 7, 2007), 40423500D); timeseries.add(new Day(16, 7, 2007), 39238000D); return new TimeSeriesCollection(timeseries); }
From source file:de.citec.csra.allocation.vis.MovingChart.java
public void updateDataPoints(String id, String label, String resource, long start, long end, State state, Priority prio, boolean token) { synchronized (this.dataset) { TimeSeries series = this.dataset.getSeries(id); if (series == null) { series = new TimeSeries(id); this.dataset.addSeries(series); }//from www . j a v a2 s.c o m series.setDomainDescription(label); int stroke = -1; Color c = null; boolean randomcolor = false; if (!randomcolor) { switch (prio) { case EMERGENCY: c = Color.RED; break; case URGENT: c = Color.ORANGE; break; case HIGH: c = Color.YELLOW; break; case NORMAL: c = Color.GREEN; break; case LOW: c = Color.BLUE; break; case NO: c = Color.BLACK; break; } } switch (state) { case REQUESTED: stroke = 1; break; case SCHEDULED: stroke = 3; break; case ALLOCATED: stroke = 9; break; case RELEASED: stroke = 1; break; case REJECTED: case CANCELLED: case ABORTED: c = Color.GRAY; stroke = 1; break; } XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) this.chart.getXYPlot() .getRendererForDataset(dataset); int number = -1; for (int i = 0; i < this.dataset.getSeries().size(); i++) { TimeSeries t = this.dataset.getSeries(i); if (t.getKey().equals(id)) { number = i; } } if (number > 0) { if (stroke > 0) { if (token) { r.setSeriesStroke(number, new BasicStroke(stroke, CAP_BUTT, JOIN_BEVEL, 1, new float[] { 1.5f, .5f }, .5f)); } else { r.setSeriesStroke(number, new BasicStroke(stroke, CAP_BUTT, JOIN_BEVEL, 1)); } } if (c != null) { r.setSeriesPaint(number, c); } } long channel; String key = resource; //prio if (values.containsKey(key)) { channel = values.get(key); } else { channel = events++; values.put(key, channel); } if (!series.isEmpty()) { series.clear(); } series.addOrUpdate(new Millisecond(new Date(start)), channel); series.addOrUpdate(new Millisecond(new Date(end)), channel); } }
From source file:org.jfree.data.time.junit.TimeSeriesTest.java
/** * Serialize an instance, restore it, and check for equality. *//*from w ww . j ava2 s . com*/ public void testSerialization() { TimeSeries s1 = new TimeSeries("A test"); s1.add(new Year(2000), 13.75); s1.add(new Year(2001), 11.90); s1.add(new Year(2002), null); s1.add(new Year(2005), 19.32); s1.add(new Year(2007), 16.89); TimeSeries s2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(s1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); s2 = (TimeSeries) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(s1.equals(s2)); }
From source file:org.imos.abos.plot.JfreeChartDemo.java
/** * Creates a sample dataset.//w w w.j av a 2 s . co m * * @return A sample dataset. */ protected TimeSeriesCollection createDataset() { TimeSeriesCollection collection = new TimeSeriesCollection(); final TimeSeries series = new TimeSeries("Random Data"); Day current = new Day(1, 1, 2000); double value = 100.0; for (int i = 0; i < 4000; i++) { try { value = value + Math.random() - 0.5; series.add(current, new Double(value)); current = (Day) current.next(); } catch (SeriesException e) { System.err.println("Error adding to series"); } } collection.addSeries(series); return collection; }
From source file:org.jfree.data.time.TimeSeriesCollectionTest.java
/** * Basic checks for cloning.//from w w w . j a v a 2s . c o m */ @Test public void testCloning() throws CloneNotSupportedException { TimeSeries s1 = new TimeSeries("Series"); s1.add(new Year(2009), 1.1); TimeSeriesCollection c1 = new TimeSeriesCollection(); c1.addSeries(s1); TimeSeriesCollection c2 = (TimeSeriesCollection) c1.clone(); assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); // check independence s1.setDescription("XYZ"); assertFalse(c1.equals(c2)); c2.getSeries(0).setDescription("XYZ"); assertTrue(c1.equals(c2)); }
From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.PortCounterPlotWorker.java
/** * Creates a sample dataset.//from ww w .ja v a2 s. c o m * * @param name the dataset name. * @param base the starting value. * @param start the starting period. * @param count the number of values to generate. * * @return The dataset. */ private XYDataset createDataset(OMS_Collection history) { TimeSeries TSeries = new TimeSeries("counts"); // iterate through the collection, and build up a time series for (int j = 0; j < history.getSize(); j++) { OpenSmMonitorService osm = history.getOMS(j); // find the desired port counter, in this instance LinkedHashMap<String, OSM_Port> pL = osm.getFabric().getOSM_Ports(); OSM_Port p = pL.get(OSM_Port.getOSM_PortKey(Port)); long lValue = p.pfmPort.getCounter(PortCounter); TimeStamp ts = p.pfmPort.getCounterTimeStamp(); RegularTimePeriod ms = new FixedMillisecond(ts.getTimeInMillis()); TSeries.add(ms, (double) lValue); } TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(TSeries); return dataset; }
From source file:tools.descartes.bungee.chart.ChartGenerator.java
private static TimeSeries createTimeSeries(List<ResourceAllocation> allocations, String label) { Integer lastAmount = null;/*from w ww . j a v a 2 s . c om*/ final TimeSeries series = new TimeSeries(label); for (ResourceAllocation allocation : allocations) { if (lastAmount != null) { series.addOrUpdate( new FixedMillisecond( new Date(DateUtility.toSecondPrecision(allocation.getDate()).getTime() - 1)), lastAmount); } series.addOrUpdate(new FixedMillisecond(DateUtility.toSecondPrecision(allocation.getDate())), allocation.getCurrentAmount()); lastAmount = allocation.getCurrentAmount(); } return series; }