public static RectangleOverlay makeRectangleOverlay( final Context context, final double x, final double y, final double w, final double h) { final RectangleOverlay overlay = new RectangleOverlay(context); overlay.getRegionOfInterest().setOrigin(new double[] {x, y}); overlay.getRegionOfInterest().setExtent(new double[] {w, h}); return overlay; }
@Override public void updateOverlay(final Figure figure, final OverlayView overlay) { super.updateOverlay(figure, overlay); final RectangleOverlay rOverlay = downcastOverlay(overlay.getData()); final RectangleRegionOfInterest roi = rOverlay.getRegionOfInterest(); final Rectangle2D.Double bounds = figure.getBounds(); roi.setOrigin(bounds.getMinX(), 0); roi.setOrigin(bounds.getMinY(), 1); roi.setExtent(bounds.getWidth(), 0); roi.setExtent(bounds.getHeight(), 1); }
@Override public void updateFigure(final OverlayView overlay, final Figure f) { super.updateFigure(overlay, f); final RectangleOverlay rectangleOverlay = downcastOverlay(overlay.getData()); final RectangleRegionOfInterest roi = rectangleOverlay.getRegionOfInterest(); final double x0 = roi.getOrigin(0); final double w = roi.getExtent(0); final double y0 = roi.getOrigin(1); final double h = roi.getExtent(1); final Point2D.Double anch = new Point2D.Double(x0, y0); final Point2D.Double lead = new Point2D.Double(x0 + w, y0 + h); f.setBounds(anch, lead); }