org.jfree.data.time.TimeSeries Java Examples
The following examples show how to use
org.jfree.data.time.TimeSeries.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChartVirtualSensor.java From gsn with GNU General Public License v3.0 | 6 votes |
/** * This method adds the specified stream elements to the timeSeries of the * appropriate plot. * * @param streamElement */ public synchronized void addData ( StreamElement streamElement ) { for ( int i = 0 ; i < streamElement.getFieldNames( ).length ; i++ ) { TimeSeries timeSeries = dataForTheChart.get( streamElement.getFieldNames( )[ i ] ); if ( timeSeries == null ) { dataForTheChart.put( streamElement.getFieldNames( )[ i ] , timeSeries = new TimeSeries( streamElement.getFieldNames( )[ i ] , org.jfree.data.time.FixedMillisecond.class ) ); if(isTimeBased){ timeSeries.setMaximumItemAge(historySize); }else{ timeSeries.setMaximumItemCount(historySize); } dataCollectionForTheChart.addSeries( timeSeries ); } try { timeSeries.addOrUpdate( new FixedMillisecond( new Date( streamElement.getTimeStamp( ) ) ) , Double.parseDouble( streamElement.getData( )[ i ].toString( ) ) ); } catch ( SeriesException e ) { logger.warn( e.getMessage( ) , e ); } } changed = true; }
Example #2
Source File: SWTMultipleAxisDemo1.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Creates a sample dataset. * * @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 static XYDataset createDataset(String name, double base, RegularTimePeriod start, int count) { TimeSeries series = new TimeSeries(name); RegularTimePeriod period = start; double value = base; for (int i = 0; i < count; i++) { series.add(period, value); period = period.next(); value = value * (1 + (Math.random() - 0.495) / 10.0); } TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); return dataset; }
Example #3
Source File: JFreeChartTest.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Serialize a time seroes chart, restore it, and check for equality. */ @Test public void testSerialization4() { RegularTimePeriod t = new Day(); TimeSeries series = new TimeSeries("Series 1"); series.add(t, 36.4); t = t.next(); series.add(t, 63.5); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); JFreeChart c1 = ChartFactory.createTimeSeriesChart("Test", "Date", "Value", dataset); JFreeChart c2 = (JFreeChart) TestUtilities.serialised(c1); assertEquals(c1, c2); }
Example #4
Source File: TimeSeriesTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getMaxY() method. */ public void testGetMaxY() { TimeSeries s1 = new TimeSeries("S1"); assertTrue(Double.isNaN(s1.getMaxY())); s1.add(new Year(2008), 1.1); assertEquals(1.1, s1.getMaxY(), EPSILON); s1.add(new Year(2009), 2.2); assertEquals(2.2, s1.getMaxY(), EPSILON); s1.add(new Year(2000), 99.9); assertEquals(99.9, s1.getMaxY(), EPSILON); s1.add(new Year(2002), -1.1); assertEquals(99.9, s1.getMaxY(), EPSILON); s1.add(new Year(2003), null); assertEquals(99.9, s1.getMaxY(), EPSILON); s1.addOrUpdate(new Year(2000), null); assertEquals(2.2, s1.getMaxY(), EPSILON); }
Example #5
Source File: MovingAverageTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * A test for the values calculated from a time series. */ public void test1() { TimeSeries source = createDailyTimeSeries1(); TimeSeries maverage = MovingAverage.createMovingAverage( source, "Moving Average", 3, 3 ); // the moving average series has 7 items, the first three // days (11, 12, 13 August are skipped) assertEquals(7, maverage.getItemCount()); double value = maverage.getValue(0).doubleValue(); assertEquals(14.1, value, EPSILON); value = maverage.getValue(1).doubleValue(); assertEquals(13.4, value, EPSILON); value = maverage.getValue(2).doubleValue(); assertEquals(14.433333333333, value, EPSILON); value = maverage.getValue(3).doubleValue(); assertEquals(14.933333333333, value, EPSILON); value = maverage.getValue(4).doubleValue(); assertEquals(19.8, value, EPSILON); value = maverage.getValue(5).doubleValue(); assertEquals(15.25, value, EPSILON); value = maverage.getValue(6).doubleValue(); assertEquals(12.5, value, EPSILON); }
Example #6
Source File: SWTMultipleAxisDemo1.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Creates a sample dataset. * * @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 static XYDataset createDataset(String name, double base, RegularTimePeriod start, int count) { TimeSeries series = new TimeSeries(name); RegularTimePeriod period = start; double value = base; for (int i = 0; i < count; i++) { series.add(period, value); period = period.next(); value = value * (1 + (Math.random() - 0.495) / 10.0); } TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); return dataset; }
Example #7
Source File: XYPlotTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a sample dataset. * * @return Series 1. */ private IntervalXYDataset createDataset1() { // create dataset 1... TimeSeries series1 = new TimeSeries("Series 1"); series1.add(new Day(1, MonthConstants.MARCH, 2002), 12353.3); series1.add(new Day(2, MonthConstants.MARCH, 2002), 13734.4); series1.add(new Day(3, MonthConstants.MARCH, 2002), 14525.3); series1.add(new Day(4, MonthConstants.MARCH, 2002), 13984.3); series1.add(new Day(5, MonthConstants.MARCH, 2002), 12999.4); series1.add(new Day(6, MonthConstants.MARCH, 2002), 14274.3); series1.add(new Day(7, MonthConstants.MARCH, 2002), 15943.5); series1.add(new Day(8, MonthConstants.MARCH, 2002), 14845.3); series1.add(new Day(9, MonthConstants.MARCH, 2002), 14645.4); series1.add(new Day(10, MonthConstants.MARCH, 2002), 16234.6); series1.add(new Day(11, MonthConstants.MARCH, 2002), 17232.3); series1.add(new Day(12, MonthConstants.MARCH, 2002), 14232.2); series1.add(new Day(13, MonthConstants.MARCH, 2002), 13102.2); series1.add(new Day(14, MonthConstants.MARCH, 2002), 14230.2); series1.add(new Day(15, MonthConstants.MARCH, 2002), 11235.2); TimeSeriesCollection collection = new TimeSeriesCollection(series1); return collection; }
Example #8
Source File: JFreeChartTest.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Serialize a time seroes chart, restore it, and check for equality. */ @Test public void testSerialization4() { RegularTimePeriod t = new Day(); TimeSeries series = new TimeSeries("Series 1"); series.add(t, 36.4); t = t.next(); series.add(t, 63.5); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); JFreeChart c1 = ChartFactory.createTimeSeriesChart("Test", "Date", "Value", dataset); JFreeChart c2 = (JFreeChart) TestUtilities.serialised(c1); assertEquals(c1, c2); }
Example #9
Source File: TimeSeriesTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Test the setMaximumItemCount() method to ensure that it removes items * from the series if necessary. */ 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))); }
Example #10
Source File: XYPlotTest.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Creates a sample dataset. * * @return Series 1. */ private IntervalXYDataset createDataset1() { // create dataset 1... TimeSeries series1 = new TimeSeries("Series 1", Day.class); series1.add(new Day(1, MonthConstants.MARCH, 2002), 12353.3); series1.add(new Day(2, MonthConstants.MARCH, 2002), 13734.4); series1.add(new Day(3, MonthConstants.MARCH, 2002), 14525.3); series1.add(new Day(4, MonthConstants.MARCH, 2002), 13984.3); series1.add(new Day(5, MonthConstants.MARCH, 2002), 12999.4); series1.add(new Day(6, MonthConstants.MARCH, 2002), 14274.3); series1.add(new Day(7, MonthConstants.MARCH, 2002), 15943.5); series1.add(new Day(8, MonthConstants.MARCH, 2002), 14845.3); series1.add(new Day(9, MonthConstants.MARCH, 2002), 14645.4); series1.add(new Day(10, MonthConstants.MARCH, 2002), 16234.6); series1.add(new Day(11, MonthConstants.MARCH, 2002), 17232.3); series1.add(new Day(12, MonthConstants.MARCH, 2002), 14232.2); series1.add(new Day(13, MonthConstants.MARCH, 2002), 13102.2); series1.add(new Day(14, MonthConstants.MARCH, 2002), 14230.2); series1.add(new Day(15, MonthConstants.MARCH, 2002), 11235.2); TimeSeriesCollection collection = new TimeSeriesCollection(series1); return collection; }
Example #11
Source File: TimeSeriesChartHyperlinkProvider.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
@Override public JRPrintHyperlink getEntityHyperlink(ChartEntity entity) { JRPrintHyperlink printHyperlink = null; if (hasHyperlinks() && entity instanceof XYItemEntity) { XYItemEntity itemEntity = (XYItemEntity) entity; TimeSeriesCollection dataset = (TimeSeriesCollection) itemEntity.getDataset(); TimeSeries series = dataset.getSeries(itemEntity.getSeriesIndex()); Map<RegularTimePeriod, JRPrintHyperlink> serieHyperlinks = itemHyperlinks.get(series.getKey()); if (serieHyperlinks != null) { RegularTimePeriod timePeriod = series.getTimePeriod(itemEntity.getItem()); printHyperlink = serieHyperlinks.get(timePeriod); } } return printHyperlink; }
Example #12
Source File: JFreeChartTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Serialize a time seroes chart, restore it, and check for equality. */ @Test public void testSerialization4() { RegularTimePeriod t = new Day(); TimeSeries series = new TimeSeries("Series 1"); series.add(t, 36.4); t = t.next(); series.add(t, 63.5); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); JFreeChart c1 = ChartFactory.createTimeSeriesChart("Test", "Date", "Value", dataset); JFreeChart c2 = (JFreeChart) TestUtilities.serialised(c1); assertEquals(c1, c2); }
Example #13
Source File: MovingAverageTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a sample series. * * @return A sample series. */ private TimeSeries createDailyTimeSeries1() { TimeSeries series = new TimeSeries("Series 1"); series.add(new Day(11, MonthConstants.AUGUST, 2003), 11.2); series.add(new Day(13, MonthConstants.AUGUST, 2003), 13.8); series.add(new Day(17, MonthConstants.AUGUST, 2003), 14.1); series.add(new Day(18, MonthConstants.AUGUST, 2003), 12.7); series.add(new Day(19, MonthConstants.AUGUST, 2003), 16.5); series.add(new Day(20, MonthConstants.AUGUST, 2003), 15.6); series.add(new Day(25, MonthConstants.AUGUST, 2003), 19.8); series.add(new Day(27, MonthConstants.AUGUST, 2003), 10.7); series.add(new Day(28, MonthConstants.AUGUST, 2003), 14.3); return series; }
Example #14
Source File: JFreeChartTest.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * Serialize a time seroes chart, restore it, and check for equality. */ @Test public void testSerialization4() { RegularTimePeriod t = new Day(); TimeSeries series = new TimeSeries("Series 1"); series.add(t, 36.4); t = t.next(); series.add(t, 63.5); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); JFreeChart c1 = ChartFactory.createTimeSeriesChart("Test", "Date", "Value", dataset); JFreeChart c2 = (JFreeChart) TestUtilities.serialised(c1); assertEquals(c1, c2); }
Example #15
Source File: MyBarRendererThresholdPaint.java From Knowage-Server with GNU Affero General Public License v3.0 | 6 votes |
public MyBarRendererThresholdPaint(boolean useTargets, HashMap<Double, TargetThreshold> thresholds, DefaultCategoryDataset dataset, TimeSeries timeSeries, Vector<String> nullValues, TargetThreshold bottomThreshold, Color background) { super(); this.useTargets = useTargets; this.thresholds = thresholds; this.dataset = dataset; this.timeSeries = timeSeries; this.nullValues=nullValues; this.background=background; this.bottomThreshold=bottomThreshold; }
Example #16
Source File: TimeSeriesTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getIndex() method. */ public void testGetIndex() { TimeSeries series = new TimeSeries("Series", Month.class); assertEquals(-1, series.getIndex(new Month(1, 2003))); series.add(new Month(1, 2003), 45.0); assertEquals(0, series.getIndex(new Month(1, 2003))); assertEquals(-1, series.getIndex(new Month(12, 2002))); assertEquals(-2, series.getIndex(new Month(2, 2003))); series.add(new Month(3, 2003), 55.0); assertEquals(-1, series.getIndex(new Month(12, 2002))); assertEquals(0, series.getIndex(new Month(1, 2003))); assertEquals(-2, series.getIndex(new Month(2, 2003))); assertEquals(1, series.getIndex(new Month(3, 2003))); assertEquals(-3, series.getIndex(new Month(4, 2003))); }
Example #17
Source File: TimeSeriesCollectionTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some tests for the indexOf() method. */ public void testIndexOf() { TimeSeries s1 = new TimeSeries("S1"); TimeSeries s2 = new TimeSeries("S2"); TimeSeriesCollection dataset = new TimeSeriesCollection(); assertEquals(-1, dataset.indexOf(s1)); assertEquals(-1, dataset.indexOf(s2)); dataset.addSeries(s1); assertEquals(0, dataset.indexOf(s1)); assertEquals(-1, dataset.indexOf(s2)); dataset.addSeries(s2); assertEquals(0, dataset.indexOf(s1)); assertEquals(1, dataset.indexOf(s2)); dataset.removeSeries(s1); assertEquals(-1, dataset.indexOf(s1)); assertEquals(0, dataset.indexOf(s2)); TimeSeries s2b = new TimeSeries("S2"); assertEquals(0, dataset.indexOf(s2b)); }
Example #18
Source File: TimeSeriesCollectionTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some tests for the indexOf() method. */ public void testIndexOf() { TimeSeries s1 = new TimeSeries("S1"); TimeSeries s2 = new TimeSeries("S2"); TimeSeriesCollection dataset = new TimeSeriesCollection(); assertEquals(-1, dataset.indexOf(s1)); assertEquals(-1, dataset.indexOf(s2)); dataset.addSeries(s1); assertEquals(0, dataset.indexOf(s1)); assertEquals(-1, dataset.indexOf(s2)); dataset.addSeries(s2); assertEquals(0, dataset.indexOf(s1)); assertEquals(1, dataset.indexOf(s2)); dataset.removeSeries(s1); assertEquals(-1, dataset.indexOf(s1)); assertEquals(0, dataset.indexOf(s2)); TimeSeries s2b = new TimeSeries("S2"); assertEquals(0, dataset.indexOf(s2b)); }
Example #19
Source File: XYPlotTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a sample dataset. * * @return Series 1. */ private IntervalXYDataset createDataset1() { // create dataset 1... TimeSeries series1 = new TimeSeries("Series 1", Day.class); series1.add(new Day(1, MonthConstants.MARCH, 2002), 12353.3); series1.add(new Day(2, MonthConstants.MARCH, 2002), 13734.4); series1.add(new Day(3, MonthConstants.MARCH, 2002), 14525.3); series1.add(new Day(4, MonthConstants.MARCH, 2002), 13984.3); series1.add(new Day(5, MonthConstants.MARCH, 2002), 12999.4); series1.add(new Day(6, MonthConstants.MARCH, 2002), 14274.3); series1.add(new Day(7, MonthConstants.MARCH, 2002), 15943.5); series1.add(new Day(8, MonthConstants.MARCH, 2002), 14845.3); series1.add(new Day(9, MonthConstants.MARCH, 2002), 14645.4); series1.add(new Day(10, MonthConstants.MARCH, 2002), 16234.6); series1.add(new Day(11, MonthConstants.MARCH, 2002), 17232.3); series1.add(new Day(12, MonthConstants.MARCH, 2002), 14232.2); series1.add(new Day(13, MonthConstants.MARCH, 2002), 13102.2); series1.add(new Day(14, MonthConstants.MARCH, 2002), 14230.2); series1.add(new Day(15, MonthConstants.MARCH, 2002), 11235.2); TimeSeriesCollection collection = new TimeSeriesCollection(series1); return collection; }
Example #20
Source File: ForecastingChartDemo.java From OpenForecast with GNU Lesser General Public License v2.1 | 6 votes |
/** * A helper function to convert data points (from startIndex to * endIndex) of a (JFreeChart) TimeSeries object into an * OpenForecast DataSet. * @param series the series of data points stored as a JFreeChart * TimeSeries object. * @param startIndex the index of the first data point required from the * series. * @param endIndex the index of the last data point required from the * series. * @return an OpenForecast DataSet representing the data points extracted * from the TimeSeries. */ private DataSet getDataSet( TimeSeries series, int startIndex, int endIndex ) { DataSet dataSet = new DataSet(); if ( endIndex > series.getItemCount() ) endIndex = series.getItemCount(); for ( int i=startIndex; i<endIndex; i++ ) { TimeSeriesDataItem dataPair = series.getDataItem(i); DataPoint dp = new Observation( dataPair.getValue().doubleValue() ); dp.setIndependentValue( "t", i ); dataSet.add( dp ); } return dataSet; }
Example #21
Source File: TimeSeriesGraphUpdater.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
private TimeSeries computeSingleTimeSeries(final List<Band> bandList, int pixelX, int pixelY, int currentLevel, String positionName) { final Band firstBand = bandList.get(0); final String firstBandName = firstBand.getName(); final int lastUnderscore = firstBandName.lastIndexOf("_"); final String suffix = positionName.isEmpty()?positionName: "_" + positionName; final String timeSeriesName = firstBandName.substring(0, lastUnderscore); final TimeSeries timeSeries = new TimeSeries(timeSeriesName + suffix); for (Band band : bandList) { final TimeCoding timeCoding = this.timeSeries.getRasterTimeMap().get(band); if (timeCoding != null) { final ProductData.UTC startTime = timeCoding.getStartTime(); final Millisecond timePeriod = new Millisecond(startTime.getAsDate(), ProductData.UTC.UTC_TIME_ZONE, Locale.getDefault()); final double value = getValue(band, pixelX, pixelY, currentLevel); timeSeries.add(new TimeSeriesDataItem(timePeriod, value)); } } return timeSeries; }
Example #22
Source File: FpsInfo.java From AndroidRobot with Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") private void createTable(Composite rtComp) { thread1 = new Thread(this); lastValue = 20D; // 创建时序图对象 timeseries = new TimeSeries( "实时FPS", FpsInfo.class$org$jfree$data$time$Millisecond != null ? FpsInfo.class$org$jfree$data$time$Millisecond : (FpsInfo.class$org$jfree$data$time$Millisecond = FpsInfo .getClass("org.jfree.data.time.Millisecond"))); TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(timeseries); // 创建图表面板 disp = shell.getDisplay(); final ChartComposite frame = new ChartComposite(rtComp, SWT.NONE, createChart(timeseriescollection), true); frame.pack(); FpsInfo.startThread(); }
Example #23
Source File: ObdDataPanel.java From AndrOBD with GNU General Public License v3.0 | 5 votes |
private void btnClearHistActionPerformed()//GEN-FIRST:event_btnClearHistActionPerformed {//GEN-HEADEREND:event_btnClearHistActionPerformed TimeSeries ts; Iterator<TimeSeries> it = selPids.values().iterator(); while (it.hasNext()) { ts = it.next(); ts.clear(); } }
Example #24
Source File: TimeSeriesTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Tests the equals method. */ public void testEquals() { TimeSeries s1 = new TimeSeries("Time Series 1"); TimeSeries s2 = new TimeSeries("Time Series 2"); boolean b1 = s1.equals(s2); assertFalse("b1", b1); s2.setKey("Time Series 1"); boolean b2 = s1.equals(s2); assertTrue("b2", b2); RegularTimePeriod p1 = new Day(); RegularTimePeriod p2 = p1.next(); s1.add(p1, 100.0); s1.add(p2, 200.0); boolean b3 = s1.equals(s2); assertFalse("b3", b3); s2.add(p1, 100.0); s2.add(p2, 200.0); boolean b4 = s1.equals(s2); assertTrue("b4", b4); s1.setMaximumItemCount(100); boolean b5 = s1.equals(s2); assertFalse("b5", b5); s2.setMaximumItemCount(100); boolean b6 = s1.equals(s2); assertTrue("b6", b6); s1.setMaximumItemAge(100); boolean b7 = s1.equals(s2); assertFalse("b7", b7); s2.setMaximumItemAge(100); boolean b8 = s1.equals(s2); assertTrue("b8", b8); }
Example #25
Source File: LogVisualizer.java From incubator-iotdb with Apache License 2.0 | 5 votes |
private Map<String, JFreeChart> drawCharts(Map<String, Map<String, TimeSeries>> taggedTimeSeries, VisualizationPlan plan) { Map<String, JFreeChart> charts = new HashMap<>(); for (Entry<String, Map<String, TimeSeries>> entry : taggedTimeSeries.entrySet()) { String measurementName = entry.getKey(); TimeSeriesCollection timeSeriesList = new TimeSeriesCollection(); for (TimeSeries timeSeries : entry.getValue().values()) { timeSeriesList.addSeries(timeSeries); } // add the start time of the timeseries to the x-axis name Date startDate = new Date((long) timeSeriesList.getDomainBounds(true).getLowerBound()); JFreeChart chart = ChartFactory.createTimeSeriesChart(measurementName, "time-"+ startDate, measurementName, timeSeriesList); XYPlot xyPlot = chart.getXYPlot(); XYLineAndShapeRenderer xyLineAndShapeRenderer = ((XYLineAndShapeRenderer) xyPlot .getRenderer()); // show the origin data points in the plot xyLineAndShapeRenderer.setDefaultShapesVisible(true); xyLineAndShapeRenderer.setDefaultShapesFilled(true); if (plan.getMeasurementPositions() == null) { // do not draw lines if we only record the time instances of the logs (no measurements) xyLineAndShapeRenderer.setDefaultLinesVisible(false); } charts.put(measurementName, chart); } return charts; }
Example #26
Source File: VagTestFrame.java From AndrOBD with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings({"unchecked"}) private void miLoadActionPerformed()//GEN-FIRST:event_miLoadActionPerformed {//GEN-HEADEREND:event_miLoadActionPerformed if (fChoose.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { File file = fChoose.getSelectedFile(); try { FileInputStream in = new FileInputStream(file); ObjectInputStream oIn = new ObjectInputStream(in); /* ensure that measurement page is activated to avoid deletion of loaded data afterwards */ Integer currPage = (Integer) oIn.readObject(); tabMain.setSelectedIndex(currPage); /* read in the data */ Kw1281Prot.VidPvs = (PvList) oIn.readObject(); Kw1281Prot.PidPvs = (PvList) oIn.readObject(); Kw1281Prot.tCodes = (PvList) oIn.readObject(); // re-setup data connection panObdData.setPidPvs(Kw1281Prot.PidPvs); panObdDtc.setTcList(Kw1281Prot.tCodes); TblVehIDs.setProcessVar(Kw1281Prot.VidPvs); // read measurement history panObdData.selPids = (HashMap<Object, TimeSeries>) oIn.readObject(); oIn.close(); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(this, ex.getMessage(), "Load ERROR", JOptionPane.ERROR_MESSAGE); } } }
Example #27
Source File: TimeSeriesTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Create a TimeSeriesDataItem, add it to a TimeSeries. Now, modifying * the original TimeSeriesDataItem should NOT affect the TimeSeries. */ public void testAdd_TimeSeriesDataItem() { TimeSeriesDataItem item = new TimeSeriesDataItem(new Year(2009), 1.0); TimeSeries series = new TimeSeries("S1"); series.add(item); assertTrue(item.equals(series.getDataItem(0))); item.setValue(new Double(99.9)); assertFalse(item.equals(series.getDataItem(0))); }
Example #28
Source File: ObdDataPlotter.java From AndrOBD with GNU General Public License v3.0 | 5 votes |
/** * add a new series to the graph * * @param series The new series to be added */ public synchronized void addSeries(TimeSeries series) { if (oneRangePerSeries) { // get paint for current axis/range/... Paint currPaint = DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[ raIndex % DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length]; XYPlot plot = (XYPlot) chart.getPlot(); // set dataset plot.setDataset(raIndex, new TimeSeriesCollection(series)); // ** set axis NumberAxis axis = new NumberAxis(); axis.setTickLabelFont(legendFont); axis.setAxisLinePaint(currPaint); axis.setTickLabelPaint(currPaint); axis.setTickMarkPaint(currPaint); // ** set axis in plot plot.setRangeAxis(raIndex, axis); plot.setRangeAxisLocation(raIndex, raIndex % 2 == 0 ? AxisLocation.TOP_OR_LEFT : AxisLocation.BOTTOM_OR_RIGHT); plot.mapDatasetToRangeAxis(raIndex, raIndex); // ** create renderer XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setBaseToolTipGenerator(toolTipGen); renderer.setSeriesPaint(0, currPaint); // ** set renderer in plot plot.setRenderer(raIndex, renderer); raIndex++; } dataset.addSeries(series); }
Example #29
Source File: SealedHistoryPricesPanel.java From MtgDesktopCompanion with GNU General Public License v3.0 | 5 votes |
@Override public JFreeChart initChart() { TimeSeriesCollection dataset = new TimeSeriesCollection(); TimeSeries series1 = new TimeSeries(title); if(cpVariations!=null) for (Entry<Date, Double> d : cpVariations.entrySet()) series1.add(new Day(d.getKey()), d.getValue().doubleValue()); dataset.addSeries(series1); return ChartFactory.createTimeSeriesChart("Price Variation", "Date", "Value", dataset, true, true,false); }
Example #30
Source File: CombinedXYPlotDemo1.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Creates a sample dataset. You wouldn't normally hard-code the * population of a dataset in this way (it would be better to read the * values from a file or a database query), but for a self-contained demo * this is the least complicated solution. * * @return The dataset. */ private static IntervalXYDataset createDataset1() { // create dataset 1... TimeSeries series1 = new TimeSeries("Series 1"); series1.add(new Month(1, 2005), 7627.743); series1.add(new Month(2, 2005), 7713.138); series1.add(new Month(3, 2005), 6776.939); series1.add(new Month(4, 2005), 5764.537); series1.add(new Month(5, 2005), 4777.880); series1.add(new Month(6, 2005), 4836.496); series1.add(new Month(7, 2005), 3887.618); series1.add(new Month(8, 2005), 3926.933); series1.add(new Month(9, 2005), 4932.710); series1.add(new Month(10, 2005), 4027.123); series1.add(new Month(11, 2005), 8092.322); series1.add(new Month(12, 2005), 8170.414); series1.add(new Month(1, 2006), 8196.070); series1.add(new Month(2, 2006), 8269.886); series1.add(new Month(3, 2006), 5371.156); series1.add(new Month(4, 2006), 5355.718); series1.add(new Month(5, 2006), 5356.777); series1.add(new Month(6, 2006), 8420.042); series1.add(new Month(7, 2006), 8444.347); series1.add(new Month(8, 2006), 8515.034); series1.add(new Month(9, 2006), 8506.974); series1.add(new Month(10, 2006), 8584.329); series1.add(new Month(11, 2006), 8633.246); series1.add(new Month(12, 2006), 8680.224); series1.add(new Month(1, 2007), 8707.561); return new TimeSeriesCollection(series1); }