org.jfree.chart.annotations.XYAnnotation Java Examples

The following examples show how to use org.jfree.chart.annotations.XYAnnotation. 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: LineChartPanel.java    From nmonvisualizer with Apache License 2.0 6 votes vote down vote up
@Override
public void addAnnotations(List<Annotation> annotations) {
    if (getChart() != null) {
        XYPlot plot = getChart().getXYPlot();

        plot.clearAnnotations();

        for (Annotation a : annotations) {
            if (a instanceof XYAnnotation) {
                XYAnnotation annotation = (XYAnnotation) a;
                plot.addAnnotation(annotation);

                firePropertyChange("annotation", null, annotation);
            }
        }
    }
}
 
Example #2
Source File: AbstractXYItemRenderer.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Adds an annotation to the specified layer and sends a
 * {@link RendererChangeEvent} to all registered listeners.
 *
 * @param annotation  the annotation (<code>null</code> not permitted).
 * @param layer  the layer (<code>null</code> not permitted).
 */
@Override
public void addAnnotation(XYAnnotation annotation, Layer layer) {
    ParamChecks.nullNotPermitted(annotation, "annotation");
    if (layer.equals(Layer.FOREGROUND)) {
        this.foregroundAnnotations.add(annotation);
        annotation.addChangeListener(this);
        fireChangeEvent();
    }
    else if (layer.equals(Layer.BACKGROUND)) {
        this.backgroundAnnotations.add(annotation);
        annotation.addChangeListener(this);
        fireChangeEvent();
    }
    else {
        // should never get here
        throw new RuntimeException("Unknown layer.");
    }
}
 
Example #3
Source File: AbstractXYItemRenderer.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds an annotation to the specified layer and sends a
 * {@link RendererChangeEvent} to all registered listeners.
 *
 * @param annotation  the annotation (<code>null</code> not permitted).
 * @param layer  the layer (<code>null</code> not permitted).
 */
public void addAnnotation(XYAnnotation annotation, Layer layer) {
    if (annotation == null) {
        throw new IllegalArgumentException("Null 'annotation' argument.");
    }
    if (layer.equals(Layer.FOREGROUND)) {
        this.foregroundAnnotations.add(annotation);
        annotation.addChangeListener(this);
        fireChangeEvent();
    }
    else if (layer.equals(Layer.BACKGROUND)) {
        this.backgroundAnnotations.add(annotation);
        annotation.addChangeListener(this);
        fireChangeEvent();
    }
    else {
        // should never get here
        throw new RuntimeException("Unknown layer.");
    }
}
 
Example #4
Source File: TimeSeriesGraphModel.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
void updateAnnotation(RasterDataNode raster) {
    removeAnnotation();

    final AbstractTimeSeries timeSeries = getTimeSeries();
    TimeCoding timeCoding = timeSeries.getRasterTimeMap().get(raster);
    if (timeCoding != null) {
        final ProductData.UTC startTime = timeCoding.getStartTime();
        final Millisecond timePeriod = new Millisecond(startTime.getAsDate(),
                ProductData.UTC.UTC_TIME_ZONE,
                Locale.getDefault());

        double millisecond = timePeriod.getFirstMillisecond();
        Range valueRange = null;
        for (int i = 0; i < timeSeriesPlot.getRangeAxisCount(); i++) {
            valueRange = Range.combine(valueRange, timeSeriesPlot.getRangeAxis(i).getRange());
        }
        if (valueRange != null) {
            XYAnnotation annotation = new XYLineAnnotation(millisecond, valueRange.getLowerBound(), millisecond,
                    valueRange.getUpperBound());
            timeSeriesPlot.addAnnotation(annotation, true);
        }
    }
}
 
Example #5
Source File: AbstractXYItemRenderer.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws all the annotations for the specified layer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param layer  the layer.
 * @param info  the plot rendering info.
 */
@Override
public void drawAnnotations(Graphics2D g2, Rectangle2D dataArea,
        ValueAxis domainAxis, ValueAxis rangeAxis, Layer layer,
        PlotRenderingInfo info) {

    Iterator iterator = null;
    if (layer.equals(Layer.FOREGROUND)) {
        iterator = this.foregroundAnnotations.iterator();
    }
    else if (layer.equals(Layer.BACKGROUND)) {
        iterator = this.backgroundAnnotations.iterator();
    }
    else {
        // should not get here
        throw new RuntimeException("Unknown layer.");
    }
    while (iterator.hasNext()) {
        XYAnnotation annotation = (XYAnnotation) iterator.next();
        int index = this.plot.getIndexOf(this);
        annotation.draw(g2, this.plot, dataArea, domainAxis, rangeAxis,
                index, info);
    }

}
 
Example #6
Source File: AbstractXYItemRenderer.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws all the annotations for the specified layer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param layer  the layer.
 * @param info  the plot rendering info.
 */
@Override
public void drawAnnotations(Graphics2D g2, Rectangle2D dataArea,
        ValueAxis domainAxis, ValueAxis rangeAxis, Layer layer,
        PlotRenderingInfo info) {

    Iterator iterator = null;
    if (layer.equals(Layer.FOREGROUND)) {
        iterator = this.foregroundAnnotations.iterator();
    }
    else if (layer.equals(Layer.BACKGROUND)) {
        iterator = this.backgroundAnnotations.iterator();
    }
    else {
        // should not get here
        throw new RuntimeException("Unknown layer.");
    }
    while (iterator.hasNext()) {
        XYAnnotation annotation = (XYAnnotation) iterator.next();
        int index = this.plot.getIndexOf(this);
        annotation.draw(g2, this.plot, dataArea, domainAxis, rangeAxis,
                index, info);
    }

}
 
Example #7
Source File: AbstractXYItemRenderer.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws all the annotations for the specified layer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param layer  the layer.
 * @param info  the plot rendering info.
 */
@Override
public void drawAnnotations(Graphics2D g2, Rectangle2D dataArea,
        ValueAxis domainAxis, ValueAxis rangeAxis, Layer layer,
        PlotRenderingInfo info) {

    Iterator iterator = null;
    if (layer.equals(Layer.FOREGROUND)) {
        iterator = this.foregroundAnnotations.iterator();
    }
    else if (layer.equals(Layer.BACKGROUND)) {
        iterator = this.backgroundAnnotations.iterator();
    }
    else {
        // should not get here
        throw new RuntimeException("Unknown layer.");
    }
    while (iterator.hasNext()) {
        XYAnnotation annotation = (XYAnnotation) iterator.next();
        int index = this.plot.getIndexOf(this);
        annotation.draw(g2, this.plot, dataArea, domainAxis, rangeAxis,
                index, info);
    }

}
 
Example #8
Source File: AbstractXYItemRenderer.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds an annotation to the specified layer and sends a
 * {@link RendererChangeEvent} to all registered listeners.
 *
 * @param annotation  the annotation (<code>null</code> not permitted).
 * @param layer  the layer (<code>null</code> not permitted).
 */
@Override
public void addAnnotation(XYAnnotation annotation, Layer layer) {
    ParamChecks.nullNotPermitted(annotation, "annotation");
    if (layer.equals(Layer.FOREGROUND)) {
        this.foregroundAnnotations.add(annotation);
        annotation.addChangeListener(this);
        fireChangeEvent();
    }
    else if (layer.equals(Layer.BACKGROUND)) {
        this.backgroundAnnotations.add(annotation);
        annotation.addChangeListener(this);
        fireChangeEvent();
    }
    else {
        // should never get here
        throw new RuntimeException("Unknown layer.");
    }
}
 
Example #9
Source File: AbstractXYItemRenderer.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Adds an annotation to the specified layer and sends a
 * {@link RendererChangeEvent} to all registered listeners.
 *
 * @param annotation  the annotation (<code>null</code> not permitted).
 * @param layer  the layer (<code>null</code> not permitted).
 */
@Override
public void addAnnotation(XYAnnotation annotation, Layer layer) {
    ParamChecks.nullNotPermitted(annotation, "annotation");
    if (layer.equals(Layer.FOREGROUND)) {
        this.foregroundAnnotations.add(annotation);
        annotation.addChangeListener(this);
        fireChangeEvent();
    }
    else if (layer.equals(Layer.BACKGROUND)) {
        this.backgroundAnnotations.add(annotation);
        annotation.addChangeListener(this);
        fireChangeEvent();
    }
    else {
        // should never get here
        throw new RuntimeException("Unknown layer.");
    }
}
 
Example #10
Source File: AbstractXYItemRenderer.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws all the annotations for the specified layer.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param layer  the layer.
 * @param info  the plot rendering info.
 */
@Override
public void drawAnnotations(Graphics2D g2, Rectangle2D dataArea,
        ValueAxis domainAxis, ValueAxis rangeAxis, Layer layer,
        PlotRenderingInfo info) {

    Iterator iterator = null;
    if (layer.equals(Layer.FOREGROUND)) {
        iterator = this.foregroundAnnotations.iterator();
    }
    else if (layer.equals(Layer.BACKGROUND)) {
        iterator = this.backgroundAnnotations.iterator();
    }
    else {
        // should not get here
        throw new RuntimeException("Unknown layer.");
    }
    while (iterator.hasNext()) {
        XYAnnotation annotation = (XYAnnotation) iterator.next();
        int index = this.plot.getIndexOf(this);
        annotation.draw(g2, this.plot, dataArea, domainAxis, rangeAxis,
                index, info);
    }

}
 
Example #11
Source File: XYPlot.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Clears all the annotations and sends a {@link PlotChangeEvent} to all
 * registered listeners.
 *
 * @see #addAnnotation(XYAnnotation)
 */
public void clearAnnotations() {
    for (XYAnnotation annotation : this.annotations) {
        annotation.removeChangeListener(this);
    }
    this.annotations.clear();
    fireChangeEvent();
}
 
Example #12
Source File: ContourPlot.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Adds an annotation to the plot.
 *
 * @param annotation  the annotation.
 */
public void addAnnotation(XYAnnotation annotation) {

    if (this.annotations == null) {
        this.annotations = new java.util.ArrayList();
    }
    this.annotations.add(annotation);
    notifyListeners(new PlotChangeEvent(this));

}
 
Example #13
Source File: XYPlot.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws the annotations for the plot.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param info  the chart rendering info.
 */
public void drawAnnotations(Graphics2D g2, Rectangle2D dataArea,
                            PlotRenderingInfo info) {

    Iterator iterator = this.annotations.iterator();
    while (iterator.hasNext()) {
        XYAnnotation annotation = (XYAnnotation) iterator.next();
        ValueAxis xAxis = getDomainAxis();
        ValueAxis yAxis = getRangeAxis();
        annotation.draw(g2, this, dataArea, xAxis, yAxis, 0, info);
    }

}
 
Example #14
Source File: ContourPlot.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds an annotation to the plot.
 *
 * @param annotation  the annotation.
 */
public void addAnnotation(XYAnnotation annotation) {

    if (this.annotations == null) {
        this.annotations = new java.util.ArrayList();
    }
    this.annotations.add(annotation);
    fireChangeEvent();

}
 
Example #15
Source File: StandardChartTheme.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Applies the settings of this theme to the specified annotation.
 *
 * @param annotation  the annotation.
 */
protected void applyToXYAnnotation(XYAnnotation annotation) {
    ParamChecks.nullNotPermitted(annotation, "annotation");
    if (annotation instanceof XYTextAnnotation) {
        XYTextAnnotation xyta = (XYTextAnnotation) annotation;
        xyta.setFont(this.smallFont);
        xyta.setPaint(this.itemLabelPaint);
    }
}
 
Example #16
Source File: XYPlot.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Clears all the annotations and sends a {@link PlotChangeEvent} to all
 * registered listeners.
 *
 * @see #addAnnotation(XYAnnotation)
 */
public void clearAnnotations() {
    for (XYAnnotation annotation : this.annotations) {
        annotation.removeChangeListener(this);
    }
    this.annotations.clear();
    fireChangeEvent();
}
 
Example #17
Source File: StandardChartTheme.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Applies the settings of this theme to the specified annotation.
 *
 * @param annotation  the annotation.
 */
protected void applyToXYAnnotation(XYAnnotation annotation) {
    ParamChecks.nullNotPermitted(annotation, "annotation");
    if (annotation instanceof XYTextAnnotation) {
        XYTextAnnotation xyta = (XYTextAnnotation) annotation;
        xyta.setFont(this.smallFont);
        xyta.setPaint(this.itemLabelPaint);
    }
}
 
Example #18
Source File: 1_XYPlot.java    From SimFix with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds an annotation to the plot and, if requested, sends a 
 * {@link PlotChangeEvent} to all registered listeners.
 *
 * @param annotation  the annotation (<code>null</code> not permitted).
 * @param notify  notify listeners?
 * 
 * @since 1.0.10
 */
public void addAnnotation(XYAnnotation annotation, boolean notify) {
    if (annotation == null) {
        throw new IllegalArgumentException("Null 'annotation' argument.");
    }
    this.annotations.add(annotation);
    if (notify) {
        fireChangeEvent();
    }
}
 
Example #19
Source File: XYPlot.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Draws the annotations for the plot.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param info  the chart rendering info.
 */
public void drawAnnotations(Graphics2D g2, Rectangle2D dataArea,
                            PlotRenderingInfo info) {

    Iterator iterator = this.annotations.iterator();
    while (iterator.hasNext()) {
        XYAnnotation annotation = (XYAnnotation) iterator.next();
        ValueAxis xAxis = getDomainAxis();
        ValueAxis yAxis = getRangeAxis();
        annotation.draw(g2, this, dataArea, xAxis, yAxis, 0, info);
    }

}
 
Example #20
Source File: XYPlot.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Clears all the annotations and sends a {@link PlotChangeEvent} to all
 * registered listeners.
 *
 * @see #addAnnotation(XYAnnotation)
 */
public void clearAnnotations() {
    for (XYAnnotation annotation : this.annotations) {
        annotation.removeChangeListener(this);
    }
    this.annotations.clear();
    fireChangeEvent();
}
 
Example #21
Source File: XYPlot.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds an annotation to the plot and, if requested, sends a 
 * {@link PlotChangeEvent} to all registered listeners.
 *
 * @param annotation  the annotation (<code>null</code> not permitted).
 * @param notify  notify listeners?
 * 
 * @since 1.0.10
 */
public void addAnnotation(XYAnnotation annotation, boolean notify) {
    if (annotation == null) {
        throw new IllegalArgumentException("Null 'annotation' argument.");
    }
    this.annotations.add(annotation);
    if (notify) {
        fireChangeEvent();
    }
}
 
Example #22
Source File: Cardumen_009_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Draws the annotations for the plot.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param info  the chart rendering info.
 */
public void drawAnnotations(Graphics2D g2,
                            Rectangle2D dataArea,
                            PlotRenderingInfo info) {

    Iterator iterator = this.annotations.iterator();
    while (iterator.hasNext()) {
        XYAnnotation annotation = (XYAnnotation) iterator.next();
        ValueAxis xAxis = getDomainAxis();
        ValueAxis yAxis = getRangeAxis();
        annotation.draw(g2, this, dataArea, xAxis, yAxis, 0, info);
    }

}
 
Example #23
Source File: StandardChartTheme.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Applies the settings of this theme to the specified annotation.
 *
 * @param annotation  the annotation.
 */
protected void applyToXYAnnotation(XYAnnotation annotation) {
    ParamChecks.nullNotPermitted(annotation, "annotation");
    if (annotation instanceof XYTextAnnotation) {
        XYTextAnnotation xyta = (XYTextAnnotation) annotation;
        xyta.setFont(this.smallFont);
        xyta.setPaint(this.itemLabelPaint);
    }
}
 
Example #24
Source File: Chart_14_XYPlot_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Adds an annotation to the plot and, if requested, sends a 
 * {@link PlotChangeEvent} to all registered listeners.
 *
 * @param annotation  the annotation (<code>null</code> not permitted).
 * @param notify  notify listeners?
 * 
 * @since 1.0.10
 */
public void addAnnotation(XYAnnotation annotation, boolean notify) {
    if (annotation == null) {
        throw new IllegalArgumentException("Null 'annotation' argument.");
    }
    this.annotations.add(annotation);
    if (notify) {
        fireChangeEvent();
    }
}
 
Example #25
Source File: XYPlot.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws the annotations for the plot.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param info  the chart rendering info.
 */
public void drawAnnotations(Graphics2D g2, Rectangle2D dataArea,
                            PlotRenderingInfo info) {

    Iterator iterator = this.annotations.iterator();
    while (iterator.hasNext()) {
        XYAnnotation annotation = (XYAnnotation) iterator.next();
        ValueAxis xAxis = getDomainAxis();
        ValueAxis yAxis = getRangeAxis();
        annotation.draw(g2, this, dataArea, xAxis, yAxis, 0, info);
    }

}
 
Example #26
Source File: ContourPlot.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds an annotation to the plot.
 *
 * @param annotation  the annotation.
 */
public void addAnnotation(XYAnnotation annotation) {

    if (this.annotations == null) {
        this.annotations = new java.util.ArrayList();
    }
    this.annotations.add(annotation);
    fireChangeEvent();

}
 
Example #27
Source File: StandardChartTheme.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Applies the settings of this theme to the specified annotation.
 *
 * @param annotation  the annotation.
 */
protected void applyToXYAnnotation(XYAnnotation annotation) {
    ParamChecks.nullNotPermitted(annotation, "annotation");
    if (annotation instanceof XYTextAnnotation) {
        XYTextAnnotation xyta = (XYTextAnnotation) annotation;
        xyta.setFont(this.smallFont);
        xyta.setPaint(this.itemLabelPaint);
    }
}
 
Example #28
Source File: XYPlot.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws the annotations for the plot.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param info  the chart rendering info.
 */
public void drawAnnotations(Graphics2D g2, Rectangle2D dataArea,
                            PlotRenderingInfo info) {

    Iterator iterator = this.annotations.iterator();
    while (iterator.hasNext()) {
        XYAnnotation annotation = (XYAnnotation) iterator.next();
        ValueAxis xAxis = getDomainAxis();
        ValueAxis yAxis = getRangeAxis();
        annotation.draw(g2, this, dataArea, xAxis, yAxis, 0, info);
    }

}
 
Example #29
Source File: StandardChartTheme.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Applies the settings of this theme to the specified annotation.
 *
 * @param annotation  the annotation.
 */
protected void applyToXYAnnotation(XYAnnotation annotation) {
    ParamChecks.nullNotPermitted(annotation, "annotation");
    if (annotation instanceof XYTextAnnotation) {
        XYTextAnnotation xyta = (XYTextAnnotation) annotation;
        xyta.setFont(this.smallFont);
        xyta.setPaint(this.itemLabelPaint);
    }
}
 
Example #30
Source File: XYPlot.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Draws the annotations for the plot.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param info  the chart rendering info.
 */
public void drawAnnotations(Graphics2D g2,
                            Rectangle2D dataArea,
                            PlotRenderingInfo info) {

    Iterator iterator = this.annotations.iterator();
    while (iterator.hasNext()) {
        XYAnnotation annotation = (XYAnnotation) iterator.next();
        ValueAxis xAxis = getDomainAxis();
        ValueAxis yAxis = getRangeAxis();
        annotation.draw(g2, this, dataArea, xAxis, yAxis, 0, info);
    }

}