Gets a Rectangle that is altered to fit on the page.

@param top		the top position
@param bottom	the bottom position
@return a <CODE>Rectangle</CODE>
485327
public Rectangle rectangle(float top, float bottom) {
		Rectangle tmp = new Rectangle(this);
		if (getTop() > top) {
			tmp.setTop(top);
			tmp.disableBorderSide(TOP);
		}
		if (getBottom() < bottom) {
			tmp.setBottom(bottom);
			tmp.disableBorderSide(BOTTOM);
		}
		return tmp;
	}
1027927
public static CmsRectangle fromPoints(CmsPoint topLeft, CmsPoint bottomRight) {

        CmsRectangle result = new CmsRectangle();
        result.m_left = topLeft.getX();
        result.m_top = topLeft.getY();
        result.m_width = bottomRight.getX() - topLeft.getX();
        result.m_height = bottomRight.getY() - topLeft.getY();
        return result;
    }
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;
	}
1332079
@Override
	@Pure
	public boolean intersects(Shape2D<?, ?, ?, ?, ?, ? extends Rectangle2afp<?, ?, ?, ?, ?, ?>> rectangle) {
		if (boundsIntersects(rectangle)) {
			final Path2d p = toPath2D();
			return p.intersects(rectangle);
		}
		return false;
	}
686387
public Rectangle enlarge(double left, double top, double right, double bottom) {
        return new Rectangle(this.left - left, this.top - top, this.right + right, this.bottom + bottom);
    }
816690
public Rectangle2D getBoundingBox() {
		Dimension glyphDimension = getMetrics().getGlyphDimension(getNotationContext());
		if (isStemUp()) {
			return new Rectangle2D.Double(
				(int)(getBase().getX()),
                stemYEnd,
				getWidth(),
				getStemBeginPosition().getY()-stemYEnd+glyphDimension.getHeight()/2);
		}
		else {
			return new Rectangle2D.Double(
				(int)(getBase().getX()),
				getStemBeginPosition().getY()-glyphDimension.getHeight()/2,
				getWidth(),
				stemYEnd-getStemBeginPosition().getY()+1+glyphDimension.getHeight()/2);
		}
	}
822437
public static CmsRectangle fromLeftTopWidthHeight(double left, double top, double width, double height) {

        CmsRectangle result = new CmsRectangle();
        result.m_left = left;
        result.m_top = top;
        result.m_width = width;
        result.m_height = height;
        return result;
    }
278367
protected Rectangle getCancelButtonBounds() {
        JTextComponent c = getComponent();
        final int      x = c.getWidth() - c.getHeight() / 2 - 9;
        final int      y = c.getHeight() / 2 - 8;

        return new Rectangle(x, y, 17, 17);
    }
172777
public Rectangle intersection(Rectangle other) {
		int left = Math.max(this.left, other.left);
		int top = Math.max(this.top, other.top);
		int right = Math.min(this.right, other.right);
		int bottom = Math.min(this.bottom, other.bottom);
		if (right >= left && bottom >= top) {
			int height = bottom - top;
			int width = right - left;
			return new Rectangle(top, left, bottom, right, width, height);
		} else {
			return null;
		}
	}
212938
function(rectangle) {
        return $.Rect.fromSummits(
            this.pointFromPixel(rectangle.getTopLeft(), true),
            this.pointFromPixel(rectangle.getTopRight(), true),
            this.pointFromPixel(rectangle.getBottomLeft(), true)
        );
    }
505370
public static Rectangle getBoundaryAbsolute(Tile upperLeft, Tile lowerRight) {
        return new Rectangle(upperLeft.getOrigin().x, upperLeft.getOrigin().y, lowerRight.getOrigin().x + upperLeft.tileSize, lowerRight.getOrigin().y + upperLeft.tileSize);
    }
419565
public void variableRectangle(Rectangle rect) {
        float t = rect.getTop();
        float b = rect.getBottom();
        float r = rect.getRight();
        float l = rect.getLeft();
        float wt = rect.getBorderWidthTop();
        float wb = rect.getBorderWidthBottom();
        float wr = rect.getBorderWidthRight();
        float wl = rect.getBorderWidthLeft();
        Color ct = rect.getBorderColorTop();
        Color cb = rect.getBorderColorBottom();
        Color cr = rect.getBorderColorRight();
        Color cl = rect.getBorderColorLeft();
        saveState();
        setLineCap(PdfContentByte.LINE_CAP_BUTT);
        setLineJoin(PdfContentByte.LINE_JOIN_MITER);
        float clw = 0;
        boolean cdef = false;
        Color ccol = null;
        boolean cdefi = false;
        Color cfil = null;
        // draw top
        if (wt > 0) {
            setLineWidth(clw = wt);
            cdef = true;
            if (ct == null)
                resetRGBColorStroke();
            else
                setColorStroke(ct);
            ccol = ct;
            moveTo(l, t - wt / 2f);
            lineTo(r, t - wt / 2f);
            stroke();
        }

        // Draw bottom
        if (wb > 0) {
            if (wb != clw)
                setLineWidth(clw = wb);
            if (!cdef || !compareColors(ccol, cb)) {
                cdef = true;
                if (cb == null)
                    resetRGBColorStroke();
                else
                    setColorStroke(cb);
                ccol = cb;
            }
            moveTo(r, b + wb / 2f);
            lineTo(l, b + wb / 2f);
            stroke();
        }

        // Draw right
        if (wr > 0) {
            if (wr != clw)
                setLineWidth(clw = wr);
            if (!cdef || !compareColors(ccol, cr)) {
                cdef = true;
                if (cr == null)
                    resetRGBColorStroke();
                else
                    setColorStroke(cr);
                ccol = cr;
            }
            boolean bt = compareColors(ct, cr);
            boolean bb = compareColors(cb, cr);
            moveTo(r - wr / 2f, bt ? t : t - wt);
            lineTo(r - wr / 2f, bb ? b : b + wb);
            stroke();
            if (!bt || !bb) {
                cdefi = true;
                if (cr == null)
                    resetRGBColorFill();
                else
                    setColorFill(cr);
                cfil = cr;
                if (!bt) {
                    moveTo(r, t);
                    lineTo(r, t - wt);
                    lineTo(r - wr, t - wt);
                    fill();
                }
                if (!bb) {
                    moveTo(r, b);
                    lineTo(r, b + wb);
                    lineTo(r - wr, b + wb);
                    fill();
                }
            }
        }

        // Draw Left
        if (wl > 0) {
            if (wl != clw)
                setLineWidth(wl);
            if (!cdef || !compareColors(ccol, cl)) {
                if (cl == null)
                    resetRGBColorStroke();
                else
                    setColorStroke(cl);
            }
            boolean bt = compareColors(ct, cl);
            boolean bb = compareColors(cb, cl);
            moveTo(l + wl / 2f, bt ? t : t - wt);
            lineTo(l + wl / 2f, bb ? b : b + wb);
            stroke();
            if (!bt || !bb) {
                if (!cdefi || !compareColors(cfil, cl)) {
                    if (cl == null)
                        resetRGBColorFill();
                    else
                        setColorFill(cl);
                }
                if (!bt) {
                    moveTo(l, t);
                    lineTo(l, t - wt);
                    lineTo(l + wl, t - wt);
                    fill();
                }
                if (!bb) {
                    moveTo(l, b);
                    lineTo(l, b + wb);
                    lineTo(l + wl, b + wb);
                    fill();
                }
            }
        }
        restoreState();
    }
206310
public Rectangle getRect() {
        verifyPropertyPresence(RECT);
        //noinspection unchecked
        return mapToRect((Map<String, Object>) getCommandResult().get(RECT));
    }
809971
public Rectangle getBoundsSurrounding (Rectangle content)
    {
        Rectangle bounds = new Rectangle(content);

        bounds.width += _leftPad + _rightPad;
        bounds.height += _topPad + _bottomPad;
        bounds.x -= _leftPad;
        bounds.y -= _topPad;

        return bounds;
    }
1360028
protected Rectangle getRadialMenuBounds (SceneObject scobj)
    {
        Rectangle mbounds = new Rectangle(scobj.bounds);
        Dimension radbox = getObjectRadialSize();
        if (mbounds.width != radbox.width) {
            mbounds.x += (mbounds.width-radbox.width)/2;
            mbounds.width = radbox.width;
        }
        if (mbounds.height != radbox.height) {
            mbounds.y += (mbounds.height-radbox.height)/2;
            mbounds.height = radbox.height;
        }
        return mbounds;
    }
381322
public Rectangle toRelative(Rectangle rect) {
		return new Rectangle(rect.getLeft() - origX, rect.getBottom() - origY, rect.getRight() - origX, rect.getTop()
				- origY);
	}
1037294
private Rectangle2D getBoundsHintVertical() {

    if (!chart.getStyler().isLegendVisible()) {
      return new Rectangle2D
          .Double(); // Constructs a new Rectangle2D, initialized to location (0, 0) and size (0,
      // 0).
    }

    boolean containsBox = false;

    // determine legend text content max width
    double legendTextContentMaxWidth = 0;

    // determine total legend content height
    double legendContentHeight = 0;

    Map<String, S> map = chart.getSeriesMap();
    for (S series : map.values()) {

      if (!series.isShowInLegend()) {
        continue;
      }
      if (!series.isEnabled()) {
        continue;
      }

      Map<String, Rectangle2D> seriesTextBounds = getSeriesTextBounds(series);

      double legendEntryHeight = 0; // could be multi-line
      for (Map.Entry<String, Rectangle2D> entry : seriesTextBounds.entrySet()) {
        legendEntryHeight += entry.getValue().getHeight() + MULTI_LINE_SPACE;
        legendTextContentMaxWidth =
            Math.max(legendTextContentMaxWidth, entry.getValue().getWidth());
      }

      legendEntryHeight -= MULTI_LINE_SPACE; // subtract away the bottom MULTI_LINE_SPACE
      legendEntryHeight = Math.max(legendEntryHeight, (getSeriesLegendRenderGraphicHeight(series)));

      legendContentHeight += legendEntryHeight + chart.getStyler().getLegendPadding();

      if (series.getLegendRenderType() == LegendRenderType.Box) {
        containsBox = true;
      }
    }

    // determine legend content width
    double legendContentWidth;
    if (!containsBox) {
      legendContentWidth =
          chart.getStyler().getLegendSeriesLineLength()
              + chart.getStyler().getLegendPadding()
              + legendTextContentMaxWidth;
    } else {
      legendContentWidth =
          BOX_SIZE + chart.getStyler().getLegendPadding() + legendTextContentMaxWidth;
    }

    // Legend Box
    double width = legendContentWidth + 2 * chart.getStyler().getLegendPadding();
    double height = legendContentHeight + chart.getStyler().getLegendPadding();

    return new Rectangle2D.Double(0, 0, width, height); // 0 indicates not sure yet.
  }