List of usage examples for org.jfree.data.time Month Month
public Month(Date time, TimeZone zone)
Month
instance, based on a date/time and a time zone. From source file:org.jfree.chart.demo.PeriodAxisDemo1.java
private static XYDataset createDataset() { TimeSeries timeseries = new TimeSeries("L&G European Index Trust"); timeseries.add(new Month(2, 2001), 181.80000000000001D); timeseries.add(new Month(3, 2001), 167.30000000000001D); timeseries.add(new Month(4, 2001), 153.80000000000001D); timeseries.add(new Month(5, 2001), 167.59999999999999D); timeseries.add(new Month(6, 2001), 158.80000000000001D); timeseries.add(new Month(7, 2001), 148.30000000000001D); timeseries.add(new Month(8, 2001), 153.90000000000001D); timeseries.add(new Month(9, 2001), 142.69999999999999D); timeseries.add(new Month(10, 2001), 123.2D); timeseries.add(new Month(11, 2001), 131.80000000000001D); timeseries.add(new Month(12, 2001), 139.59999999999999D); timeseries.add(new Month(1, 2002), 142.90000000000001D); timeseries.add(new Month(2, 2002), 138.69999999999999D); timeseries.add(new Month(3, 2002), 137.30000000000001D); timeseries.add(new Month(4, 2002), 143.90000000000001D); timeseries.add(new Month(5, 2002), 139.80000000000001D); timeseries.add(new Month(6, 2002), 137D); timeseries.add(new Month(7, 2002), 132.80000000000001D); TimeSeries timeseries1 = new TimeSeries("L&G UK Index Trust"); timeseries1.add(new Month(2, 2001), 129.59999999999999D); timeseries1.add(new Month(3, 2001), 123.2D); timeseries1.add(new Month(4, 2001), 117.2D); timeseries1.add(new Month(5, 2001), 124.09999999999999D); timeseries1.add(new Month(6, 2001), 122.59999999999999D); timeseries1.add(new Month(7, 2001), 119.2D); timeseries1.add(new Month(8, 2001), 116.5D); timeseries1.add(new Month(9, 2001), 112.7D); timeseries1.add(new Month(10, 2001), 101.5D); timeseries1.add(new Month(11, 2001), 106.09999999999999D); timeseries1.add(new Month(12, 2001), 110.3D); timeseries1.add(new Month(1, 2002), 111.7D); timeseries1.add(new Month(2, 2002), 111D); timeseries1.add(new Month(3, 2002), 109.59999999999999D); timeseries1.add(new Month(4, 2002), 113.2D); timeseries1.add(new Month(5, 2002), 111.59999999999999D); timeseries1.add(new Month(6, 2002), 108.8D); timeseries1.add(new Month(7, 2002), 101.59999999999999D); TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); timeseriescollection.addSeries(timeseries); timeseriescollection.addSeries(timeseries1); timeseriescollection.setXPosition(TimePeriodAnchor.MIDDLE); return timeseriescollection; }
From source file:org.jfree.chart.demo.XYDrawableAnnotationDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("XYDrawableAnnotationDemo1", null, "$ million", xydataset, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainPannable(true);//from w ww .java 2s . c o m xyplot.setRangePannable(true); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setLowerMargin(0.20000000000000001D); dateaxis.setUpperMargin(0.20000000000000001D); dateaxis.setStandardTickUnits(createStandardDateTickUnits()); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setLowerMargin(0.20000000000000001D); numberaxis.setUpperMargin(0.20000000000000001D); XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(); xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseLinesVisible(true); xylineandshaperenderer.setSeriesShape(0, new java.awt.geom.Ellipse2D.Double(-5D, -5D, 10D, 10D)); xylineandshaperenderer.setSeriesShape(1, new java.awt.geom.Ellipse2D.Double(-5D, -5D, 10D, 10D)); xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(3F)); xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(3F, 1, 1, 5F, new float[] { 10F, 5F }, 0.0F)); xylineandshaperenderer.setSeriesFillPaint(0, Color.white); xylineandshaperenderer.setSeriesFillPaint(1, Color.white); xylineandshaperenderer.setUseFillPaint(true); xylineandshaperenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); xylineandshaperenderer.setDefaultEntityRadius(6); xylineandshaperenderer.addAnnotation(new XYDrawableAnnotation((new Month(4, 2005)).getFirstMillisecond(), 600D, 180D, 100D, 3D, createPieChart())); xylineandshaperenderer.addAnnotation(new XYDrawableAnnotation((new Month(9, 2007)).getFirstMillisecond(), 1250D, 120D, 100D, 2D, createBarChart())); xyplot.setRenderer(xylineandshaperenderer); return jfreechart; }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.utils.MyBarRendererThresholdPaint.java
public Paint getItemPaint(int row, int column) { logger.debug("IN"); String columnKey = (String) dataset.getColumnKey(column); int separator = columnKey.indexOf('-'); String month = columnKey.substring(0, separator); String year = columnKey.substring(separator + 1); Number value = dataset.getValue(row, column); // value put in dataset (- 0.5 or 0.5) Month currentMonth = new Month(Integer.valueOf(month), Integer.valueOf(year)); // value for that month TimeSeriesDataItem item = timeSeries.getDataItem(currentMonth); if (nullValues.contains(columnKey)) { return background; }//from ww w .j av a2s .c om // If no item is retrieved means that no value was specified for that month in that year if (item == null || item.getValue() == null) { return background; } Double currentValue = (Double) item.getValue(); TreeSet<Double> orderedThresholds = new TreeSet<Double>(thresholds.keySet()); Double thresholdGiveColor = null; // if dealing with targets, begin from first target and go to on till the current value is major if (useTargets) { boolean stop = false; for (Iterator iterator = orderedThresholds.iterator(); iterator.hasNext() && stop == false;) { Double currentThres = (Double) iterator.next(); if (currentValue >= currentThres) { thresholdGiveColor = currentThres; } else { stop = true; } } //previous threshold is the right threshold that has been passed, if it is null means that we are in the bottom case } else if (!useTargets) { // if dealing with baseline, begin from first baseline and go to the last; // opposite case than targets, it gets the next baseline boolean stop = false; for (Iterator iterator = orderedThresholds.iterator(); iterator.hasNext() && stop == false;) { Double currentThres = (Double) iterator.next(); if (currentValue > currentThres) { } else { stop = true; thresholdGiveColor = currentThres; } } if (stop == false) { // means that current value was > than last baselines, so we are in the bottom case thresholdGiveColor = null; } } // ******* Get the color ************* Color colorToReturn = null; if (thresholdGiveColor == null) { //bottom case if (bottomThreshold != null && bottomThreshold.getColor() != null) { colorToReturn = bottomThreshold.getColor(); } if (colorToReturn == null) { colorToReturn = Color.BLACK; } } else { if (thresholds.get(thresholdGiveColor) != null && thresholds.get(thresholdGiveColor).getColor() != null) colorToReturn = thresholds.get(thresholdGiveColor).getColor(); if (colorToReturn == null) { colorToReturn = Color.BLACK; } } logger.debug("OUT"); return colorToReturn; }
From source file:org.jfree.chart.demo.CompareToPreviousYearDemo.java
private static XYDataset createDataset2006() { TimeSeries timeseries = new TimeSeries("Sales 2006"); timeseries.add(new Month(1, 2006), 100D); timeseries.add(new Month(2, 2006), 102.3D); timeseries.add(new Month(3, 2006), 105.7D); timeseries.add(new Month(4, 2006), 104.2D); timeseries.add(new Month(5, 2006), 114.7D); timeseries.add(new Month(6, 2006), 121.7D); timeseries.add(new Month(7, 2006), 155.59999999999999D); timeseries.add(new Month(8, 2006), 143.19999999999999D); timeseries.add(new Month(9, 2006), 131.90000000000001D); timeseries.add(new Month(10, 2006), 120D); timeseries.add(new Month(11, 2006), 109.90000000000001D); timeseries.add(new Month(12, 2006), 99.599999999999994D); TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); timeseriescollection.addSeries(timeseries); timeseriescollection.setXPosition(TimePeriodAnchor.MIDDLE); return timeseriescollection; }
From source file:org.jfree.chart.demo.TimeSeriesDemo3.java
/** * A demonstration application showing a quarterly time series containing a null value. * * @param title the frame title./*from www . jav a2s . co m*/ */ public TimeSeriesDemo3(final String title) { super(title); final TimeSeries series1 = new TimeSeries("Series 1", Month.class); series1.add(new Month(1, 2002), 500.2); series1.add(new Month(2, 2002), 694.1); series1.add(new Month(3, 2002), 734.4); series1.add(new Month(4, 2002), 453.2); series1.add(new Month(5, 2002), 500.2); series1.add(new Month(6, 2002), 345.6); series1.add(new Month(7, 2002), 500.2); series1.add(new Month(8, 2002), 694.1); series1.add(new Month(9, 2002), 734.4); series1.add(new Month(10, 2002), 453.2); series1.add(new Month(11, 2002), 500.2); series1.add(new Month(12, 2002), 345.6); final TimeSeries series2 = new TimeSeries("Series 2", Month.class); series2.add(new Month(1, 2002), 234.1); series2.add(new Month(2, 2002), 623.7); series2.add(new Month(3, 2002), 642.5); series2.add(new Month(4, 2002), 651.4); series2.add(new Month(5, 2002), 643.5); series2.add(new Month(6, 2002), 785.6); series2.add(new Month(7, 2002), 234.1); series2.add(new Month(8, 2002), 623.7); series2.add(new Month(9, 2002), 642.5); series2.add(new Month(10, 2002), 651.4); series2.add(new Month(11, 2002), 643.5); series2.add(new Month(12, 2002), 785.6); final TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series1); dataset.addSeries(series2); final JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:org.hxzon.demo.jfreechart.DatasetVisibleDemo.java
private static XYDataset createDataset() { TimeSeries s1 = new TimeSeries(series1Name); s1.add(new Month(1, 2001), 181.8); s1.add(new Month(2, 2001), 167.3); s1.add(new Month(4, 2001), 153.8); s1.add(new Month(5, 2001), 167.6); s1.add(new Month(6, 2001), 158.8); s1.add(new Month(9, 2001), 148.3); s1.add(new Month(10, 2001), 153.9); s1.add(new Month(11, 2001), 142.7); s1.add(new Month(12, 2001), 123.2); s1.add(new Month(1, 2002), 131.8); s1.add(new Month(2, 2002), 139.6); s1.add(new Month(3, 2002), 142.9); s1.add(new Month(4, 2002), 138.7); s1.add(new Month(6, 2002), 137.3); s1.add(new Month(7, 2002), 143.9); s1.add(new Month(8, 2002), 139.8); s1.add(new Month(9, 2002), 137.0); s1.add(new Month(10, 2002), 132.8); TimeSeries s2 = new TimeSeries(series2Name); s2.add(new Month(2, 2001), 129.6); s2.add(new Month(3, 2001), 123.2); s2.add(new Month(4, 2001), 117.2); s2.add(new Month(5, 2001), 124.1); s2.add(new Month(6, 2001), 122.6); s2.add(new Month(7, 2001), 119.2); s2.add(new Month(8, 2001), 116.5); s2.add(new Month(9, 2001), 112.7); s2.add(new Month(10, 2001), 101.5); s2.add(new Month(11, 2001), 106.1); s2.add(new Month(12, 2001), 110.3); s2.add(new Month(1, 2002), 111.7); s2.add(new Month(2, 2002), 111.0); s2.add(new Month(3, 2002), 109.6); s2.add(new Month(4, 2002), 113.2); s2.add(new Month(5, 2002), 111.6); s2.add(new Month(6, 2002), 108.8); s2.add(new Month(7, 2002), 101.6); TimeSeries s3 = new TimeSeries(series3Name); s3.add(new Month(2, 2001), 1129.6); s3.add(new Month(3, 2001), 1123.2); s3.add(new Month(4, 2001), 1117.2); s3.add(new Month(5, 2001), 1124.1); s3.add(new Month(6, 2001), 1122.6); s3.add(new Month(7, 2001), 1119.2); s3.add(new Month(8, 2001), 1116.5); s3.add(new Month(9, 2001), 1112.7); s3.add(new Month(10, 2001), 1101.5); s3.add(new Month(11, 2001), 1106.1); s3.add(new Month(12, 2001), 1110.3); s3.add(new Month(1, 2002), 1111.7); s3.add(new Month(2, 2002), 1111.0); s3.add(new Month(3, 2002), 1109.6); s3.add(new Month(4, 2002), 1113.2); s3.add(new Month(5, 2002), 1111.6); s3.add(new Month(6, 2002), 1108.8); s3.add(new Month(7, 2002), 1101.6); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(s3);/*from w w w .j av a 2 s . c o m*/ dataset.addSeries(s2); dataset.addSeries(s1); return dataset; }
From source file:org.hxzon.demo.jfreechart.DatasetVisibleDemo3.java
private static XYDataset createDataset1() { boolean notify = false; TimeSeries s1 = new TimeSeries(series1Name); s1.add(new Month(1, 2001), 181.8, notify); s1.add(new Month(2, 2001), 167.3, notify); s1.add(new Month(4, 2001), 153.8, notify); s1.add(new Month(5, 2001), 167.6, notify); s1.add(new Month(6, 2001), 158.8, notify); s1.add(new Month(9, 2001), 148.3, notify); s1.add(new Month(10, 2001), 153.9, notify); s1.add(new Month(11, 2001), 142.7, notify); s1.add(new Month(12, 2001), 123.2, notify); s1.add(new Month(1, 2002), 131.8, notify); s1.add(new Month(2, 2002), 139.6, notify); s1.add(new Month(3, 2002), 142.9, notify); s1.add(new Month(4, 2002), 138.7, notify); s1.add(new Month(6, 2002), 137.3, notify); s1.add(new Month(7, 2002), 143.9, notify); s1.add(new Month(8, 2002), 139.8, notify); s1.add(new Month(9, 2002), 137.0, notify); s1.add(new Month(10, 2002), 132.8, notify); TimeSeries s2 = new TimeSeries(series2Name); s2.add(new Month(2, 2001), 129.6, notify); s2.add(new Month(3, 2001), 123.2, notify); s2.add(new Month(4, 2001), 117.2, notify); s2.add(new Month(5, 2001), 124.1, notify); s2.add(new Month(6, 2001), 122.6, notify); s2.add(new Month(7, 2001), 119.2, notify); s2.add(new Month(8, 2001), 116.5, notify); s2.add(new Month(9, 2001), 112.7, notify); s2.add(new Month(10, 2001), 101.5, notify); s2.add(new Month(11, 2001), 106.1, notify); s2.add(new Month(12, 2001), 110.3, notify); s2.add(new Month(1, 2002), 111.7, notify); s2.add(new Month(2, 2002), 111.0, notify); s2.add(new Month(3, 2002), 109.6, notify); s2.add(new Month(4, 2002), 113.2, notify); s2.add(new Month(5, 2002), 111.6, notify); s2.add(new Month(6, 2002), 108.8, notify); s2.add(new Month(7, 2002), 101.6, notify); TimeSeries s3 = new TimeSeries(series3Name); s3.add(new Month(2, 2001), 1129.6, notify); s3.add(new Month(3, 2001), 1123.2, notify); s3.add(new Month(4, 2001), 1117.2, notify); s3.add(new Month(5, 2001), 1124.1, notify); s3.add(new Month(6, 2001), 1122.6, notify); s3.add(new Month(7, 2001), 1119.2, notify); s3.add(new Month(8, 2001), 1116.5, notify); s3.add(new Month(9, 2001), 1112.7, notify); s3.add(new Month(10, 2001), 1101.5, notify); s3.add(new Month(11, 2001), 1106.1, notify); s3.add(new Month(12, 2001), 1110.3, notify); s3.add(new Month(1, 2002), 1111.7, notify); s3.add(new Month(2, 2002), 1111.0, notify); s3.add(new Month(3, 2002), 1109.6, notify); s3.add(new Month(4, 2002), 1113.2, notify); s3.add(new Month(5, 2002), 1111.6, notify); s3.add(new Month(6, 2002), 1108.8, notify); s3.add(new Month(7, 2002), 1101.6, notify); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(s3);/*from w ww . j a v a 2 s .c o m*/ dataset.addSeries(s2); dataset.addSeries(s1); return dataset; }
From source file:org.hxzon.demo.jfreechart.DatasetVisibleDemo2.java
private static XYDataset createDataset() { boolean notify = false; TimeSeries s1 = new TimeSeries(series1Name); s1.add(new Month(1, 2001), 181.8, notify); s1.add(new Month(2, 2001), 167.3, notify); s1.add(new Month(4, 2001), 153.8, notify); s1.add(new Month(5, 2001), 167.6, notify); s1.add(new Month(6, 2001), 158.8, notify); s1.add(new Month(9, 2001), 148.3, notify); s1.add(new Month(10, 2001), 153.9, notify); s1.add(new Month(11, 2001), 142.7, notify); s1.add(new Month(12, 2001), 123.2, notify); s1.add(new Month(1, 2002), 131.8, notify); s1.add(new Month(2, 2002), 139.6, notify); s1.add(new Month(3, 2002), 142.9, notify); s1.add(new Month(4, 2002), 138.7, notify); s1.add(new Month(6, 2002), 137.3, notify); s1.add(new Month(7, 2002), 143.9, notify); s1.add(new Month(8, 2002), 139.8, notify); s1.add(new Month(9, 2002), 137.0, notify); s1.add(new Month(10, 2002), 132.8, notify); TimeSeries s2 = new TimeSeries(series2Name); s2.add(new Month(2, 2001), 129.6, notify); s2.add(new Month(3, 2001), 123.2, notify); s2.add(new Month(4, 2001), 117.2, notify); s2.add(new Month(5, 2001), 124.1, notify); s2.add(new Month(6, 2001), 122.6, notify); s2.add(new Month(7, 2001), 119.2, notify); s2.add(new Month(8, 2001), 116.5, notify); s2.add(new Month(9, 2001), 112.7, notify); s2.add(new Month(10, 2001), 101.5, notify); s2.add(new Month(11, 2001), 106.1, notify); s2.add(new Month(12, 2001), 110.3, notify); s2.add(new Month(1, 2002), 111.7, notify); s2.add(new Month(2, 2002), 111.0, notify); s2.add(new Month(3, 2002), 109.6, notify); s2.add(new Month(4, 2002), 113.2, notify); s2.add(new Month(5, 2002), 111.6, notify); s2.add(new Month(6, 2002), 108.8, notify); s2.add(new Month(7, 2002), 101.6, notify); TimeSeries s3 = new TimeSeries(series3Name); s3.add(new Month(2, 2001), 1129.6, notify); s3.add(new Month(3, 2001), 1123.2, notify); s3.add(new Month(4, 2001), 1117.2, notify); s3.add(new Month(5, 2001), 1124.1, notify); s3.add(new Month(6, 2001), 1122.6, notify); s3.add(new Month(7, 2001), 1119.2, notify); s3.add(new Month(8, 2001), 1116.5, notify); s3.add(new Month(9, 2001), 1112.7, notify); s3.add(new Month(10, 2001), 1101.5, notify); s3.add(new Month(11, 2001), 1106.1, notify); s3.add(new Month(12, 2001), 1110.3, notify); s3.add(new Month(1, 2002), 1111.7, notify); s3.add(new Month(2, 2002), 1111.0, notify); s3.add(new Month(3, 2002), 1109.6, notify); s3.add(new Month(4, 2002), 1113.2, notify); s3.add(new Month(5, 2002), 1111.6, notify); s3.add(new Month(6, 2002), 1108.8, notify); s3.add(new Month(7, 2002), 1101.6, notify); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(s3);//from w w w . j av a 2s . c om dataset.addSeries(s2); dataset.addSeries(s1); return dataset; }
From source file:org.n52.oxf.render.sos.TimeCategoryPlot.java
/** * Creates a dataset, consisting of two series of monthly data. * * @return The dataset.//from w ww .j av a 2s . com */ private static XYDataset createDataset() { TimeSeries s1 = new TimeSeries("L&G European Index Trust", Month.class); s1.add(new Month(2, 2001), 0); s1.add(new Month(3, 2001), 4); s1.add(new Month(4, 2001), 3); s1.add(new Month(5, 2001), 167.6); s1.add(new Month(6, 2001), 158.8); s1.add(new Month(7, 2001), 148.3); s1.add(new Month(8, 2001), 153.9); s1.add(new Month(9, 2001), 142.7); s1.add(new Month(10, 2001), 123.2); s1.add(new Month(11, 2001), 131.8); s1.add(new Month(12, 2001), 139.6); s1.add(new Month(1, 2002), 142.9); s1.add(new Month(2, 2002), 138.7); s1.add(new Month(3, 2002), 137.3); s1.add(new Month(4, 2002), 143.9); s1.add(new Month(5, 2002), 139.8); s1.add(new Month(6, 2002), 137.0); s1.add(new Month(7, 2002), 132.8); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(s1); dataset.setDomainIsPointsInTime(true); return dataset; }
From source file:org.jfree.data.time.MonthTest.java
/** * Common test setup./* w w w . j av a 2s . com*/ */ @Before public void setUp() { this.jan1900 = new Month(MonthConstants.JANUARY, 1900); this.feb1900 = new Month(MonthConstants.FEBRUARY, 1900); this.nov9999 = new Month(MonthConstants.NOVEMBER, 9999); this.dec9999 = new Month(MonthConstants.DECEMBER, 9999); }