Package xyz.gmitch215.socketmc.screen.ui
Class AbstractWidget
java.lang.Object
xyz.gmitch215.socketmc.screen.ui.AbstractWidget
- All Implemented Interfaces:
Serializable
,LayoutElement
,Positionable
- Direct Known Subclasses:
AbstractTextWidget
,ImageWidget
Represents a Widget on the screen.
This class is not legal for implementation!
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The default padding around text elements.protected int
The height of this widget.The tooltip for this widget.protected int
The width of this widget.protected int
The x-coordinate of this widget.protected int
The y-coordinate of this widget. -
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractWidget
(int x, int y, int width, int height) Constructs a new widget.protected
AbstractWidget
(@NotNull ElementBounds bounds) Constructs a new widget. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears all listeners from this widget.boolean
final int
Gets the height of this object.Gets an immutable copy of the listeners for this widget.final Tooltip
Gets the tooltip for this widget.final int
getWidth()
Gets the width of this object.final int
getX()
Gets the x-coordinate of this object.final int
getY()
Gets the y-coordinate of this object.final int
hashCode()
void
onClick
(@NotNull SerializableConsumer<Positionable> listener) Adds an on-click listener to this widget.final void
setHeight
(int height) Sets the height of this object.final void
setTooltip
(@Nullable Tooltip tooltip) Sets the tooltip for this widget.final void
setWidth
(int width) Sets the width of this object.final void
setX
(int x) Sets the x-coordinate of this object.final void
setY
(int y) Sets the y-coordinate of this object.final String
toString()
final void
visitWidgets
(@NotNull Consumer<AbstractWidget> visitor) Visits this object, applying a function to it.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface xyz.gmitch215.socketmc.screen.layout.LayoutElement
setPosition, setSize, setSize, setSize
Methods inherited from interface xyz.gmitch215.socketmc.screen.Positionable
inSamePosition
-
Field Details
-
DEFAULT_PADDING
public static final int DEFAULT_PADDINGThe default padding around text elements.- See Also:
-
x
protected int xThe x-coordinate of this widget. -
y
protected int yThe y-coordinate of this widget. -
width
protected int widthThe width of this widget. -
height
protected int heightThe height of this widget. -
tooltip
The tooltip for this widget.
-
-
Constructor Details
-
AbstractWidget
Constructs a new widget.- Parameters:
bounds
- the bounds
-
AbstractWidget
Constructs a new widget.- Parameters:
x
- the x-coordinatey
- the y-coordinatewidth
- the widthheight
- the height- Throws:
IllegalArgumentException
- if coordinates or dimensions are negative
-
-
Method Details
-
getX
public final int getX()Description copied from interface:LayoutElement
Gets the x-coordinate of this object.- Specified by:
getX
in interfaceLayoutElement
- Returns:
- the x-coordinate
-
setX
public final void setX(int x) Description copied from interface:LayoutElement
Sets the x-coordinate of this object.- Specified by:
setX
in interfaceLayoutElement
- Parameters:
x
- the x-coordinate
-
getY
public final int getY()Description copied from interface:LayoutElement
Gets the y-coordinate of this object.- Specified by:
getY
in interfaceLayoutElement
- Returns:
- the y-coordinate
-
setY
public final void setY(int y) Description copied from interface:LayoutElement
Sets the y-coordinate of this object.- Specified by:
setY
in interfaceLayoutElement
- Parameters:
y
- the y-coordinate
-
getWidth
public final int getWidth()Description copied from interface:LayoutElement
Gets the width of this object.- Specified by:
getWidth
in interfaceLayoutElement
- Returns:
- the width
-
setWidth
public final void setWidth(int width) Description copied from interface:LayoutElement
Sets the width of this object.- Specified by:
setWidth
in interfaceLayoutElement
- Parameters:
width
- the width
-
getHeight
public final int getHeight()Description copied from interface:LayoutElement
Gets the height of this object.- Specified by:
getHeight
in interfaceLayoutElement
- Returns:
- the height
-
setHeight
public final void setHeight(int height) Description copied from interface:LayoutElement
Sets the height of this object.- Specified by:
setHeight
in interfaceLayoutElement
- Parameters:
height
- the height
-
getTooltip
Description copied from interface:Positionable
Gets the tooltip for this widget.- Specified by:
getTooltip
in interfacePositionable
- Returns:
- Widget Tooltip
-
setTooltip
Description copied from interface:Positionable
Sets the tooltip for this widget.- Specified by:
setTooltip
in interfacePositionable
- Parameters:
tooltip
- Widget Tooltip
-
visitWidgets
Description copied from interface:LayoutElement
Visits this object, applying a function to it.- Specified by:
visitWidgets
in interfaceLayoutElement
- Parameters:
visitor
- the visitor
-
onClick
Description copied from interface:Positionable
Adds an on-click listener to this widget.- Specified by:
onClick
in interfacePositionable
- Parameters:
listener
- the listener- See Also:
-
clearListeners
public void clearListeners()Description copied from interface:Positionable
Clears all listeners from this widget.- Specified by:
clearListeners
in interfacePositionable
-
getListeners
Description copied from interface:Positionable
Gets an immutable copy of the listeners for this widget.- Specified by:
getListeners
in interfacePositionable
- Returns:
- the listeners
-
toString
-
equals
-
hashCode
public final int hashCode()
-