Search in sources :

Example 1 with Annotation

use of org.csstudio.javafx.rtplot.Annotation in project org.csstudio.display.builder by kasemir.

the class ControllerBase method start.

/**
 * Start model items and initiate scrolling/updates
 *  @throws Exception on error: Already running, problem starting threads, ...
 *  @see #isRunning()
 */
public void start() throws Exception {
    if (isRunning())
        throw new IllegalStateException("Already started");
    plot.getPlot().setBackground(SWTMediaPool.getJFX(model.getPlotBackground()));
    plot.getPlot().getXAxis().setGridVisible(model.isGridVisible());
    plot.getPlot().showToolbar(model.isToolbarVisible());
    plot.getPlot().showLegend(model.isLegendVisible());
    plot.getPlot().setTitleFont(SWTMediaPool.getJFX(model.getTitleFont()));
    plot.getPlot().setLegendFont(SWTMediaPool.getJFX(model.getLegendFont()));
    String title = model.getTitle().orElse(null);
    if (title != null)
        title = model.resolveMacros(title);
    plot.getPlot().setTitle(title);
    plot.getPlot().setScrollStep(model.getScrollStep());
    final List<Trace<Instant>> traces = new ArrayList<>();
    for (Trace<Instant> trace : plot.getPlot().getTraces()) traces.add(trace);
    for (AnnotationInfo info : model.getAnnotations()) {
        final Trace<Instant> trace = traces.get(info.getItemIndex());
        final Annotation<Instant> annotation = new Annotation<Instant>(info.isInternal(), trace, info.getTime(), info.getValue(), info.getOffset(), info.getText());
        plot.getPlot().addAnnotation(annotation);
    }
    createUpdateTask();
    model.start();
    // Initial time range setup, schedule archive fetch
    if (!model.isScrollEnabled())
        plot.getPlot().setScrolling(false);
    model_listener.changedTimerange();
}
Also used : Trace(org.csstudio.javafx.rtplot.Trace) Instant(java.time.Instant) ArrayList(java.util.ArrayList) Annotation(org.csstudio.javafx.rtplot.Annotation) AnnotationInfo(org.csstudio.trends.databrowser3.model.AnnotationInfo)

Example 2 with Annotation

use of org.csstudio.javafx.rtplot.Annotation in project org.csstudio.display.builder by kasemir.

the class ModelBasedPlot method setAnnotations.

/**
 * Set annotations in plot to match model's annotations
 *  @param newAnnotations Annotations to show in plot
 */
void setAnnotations(final Collection<AnnotationInfo> newAnnotations) {
    final List<Trace<Instant>> traces = new ArrayList<>();
    for (Trace<Instant> trace : plot.getTraces()) traces.add(trace);
    // Remove old annotations from plot
    final List<Annotation<Instant>> plot_annotations = new ArrayList<>(plot.getAnnotations());
    for (Annotation<Instant> old : plot_annotations) plot.removeAnnotation(old);
    // Set new annotations in plot
    for (AnnotationInfo annotation : newAnnotations) plot.addAnnotation(new Annotation<Instant>(annotation.isInternal(), traces.get(annotation.getItemIndex()), annotation.getTime(), annotation.getValue(), annotation.getOffset(), annotation.getText()));
}
Also used : Trace(org.csstudio.javafx.rtplot.Trace) Instant(java.time.Instant) ArrayList(java.util.ArrayList) Annotation(org.csstudio.javafx.rtplot.Annotation) AnnotationInfo(org.csstudio.trends.databrowser3.model.AnnotationInfo)

Aggregations

Instant (java.time.Instant)2 ArrayList (java.util.ArrayList)2 Annotation (org.csstudio.javafx.rtplot.Annotation)2 Trace (org.csstudio.javafx.rtplot.Trace)2 AnnotationInfo (org.csstudio.trends.databrowser3.model.AnnotationInfo)2