org.jfree.chart.annotations.CategoryTextAnnotation Java Examples
The following examples show how to use
org.jfree.chart.annotations.CategoryTextAnnotation.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BarChartPanel.java From nmonvisualizer with Apache License 2.0 | 6 votes |
@Override public void addAnnotations(List<Annotation> annotations) { if (getChart() != null) { CategoryPlot plot = getChart().getCategoryPlot(); plot.clearAnnotations(); for (Annotation a : annotations) { if (a instanceof CategoryTextAnnotation) { CategoryTextAnnotation annotation = (CategoryTextAnnotation) a; if (plot.getCategories().contains(annotation.getCategory())) { plot.addAnnotation(annotation); firePropertyChange("annotation", null, annotation); } } } } }
Example #2
Source File: CategoryTextAnnotationTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * 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)); }
Example #3
Source File: CategoryTextAnnotationTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { CategoryTextAnnotation a1 = new CategoryTextAnnotation("Test", "Category", 1.0); CategoryTextAnnotation a2 = new CategoryTextAnnotation("Test", "Category", 1.0); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); }
Example #4
Source File: TextAnnotationTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { TextAnnotation a1 = new CategoryTextAnnotation("Test", "Category", 1.0); TextAnnotation a2 = new CategoryTextAnnotation("Test", "Category", 1.0); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); }
Example #5
Source File: CategoryTextAnnotationTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * 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)); }
Example #6
Source File: CategoryTextAnnotationTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { CategoryTextAnnotation a1 = new CategoryTextAnnotation( "Test", "Category", 1.0 ); CategoryTextAnnotation a2 = new CategoryTextAnnotation( "Test", "Category", 1.0 ); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); }
Example #7
Source File: TextAnnotationTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { TextAnnotation a1 = new CategoryTextAnnotation("Test", "Category", 1.0); TextAnnotation a2 = new CategoryTextAnnotation("Test", "Category", 1.0); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); }
Example #8
Source File: BarChartPanel.java From nmonvisualizer with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(ActionEvent e) { if (categoryKey == null) { return; } String text = JOptionPane.showInputDialog(gui.getMainFrame(), "Annotation Text", "Annotate Bar Chart", JOptionPane.QUESTION_MESSAGE); if (text != null) { text = text.trim(); if ("".equals(text)) { return; } CategoryPlot categoryPlot = getChart().getCategoryPlot(); double y = categoryPlot.getRangeAxis().java2DToValue(clickLocation.getY(), getChartRenderingInfo().getPlotInfo().getDataArea(), categoryPlot.getRangeAxisEdge()); if (y < categoryPlot.getRangeAxis().getLowerBound()) { y = categoryPlot.getRangeAxis().getLowerBound(); } if (y > categoryPlot.getRangeAxis().getUpperBound()) { y = categoryPlot.getRangeAxis().getUpperBound(); } CategoryTextAnnotation annotation = new CategoryTextAnnotation(text, categoryKey, y); gui.getChartFormatter().formatAnnotation(annotation); getChart().getCategoryPlot().addAnnotation(annotation); firePropertyChange("annotation", null, annotation); } }
Example #9
Source File: AbstractCategoryItemRendererTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Checks that all fields are distinguished. */ public void testEquals() { BarRenderer r1 = new BarRenderer(); BarRenderer r2 = new BarRenderer(); assertEquals(r1, r2); // the plot field is NOT tested // toolTipGeneratorList r1.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); assertTrue(r1.equals(r2)); // baseToolTipGenerator r1.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator("{2}", NumberFormat.getInstance())); assertFalse(r1.equals(r2)); r2.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator("{2}", NumberFormat.getInstance())); assertTrue(r1.equals(r2)); // itemLabelGeneratorList r1.setSeriesItemLabelGenerator(1, new StandardCategoryItemLabelGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesItemLabelGenerator(1, new StandardCategoryItemLabelGenerator()); assertTrue(r1.equals(r2)); // baseItemLabelGenerator r1.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator( "{2}", NumberFormat.getInstance())); assertFalse(r1.equals(r2)); r2.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator( "{2}", NumberFormat.getInstance())); assertTrue(r1.equals(r2)); // urlGeneratorList r1.setSeriesURLGenerator(1, new StandardCategoryURLGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesURLGenerator(1, new StandardCategoryURLGenerator()); assertTrue(r1.equals(r2)); // baseItemURLGenerator r1.setBaseURLGenerator(new StandardCategoryURLGenerator( "abc.html")); assertFalse(r1.equals(r2)); r2.setBaseURLGenerator(new StandardCategoryURLGenerator( "abc.html")); assertTrue(r1.equals(r2)); // legendItemLabelGenerator r1.setLegendItemLabelGenerator(new StandardCategorySeriesLabelGenerator( "XYZ")); assertFalse(r1.equals(r2)); r2.setLegendItemLabelGenerator(new StandardCategorySeriesLabelGenerator( "XYZ")); assertTrue(r1.equals(r2)); // legendItemToolTipGenerator r1.setLegendItemToolTipGenerator( new StandardCategorySeriesLabelGenerator("ToolTip")); assertFalse(r1.equals(r2)); r2.setLegendItemToolTipGenerator( new StandardCategorySeriesLabelGenerator("ToolTip")); assertTrue(r1.equals(r2)); // legendItemURLGenerator r1.setLegendItemURLGenerator( new StandardCategorySeriesLabelGenerator("URL")); assertFalse(r1.equals(r2)); r2.setLegendItemURLGenerator( new StandardCategorySeriesLabelGenerator("URL")); assertTrue(r1.equals(r2)); // background annotation r1.addAnnotation(new CategoryTextAnnotation("ABC", "A", 2.0), Layer.BACKGROUND); assertFalse(r1.equals(r2)); r2.addAnnotation(new CategoryTextAnnotation("ABC", "A", 2.0), Layer.BACKGROUND); assertTrue(r1.equals(r2)); // foreground annotation r1.addAnnotation(new CategoryTextAnnotation("DEF", "B", 4.0), Layer.FOREGROUND); assertFalse(r1.equals(r2)); r2.addAnnotation(new CategoryTextAnnotation("DEF", "B", 4.0), Layer.FOREGROUND); assertTrue(r1.equals(r2)); }
Example #10
Source File: CategoryTextAnnotationTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Checks that this class implements PublicCloneable. */ public void testPublicCloneable() { CategoryTextAnnotation a1 = new CategoryTextAnnotation( "Test", "Category", 1.0); assertTrue(a1 instanceof PublicCloneable); }
Example #11
Source File: TextAnnotationTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { TextAnnotation a1 = new CategoryTextAnnotation("Test", "Category", 1.0); TextAnnotation a2 = new CategoryTextAnnotation("Test", "Category", 1.0); assertTrue(a1.equals(a2)); // text a1.setText("Text"); assertFalse(a1.equals(a2)); a2.setText("Text"); assertTrue(a1.equals(a2)); // font a1.setFont(new Font("Serif", Font.BOLD, 18)); assertFalse(a1.equals(a2)); a2.setFont(new Font("Serif", Font.BOLD, 18)); assertTrue(a1.equals(a2)); // paint a1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.pink)); assertFalse(a1.equals(a2)); a2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.pink)); assertTrue(a1.equals(a2)); // textAnchor a1.setTextAnchor(TextAnchor.BOTTOM_LEFT); assertFalse(a1.equals(a2)); a2.setTextAnchor(TextAnchor.BOTTOM_LEFT); assertTrue(a1.equals(a2)); // rotationAnchor a1.setRotationAnchor(TextAnchor.BOTTOM_LEFT); assertFalse(a1.equals(a2)); a2.setRotationAnchor(TextAnchor.BOTTOM_LEFT); assertTrue(a1.equals(a2)); // rotationAngle a1.setRotationAngle(Math.PI); assertFalse(a1.equals(a2)); a2.setRotationAngle(Math.PI); assertTrue(a1.equals(a2)); }
Example #12
Source File: AbstractCategoryItemRendererTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Checks that all fields are distinguished. */ public void testEquals() { BarRenderer r1 = new BarRenderer(); BarRenderer r2 = new BarRenderer(); assertEquals(r1, r2); // the plot field is NOT tested // toolTipGeneratorList r1.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); assertTrue(r1.equals(r2)); // baseToolTipGenerator r1.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator("{2}", NumberFormat.getInstance())); assertFalse(r1.equals(r2)); r2.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator("{2}", NumberFormat.getInstance())); assertTrue(r1.equals(r2)); // itemLabelGeneratorList r1.setSeriesItemLabelGenerator(1, new StandardCategoryItemLabelGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesItemLabelGenerator(1, new StandardCategoryItemLabelGenerator()); assertTrue(r1.equals(r2)); // baseItemLabelGenerator r1.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator( "{2}", NumberFormat.getInstance())); assertFalse(r1.equals(r2)); r2.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator( "{2}", NumberFormat.getInstance())); assertTrue(r1.equals(r2)); // urlGeneratorList r1.setSeriesURLGenerator(1, new StandardCategoryURLGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesURLGenerator(1, new StandardCategoryURLGenerator()); assertTrue(r1.equals(r2)); // baseItemURLGenerator r1.setBaseURLGenerator(new StandardCategoryURLGenerator( "abc.html")); assertFalse(r1.equals(r2)); r2.setBaseURLGenerator(new StandardCategoryURLGenerator( "abc.html")); assertTrue(r1.equals(r2)); // legendItemLabelGenerator r1.setLegendItemLabelGenerator(new StandardCategorySeriesLabelGenerator( "XYZ")); assertFalse(r1.equals(r2)); r2.setLegendItemLabelGenerator(new StandardCategorySeriesLabelGenerator( "XYZ")); assertTrue(r1.equals(r2)); // legendItemToolTipGenerator r1.setLegendItemToolTipGenerator( new StandardCategorySeriesLabelGenerator("ToolTip")); assertFalse(r1.equals(r2)); r2.setLegendItemToolTipGenerator( new StandardCategorySeriesLabelGenerator("ToolTip")); assertTrue(r1.equals(r2)); // legendItemURLGenerator r1.setLegendItemURLGenerator( new StandardCategorySeriesLabelGenerator("URL")); assertFalse(r1.equals(r2)); r2.setLegendItemURLGenerator( new StandardCategorySeriesLabelGenerator("URL")); assertTrue(r1.equals(r2)); // background annotation r1.addAnnotation(new CategoryTextAnnotation("ABC", "A", 2.0), Layer.BACKGROUND); assertFalse(r1.equals(r2)); r2.addAnnotation(new CategoryTextAnnotation("ABC", "A", 2.0), Layer.BACKGROUND); assertTrue(r1.equals(r2)); // foreground annotation r1.addAnnotation(new CategoryTextAnnotation("DEF", "B", 4.0), Layer.FOREGROUND); assertFalse(r1.equals(r2)); r2.addAnnotation(new CategoryTextAnnotation("DEF", "B", 4.0), Layer.FOREGROUND); assertTrue(r1.equals(r2)); }
Example #13
Source File: TextAnnotationTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { TextAnnotation a1 = new CategoryTextAnnotation("Test", "Category", 1.0); TextAnnotation a2 = new CategoryTextAnnotation("Test", "Category", 1.0); assertTrue(a1.equals(a2)); // text a1.setText("Text"); assertFalse(a1.equals(a2)); a2.setText("Text"); assertTrue(a1.equals(a2)); // font a1.setFont(new Font("Serif", Font.BOLD, 18)); assertFalse(a1.equals(a2)); a2.setFont(new Font("Serif", Font.BOLD, 18)); assertTrue(a1.equals(a2)); // paint a1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.pink)); assertFalse(a1.equals(a2)); a2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.pink)); assertTrue(a1.equals(a2)); // textAnchor a1.setTextAnchor(TextAnchor.BOTTOM_LEFT); assertFalse(a1.equals(a2)); a2.setTextAnchor(TextAnchor.BOTTOM_LEFT); assertTrue(a1.equals(a2)); // rotationAnchor a1.setRotationAnchor(TextAnchor.BOTTOM_LEFT); assertFalse(a1.equals(a2)); a2.setRotationAnchor(TextAnchor.BOTTOM_LEFT); assertTrue(a1.equals(a2)); // rotationAngle a1.setRotationAngle(Math.PI); assertFalse(a1.equals(a2)); a2.setRotationAngle(Math.PI); assertTrue(a1.equals(a2)); }