/** * Problem that the equals(...) method distinguishes all fields. */ public void testEquals() { DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer(); DefaultCategoryItemRenderer r2 = new DefaultCategoryItemRenderer(); assertEquals(r1, r2); }
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer(); DefaultCategoryItemRenderer r2 = new DefaultCategoryItemRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); }
/** * Some tests for the getRangeAxisForDataset() method. */ @Test public void testGetRangeAxisForDataset() { CategoryDataset dataset = new DefaultCategoryDataset(); CategoryAxis xAxis = new CategoryAxis("X"); NumberAxis yAxis = new NumberAxis("Y"); CategoryItemRenderer renderer = new DefaultCategoryItemRenderer(); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); assertEquals(yAxis, plot.getRangeAxisForDataset(0)); // should get IllegalArgumentException for negative index boolean pass = false; try { plot.getRangeAxisForDataset(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); // if multiple axes are mapped, the first in the list should be // returned... NumberAxis yAxis2 = new NumberAxis("Y2"); plot.setRangeAxis(1, yAxis2); assertEquals(yAxis, plot.getRangeAxisForDataset(0)); plot.mapDatasetToRangeAxis(0, 1); assertEquals(yAxis2, plot.getRangeAxisForDataset(0)); List axisIndices = Arrays.asList(new Integer[] {new Integer(0), new Integer(1)}); plot.mapDatasetToRangeAxes(0, axisIndices); assertEquals(yAxis, plot.getRangeAxisForDataset(0)); axisIndices = Arrays.asList(new Integer[] {new Integer(1), new Integer(2)}); plot.mapDatasetToRangeAxes(0, axisIndices); assertEquals(yAxis2, plot.getRangeAxisForDataset(0)); }
/** * Some tests for the getRangeAxisForDataset() method. */ public void testGetRangeAxisForDataset() { CategoryDataset dataset = new DefaultCategoryDataset(); CategoryAxis xAxis = new CategoryAxis("X"); NumberAxis yAxis = new NumberAxis("Y"); CategoryItemRenderer renderer = new DefaultCategoryItemRenderer(); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); assertEquals(yAxis, plot.getRangeAxisForDataset(0)); // should get IllegalArgumentException for negative index boolean pass = false; try { plot.getRangeAxisForDataset(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); // if multiple axes are mapped, the first in the list should be // returned... NumberAxis yAxis2 = new NumberAxis("Y2"); plot.setRangeAxis(1, yAxis2); assertEquals(yAxis, plot.getRangeAxisForDataset(0)); plot.mapDatasetToRangeAxis(0, 1); assertEquals(yAxis2, plot.getRangeAxisForDataset(0)); List axisIndices = Arrays.asList(new Integer[] {new Integer(0), new Integer(1)}); plot.mapDatasetToRangeAxes(0, axisIndices); assertEquals(yAxis, plot.getRangeAxisForDataset(0)); axisIndices = Arrays.asList(new Integer[] {new Integer(1), new Integer(2)}); plot.mapDatasetToRangeAxes(0, axisIndices); assertEquals(yAxis2, plot.getRangeAxisForDataset(0)); }
private CategoryItemRenderer createRenderer(List<ProfileRow> rows){ // create renderer DefaultCategoryItemRenderer renderer = new DefaultCategoryItemRenderer(); renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator()); renderer.setShapesVisible(false); // generate colors Collections.sort(rows); float position = 0.0f; float step = 1.0f / ((float)rows.size()); for (ProfileRow row : rows) { if(selectedIndexes.contains(row.series)){ renderer.setSeriesPaint(row.series, Color.black); } else { row.color = getColor(position); renderer.setSeriesPaint(row.series, getColor(position)); } position += step; } //List isn't initialised, if visualising clustered profiles if(list != null){ list.setSelectedRows(selectedIndexes, this, false, data); } return renderer; }
/** * Check that the equals() method distinguishes all fields. */ public void testEquals() { DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer(); DefaultCategoryItemRenderer r2 = new DefaultCategoryItemRenderer(); assertEquals(r1, r2); }
/** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer(); assertTrue(r1 instanceof PublicCloneable); }