Creates a {@linkplain Rectangle2D.Double rectangle} from the current
region.

<p>
Note that the rectangle width and height are world coordinates.
</p>

@return the rectangle wrapping the current region.
487044
public Rectangle2D.Double getRectangle() {
        return new Rectangle2D.Double(west, south, east - west, north - south);
    }
154220
function(rectangle) {
        var topLeft = this.viewport.pixelFromPointNoRotate(rectangle.getTopLeft(), true);
        var size = this.viewport.deltaPixelsFromPointsNoRotate(rectangle.getSize(), true);

        return new $.Rect(
            topLeft.x * $.pixelDensityRatio,
            topLeft.y * $.pixelDensityRatio,
            size.x * $.pixelDensityRatio,
            size.y * $.pixelDensityRatio
        );
    }
529841
public Rectangle2D getBounds() {
		if (needsRefresh)
			refreshCurve();
		Rectangle2D b = curve.getBounds();
		Area area = new Area(bounds);
		area.transform(affineToText);
		b.add(area.getBounds());
		return b;
	}
944433
@Pure
	public Rectangle2d toBounds2D() {
		int startIndex = this.id.indexOf('#');
		if (startIndex <= 0) {
			return null;
		}

		try {
			int endIndex = this.id.indexOf(';', startIndex);
			if (endIndex <= startIndex) {
				return null;
			}
			final long minx = Long.parseLong(this.id.substring(startIndex + 1, endIndex));

			startIndex = endIndex + 1;
			endIndex = this.id.indexOf(';', startIndex);
			if (endIndex <= startIndex) {
				return null;
			}
			final long miny = Long.parseLong(this.id.substring(startIndex, endIndex));

			startIndex = endIndex + 1;
			endIndex = this.id.indexOf(';', startIndex);
			if (endIndex <= startIndex) {
				return null;
			}
			final long maxx = Long.parseLong(this.id.substring(startIndex, endIndex));

			startIndex = endIndex + 1;
			final long maxy = Long.parseLong(this.id.substring(startIndex));

			final Rectangle2d r = new Rectangle2d();
			r.setFromCorners(minx, miny, maxx, maxy);
			return r;
		} catch (Throwable exception) {
			//
		}

		return null;
	}
722295
@Override
	@Pure
	protected Rectangle2d calcBounds() {
		double x = this.getX();
		double y = this.getY();

		final double w = this.radius * 2;
		final double h = w;

		x -= w / 2.;
		y -= h / 2.;

		return new Rectangle2d(x, y, w, h);
	}
592526
private static RoundRectangle2D.Double toRoundRect(final Rectangle2D pRectangle, final int pArcW, final int pArcH) {
        return new RoundRectangle2D.Double(
                pRectangle.getX(), pRectangle.getY(),
                pRectangle.getWidth(), pRectangle.getHeight(),
                pArcW, pArcH);
    }
897504
protected Rectangle applyClip(Shape current, Rectangle newclip)
    {
        if (current == null)
            return newclip;
        else
        {
            if (current instanceof Rectangle)
                return ((Rectangle) current).intersection(newclip);
            else
                return current.getBounds().intersection(newclip);
        }
    }
995744
public Rectangle getViewport() {
		@SuppressWarnings("unchecked")
		Map<String, Number> result = (Map<String, Number>) executeScript(JS_GET_VIEWPORT);
		int width = result.get("width").intValue();
		int height = result.get("height").intValue();
		Rectangle viewport = new Rectangle(0, 0, height, width, width, height);
		LOGGER.info("Viewport rectangle: {}", viewport);
		return viewport;
	}
509506
public ObjectProperty<Rectangle2ifx> controlPointBoundingBoxProperty() {
		if (this.logicalBounds == null) {
			this.logicalBounds = new ReadOnlyObjectWrapper<>(this, MathFXAttributeNames.CONTROL_POINT_BOUNDING_BOX);
			this.logicalBounds.bind(Bindings.createObjectBinding(() -> {
				final Rectangle2ifx bb = getGeomFactory().newBox();
				Path2ai.calculatesControlPointBoundingBox(
						getPathIterator(),
						bb);
				return bb;
			}, innerPointsProperty()));
		}
		return this.logicalBounds;
	}
245577
public Rectangle getContainingBlock()
    {
        if (cbox instanceof Viewport) //initial containing block
        {
            Rectangle visible = ((Viewport) cbox).getVisibleRect();
            return new Rectangle(0, 0, visible.width, visible.height);
        }
        else //static or relative position
            return cbox.getContentBounds();
    }
569792
public Rectangle getAbsoluteContainingBlock()
    {
        if (cbox instanceof Viewport) //initial containing block
        {
            Rectangle ab = cbox.getAbsoluteBounds(); //normally positioned at 0,0; other value for nested viewports (e.g. objects)
            Rectangle visible = ((Viewport) cbox).getVisibleRect();
            return new Rectangle(ab.x, ab.y, visible.width, visible.height);
        }
        else //static or relative position
            return cbox.getAbsoluteContentBounds();
    }
1034681
function(rectangle) {
        return $.Rect.fromSummits(
            this.pixelFromPoint(rectangle.getTopLeft(), true),
            this.pixelFromPoint(rectangle.getTopRight(), true),
            this.pixelFromPoint(rectangle.getBottomLeft(), true)
        );
    }
1358920
protected Rectangle convertToDiagramBounds(Rectangle2D modelBounds) {
        double xCenter = modelBounds.getCenterX();
        double yCenter = modelBounds.getCenterY();
        double modelWidth = modelBounds.getWidth();
        double modelHeight = modelBounds.getHeight();

        double scale = rendererModel.getParameter(Scale.class).getValue();
        double zoom = rendererModel.getParameter(ZoomFactor.class).getValue();

        Point2d screenCoord = this.toScreenCoordinates(xCenter, yCenter);

        // special case for 0 or 1 atoms
        if (modelWidth == 0 && modelHeight == 0) {
            return new Rectangle((int) screenCoord.x, (int) screenCoord.y, 0, 0);
        }

        double margin = rendererModel.getParameter(Margin.class).getValue();
        int width = (int) ((scale * zoom * modelWidth) + (2 * margin));
        int height = (int) ((scale * zoom * modelHeight) + (2 * margin));
        int xCoord = (int) (screenCoord.x - width / 2);
        int yCoord = (int) (screenCoord.y - height / 2);

        return new Rectangle(xCoord, yCoord, width, height);
    }
175307
private Rectangle getDefaultBounds() {
		final Dimension size = getToolkit().getScreenSize();
		final Insets insets = getToolkit().getScreenInsets(getGraphicsConfiguration());
		return new Rectangle(insets.left, insets.top, size.width - insets.left - insets.right,
				size.height - insets.top - insets.bottom);
	}
1319652
public Rectangle rectangle(float top, float bottom) {
        Rectangle tmp = new Rectangle(getLeft(), getBottom(), getRight(), getTop());
        tmp.cloneNonPositionParameters(this);
        if (getTop() > top) {
            tmp.setTop(top);
            tmp.setBorder(border - (border & TOP));
        }
        if (getBottom() < bottom) {
            tmp.setBottom(bottom);
            tmp.setBorder(border - (border & BOTTOM));
        }
        return tmp;
    }
561712
@Override
	@Pure
	public boolean intersects(Shape2D<?, ?, ?, ?, ?, ? extends Rectangle2afp<?, ?, ?, ?, ?, ?>> rectangle) {
		if (boundsIntersects(rectangle)) {
			final double x = getX();
			final double y = getY();
			final Rectangle2afp<?, ?, ?, ?, ?, ?> box = rectangle.toBoundingBox();
			final double minx = box.getMinX();
			final double miny = box.getMinY();
			final double maxx = box.getMaxX();
			final double maxy = box.getMaxY();

			return MathUtil.min(
					Segment2afp.calculatesDistanceSegmentPoint(minx, miny, maxx, miny, x, y),
					Segment2afp.calculatesDistanceSegmentPoint(minx, miny, minx, maxy, x, y),
					Segment2afp.calculatesDistanceSegmentPoint(maxx, miny, maxx, maxy, x, y),
					Segment2afp.calculatesDistanceSegmentPoint(minx, maxy, maxx, maxy, x, y)) <= this.radius;
		}
		return false;
	}
248822
public static Dimension rectangleDoubleToDimension(final Rectangle2D.Double rectangle) {
        return new Dimension(
                (int) Math.round(rectangle.width),
                (int) Math.round(rectangle.height));
    }