/** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { CategoryTextAnnotation a1 = new CategoryTextAnnotation("Test", "Category", 1.0); CategoryTextAnnotation a2 = new CategoryTextAnnotation("Test", "Category", 1.0); assertTrue(a1.equals(a2)); // category a1.setCategory("Category 2"); assertFalse(a1.equals(a2)); a2.setCategory("Category 2"); assertTrue(a1.equals(a2)); // categoryAnchor a1.setCategoryAnchor(CategoryAnchor.START); assertFalse(a1.equals(a2)); a2.setCategoryAnchor(CategoryAnchor.START); assertTrue(a1.equals(a2)); // value a1.setValue(0.15); assertFalse(a1.equals(a2)); a2.setValue(0.15); assertTrue(a1.equals(a2)); }
/** * Draws the domain gridlines for the plot, if they are visible. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * * @see #drawRangeGridlines(Graphics2D, Rectangle2D, List) */ protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea) { if (!isDomainGridlinesVisible()) { return; } CategoryAnchor anchor = getDomainGridlinePosition(); RectangleEdge domainAxisEdge = getDomainAxisEdge(); CategoryDataset dataset = getDataset(); if (dataset == null) { return; } CategoryAxis axis = getDomainAxis(); if (axis != null) { int columnCount = dataset.getColumnCount(); for (int c = 0; c < columnCount; c++) { double xx = axis.getCategoryJava2DCoordinate(anchor, c, columnCount, dataArea, domainAxisEdge); CategoryItemRenderer renderer1 = getRenderer(); if (renderer1 != null) { renderer1.drawDomainGridline(g2, this, dataArea, xx); } } } }
/** * Draws the gridlines for the plot. * * @param g2 the graphics device. * @param dataArea the area inside the axes. */ protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea) { // draw the domain grid lines, if any... if (isDomainGridlinesVisible()) { CategoryAnchor anchor = getDomainGridlinePosition(); RectangleEdge domainAxisEdge = getDomainAxisEdge(); Stroke gridStroke = getDomainGridlineStroke(); Paint gridPaint = getDomainGridlinePaint(); if ((gridStroke != null) && (gridPaint != null)) { // iterate over the categories CategoryDataset data = getDataset(); if (data != null) { CategoryAxis axis = getDomainAxis(); if (axis != null) { int columnCount = data.getColumnCount(); for (int c = 0; c < columnCount; c++) { double xx = axis.getCategoryJava2DCoordinate( anchor, c, columnCount, dataArea, domainAxisEdge ); CategoryItemRenderer renderer1 = getRenderer(); if (renderer1 != null) { renderer1.drawDomainGridline(g2, this, dataArea, xx); } } } } } } }
/** * Problem equals method. */ public void testEquals() { assertEquals(CategoryAnchor.START, CategoryAnchor.START); assertEquals(CategoryAnchor.MIDDLE, CategoryAnchor.MIDDLE); assertEquals(CategoryAnchor.END, CategoryAnchor.END); assertFalse(CategoryAnchor.START.equals(CategoryAnchor.END)); assertFalse(CategoryAnchor.MIDDLE.equals(CategoryAnchor.END)); }
/** * Check that the equals() method distinguishes known instances. */ public void testEquals() { assertEquals(CategoryAnchor.START, CategoryAnchor.START); assertEquals(CategoryAnchor.MIDDLE, CategoryAnchor.MIDDLE); assertEquals(CategoryAnchor.END, CategoryAnchor.END); assertFalse(CategoryAnchor.START.equals(CategoryAnchor.END)); assertFalse(CategoryAnchor.MIDDLE.equals(CategoryAnchor.END)); }
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { CategoryAnchor a1 = CategoryAnchor.START; CategoryAnchor a2 = CategoryAnchor.START; assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); }
/** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { CategoryTextAnnotation a1 = new CategoryTextAnnotation( "Test", "Category", 1.0 ); CategoryTextAnnotation a2 = new CategoryTextAnnotation( "Test", "Category", 1.0 ); assertTrue(a1.equals(a2)); // category a1.setCategory("Category 2"); assertFalse(a1.equals(a2)); a2.setCategory("Category 2"); assertTrue(a1.equals(a2)); // categoryAnchor a1.setCategoryAnchor(CategoryAnchor.START); assertFalse(a1.equals(a2)); a2.setCategoryAnchor(CategoryAnchor.START); assertTrue(a1.equals(a2)); // value a1.setValue(0.15); assertFalse(a1.equals(a2)); a2.setValue(0.15); assertTrue(a1.equals(a2)); }
/** * Draws the gridlines for the plot. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * * @see #drawRangeGridlines(Graphics2D, Rectangle2D, List) */ protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea) { // draw the domain grid lines, if any... if (isDomainGridlinesVisible()) { CategoryAnchor anchor = getDomainGridlinePosition(); RectangleEdge domainAxisEdge = getDomainAxisEdge(); Stroke gridStroke = getDomainGridlineStroke(); Paint gridPaint = getDomainGridlinePaint(); if ((gridStroke != null) && (gridPaint != null)) { // iterate over the categories CategoryDataset data = getDataset(); if (data != null) { CategoryAxis axis = getDomainAxis(); if (axis != null) { int columnCount = data.getColumnCount(); for (int c = 0; c < columnCount; c++) { double xx = axis.getCategoryJava2DCoordinate( anchor, c, columnCount, dataArea, domainAxisEdge); CategoryItemRenderer renderer1 = getRenderer(); if (renderer1 != null) { renderer1.drawDomainGridline(g2, this, dataArea, xx); } } } } } } }
/** * Creates a new annotation to be displayed at the given location. * * @param text the text (<code>null</code> not permitted). * @param category the category (<code>null</code> not permitted). * @param value the value. */ public CategoryTextAnnotation(String text, Comparable category, double value) { super(text); if (category == null) { throw new IllegalArgumentException("Null 'category' argument."); } this.category = category; this.value = value; this.categoryAnchor = CategoryAnchor.MIDDLE; }
/** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { CategoryTextAnnotation a1 = new CategoryTextAnnotation("Test", "Category", 1.0); CategoryTextAnnotation a2 = new CategoryTextAnnotation("Test", "Category", 1.0); assertTrue(a1.equals(a2)); // category a1.setCategory("Category 2"); assertFalse(a1.equals(a2)); a2.setCategory("Category 2"); assertTrue(a1.equals(a2)); // categoryAnchor a1.setCategoryAnchor(CategoryAnchor.START); assertFalse(a1.equals(a2)); a2.setCategoryAnchor(CategoryAnchor.START); assertTrue(a1.equals(a2)); // value a1.setValue(0.15); assertFalse(a1.equals(a2)); a2.setValue(0.15); assertTrue(a1.equals(a2)); }
/** * Creates a new annotation to be displayed at the given location. * * @param text the text (<code>null</code> not permitted). * @param category the category (<code>null</code> not permitted). * @param value the value. */ public CategoryTextAnnotation(String text, Comparable category, double value) { super(text); ParamChecks.nullNotPermitted(category, "category"); this.category = category; this.value = value; this.categoryAnchor = CategoryAnchor.MIDDLE; }
/** * Creates a new annotation to be displayed at the given location. * * @param text the text ({@code null} not permitted). * @param category the category ({@code null} not permitted). * @param value the value. */ public CategoryTextAnnotation(String text, Comparable category, double value) { super(text); Args.nullNotPermitted(category, "category"); this.category = category; this.value = value; this.categoryAnchor = CategoryAnchor.MIDDLE; }