Constructor and Description |
---|
RelativeDimension(float widthRatio,
float heightRatio)
Creates a relative dimension with constraints.
|
Modifier and Type | Method and Description |
---|---|
void |
computeOptimalSize(Widget widget,
int availableWidth,
int availableHeight,
Size optimalSize)
Computes the optimal size of a widget.
|
boolean |
equals(java.lang.Object obj) |
void |
getAvailableSize(Widget widget,
int availableWidth,
int availableHeight,
Size availableSize)
Gets the available size for a widget.
|
float |
getHeightRatio()
Returns the height ratio.
|
float |
getWidthRatio()
Returns the width ratio.
|
int |
hashCode() |
void |
layOut(Widget widget,
Rectangle bounds)
Lays out a widget.
|
public RelativeDimension(float widthRatio, float heightRatio)
Widget.NO_CONSTRAINT
can be used to relax constraint on one dimension (width or height).
The given width ratio and height ratio are clamped between 0.0f
and 1.0f
.
widthRatio
- the width ratio.heightRatio
- the height ratio.public float getWidthRatio()
Widget.NO_CONSTRAINT
if there is no width constraint.public float getHeightRatio()
Widget.NO_CONSTRAINT
if there is no height constraint.public void getAvailableSize(Widget widget, int availableWidth, int availableHeight, Size availableSize)
Dimension
The given available size is the available width and height minus the outlines.
The given size is updated by this method to set the available size for this dimension.
getAvailableSize
in interface Dimension
widget
- the widget.availableWidth
- the available width.availableHeight
- the available height.availableSize
- the available size.public void computeOptimalSize(Widget widget, int availableWidth, int availableHeight, Size optimalSize)
Dimension
The given optimal size is the optimal size of the widget considering the available size.
The given size is updated by this method to set the optimal size for this dimension.
computeOptimalSize
in interface Dimension
widget
- the widget.availableWidth
- the available width.availableHeight
- the available height.optimalSize
- the optimal size.public void layOut(Widget widget, Rectangle bounds)
Dimension
The style of the widget must be set before (not null
).
This dimension is applied to compute the widget bounds and align the widget in the given bounds. The given rectangle is updated with the updated bounds.
public boolean equals(@Nullable java.lang.Object obj)