Package xyz.gmitch215.socketmc.screen.ui
Class ImageWidget
java.lang.Object
xyz.gmitch215.socketmc.screen.ui.AbstractWidget
xyz.gmitch215.socketmc.screen.ui.ImageWidget
- All Implemented Interfaces:
Serializable
,LayoutElement
,Positionable
Represents a widget that displays an image.
- See Also:
-
Nested Class Summary
-
Field Summary
Fields inherited from class xyz.gmitch215.socketmc.screen.ui.AbstractWidget
DEFAULT_PADDING, height, tooltip, width, x, y
-
Constructor Summary
ConstructorDescriptionImageWidget
(int x, int y, int width, int height, @NotNull ImageWidget.Type type, @NotNull Identifier location) Constructs a new widget.ImageWidget
(@NotNull ElementBounds bounds, @NotNull ImageWidget.Type type, @NotNull Identifier location) Constructs a new image widget. -
Method Summary
Modifier and TypeMethodDescriptionGets the location of the image.getType()
Gets the type of the image widget.void
setLocation
(@NotNull Identifier location) Sets the location of the image.static @NotNull ImageWidget
sprite
(int x, int y, int width, int height, @NotNull Identifier location) Constructs a new image widget withImageWidget.Type.SPRITE
.static @NotNull ImageWidget
sprite
(@NotNull ElementBounds bounds, @NotNull Identifier location) Constructs a new image widget withImageWidget.Type.SPRITE
.static @NotNull ImageWidget
texture
(int x, int y, int width, int height, @NotNull Identifier location) Constructs a new image widget withImageWidget.Type.TEXTURE
.static @NotNull ImageWidget
texture
(@NotNull ElementBounds bounds, @NotNull Identifier location) Constructs a new image widget withImageWidget.Type.TEXTURE
.Methods inherited from class xyz.gmitch215.socketmc.screen.ui.AbstractWidget
clearListeners, equals, getHeight, getListeners, getTooltip, getWidth, getX, getY, hashCode, onClick, setHeight, setTooltip, setWidth, setX, setY, toString, visitWidgets
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
-
Constructor Details
-
ImageWidget
public ImageWidget(@NotNull @NotNull ElementBounds bounds, @NotNull @NotNull ImageWidget.Type type, @NotNull @NotNull Identifier location) throws IllegalArgumentException Constructs a new image widget.- Parameters:
bounds
- the boundstype
- the type of imagelocation
- the location of the image- Throws:
IllegalArgumentException
- if the type or location are null
-
ImageWidget
public ImageWidget(int x, int y, int width, int height, @NotNull @NotNull ImageWidget.Type type, @NotNull @NotNull Identifier location) throws IllegalArgumentException Constructs a new widget.- Parameters:
x
- the x-coordinatey
- the y-coordinatewidth
- the widthheight
- the heighttype
- the type of imagelocation
- the location of the image- Throws:
IllegalArgumentException
- if coordinates or dimensions are negative, or if the type/location is null
-
-
Method Details
-
getType
Gets the type of the image widget.- Returns:
- Image Widget Type
-
getLocation
Gets the location of the image.- Returns:
- Image File Location
-
setLocation
Sets the location of the image.- Parameters:
location
- Image File Location- Throws:
IllegalArgumentException
- if the location is null
-
texture
@NotNull public static @NotNull ImageWidget texture(@NotNull @NotNull ElementBounds bounds, @NotNull @NotNull Identifier location) throws IllegalArgumentException Constructs a new image widget withImageWidget.Type.TEXTURE
.- Parameters:
bounds
- the bounds of the widgetlocation
- the location of the image- Returns:
- Image Widget
- Throws:
IllegalArgumentException
-
texture
@NotNull public static @NotNull ImageWidget texture(int x, int y, int width, int height, @NotNull @NotNull Identifier location) throws IllegalArgumentException Constructs a new image widget withImageWidget.Type.TEXTURE
.- Parameters:
x
- the x-coordinatey
- the y-coordinatewidth
- the widthheight
- the heightlocation
- the location of the image- Returns:
- Image Widget
- Throws:
IllegalArgumentException
- if coordinates or dimensions are negative, or if the location is null
-
sprite
@NotNull public static @NotNull ImageWidget sprite(@NotNull @NotNull ElementBounds bounds, @NotNull @NotNull Identifier location) throws IllegalArgumentException Constructs a new image widget withImageWidget.Type.SPRITE
.- Parameters:
bounds
- the bounds of the widgetlocation
- the location of the image- Returns:
- Image Widget
- Throws:
IllegalArgumentException
- if the location is null
-
sprite
@NotNull public static @NotNull ImageWidget sprite(int x, int y, int width, int height, @NotNull @NotNull Identifier location) throws IllegalArgumentException Constructs a new image widget withImageWidget.Type.SPRITE
.- Parameters:
x
- the x-coordinatey
- the y-coordinatewidth
- the widthheight
- the heightlocation
- the location of the image- Returns:
- Image Widget
- Throws:
IllegalArgumentException
- if coordinates or dimensions are negative, or if the location is null
-