List of usage examples for org.jfree.data.time Minute Minute
public Minute(int minute, int hour, int day, int month, int year)
From source file:org.jfree.chart.demo.RelativeDateFormatDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Exercise Chart", "Elapsed Time", "Beats Per Minute", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); }/* w w w . j a v a2 s .co m*/ DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); Minute minute = new Minute(0, 9, 1, 10, 2006); RelativeDateFormat relativedateformat = new RelativeDateFormat(minute.getFirstMillisecond()); relativedateformat.setSecondFormatter(new DecimalFormat("00")); dateaxis.setDateFormatOverride(relativedateformat); return jfreechart; }
From source file:org.jfree.chart.demo.DifferenceChartDemo2.java
/** * A utility method for creating a value based on a time. * * @param hour the hour.//from w w w . ja v a 2 s. c om * @param min the minute. * * @return a value. */ private Long time(final int hour, final int min) { final Minute m = new Minute(min, hour, 1, 1, 1970); return new Long(m.getFirstMillisecond()); }
From source file:org.jfree.data.time.MinuteTest.java
/** * Two objects that are equal are required to return the same hashCode. *//* w w w .j a v a2s .c o m*/ @Test public void testHashcode() { Minute m1 = new Minute(45, 5, 1, 2, 2003); Minute m2 = new Minute(45, 5, 1, 2, 2003); assertTrue(m1.equals(m2)); int h1 = m1.hashCode(); int h2 = m2.hashCode(); assertEquals(h1, h2); }
From source file:org.jfree.data.time.Second.java
/** * Creates a new second./*from w ww . j a v a 2 s. c o m*/ * * @param second the second (0-59). * @param minute the minute (0-59). * @param hour the hour (0-23). * @param day the day (1-31). * @param month the month (1-12). * @param year the year (1900-9999). */ public Second(int second, int minute, int hour, int day, int month, int year) { this(second, new Minute(minute, hour, day, month, year)); }
From source file:org.jfree.data.time.MinuteTest.java
/** * The {@link Minute} class is immutable, so should not be * {@link Cloneable}./*from ww w . j av a 2 s .c o m*/ */ @Test public void testNotCloneable() { Minute m = new Minute(45, 5, 1, 2, 2003); assertFalse(m instanceof Cloneable); }
From source file:org.jfree.chart.demo.TimeSeriesDemo12.java
/** * Creates a sample dataset./*from www .j a v a 2 s. c o m*/ * * @return the dataset. */ private XYDataset createDataset() { final TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.setDomainIsPointsInTime(true); final TimeSeries s1 = new TimeSeries("Series 1", Minute.class); s1.add(new Minute(0, 0, 7, 12, 2003), 1.2); s1.add(new Minute(30, 12, 7, 12, 2003), 3.0); s1.add(new Minute(15, 14, 7, 12, 2003), 8.0); final TimeSeries s2 = new TimeSeries("Series 2", Minute.class); s2.add(new Minute(0, 3, 7, 12, 2003), 0.0); s2.add(new Minute(30, 9, 7, 12, 2003), 0.0); s2.add(new Minute(15, 10, 7, 12, 2003), 0.0); dataset.addSeries(s1); dataset.addSeries(s2); return dataset; }
From source file:org.cerberus.crud.service.impl.TestCaseExecutionwwwDetService.java
@Override public BufferedImage getHistoricOfParameter(TestCase testcase, String parameter) { List<TestCaseExecutionwwwSumHistoric> historic = testCaseExecutionWWWDetDAO .getHistoricForParameter(testcase, parameter); BufferedImage result = null;//from www .j a v a 2s . c o m DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset(); TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); /*Create timeseries with the data*/ String timeseriesname = parameter; TimeSeries timeseries = new TimeSeries(timeseriesname, Minute.class); for (TestCaseExecutionwwwSumHistoric ep : historic) { defaultcategorydataset.addValue(Float.valueOf(ep.getParameter()), parameter, ep.getStart()); if (!ep.getStart().equals("2011-01-01 00:00")) { String tims = ep.getStart(); int year = Integer.valueOf(tims.substring(0, 4)); int month = Integer.valueOf(tims.substring(5, 7)); int day = Integer.valueOf(tims.substring(8, 10)); int hour = Integer.valueOf(tims.substring(11, 13)); int min = Integer.valueOf(tims.substring(14, 16)); float value = Float.valueOf(ep.getParameter()); timeseries.addOrUpdate(new Minute(min, hour, day, month, year), value); } } timeseriescollection.addSeries(timeseries); result = this.bi(timeseriescollection, "test", parameter, 1); return result; }
From source file:LineChart.java
private static JFreeChart createDataset(JTable table) { TimeZone tz = TimeZone.getTimeZone("GMT"); XYDataset ds = null;//from w w w. java 2s . c om if (table.getColumnCount() > 0) { Class klass = table.getColumnClass(0); if ((klass == Date.class) || (klass == Time.class) || (klass == c.Month.class) || (klass == c.Minute.class) || (klass == c.Second.class) || (klass == Timestamp.class)) { TimeSeriesCollection tsc = new TimeSeriesCollection(); for (int col = 1; col < table.getColumnCount(); col++) { TimeSeries series = null; try { if (klass == Date.class) { series = new TimeSeries(table.getColumnName(col), Day.class); for (int row = 0; row < table.getRowCount(); row++) { Date date = (Date) table.getValueAt(row, 0); Day day = new Day(date, tz); Object o = table.getValueAt(row, col); if (o instanceof Number) { ((TimeSeries) series).addOrUpdate(day, (Number) table.getValueAt(row, col)); } } } else if (klass == Time.class) { series = new TimeSeries(table.getColumnName(col), Millisecond.class); for (int row = 0; row < table.getRowCount(); row++) { Time time = (Time) table.getValueAt(row, 0); Millisecond ms = new Millisecond(time, tz); // Millisecond ms = new Millisecond(time); Object o = table.getValueAt(row, col); if (o instanceof Number) { series.addOrUpdate(ms, (Number) table.getValueAt(row, col)); } } } else if (klass == Timestamp.class) { series = new TimeSeries(table.getColumnName(col), Millisecond.class); for (int row = 0; row < table.getRowCount(); row++) { Timestamp time = (Timestamp) table.getValueAt(row, 0); Millisecond ms = new Millisecond(time, tz); Object o = table.getValueAt(row, col); if (o instanceof Number) { series.addOrUpdate(ms, (Number) table.getValueAt(row, col)); } } } else if (klass == c.Month.class) { series = new TimeSeries(table.getColumnName(col), Month.class); for (int row = 0; row < table.getRowCount(); row++) { c.Month time = (c.Month) table.getValueAt(row, 0); 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 Number) { series.addOrUpdate(month, (Number) table.getValueAt(row, col)); } } } else if (klass == c.Second.class) { series = new TimeSeries(table.getColumnName(col), Second.class); for (int row = 0; row < table.getRowCount(); row++) { c.Second time = (c.Second) table.getValueAt(row, 0); Second second = new Second(time.i % 60, time.i / 60, 0, 1, 1, 2001); Object o = table.getValueAt(row, col); if (o instanceof Number) { series.addOrUpdate(second, (Number) table.getValueAt(row, col)); } } } else if (klass == c.Minute.class) { series = new TimeSeries(table.getColumnName(col), Minute.class); for (int row = 0; row < table.getRowCount(); row++) { c.Minute time = (c.Minute) table.getValueAt(row, 0); Minute minute = new Minute(time.i % 60, time.i / 60, 1, 1, 2001); Object o = table.getValueAt(row, col); if (o instanceof Number) { series.addOrUpdate(minute, (Number) table.getValueAt(row, col)); } } } } catch (SeriesException e) { System.err.println("Error adding to series"); } if (series.getItemCount() > 0) tsc.addSeries(series); } ds = tsc; } else if ((klass == double.class) || (klass == int.class) || (klass == short.class) || (klass == long.class) || (klass == Time.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++) { Number x = (Number) table.getValueAt(row, 0); Object y = table.getValueAt(row, col); if (y instanceof Number) { series.add(x, (Number) 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.MinuteTest.java
/** * Some checks for the getFirstMillisecond() method. *//* w w w. j a v a2 s. c o m*/ @Test public void testGetFirstMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Minute m = new Minute(43, 15, 1, 4, 2006); assertEquals(1143902580000L, m.getFirstMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); }
From source file:org.jfree.data.time.junit.MinuteTest.java
/** * Two objects that are equal are required to return the same hashCode. *///w w w . j a v a 2 s . c o m public void testHashcode() { Minute m1 = new Minute(45, 5, 1, 2, 2003); Minute m2 = new Minute(45, 5, 1, 2, 2003); assertTrue(m1.equals(m2)); int h1 = m1.hashCode(); int h2 = m2.hashCode(); assertEquals(h1, h2); }