Search in sources :

Example 6 with AnnotationInfo

use of org.csstudio.trends.databrowser3.model.AnnotationInfo in project org.csstudio.display.builder by kasemir.

the class WaveformView method updateAnnotation.

private void updateAnnotation(final Instant time, final double value) {
    final List<AnnotationInfo> annotations = new ArrayList<AnnotationInfo>(model.getAnnotations());
    // Initial annotation offset
    Point2D offset = new Point2D(20, -20);
    // If already in model, note its offset and remove
    for (AnnotationInfo annotation : annotations) {
        if (annotation.getText().equals(ANNOTATION_TEXT)) {
            // Update offset to where user last placed it
            offset = annotation.getOffset();
            waveform_annotation = annotation;
            annotations.remove(waveform_annotation);
            break;
        }
    }
    int i = 0;
    int item_index = 0;
    for (ModelItem item : model.getItems()) {
        if (item == model_item) {
            item_index = i;
            break;
        }
        i++;
    }
    waveform_annotation = new AnnotationInfo(true, item_index, time, value, offset, ANNOTATION_TEXT);
    annotations.add(waveform_annotation);
    changing_annotations = true;
    model.setAnnotations(annotations);
    changing_annotations = false;
}
Also used : Point2D(javafx.geometry.Point2D) ArrayList(java.util.ArrayList) ModelItem(org.csstudio.trends.databrowser3.model.ModelItem) AnnotationInfo(org.csstudio.trends.databrowser3.model.AnnotationInfo)

Aggregations

AnnotationInfo (org.csstudio.trends.databrowser3.model.AnnotationInfo)6 ArrayList (java.util.ArrayList)4 ModelItem (org.csstudio.trends.databrowser3.model.ModelItem)3 Instant (java.time.Instant)2 Annotation (org.csstudio.javafx.rtplot.Annotation)2 Trace (org.csstudio.javafx.rtplot.Trace)2 AxisConfig (org.csstudio.trends.databrowser3.model.AxisConfig)2 PrintWriter (java.io.PrintWriter)1 Point2D (javafx.geometry.Point2D)1 TimeDataSearch (org.csstudio.javafx.rtplot.data.TimeDataSearch)1 PVItem (org.csstudio.trends.databrowser3.model.PVItem)1 PlotSamples (org.csstudio.trends.databrowser3.model.PlotSamples)1 RGB (org.eclipse.swt.graphics.RGB)1 Element (org.w3c.dom.Element)1