Package uk.ac.starlink.ttools.plot2
Class Padding
- java.lang.Object
-
- uk.ac.starlink.ttools.plot2.Padding
-
@Equality public class Padding extends java.lang.Object
Defines user preferences for padding a rectangular area. This resemblesInsets, 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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)java.lang.IntegergetBottom()Returns the required bottom margin.java.lang.IntegergetLeft()Returns the required left margin.java.lang.IntegergetRight()Returns the required right margin.java.lang.IntegergetTop()Returns the required top margin.inthashCode()booleanisDefinite()Returns true if all the members of this padding object are non-null.java.awt.InsetsoverrideInsets(java.awt.Insets insets)Applies the requirements specified by this object to an existing Insets object.java.awt.InsetstoDefiniteInsets()Returns the insets object corresponding to this padding object if all the members are non-null, and null otherwise.
-
-
-
Constructor Detail
-
Padding
public Padding()
Constructs an empty padding object (no preferences).
-
Padding
public Padding(java.lang.Integer top, java.lang.Integer left, java.lang.Integer bottom, java.lang.Integer right)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 Detail
-
getTop
public java.lang.Integer getTop()
Returns the required top margin.- Returns:
- top margin in pixels, or null for no preference
-
getLeft
public java.lang.Integer getLeft()
Returns the required left margin.- Returns:
- left margin in pixels, or null for no preference
-
getBottom
public java.lang.Integer getBottom()
Returns the required bottom margin.- Returns:
- bottom margin in pixels, or null for no preference
-
getRight
public java.lang.Integer getRight()
Returns the required right margin.- Returns:
- right margin in pixels, or null for no preference
-
overrideInsets
public java.awt.Insets overrideInsets(java.awt.Insets insets)
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- 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
public java.awt.Insets 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()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
-