List of usage examples for org.jfree.data.time TimeSeries getMinY
public double getMinY()
null
and Double.NaN
values. From source file:org.jfree.data.time.TimeSeriesTest.java
/** * Check that the item bounds are determined correctly when there is a * maximum item count./*from w w w. j a va2 s.co m*/ */ @Test public void testRemoveAgedItems4() { TimeSeries s1 = new TimeSeries("S1"); s1.setMaximumItemAge(2); s1.add(new Year(2010), 1.1); s1.add(new Year(2011), 2.2); s1.add(new Year(2012), 3.3); s1.add(new Year(2013), 2.5); assertEquals(3, s1.getItemCount()); assertEquals(2.2, s1.getMinY(), EPSILON); assertEquals(3.3, s1.getMaxY(), EPSILON); }
From source file:org.jfree.data.time.TimeSeriesTest.java
/** * Some checks for the update(RegularTimePeriod...method). *//*w ww .j a v a 2 s.c om*/ @Test public void testUpdate_RegularTimePeriod() { TimeSeries s1 = new TimeSeries("S1"); s1.add(new Year(2010), 1.1); s1.add(new Year(2011), 2.2); s1.add(new Year(2012), 3.3); s1.update(new Year(2012), 4.4); assertEquals(4.4, s1.getMaxY(), EPSILON); s1.update(new Year(2010), 0.5); assertEquals(0.5, s1.getMinY(), EPSILON); s1.update(new Year(2012), null); assertEquals(2.2, s1.getMaxY(), EPSILON); s1.update(new Year(2010), null); assertEquals(2.2, s1.getMinY(), EPSILON); }
From source file:org.jfree.data.time.TimeSeriesTest.java
/** * Check that the item bounds are determined correctly after a call to * removeAgedItems().//from w w w . ja v a 2 s . c o m */ @Test public void testRemoveAgedItems5() { TimeSeries s1 = new TimeSeries("S1"); s1.setMaximumItemAge(4); s1.add(new Year(2010), 1.1); s1.add(new Year(2011), 2.2); s1.add(new Year(2012), 3.3); s1.add(new Year(2013), 2.5); s1.removeAgedItems(new Year(2015).getMiddleMillisecond(), true); assertEquals(3, s1.getItemCount()); assertEquals(2.2, s1.getMinY(), EPSILON); assertEquals(3.3, s1.getMaxY(), EPSILON); }
From source file:org.jfree.data.time.junit.TimeSeriesTest.java
/** * Some checks for the delete(int, int) method. *//* w w w. ja v a 2 s . com*/ public void testDelete3() { TimeSeries s1 = new TimeSeries("S1"); s1.add(new Year(2011), 1.1); s1.add(new Year(2012), 2.2); s1.add(new Year(2013), 3.3); s1.add(new Year(2014), 4.4); s1.add(new Year(2015), 5.5); s1.add(new Year(2016), 6.6); s1.delete(2, 5); assertEquals(2, s1.getItemCount()); assertEquals(new Year(2011), s1.getTimePeriod(0)); assertEquals(new Year(2012), s1.getTimePeriod(1)); assertEquals(1.1, s1.getMinY(), EPSILON); assertEquals(2.2, s1.getMaxY(), EPSILON); }
From source file:org.jfree.data.time.junit.TimeSeriesTest.java
/** * Test the setMaximumItemCount() method to ensure that it removes items * from the series if necessary./* w w w. j ava2s . com*/ */ public void testSetMaximumItemCount() { TimeSeries s1 = new TimeSeries("S1"); 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); assertTrue(s1.getItemCount() == 5); s1.setMaximumItemCount(3); assertTrue(s1.getItemCount() == 3); TimeSeriesDataItem item = s1.getDataItem(0); assertTrue(item.getPeriod().equals(new Year(2002))); assertEquals(16.89, s1.getMinY(), EPSILON); assertEquals(19.32, s1.getMaxY(), EPSILON); }
From source file:org.jfree.data.time.TimeSeriesTest.java
/** * Some checks for the delete(int, int) method. */// w w w. j av a 2 s. c o m @Test public void testDelete3() { TimeSeries s1 = new TimeSeries("S1"); s1.add(new Year(2011), 1.1); s1.add(new Year(2012), 2.2); s1.add(new Year(2013), 3.3); s1.add(new Year(2014), 4.4); s1.add(new Year(2015), 5.5); s1.add(new Year(2016), 6.6); s1.delete(2, 5); assertEquals(2, s1.getItemCount()); assertEquals(new Year(2011), s1.getTimePeriod(0)); assertEquals(new Year(2012), s1.getTimePeriod(1)); assertEquals(1.1, s1.getMinY(), EPSILON); assertEquals(2.2, s1.getMaxY(), EPSILON); }
From source file:org.jfree.data.time.TimeSeriesTest.java
/** * Test the setMaximumItemCount() method to ensure that it removes items * from the series if necessary./*from w w w. j av a 2 s .co m*/ */ @Test public void testSetMaximumItemCount() { TimeSeries s1 = new TimeSeries("S1", Year.class); 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); assertTrue(s1.getItemCount() == 5); s1.setMaximumItemCount(3); assertTrue(s1.getItemCount() == 3); TimeSeriesDataItem item = s1.getDataItem(0); assertTrue(item.getPeriod().equals(new Year(2002))); assertEquals(16.89, s1.getMinY(), EPSILON); assertEquals(19.32, s1.getMaxY(), EPSILON); }
From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.ChartHelper.java
/*********************************************************************************************** * Dump the (partial) contents of each Series in an XYdatset. * * @param dump//from ww w . j a va2s.com * @param calendar * @param dataset * @param dumprowcount * @param title */ public static void dumpXYDataset(final boolean dump, final Calendar calendar, final XYDataset dataset, final int dumprowcount, final String title) { final String SOURCE = "ChartHelper.dumpXYDataset() "; if (dump) { LOGGER.log(title); if ((dataset != null) && (dataset instanceof XYSeriesCollection)) { final XYSeriesCollection seriesCollection; seriesCollection = (XYSeriesCollection) dataset; LOGGER.log("XYSeriesCollection"); LOGGER.log(" [series.count=" + seriesCollection.getSeriesCount() + "]"); LOGGER.log(" [domain.lowerbound.interval.true=" + (long) seriesCollection.getDomainLowerBound(true) + "]"); LOGGER.log(" [domain.lowerbound.interval.false=" + (long) seriesCollection.getDomainLowerBound(false) + "]"); LOGGER.log(" [domain.upperbound.interval.true=" + (long) seriesCollection.getDomainUpperBound(true) + "]"); LOGGER.log(" [domain.upperbound.interval.false=" + (long) seriesCollection.getDomainUpperBound(false) + "]"); LOGGER.log(" [domain.order=" + seriesCollection.getDomainOrder() + "]"); for (int intSeriesIndex = 0; intSeriesIndex < seriesCollection.getSeriesCount(); intSeriesIndex++) { final XYSeries xySeries; LOGGER.log(""); LOGGER.log(" [xyseries.index=" + intSeriesIndex + "]"); xySeries = seriesCollection.getSeries(intSeriesIndex); LOGGER.log(" [xyseries.itemcount=" + xySeries.getItemCount() + "]"); LOGGER.log(" [xyseries.key=" + xySeries.getKey() + "]"); LOGGER.log(" [xyseries.xmin=" + xySeries.getMinX() + "]"); LOGGER.log(" [xyseries.xmax=" + xySeries.getMaxX() + "]"); LOGGER.log(" [xyseries.ymin=" + xySeries.getMinY() + "]"); LOGGER.log(" [xyseries.ymax=" + xySeries.getMaxY() + "]"); LOGGER.log(" [xyseries.description=" + xySeries.getDescription() + "]"); LOGGER.log(" [xyseries.autosort=" + xySeries.getAutoSort() + "]"); LOGGER.log(" [xyseries.allowduplicatex=" + xySeries.getAllowDuplicateXValues() + "]"); // Dump the first chunk for (int intItemIndex = 0; intItemIndex < (Math.min(dumprowcount, xySeries.getItemCount())); intItemIndex++) { final XYDataItem item; item = xySeries.getDataItem(intItemIndex); LOGGER.log(" [item.index=" + intItemIndex + "] [item.x=" + item.getXValue() + "] [item.y=" + item.getYValue() + "]"); } LOGGER.log(" ..."); // Dump the last chunk for (int intItemIndex = 0; intItemIndex < (Math.min(dumprowcount, xySeries.getItemCount())); intItemIndex++) { final XYDataItem item; final int intIndex; intIndex = Math.max(0, xySeries.getItemCount() - dumprowcount) + intItemIndex; item = xySeries.getDataItem(intIndex); LOGGER.log(" [item.index=" + intIndex + "] [item.x=" + item.getXValue() + "] [item.y=" + item.getYValue() + "]"); } } } else if ((dataset != null) && (dataset instanceof TimeSeriesCollection)) { final TimeSeriesCollection seriesCollection; seriesCollection = (TimeSeriesCollection) dataset; LOGGER.log("TimeSeriesCollection"); LOGGER.log(" [series.count=" + seriesCollection.getSeriesCount() + "]"); LOGGER.log(" [domain.lowerbound.interval.true=" + (long) seriesCollection.getDomainLowerBound(true) + "]"); LOGGER.log(" [domain.lowerbound.interval.false=" + (long) seriesCollection.getDomainLowerBound(false) + "]"); LOGGER.log(" [domain.upperbound.interval.true=" + (long) seriesCollection.getDomainUpperBound(true) + "]"); LOGGER.log(" [domain.upperbound.interval.false=" + (long) seriesCollection.getDomainUpperBound(false) + "]"); LOGGER.log(" [domain.order=" + seriesCollection.getDomainOrder() + "]"); for (int intSeriesIndex = 0; intSeriesIndex < seriesCollection.getSeriesCount(); intSeriesIndex++) { final TimeSeries timeSeries; LOGGER.log(""); LOGGER.log(" [timeseries.index=" + intSeriesIndex + "]"); timeSeries = seriesCollection.getSeries(intSeriesIndex); LOGGER.log(" [timeseries.itemcount=" + timeSeries.getItemCount() + "]"); LOGGER.log(" [timeseries.key=" + timeSeries.getKey() + "]"); LOGGER.log(" [timeseries.ymin=" + timeSeries.getMinY() + "]"); LOGGER.log(" [timeseries.ymax=" + timeSeries.getMaxY() + "]"); LOGGER.log(" [timeseries.domain=" + timeSeries.getDomainDescription() + "]"); LOGGER.log(" [timeseries.range=" + timeSeries.getRangeDescription() + "]"); LOGGER.log( " [timeseries.timeperiodclass=" + timeSeries.getTimePeriodClass().getName() + "]"); for (int intItemIndex = 0; intItemIndex < (Math.min(dumprowcount, timeSeries.getItemCount())); intItemIndex++) { final TimeSeriesDataItem item; item = timeSeries.getDataItem(intItemIndex); LOGGER.log(" [item.index=" + intItemIndex + "] [item.period.serialindex=" + item.getPeriod().getSerialIndex() + "] [item.period.firstmillis=" + item.getPeriod().getFirstMillisecond(calendar) + "] [item.value=" + item.getValue() + "]"); } LOGGER.log(" ..."); for (int intItemIndex = 0; intItemIndex < (Math.min(dumprowcount, timeSeries.getItemCount())); intItemIndex++) { final TimeSeriesDataItem item; final int intIndex; intIndex = Math.max(0, timeSeries.getItemCount() - dumprowcount) + intItemIndex; item = timeSeries.getDataItem(intIndex); LOGGER.log(" [item.index=" + intIndex + "] [item.period.serialindex=" + item.getPeriod().getSerialIndex() + "] [item.period.firstmillis=" + item.getPeriod().getFirstMillisecond(calendar) + "] [item.value=" + item.getValue() + "]"); } } } else { LOGGER.error(SOURCE + "Unsupported XYDataset type"); } } }
From source file:org.ramadda.data.services.PointFormHandler.java
/** * _more_/*w ww .j a v a2 s .c om*/ * * @param request _more_ * @param pointEntry _more_ * @param plotInfo _more_ * * @return _more_ * * @throws Exception _more_ */ public BufferedImage makeTimeseriesImage(Request request, PointEntry pointEntry, final PlotInfo plotInfo) throws Exception { Entry entry = pointEntry.getEntry(); int width = TIMESERIES_WIDTH; int height = TIMESERIES_HEIGHT; long numRecords = pointEntry.getNumRecords(); final int numPointsToPlot = request.get(ARG_NUMPOINTS, TIMESERIES_POINTS); final int[] cnt = { 0 }; final List<TimeSeries> series = new ArrayList<TimeSeries>(); final List<RecordField> tmpFields = pointEntry.getRecordFile().getChartableFields(); final List<RecordField> fields = new ArrayList<RecordField>(); if (request.get(ARG_CHART_SHOW + FIELD_ALTITUDE, false)) { fields.add(new RecordField(FIELD_ALTITUDE, LABEL_ALTITUDE, "", -1, UNIT_M)); } for (RecordField attr : tmpFields) { if (request.get(ARG_CHART_SHOW + attr.getName(), false)) { fields.add(attr); } } if ((fields.size() == 0) && (tmpFields.size() > 0)) { fields.add(tmpFields.get(0)); request.put(ARG_CHART_SHOW + tmpFields.get(0).getName(), "true"); } for (RecordField attr : fields) { series.add(new TimeSeries(attr.getLabel())); } RecordVisitor visitor = new BridgeRecordVisitor(getOutputHandler()) { public boolean doVisitRecord(RecordFile file, VisitInfo visitInfo, Record record) { PointRecord pointRecord = (PointRecord) record; for (int fieldCnt = 0; fieldCnt < fields.size(); fieldCnt++) { RecordField field = fields.get(fieldCnt); double value; //Check for altitude if (field.getParamId() < 0) { value = pointRecord.getAltitude(); } else { value = record.getValue(field.getParamId()); } long time = record.getRecordTime(); series.get(fieldCnt).add(new FixedMillisecond(time), value); } plotInfo.setIndex(pointRecord.index); cnt[0]++; return true; } }; long t1 = System.currentTimeMillis(); int skip = (int) (numRecords / numPointsToPlot); getRecordJobManager().visitSequential(request, pointEntry, visitor, new VisitInfo(skip)); long t2 = System.currentTimeMillis(); JFreeChart chart = createTimeseriesChart(request, entry, new TimeSeriesCollection(), null); long t3 = System.currentTimeMillis(); XYPlot plot = (XYPlot) chart.getPlot(); int lineCnt = 0; int[] colorCnt = { 0 }; int numberOfAxisLegends = 0; Hashtable<String, double[]> valueRanges = new Hashtable<String, double[]>(); for (int extraCnt = 0; extraCnt < series.size(); extraCnt++) { TimeSeries timeSeries = series.get(extraCnt); RecordField field = fields.get(extraCnt); String unit = field.getUnit(); if ((unit != null) && (unit.length() == 0)) { unit = null; } if (unit == null) { unit = extraCnt + ""; } if (unit == null) { continue; } double max = timeSeries.getMaxY(); double min = timeSeries.getMinY(); double[] range = valueRanges.get(unit); if (range == null) { range = new double[] { min, max }; valueRanges.put(unit, range); } else { range[0] = Math.min(range[0], min); range[1] = Math.max(range[1], max); } } Hashtable<String, NumberAxis> seenAxis = new Hashtable<String, NumberAxis>(); for (int extraCnt = 0; extraCnt < series.size(); extraCnt++) { TimeSeries timeSeries = series.get(extraCnt); RecordField field = fields.get(extraCnt); String unit = field.getUnit(); if ((unit != null) && (unit.length() == 0)) { unit = null; } TimeSeriesCollection dataset2 = new TimeSeriesCollection(); dataset2.addSeries(timeSeries); NumberAxis axis = new NumberAxis(field.getLabel()); numberOfAxisLegends++; if (unit != null) { double[] range = valueRanges.get(unit); axis.setRange(range[0], range[1]); NumberAxis seenOne = seenAxis.get(unit); if (seenOne == null) { seenAxis.put(unit, axis); } else { seenOne.setLabel(seenOne.getLabel() + "/" + field.getLabel()); axis.setVisible(false); numberOfAxisLegends--; } } else { axis.setAutoRange(true); axis.setAutoRangeIncludesZero(true); } plot.setRangeAxis(lineCnt, axis); plot.setDataset(lineCnt, dataset2); plot.mapDatasetToRangeAxis(lineCnt, lineCnt); plot.setRangeAxisLocation(lineCnt, AxisLocation.BOTTOM_OR_RIGHT); StandardXYItemRenderer renderer = new MyStandardXYItemRenderer(plotInfo); renderer.setSeriesPaint(0, getColor(request, ARG_CHART_COLOR + field.getName(), colorCnt)); plot.setRenderer(lineCnt, renderer); lineCnt++; } AxisSpace axisSpace = new AxisSpace(); axisSpace.setRight(TIMESERIES_AXIS_WIDTHPER * numberOfAxisLegends); plot.setFixedRangeAxisSpace(axisSpace); long t4 = System.currentTimeMillis(); BufferedImage newImage = chart.createBufferedImage(width + (numberOfAxisLegends * TIMESERIES_AXIS_WIDTHPER), height); long t5 = System.currentTimeMillis(); // System.err.println("Time series cnt:" + cnt[0] + " " + (t2 - t1) + " " + (t3 - t2) + " " + (t4 - t3) + " " + (t5 - t4)); return newImage; }
From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.ChartHelper.java
/*********************************************************************************************** * Create a dummy TimeSeriesDataItem at the origin of the Domain. * * @param timeseriescollection/*w ww .j a v a 2s. com*/ * @param timeseries * @param domainstart * @param debug * * @return TimeSeriesDataItem */ public static TimeSeriesDataItem createDummyTimeSeriesDataItemAtOrigin( final TimeSeriesCollection timeseriescollection, final TimeSeries timeseries, final int domainstart, final boolean debug) { final String SOURCE = "ChartHelper.createDummyTimeSeriesDataItemAtOrigin() [domainstart=" + domainstart + "]"; LOGGER.debug(debug, SOURCE); return new TimeSeriesDataItem( RegularTimePeriod.createInstance(timeseries.getTimePeriodClass(), new Date(calculateDomainSliderMillis(ChartUIComponentPlugin.DOMAIN_SLIDER_MINIMUM, ChartUIComponentPlugin.DOMAIN_SLIDER_MAXIMUM, domainstart, timeseriescollection.getDomainLowerBound(true), timeseriescollection.getDomainUpperBound(true), debug)), TimeZone.getDefault()), timeseries.getMinY()); }