Example usage for org.jfree.chart.annotations XYTextAnnotation setOutlineVisible

List of usage examples for org.jfree.chart.annotations XYTextAnnotation setOutlineVisible

Introduction

In this page you can find the example usage for org.jfree.chart.annotations XYTextAnnotation setOutlineVisible.

Prototype

public void setOutlineVisible(boolean visible) 

Source Link

Document

Sets the flag that controls whether or not the outline is drawn and sends an AnnotationChangeEvent to all registered listeners.

Usage

From source file:edu.umn.ecology.populus.plot.BasicPlotInfo.java

public ChartTheme getJFreeChartTheme() {
    class PopChartTheme implements ChartTheme {
        private BasicPlotInfo bpiRef;

        public PopChartTheme(BasicPlotInfo bpi) {
            this.bpiRef = bpi;
        }/*from   w  w w  .  j av a  2  s .  c o  m*/

        public void apply(JFreeChart chart) {
            JFCXYAdapter jfca = new JFCXYAdapter();
            XYPlot plot = chart.getXYPlot();
            plot.setDataset(jfca);

            if (isLogPlot) {
                plot.setRangeAxis(new LogarithmicAxis(""));
            }
            if (isFrequencies) {
                ValueAxis va = plot.getRangeAxis();
                if (va instanceof NumberAxis) {
                    NumberAxis na = (NumberAxis) va;
                    na.setTickUnit(new NumberTickUnit(0.1));
                } else {
                    Logging.log("Range Axis is not NumberAxis, why?", Logging.kWarn);
                }
            }

            if (xMinSet)
                plot.getDomainAxis().setLowerBound(xAxisMin);
            if (xMaxSet)
                plot.getDomainAxis().setUpperBound(xAxisMax);
            if (yMinSet)
                plot.getRangeAxis().setLowerBound(yAxisMin);
            if (yMaxSet)
                plot.getRangeAxis().setUpperBound(yAxisMax);

            //TODO - just use this renderer
            plot.setRenderer(new ChartRendererWithOrientatedShapes(bpiRef));

            XYItemRenderer r = plot.getRenderer();
            //         AbstractXYItemRenderer r = plot.getRenderer();
            if (r instanceof XYLineAndShapeRenderer) {
                XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
                for (int i = 0; i < getNumSeries(); i++) {
                    //Set Line
                    renderer.setSeriesPaint(i, getLineColor(i));
                    renderer.setSeriesStroke(i, getLineStroke(i));

                    //Set Symbol
                    renderer.setSeriesFillPaint(i, getSymbolColor(i));
                    renderer.setSeriesOutlinePaint(i, getSymbolColor(i));

                    Shape shape = getSymbolShape(i);
                    if (shape != null) {
                        renderer.setSeriesShape(i, shape);
                        renderer.setSeriesShapesFilled(i, isSymbolOpaque(i));
                        renderer.setUseFillPaint(true);
                        renderer.setUseOutlinePaint(true);
                        renderer.setSeriesShapesVisible(i, true);
                    }
                }
            } else if (r instanceof XYBarRenderer) {
                XYBarRenderer barRenderer = (XYBarRenderer) r;
                barRenderer.setBarPainter(new StandardXYBarPainter());
            } else {
                Logging.log("Unknown renderer type: " + r.getClass(), Logging.kWarn);
            }

            //inner labels, used in AIDS: Therapy
            plot.clearAnnotations();
            Enumeration<InnerLabel> e = innerLabels.elements();
            while (e.hasMoreElements()) {
                InnerLabel lab = (InnerLabel) e.nextElement();
                Logging.log("Adding " + lab.caption + " at " + lab.x + ", " + lab.y);

                XYTextAnnotation annotation = new XYTextAnnotation(lab.caption, lab.x, lab.y);
                annotation.setTextAnchor(TextAnchor.BOTTOM_CENTER);
                annotation.setOutlineVisible(true);
                plot.addAnnotation(annotation);

                //I actually think the annotation above is ugly.  We can use one of these instead in the future, maybe...
                /*PointerAnnotation may look cool...
                 * That 2.0 is the angle, randomly picked
                 * XYPointerAnnotation annotation = new XYPointerAnnotation(lab.caption, lab.x, lab.y, 2.0); 
                 */

                /*
                ValueMarker marker = new ValueMarker(lab.x);
                marker.setLabel(lab.caption);
                marker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT);
                plot.addDomainMarker(marker);
                 */

            }

            //This is set for GD: AMCM
            if (startGridded) {
                plot.setDomainGridlinesVisible(true);
                plot.setDomainGridlinePaint(Color.BLACK);
                plot.setRangeGridlinesVisible(true);
                plot.setRangeGridlinePaint(Color.BLACK);
            }

        }
    }
    return new PopChartTheme(this);
}