T - the type of UIComponentpublic abstract class UIComponent<T extends UIComponent<T>> extends java.lang.Object implements ITransformable.Position<T>, ITransformable.Size<T>, ITransformable.Alpha, IKeyListener
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 IGuiIconProvider |
iconProvider
GuiIcon used to draw this UIComponent. |
static int |
INHERITED
The Constant INHERITED.
|
protected java.lang.String |
name
The name of this
UIComponent. |
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. |
void |
attachData(java.lang.Object data) |
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. |
java.lang.Object |
getData() |
MalisisGui |
getGui()
Gets the
MalisisGui this UIComponent was added to. |
int |
getHeight()
Gets the height of this
UIComponent. |
IIconProvider |
getIconProvider() |
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. |
GuiRenderer |
getRenderer()
Gets the
GuiRenderer that will draw 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)
On button press.
|
boolean |
onButtonRelease(int x,
int y,
MouseButton button)
On button release.
|
boolean |
onClick(int x,
int y)
On click.
|
boolean |
onDoubleClick(int x,
int y,
MouseButton button)
On double click.
|
boolean |
onDrag(int lastX,
int lastY,
int x,
int y,
MouseButton button)
On drag.
|
boolean |
onKeyTyped(char keyChar,
int keyCode)
Called when a key is typed inside
MalisisGui. |
boolean |
onMouseMove(int lastX,
int lastY,
int x,
int y)
On mouse move.
|
boolean |
onRightClick(int x,
int y)
On right click.
|
boolean |
onScrollWheel(int x,
int y,
int delta)
On scroll wheel.
|
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. |
T |
self() |
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. |
T |
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()
To string.
|
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 Anchorprotected 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 IGuiIconProvider iconProvider
GuiIcon used to draw this UIComponent.protected int alpha
UIComponent.public UIComponent(MalisisGui gui)
UIComponent.gui - the guipublic T self()
public MalisisGui getGui()
MalisisGui this UIComponent was added to.public GuiRenderer getRenderer()
GuiRenderer that will draw this UIComponent.public T setPosition(int x, int y)
UIComponent.setPosition in interface ITransformable.Position<T extends UIComponent<T>>x - the xy - the yUIComponentpublic T setPosition(int x, int y, int anchor)
UIComponent relative to an anchor.x - the xy - the yanchor - the anchorUIComponentpublic int getX()
UIComponent's position.public int getY()
UIComponent's position.public T setZIndex(int zIndex)
UIComponent.zIndex - the z indexUIComponentpublic int getZIndex()
UIComponent.public T setAnchor(int anchor)
UIComponent's position.anchor - the anchorUIComponentpublic int getAnchor()
UIComponent's positionpublic T setSize(int width, int height)
UIComponent.setSize in interface ITransformable.Size<T extends UIComponent<T>>width - the widthheight - the heightUIComponentpublic 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 componentUIComponentpublic boolean isDisabled()
UIComponent is disabled.public T setDisabled(boolean disabled)
UIComponent.disabled - the new stateUIComponentpublic java.lang.String getName()
UIComponent.public T 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 tooltipUIComponentpublic 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.Alphaalpha - the new alphapublic int getAlpha()
UIComponent.public void attachData(java.lang.Object data)
public java.lang.Object getData()
public IIconProvider getIconProvider()
public T register(java.lang.Object object)
object to handle events received by this UIComponent.object - object whose handler methods should be registeredUIComponentpublic T unregister(java.lang.Object object)
object to stop receiving events for this UIComponent.object - the objectUIComponentpublic boolean fireEvent(ComponentEvent<?> event)
ComponentEvent.event - the eventpublic boolean onMouseMove(int lastX,
int lastY,
int x,
int y)
lastX - the last xlastY - the last yx - the xy - the ypublic boolean onButtonPress(int x,
int y,
MouseButton button)
x - the xy - the ybutton - the buttonpublic boolean onButtonRelease(int x,
int y,
MouseButton button)
x - the xy - the ybutton - the buttonpublic boolean onClick(int x,
int y)
x - the xy - the ypublic boolean onRightClick(int x,
int y)
x - the xy - the ypublic boolean onDoubleClick(int x,
int y,
MouseButton button)
x - the xy - the ybutton - the buttonpublic boolean onDrag(int lastX,
int lastY,
int x,
int y,
MouseButton button)
lastX - the last xlastY - the last yx - the xy - the ybutton - the buttonpublic boolean onScrollWheel(int x,
int y,
int delta)
x - the xy - the ydelta - the deltapublic boolean onKeyTyped(char keyChar,
int keyCode)
IKeyListenerMalisisGui.onKeyTyped in interface IKeyListenerkeyChar - 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 if 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 UIComponentrenderer - 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.Objectpublic 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