Package uk.ac.starlink.ttools.plot2
Class Padding
java.lang.Object
uk.ac.starlink.ttools.plot2.Padding
Defines user preferences for padding a rectangular area.
This resembles
Insets
, except that each member
may be null, to indicate that the user has no preference.
And it's immutable.- Since:
- 9 Dec 2016
- Author:
- Mark Taylor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns the required bottom margin.getLeft()
Returns the required left margin.getRight()
Returns the required right margin.getTop()
Returns the required top margin.int
hashCode()
boolean
Returns true if all the members of this padding object are non-null.overrideInsets
(Insets insets) Applies the requirements specified by this object to an existing Insets object.static Insets
Returns a non-null insets object based on a supplied Insets which will be modified by the state of a supplied Padding.Returns the insets object corresponding to this padding object if all the members are non-null, and null otherwise.
-
Constructor Details
-
Padding
public Padding()Constructs an empty padding object (no preferences). -
Padding
Constructs a padding object with preferences for all dimensions. Any of the arguments may be null.- Parameters:
top
- required top margin in pixels, or nullleft
- required left margin in pixels, or nullbottom
- required bottom margin in pixels, or nullright
- required right margin in pixels, or null
-
-
Method Details
-
getTop
Returns the required top margin.- Returns:
- top margin in pixels, or null for no preference
-
getLeft
Returns the required left margin.- Returns:
- left margin in pixels, or null for no preference
-
getBottom
Returns the required bottom margin.- Returns:
- bottom margin in pixels, or null for no preference
-
getRight
Returns the required right margin.- Returns:
- right margin in pixels, or null for no preference
-
overrideInsets
Applies the requirements specified by this object to an existing Insets object. The members of the returned insets object are those of this object where they are non-null, and those of the supplied insets otherwise.- Parameters:
insets
- input insets object, not null- Returns:
- new insets object with values taken from this padding where available
-
isDefinite
public boolean isDefinite()Returns true if all the members of this padding object are non-null.- Returns:
- true iff all margins have definite values
-
toDefiniteInsets
Returns the insets object corresponding to this padding object if all the members are non-null, and null otherwise.- Returns:
- insets if
isDefinite()
, otherwise null
-
hashCode
public int hashCode() -
equals
-
padInsets
Returns a non-null insets object based on a supplied Insets which will be modified by the state of a supplied Padding.This convenience method calls
overrideInsets(java.awt.Insets)
ifpadding
is non-null, otherwise it returns the inputinsets
.- Parameters:
padding
- padding to override insets value, may be nullinsets
- default insets, not null- Returns:
- effective insets
-