Package ej.mwt.style.dimension
Class RelativeDimension
- java.lang.Object
-
- ej.mwt.style.dimension.RelativeDimension
-
-
Constructor Summary
Constructors Constructor Description RelativeDimension(float widthRatio, float heightRatio)Creates a relative dimension with constraints.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcomputeOptimalSize(Widget widget, int availableWidth, int availableHeight, Size optimalSize)Computes the optimal size of a widget.booleanequals(java.lang.Object obj)voidgetAvailableSize(Widget widget, int availableWidth, int availableHeight, Size availableSize)Gets the available size for a widget.floatgetHeightRatio()Returns the height ratio.floatgetWidthRatio()Returns the width ratio.inthashCode()voidlayOut(Widget widget, Rectangle bounds)Lays out a widget.
-
-
-
Constructor Detail
-
RelativeDimension
public RelativeDimension(float widthRatio, float heightRatio)Creates a relative dimension with constraints.Widget.NO_CONSTRAINTcan be used to relax constraint on one dimension (width or height).The given width ratio and height ratio are clamped between
0.0fand1.0f.- Parameters:
widthRatio- the width ratio.heightRatio- the height ratio.
-
-
Method Detail
-
getWidthRatio
public float getWidthRatio()
Returns the width ratio.- Returns:
- the width ratio, or
Widget.NO_CONSTRAINTif there is no width constraint.
-
getHeightRatio
public float getHeightRatio()
Returns the height ratio.- Returns:
- the height ratio, or
Widget.NO_CONSTRAINTif there is no height constraint.
-
getAvailableSize
public void getAvailableSize(Widget widget, int availableWidth, int availableHeight, Size availableSize)
Description copied from interface:DimensionGets the available size for a widget.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.
- Specified by:
getAvailableSizein interfaceDimension- Parameters:
widget- the widget.availableWidth- the available width.availableHeight- the available height.availableSize- the available size.
-
computeOptimalSize
public void computeOptimalSize(Widget widget, int availableWidth, int availableHeight, Size optimalSize)
Description copied from interface:DimensionComputes the optimal size of a widget.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.
- Specified by:
computeOptimalSizein interfaceDimension- Parameters:
widget- the widget.availableWidth- the available width.availableHeight- the available height.optimalSize- the optimal size.
-
layOut
public void layOut(Widget widget, Rectangle bounds)
Description copied from interface:DimensionLays out a widget.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.
-
equals
public boolean equals(@Nullable java.lang.Object obj)
-
-