T
- the type of UIComponent
public abstract class UIComponent<T extends UIComponent> extends java.lang.Object implements ITransformable.Position<T>, ITransformable.Size<T>, ITransformable.Alpha
UIComponent
is the base of everything drawn onto a GUI.ITransformable.Alpha, ITransformable.Brightness, ITransformable.Color, ITransformable.Position<T>, ITransformable.Rotate, ITransformable.Scale, ITransformable.Size<T>, ITransformable.Translate
Modifier and Type | Field and Description |
---|---|
protected int |
alpha
Alpha transparency of this
UIComponent . |
protected int |
anchor
Position anchor for this
UIComponent . |
protected boolean |
disabled
Determines whether this
UIComponent is enabled. |
protected boolean |
focused
Focus state of this
UIComponent . |
protected int |
height
Size of this
UIComponent . |
protected boolean |
hovered
Hover state of this
UIComponent . |
protected GuiIcon |
icon
GuiIcon used to draw this UIComponent . |
static int |
INHERITED |
protected java.lang.String |
name
The name of this
UIComponent Can be used to retrieve this back from a container. |
protected UIComponent |
parent
The parent
UIComponent of this UIComponent . |
protected RenderParameters |
rp
RenderParameters used to draw this UIComponent . |
protected GuiShape |
shape
GuiShape used to draw this
UIComponent . |
protected UITooltip |
tooltip
The tooltip for this
UIComponent Automatically displayed when the UIComponent is hovered. |
protected boolean |
visible
Determines whether this
UIComponent is visible. |
protected int |
width
Size of this
UIComponent . |
protected int |
x
Position of this
UIComponent . |
protected int |
y
Position of this
UIComponent . |
protected int |
zIndex
Z index of the component.
|
Constructor and Description |
---|
UIComponent(MalisisGui gui)
Instantiates a new
UIComponent . |
Modifier and Type | Method and Description |
---|---|
void |
addControlComponent(IControlComponent component)
Adds a
IControlComponent component to this UIComponent . |
int |
componentX(UIComponent component)
Gets the X coordinate of a
UIComponent inside this UIComponent . |
int |
componentY(UIComponent component)
Gets the Y coordinate of a
UIComponent inside this UIComponent . |
void |
draw(GuiRenderer renderer,
int mouseX,
int mouseY,
float partialTick)
Draws this
UIComponent Called by parent component. |
abstract void |
drawBackground(GuiRenderer renderer,
int mouseX,
int mouseY,
float partialTick)
Called first when drawing this
UIComponent . |
abstract void |
drawForeground(GuiRenderer renderer,
int mouseX,
int mouseY,
float partialTick)
Called last when drawing this
UIComponent . |
boolean |
fireEvent(ComponentEvent event)
Fires a
ComponentEvent . |
int |
getAlpha()
Gets the alpha transparency for this
UIComponent . |
int |
getAnchor()
Gets the anchor.
|
UIComponent |
getComponentAt(int x,
int y)
Gets the
UIComponent at the specified coordinates. |
MalisisGui |
getGui()
Gets the
MalisisGui this UIComponent was added to. |
int |
getHeight()
Gets the height of this
UIComponent . |
java.lang.String |
getName()
Gets the name of this
UIComponent . |
UIComponent |
getParent()
Gets the parent of this
UIComponent . |
java.lang.String |
getPropertyString()
Gets the property string.
|
int |
getRawHeight()
Gets the raw height of this
UIComponent . |
int |
getRawWidth()
Gets the raw width of this
UIComponent |
UITooltip |
getTooltip()
Gets the
UITooltip for this UIComponent . |
int |
getWidth()
Gets the width of this
UIComponent . |
int |
getX()
Gets the X coordinate of this
UIComponent 's position. |
int |
getY()
Gets the Y coordinate of this
UIComponent 's position. |
int |
getZIndex()
Gets the zIndex of this
UIComponent . |
boolean |
isDisabled()
Checks if this
UIComponent is disabled |
boolean |
isFocused()
Gets the
focused state of this UIComponent . |
boolean |
isHovered()
Gets the
hovered state of this UIComponent . |
boolean |
isInsideBounds(int x,
int y)
Checks if supplied coordinates are inside this
UIComponent bounds. |
boolean |
isRelativeHeight()
Checks if the height of this
UIComponent is relative to its parent UIComponent . |
boolean |
isRelativeWidth()
Checks if the width of this
UIComponent is relative to its parent UIComponent . |
boolean |
isVisible()
Checks if this
UIComponent is visible. |
void |
onAddedToScreen()
Called when this
UIComponent is added to screen. |
boolean |
onButtonPress(int x,
int y,
MouseButton button) |
boolean |
onButtonRelease(int x,
int y,
MouseButton button) |
boolean |
onClick(int x,
int y) |
boolean |
onDoubleClick(int x,
int y,
MouseButton button) |
boolean |
onDrag(int lastX,
int lastY,
int x,
int y,
MouseButton button) |
boolean |
onKeyTyped(char keyChar,
int keyCode)
Called when a key is typed while this
UIComponent is focused or hovered. |
boolean |
onMouseMove(int lastX,
int lastY,
int x,
int y) |
boolean |
onRightClick(int x,
int y) |
boolean |
onScrollWheel(int x,
int y,
int delta) |
int |
parentX()
Gets the X coordinate of this
UIComponent relative to its parent. |
int |
parentY()
Get the Y coordinate of this
UIComponent relative to its parent. |
T |
register(java.lang.Object object)
Registers an
object to handle events received by this UIComponent . |
int |
relativeX(int x)
Gets the X coordinate relative to this
UIComponent . |
int |
relativeY(int y)
Gets the Y coordinate relative to this
UIComponent . |
void |
removeAllControlComponents()
Removes all the
IControlComponent from this UIContainer . |
void |
removeControlComponent(IControlComponent component)
Removes the
IControlComponent from this UIComponent . |
int |
screenX()
Gets the X coordinate of this
UIComponent relative to the screen. |
int |
screenY()
Gets the Y coordinate of this
UIComponent relative to the screen. |
void |
setAlpha(int alpha)
Sets the alpha transparency for this
UIComponent . |
T |
setAnchor(int anchor)
Sets the anchor for this
UIComponent 's position. |
T |
setDisabled(boolean disabled)
Set the state of this
UIComponent . |
void |
setFocused(boolean focused)
Sets the
focused state of this UIComponent . |
void |
setHovered(boolean hovered)
Sets the
hovered state of this UIComponent . |
void |
setName(java.lang.String name)
Sets the name of this
UIComponent . |
void |
setParent(UIComponent parent)
Sets the parent of this
UIComponent . |
T |
setPosition(int x,
int y)
Sets the position of this
UIComponent . |
T |
setPosition(int x,
int y,
int anchor)
Sets the position of this
UIComponent relative to an anchor. |
T |
setSize(int width,
int height)
Sets the size of this
UIComponent . |
T |
setTooltip(java.lang.String text)
Sets the
UITooltip of this UIComponent . |
T |
setTooltip(UITooltip tooltip)
Sets the
UITooltip of this UIComponent . |
T |
setVisible(boolean visible)
Sets the visibility of this
UIComponent . |
T |
setZIndex(int zIndex)
Sets the zIndex for this
UIComponent . |
java.lang.String |
toString() |
T |
unregister(java.lang.Object object)
Unregister an
object to stop receiving events for this UIComponent . |
public static final int INHERITED
protected int x
UIComponent
.protected int y
UIComponent
.protected int zIndex
protected int anchor
UIComponent
. See Anchor
protected int width
UIComponent
.protected int height
UIComponent
.protected UIComponent parent
UIComponent
of this UIComponent
.protected java.lang.String name
UIComponent
Can be used to retrieve this back from a container.protected UITooltip tooltip
UIComponent
Automatically displayed when the UIComponent
is hovered.protected boolean visible
UIComponent
is visible.protected boolean disabled
UIComponent
is enabled. If set to false, will cancel any
events
received.protected boolean hovered
UIComponent
.protected boolean focused
UIComponent
.protected GuiShape shape
UIComponent
.protected RenderParameters rp
RenderParameters
used to draw this UIComponent
.protected GuiIcon icon
GuiIcon
used to draw this UIComponent
.protected int alpha
UIComponent
.public UIComponent(MalisisGui gui)
UIComponent
.gui
- the guipublic MalisisGui getGui()
MalisisGui
this UIComponent
was added to.public T setPosition(int x, int y)
UIComponent
.setPosition
in interface ITransformable.Position<T extends UIComponent>
x
- the xy
- the yUIComponent
public T setPosition(int x, int y, int anchor)
UIComponent
relative to an anchor.x
- the xy
- the yanchor
- the anchorUIComponent
public int getX()
UIComponent
's position.public int getY()
UIComponent
's position.public T setZIndex(int zIndex)
UIComponent
.zIndex
- the z indexUIComponent
public int getZIndex()
UIComponent
.public T setAnchor(int anchor)
UIComponent
's position.anchor
- the anchorUIComponent
public int getAnchor()
UIComponent
's positionpublic T setSize(int width, int height)
UIComponent
.setSize
in interface ITransformable.Size<T extends UIComponent>
width
- the widthheight
- the heightUIComponent
public int getRawWidth()
UIComponent
public int getWidth()
UIComponent
.public boolean isRelativeWidth()
UIComponent
is relative to its parent UIComponent
.public int getRawHeight()
UIComponent
.public int getHeight()
UIComponent
.public boolean isRelativeHeight()
UIComponent
is relative to its parent UIComponent
.public void setHovered(boolean hovered)
hovered
state of this UIComponent
.hovered
- the new statepublic boolean isHovered()
hovered
state of this UIComponent
.public void setFocused(boolean focused)
focused
state of this UIComponent
.focused
- the statepublic boolean isFocused()
focused
state of this UIComponent
.public UIComponent getParent()
UIComponent
.public void setParent(UIComponent parent)
UIComponent
.parent
- the parentpublic boolean isVisible()
UIComponent
is visible.public T setVisible(boolean visible)
UIComponent
.visible
- the visibility for this componentUIComponent
public boolean isDisabled()
UIComponent
is disabledpublic T setDisabled(boolean disabled)
UIComponent
.disabled
- the new stateUIComponent
public java.lang.String getName()
UIComponent
.public void setName(java.lang.String name)
UIComponent
.name
- the name to be usedpublic UITooltip getTooltip()
UITooltip
for this UIComponent
.public T setTooltip(UITooltip tooltip)
UITooltip
of this UIComponent
.tooltip
- the tooltipUIComponent
public T setTooltip(java.lang.String text)
UITooltip
of this UIComponent
.text
- the text of the tooltippublic void setAlpha(int alpha)
UIComponent
.setAlpha
in interface ITransformable.Alpha
alpha
- the new alphapublic int getAlpha()
UIComponent
.public T register(java.lang.Object object)
object
to handle events received by this UIComponent
.object
- object whose handler methods should be registeredUIComponent
public T unregister(java.lang.Object object)
object
to stop receiving events for this UIComponent
.object
- the objectUIComponent
public boolean fireEvent(ComponentEvent event)
ComponentEvent
.event
- the eventpublic boolean onMouseMove(int lastX, int lastY, int x, int y)
public boolean onButtonPress(int x, int y, MouseButton button)
public boolean onButtonRelease(int x, int y, MouseButton button)
public boolean onClick(int x, int y)
public boolean onRightClick(int x, int y)
public boolean onDoubleClick(int x, int y, MouseButton button)
public boolean onDrag(int lastX, int lastY, int x, int y, MouseButton button)
public boolean onScrollWheel(int x, int y, int delta)
public boolean onKeyTyped(char keyChar, int keyCode)
UIComponent
is focused or hovered.keyChar
- the key charkeyCode
- the key codepublic boolean isInsideBounds(int x, int y)
UIComponent
bounds.x
- the xy
- the ypublic UIComponent getComponentAt(int x, int y)
UIComponent
at the specified coordinates.IControlComponent
if any. Checks if inside bounds, visible and not disabled.x
- the xy
- the yUIComponent
or null if outside its bounds.public int relativeX(int x)
UIComponent
.x
- the xpublic int relativeY(int y)
UIComponent
.y
- the ypublic int componentX(UIComponent component)
UIComponent
inside this UIComponent
.component
- the componentpublic int componentY(UIComponent component)
UIComponent
inside this UIComponent
.component
- the componentpublic int parentX()
UIComponent
relative to its parent.public int parentY()
UIComponent
relative to its parent.public int screenX()
UIComponent
relative to the screen.public int screenY()
UIComponent
relative to the screen.public void addControlComponent(IControlComponent component)
IControlComponent
component to this UIComponent
.component
- the componentpublic void removeControlComponent(IControlComponent component)
IControlComponent
from this UIComponent
.component
- the componentpublic void removeAllControlComponents()
IControlComponent
from this UIContainer
.public void onAddedToScreen()
UIComponent
is added to screen.SpaceChangeEvent.SizeChangeEvent
is this component size is relative.public void draw(GuiRenderer renderer, int mouseX, int mouseY, float partialTick)
UIComponent
Called by parent
component.shape
according to the size of this UIComponent
renderer
- the renderermouseX
- the mouse xmouseY
- the mouse ypartialTick
- the partial tickpublic java.lang.String getPropertyString()
public java.lang.String toString()
toString
in class java.lang.Object
public abstract void drawBackground(GuiRenderer renderer, int mouseX, int mouseY, float partialTick)
UIComponent
.renderer
- the renderermouseX
- the mouse xmouseY
- the mouse ypartialTick
- the partial tickpublic abstract void drawForeground(GuiRenderer renderer, int mouseX, int mouseY, float partialTick)
UIComponent
.renderer
- the renderermouseX
- the mouse xmouseY
- the mouse ypartialTick
- the partial tick