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
FieldsModifier and TypeFieldDescriptionstatic final intThe default padding around text elements.protected intThe height of this widget.The tooltip for this widget.protected intThe width of this widget.protected intThe x-coordinate of this widget.protected intThe y-coordinate of this widget. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractWidget(int x, int y, int width, int height) Constructs a new widget.protectedAbstractWidget(@NotNull ElementBounds bounds) Constructs a new widget. -
Method Summary
Modifier and TypeMethodDescriptionvoidClears all listeners from this widget.booleanfinal intGets the height of this object.Gets an immutable copy of the listeners for this widget.final TooltipGets the tooltip for this widget.final intgetWidth()Gets the width of this object.final intgetX()Gets the x-coordinate of this object.final intgetY()Gets the y-coordinate of this object.final inthashCode()voidonClick(@NotNull SerializableConsumer<Positionable> listener) Adds an on-click listener to this widget.final voidsetHeight(int height) Sets the height of this object.final voidsetTooltip(@Nullable Tooltip tooltip) Sets the tooltip for this widget.final voidsetWidth(int width) Sets the width of this object.final voidsetX(int x) Sets the x-coordinate of this object.final voidsetY(int y) Sets the y-coordinate of this object.final StringtoString()final voidvisitWidgets(@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, waitMethods inherited from interface xyz.gmitch215.socketmc.screen.layout.LayoutElement
setPosition, setSize, setSize, setSizeMethods 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:LayoutElementGets the x-coordinate of this object.- Specified by:
getXin interfaceLayoutElement- Returns:
- the x-coordinate
-
setX
public final void setX(int x) Description copied from interface:LayoutElementSets the x-coordinate of this object.- Specified by:
setXin interfaceLayoutElement- Parameters:
x- the x-coordinate
-
getY
public final int getY()Description copied from interface:LayoutElementGets the y-coordinate of this object.- Specified by:
getYin interfaceLayoutElement- Returns:
- the y-coordinate
-
setY
public final void setY(int y) Description copied from interface:LayoutElementSets the y-coordinate of this object.- Specified by:
setYin interfaceLayoutElement- Parameters:
y- the y-coordinate
-
getWidth
public final int getWidth()Description copied from interface:LayoutElementGets the width of this object.- Specified by:
getWidthin interfaceLayoutElement- Returns:
- the width
-
setWidth
public final void setWidth(int width) Description copied from interface:LayoutElementSets the width of this object.- Specified by:
setWidthin interfaceLayoutElement- Parameters:
width- the width
-
getHeight
public final int getHeight()Description copied from interface:LayoutElementGets the height of this object.- Specified by:
getHeightin interfaceLayoutElement- Returns:
- the height
-
setHeight
public final void setHeight(int height) Description copied from interface:LayoutElementSets the height of this object.- Specified by:
setHeightin interfaceLayoutElement- Parameters:
height- the height
-
getTooltip
Description copied from interface:PositionableGets the tooltip for this widget.- Specified by:
getTooltipin interfacePositionable- Returns:
- Widget Tooltip
-
setTooltip
Description copied from interface:PositionableSets the tooltip for this widget.- Specified by:
setTooltipin interfacePositionable- Parameters:
tooltip- Widget Tooltip
-
visitWidgets
Description copied from interface:LayoutElementVisits this object, applying a function to it.- Specified by:
visitWidgetsin interfaceLayoutElement- Parameters:
visitor- the visitor
-
onClick
Description copied from interface:PositionableAdds an on-click listener to this widget.- Specified by:
onClickin interfacePositionable- Parameters:
listener- the listener- See Also:
-
clearListeners
public void clearListeners()Description copied from interface:PositionableClears all listeners from this widget.- Specified by:
clearListenersin interfacePositionable
-
getListeners
Description copied from interface:PositionableGets an immutable copy of the listeners for this widget.- Specified by:
getListenersin interfacePositionable- Returns:
- the listeners
-
toString
-
equals
-
hashCode
public final int hashCode()
-