List of usage examples for org.jfree.chart.annotations CategoryPointerAnnotation CategoryPointerAnnotation
public CategoryPointerAnnotation(String label, Comparable key, double value, double angle)
From source file:org.jfree.chart.demo.CategoryPointerAnnotationDemo1.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createLineChart("Java Standard Class Library", "Release", "Class Count", categorydataset, PlotOrientation.VERTICAL, false, true, false); jfreechart.addSubtitle(new TextTitle("Number of Classes By Release")); TextTitle texttitle = new TextTitle( "Source: Java In A Nutshell (4th Edition) by David Flanagan (O'Reilly)"); texttitle.setFont(new Font("SansSerif", 0, 10)); texttitle.setPosition(RectangleEdge.BOTTOM); texttitle.setHorizontalAlignment(HorizontalAlignment.RIGHT); jfreechart.addSubtitle(texttitle);//w w w. j a v a 2 s.c o m jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer(); lineandshaperenderer.setBaseShapesVisible(true); lineandshaperenderer.setDrawOutlines(true); lineandshaperenderer.setUseFillPaint(true); lineandshaperenderer.setBaseFillPaint(Color.white); CategoryPointerAnnotation categorypointerannotation = new CategoryPointerAnnotation("Released 4-Dec-1998", "JDK 1.2", 1530D, -2.3561944901923448D); categorypointerannotation.setTextAnchor(TextAnchor.BOTTOM_RIGHT); categoryplot.addAnnotation(categorypointerannotation); return jfreechart; }
From source file:org.operamasks.faces.render.graph.ChartRenderer.java
private CategoryTextAnnotation createCategoryTextAnnotation(UITextAnnotation at, Comparable key) { CategoryTextAnnotation result;/*ww w . ja v a2 s . co m*/ String label = at.getText(); double value = Coercion.coerceToDouble(at.getyValue()); if (at.isDrawArrow()) { Double angle = at.getArrowAngle(); if (angle == null) angle = 0.0; CategoryPointerAnnotation pointer = new CategoryPointerAnnotation(label, key, value, angle * Math.PI / 180.0); Double length = at.getArrowLength(); if (length != null) { pointer.setBaseRadius(length); } Paint arrowColor = at.getArrowColor(); if (arrowColor == null) arrowColor = at.getColor(); if (arrowColor != null) pointer.setArrowPaint(arrowColor); result = pointer; } else { result = new CategoryTextAnnotation(label, key, value); } Font font = at.getFont(); if (font != null) { result.setFont(font); } Paint color = at.getColor(); if (color != null) { result.setPaint(color); } TextAnchor anchor = getTextAnchor(at.getAnchor()); if (anchor != null) { result.setTextAnchor(anchor); } Double rotationAngle = at.getRotationAngle(); if (rotationAngle != null) { result.setRotationAngle(rotationAngle * Math.PI / 180.0); } return result; }