Package org.apache.pivot.wtk
Class Insets
- java.lang.Object
-
- org.apache.pivot.wtk.Insets
-
- All Implemented Interfaces:
java.io.Serializable
public final class Insets extends java.lang.Object implements java.io.SerializableClass representing the insets of an object, also called "padding" (or in some classes, "margin").- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description intbottomValue for the bottom inset (or below the object).static java.lang.StringBOTTOM_KEYMap key name for the "bottom" value.intleftValue for the left inset (or to the left of the object).static java.lang.StringLEFT_KEYMap key name for the "left" value.static InsetsNONEInsets whose top, left, bottom, and right values are all zero.intrightValue for the right inset (or to the right of the object).static java.lang.StringRIGHT_KEYMap key name for the "right" value.inttopValue for the top inset (or above the object).static java.lang.StringTOP_KEYMap key name for the "top" value.
-
Constructor Summary
Constructors Constructor Description Insets(int inset)Construct insets with all the same value.Insets(int height, int width)Construct anInsetsvalue given the total height and width values to produce.Insets(int topV, int leftV, int bottomV, int rightV)Construct with different values for each side.Insets(java.lang.Number inset)Construct insets with all the same integer value.Insets(Dictionary<java.lang.String,?> insets)Construct a new set of insets given a dictionary with the values to use.Insets(Sequence<?> insets)Construct a new set of insets given a sequence of values to use.Insets(Dimensions size)Construct anInsetsvalue given the total dimensions of the value to produce.Insets(Insets insets)Copy an insets structure to a new one with the same values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Insetsdecode(java.lang.String value)Decode a possible Insets value.booleanequals(java.lang.Object object)static InsetsfromObject(java.lang.Object source)Convert any of our supported object sources into aInsetsobject.static InsetsfromObject(java.lang.Object source, java.lang.String message)Convert any of our supported object sources into aInsetsobject.intgetHeight()DimensionsgetSize()Return the total size of this insets value as a singleDimensionsvalue.intgetWidth()inthashCode()java.lang.StringtoString()
-
-
-
Field Detail
-
top
public final int top
Value for the top inset (or above the object).
-
left
public final int left
Value for the left inset (or to the left of the object).
-
bottom
public final int bottom
Value for the bottom inset (or below the object).
-
right
public final int right
Value for the right inset (or to the right of the object).
-
TOP_KEY
public static final java.lang.String TOP_KEY
Map key name for the "top" value.- See Also:
- Constant Field Values
-
LEFT_KEY
public static final java.lang.String LEFT_KEY
Map key name for the "left" value.- See Also:
- Constant Field Values
-
BOTTOM_KEY
public static final java.lang.String BOTTOM_KEY
Map key name for the "bottom" value.- See Also:
- Constant Field Values
-
RIGHT_KEY
public static final java.lang.String RIGHT_KEY
Map key name for the "right" value.- See Also:
- Constant Field Values
-
NONE
public static final Insets NONE
Insets whose top, left, bottom, and right values are all zero.
-
-
Constructor Detail
-
Insets
public Insets(int inset)
Construct insets with all the same value.- Parameters:
inset- The pixel inset to use on all four sides.
-
Insets
public Insets(java.lang.Number inset)
Construct insets with all the same integer value.- Parameters:
inset- The pixel value for all the insets (truncated to an integer).
-
Insets
public Insets(int topV, int leftV, int bottomV, int rightV)Construct with different values for each side.- Parameters:
topV- The top inset value.leftV- The left inset value.bottomV- The bottom inset value.rightV- The right inset value.
-
Insets
public Insets(int height, int width)Construct anInsetsvalue given the total height and width values to produce.This will assign half the height to each of the top and bottom, and half the width each to the left and right.
Any excess (for odd values) will be assigned to the bottom and right respectively.
- Parameters:
height- The total height to assign to this Insets value.width- The total width to assign.- See Also:
getHeight(),getWidth()
-
Insets
public Insets(Dimensions size)
Construct anInsetsvalue given the total dimensions of the value to produce.This will assign half the dimensions height to each of the top and bottom, and half the dimensions width each to the left and right.
Any excess (for odd values) will be assigned to the right and bottom respectively.
- Parameters:
size- The total size (height and width) to assign.- See Also:
getSize()
-
Insets
public Insets(Insets insets)
Copy an insets structure to a new one with the same values.- Parameters:
insets- The existing insets to copy (must not be null).- Throws:
java.lang.IllegalArgumentException- if the input is null.
-
Insets
public Insets(Dictionary<java.lang.String,?> insets)
Construct a new set of insets given a dictionary with the values to use.- Parameters:
insets- The dictionary of values to use.- Throws:
java.lang.IllegalArgumentException- if the input is null.
-
Insets
public Insets(Sequence<?> insets)
Construct a new set of insets given a sequence of values to use.- Parameters:
insets- The sequence of values to use in the order of [top, left, bottom, right].- Throws:
java.lang.IllegalArgumentException- if the input is null.
-
-
Method Detail
-
getWidth
public int getWidth()
- Returns:
- The total width of this Insets (that is, the left + right values).
-
getHeight
public int getHeight()
- Returns:
- The total height of this Insets (that is, the top + bottom values).
-
getSize
public Dimensions getSize()
Return the total size of this insets value as a singleDimensionsvalue.- Returns:
- The total width and height of this object.
- See Also:
getWidth(),getHeight(),Insets(Dimensions)
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
fromObject
public static Insets fromObject(java.lang.Object source)
Convert any of our supported object sources into aInsetsobject.- Parameters:
source- Any supported object (Integer,Number,String, etc.).- Returns:
- The constructed
Insetsobject. - Throws:
java.lang.IllegalArgumentException- if the source ifnullor we can't figure out how to convert.
-
fromObject
public static Insets fromObject(java.lang.Object source, java.lang.String message)
Convert any of our supported object sources into aInsetsobject.- Parameters:
source- Any supported object (Integer,Number,String, etc.).message- Description of the setting we are converting (eg, "margin", "padding", etc.).- Returns:
- The constructed
Insetsobject. - Throws:
java.lang.IllegalArgumentException- if the source ifnullor we can't figure out how to convert.
-
decode
public static Insets decode(java.lang.String value)
Decode a possible Insets value. The value can be in one of the following forms:{ "top": nnn, "left": nnn, "bottom": nnn, "right": nnn }[ top, left, bottom, right ]
top[,;] left[,;] bottom[,;] right
- nnnn
- Parameters:
value- The string value of the Insets to decode.- Returns:
- The parsed
Insetsvalue. - Throws:
java.lang.IllegalArgumentException- if the input is not in one of these formats.- See Also:
Insets(Dictionary),Insets(Sequence),Insets(int, int, int, int),Insets(int)
-
-