T - specifies the type of the inheriting class in order to avoid
otherwise necessary type castsS - specifies the result type of all rotation short-cut methods (see
IRotatable)public abstract class AbstractRectangleBasedGeometry<T extends AbstractRectangleBasedGeometry<?,?>,S extends IGeometry> extends java.lang.Object implements ITranslatable<T>, IScalable<T>, IRotatable<S>
Abstract superclass of geometries that are defined by means of their upper left coordinate (x, y) and a given width and height.
The type parameter T specifies the type of the inheriting class.
This is to be able to return the correct type, so that a type cast is
unnecessary.
The type parameter S specifies the result type of all rotation
short-cut methods. See IRotatable for more information.
| Constructor and Description |
|---|
AbstractRectangleBasedGeometry(double x,
double y,
double width,
double height)
Constructs a new
AbstractRectangleBasedGeometry with the given
position and size. |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
clone()
Overridden with public visibility as recommended within
Cloneable
. |
T |
expand(double h,
double v)
Expands the horizontal and vertical sides of this
AbstractRectangleBasedGeometry with the values provided as input,
and returns this for convenience. |
T |
expand(double left,
double top,
double right,
double bottom)
Expands this
AbstractRectangleBasedGeometry by the given amounts,
and returns this for convenience. |
Rectangle |
getBounds()
|
Point |
getCenter()
Returns the center
Point of this
AbstractRectangleBasedGeometry. |
T |
getExpanded(double h,
double v)
Returns a new expanded
AbstractRectangleBasedGeometry, where the
sides are incremented by the horizontal and vertical values provided. |
T |
getExpanded(double left,
double top,
double right,
double bottom)
Creates and returns a new
AbstractRectangleBasedGeometry with the
bounds of this AbstractRectangleBasedGeometry expanded by the
given insets. |
double |
getHeight()
Returns the height of this
AbstractRectangleBasedGeometry. |
Point |
getLocation()
Returns a
Point specifying the x and y coordinates of this
AbstractRectangleBasedGeometry. |
T |
getScaled(double factor)
Scales a copy of the calling object by the given factor relative to its
center
Point. |
T |
getScaled(double factorX,
double factorY)
Scales a copy of the calling object by the given factors relative to its
center
Point. |
T |
getScaled(double factor,
double centerX,
double centerY)
Scales a copy of the calling object by the given factor relative to the
given center
Point (cx, cy). |
T |
getScaled(double factorX,
double factorY,
double centerX,
double centerY)
Scales a copy of the calling object by the given factors relative to the
given center
Point (cx, cy). |
T |
getScaled(double factorX,
double factorY,
Point center)
Scales a copy of the calling object by the given factors relative to the
given center
Point. |
T |
getScaled(double factor,
Point center)
Scales a copy of the calling object by the given factor relative to the
given center
Point. |
T |
getShrinked(double h,
double v)
Returns a new
AbstractRectangleBasedGeometry, where the sides are
shrinked by the horizontal and vertical values supplied. |
T |
getShrinked(double left,
double top,
double right,
double bottom)
Returns a new
AbstractRectangleBasedGeometry shrinked by the
specified insets. |
Dimension |
getSize()
Returns a
Dimension that records the width and height of this
AbstractRectangleBasedGeometry. |
IGeometry |
getTransformed(AffineTransform t)
|
T |
getTranslated(double dx,
double dy)
Translates a copy of this object by the given values in x and y
direction.
|
T |
getTranslated(Point pt)
Translates a copy of this object by the given
Point. |
double |
getWidth()
Returns the width of this
AbstractRectangleBasedGeometry. |
double |
getX()
Returns the x coordinate this
AbstractRectangleBasedGeometry. |
double |
getY()
Returns the y coordinate of this
AbstractRectangleBasedGeometry. |
int |
hashCode() |
T |
scale(double factor)
Scales the calling object by the given factor relative to its center
Point. |
T |
scale(double fx,
double fy)
Scales the calling object by the given factors relative to the given
center
Point. |
T |
scale(double factor,
double cx,
double cy)
Scales the calling object by the given factor relative to the given
center
Point (cx, cy). |
T |
scale(double fx,
double fy,
double cx,
double cy)
Scales the calling object by the given factors relative to the given
center
Point (cx, cy). |
T |
scale(double fx,
double fy,
Point center)
Scales the calling object by the given factors relative to the given
center
Point. |
T |
scale(double factor,
Point center)
Scales the calling object by the given factor relative to the given
center
Point. |
T |
setBounds(double x,
double y,
double w,
double h)
Sets the x, y, width, and height values of this
AbstractRectangleBasedGeometry to the given values. |
T |
setBounds(Point loc,
Dimension size)
Sets the x, y, width, and height values of this
AbstractRectangleBasedGeometry to the respective values specified
by the passed-in Point and the passed-in Dimension. |
T |
setBounds(Rectangle r)
Sets the x and y coordinates and the width and height of this
AbstractRectangleBasedGeometry to the respective values of the
given Rectangle. |
T |
setHeight(double height)
Sets the height of this
AbstractRectangleBasedGeometry to the
given value. |
T |
setLocation(double x,
double y)
Sets the x and y coordinates of this
AbstractRectangleBasedGeometry to the specified values. |
T |
setLocation(Point p)
Sets the x and y coordinates of this
AbstractRectangleBasedGeometry to the respective values of the
given Point. |
T |
setSize(Dimension d)
Sets the width and height of this
AbstractRectangleBasedGeometry
to the width and height of the given Dimension. |
T |
setSize(double w,
double h)
Sets the width and height of this
AbstractRectangleBasedGeometry
to the given values. |
T |
setWidth(double width)
Sets the width of this
AbstractRectangleBasedGeometry to the
passed-in value. |
T |
setX(double x)
Sets the x-coordinate of this
AbstractRectangleBasedGeometry to
the given value. |
T |
setY(double y)
Sets the y-coordinate of this
AbstractRectangleBasedGeometry to
the given value. |
T |
shrink(double h,
double v)
Shrinks the sides of this
AbstractRectangleBasedGeometry by the
horizontal and vertical values provided as input, and returns this
AbstractRectangleBasedGeometry for convenience. |
T |
shrink(double left,
double top,
double right,
double bottom)
Shrinks this
AbstractRectangleBasedGeometry by the specified
amounts. |
boolean |
touches(IGeometry g)
|
T |
translate(double dx,
double dy)
Translates the object by the given values in x and y direction.
|
T |
translate(Point p)
Translates the object by the given
Point. |
equals, finalize, getClass, notify, notifyAll, toString, wait, wait, waitgetRotatedCCW, getRotatedCCW, getRotatedCCW, getRotatedCW, getRotatedCW, getRotatedCWpublic AbstractRectangleBasedGeometry(double x,
double y,
double width,
double height)
AbstractRectangleBasedGeometry with the given
position and size. If the width or height is negative, will use
0 instead.x - The x-coordinate of this
AbstractRectangleBasedGeometryy - The y-coordinate of this
AbstractRectangleBasedGeometrywidth - the width of this AbstractRectangleBasedGeometryheight - the height of this AbstractRectangleBasedGeometrysetX(double),
setY(double),
setWidth(double),
setHeight(double)public T expand(double h, double v)
AbstractRectangleBasedGeometry with the values provided as input,
and returns this for convenience. The location of its center
is kept constant.h - the horizontal incrementv - the vertical incrementthis for conveniencepublic T expand(double left, double top, double right, double bottom)
AbstractRectangleBasedGeometry by the given amounts,
and returns this for convenience.left - the amount to expand the left sidetop - the amount to expand the top sideright - the amount to expand the right sidebottom - the amount to expand the bottom sidethis for conveniencepublic Point getCenter()
Point of this
AbstractRectangleBasedGeometry.Point of this
AbstractRectangleBasedGeometrypublic T getExpanded(double h, double v)
AbstractRectangleBasedGeometry, where the
sides are incremented by the horizontal and vertical values provided. The
center of the AbstractRectangleBasedGeometry is maintained
constant.h - The horizontal incrementv - The vertical incrementAbstractRectangleBasedGeometrypublic T getExpanded(double left, double top, double right, double bottom)
AbstractRectangleBasedGeometry with the
bounds of this AbstractRectangleBasedGeometry expanded by the
given insets.left - the amount to expand the left sidetop - the amount to expand the top sideright - the amount to expand the right sidebottom - the amount to expand the bottom sideAbstractRectangleBasedGeometrypublic final double getHeight()
AbstractRectangleBasedGeometry.AbstractRectangleBasedGeometrypublic Point getLocation()
Point specifying the x and y coordinates of this
AbstractRectangleBasedGeometry.Point representing the x and y coordinates of this
AbstractRectangleBasedGeometrypublic T getScaled(double factor)
IScalablePoint.getScaled in interface IScalable<T extends AbstractRectangleBasedGeometry<?,?>>factor - scale-factorpublic T getScaled(double factorX, double factorY)
IScalablePoint.getScaled in interface IScalable<T extends AbstractRectangleBasedGeometry<?,?>>factorX - x-scale-factorfactorY - y-scale-factorpublic T getScaled(double factor, double centerX, double centerY)
IScalablePoint (cx, cy).public T getScaled(double factorX, double factorY, double centerX, double centerY)
IScalablePoint (cx, cy).getScaled in interface IScalable<T extends AbstractRectangleBasedGeometry<?,?>>factorX - x-scale-factorfactorY - y-scale-factorcenterX - x-coordinate of the relative Point for the scalingcenterY - y-coordinate of the relative Point for the scalingpublic T getScaled(double factorX, double factorY, Point center)
IScalablePoint.getScaled in interface IScalable<T extends AbstractRectangleBasedGeometry<?,?>>factorX - x-scale-factorfactorY - y-scale-factorcenter - relative Point for the scalingpublic T getScaled(double factor, Point center)
IScalablePoint.getScaled in interface IScalable<T extends AbstractRectangleBasedGeometry<?,?>>factor - scale-factorcenter - relative Point for the scalingpublic T getShrinked(double h, double v)
AbstractRectangleBasedGeometry, where the sides are
shrinked by the horizontal and vertical values supplied. The center of
this AbstractRectangleBasedGeometry is kept constant.h - horizontal reduction amountv - vertical reduction amountAbstractRectangleBasedGeometrypublic T getShrinked(double left, double top, double right, double bottom)
AbstractRectangleBasedGeometry shrinked by the
specified insets.left - the amount to shrink the left sidetop - the amount to shrink the top sideright - the amount to shrink the right sidebottom - the amount to shrink the bottom sideAbstractRectangleBasedGeometrypublic final Dimension getSize()
Dimension that records the width and height of this
AbstractRectangleBasedGeometry.Dimension that records the width and height of this
AbstractRectangleBasedGeometrypublic T getTranslated(double dx, double dy)
ITranslatablegetTranslated in interface ITranslatable<T extends AbstractRectangleBasedGeometry<?,?>>dx - x-translationdy - y-translationpublic T getTranslated(Point pt)
ITranslatablePoint.getTranslated in interface ITranslatable<T extends AbstractRectangleBasedGeometry<?,?>>pt - translation Pointpublic final double getWidth()
AbstractRectangleBasedGeometry.AbstractRectangleBasedGeometrypublic final double getX()
AbstractRectangleBasedGeometry.AbstractRectangleBasedGeometrypublic final double getY()
AbstractRectangleBasedGeometry.AbstractRectangleBasedGeometrypublic T scale(double factor)
IScalablePoint.scale in interface IScalable<T extends AbstractRectangleBasedGeometry<?,?>>factor - scale-factorthis for conveniencepublic T scale(double fx, double fy)
IScalablePoint.scale in interface IScalable<T extends AbstractRectangleBasedGeometry<?,?>>fx - x-scale-factorfy - y-scale-factorthis for conveniencepublic T scale(double factor, double cx, double cy)
IScalablePoint (cx, cy).public T scale(double fx, double fy, double cx, double cy)
IScalablePoint (cx, cy).public T scale(double fx, double fy, Point center)
IScalablePoint.scale in interface IScalable<T extends AbstractRectangleBasedGeometry<?,?>>fx - x-scale-factorfy - y-scale-factorcenter - relative Point for the scalingthis for conveniencepublic T scale(double factor, Point center)
IScalablePoint.scale in interface IScalable<T extends AbstractRectangleBasedGeometry<?,?>>factor - scale-factorcenter - relative Point for the scalingthis for conveniencepublic final T setBounds(double x, double y, double w, double h)
AbstractRectangleBasedGeometry to the given values.x - the new x-coordinatey - the new y-coordinatew - the new widthh - the new heightthis for conveniencepublic final T setBounds(Point loc, Dimension size)
AbstractRectangleBasedGeometry to the respective values specified
by the passed-in Point and the passed-in Dimension.loc - the Point specifying the new x and y coordinates of
this AbstractRectangleBasedGeometrysize - the Dimension specifying the new width and height of
this AbstractRectangleBasedGeometrythis for conveniencepublic final T setBounds(Rectangle r)
AbstractRectangleBasedGeometry to the respective values of the
given Rectangle.r - the Rectangle specifying the new x, y, width, and
height values of this AbstractRectangleBasedGeometrythis for conveniencepublic final T setHeight(double height)
AbstractRectangleBasedGeometry to the
given value.height - the new heightthis for conveniencepublic final T setLocation(double x, double y)
AbstractRectangleBasedGeometry to the specified values.x - the new x coordinate of this
AbstractRectangleBasedGeometryy - the new y coordinate of this
AbstractRectangleBasedGeometrythis for conveniencepublic final T setLocation(Point p)
AbstractRectangleBasedGeometry to the respective values of the
given Point.p - the Point specifying the new x and y coordinates of
this AbstractRectangleBasedGeometrythis for conveniencepublic final T setSize(Dimension d)
AbstractRectangleBasedGeometry
to the width and height of the given Dimension.d - the Dimension specifying the new width and height of
this AbstractRectangleBasedGeometrythis for conveniencepublic final T setSize(double w, double h)
AbstractRectangleBasedGeometry
to the given values.w - the new width of this AbstractRectangleBasedGeometryh - the new height of this AbstractRectangleBasedGeometrythis for conveniencepublic final T setWidth(double width)
AbstractRectangleBasedGeometry to the
passed-in value.width - the new width of this AbstractRectangleBasedGeometrythis for conveniencepublic final T setX(double x)
AbstractRectangleBasedGeometry to
the given value.x - The new x-coordinate.this for convenience.public final T setY(double y)
AbstractRectangleBasedGeometry to
the given value.y - The new y-coordinate.this for convenience.public T shrink(double h, double v)
AbstractRectangleBasedGeometry by the
horizontal and vertical values provided as input, and returns this
AbstractRectangleBasedGeometry for convenience. The center of
this AbstractRectangleBasedGeometry is kept constant.h - horizontal reduction amountv - vertical reduction amountthis for conveniencepublic T shrink(double left, double top, double right, double bottom)
AbstractRectangleBasedGeometry by the specified
amounts.left - the amount to shrink the left sidetop - the amount to shrink the top sideright - the amount to shrink the right sidebottom - the amount to shrink the bottom sidethis for conveniencepublic T translate(double dx, double dy)
ITranslatabletranslate in interface ITranslatable<T extends AbstractRectangleBasedGeometry<?,?>>dx - x-translationdy - y-translationthis for conveniencepublic T translate(Point p)
ITranslatablePoint.translate in interface ITranslatable<T extends AbstractRectangleBasedGeometry<?,?>>p - translation Pointthis for conveniencepublic java.lang.Object clone()
Cloneable
.clone in class java.lang.Objectpublic IGeometry getTransformed(AffineTransform t)
Path
representation of this IGeometry. Subclasses may override this
method to return a more specific representation.getTransformed in interface IGeometryt - The AffineTransform to be appliedPath representation of this
IGeometrypublic final int hashCode()
hashCode in class java.lang.ObjectObject.hashCode()Copyright (c) 2014 itemis AG, and others. All rights reserved.