public final class Boxes extends Object
| Modifier and Type | Method and Description |
|---|---|
static <S> BoxType<S> |
alignBottomLeft(BoxType<S> outer,
BoxType<S> inner)
Equivalent to calling
alignBottomLeftOffset(BoxType, BoxType, int,
int) with zero offsets. |
static <S> BoxType<S> |
alignBottomLeftOffset(BoxType<S> outer,
BoxType<S> inner,
int offset_left,
int offset_bottom)
Align the box
inner such that the bottom edge is at least offset_bottom from the inside bottom edge of outer and the left
edge is at least offset_left from the inside left edge of outer. |
static <S> BoxType<S> |
alignBottomRight(BoxType<S> outer,
BoxType<S> inner)
Equivalent to calling
alignBottomRightOffset(BoxType, BoxType, int,
int) with zero offsets. |
static <S> BoxType<S> |
alignBottomRightOffset(BoxType<S> outer,
BoxType<S> inner,
int offset_right,
int offset_bottom)
Align the box
inner such that the bottom edge is at least offset_bottom from the inside bottom edge of outer and the right
edge is at least offset_right from the inside right edge of outer. |
static <S> BoxType<S> |
alignCenter(BoxType<S> outer,
BoxType<S> inner)
Align the box
inner such that the center of the box is equal to the
center of outer. |
static <S> BoxType<S> |
alignHorizontallyCenter(BoxType<S> outer,
BoxType<S> inner)
Align the box
inner horizontally in the center of outer. |
static <S> BoxType<S> |
alignHorizontallyLeft(BoxType<S> outer,
BoxType<S> inner)
Equivalent to calling
alignHorizontallyLeftOffset(BoxType, BoxType,
int) with a zero offset. |
static <S> BoxType<S> |
alignHorizontallyLeftOffset(BoxType<S> outer,
BoxType<S> inner,
int offset)
Align the box
inner horizontally against the inside left edge of
outer. |
static <S> BoxType<S> |
alignHorizontallyRight(BoxType<S> outer,
BoxType<S> inner)
Equivalent to calling
alignHorizontallyRightOffset(BoxType,
BoxType, int) with a zero offset. |
static <S> BoxType<S> |
alignHorizontallyRightOffset(BoxType<S> outer,
BoxType<S> inner,
int offset)
Align the box
inner horizontally against the inside right edge of
outer. |
static <S> BoxType<S> |
alignTopLeft(BoxType<S> outer,
BoxType<S> inner)
Equivalent to calling
alignTopLeftOffset(BoxType, BoxType, int,
int) with zero offsets. |
static <S> BoxType<S> |
alignTopLeftOffset(BoxType<S> outer,
BoxType<S> inner,
int offset_left,
int offset_top)
Align the box
inner such that the top edge is at least offset_top from the inside top edge of outer and the left edge is
at least offset_left from the inside left edge of outer. |
static <S> BoxType<S> |
alignTopRight(BoxType<S> outer,
BoxType<S> inner)
Equivalent to calling
alignTopRightOffset(BoxType, BoxType, int,
int) with zero offsets. |
static <S> BoxType<S> |
alignTopRightOffset(BoxType<S> outer,
BoxType<S> inner,
int offset_right,
int offset_top)
Align the box
inner such that the top edge is at least offset_top from the inside top edge of outer and the right edge is
at least offset_right from the inside right edge of outer. |
static <S> BoxType<S> |
alignVerticallyBottom(BoxType<S> outer,
BoxType<S> inner)
Equivalent to calling
alignVerticallyBottomOffset(BoxType, BoxType,
int) with a zero offset. |
static <S> BoxType<S> |
alignVerticallyBottomOffset(BoxType<S> outer,
BoxType<S> inner,
int offset)
Align the box
inner vertically against the inside bottom edge of
outer. |
static <S> BoxType<S> |
alignVerticallyCenter(BoxType<S> outer,
BoxType<S> inner)
Align the box
inner vertically in the center of outer. |
static <S> BoxType<S> |
alignVerticallyTop(BoxType<S> outer,
BoxType<S> inner)
Equivalent to calling
alignVerticallyTopOffset(BoxType, BoxType,
int) with a zero offset. |
static <S> BoxType<S> |
alignVerticallyTopOffset(BoxType<S> outer,
BoxType<S> inner,
int offset)
Align the box
inner vertically against the inside top edge of
outer. |
static <S,T> BoxType<T> |
cast(BoxType<S> box)
Brand a given box as belonging to a different coordinate space.
|
static <S> BoxType<S> |
containing(BoxType<S> a,
BoxType<S> b)
Construct a box that will contain both
a and b. |
static <S> boolean |
contains(BoxType<S> a,
BoxType<S> b)
Determine whether or not one box contains another.
|
static <S> boolean |
containsPoint(BoxType<S> a,
int x,
int y)
Determine whether or not a box contains a given point.
|
static <S> boolean |
couldFitInside(BoxType<S> a,
BoxType<S> b)
Determine whether or not one box could fit inside another.
|
static <S> BoxType<S> |
create(int x,
int y,
int width,
int height)
Create a box of width
width and height height, placing the
top left corner at (x, y). |
static <S> BoxType<S> |
fitBetweenHorizontal(BoxType<S> fit,
BoxType<S> a,
BoxType<S> b)
Attempt to fit
fit between a and b, horizontally. |
static <S> BoxType<S> |
fitBetweenVertical(BoxType<S> fit,
BoxType<S> a,
BoxType<S> b)
Attempt to fit
fit between a and b, vertically. |
static <S> BoxType<S> |
hollowOut(BoxType<S> outer,
int left_offset,
int right_offset,
int top_offset,
int bottom_offset)
Construct a new box that fits inside
outer based on the given
offsets from each edge. |
static <S> BoxType<S> |
hollowOutEvenly(BoxType<S> outer,
int offset)
Equivalent to calling
hollowOut(BoxType, int, int, int, int) with
offset for all offset parameters. |
static <S> BoxType<S> |
moveAbsolute(BoxType<S> box,
int x,
int y)
Move the given box to
(x, y). |
static <S> BoxType<S> |
moveRelative(BoxType<S> box,
int x,
int y)
Move the given box by
(x, y). |
static <S> BoxType<S> |
moveToOrigin(BoxType<S> box)
Move the given box to
(0, 0). |
static <S> boolean |
overlaps(BoxType<S> a,
BoxType<S> b)
Determine whether or not two boxes overlap.
|
static <S> BoxType<S> |
scaleFromBottomLeft(BoxType<S> box,
int x_diff,
int y_diff)
Scale
box by adding x_diff to the width, and y_diff to the height. |
static <S> BoxType<S> |
scaleFromBottomRight(BoxType<S> box,
int x_diff,
int y_diff)
Scale
box by adding x_diff to the width, and y_diff to the height. |
static <S> BoxType<S> |
scaleFromCenter(BoxType<S> box,
int x_diff,
int y_diff)
Scale
box by adding x_diff to the width, and y_diff to the height. |
static <S> BoxType<S> |
scaleFromTopLeft(BoxType<S> box,
int x_diff,
int y_diff)
Scale
box by adding x_diff to the width, and y_diff to the height. |
static <S> BoxType<S> |
scaleFromTopRight(BoxType<S> box,
int x_diff,
int y_diff)
Scale
box by adding x_diff to the width, and y_diff to the height. |
static <S> BoxType<S> |
setSizeFromBottomLeft(BoxType<S> box,
int width,
int height)
Set the width and height of
box to width and height, respectively. |
static <S> BoxType<S> |
setSizeFromBottomRight(BoxType<S> box,
int width,
int height)
Set the width and height of
box to width and height, respectively. |
static <S> BoxType<S> |
setSizeFromCenter(BoxType<S> box,
int width,
int height)
Set the width and height of
box to width and height, respectively. |
static <S> BoxType<S> |
setSizeFromTopLeft(BoxType<S> box,
int width,
int height)
Set the width and height of
box to width and height, respectively. |
static <S> BoxType<S> |
setSizeFromTopRight(BoxType<S> box,
int width,
int height)
Set the width and height of
box to width and height, respectively. |
static <S> String |
show(BoxType<S> box) |
static <S> String |
showToBuilder(BoxType<S> box,
StringBuilder sb) |
static <S> BoxHorizontalSplitType<S> |
splitAlongHorizontal(BoxType<S> box,
int height)
Split
box along a horizontal line placed at height units
from its own top edge. |
static <S> BoxVerticalSplitType<S> |
splitAlongVertical(BoxType<S> box,
int width)
Split
box along a vertical line placed at width units from
its own left edge. |
public static <S,T> BoxType<T> cast(BoxType<S> box)
S - The starting coordinate spaceT - The resulting coordinate spacebox - A boxboxpublic static <S> BoxType<S> moveRelative(BoxType<S> box, int x, int y)
(x, y).S - The coordinate space of the boxbox - The boxx - The amount to move on the X axisy - The amount to move on the Y axispublic static <S> BoxType<S> moveAbsolute(BoxType<S> box, int x, int y)
(x, y).S - The coordinate space of the boxbox - The boxx - The position to which to move on the X axisy - The position to which to move on the Y axispublic static <S> BoxType<S> moveToOrigin(BoxType<S> box)
(0, 0).S - The coordinate space of the boxbox - The boxpublic static <S> BoxType<S> create(int x, int y, int width, int height)
width and height height, placing the
top left corner at (x, y).S - The coordinate space of the boxx - The X value of the top left cornery - The Y value of the bottom left cornerwidth - The width of the boxheight - The height of the boxpublic static <S> BoxType<S> alignHorizontallyCenter(BoxType<S> outer, BoxType<S> inner)
inner horizontally in the center of outer.S - The coordinate space of the boxesouter - The outer boxinner - The inner boxpublic static <S> BoxType<S> alignHorizontallyLeft(BoxType<S> outer, BoxType<S> inner)
alignHorizontallyLeftOffset(BoxType, BoxType,
int) with a zero offset.S - The coordinate space of the boxesouter - The outer boxinner - The inner boxpublic static <S> BoxType<S> alignHorizontallyLeftOffset(BoxType<S> outer, BoxType<S> inner, int offset)
inner horizontally against the inside left edge of
outer. The box will be at least offset units from the left
edge.S - The coordinate space of the boxesouter - The outer boxinner - The inner boxoffset - The offset from the edgepublic static <S> BoxType<S> alignHorizontallyRight(BoxType<S> outer, BoxType<S> inner)
alignHorizontallyRightOffset(BoxType,
BoxType, int) with a zero offset.S - The coordinate space of the boxesouter - The outer boxinner - The inner boxpublic static <S> BoxType<S> alignHorizontallyRightOffset(BoxType<S> outer, BoxType<S> inner, int offset)
inner horizontally against the inside right edge of
outer. The box will be at least offset units from the right
edge.S - The coordinate space of the boxesouter - The outer boxinner - The inner boxoffset - The offset from the edgepublic static <S> BoxType<S> alignVerticallyTop(BoxType<S> outer, BoxType<S> inner)
alignVerticallyTopOffset(BoxType, BoxType,
int) with a zero offset.S - The coordinate space of the boxesouter - The outer boxinner - The inner boxpublic static <S> BoxType<S> alignVerticallyTopOffset(BoxType<S> outer, BoxType<S> inner, int offset)
inner vertically against the inside top edge of
outer. The box will be at least offset units from the top
edge.S - The coordinate space of the boxesouter - The outer boxinner - The inner boxoffset - The offset from the edgepublic static <S> BoxType<S> alignVerticallyBottom(BoxType<S> outer, BoxType<S> inner)
alignVerticallyBottomOffset(BoxType, BoxType,
int) with a zero offset.S - The coordinate space of the boxesouter - The outer boxinner - The inner boxpublic static <S> BoxType<S> alignVerticallyBottomOffset(BoxType<S> outer, BoxType<S> inner, int offset)
inner vertically against the inside bottom edge of
outer. The box will be at least offset units from the
bottom edge.S - The coordinate space of the boxesouter - The outer boxinner - The inner boxoffset - The offset from the edgepublic static <S> BoxType<S> alignVerticallyCenter(BoxType<S> outer, BoxType<S> inner)
inner vertically in the center of outer.S - The coordinate space of the boxesouter - The outer boxinner - The inner boxpublic static <S> BoxType<S> alignTopLeft(BoxType<S> outer, BoxType<S> inner)
alignTopLeftOffset(BoxType, BoxType, int,
int) with zero offsets.S - The coordinate space of the boxesouter - The outer boxinner - The inner boxpublic static <S> BoxType<S> alignTopLeftOffset(BoxType<S> outer, BoxType<S> inner, int offset_left, int offset_top)
inner such that the top edge is at least offset_top from the inside top edge of outer and the left edge is
at least offset_left from the inside left edge of outer.S - The coordinate space of the boxesouter - The outer boxinner - The inner boxoffset_left - The offset from the left edgeoffset_top - The offset from the top edgepublic static <S> BoxType<S> alignTopRight(BoxType<S> outer, BoxType<S> inner)
alignTopRightOffset(BoxType, BoxType, int,
int) with zero offsets.S - The coordinate space of the boxesouter - The outer boxinner - The inner boxpublic static <S> BoxType<S> alignTopRightOffset(BoxType<S> outer, BoxType<S> inner, int offset_right, int offset_top)
inner such that the top edge is at least offset_top from the inside top edge of outer and the right edge is
at least offset_right from the inside right edge of outer.S - The coordinate space of the boxesouter - The outer boxinner - The inner boxoffset_right - The offset from the right edgeoffset_top - The offset from the top edgepublic static <S> BoxType<S> alignBottomLeft(BoxType<S> outer, BoxType<S> inner)
alignBottomLeftOffset(BoxType, BoxType, int,
int) with zero offsets.S - The coordinate space of the boxesouter - The outer boxinner - The inner boxpublic static <S> BoxType<S> alignBottomLeftOffset(BoxType<S> outer, BoxType<S> inner, int offset_left, int offset_bottom)
inner such that the bottom edge is at least offset_bottom from the inside bottom edge of outer and the left
edge is at least offset_left from the inside left edge of outer.S - The coordinate space of the boxesouter - The outer boxinner - The inner boxoffset_left - The offset from the left edgeoffset_bottom - The offset from the bottom edgepublic static <S> BoxType<S> alignBottomRight(BoxType<S> outer, BoxType<S> inner)
alignBottomRightOffset(BoxType, BoxType, int,
int) with zero offsets.S - The coordinate space of the boxesouter - The outer boxinner - The inner boxpublic static <S> BoxType<S> alignBottomRightOffset(BoxType<S> outer, BoxType<S> inner, int offset_right, int offset_bottom)
inner such that the bottom edge is at least offset_bottom from the inside bottom edge of outer and the right
edge is at least offset_right from the inside right edge of outer.S - The coordinate space of the boxesouter - The outer boxinner - The inner boxoffset_right - The offset from the right edgeoffset_bottom - The offset from the bottom edgepublic static <S> BoxType<S> alignCenter(BoxType<S> outer, BoxType<S> inner)
inner such that the center of the box is equal to the
center of outer.S - The coordinate space of the boxesouter - The outer boxinner - The inner boxpublic static <S> BoxType<S> hollowOut(BoxType<S> outer, int left_offset, int right_offset, int top_offset, int bottom_offset)
outer based on the given
offsets from each edge.S - The coordinate space of the boxesouter - The containing boxleft_offset - The offset from the left edge (must be non-negative)right_offset - The offset from the right edge (must be non-negative)top_offset - The offset from the top edge (must be non-negative)bottom_offset - The offset from the bottom edge (must be
non-negative)public static <S> BoxType<S> hollowOutEvenly(BoxType<S> outer, int offset)
hollowOut(BoxType, int, int, int, int) with
offset for all offset parameters.S - The coordinate space of the boxesouter - The containing boxoffset - The offset from each edge (must be non-negative)public static <S> BoxType<S> setSizeFromCenter(BoxType<S> box, int width, int height)
Set the width and height of box to width and height, respectively.
The box is resized from its own center.
S - The coordinate space of the boxbox - The boxwidth - The new width (must be non-negative)height - The new height (must be non-negative)public static <S> BoxType<S> setSizeFromTopLeft(BoxType<S> box, int width, int height)
Set the width and height of box to width and height, respectively.
The box is resized by moving its top-left corner.
S - The coordinate space of the boxbox - The boxwidth - The new width (must be non-negative)height - The new height (must be non-negative)public static <S> BoxType<S> setSizeFromTopRight(BoxType<S> box, int width, int height)
Set the width and height of box to width and height, respectively.
The box is resized by moving its top-right corner.
S - The coordinate space of the boxbox - The boxwidth - The new width (must be non-negative)height - The new height (must be non-negative)public static <S> BoxType<S> setSizeFromBottomRight(BoxType<S> box, int width, int height)
Set the width and height of box to width and height, respectively.
The box is resized by moving its bottom-right corner.
S - The coordinate space of the boxbox - The boxwidth - The new width (must be non-negative)height - The new height (must be non-negative)public static <S> BoxType<S> setSizeFromBottomLeft(BoxType<S> box, int width, int height)
Set the width and height of box to width and height, respectively.
The box is resized by moving its bottom-left corner.
S - The coordinate space of the boxbox - The boxwidth - The new width (must be non-negative)height - The new height (must be non-negative)public static <S> BoxType<S> scaleFromTopLeft(BoxType<S> box, int x_diff, int y_diff)
Scale box by adding x_diff to the width, and y_diff to the height. The size of the resulting box is clamped so that its
width and height are always non-negative.
The box is resized by moving its top-left corner.
S - The coordinate space of the boxbox - The boxx_diff - The X differencey_diff - The Y differencepublic static <S> BoxType<S> scaleFromTopRight(BoxType<S> box, int x_diff, int y_diff)
Scale box by adding x_diff to the width, and y_diff to the height. The size of the resulting box is clamped so that its
width and height are always non-negative.
The box is resized by moving its top-right corner.
S - The coordinate space of the boxbox - The boxx_diff - The X differencey_diff - The Y differencepublic static <S> BoxType<S> scaleFromBottomLeft(BoxType<S> box, int x_diff, int y_diff)
Scale box by adding x_diff to the width, and y_diff to the height. The size of the resulting box is clamped so that its
width and height are always non-negative.
The box is resized by moving its bottom-left corner.
S - The coordinate space of the boxbox - The boxx_diff - The X differencey_diff - The Y differencepublic static <S> BoxType<S> scaleFromBottomRight(BoxType<S> box, int x_diff, int y_diff)
Scale box by adding x_diff to the width, and y_diff to the height. The size of the resulting box is clamped so that its
width and height are always non-negative.
The box is resized by moving its bottom-right corner.
S - The coordinate space of the boxbox - The boxx_diff - The X differencey_diff - The Y differencepublic static <S> BoxType<S> scaleFromCenter(BoxType<S> box, int x_diff, int y_diff)
Scale box by adding x_diff to the width, and y_diff to the height. The size of the resulting box is clamped so that its
width and height are always non-negative.
The box is resized from its own center.
S - The coordinate space of the boxbox - The boxx_diff - The X differencey_diff - The Y differencepublic static <S> boolean overlaps(BoxType<S> a, BoxType<S> b)
Determine whether or not two boxes overlap.
Overlapping is reflexive: overlaps(a, a) == true.
Overlapping is symmetric: overlaps(a, b) == contains(b, a).
Overlapping is not necessarily transitive.
S - The coordinate space of the boxesa - A boxb - A boxtrue iff a overlaps bpublic static <S> boolean couldFitInside(BoxType<S> a, BoxType<S> b)
Determine whether or not one box could fit inside another.
Fitting is reflexive: couldFitInside(a, a) == true.
Fitting is transitive: couldFitInside(a, b) → couldFitInside(b,
c) → couldFitInside(a, c).
Fitting is not necessarily symmetric.
S - The coordinate space of the boxesa - A boxb - A boxtrue iff a could fit inside bpublic static <S> boolean contains(BoxType<S> a, BoxType<S> b)
Determine whether or not one box contains another.
Containing is reflexive: contains(a, a) == true.
Containing is transitive: contains(a, b) → contains(b, c) →
contains(a, c).
Containing is not necessarily symmetric.
S - The coordinate space of the boxesa - A boxb - A boxtrue iff a contains bpublic static <S> BoxType<S> containing(BoxType<S> a, BoxType<S> b)
a and b.S - The coordinate space of the boxesa - A boxb - A boxa and bpublic static <S> boolean containsPoint(BoxType<S> a, int x, int y)
Determine whether or not a box contains a given point.
S - The coordinate space of the boxa - A boxx - The X coordinate of the pointy - The Y coordinate of the pointtrue iff a contains (x, y)public static <S> BoxType<S> fitBetweenHorizontal(BoxType<S> fit, BoxType<S> a, BoxType<S> b)
fit between a and b, horizontally.S - The coordinate space of the boxesfit - The box to be fitteda - A boxb - A boxpublic static <S> BoxType<S> fitBetweenVertical(BoxType<S> fit, BoxType<S> a, BoxType<S> b)
fit between a and b, vertically.S - The coordinate space of the boxesfit - The box to be fitteda - A boxb - A boxpublic static <S> BoxHorizontalSplitType<S> splitAlongHorizontal(BoxType<S> box, int height)
box along a horizontal line placed at height units
from its own top edge.S - The coordinate space of the boxesbox - The box to be splitheight - The relative Y coordinate of the splitting edgepublic static <S> BoxVerticalSplitType<S> splitAlongVertical(BoxType<S> box, int width)
box along a vertical line placed at width units from
its own left edge.S - The coordinate space of the boxesbox - The box to be splitwidth - The relative X coordinate of the splitting edgepublic static <S> String show(BoxType<S> box)
S - The coordinate space of the boxbox - The boxpublic static <S> String showToBuilder(BoxType<S> box, StringBuilder sb)
S - The coordinate space of the boxbox - The boxsb - A string builderCopyright © 2016 <code@io7m.com> http://io7m.com