Example usage for org.jfree.chart.plot XYPlot getAnnotations

List of usage examples for org.jfree.chart.plot XYPlot getAnnotations

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot getAnnotations.

Prototype

public List getAnnotations() 

Source Link

Document

Returns the list of annotations.

Usage

From source file:Transistor.JFETGraphViewer.java

public JFreeChart getResultChart() {
    this.makeNewSeries();

    this.chart = ChartFactory.createXYLineChart("Output characteristic V-I curves", "V_ds", "I_d", data,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.getRangeAxis().setRange(0, 2100);
    pointer = new XYPointerAnnotation("V_ds", info.getVds(), getDrainCurrent(info.getVds()), PI / 4.0);
    plot.getAnnotations().clear();
    plot.addAnnotation(pointer);//w  w  w  . j  a v a  2 s .c  o  m

    return this.chart;
}

From source file:com.diversityarrays.kdxplore.scatterplot.ScatterPlotPanel.java

@SuppressWarnings("unchecked")
public void redrawSelectedPlots() {

    if (syncedOption.getSyncWhat().isSync() && !getSelectionChanging()) {
        XYPlot xyplot = getChart().getXYPlot();

        //         curationControls.setSyncedState(true);

        Double yscale = (xyplot.getRangeAxis().getUpperBound() - xyplot.getRangeAxis().getLowerBound()) / 50;
        Double xscale = (xyplot.getDomainAxis().getUpperBound() - xyplot.getDomainAxis().getLowerBound()) / 50;

        Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3 },
                0);/*www. j a  va2 s  .c  om*/
        Paint paint = Color.RED;

        for (Annotation anno : (List<Annotation>) xyplot.getAnnotations()) {
            if (anno != intervalAnnotation && anno instanceof XYShapeAnnotation) {
                xyplot.removeAnnotation((XYShapeAnnotation) anno);
            }
        }

        for (Point2D point : selectedPoints) {
            double x = point.getX();
            double y = point.getY();

            double y1 = y - yscale;
            double y2 = y + yscale;
            double x1 = x - xscale;
            double x2 = x + xscale;

            Ellipse2D oval = new Ellipse2D.Double(x1, y1, x2 - x1, y2 - y1);

            XYShapeAnnotation lineanno0 = new XYShapeAnnotation(oval, stroke, paint);
            addRangeMarker(lineanno0);
        }
    }
    curationControls.updateButtons();
}