T
- child type restriction.public abstract class Component<T extends Component>
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
Component()
Default constructor.
|
Component(float x,
float y,
float width,
float height)
Constructor with position and size parameters.
|
Component(org.joml.Vector2f position,
org.joml.Vector2f size)
Constructor with position and size parameters.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(T component)
Used to add component to layerFrame.
|
boolean |
addAll(java.util.Collection<? extends T> components)
Used to add components.
|
void |
clearChilds()
Used to remove all child components from layerFrame.
|
java.util.Iterator<T> |
containerIterator()
Returns an iterator over the elements in this layerFrame.
|
boolean |
contains(T component)
Returns true if layerFrame contains specified component.
|
boolean |
containsAll(java.util.Collection<T> components)
Returns true if this Container contains all of the elements of the specified collection.
|
int |
count()
Returns count of child components.
|
boolean |
equals(java.lang.Object o) |
void |
forEach(java.util.function.Consumer<? super T> action)
Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.
|
org.joml.Vector2f |
getAbsolutePosition()
Returns absolute component position.
|
org.joml.Vector4f |
getBackgroundColor()
Returns
Vector4f background color vector where x,y,z,w mapped to r,g,b,a values. |
Border |
getBorder()
Returns border of component.
|
java.util.List<T> |
getChilds()
Used to retrieve child components as
List . |
float |
getCornerRadius()
Returns corner radius of component.
|
org.joml.Vector4f |
getFocusedStrokeColor()
Returns
Vector4f focused stroke color vector where x,y,z,w mapped to r,g,b,a values. |
Intersector |
getIntersector()
Returns component intersector which used to check if cursor intersect component or not.
|
ListenerMap |
getListenerMap()
Returns event listeners for component instance.
|
java.util.Map<java.lang.String,java.lang.Object> |
getMetadata()
Returns component metadata.
|
Component |
getParent()
Returns parent component.
|
org.joml.Vector2f |
getPosition()
Returns position vector.
|
org.joml.Vector2f |
getSize()
Returns size vector of component.
|
Tooltip |
getTooltip()
Returns tooltip if it persist.
|
int |
hashCode() |
boolean |
intersects(org.joml.Vector2f point)
Used to determine if point intersects component (in screen space).
|
boolean |
isEmpty()
Returns true if layerFrame contains no elements.
|
boolean |
isEnabled()
Returns true if component enabled.
|
boolean |
isFocused()
Returns true if component is focused.
|
boolean |
isHovered()
Returns true if component is hovered.
|
boolean |
isPressed()
Returns true if component is pressed.
|
boolean |
isVisible()
Returns true if component visible.
|
java.util.stream.Stream<T> |
parallelStream()
Returns a possibly parallel Stream with this collection as its source.
|
boolean |
remove(T component)
Used to remove component.
|
void |
removeAll(java.util.Collection<? extends T> components)
Used to remove components.
|
boolean |
removeIf(java.util.function.Predicate<? super T> filter)
Removes all of the elements of this layerFrame that satisfy the given predicate.
|
void |
setBackgroundColor(float r,
float g,
float b,
float a)
Used to set background color vector.
|
void |
setBackgroundColor(org.joml.Vector4f backgroundColor)
Used to set background color vector where x,y,z,w mapped to r,g,b,a values.
|
void |
setBorder(Border border)
Used to set border for component.
|
void |
setCornerRadius(float cornerRadius)
Used to set corner radius.
|
void |
setEnabled(boolean enabled)
Used to enable or disable component.
|
void |
setFocused(boolean focused)
Used to make component focused or not.
|
void |
setFocusedStrokeColor(float r,
float g,
float b,
float a)
Used to set focused stroke color vector.
|
void |
setFocusedStrokeColor(org.joml.Vector4f focusedStrokeColor)
Used to set focused stroke color vector where x,y,z,w mapped to r,g,b,a values.
|
void |
setHovered(boolean hovered)
Used to make component hovered or not.
|
void |
setIntersector(Intersector intersector)
Used to set intersector for component.
|
void |
setListenerMap(ListenerMap listenerMap)
Used to set event listener map for component.
|
void |
setParent(Component parent)
Used to set parent component.
|
void |
setPosition(float x,
float y)
Used to set current position.
|
void |
setPosition(org.joml.Vector2f position)
Used to set position of component.
|
void |
setPressed(boolean pressed)
Used to make component pressed or not.
|
void |
setSize(float width,
float height)
Used to set size vector.
|
void |
setSize(org.joml.Vector2f size)
Used to set size vector.
|
void |
setTooltip(Tooltip tooltip)
Used to set tooltip to component.
|
void |
setVisible(boolean visible)
Used to make component visible or invisible.
|
java.util.stream.Stream<T> |
stream()
Returns a sequential Stream with this collection as its source.
|
java.lang.String |
toString() |
public Component()
Also if you want to make it easy to use with Json marshaller/unmarshaller component should contain empty constructor.
public Component(float x, float y, float width, float height)
x
- x position position in parent component.y
- y position position in parent component.width
- width of component.height
- height of component.public Component(org.joml.Vector2f position, org.joml.Vector2f size)
position
- position position in parent component.size
- size of component.public Component getParent()
public void setParent(Component parent)
Don't use this method if you want to attach component to container. In this case use add(Component)
method.
parent
- component container.public ListenerMap getListenerMap()
public void setListenerMap(ListenerMap listenerMap)
listenerMap
- map of event listeners.public org.joml.Vector2f getPosition()
public void setPosition(org.joml.Vector2f position)
position
- new position for component.public void setPosition(float x, float y)
x
- x position relative to parent component.y
- y position relative to parent component.public org.joml.Vector2f getSize()
Vector2f size = component.getSize();
float width = size.x;
float height = size.y;
public void setSize(org.joml.Vector2f size)
size
- size vector.public void setSize(float width, float height)
width
- width to set.height
- height to set.public org.joml.Vector2f getAbsolutePosition()
public org.joml.Vector4f getBackgroundColor()
Vector4f
background color vector where x,y,z,w mapped to r,g,b,a values. public void setBackgroundColor(org.joml.Vector4f backgroundColor)
backgroundColor
- background color vector.public void setBackgroundColor(float r, float g, float b, float a)
r
- red value.g
- green value.b
- blue value.a
- alpha value.public org.joml.Vector4f getFocusedStrokeColor()
Vector4f
focused stroke color vector where x,y,z,w mapped to r,g,b,a values. public void setFocusedStrokeColor(org.joml.Vector4f focusedStrokeColor)
focusedStrokeColor
- focused stroke color vector.public void setFocusedStrokeColor(float r, float g, float b, float a)
r
- red value.g
- green value.b
- blue value.a
- alpha value.public boolean isEnabled()
Boolean.TRUE
.public void setEnabled(boolean enabled)
enabled
- flag to set.public boolean isVisible()
Boolean.TRUE
.public void setVisible(boolean visible)
visible
- flag to set.public boolean intersects(org.joml.Vector2f point)
point
- point to check.public Intersector getIntersector()
public void setIntersector(Intersector intersector)
intersector
- intersector.public java.util.Map<java.lang.String,java.lang.Object> getMetadata()
public Border getBorder()
public void setBorder(Border border)
border
- border.public float getCornerRadius()
public void setCornerRadius(float cornerRadius)
cornerRadius
- corner radius.public boolean isHovered()
public void setHovered(boolean hovered)
hovered
- new hovered value.public boolean isFocused()
public void setFocused(boolean focused)
focused
- new hovered value.public boolean isPressed()
public void setPressed(boolean pressed)
pressed
- new hovered value.public Tooltip getTooltip()
public void setTooltip(Tooltip tooltip)
tooltip
- tooltip to set.public int count()
List.size()
public boolean isEmpty()
List.isEmpty()
public boolean contains(T component)
component
- component to check.List.contains(Object)
public java.util.Iterator<T> containerIterator()
List.iterator()
public boolean add(T component)
component
- component to add.List.add(Object)
public boolean addAll(java.util.Collection<? extends T> components)
components
- components nodes to add.List.addAll(Collection)
public boolean remove(T component)
component
- component to remove.List.remove(Object)
public void removeAll(java.util.Collection<? extends T> components)
components
- components to remove.List.removeAll(Collection)
public boolean removeIf(java.util.function.Predicate<? super T> filter)
filter
- a predicate which returns true for elements to be removed.Collection.removeIf(Predicate)
public void clearChilds()
List.clear()
public boolean containsAll(java.util.Collection<T> components)
components
- components collection to check.List.containsAll(Collection)
public java.util.stream.Stream<T> stream()
Collection.stream()
public java.util.stream.Stream<T> parallelStream()
Collection.parallelStream()
public void forEach(java.util.function.Consumer<? super T> action)
action
- The action to be performed for each element.public java.util.List<T> getChilds()
List
.
NOTE: this method returns NEW List
of components.
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object