/** * Add an overlay to the panel. * * @param overlay * the overlay (<code>null</code> not permitted). * * @since 1.0.13 */ @Override public void addOverlay(Overlay overlay) { if (overlay == null) { throw new IllegalArgumentException("Null 'overlay' argument."); } this.overlays.add(overlay); overlay.addChangeListener(this); repaint(); }
/** * Removes an overlay from the panel. * * @param overlay * the overlay to remove (<code>null</code> not permitted). * * @since 1.0.13 */ @Override public void removeOverlay(Overlay overlay) { if (overlay == null) { throw new IllegalArgumentException("Null 'overlay' argument."); } boolean removed = this.overlays.remove(overlay); if (removed) { overlay.removeChangeListener(this); repaint(); } }
/** * Removes an overlay from the panel. * * @param overlay the overlay to remove (<code>null</code> not permitted). * * @since 1.0.13 */ public void removeOverlay(Overlay overlay) { ParamChecks.nullNotPermitted(overlay, "overlay"); boolean removed = this.overlays.remove(overlay); if (removed) { overlay.removeChangeListener(this); repaint(); } }
/** * Removes an overlay from the panel. * * @param overlay the overlay to remove ({@code null} not permitted). * * @since 1.0.13 */ public void removeOverlay(Overlay overlay) { Args.nullNotPermitted(overlay, "overlay"); boolean removed = this.overlays.remove(overlay); if (removed) { overlay.removeChangeListener(this); repaint(); } }
/** * Add an overlay to the panel. * * @param overlay the overlay (<code>null</code> not permitted). * * @since 1.0.13 */ public void addOverlay(Overlay overlay) { if (overlay == null) { throw new IllegalArgumentException("Null 'overlay' argument."); } this.overlays.add(overlay); overlay.addChangeListener(this); repaint(); }
/** * Removes an overlay from the panel. * * @param overlay the overlay to remove (<code>null</code> not permitted). * * @since 1.0.13 */ public void removeOverlay(Overlay overlay) { if (overlay == null) { throw new IllegalArgumentException("Null 'overlay' argument."); } boolean removed = this.overlays.remove(overlay); if (removed) { overlay.removeChangeListener(this); repaint(); } }
/** * Paints the component by drawing the chart to fill the entire component, but allowing for the * insets (which will be non-zero if a border has been set for this component). To increase * performance (at the expense of memory), an off-screen buffer image can be used. * * @param g * the graphics device for drawing on. */ @Override public void paintComponent(Graphics g) { if (this.chart == null) { return; } Graphics2D g2 = (Graphics2D) g.create(); // first determine the size of the chart rendering area... Dimension size = getSize(); Insets insets = getInsets(); Rectangle2D available = new Rectangle2D.Double(insets.left, insets.top, size.getWidth() - insets.left - insets.right, size.getHeight() - insets.top - insets.bottom); // work out if scaling is required... boolean scale = false; double drawWidth = available.getWidth(); double drawHeight = available.getHeight(); this.scaleX = 1.0; this.scaleY = 1.0; if (drawWidth < this.minimumDrawWidth) { this.scaleX = drawWidth / this.minimumDrawWidth; drawWidth = this.minimumDrawWidth; scale = true; } else if (drawWidth > this.maximumDrawWidth) { this.scaleX = drawWidth / this.maximumDrawWidth; drawWidth = this.maximumDrawWidth; scale = true; } if (drawHeight < this.minimumDrawHeight) { this.scaleY = drawHeight / this.minimumDrawHeight; drawHeight = this.minimumDrawHeight; scale = true; } else if (drawHeight > this.maximumDrawHeight) { this.scaleY = drawHeight / this.maximumDrawHeight; drawHeight = this.maximumDrawHeight; scale = true; } Rectangle2D chartArea = new Rectangle2D.Double(0.0, 0.0, drawWidth, drawHeight); // redrawing the chart every time... AffineTransform saved = g2.getTransform(); g2.translate(insets.left, insets.top); if (scale) { AffineTransform st = AffineTransform.getScaleInstance(this.scaleX, this.scaleY); g2.transform(st); } this.chart.draw(g2, chartArea, this.anchor, this.info); g2.setTransform(saved); Iterator<Overlay> iterator = this.overlays.iterator(); while (iterator.hasNext()) { Overlay overlay = iterator.next(); overlay.paintOverlay(g2, this); } // redraw the zoom rectangle (if present) - if useBuffer is false, // we use XOR so we can XOR the rectangle away again without redrawing // the chart drawSelectionRectangle(g2); g2.dispose(); this.anchor = null; this.verticalTraceLine = null; this.horizontalTraceLine = null; }
@SuppressWarnings("unchecked") public List<Overlay> getOverlayList() { return ((List<Overlay>) getChartFieldValueByName("overlays")); }
public void setOverlayList(List<Overlay> list) { setChartFieldValue(getChartFieldByName("overlays"), list); }
@SuppressWarnings("unchecked") public List<Overlay> getOverlayList() { return (List<Overlay>) getChartFieldValueByName("overlays"); }
/** * Paints the component by drawing the chart to fill the entire component, but allowing for the insets (which will * be non-zero if a border has been set for this component). To increase performance (at the expense of memory), an * off-screen buffer image can be used. * * @param g * the graphics device for drawing on. */ @Override public void paintComponent(Graphics g) { if (this.chart == null) { return; } Graphics2D g2 = (Graphics2D) g.create(); // first determine the size of the chart rendering area... Dimension size = getSize(); Insets insets = getInsets(); Rectangle2D available = new Rectangle2D.Double(insets.left, insets.top, size.getWidth() - insets.left - insets.right, size.getHeight() - insets.top - insets.bottom); // work out if scaling is required... boolean scale = false; double drawWidth = available.getWidth(); double drawHeight = available.getHeight(); this.scaleX = 1.0; this.scaleY = 1.0; if (drawWidth < this.minimumDrawWidth) { this.scaleX = drawWidth / this.minimumDrawWidth; drawWidth = this.minimumDrawWidth; scale = true; } else if (drawWidth > this.maximumDrawWidth) { this.scaleX = drawWidth / this.maximumDrawWidth; drawWidth = this.maximumDrawWidth; scale = true; } if (drawHeight < this.minimumDrawHeight) { this.scaleY = drawHeight / this.minimumDrawHeight; drawHeight = this.minimumDrawHeight; scale = true; } else if (drawHeight > this.maximumDrawHeight) { this.scaleY = drawHeight / this.maximumDrawHeight; drawHeight = this.maximumDrawHeight; scale = true; } Rectangle2D chartArea = new Rectangle2D.Double(0.0, 0.0, drawWidth, drawHeight); // redrawing the chart every time... AffineTransform saved = g2.getTransform(); g2.translate(insets.left, insets.top); if (scale) { AffineTransform st = AffineTransform.getScaleInstance(this.scaleX, this.scaleY); g2.transform(st); } this.chart.draw(g2, chartArea, this.anchor, this.info); g2.setTransform(saved); Iterator<Overlay> iterator = this.overlays.iterator(); while (iterator.hasNext()) { Overlay overlay = iterator.next(); overlay.paintOverlay(g2, this); } // redraw the zoom rectangle (if present) - if useBuffer is false, // we use XOR so we can XOR the rectangle away again without redrawing // the chart drawSelectionRectangle(g2); g2.dispose(); this.anchor = null; this.verticalTraceLine = null; this.horizontalTraceLine = null; }
/** * Add an overlay to the panel. * * @param overlay the overlay (<code>null</code> not permitted). * * @since 1.0.13 */ public void addOverlay(Overlay overlay) { ParamChecks.nullNotPermitted(overlay, "overlay"); this.overlays.add(overlay); overlay.addChangeListener(this); repaint(); }
/** * Add an overlay to the panel. * * @param overlay the overlay ({@code null} not permitted). * * @since 1.0.13 */ public void addOverlay(Overlay overlay) { Args.nullNotPermitted(overlay, "overlay"); this.overlays.add(overlay); overlay.addChangeListener(this); repaint(); }