Example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer addAnnotation

List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer addAnnotation

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer addAnnotation.

Prototype

@Override
public void addAnnotation(XYAnnotation annotation, Layer layer) 

Source Link

Document

Adds an annotation to the specified layer and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:org.jfree.chart.demo.XYPolygonAnnotationDemo1.java

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createScatterPlot("XYPolygonAnnotationDemo1", "X", "Y", xydataset,
            PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    XYPolygonAnnotation xypolygonannotation = new XYPolygonAnnotation(
            new double[] { 2D, 5D, 2.5D, 8D, 3D, 5D, 2.5D, 2D }, null, null, new Color(200, 200, 255, 100));
    xypolygonannotation.setToolTipText("Target Zone");
    xylineandshaperenderer.addAnnotation(xypolygonannotation, Layer.BACKGROUND);
    return jfreechart;
}

From source file:org.jfree.chart.demo.XYPointerAnnotationDemo1.java

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createScatterPlot("XYPointerAnnotationDemo1", "X", "Y", xydataset,
            PlotOrientation.HORIZONTAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    XYPointerAnnotation xypointerannotation = new XYPointerAnnotation("Special point", 2.2000000000000002D, 6D,
            3.9269908169872414D);//from w  ww . j a v a2  s .c  om
    xypointerannotation.setTextAnchor(TextAnchor.BOTTOM_RIGHT);
    xypointerannotation.setToolTipText("The pointer has a tool tip!");
    xylineandshaperenderer.addAnnotation(xypointerannotation, Layer.BACKGROUND);
    return jfreechart;
}