List of usage examples for org.jfree.data.time Second Second
public Second(int second, int minute, int hour, int day, int month, int year)
From source file:org.jfree.data.time.SecondTest.java
/** * Some checks for the getFirstMillisecond(TimeZone) method. *///w w w . ja v a 2s . c om @Test public void testGetFirstMillisecondWithTimeZone() { Second s = new Second(50, 59, 15, 1, 4, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-623289610000L, s.getFirstMillisecond(zone)); // try null calendar boolean pass = false; try { s.getFirstMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
From source file:org.jfree.data.time.Millisecond.java
/** * Returns the second.//from ww w. j a v a 2s .c o m * * @return The second. */ public Second getSecond() { return new Second(this.second, this.minute, this.hour, this.day.getDayOfMonth(), this.day.getMonth(), this.day.getYear()); }
From source file:org.jfree.data.time.junit.SecondTest.java
/** * The {@link Second} class is immutable, so should not be * {@link Cloneable}./*from ww w .j av a 2s.c o m*/ */ public void testNotCloneable() { Second s = new Second(13, 45, 5, 1, 2, 2003); assertFalse(s instanceof Cloneable); }
From source file:org.jfree.data.time.SecondTest.java
/** * Some checks for the getFirstMillisecond(TimeZone) method. *///from w ww .j a v a 2 s . c o m @Test public void testGetFirstMillisecondWithCalendar() { Second s = new Second(55, 40, 2, 15, 4, 2000); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(955766455000L, s.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { s.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
From source file:org.jfree.data.time.junit.SecondTest.java
/** * Some checks for the getFirstMillisecond() method. *///from w w w . j ava 2s . c o m public void testGetFirstMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Second s = new Second(15, 43, 15, 1, 4, 2006); assertEquals(1143902595000L, s.getFirstMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); }
From source file:org.jfree.data.time.junit.SecondTest.java
/** * Some checks for the getFirstMillisecond(TimeZone) method. *//*from ww w .j a va 2 s. co m*/ public void testGetFirstMillisecondWithTimeZone() { Second s = new Second(50, 59, 15, 1, 4, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); Calendar c = new GregorianCalendar(zone); assertEquals(-623289610000L, s.getFirstMillisecond(c)); // try null calendar boolean pass = false; try { s.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
From source file:org.n52.oxf.render.sos.TimeSeriesChartRenderer4xPhenomenons.java
protected TimeSeriesCollection createDataset(String[] foiIdArray, ObservationSeriesCollection tuples4FOI, int observedPropertyIndex) { TimeSeriesCollection dataset = new TimeSeriesCollection(); for (String featureID : foiIdArray) { Map<ITimePosition, ObservedValueTuple> tupleMap = tuples4FOI.getAllTuples(featureID); if (tupleMap != null) { // for each selected <feature,observedPropertyIndex> pair construct a new TimeSeries: TimeSeries timeSeries = new TimeSeries( featureID + "___" + this.observedProperties[observedPropertyIndex], Second.class); for (ITimePosition timePos : tupleMap.keySet()) { ObservedValueTuple tuple = tupleMap.get(timePos); Number result = (Number) tuple.getValue(observedPropertyIndex); timeSeries.add(new Second(new Float(timePos.getSecond()).intValue(), timePos.getMinute(), timePos.getHour(), timePos.getDay(), timePos.getMonth(), new Long(timePos.getYear()).intValue()), result); }/*from w w w . j a v a 2 s .c om*/ dataset.addSeries(timeSeries); } } dataset.setDomainIsPointsInTime(true); return dataset; }
From source file:studio.ui.LineChart.java
public static JFreeChart createDataset(KTableModel table) { TimeZone tz = TimeZone.getTimeZone("GMT"); XYDataset ds = null;/* w w w. ja v a 2s . com*/ if (table.getColumnCount() > 0) { Class klass = table.getColumnClass(0); if ((klass == K.KTimestampVector.class) || (klass == K.KTimespanVector.class) || (klass == K.KDateVector.class) || (klass == K.KTimeVector.class) || (klass == K.KMonthVector.class) || (klass == K.KMinuteVector.class) || (klass == K.KSecondVector.class) || (klass == K.KDatetimeVector.class)) { TimeSeriesCollection tsc = new TimeSeriesCollection(tz); for (int col = 1; col < table.getColumnCount(); col++) { TimeSeries series = null; try { if (klass == K.KDateVector.class) { series = new TimeSeries(table.getColumnName(col), Day.class); K.KDateVector dates = (K.KDateVector) table.getColumn(0); for (int row = 0; row < dates.getLength(); row++) { K.KDate date = (K.KDate) dates.at(row); Day day = new Day(date.toDate(), tz); Object o = table.getValueAt(row, col); if (o instanceof K.KBase) if (!((K.KBase) o).isNull()) if (o instanceof ToDouble) series.addOrUpdate(day, ((ToDouble) o).toDouble()); } } else if (klass == K.KTimeVector.class) { series = new TimeSeries(table.getColumnName(col), Millisecond.class); K.KTimeVector times = (K.KTimeVector) table.getColumn(0); for (int row = 0; row < table.getRowCount(); row++) { K.KTime time = (K.KTime) times.at(row); Millisecond ms = new Millisecond(time.toTime(), tz); Object o = table.getValueAt(row, col); if (o instanceof K.KBase) if (!((K.KBase) o).isNull()) if (o instanceof ToDouble) series.addOrUpdate(ms, ((ToDouble) o).toDouble()); } } else if (klass == K.KTimestampVector.class) { series = new TimeSeries(table.getColumnName(col), Day.class); K.KTimestampVector dates = (K.KTimestampVector) table.getColumn(0); for (int row = 0; row < dates.getLength(); row++) { K.KTimestamp date = (K.KTimestamp) dates.at(row); Day day = new Day(new java.util.Date(date.toTimestamp().getTime()), tz); Object o = table.getValueAt(row, col); if (o instanceof K.KBase) if (!((K.KBase) o).isNull()) if (o instanceof ToDouble) series.addOrUpdate(day, ((ToDouble) o).toDouble()); } } else if (klass == K.KTimespanVector.class) { series = new TimeSeries(table.getColumnName(col), Millisecond.class); K.KTimespanVector times = (K.KTimespanVector) table.getColumn(0); for (int row = 0; row < table.getRowCount(); row++) { K.KTimespan time = (K.KTimespan) times.at(row); Millisecond ms = new Millisecond(time.toTime(), tz); Object o = table.getValueAt(row, col); if (o instanceof K.KBase) if (!((K.KBase) o).isNull()) if (o instanceof ToDouble) series.addOrUpdate(ms, ((ToDouble) o).toDouble()); } } else if (klass == K.KDatetimeVector.class) { series = new TimeSeries(table.getColumnName(col), Millisecond.class); K.KDatetimeVector times = (K.KDatetimeVector) table.getColumn(0); for (int row = 0; row < table.getRowCount(); row++) { K.KDatetime time = (K.KDatetime) times.at(row); Millisecond ms = new Millisecond(time.toTimestamp(), tz); Object o = table.getValueAt(row, col); if (o instanceof K.KBase) if (!((K.KBase) o).isNull()) if (o instanceof ToDouble) series.addOrUpdate(ms, ((ToDouble) o).toDouble()); } } else if (klass == K.KMonthVector.class) { series = new TimeSeries(table.getColumnName(col), Month.class); K.KMonthVector times = (K.KMonthVector) table.getColumn(0); for (int row = 0; row < table.getRowCount(); row++) { K.Month time = (K.Month) times.at(row); int m = time.i + 24000; int y = m / 12; m = 1 + m % 12; Month month = new Month(m, y); Object o = table.getValueAt(row, col); if (o instanceof K.KBase) if (!((K.KBase) o).isNull()) if (o instanceof ToDouble) series.addOrUpdate(month, ((ToDouble) o).toDouble()); } } else if (klass == K.KSecondVector.class) { series = new TimeSeries(table.getColumnName(col), Second.class); K.KSecondVector times = (K.KSecondVector) table.getColumn(0); for (int row = 0; row < table.getRowCount(); row++) { K.Second time = (K.Second) times.at(row); Second second = new Second(time.i % 60, time.i / 60, 0, 1, 1, 2001); Object o = table.getValueAt(row, col); if (o instanceof K.KBase) if (!((K.KBase) o).isNull()) if (o instanceof ToDouble) series.addOrUpdate(second, ((ToDouble) o).toDouble()); } } else if (klass == K.KMinuteVector.class) { series = new TimeSeries(table.getColumnName(col), Minute.class); K.KMinuteVector times = (K.KMinuteVector) table.getColumn(0); for (int row = 0; row < table.getRowCount(); row++) { K.Minute time = (K.Minute) times.at(row); Minute minute = new Minute(time.i % 60, time.i / 60, 1, 1, 2001); Object o = table.getValueAt(row, col); if (o instanceof K.KBase) if (!((K.KBase) o).isNull()) if (o instanceof ToDouble) series.addOrUpdate(minute, ((ToDouble) o).toDouble()); } } } catch (SeriesException e) { System.err.println("Error adding to series"); } if (series.getItemCount() > 0) tsc.addSeries(series); } ds = tsc; } else if ((klass == K.KDoubleVector.class) || (klass == K.KFloatVector.class) || (klass == K.KShortVector.class) || (klass == K.KIntVector.class) || (klass == K.KLongVector.class)) { XYSeriesCollection xysc = new XYSeriesCollection(); for (int col = 1; col < table.getColumnCount(); col++) { XYSeries series = null; try { series = new XYSeries(table.getColumnName(col)); for (int row = 0; row < table.getRowCount(); row++) { double x = ((ToDouble) table.getValueAt(row, 0)).toDouble(); double y = ((ToDouble) table.getValueAt(row, col)).toDouble(); series.add(x, y); } } catch (SeriesException e) { System.err.println("Error adding to series"); } if (series.getItemCount() > 0) xysc.addSeries(series); } ds = xysc; } } if (ds != null) { boolean legend = false; if (ds.getSeriesCount() > 1) legend = true; if (ds instanceof XYSeriesCollection) return ChartFactory.createXYLineChart("", "", "", ds, PlotOrientation.VERTICAL, legend, true, true); else if (ds instanceof TimeSeriesCollection) return ChartFactory.createTimeSeriesChart("", "", "", ds, legend, true, true); } return null; }
From source file:org.jfree.data.time.SecondTest.java
/** * Some checks for the getLastMillisecond() method. *//*w w w.j a v a2s .co m*/ @Test public void testGetLastMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Second s = new Second(1, 1, 1, 1, 1, 1970); assertEquals(61999L, s.getLastMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); }
From source file:org.n52.oxf.render.sos.TimeSeriesMapChartRenderer.java
/** * The resulting chart consists a TimeSeries for each FeatureOfInterest contained in the * observationCollection.//from w ww . j a v a 2 s . com * * @param foiIdArray * the IDs of the FeaturesOfInterest whose Observations shall be rendered * @param observationCollection * @return */ protected XYPlot drawChart4FOI(String foiID, Map<ITimePosition, ObservedValueTuple> timeMap) { TimeSeriesCollection dataset = new TimeSeriesCollection(); TimeSeries timeSeries = new TimeSeries(foiID, Second.class); for (ITimePosition timePos : timeMap.keySet()) { Number value = (Number) timeMap.get(timePos).getValue(0); timeSeries.add( new Second(new Float(timePos.getSecond()).intValue(), timePos.getMinute(), timePos.getHour(), timePos.getDay(), timePos.getMonth(), new Long(timePos.getYear()).intValue()), value); } dataset.addSeries(timeSeries); dataset.setDomainIsPointsInTime(true); // // create Plot: // XYPlot plot = new XYPlot(); plot.setDataset(dataset); plot.setBackgroundPaint(Color.white); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseShapesVisible(false); plot.setRenderer(renderer); DateAxis dateAxis = new DateAxis(); dateAxis.setTickMarkPosition(DateTickMarkPosition.START); dateAxis.setTickMarksVisible(true); dateAxis.setVerticalTickLabels(true); dateAxis.setDateFormatOverride(new SimpleDateFormat("dd'.'MM'.'")); plot.setDomainAxis(dateAxis); plot.setRangeAxis(new NumberAxis()); return plot; }