Package swingtree.layout
Class Size
java.lang.Object
swingtree.layout.Size
An immutable value object that represents a size
in the form of a width and height or lack thereof.
This is used to represent the size of icons
as part of
IconDeclaration
s
and the SwingTree style API, see UIForAnySwing.withStyle(Styler)
,
ComponentStyleDelegate.image(swingtree.api.Configurator)
and
ImageConf.size(int, int)
.-
Method Summary
Modifier and TypeMethodDescriptionboolean
int
hashCode()
boolean
boolean
height()
The height of thisSize
instance may not be specified, in which case this method returnsOptional.empty()
and the thing that this configuration is applied to should resort to its default height.static Size
of
(float width, float height) A factory method that creates aSize
instance from a width and height.static Size
scale
(double scaleFactor) toString()
static Size
unknown()
Exposes theUNKNOWN
size instance, which is a null object that represents an unknown size.width()
The width of thisSize
instance may not be specified, in which case this method returnsOptional.empty()
and the thing that this configuration is applied to should resort to its default width.withHeight
(int height) Creates an updatedSize
instance with the given height.withWidth
(int width) Creates an updatedSize
instance with the given width.
-
Method Details
-
unknown
Exposes theUNKNOWN
size instance, which is a null object that represents an unknown size. It uses -1 for both width and height and will returnOptional.empty()
for both width and height.- Returns:
- A
Size
instance that represents an unknown size.
-
of
A factory method that creates aSize
instance from a width and height. If the width or height is negative, the returned size will have be theUNKNOWN
size with a width or height of -1.- Parameters:
width
- The width of the size.height
- The height of the size.- Returns:
- A
Size
instance that represents the given width and height.
-
of
-
width
The width of thisSize
instance may not be specified, in which case this method returnsOptional.empty()
and the thing that this configuration is applied to should resort to its default width.- Returns:
- The width of this
Size
instance orOptional.empty()
if unknown.
-
height
The height of thisSize
instance may not be specified, in which case this method returnsOptional.empty()
and the thing that this configuration is applied to should resort to its default height.- Returns:
- The height of this
Size
instance orOptional.empty()
if unknown.
-
hasPositiveWidth
public boolean hasPositiveWidth() -
hasPositiveHeight
public boolean hasPositiveHeight() -
withWidth
Creates an updatedSize
instance with the given width. If the width is negative, the width of the returned size will be -1.- Parameters:
width
- The width of the size to create.- Returns:
- A new
Size
instance with the given width.
-
withHeight
Creates an updatedSize
instance with the given height. If the height is negative, the height of the returned size will be -1.- Parameters:
height
- The height of the size to create.- Returns:
- A new
Size
instance with the given height.
-
toDimension
-
scale
-
toString
-
equals
-
hashCode
public int hashCode()
-