/** * Adds an annotation to the specified layer. * * @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); notifyListeners(new RendererChangeEvent(this)); } else if (layer.equals(Layer.BACKGROUND)) { this.backgroundAnnotations.add(annotation); notifyListeners(new RendererChangeEvent(this)); } else { // should never get here throw new RuntimeException("Unknown layer."); } }
/** * 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. */ 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(); annotation.draw(g2, this.plot, dataArea, domainAxis, rangeAxis, 0, info); } }
/** * 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."); } }
/** * 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); } }
/** * Adds an annotation to the specified layer and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param annotation the annotation ({@code null} not permitted). * @param layer the layer ({@code null} not permitted). */ @Override public void addAnnotation(XYAnnotation annotation, Layer layer) { Args.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."); } }
/** * 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); fireChangeEvent(); } else if (layer.equals(Layer.BACKGROUND)) { this.backgroundAnnotations.add(annotation); fireChangeEvent(); } else { // should never get here throw new RuntimeException("Unknown layer."); } }
/** * 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."); } }
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); } } }
@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); } } } }
/** * Adds an annotation to the plot and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param annotation the annotation (<code>null</code> not permitted). */ public void addAnnotation(XYAnnotation annotation) { if (annotation == null) { throw new IllegalArgumentException("Null 'annotation' argument."); } if (this.annotations == null) { this.annotations = new java.util.ArrayList(); } this.annotations.add(annotation); notifyListeners(new PlotChangeEvent(this)); }
/** * Removes an annotation from the plot and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param annotation the annotation (<code>null</code> not permitted). * * @return A boolean (indicates whether or not the annotation is removed). */ public boolean removeAnnotation(XYAnnotation annotation) { if (annotation == null) { throw new IllegalArgumentException("Null 'annotation' argument."); } if (this.annotations != null) { boolean removed = this.annotations.remove(annotation); notifyListeners(new PlotChangeEvent(this)); return removed; } else { return false; } }
/** * 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) { // draw the annotations... if (this.annotations != null) { Iterator iterator = this.annotations.iterator(); while (iterator.hasNext()) { XYAnnotation annotation = (XYAnnotation) iterator.next(); annotation.draw(g2, this, dataArea, getDomainAxis(), getRangeAxis()); } } }
/** * 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)); }
/** * 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); } }