Class DrawingContext
java.lang.Object
xyz.gmitch215.socketmc.util.render.DrawingContext
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<Function<GraphicsContext,
DrawingContext.Command>>
public final class DrawingContext
extends Object
implements Serializable, Iterable<Function<GraphicsContext,DrawingContext.Command>>, Cloneable
Represents the raw graphics context used to display graphics on the screen.
This allows you to also collect the context of the current screen, as specified in GraphicsContext
.
The Function
interfaces you specify must be serializable and cannot call anything external.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Represents a command in a DrawingContext.static final class
Represents a modifier for a specificDrawingContext.Command
.static enum
Represents the type of drawing command to use. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Blitstatic final int
Blit Spritestatic final int
Disable Scissorstatic final int
Draw Centered Stringstatic final int
Draw ItemStackstatic final int
Draw Stringstatic final int
Draw Tooltipstatic final int
Draw Word Wrapstatic final int
Enable Scissorstatic final int
Fillstatic final int
Fill Gradientstatic final int
Horizontal Linestatic final int
A custom modifier on the normal for the pose stack.static final int
A custom modifier on the pose for the pose stack.static final int
Rotates an element on the XYZ axis.static final int
Rotates an element on the XYZ axis around a specific coordinate.static final int
Scales an element on the XYZ axis.static final int
Translates an element across the XYZ axis.static final int
Outlinestatic final int
Vertical Line -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCommand
(int index, @NotNull Function<GraphicsContext, DrawingContext.Command> command) Adds a command to the DrawingContext at the specified index.void
addCommand
(int index, @NotNull DrawingContext.Command command) Adds a command to the DrawingContext at the specified index.void
Adds a command to the DrawingContext.void
addCommand
(@NotNull DrawingContext.Command command) Adds a command to the DrawingContext.void
Clears all commands from the DrawingContext.clone()
boolean
Gets an immutable copy of the commands in this DrawingContext, with the currentGraphicsContext
information.int
hashCode()
boolean
isLocked()
Checks if the DrawingContext is locked.iterator()
void
lock()
Locks the DrawingContext, making it immutable.static @NotNull DrawingContext
of
(@NotNull Collection<Function<GraphicsContext, DrawingContext.Command>> commands) Creates a newDrawingContext
from a list of commands.static @NotNull DrawingContext
of
(@NotNull Function<GraphicsContext, DrawingContext.Command> command) Creates a newDrawingContext
from a single command.static @NotNull DrawingContext
of
(@NotNull Function<GraphicsContext, DrawingContext.Command>... commands) Creates a newDrawingContext
from an array of commands.void
removeCommand
(int index) Removes a command from the DrawingContext at the specified index.toString()
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
H_LINE
public static final int H_LINEHorizontal Line- See Also:
-
V_LINE
public static final int V_LINEVertical Line- See Also:
-
ENABLE_SCISSOR
public static final int ENABLE_SCISSOREnable Scissor- See Also:
-
DISABLE_SCISSOR
public static final int DISABLE_SCISSORDisable Scissor- See Also:
-
FILL
public static final int FILLFill- See Also:
-
FILL_GRADIENT
public static final int FILL_GRADIENTFill Gradient- See Also:
-
DRAW_CENTERED_STRING
public static final int DRAW_CENTERED_STRINGDraw Centered String- See Also:
-
DRAW_STRING
public static final int DRAW_STRINGDraw String- See Also:
-
DRAW_WORD_WRAP
public static final int DRAW_WORD_WRAPDraw Word Wrap- See Also:
-
OUTLINE
public static final int OUTLINEOutline- See Also:
-
BLIT
public static final int BLITBlit- See Also:
-
BLIT_SPRITE
public static final int BLIT_SPRITEBlit Sprite- See Also:
-
DRAW_TOOLTIP
public static final int DRAW_TOOLTIPDraw Tooltip- See Also:
-
DRAW_ITEMSTACK
public static final int DRAW_ITEMSTACKDraw ItemStack- See Also:
-
MODIFIER_SCALE
public static final int MODIFIER_SCALEScales an element on the XYZ axis.- See Also:
-
MODIFIER_TRANSLATE
public static final int MODIFIER_TRANSLATETranslates an element across the XYZ axis.- See Also:
-
MODIFIER_ROTATE
public static final int MODIFIER_ROTATERotates an element on the XYZ axis.- See Also:
-
MODIFIER_ROTATE_AROUND
public static final int MODIFIER_ROTATE_AROUNDRotates an element on the XYZ axis around a specific coordinate.- See Also:
-
MODIFIER_APPLY_POSE
public static final int MODIFIER_APPLY_POSEA custom modifier on the pose for the pose stack.- See Also:
-
MODIFIER_APPLY_NORMAL
public static final int MODIFIER_APPLY_NORMALA custom modifier on the normal for the pose stack.- See Also:
-
-
Method Details
-
getCommands
Gets an immutable copy of the commands in this DrawingContext, with the currentGraphicsContext
information.- Returns:
- DrawingContext Commands
-
addCommand
public void addCommand(@NotNull @NotNull DrawingContext.Command command) throws IllegalArgumentException Adds a command to the DrawingContext.- Parameters:
command
- the command to add- Throws:
IllegalArgumentException
- if the command is null
-
addCommand
public void addCommand(@NotNull @NotNull Function<GraphicsContext, DrawingContext.Command> command) throws IllegalArgumentExceptionAdds a command to the DrawingContext.- Parameters:
command
- the command to add- Throws:
IllegalArgumentException
- if the command is null
-
addCommand
public void addCommand(int index, @NotNull @NotNull DrawingContext.Command command) throws IllegalArgumentException Adds a command to the DrawingContext at the specified index.- Parameters:
index
- the index to add the command atcommand
- the command to add- Throws:
IllegalArgumentException
- if the command is null
-
addCommand
public void addCommand(int index, @NotNull @NotNull Function<GraphicsContext, DrawingContext.Command> command) throws IllegalArgumentExceptionAdds a command to the DrawingContext at the specified index.- Parameters:
index
- the index to add the command atcommand
- the command to add- Throws:
IllegalArgumentException
- if the command is null
-
removeCommand
public void removeCommand(int index) Removes a command from the DrawingContext at the specified index.- Parameters:
index
- the index to remove the command at
-
clearCommands
public void clearCommands()Clears all commands from the DrawingContext. -
isLocked
public boolean isLocked()Checks if the DrawingContext is locked. If true, this DrawingContext cannot be modified.- Returns:
- true if the DrawingContext is locked, false otherwise
-
lock
Locks the DrawingContext, making it immutable.- Throws:
IllegalStateException
- if the DrawingContext is already locked
-
clone
-
iterator
- Specified by:
iterator
in interfaceIterable<Function<GraphicsContext,
DrawingContext.Command>>
-
equals
-
hashCode
public int hashCode() -
toString
-
of
@NotNull public static @NotNull DrawingContext of(@NotNull @NotNull Function<GraphicsContext, DrawingContext.Command> command) throws IllegalArgumentExceptionCreates a newDrawingContext
from a single command.- Parameters:
command
- the command to use- Returns:
- A new DrawingContext
- Throws:
IllegalArgumentException
- if the command is null
-
of
@NotNull public static @NotNull DrawingContext of(@NotNull @NotNull Collection<Function<GraphicsContext, DrawingContext.Command>> commands) throws IllegalArgumentExceptionCreates a newDrawingContext
from a list of commands.- Parameters:
commands
- the commands to use- Returns:
- A new DrawingContext
- Throws:
IllegalArgumentException
- if the commands are null
-
of
@NotNull @SafeVarargs public static @NotNull DrawingContext of(@NotNull @NotNull Function<GraphicsContext, DrawingContext.Command>... commands) throws IllegalArgumentExceptionCreates a newDrawingContext
from an array of commands.- Parameters:
commands
- the commands to use- Returns:
- A new DrawingContext
- Throws:
IllegalArgumentException
- if the commands are null
-