/** * Check that the equals() method distinguishes all fields. */ public void testEquals() { XYLine3DRenderer r1 = new XYLine3DRenderer(); XYLine3DRenderer r2 = new XYLine3DRenderer(); assertEquals(r1, r2); r1.setXOffset(11.1); assertFalse(r1.equals(r2)); r2.setXOffset(11.1); assertTrue(r1.equals(r2)); r1.setYOffset(11.1); assertFalse(r1.equals(r2)); r2.setYOffset(11.1); assertTrue(r1.equals(r2)); r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(r1.equals(r2)); r2.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(r1.equals(r2)); }
@Override protected JFreeChart createXyLineChart() throws JRException { JFreeChart jfreeChart = super.createXyLineChart(); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); XYLineAndShapeRenderer lineRenderer = (XYLineAndShapeRenderer) jfreeChart.getXYPlot().getRenderer(); XYLine3DRenderer line3DRenderer = new XYLine3DRenderer(); line3DRenderer.setBaseToolTipGenerator(lineRenderer.getBaseToolTipGenerator()); line3DRenderer.setURLGenerator(lineRenderer.getURLGenerator()); line3DRenderer.setBaseStroke(new BasicStroke(2, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); line3DRenderer.setBaseLinesVisible(lineRenderer.getBaseLinesVisible()); line3DRenderer.setBaseShapesVisible(lineRenderer.getBaseShapesVisible()); Stroke stroke = new BasicStroke(2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); XYDataset xyDataset = xyPlot.getDataset(); if (xyDataset != null) { for (int i = 0; i < xyDataset.getSeriesCount(); i++) { line3DRenderer.setSeriesStroke(i, stroke); line3DRenderer.setSeriesLinesVisible(i, lineRenderer.getBaseLinesVisible()); line3DRenderer.setSeriesShapesVisible(i, lineRenderer.getBaseShapesVisible()); } } line3DRenderer.setXOffset(2); line3DRenderer.setYOffset(2); line3DRenderer.setWallPaint(ChartThemesConstants.GRAY_PAINT_134); xyPlot.setRenderer(line3DRenderer); return jfreeChart; }
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYLine3DRenderer r1 = new XYLine3DRenderer(); XYLine3DRenderer r2 = new XYLine3DRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); }
/** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XYLine3DRenderer r1 = new XYLine3DRenderer(); assertTrue(r1 instanceof PublicCloneable); }