Package com.spinyowl.legui.component
Class Component
java.lang.Object
com.spinyowl.legui.component.Component
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AbstractTextComponent,ImageView,Layer,Panel,ProgressBar,ScrollablePanel,ScrollBar,SelectBox,Slider,TextArea,Widget
Component is an object that have graphical representation in legui system.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanUsed to add component to component.voidaddAll(Collection<? extends Component> components) Used to add components.voidUsed to remove all child components from component.Returns an iterator over the elements in this component.booleanReturns true if component contains specified component.booleancontainsAll(Collection<Component> components) Returns true if this Container contains all of the elements of the specified collection.intcount()Returns count of child components.booleanvoidPerforms the given action for each element of the Iterable until all elements have been processed or the action throws an exception.org.joml.Vector2fReturns absolute component position.Used to retrieve child components asList.getFrame()Returns component intersector which used to check if cursor intersect component or not.getLayer()Returns event listeners for component instance.Returns component metadata.Returns parent component.org.joml.Vector2fReturns position vector.org.joml.Vector2fgetSize()Returns size vector of component.getStyle()Returns component style.intReturns tab index.Returns tooltip if it persist.inthashCode()intindexOfChild(Component component) booleanintersects(org.joml.Vector2f point) Used to determine if point intersects component (in screen space).booleanisEmpty()Returns true if component contains no elements.booleanReturns true if component enabled.booleanReturns true if component focused.booleanReturns true if component is focused.booleanReturns true if component is hovered.booleanReturns true if component is pressed.booleanReturns true if component focused by tabbing.booleanReturns true if component visible.booleanShows if rendering pipeline should be redefined to not skip element rendering if it is not visible in parent components (is out of view).voidkeepRendering(boolean keepRendering) Used to redefine rendering pipeline to not skip element rendering if it is not visible in parent components (is out of view).Returns a possibly parallel Stream with this collection as its source.remove(int index) booleanUsed to remove component.voidremoveAll(Collection<? extends Component> components) Used to remove components.voidRemoves all of the elements of this component that satisfy the given predicate.voidsetEnabled(boolean enabled) Used to enable or disable component.voidsetFocusable(boolean focusable) Used to set component focusable.voidsetFocused(boolean focused) Used to make component focused or not.voidsetHovered(boolean hovered) Used to make component hovered or not.voidsetIntersector(Intersector intersector) Used to set intersector for component.voidsetListenerMap(ListenerMap listenerMap) Used to set event listener map for component.voidUsed to set parent component.voidsetPosition(float x, float y) Used to set current position.voidsetPosition(org.joml.Vector2f position) Used to set position of component.voidsetPressed(boolean pressed) Used to make component pressed or not.voidsetSize(float width, float height) Used to set size vector.voidsetSize(org.joml.Vector2f size) Used to set size vector.voidUsed to set component style.voidsetTabFocusable(boolean tabFocusable) Used to set tab affecting for component.voidsetTabIndex(int tabIndex) Used to set tab index.voidsetTooltip(Tooltip tooltip) Used to set tooltip to component.stream()Returns a sequential Stream with this collection as its source.toString()
-
Constructor Details
-
Component
public Component()Default constructor. Used to create component instance without any parameters.Also if you want to make it easy to use with Json marshaller/unmarshaller component should contain empty constructor.
-
Component
public Component(float x, float y, float width, float height) Constructor with position and size parameters.- Parameters:
x- x position position in parent component.y- y position position in parent component.width- width of component.height- height of component.
-
Component
public Component(org.joml.Vector2f position, org.joml.Vector2f size) Constructor with position and size parameters.- Parameters:
position- position position in parent component.size- size of component.
-
-
Method Details
-
getFocusedStyle
-
getHoveredStyle
-
getPressedStyle
-
getStyle
Returns component style.- Returns:
- component style.
-
setStyle
Used to set component style.- Parameters:
style- component style to set.
-
getParent
Returns parent component. If returns null - current component is root component.- Returns:
- null or parent component.
-
setParent
Used to set parent component. By default used by containers to attach component to container. Parent component used by renderers and event listeners and processors.Don't use this method if you want to attach component to container. In this case use
add(Component)method.- Parameters:
parent- component container.
-
getListenerMap
Returns event listeners for component instance.- Returns:
- event listeners map.
-
setListenerMap
Used to set event listener map for component.- Parameters:
listenerMap- map of event listeners.
-
getPosition
public org.joml.Vector2f getPosition()Returns position vector. Be careful during changing this vector.- Returns:
- position vector.
-
setPosition
public void setPosition(org.joml.Vector2f position) Used to set position of component.- Parameters:
position- new position for component.
-
setPosition
public void setPosition(float x, float y) Used to set current position.- Parameters:
x- x position relative to parent component.y- y position relative to parent component.
-
getSize
public org.joml.Vector2f getSize()Returns size vector of component. So to get width you can use.Vector2f size = component.getSize(); float width = size.x; float height = size.y;- Returns:
- size of component.
-
setSize
public void setSize(org.joml.Vector2f size) Used to set size vector.- Parameters:
size- size vector.
-
setSize
public void setSize(float width, float height) Used to set size vector.- Parameters:
width- width to set.height- height to set.
-
getAbsolutePosition
public org.joml.Vector2f getAbsolutePosition()Returns absolute component position.- Returns:
- position vector.
-
isEnabled
public boolean isEnabled()Returns true if component enabled. By default if component enabled it receives and proceed events.- Returns:
- true if component enabled. default value is
Boolean.TRUE.
-
setEnabled
public void setEnabled(boolean enabled) Used to enable or disable component. By default if component enabled it receives and proceed events.- Parameters:
enabled- flag to set.
-
isVisible
public boolean isVisible()Returns true if component visible. By default if component visible it will be rendered and will receive events.- Returns:
- true if component visible. default value is
Boolean.TRUE.
-
intersects
public boolean intersects(org.joml.Vector2f point) Used to determine if point intersects component (in screen space). This method uses component intersector.- Parameters:
point- point to check.- Returns:
- true if component intersected by point.
-
getIntersector
Returns component intersector which used to check if cursor intersect component or not.- Returns:
- intersector.
-
setIntersector
Used to set intersector for component.- Parameters:
intersector- intersector.
-
getMetadata
Returns component metadata. Storage of some temporary statements. Can be used for example by stateless renderers.- Returns:
- map of objects.
-
isHovered
public boolean isHovered()Returns true if component is hovered.- Returns:
- true if component is hovered.
-
setHovered
public void setHovered(boolean hovered) Used to make component hovered or not.- Parameters:
hovered- new hovered value.
-
isFocused
public boolean isFocused()Returns true if component is focused.- Returns:
- true if component is focused.
-
setFocused
public void setFocused(boolean focused) Used to make component focused or not.- Parameters:
focused- new hovered value.
-
isPressed
public boolean isPressed()Returns true if component is pressed.- Returns:
- true if component is pressed.
-
setPressed
public void setPressed(boolean pressed) Used to make component pressed or not.- Parameters:
pressed- new hovered value.
-
getTooltip
Returns tooltip if it persist.- Returns:
- tooltip.
-
setTooltip
Used to set tooltip to component.- Parameters:
tooltip- tooltip to set.
-
getTabIndex
public int getTabIndex()Returns tab index.- Returns:
- tab index.
-
setTabIndex
public void setTabIndex(int tabIndex) Used to set tab index.- Parameters:
tabIndex- tab index.
-
isTabFocusable
public boolean isTabFocusable()Returns true if component focused by tabbing.- Returns:
- true if component focused by tabbing.
-
setTabFocusable
public void setTabFocusable(boolean tabFocusable) Used to set tab affecting for component.- Parameters:
tabFocusable- new tab affecting state.
-
isFocusable
public boolean isFocusable()Returns true if component focused.- Returns:
- true if component focused.
-
setFocusable
public void setFocusable(boolean focusable) Used to set component focusable.
Note! You should take in consideration that component that marked as non-focusable will not receive any events. In fact this could be used to organize elements using containers.- Parameters:
focusable- new focusable state.
-
count
public int count()Returns count of child components.- Returns:
- count of child components.
- See Also:
-
isEmpty
public boolean isEmpty()Returns true if component contains no elements.- Returns:
- true if component contains no elements.
- See Also:
-
contains
Returns true if component contains specified component.- Parameters:
component- component to check.- Returns:
- true if component contains specified component.
- See Also:
-
containerIterator
Returns an iterator over the elements in this component. The elements are returned in no particular order.- Returns:
- an iterator over the elements in this component.
- See Also:
-
add
Used to add component to component.- Parameters:
component- component to add.- Returns:
- true if component is added.
- See Also:
-
add
-
addAll
Used to add components.- Parameters:
components- components nodes to add.
-
remove
Used to remove component.- Parameters:
component- component to remove.- Returns:
- true if removed.
- See Also:
-
remove
-
removeAll
Used to remove components.- Parameters:
components- components to remove.- See Also:
-
removeIf
Removes all of the elements of this component that satisfy the given predicate. Errors or runtime exceptions thrown during iteration or by the predicate are relayed to the caller.- Parameters:
filter- a predicate which returns true for elements to be removed.- See Also:
-
clearChildComponents
public void clearChildComponents()Used to remove all child components from component.- See Also:
-
containsAll
Returns true if this Container contains all of the elements of the specified collection.- Parameters:
components- components collection to check.- Returns:
- true if this Container contains all of the elements of the specified collection.
- See Also:
-
stream
Returns a sequential Stream with this collection as its source.- Returns:
- a sequential Stream with this collection as its source.
- See Also:
-
parallelStream
Returns a possibly parallel Stream with this collection as its source. It is allowable for this method to return a sequential stream.- Returns:
- possibly parallel Stream with this collection as its source.
- See Also:
-
forEach
Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.- Parameters:
action- The action to be performed for each element.
-
getChildComponents
- Returns:
- list of child components.
-
equals
-
hashCode
public int hashCode() -
toString
-
indexOfChild
-
getLayer
-
getFrame
-
keepRendering
public boolean keepRendering()Shows if rendering pipeline should be redefined to not skip element rendering if it is not visible in parent components (is out of view).- Returns:
- true if component should be rendered out of view.
-
keepRendering
public void keepRendering(boolean keepRendering) Used to redefine rendering pipeline to not skip element rendering if it is not visible in parent components (is out of view).- Parameters:
keepRendering- set to true to allow component be rendered even if it is out of view.
-