/** * Draws the chart with a <code>null</code> info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ public void testDrawWithNullInfo() { boolean success = false; try { double[][] starts = new double[][] {{0.1, 0.2, 0.3}, {0.3, 0.4, 0.5}}; double[][] ends = new double[][] {{0.5, 0.6, 0.7}, {0.7, 0.8, 0.9}}; DefaultIntervalCategoryDataset dataset = new DefaultIntervalCategoryDataset(starts, ends); IntervalBarRenderer renderer = new IntervalBarRenderer(); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), renderer); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); }
private static JFreeChart createChart() { final CategoryAxis domainAxis = new CategoryAxis(""); final NumberAxis rangeAxis = new NumberAxis(""); final IntervalBarRenderer renderer = new IntervalBarRenderer(); renderer.setBaseToolTipGenerator(new IntervalCategoryToolTipGenerator()); renderer.setBaseToolTipGenerator((dataset, row, column) -> { final IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset; return icd.getRowKey(row) + ": " + (icd.getEndValue(row, column).doubleValue() - icd.getStartValue(row, column).doubleValue()); }); final CategoryPlot plot = new CategoryPlot(null, domainAxis, rangeAxis, renderer); final JFreeChart chart = new JFreeChart("Unternehmenswert", plot); plot.setDomainGridlinesVisible(true); plot.setRangePannable(true); ChartUtilities.applyCurrentTheme(chart); return chart; }
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { IntervalBarRenderer r1 = new IntervalBarRenderer(); IntervalBarRenderer r2 = new IntervalBarRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); }
/** * Problem that the equals() method distinguishes all fields. */ public void testEquals() { IntervalBarRenderer r1 = new IntervalBarRenderer(); IntervalBarRenderer r2 = new IntervalBarRenderer(); assertEquals(r1, r2); // the renderer should not be equal to a BarRenderer BarRenderer br = new BarRenderer(); assertFalse(r1.equals(br)); }
/** * Problem that the equals(...) method distinguishes all fields. */ public void testEquals() { IntervalBarRenderer r1 = new IntervalBarRenderer(); IntervalBarRenderer r2 = new IntervalBarRenderer(); assertEquals(r1, r2); }
/** * Problem that the equals() method distinguishes all fields. */ public void testEquals() { IntervalBarRenderer r1 = new IntervalBarRenderer(); IntervalBarRenderer r2 = new IntervalBarRenderer(); assertEquals(r1, r2); }
/** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { IntervalBarRenderer r1 = new IntervalBarRenderer(); assertTrue(r1 instanceof PublicCloneable); }