Class BaseElement
- java.lang.Object
-
- be.yildizgames.common.util.BaseRegisterable
-
- be.yildizgames.module.graphic.gui.internal.BaseElement
-
- All Implemented Interfaces:
be.yildizgames.common.util.Registerable,Element
- Direct Known Subclasses:
AbstractIconElement,AbstractTextElement,BaseWidget
public abstract class BaseElement extends be.yildizgames.common.util.BaseRegisterable implements Element
Base for GUI elements.- Author:
- Grégory Van Den Borre
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface be.yildizgames.module.graphic.gui.internal.Element
Element.Alignment
-
-
Field Summary
Fields Modifier and Type Field Description static intMAX_OPACITYValue for maximum opacity.protected intvirtualHeight
-
Constructor Summary
Constructors Modifier Constructor Description protectedBaseElement(String name, be.yildizgames.module.coordinate.BaseCoordinate coordinates)Full constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddToLeft(int value)Move the element left or right by adding a value to its current x value.voidaddToPosition(int xValue, int yValue)Move the widget.voidaddToTop(int value)Move the element up or down by adding a value to its current y value.abstract voiddelete()Delete the widget.intgetBottom()be.yildizgames.module.coordinate.BaseCoordinategetCoordinates()intgetHeight()intgetLeft()intgetOpacity()intgetRight()intgetTop()intgetWidth()Elementhide()Set the element invisible on screen.protected abstract voidhideImpl()Implementation to set the widget invisible.booleanisVisible()voidmultiplySize(float factor)Multiply the size of the element.voidresetVirtualHeight()voidsetCoordinates(be.yildizgames.module.coordinate.BaseCoordinate coordinates)Set the position and size coordinates.voidsetHeight(int value)Set the widget height.ElementsetLeft(int leftValue)Set the element left position.BaseElementsetLeft(Element other, PositionRelativeLeft relative)Set the element left position relative to an other widget.BaseElementsetLeft(Element other, PositionRelativeLeft relative, int diff)Set the element left position relative to an other element with a position difference.BaseElementsetLeft(Element other, PositionRelativeLeft left, be.yildizgames.module.coordinate.Relative relativeDiff)Set the element left position relative to an other element with a position difference relative to the width of the parent.ElementsetPosition(int leftPosition, int topPosition)Set the left and top element position.BaseElementsetPosition(Element other)Set at the same position as the other element.protected abstract ElementsetPositionImpl(int newLeft, int newTop)Implementation to update the widget position.voidsetSize(int newWidth, int newHeight)Update the widget size.voidsetSize(be.yildizgames.module.coordinate.Size size)Update the widget size.protected abstract voidsetSizeImpl(int newWidth, int newHeight)Implementation to set the widget size.ElementsetTop(int topValue)Set the element top position.BaseElementsetTop(Element other, PositionRelativeTop relative)Set the element top position relative to an other widget.BaseElementsetTop(Element other, PositionRelativeTop relative, int diff)Set the element top position relative to an other element with a position difference.BaseElementsetTop(Element other, PositionRelativeTop top, be.yildizgames.module.coordinate.Relative relativeDiff)Set the element top position relative to an other element with a position difference relative to the height of the parent.voidsetVirtualHeight(int height)ElementsetVisible(boolean visible)Show or hide the element.voidsetWidth(int value)Set the widget width.Elementshow()Set the element visible on screen.protected abstract voidshowImpl()Implementation to set the widget visible.voidupdateAddPositionValue(int left, int top)Update position value without updating the widget.-
Methods inherited from class be.yildizgames.common.util.BaseRegisterable
equals, getName, hashCode, toString
-
-
-
-
Field Detail
-
MAX_OPACITY
public static final int MAX_OPACITY
Value for maximum opacity.- See Also:
- Constant Field Values
-
virtualHeight
protected int virtualHeight
-
-
Constructor Detail
-
BaseElement
protected BaseElement(String name, be.yildizgames.module.coordinate.BaseCoordinate coordinates)
Full constructor.- Parameters:
name- Element name, must be unique.coordinates- Element size and position.
-
-
Method Detail
-
setLeft
public final BaseElement setLeft(Element other, PositionRelativeLeft relative, int diff)
Set the element left position relative to an other element with a position difference.
-
setLeft
public final BaseElement setLeft(Element other, PositionRelativeLeft left, be.yildizgames.module.coordinate.Relative relativeDiff)
Set the element left position relative to an other element with a position difference relative to the width of the parent.
-
setVisible
public final Element setVisible(boolean visible)
Show or hide the element.- Specified by:
setVisiblein interfaceElement- Parameters:
visible-truewill set the element visible, false will hide it.- Returns:
- This object for chaining.
-
setLeft
public final BaseElement setLeft(Element other, PositionRelativeLeft relative)
Set the element left position relative to an other widget.
-
updateAddPositionValue
public final void updateAddPositionValue(int left, int top)Update position value without updating the widget.- Parameters:
left- Value to add to left value.top- Value to add to top value.
-
setTop
public final BaseElement setTop(Element other, PositionRelativeTop relative, int diff)
Set the element top position relative to an other element with a position difference.
-
setTop
public final BaseElement setTop(Element other, PositionRelativeTop top, be.yildizgames.module.coordinate.Relative relativeDiff)
Set the element top position relative to an other element with a position difference relative to the height of the parent.
-
setTop
public final BaseElement setTop(Element other, PositionRelativeTop relative)
Set the element top position relative to an other widget.
-
setPosition
public final BaseElement setPosition(Element other)
Set at the same position as the other element.- Specified by:
setPositionin interfaceElement- Parameters:
other- Other element to get the position.- Returns:
- This.
-
show
public final Element show()
Description copied from interface:ElementSet the element visible on screen.
-
hide
public final Element hide()
Description copied from interface:ElementSet the element invisible on screen.
-
addToPosition
public final void addToPosition(int xValue, int yValue)Move the widget.- Specified by:
addToPositionin interfaceElement- Parameters:
xValue- Add this value to the container current X position.yValue- Add this value to the container current Y position.
-
addToLeft
public final void addToLeft(int value)
Move the element left or right by adding a value to its current x value.
-
addToTop
public final void addToTop(int value)
Move the element up or down by adding a value to its current y value.
-
multiplySize
public final void multiplySize(float factor)
Multiply the size of the element.- Parameters:
factor- Multiplication factor.
-
delete
public abstract void delete()
Delete the widget.
-
showImpl
protected abstract void showImpl()
Implementation to set the widget visible.
-
hideImpl
protected abstract void hideImpl()
Implementation to set the widget invisible.
-
setPosition
public final Element setPosition(int leftPosition, int topPosition)
Set the left and top element position.- Specified by:
setPositionin interfaceElement- Parameters:
leftPosition- Left position.topPosition- Top position.- Returns:
- This object for chaining.
-
setTop
public final Element setTop(int topValue)
Description copied from interface:ElementSet the element top position.
-
setLeft
public final Element setLeft(int leftValue)
Description copied from interface:ElementSet the element left position.
-
getBottom
public final int getBottom()
-
setSize
public final void setSize(be.yildizgames.module.coordinate.Size size)
Update the widget size.
-
setHeight
public final void setHeight(int value)
Set the widget height.
-
setWidth
public final void setWidth(int value)
Set the widget width.
-
getCoordinates
public final be.yildizgames.module.coordinate.BaseCoordinate getCoordinates()
- Specified by:
getCoordinatesin interfaceElement- Returns:
- An object containing this widget coordinates.
-
setCoordinates
public final void setCoordinates(be.yildizgames.module.coordinate.BaseCoordinate coordinates)
Set the position and size coordinates.- Specified by:
setCoordinatesin interfaceElement- Parameters:
coordinates- Coordinates to set.
-
setSize
public final void setSize(int newWidth, int newHeight)Update the widget size.
-
getWidth
public final int getWidth()
-
getHeight
public final int getHeight()
-
getLeft
public final int getLeft()
-
getTop
public final int getTop()
-
getOpacity
public final int getOpacity()
-
getRight
public final int getRight()
-
setVirtualHeight
public final void setVirtualHeight(int height)
- Specified by:
setVirtualHeightin interfaceElement
-
resetVirtualHeight
public final void resetVirtualHeight()
- Specified by:
resetVirtualHeightin interfaceElement
-
setSizeImpl
protected abstract void setSizeImpl(int newWidth, int newHeight)Implementation to set the widget size.- Parameters:
newWidth- New width.newHeight- New height.
-
setPositionImpl
protected abstract Element setPositionImpl(int newLeft, int newTop)
Implementation to update the widget position.- Parameters:
newLeft- New widget x position.newTop- New widget y position.- Returns:
- This object for chaining.
-
-