org.jfree.chart.annotations.Annotation Java Examples

The following examples show how to use org.jfree.chart.annotations.Annotation. 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: ChartFormatter.java    From nmonvisualizer with Apache License 2.0 6 votes vote down vote up
public void reformatAnnotations() {
    for (Annotation a : AnnotationCache.getAnnotations()) {
        if (a instanceof TextAnnotation) {
            formatAnnotation((TextAnnotation) a);
        }
        else if (a instanceof XYTextAnnotation) {
            formatAnnotation((XYTextAnnotation) a);
        }
    }

    for (Marker m : AnnotationCache.getMarkers()) {
        boolean horizontal = m.getLabelTextAnchor() == TextAnchor.TOP_CENTER;

        // match offsets adjustments in formatMarker()
        if (horizontal) {
            formatMarker(m, true, (int) m.getLabelOffset().getLeft() - 50);
        }
        else {
            formatMarker(m, false, (int) m.getLabelOffset().getTop() - 5);
        }
    }
}
 
Example #2
Source File: BarChartPanel.java    From nmonvisualizer with Apache License 2.0 6 votes vote down vote up
@Override
public void addAnnotations(List<Annotation> annotations) {
    if (getChart() != null) {
        CategoryPlot plot = getChart().getCategoryPlot();

        plot.clearAnnotations();
        
        for (Annotation a : annotations) {
            if (a instanceof CategoryTextAnnotation) {
                CategoryTextAnnotation annotation = (CategoryTextAnnotation) a;

                if (plot.getCategories().contains(annotation.getCategory())) {
                    plot.addAnnotation(annotation);
                    firePropertyChange("annotation", null, annotation);
                }
            }
        }
    }
}
 
Example #3
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 #4
Source File: AnnotationCache.java    From nmonvisualizer with Apache License 2.0 5 votes vote down vote up
public static void addAnnotation(Annotation annotation) {
    if (annotation != null) {
        annotations.add(annotation);

        for (AnnotationListener listener : listeners) {
            listener.annotationAdded();
        }
    }
}
 
Example #5
Source File: AnnotationCache.java    From nmonvisualizer with Apache License 2.0 5 votes vote down vote up
public static void add(Object o) {
    if (o instanceof Marker) {
        markers.add((Marker) o);
    }
    else if (o instanceof Annotation) {
        annotations.add((Annotation) o);
    }
    else {
        return;
    }

    for (AnnotationListener listener : listeners) {
        listener.annotationAdded();
    }
}
 
Example #6
Source File: AnnotationCache.java    From nmonvisualizer with Apache License 2.0 4 votes vote down vote up
public static List<Annotation> getAnnotations() {
    return java.util.Collections.unmodifiableList(annotations);
}
 
Example #7
Source File: AnnotationChangeEvent.java    From buffer_bci with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Returns the annotation that triggered the event.
 *
 * @return The annotation that triggered the event (never <code>null</code>).
 *
 * @since 1.0.14
 */
public Annotation getAnnotation() {
    return this.annotation;
}
 
Example #8
Source File: AnnotationChangeEvent.java    From openstock with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Creates a new <code>AnnotationChangeEvent</code> instance.
 *
 * @param source  the event source.
 * @param annotation  the annotation that triggered the event
 *     (<code>null</code> not permitted).
 *
 * @since 1.0.14
 */
public AnnotationChangeEvent(Object source, Annotation annotation) {
    super(source);
    ParamChecks.nullNotPermitted(annotation, "annotation");
    this.annotation = annotation;
}
 
Example #9
Source File: AnnotationChangeEvent.java    From buffer_bci with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Creates a new <code>AnnotationChangeEvent</code> instance.
 *
 * @param source  the event source.
 * @param annotation  the annotation that triggered the event
 *     (<code>null</code> not permitted).
 *
 * @since 1.0.14
 */
public AnnotationChangeEvent(Object source, Annotation annotation) {
    super(source);
    ParamChecks.nullNotPermitted(annotation, "annotation");
    this.annotation = annotation;
}
 
Example #10
Source File: AnnotationChangeEvent.java    From buffer_bci with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Returns the annotation that triggered the event.
 *
 * @return The annotation that triggered the event (never <code>null</code>).
 *
 * @since 1.0.14
 */
public Annotation getAnnotation() {
    return this.annotation;
}
 
Example #11
Source File: AnnotationChangeEvent.java    From buffer_bci with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Creates a new <code>AnnotationChangeEvent</code> instance.
 *
 * @param source  the event source.
 * @param annotation  the annotation that triggered the event
 *     (<code>null</code> not permitted).
 *
 * @since 1.0.14
 */
public AnnotationChangeEvent(Object source, Annotation annotation) {
    super(source);
    ParamChecks.nullNotPermitted(annotation, "annotation");
    this.annotation = annotation;
}
 
Example #12
Source File: AnnotationChangeEvent.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the annotation that triggered the event.
 *
 * @return The annotation that triggered the event (never <code>null</code>).
 *
 * @since 1.0.14
 */
public Annotation getAnnotation() {
    return this.annotation;
}
 
Example #13
Source File: AnnotationChangeEvent.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a new <code>AnnotationChangeEvent</code> instance.
 *
 * @param annotation  the annotation that triggered the event
 *     (<code>null</code> not permitted).
 *
 * @since 1.0.14
 */
public AnnotationChangeEvent(Object source, Annotation annotation) {
    super(source);
    this.annotation = annotation;
}
 
Example #14
Source File: AnnotationChangeEvent.java    From ECG-Viewer with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the annotation that triggered the event.
 *
 * @return The annotation that triggered the event (never <code>null</code>).
 *
 * @since 1.0.14
 */
public Annotation getAnnotation() {
    return this.annotation;
}
 
Example #15
Source File: AnnotationChangeEvent.java    From ECG-Viewer with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a new <code>AnnotationChangeEvent</code> instance.
 *
 * @param source  the event source.
 * @param annotation  the annotation that triggered the event
 *     (<code>null</code> not permitted).
 *
 * @since 1.0.14
 */
public AnnotationChangeEvent(Object source, Annotation annotation) {
    super(source);
    ParamChecks.nullNotPermitted(annotation, "annotation");
    this.annotation = annotation;
}
 
Example #16
Source File: AnnotationChangeEvent.java    From SIMVA-SoS with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the annotation that triggered the event.
 *
 * @return The annotation that triggered the event (never <code>null</code>).
 *
 * @since 1.0.14
 */
public Annotation getAnnotation() {
    return this.annotation;
}
 
Example #17
Source File: AnnotationChangeEvent.java    From SIMVA-SoS with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new <code>AnnotationChangeEvent</code> instance.
 *
 * @param source  the event source.
 * @param annotation  the annotation that triggered the event
 *     (<code>null</code> not permitted).
 *
 * @since 1.0.14
 */
public AnnotationChangeEvent(Object source, Annotation annotation) {
    super(source);
    ParamChecks.nullNotPermitted(annotation, "annotation");
    this.annotation = annotation;
}
 
Example #18
Source File: AnnotationChangeEvent.java    From ccu-historian with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Returns the annotation that triggered the event.
 *
 * @return The annotation that triggered the event (never <code>null</code>).
 *
 * @since 1.0.14
 */
public Annotation getAnnotation() {
    return this.annotation;
}
 
Example #19
Source File: AnnotationChangeEvent.java    From ccu-historian with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Creates a new <code>AnnotationChangeEvent</code> instance.
 *
 * @param source  the event source.
 * @param annotation  the annotation that triggered the event
 *     (<code>null</code> not permitted).
 *
 * @since 1.0.14
 */
public AnnotationChangeEvent(Object source, Annotation annotation) {
    super(source);
    ParamChecks.nullNotPermitted(annotation, "annotation");
    this.annotation = annotation;
}
 
Example #20
Source File: AnnotationChangeEvent.java    From openstock with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Returns the annotation that triggered the event.
 *
 * @return The annotation that triggered the event (never <code>null</code>).
 *
 * @since 1.0.14
 */
public Annotation getAnnotation() {
    return this.annotation;
}
 
Example #21
Source File: BaseChartPanel.java    From nmonvisualizer with Apache License 2.0 votes vote down vote up
public void addAnnotations(List<Annotation> annotations) {}