Package jme3utilities.math
Class RectSizeLimits
java.lang.Object
jme3utilities.math.RectSizeLimits
Limits on the size of a non-degenerate rectangle. Immutable.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRectSizeLimits(int minWidth, int minHeight, int maxWidth, int maxHeight) Instantiate a set of limits. -
Method Summary
Modifier and TypeMethodDescriptionintclampHeight(int height) Clamp the specified height to the limits.intclampWidth(int width) Clamp the specified width to the limits.booleanTest for exact equivalence with another Object.feedbackInRange(int width, int height) Explain why the specified size is invalid.inthashCode()Generate the hash code for these limits.booleanisInRange(int width, int height) Test the validity of the specified dimensions.toString()Represent these limits as a text string.
-
Field Details
-
maxHeight
public final int maxHeightmaximum height (≥minHeight) -
maxWidth
public final int maxWidthmaximum width (≥minWidth) -
minHeight
public final int minHeightminimum height (≤maxHeight) -
minWidth
public final int minWidthminimum width (≤maxWidth)
-
-
Constructor Details
-
RectSizeLimits
public RectSizeLimits(int minWidth, int minHeight, int maxWidth, int maxHeight) Instantiate a set of limits.- Parameters:
minWidth- the desired minimum width (>0, ≤maxWidth)minHeight- the desired minimum height (>0, ≤maxHeight)maxWidth- the desired maximum width (≥minWidth)maxHeight- the desired maximum height (≥minHeight)
-
-
Method Details
-
clampHeight
public int clampHeight(int height) Clamp the specified height to the limits.- Parameters:
height- the height to be clamped- Returns:
- the value between minHeight and maxHeight inclusive that is
closest to
height
-
clampWidth
public int clampWidth(int width) Clamp the specified width to the limits.- Parameters:
width- the width to be clamped- Returns:
- the value between minWidth and maxWidth inclusive that is closest
to
width
-
feedbackInRange
Explain why the specified size is invalid.- Parameters:
width- the width to testheight- the height to test- Returns:
- message text in English or "" if in range (not null)
-
isInRange
public boolean isInRange(int width, int height) Test the validity of the specified dimensions.This test is inclusive, so both (minWidth, minHeight) and (maxWidth, maxHeight) are considered valid.
- Parameters:
width- the width to testheight- the height to test- Returns:
- true if in range, otherwise false
-
equals
Test for exact equivalence with another Object. -
hashCode
public int hashCode()Generate the hash code for these limits. -
toString
Represent these limits as a text string.The format is: (minWidth, minHeight)-(maxWidth, maxHeight)
-