< prev index next >

src/java.desktop/share/classes/java/awt/geom/RectangularShape.java

Print this page

        

*** 28,42 **** import java.awt.Shape; import java.awt.Rectangle; import java.beans.Transient; /** ! * <code>RectangularShape</code> is the base class for a number of * {@link Shape} objects whose geometry is defined by a rectangular frame. * This class does not directly specify any specific geometry by * itself, but merely provides manipulation methods inherited by ! * a whole category of <code>Shape</code> objects. * The manipulation methods provided by this class can be used to * query and modify the rectangular frame, which provides a reference * for the subclasses to define their geometry. * * @author Jim Graham --- 28,42 ---- import java.awt.Shape; import java.awt.Rectangle; import java.beans.Transient; /** ! * {@code RectangularShape} is the base class for a number of * {@link Shape} objects whose geometry is defined by a rectangular frame. * This class does not directly specify any specific geometry by * itself, but merely provides manipulation methods inherited by ! * a whole category of {@code Shape} objects. * The manipulation methods provided by this class can be used to * query and modify the rectangular frame, which provides a reference * for the subclasses to define their geometry. * * @author Jim Graham
*** 56,174 **** protected RectangularShape() { } /** * Returns the X coordinate of the upper-left corner of ! * the framing rectangle in <code>double</code> precision. * @return the X coordinate of the upper-left corner of * the framing rectangle. * @since 1.2 */ public abstract double getX(); /** * Returns the Y coordinate of the upper-left corner of ! * the framing rectangle in <code>double</code> precision. * @return the Y coordinate of the upper-left corner of * the framing rectangle. * @since 1.2 */ public abstract double getY(); /** * Returns the width of the framing rectangle in ! * <code>double</code> precision. * @return the width of the framing rectangle. * @since 1.2 */ public abstract double getWidth(); /** * Returns the height of the framing rectangle ! * in <code>double</code> precision. * @return the height of the framing rectangle. * @since 1.2 */ public abstract double getHeight(); /** * Returns the smallest X coordinate of the framing ! * rectangle of the <code>Shape</code> in <code>double</code> * precision. * @return the smallest X coordinate of the framing ! * rectangle of the <code>Shape</code>. * @since 1.2 */ public double getMinX() { return getX(); } /** * Returns the smallest Y coordinate of the framing ! * rectangle of the <code>Shape</code> in <code>double</code> * precision. * @return the smallest Y coordinate of the framing ! * rectangle of the <code>Shape</code>. * @since 1.2 */ public double getMinY() { return getY(); } /** * Returns the largest X coordinate of the framing ! * rectangle of the <code>Shape</code> in <code>double</code> * precision. * @return the largest X coordinate of the framing ! * rectangle of the <code>Shape</code>. * @since 1.2 */ public double getMaxX() { return getX() + getWidth(); } /** * Returns the largest Y coordinate of the framing ! * rectangle of the <code>Shape</code> in <code>double</code> * precision. * @return the largest Y coordinate of the framing ! * rectangle of the <code>Shape</code>. * @since 1.2 */ public double getMaxY() { return getY() + getHeight(); } /** * Returns the X coordinate of the center of the framing ! * rectangle of the <code>Shape</code> in <code>double</code> * precision. * @return the X coordinate of the center of the framing rectangle ! * of the <code>Shape</code>. * @since 1.2 */ public double getCenterX() { return getX() + getWidth() / 2.0; } /** * Returns the Y coordinate of the center of the framing ! * rectangle of the <code>Shape</code> in <code>double</code> * precision. * @return the Y coordinate of the center of the framing rectangle ! * of the <code>Shape</code>. * @since 1.2 */ public double getCenterY() { return getY() + getHeight() / 2.0; } /** * Returns the framing {@link Rectangle2D} * that defines the overall shape of this object. ! * @return a <code>Rectangle2D</code>, specified in ! * <code>double</code> coordinates. * @see #setFrame(double, double, double, double) * @see #setFrame(Point2D, Dimension2D) * @see #setFrame(Rectangle2D) * @since 1.2 */ --- 56,174 ---- protected RectangularShape() { } /** * Returns the X coordinate of the upper-left corner of ! * the framing rectangle in {@code double} precision. * @return the X coordinate of the upper-left corner of * the framing rectangle. * @since 1.2 */ public abstract double getX(); /** * Returns the Y coordinate of the upper-left corner of ! * the framing rectangle in {@code double} precision. * @return the Y coordinate of the upper-left corner of * the framing rectangle. * @since 1.2 */ public abstract double getY(); /** * Returns the width of the framing rectangle in ! * {@code double} precision. * @return the width of the framing rectangle. * @since 1.2 */ public abstract double getWidth(); /** * Returns the height of the framing rectangle ! * in {@code double} precision. * @return the height of the framing rectangle. * @since 1.2 */ public abstract double getHeight(); /** * Returns the smallest X coordinate of the framing ! * rectangle of the {@code Shape} in {@code double} * precision. * @return the smallest X coordinate of the framing ! * rectangle of the {@code Shape}. * @since 1.2 */ public double getMinX() { return getX(); } /** * Returns the smallest Y coordinate of the framing ! * rectangle of the {@code Shape} in {@code double} * precision. * @return the smallest Y coordinate of the framing ! * rectangle of the {@code Shape}. * @since 1.2 */ public double getMinY() { return getY(); } /** * Returns the largest X coordinate of the framing ! * rectangle of the {@code Shape} in {@code double} * precision. * @return the largest X coordinate of the framing ! * rectangle of the {@code Shape}. * @since 1.2 */ public double getMaxX() { return getX() + getWidth(); } /** * Returns the largest Y coordinate of the framing ! * rectangle of the {@code Shape} in {@code double} * precision. * @return the largest Y coordinate of the framing ! * rectangle of the {@code Shape}. * @since 1.2 */ public double getMaxY() { return getY() + getHeight(); } /** * Returns the X coordinate of the center of the framing ! * rectangle of the {@code Shape} in {@code double} * precision. * @return the X coordinate of the center of the framing rectangle ! * of the {@code Shape}. * @since 1.2 */ public double getCenterX() { return getX() + getWidth() / 2.0; } /** * Returns the Y coordinate of the center of the framing ! * rectangle of the {@code Shape} in {@code double} * precision. * @return the Y coordinate of the center of the framing rectangle ! * of the {@code Shape}. * @since 1.2 */ public double getCenterY() { return getY() + getHeight() / 2.0; } /** * Returns the framing {@link Rectangle2D} * that defines the overall shape of this object. ! * @return a {@code Rectangle2D}, specified in ! * {@code double} coordinates. * @see #setFrame(double, double, double, double) * @see #setFrame(Point2D, Dimension2D) * @see #setFrame(Rectangle2D) * @since 1.2 */
*** 176,197 **** public Rectangle2D getFrame() { return new Rectangle2D.Double(getX(), getY(), getWidth(), getHeight()); } /** ! * Determines whether the <code>RectangularShape</code> is empty. ! * When the <code>RectangularShape</code> is empty, it encloses no * area. ! * @return <code>true</code> if the <code>RectangularShape</code> is empty; ! * <code>false</code> otherwise. * @since 1.2 */ public abstract boolean isEmpty(); /** * Sets the location and size of the framing rectangle of this ! * <code>Shape</code> to the specified rectangular values. * * @param x the X coordinate of the upper-left corner of the * specified rectangular shape * @param y the Y coordinate of the upper-left corner of the * specified rectangular shape --- 176,197 ---- public Rectangle2D getFrame() { return new Rectangle2D.Double(getX(), getY(), getWidth(), getHeight()); } /** ! * Determines whether the {@code RectangularShape} is empty. ! * When the {@code RectangularShape} is empty, it encloses no * area. ! * @return {@code true} if the {@code RectangularShape} is empty; ! * {@code false} otherwise. * @since 1.2 */ public abstract boolean isEmpty(); /** * Sets the location and size of the framing rectangle of this ! * {@code Shape} to the specified rectangular values. * * @param x the X coordinate of the upper-left corner of the * specified rectangular shape * @param y the Y coordinate of the upper-left corner of the * specified rectangular shape
*** 202,241 **** */ public abstract void setFrame(double x, double y, double w, double h); /** * Sets the location and size of the framing rectangle of this ! * <code>Shape</code> to the specified {@link Point2D} and * {@link Dimension2D}, respectively. The framing rectangle is used ! * by the subclasses of <code>RectangularShape</code> to define * their geometry. ! * @param loc the specified <code>Point2D</code> ! * @param size the specified <code>Dimension2D</code> * @see #getFrame * @since 1.2 */ public void setFrame(Point2D loc, Dimension2D size) { setFrame(loc.getX(), loc.getY(), size.getWidth(), size.getHeight()); } /** ! * Sets the framing rectangle of this <code>Shape</code> to ! * be the specified <code>Rectangle2D</code>. The framing rectangle is ! * used by the subclasses of <code>RectangularShape</code> to define * their geometry. ! * @param r the specified <code>Rectangle2D</code> * @see #getFrame * @since 1.2 */ public void setFrame(Rectangle2D r) { setFrame(r.getX(), r.getY(), r.getWidth(), r.getHeight()); } /** ! * Sets the diagonal of the framing rectangle of this <code>Shape</code> * based on the two specified coordinates. The framing rectangle is ! * used by the subclasses of <code>RectangularShape</code> to define * their geometry. * * @param x1 the X coordinate of the start point of the specified diagonal * @param y1 the Y coordinate of the start point of the specified diagonal * @param x2 the X coordinate of the end point of the specified diagonal --- 202,241 ---- */ public abstract void setFrame(double x, double y, double w, double h); /** * Sets the location and size of the framing rectangle of this ! * {@code Shape} to the specified {@link Point2D} and * {@link Dimension2D}, respectively. The framing rectangle is used ! * by the subclasses of {@code RectangularShape} to define * their geometry. ! * @param loc the specified {@code Point2D} ! * @param size the specified {@code Dimension2D} * @see #getFrame * @since 1.2 */ public void setFrame(Point2D loc, Dimension2D size) { setFrame(loc.getX(), loc.getY(), size.getWidth(), size.getHeight()); } /** ! * Sets the framing rectangle of this {@code Shape} to ! * be the specified {@code Rectangle2D}. The framing rectangle is ! * used by the subclasses of {@code RectangularShape} to define * their geometry. ! * @param r the specified {@code Rectangle2D} * @see #getFrame * @since 1.2 */ public void setFrame(Rectangle2D r) { setFrame(r.getX(), r.getY(), r.getWidth(), r.getHeight()); } /** ! * Sets the diagonal of the framing rectangle of this {@code Shape} * based on the two specified coordinates. The framing rectangle is ! * used by the subclasses of {@code RectangularShape} to define * their geometry. * * @param x1 the X coordinate of the start point of the specified diagonal * @param y1 the Y coordinate of the start point of the specified diagonal * @param x2 the X coordinate of the end point of the specified diagonal
*** 256,283 **** } setFrame(x1, y1, x2 - x1, y2 - y1); } /** ! * Sets the diagonal of the framing rectangle of this <code>Shape</code> ! * based on two specified <code>Point2D</code> objects. The framing ! * rectangle is used by the subclasses of <code>RectangularShape</code> * to define their geometry. * ! * @param p1 the start <code>Point2D</code> of the specified diagonal ! * @param p2 the end <code>Point2D</code> of the specified diagonal * @since 1.2 */ public void setFrameFromDiagonal(Point2D p1, Point2D p2) { setFrameFromDiagonal(p1.getX(), p1.getY(), p2.getX(), p2.getY()); } /** ! * Sets the framing rectangle of this <code>Shape</code> * based on the specified center point coordinates and corner point * coordinates. The framing rectangle is used by the subclasses of ! * <code>RectangularShape</code> to define their geometry. * * @param centerX the X coordinate of the specified center point * @param centerY the Y coordinate of the specified center point * @param cornerX the X coordinate of the specified corner point * @param cornerY the Y coordinate of the specified corner point --- 256,283 ---- } setFrame(x1, y1, x2 - x1, y2 - y1); } /** ! * Sets the diagonal of the framing rectangle of this {@code Shape} ! * based on two specified {@code Point2D} objects. The framing ! * rectangle is used by the subclasses of {@code RectangularShape} * to define their geometry. * ! * @param p1 the start {@code Point2D} of the specified diagonal ! * @param p2 the end {@code Point2D} of the specified diagonal * @since 1.2 */ public void setFrameFromDiagonal(Point2D p1, Point2D p2) { setFrameFromDiagonal(p1.getX(), p1.getY(), p2.getX(), p2.getY()); } /** ! * Sets the framing rectangle of this {@code Shape} * based on the specified center point coordinates and corner point * coordinates. The framing rectangle is used by the subclasses of ! * {@code RectangularShape} to define their geometry. * * @param centerX the X coordinate of the specified center point * @param centerY the Y coordinate of the specified center point * @param cornerX the X coordinate of the specified corner point * @param cornerY the Y coordinate of the specified corner point
*** 289,304 **** double halfH = Math.abs(cornerY - centerY); setFrame(centerX - halfW, centerY - halfH, halfW * 2.0, halfH * 2.0); } /** ! * Sets the framing rectangle of this <code>Shape</code> based on a ! * specified center <code>Point2D</code> and corner ! * <code>Point2D</code>. The framing rectangle is used by the subclasses ! * of <code>RectangularShape</code> to define their geometry. ! * @param center the specified center <code>Point2D</code> ! * @param corner the specified corner <code>Point2D</code> * @since 1.2 */ public void setFrameFromCenter(Point2D center, Point2D corner) { setFrameFromCenter(center.getX(), center.getY(), corner.getX(), corner.getY()); --- 289,304 ---- double halfH = Math.abs(cornerY - centerY); setFrame(centerX - halfW, centerY - halfH, halfW * 2.0, halfH * 2.0); } /** ! * Sets the framing rectangle of this {@code Shape} based on a ! * specified center {@code Point2D} and corner ! * {@code Point2D}. The framing rectangle is used by the subclasses ! * of {@code RectangularShape} to define their geometry. ! * @param center the specified center {@code Point2D} ! * @param corner the specified corner {@code Point2D} * @since 1.2 */ public void setFrameFromCenter(Point2D center, Point2D corner) { setFrameFromCenter(center.getX(), center.getY(), corner.getX(), corner.getY());
*** 348,379 **** (int) (x2 - x1), (int) (y2 - y1)); } /** * Returns an iterator object that iterates along the ! * <code>Shape</code> object's boundary and provides access to a ! * flattened view of the outline of the <code>Shape</code> * object's geometry. * <p> * Only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE point types will * be returned by the iterator. * <p> * The amount of subdivision of the curved segments is controlled ! * by the <code>flatness</code> parameter, which specifies the * maximum distance that any point on the unflattened transformed * curve can deviate from the returned flattened path segments. * An optional {@link AffineTransform} can * be specified so that the coordinates returned in the iteration are * transformed accordingly. ! * @param at an optional <code>AffineTransform</code> to be applied to the * coordinates as they are returned in the iteration, ! * or <code>null</code> if untransformed coordinates are desired. * @param flatness the maximum distance that the line segments used to * approximate the curved segments are allowed to deviate * from any point on the original curve ! * @return a <code>PathIterator</code> object that provides access to ! * the <code>Shape</code> object's flattened geometry. * @since 1.2 */ public PathIterator getPathIterator(AffineTransform at, double flatness) { return new FlatteningPathIterator(getPathIterator(at), flatness); } --- 348,379 ---- (int) (x2 - x1), (int) (y2 - y1)); } /** * Returns an iterator object that iterates along the ! * {@code Shape} object's boundary and provides access to a ! * flattened view of the outline of the {@code Shape} * object's geometry. * <p> * Only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE point types will * be returned by the iterator. * <p> * The amount of subdivision of the curved segments is controlled ! * by the {@code flatness} parameter, which specifies the * maximum distance that any point on the unflattened transformed * curve can deviate from the returned flattened path segments. * An optional {@link AffineTransform} can * be specified so that the coordinates returned in the iteration are * transformed accordingly. ! * @param at an optional {@code AffineTransform} to be applied to the * coordinates as they are returned in the iteration, ! * or {@code null} if untransformed coordinates are desired. * @param flatness the maximum distance that the line segments used to * approximate the curved segments are allowed to deviate * from any point on the original curve ! * @return a {@code PathIterator} object that provides access to ! * the {@code Shape} object's flattened geometry. * @since 1.2 */ public PathIterator getPathIterator(AffineTransform at, double flatness) { return new FlatteningPathIterator(getPathIterator(at), flatness); }
< prev index next >