Module io.github.mmm.ui.api.window
Package io.github.mmm.ui.spi.window
Class UiWindowPositionAndSize
- java.lang.Object
-
- io.github.mmm.ui.spi.window.UiWindowPositionAndSize
-
- All Implemented Interfaces:
AttributeReadPosition
,AttributeReadSize
,AttributeWritePosition
,AttributeWritePositionRange
,AttributeWriteSize
,AttributeWriteSizeInPixel
,AttributeWriteSizeRange
- Direct Known Subclasses:
FxAbstractWindowPositionAndSize
,TestAbstractWindowPositionAndSize
public abstract class UiWindowPositionAndSize extends Object implements AttributeWritePositionRange, AttributeWriteSizeRange
Abstract base implementation for position, size and controls related attributes ofUiAbstractWindow
orUiChildWindow
.- Since:
- 1.0.0
-
-
Field Summary
Fields Modifier and Type Field Description protected double
height
protected double
maxHeight
protected double
maxWidth
protected double
maxX
protected double
maxY
protected double
minHeight
protected double
minWidth
protected double
minX
protected double
minY
protected double
width
protected double
x
protected double
y
-
Constructor Summary
Constructors Constructor Description UiWindowPositionAndSize()
The constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
centerOnScreen(boolean force)
Initializes the position and size.protected static double
clipMax(double max)
protected static double
clipSize(double size)
protected static double
clipZero(double pos)
double
getHeightInPixel()
double
getMaxHeight()
double
getMaxWidth()
double
getMaxX()
double
getMaxY()
double
getMinHeight()
double
getMinWidth()
double
getMinX()
double
getMinY()
protected abstract double
getScreenHeight()
protected abstract double
getScreenWidth()
double
getWidthInPixel()
double
getX()
double
getY()
void
setHeight(UiSize height)
void
setHeightInPixel(double height)
void
setMaxHeight(double maxHeight)
void
setMaxWidth(double maxWidth)
void
setMaxX(double maxX)
void
setMaxY(double maxY)
void
setMinHeight(double minHeight)
void
setMinWidth(double minWidth)
void
setMinX(double minX)
void
setMinY(double minY)
void
setPosition(double x, double y)
This method sets the position of the widget.void
setSize(UiSize width, UiSize height)
void
setSizeInPixel(double width, double height)
void
setWidth(UiSize width)
void
setWidthInPixel(double width)
void
setX(double x)
void
setY(double y)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.github.mmm.ui.api.attribute.AttributeReadSize
getHeight, getWidth
-
Methods inherited from interface io.github.mmm.ui.api.attribute.AttributeWritePositionRange
setXRange, setYRange
-
Methods inherited from interface io.github.mmm.ui.api.attribute.AttributeWriteSize
setSize
-
Methods inherited from interface io.github.mmm.ui.api.attribute.AttributeWriteSizeRange
setHeightRange, setWidthRange
-
-
-
-
Field Detail
-
x
protected double x
- See Also:
getX()
-
y
protected double y
- See Also:
getY()
-
minX
protected double minX
- See Also:
getMinX()
-
minY
protected double minY
- See Also:
getMinY()
-
maxX
protected double maxX
- See Also:
getMaxX()
-
maxY
protected double maxY
- See Also:
getMaxY()
-
width
protected double width
- See Also:
AttributeReadSize.getWidth()
-
height
protected double height
- See Also:
AttributeReadSize.getHeight()
-
minWidth
protected double minWidth
- See Also:
getMinWidth()
-
minHeight
protected double minHeight
- See Also:
getMinHeight()
-
maxWidth
protected double maxWidth
- See Also:
getMaxWidth()
-
maxHeight
protected double maxHeight
- See Also:
getMaxHeight()
-
-
Method Detail
-
getWidthInPixel
public double getWidthInPixel()
- Specified by:
getWidthInPixel
in interfaceAttributeReadSize
- Returns:
- the width of this object in pixels.
NOTE: The result will typically be anint
value. However, to be compatible withUiSize.getAmount()
and with some underlying native toolkits we usedouble
. You may cast the result toint
.
-
setWidthInPixel
public void setWidthInPixel(double width)
- Specified by:
setWidthInPixel
in interfaceAttributeWriteSize
- Specified by:
setWidthInPixel
in interfaceAttributeWriteSizeInPixel
- Parameters:
width
- the newwidth in pixel
.
-
setWidth
public void setWidth(UiSize width)
- Specified by:
setWidth
in interfaceAttributeWriteSize
- Parameters:
width
- the newwidth
.
-
getHeightInPixel
public double getHeightInPixel()
- Specified by:
getHeightInPixel
in interfaceAttributeReadSize
- Returns:
- the height of this object in pixels.
NOTE: The result will typically be anint
value. However, to be compatible withUiSize.getAmount()
and with some underlying native toolkits we usedouble
. You may cast the result toint
.
-
setHeightInPixel
public void setHeightInPixel(double height)
- Specified by:
setHeightInPixel
in interfaceAttributeWriteSize
- Specified by:
setHeightInPixel
in interfaceAttributeWriteSizeInPixel
- Parameters:
height
- the newheight in pixel
.
-
setHeight
public void setHeight(UiSize height)
- Specified by:
setHeight
in interfaceAttributeWriteSize
- Parameters:
height
- the newheight
.
-
setSizeInPixel
public void setSizeInPixel(double width, double height)
- Specified by:
setSizeInPixel
in interfaceAttributeWriteSize
- Specified by:
setSizeInPixel
in interfaceAttributeWriteSizeInPixel
- Parameters:
width
- the newwidth in pixel
.height
- the newheight in pixel
.
-
setSize
public void setSize(UiSize width, UiSize height)
- Specified by:
setSize
in interfaceAttributeWriteSize
- Parameters:
width
- the newwidth
.height
- the newheight
.
-
getMinWidth
public double getMinWidth()
- Specified by:
getMinWidth
in interfaceAttributeWriteSizeRange
- Returns:
- the minimum allowed value of
width in pixel
. Will be200
by default. Should be less or equal tomaxWidth
.
-
setMinWidth
public void setMinWidth(double minWidth)
- Specified by:
setMinWidth
in interfaceAttributeWriteSizeRange
- Parameters:
minWidth
- the new value ofminWidth
. Will not affect currentwidth
but only apply to resizing by the end-user.
-
getMaxWidth
public double getMaxWidth()
- Specified by:
getMaxWidth
in interfaceAttributeWriteSizeRange
- Returns:
- the maximum allowed value of
width in pixel
. Will beInteger.MAX_VALUE
by default (unbounded) and is automatically clipped to the available width (of theUiScreen
or main window). Should be greater or equal tominWidth
.
-
setMaxWidth
public void setMaxWidth(double maxWidth)
- Specified by:
setMaxWidth
in interfaceAttributeWriteSizeRange
- Parameters:
maxWidth
- the new value ofmaxWidth
. Will not affect currentwidth
but only apply to resizing by the end-user.
-
getMinHeight
public double getMinHeight()
- Specified by:
getMinHeight
in interfaceAttributeWriteSizeRange
- Returns:
- the minimum allowed value of
height in pixel
. Will be200
by default. Should be less or equal tomaxHeight
.
-
setMinHeight
public void setMinHeight(double minHeight)
- Specified by:
setMinHeight
in interfaceAttributeWriteSizeRange
- Parameters:
minHeight
- the new value ofminHeight
. Will not affect currentheight
but only apply to resizing by the end-user.
-
getMaxHeight
public double getMaxHeight()
- Specified by:
getMaxHeight
in interfaceAttributeWriteSizeRange
- Returns:
- the maximum allowed value of
height in pixel
. Will beInteger.MAX_VALUE
by default (unbounded) and is automatically clipped to the available height (of theUiScreen
or main window). Should be greater or equal tominHeight
.
-
setMaxHeight
public void setMaxHeight(double maxHeight)
- Specified by:
setMaxHeight
in interfaceAttributeWriteSizeRange
- Parameters:
maxHeight
- the new value ofmaxHeight
. Will not affect currentheight
but only apply to resizing by the end-user.
-
getX
public double getX()
- Specified by:
getX
in interfaceAttributeReadPosition
- Returns:
- the x position of this object as the number of pixels from the left on the x-axis (horizontally).
-
setX
public void setX(double x)
- Specified by:
setX
in interfaceAttributeWritePosition
- Parameters:
x
- the newposition on the x-axis
.
-
getY
public double getY()
- Specified by:
getY
in interfaceAttributeReadPosition
- Returns:
- the y position of this object as the number of pixels from the top on the y-axis (vertically).
-
setY
public void setY(double y)
- Specified by:
setY
in interfaceAttributeWritePosition
- Parameters:
y
- the newposition on the y-axis
.
-
setPosition
public void setPosition(double x, double y)
Description copied from interface:AttributeWritePosition
This method sets the position of the widget.- Specified by:
setPosition
in interfaceAttributeWritePosition
- Parameters:
x
- the newposition on the x-axis
.y
- the newposition on the y-axis
.
-
getMinX
public double getMinX()
- Specified by:
getMinX
in interfaceAttributeWritePositionRange
- Returns:
- the minimum allowed value of
X
. Will be0
by default (unbounded). Should be less or equal tomaxX
.
-
setMinX
public void setMinX(double minX)
- Specified by:
setMinX
in interfaceAttributeWritePositionRange
- Parameters:
minX
- the new value ofminX
. Will not affect currentX
coordinate but only apply to moving and resizing by the end-user.
-
getMaxX
public double getMaxX()
- Specified by:
getMaxX
in interfaceAttributeWritePositionRange
- Returns:
- the maximum allowed value of
X
. Will beInteger.MAX_VALUE
by default (unbounded) and is automatically clipped to the available width (of theUiScreen
or main window). Should be greater or equal tominX
.
-
setMaxX
public void setMaxX(double maxX)
- Specified by:
setMaxX
in interfaceAttributeWritePositionRange
- Parameters:
maxX
- the new value ofmaxX
. Will not affect currentX
coordinate but only apply to moving and resizing by the end-user.
-
getMinY
public double getMinY()
- Specified by:
getMinY
in interfaceAttributeWritePositionRange
- Returns:
- the minimum allowed value of
Y
. Will be0
by default (unbounded). Should be less or equal tomaxY
.
-
setMinY
public void setMinY(double minY)
- Specified by:
setMinY
in interfaceAttributeWritePositionRange
- Parameters:
minY
- the new value ofminY
. Will not affect currentY
coordinate but only apply to moving and resizing by the end-user.
-
getMaxY
public double getMaxY()
- Specified by:
getMaxY
in interfaceAttributeWritePositionRange
- Returns:
- the maximum allowed value of
Y
. Will beInteger.MAX_VALUE
by default (unbounded) and is automatically clipped to the available width (of theUiScreen
or main window). Should be greater or equal tominY
.
-
setMaxY
public void setMaxY(double maxY)
- Specified by:
setMaxY
in interfaceAttributeWritePositionRange
- Parameters:
maxY
- the new value ofmaxY
. Will not affect currentY
coordinate but only apply to moving and resizing by the end-user.
-
getScreenWidth
protected abstract double getScreenWidth()
- Returns:
- the current width of the screen available for child windows.
-
getScreenHeight
protected abstract double getScreenHeight()
- Returns:
- the current height of the screen available for child windows.
-
centerOnScreen
public void centerOnScreen(boolean force)
Initializes the position and size. If neither of those is set, size will be set to a quarter of the screen (half of screen width and height) and window is centered on the screen.
-
clipSize
protected static double clipSize(double size)
- Parameters:
size
- the width or height to clip.- Returns:
- the maximum of the given
size
and100
.
-
clipZero
protected static double clipZero(double pos)
- Parameters:
pos
- the position value.- Returns:
- the maximum of the given
pos
and0
.
-
clipMax
protected static double clipMax(double max)
- Parameters:
max
- the maximum value.- Returns:
- the given
max
clipped to the range from0
toInteger.MAX_VALUE
.
-
-