|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.miginfocom.util.gfx.geometry.AbsRect
public final class AbsRect
Rectangle that is in some way relative to another rectangle, called "reference". Ideal as a spec for a dockable rectangle that "docks" to another
rectangular shape. Since it can use relative coordinates (E.g. AtFraction
or AtStart
) as well as size
constraints the rectangle can be really flexible.
The coordinates (E.g. x1
) can even be filtered and thus constrained. All numbers (coordinates) that implements
AtRefRangeNumber
are decorateable (like a BufferedReader
can wrap a Reader
)
and any constraints or arithmetics can be applied to them.
Since the rectangle that this class describes is only relative to some reference bounds it doesn't normally have coordinates of it's own that makes sence.
The method getRect(java.awt.Rectangle, java.awt.Dimension)
or getRect(java.awt.Rectangle)
is/can be called with a reference rectangle and an
optional reference size to get the resulting rectangle that this class specifies.
For instance, with this class you can specify a rectangle to docked inside the referece bounds, with a size of 10% of it's height but no less than 20 pixels and no more than 40.
If possible use the static FILL
and FILL_INSIDE
.
Field Summary | |
---|---|
static AbsRect |
FILL
Rectangle that fills the bounds. |
static AbsRect |
FILL_INSIDE
Rectangle that fills the bounds but with a 1 pixel empty boundary. |
static AbsRect |
FILL_UPPER_LEFT
|
static AbsRect |
NULL
Rectangle that set upper left corner to 0, 0. |
Constructor Summary | |
---|---|
AbsRect(AtRefRangeNumber x1,
AtRefRangeNumber y1)
Constructor with no min/max sizes and keep width of source rectangle. |
|
AbsRect(AtRefRangeNumber x1,
AtRefRangeNumber y1,
AtRefRangeNumber x2,
AtRefRangeNumber y2)
Constructor with no min/max sizes. |
|
AbsRect(AtRefRangeNumber x1,
AtRefRangeNumber y1,
AtRefRangeNumber x2,
AtRefRangeNumber y2,
java.awt.Insets resize)
Constructor with no min/max sizes. |
|
AbsRect(AtRefRangeNumber x1,
AtRefRangeNumber y1,
AtRefRangeNumber x2,
AtRefRangeNumber y2,
SizeConstraint horConstr,
SizeConstraint verConstr,
java.awt.Insets resize)
Constructor. |
|
AbsRect(java.awt.Insets border)
Constructor that sizes to the bounds except for the insets. Short for: new AtStart(border.left), new AtStart(border.top), new AtEnd(-border.right), new AtEnd(-border.bottom)); |
|
AbsRect(int border)
Constructor that sizes to the bounds except for the inset all around. Short for: new AtStart(border), new AtStart(border), new AtEnd(-border), new AtEnd(-border)); |
|
AbsRect(int dockSide,
java.lang.Number size)
Constructor that will return a relative rectangle that is "docked" inside the reference rectangle. Min size will be 0 and max 100% of available. |
|
AbsRect(int dockSide,
java.lang.Number size,
SizeConstraint refRangeConstr)
Constructor that will return a relative rectangle that is "docked" inside the reference rectangle. |
Method Summary | |
---|---|
AbsRect |
derive(java.awt.Insets resize)
Creates a new relative rect by resizing this. |
boolean |
equals(java.lang.Object o)
|
SizeConstraint |
getHorizontalSizeConstraint()
|
java.awt.Rectangle |
getRect(java.awt.Rectangle r)
Returns a rectangle that might be translated, scaled and checked for max/min bounds. |
java.awt.Rectangle |
getRect(java.awt.Rectangle r,
java.awt.Dimension refSize)
Returns a rectangle that might be translated, scaled and checked for max/min bounds. |
java.awt.Insets |
getResize()
|
SizeConstraint |
getVerticalSizeConstraint()
|
AtRefRangeNumber |
getX1()
|
AtRefRangeNumber |
getX2()
|
AtRefRangeNumber |
getY1()
|
AtRefRangeNumber |
getY2()
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final AbsRect NULL
null
.
public static final AbsRect FILL
public static final AbsRect FILL_INSIDE
public static final AbsRect FILL_UPPER_LEFT
Constructor Detail |
---|
public AbsRect(int dockSide, java.lang.Number size)
dockSide
- What side to dock on. E.g. SwingConstants.TOP
. Not Center!size
- The size. If Integer
it's in pixels and if it's a Float
it's a percentage of the remaining size of the
container.public AbsRect(int dockSide, java.lang.Number size, SizeConstraint refRangeConstr)
dockSide
- What side to dock on. E.g. SwingConstants.TOP
. Not CENTER! To simulate center set to some
other dock side and set size to Float(1f)
. This way refRangeConstr
can still be used for one dimension.size
- The size. If Integer
it's in pixels and if it's a Float
it's a percentage of the remaining size of the
container.refRangeConstr
- The size constraint in the docked dimension. E.g. height for a top/bottom dock. If null
then SizeConstraint.SIZE_MIN_MAX_START
will be used for top/left and SizeConstraint.SIZE_MIN_MAX_END
for bottom/right docks.SizeConstraint
,
RefOperFilter
public AbsRect(int border)
new AtStart(border), new AtStart(border), new AtEnd(-border), new AtEnd(-border));
border
- How think the inset around should be.public AbsRect(java.awt.Insets border)
new AtStart(border.left), new AtStart(border.top), new AtEnd(-border.right), new AtEnd(-border.bottom));
border
- The insets. Not null
. Not that this is not same as the resize
insets at the other constructors.public AbsRect(AtRefRangeNumber x1, AtRefRangeNumber y1)
x1
- The first x coordinate. Can be null
.y1
- The first y coordinate. Can be null
.public AbsRect(AtRefRangeNumber x1, AtRefRangeNumber y1, AtRefRangeNumber x2, AtRefRangeNumber y2)
x1
- The first x coordinate. Can be null
.y1
- The first y coordinate. Can be null
.x2
- The second x coordinate/width. Can be null
.y2
- The second y coordinate/height. Can be null
.public AbsRect(AtRefRangeNumber x1, AtRefRangeNumber y1, AtRefRangeNumber x2, AtRefRangeNumber y2, java.awt.Insets resize)
x1
- The first x coordinate. Can be null
.y1
- The first y coordinate. Can be null
.x2
- The second x coordinate/width. Can be null
.y2
- The second y coordinate/height. Can be null
.resize
- If non-null
resizes the rectangle with an absolute number of pixels at the last stage.
Positive values enlarges the rectangle. Object is cloned for local storage.public AbsRect(AtRefRangeNumber x1, AtRefRangeNumber y1, AtRefRangeNumber x2, AtRefRangeNumber y2, SizeConstraint horConstr, SizeConstraint verConstr, java.awt.Insets resize)
x1
- The first x coordinate. Can be null
.y1
- The first y coordinate. Can be null
.x2
- The second x coordinate/width. Can be null
.y2
- The second y coordinate/height. Can be null
.horConstr
- The size and/or star/end position constraint in the horizontal dimension. No constraing if null
.verConstr
- The size and/or star/end position constraint in the vertical dimension. No constraing if null
.resize
- If non-null
resizes the rectangle with an absolute number of pixels at the last stage.
Positive values enlarges the rectangle. Object is cloned for local storage.Method Detail |
---|
public java.awt.Rectangle getRect(java.awt.Rectangle r)
PlaceRect
This method is normally just a transfer to PlaceRect.getRect(java.awt.Rectangle, java.awt.Dimension)
with
refSize
set ti null
.
getRect
in interface PlaceRect
r
- The rectangle that is to be used as the source. Not null
. Will not be changed.
null
.public java.awt.Rectangle getRect(java.awt.Rectangle r, java.awt.Dimension refSize)
PlaceRect
getRect
in interface PlaceRect
r
- The rectangle that is to be used as the source. Not null
. Will not be changed.refSize
- If x1, y1, x2 and/or y2
is null
(in this)
) the horizontal/vertical
size if taken from this dimension instead. If null
the size is taken from r
.null
.public AbsRect derive(java.awt.Insets resize)
resize
- The resize. May be null
. If both ins
and this.resize
are non-null
they
are combined (added).
public java.awt.Insets getResize()
public AtRefRangeNumber getX1()
public AtRefRangeNumber getY1()
public AtRefRangeNumber getX2()
public AtRefRangeNumber getY2()
public SizeConstraint getHorizontalSizeConstraint()
public SizeConstraint getVerticalSizeConstraint()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |