public static void setTimeSeriesBarRender(Plot plot, boolean isShowDataLabels) { XYPlot xyplot = (XYPlot) plot; xyplot.setNoDataMessage(NO_DATA_MSG); XYBarRenderer xyRenderer = new XYBarRenderer(0.1D); xyRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); if (isShowDataLabels) { xyRenderer.setBaseItemLabelsVisible(true); xyRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); } StandardXYToolTipGenerator xyTooltipGenerator = new StandardXYToolTipGenerator("{1}:{2}", new SimpleDateFormat("yyyy-MM-dd"), new DecimalFormat("0")); xyRenderer.setBaseToolTipGenerator(xyTooltipGenerator); setXY_XAixs(xyplot); setXY_YAixs(xyplot); }
public static void setTimeSeriesRender(Plot plot, boolean isShowData, boolean isShapesVisible) { XYPlot xyplot = (XYPlot) plot; xyplot.setNoDataMessage(NO_DATA_MSG); xyplot.setInsets(new RectangleInsets(10, 10, 5, 10)); XYLineAndShapeRenderer xyRenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xyRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); xyRenderer.setBaseShapesVisible(false); if (isShowData) { xyRenderer.setBaseItemLabelsVisible(true); xyRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); xyRenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE1, TextAnchor.BOTTOM_CENTER)); } xyRenderer.setBaseShapesVisible(isShapesVisible); DateAxis domainAxis = (DateAxis) xyplot.getDomainAxis(); domainAxis.setAutoTickUnitSelection(false); DateTickUnit dateTickUnit = new DateTickUnit(DateTickUnitType.YEAR, 1, new SimpleDateFormat("yyyy-MM")); domainAxis.setTickUnit(dateTickUnit); StandardXYToolTipGenerator xyTooltipGenerator = new StandardXYToolTipGenerator("{1}:{2}", new SimpleDateFormat("yyyy-MM-dd"), new DecimalFormat("0")); xyRenderer.setBaseToolTipGenerator(xyTooltipGenerator); setXY_XAixs(xyplot); setXY_YAixs(xyplot); }
/** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { YIntervalRenderer r1 = new YIntervalRenderer(); YIntervalRenderer r2 = (YIntervalRenderer) r1.clone(); assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check independence r1.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator()); assertTrue(r1.equals(r2)); r1.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator()); assertTrue(r1.equals(r2)); r1.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0), Layer.FOREGROUND); assertFalse(r1.equals(r2)); r2.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0), Layer.FOREGROUND); assertTrue(r1.equals(r2)); r1.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0), Layer.BACKGROUND); assertFalse(r1.equals(r2)); r2.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0), Layer.BACKGROUND); assertTrue(r1.equals(r2)); }
@Test public void testEquals_ObjectList() { XYBarRenderer r1 = new XYBarRenderer(); r1.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator()); XYBarRenderer r2 = new XYBarRenderer(); r2.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator()); assertEquals(r1, r2); r2.setSeriesItemLabelGenerator(1, new StandardXYItemLabelGenerator("X")); assertNotEquals(r1, r2); }
/** * Tests this object for equality with an arbitrary object. * * @param obj the other object (<code>null</code> permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof StandardXYItemLabelGenerator) { return super.equals(obj); } return false; }
/** * Simple check that hashCode is implemented. */ public void testHashCode() { StandardXYItemLabelGenerator g1 = new StandardXYItemLabelGenerator(); StandardXYItemLabelGenerator g2 = new StandardXYItemLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); }
/** * Check that the equals() method distinguishes all fields. */ public void testEquals() { YIntervalRenderer r1 = new YIntervalRenderer(); YIntervalRenderer r2 = new YIntervalRenderer(); assertEquals(r1, r2); // the following fields are inherited from the AbstractXYItemRenderer r1.setItemLabelGenerator(new StandardXYItemLabelGenerator()); assertFalse(r1.equals(r2)); r2.setItemLabelGenerator(new StandardXYItemLabelGenerator()); assertTrue(r1.equals(r2)); r1.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator()); assertTrue(r1.equals(r2)); r1.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); assertFalse(r1.equals(r2)); r2.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); assertTrue(r1.equals(r2)); r1.setToolTipGenerator(new StandardXYToolTipGenerator()); assertFalse(r1.equals(r2)); r2.setToolTipGenerator(new StandardXYToolTipGenerator()); assertTrue(r1.equals(r2)); r1.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator()); assertTrue(r1.equals(r2)); r1.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); assertFalse(r1.equals(r2)); r2.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); assertTrue(r1.equals(r2)); r1.setURLGenerator(new StandardXYURLGenerator()); assertFalse(r1.equals(r2)); r2.setURLGenerator(new StandardXYURLGenerator()); assertTrue(r1.equals(r2)); r1.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.FOREGROUND); assertFalse(r1.equals(r2)); r2.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.FOREGROUND); assertTrue(r1.equals(r2)); r1.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.BACKGROUND); assertFalse(r1.equals(r2)); r2.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.BACKGROUND); assertTrue(r1.equals(r2)); r1.setDefaultEntityRadius(99); assertFalse(r1.equals(r2)); r2.setDefaultEntityRadius(99); assertTrue(r1.equals(r2)); r1.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator( "{0} {1}")); assertFalse(r1.equals(r2)); r2.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator( "{0} {1}")); assertTrue(r1.equals(r2)); r1.setLegendItemToolTipGenerator(new StandardXYSeriesLabelGenerator()); assertFalse(r1.equals(r2)); r2.setLegendItemToolTipGenerator(new StandardXYSeriesLabelGenerator()); assertTrue(r1.equals(r2)); r1.setLegendItemURLGenerator(new StandardXYSeriesLabelGenerator()); assertFalse(r1.equals(r2)); r2.setLegendItemURLGenerator(new StandardXYSeriesLabelGenerator()); assertTrue(r1.equals(r2)); }
/** * Check that the equals() method distinguishes all fields. */ @Test public void testEquals() { YIntervalRenderer r1 = new YIntervalRenderer(); YIntervalRenderer r2 = new YIntervalRenderer(); assertEquals(r1, r2); // the following fields are inherited from the AbstractXYItemRenderer r1.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator()); assertTrue(r1.equals(r2)); r1.setDefaultItemLabelGenerator(new StandardXYItemLabelGenerator()); assertFalse(r1.equals(r2)); r2.setDefaultItemLabelGenerator(new StandardXYItemLabelGenerator()); assertTrue(r1.equals(r2)); r1.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator()); assertTrue(r1.equals(r2)); r1.setDefaultToolTipGenerator(new StandardXYToolTipGenerator()); assertFalse(r1.equals(r2)); r2.setDefaultToolTipGenerator(new StandardXYToolTipGenerator()); assertTrue(r1.equals(r2)); r1.setURLGenerator(new StandardXYURLGenerator()); assertFalse(r1.equals(r2)); r2.setURLGenerator(new StandardXYURLGenerator()); assertTrue(r1.equals(r2)); r1.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.FOREGROUND); assertFalse(r1.equals(r2)); r2.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.FOREGROUND); assertTrue(r1.equals(r2)); r1.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.BACKGROUND); assertFalse(r1.equals(r2)); r2.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.BACKGROUND); assertTrue(r1.equals(r2)); r1.setDefaultEntityRadius(99); assertFalse(r1.equals(r2)); r2.setDefaultEntityRadius(99); assertTrue(r1.equals(r2)); r1.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator( "{0} {1}")); assertFalse(r1.equals(r2)); r2.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator( "{0} {1}")); assertTrue(r1.equals(r2)); r1.setLegendItemToolTipGenerator(new StandardXYSeriesLabelGenerator()); assertFalse(r1.equals(r2)); r2.setLegendItemToolTipGenerator(new StandardXYSeriesLabelGenerator()); assertTrue(r1.equals(r2)); r1.setLegendItemURLGenerator(new StandardXYSeriesLabelGenerator()); assertFalse(r1.equals(r2)); r2.setLegendItemURLGenerator(new StandardXYSeriesLabelGenerator()); assertTrue(r1.equals(r2)); r1.setAdditionalItemLabelGenerator(new IntervalXYItemLabelGenerator()); assertFalse(r1.equals(r2)); r2.setAdditionalItemLabelGenerator(new IntervalXYItemLabelGenerator()); assertTrue(r1.equals(r2)); }
/** * Check that the equals() method distinguishes all fields. */ public void testEquals() { YIntervalRenderer r1 = new YIntervalRenderer(); YIntervalRenderer r2 = new YIntervalRenderer(); assertEquals(r1, r2); // the following fields are inherited from the AbstractXYItemRenderer r1.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator()); assertTrue(r1.equals(r2)); r1.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); assertFalse(r1.equals(r2)); r2.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); assertTrue(r1.equals(r2)); r1.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator()); assertTrue(r1.equals(r2)); r1.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); assertFalse(r1.equals(r2)); r2.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); assertTrue(r1.equals(r2)); r1.setSeriesURLGenerator(0, new StandardXYURLGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesURLGenerator(0, new StandardXYURLGenerator()); assertTrue(r1.equals(r2)); r1.setBaseURLGenerator(new StandardXYURLGenerator()); assertFalse(r1.equals(r2)); r2.setBaseURLGenerator(new StandardXYURLGenerator()); assertTrue(r1.equals(r2)); r1.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.FOREGROUND); assertFalse(r1.equals(r2)); r2.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.FOREGROUND); assertTrue(r1.equals(r2)); r1.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.BACKGROUND); assertFalse(r1.equals(r2)); r2.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.BACKGROUND); assertTrue(r1.equals(r2)); r1.setDefaultEntityRadius(99); assertFalse(r1.equals(r2)); r2.setDefaultEntityRadius(99); assertTrue(r1.equals(r2)); r1.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator( "{0} {1}")); assertFalse(r1.equals(r2)); r2.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator( "{0} {1}")); assertTrue(r1.equals(r2)); r1.setLegendItemToolTipGenerator(new StandardXYSeriesLabelGenerator()); assertFalse(r1.equals(r2)); r2.setLegendItemToolTipGenerator(new StandardXYSeriesLabelGenerator()); assertTrue(r1.equals(r2)); r1.setLegendItemURLGenerator(new StandardXYSeriesLabelGenerator()); assertFalse(r1.equals(r2)); r2.setLegendItemURLGenerator(new StandardXYSeriesLabelGenerator()); assertTrue(r1.equals(r2)); r1.setAdditionalItemLabelGenerator(new IntervalXYItemLabelGenerator()); assertFalse(r1.equals(r2)); r2.setAdditionalItemLabelGenerator(new IntervalXYItemLabelGenerator()); assertTrue(r1.equals(r2)); }
/** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { StandardXYItemLabelGenerator g1 = new StandardXYItemLabelGenerator(); assertTrue(g1 instanceof PublicCloneable); }
@Override protected JFreeChart createChart(CCMovieList movielist, StatisticsTypeFilter source) { if (chart != null) return chart; indexMap = new HashMap<>(); datasetList = new HashMap<>(); DateAxis dateAxis = new DateAxis(""); //$NON-NLS-1$ DateFormat chartFormatter = new SimpleDateFormat("dd.MM.yyyy"); //$NON-NLS-1$ dateAxis.setDateFormatOverride(chartFormatter); valueAxis = new NumberAxis(""); //$NON-NLS-1$ valueAxis.setRange(0, 35); plot = new XYPlot(new DefaultXYDataset(), dateAxis, valueAxis, new StandardXYItemRenderer(StandardXYItemRenderer.LINES, null, null)); List<TupleSeriesEpList> serieslist = getIncludedSeries(movielist); CCDate startdate = GetStartDate(serieslist); CCDate enddate = GetEndDate(serieslist); int idx = 0; for (TupleSeriesEpList series : serieslist) { indexMap.put(series.series, idx); Color cf = new Color(StatisticsHelper.CHART_COLORS[idx % StatisticsHelper.CHART_COLORS.length]); Color ca = new Color(cf.getRed(), cf.getGreen(), cf.getBlue(), 178); XYDataset dataset = getDataSet(series, startdate, enddate, false); XYDataset startset = getDataSet(series, startdate, enddate, true); datasetList.put(3*idx, dataset); plot.setDataset(3*idx, dataset); plot.setRenderer(3*idx, new XYAreaRenderer(XYAreaRenderer.AREA, null, null)); plot.getRenderer(3*idx).setSeriesPaint(0, ca); plot.getRenderer(3*idx).setSeriesVisibleInLegend(0, false); datasetList.put(3*idx + 1, dataset); plot.setDataset(3*idx + 1, dataset); plot.setRenderer(3*idx + 1, new StandardXYItemRenderer(StandardXYItemRenderer.LINES, null, null)); plot.getRenderer(3*idx + 1).setSeriesPaint(0, cf); plot.getRenderer(3*idx + 1).setSeriesVisibleInLegend(0, false); datasetList.put(3*idx + 2, startset); plot.setDataset( 3*idx + 2, startset); plot.setRenderer(3*idx + 2, new StandardXYItemRenderer(StandardXYItemRenderer.LINES, null, null)); plot.getRenderer(3*idx + 2).setSeriesPaint(0, cf); plot.getRenderer(3*idx + 2).setSeriesVisibleInLegend(0, false); plot.getRenderer(3*idx + 2).setBaseItemLabelGenerator(new StandardXYItemLabelGenerator("{0}")); //$NON-NLS-1$ plot.getRenderer(3*idx + 2).setBaseItemLabelPaint(cf); plot.getRenderer(3*idx + 2).setBaseItemLabelsVisible(true); plot.getRenderer(3*idx + 2).setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_LEFT, TextAnchor.BOTTOM_LEFT, -45)); plot.getRenderer(3*idx + 2).setSeriesItemLabelsVisible(0, true); idx++; } domainTotalRangeMin = startdate.asMilliseconds(); domainTotalRangeMax = enddate.asMilliseconds(); if (domainTotalRangeMin == domainTotalRangeMax) domainTotalRangeMax++; plot.setBackgroundPaint(XYBACKGROUND_COLOR); plot.setDomainGridlinePaint(GRIDLINECOLOR); plot.setRangeGridlinePaint(GRIDLINECOLOR); chart = new JFreeChart(plot); //chart.removeLegend(); chart.setBackgroundPaint(null); plot.getDomainAxis().setTickLabelPaint(TEXT_FOREGROUND); plot.getRangeAxis().setTickLabelPaint(TEXT_FOREGROUND); plot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis = plot.getDomainAxis(); return chart; }