Class Parent
java.lang.Object
io.github.somesourcecode.someguiapi.scene.Node
io.github.somesourcecode.someguiapi.scene.Parent
- Direct Known Subclasses:
Region
The base class for all nodes that can have children.
This class handles all hierarchy-related operations, such as adding and removing child nodes, layout and rendering.
- Since:
- 1.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the background of this parent.protected ObservableList<Node>Returns the list of children of this parent.booleanReturns whether this parent is the root of a scene.final voidlayout()Recursively applies the layout to all children and itself.protected voidFinds thisNodeor the first sub-node by the given selector.Used by Node and Parent to traverse the scene graph to find all nodes that match the given selector.booleanReturns whether this parent needs a layout update.nodeAt(int x, int y) Returns the node at the given coordinates.renderPixelAt(int x, int y) Returns aPixelthat should be rendered at the given coordinates.voidRequests a layout update for this parent.voidsetBackground(Background background) Sets the background of this parent.Methods inherited from class io.github.somesourcecode.someguiapi.scene.Node
getHeight, getId, getLayoutX, getLayoutY, getOnClick, getOnHotBarClick, getOnLeftClick, getOnRightClick, getOnShiftClick, getParent, getScene, getTranslateX, getTranslateY, getWidth, isClipping, isVisible, lookupAll, relocate, requestParentLayout, setClipping, setId, setLayoutX, setLayoutY, setOnClick, setOnHotBarClick, setOnLeftClick, setOnRightClick, setOnShiftClick, setTranslateX, setTranslateY, setVisible
-
Constructor Details
-
Parent
protected Parent()Constructs a new parent node.- Since:
- 1.0.0
-
-
Method Details
-
getChildren
Returns the list of children of this parent.- Returns:
- the list of children
- Since:
- 1.0.0
-
isSceneRoot
public boolean isSceneRoot()Returns whether this parent is the root of a scene.- Returns:
- whether this parent is the root of a scene
- Since:
- 2.0.0
-
lookup
Description copied from class:NodeFinds thisNodeor the first sub-node by the given selector.For example, to find a node with the id "my-node", the method can be used like this:
scene.lookup("#my-node"). -
lookupAll
Used by Node and Parent to traverse the scene graph to find all nodes that match the given selector.Note: This method should never create the result set. That should be done by the Node class implementation.
-
requestLayout
public void requestLayout()Requests a layout update for this parent. Layout will be applied on the next layout pass.- Since:
- 2.0.0
-
needsLayout
public boolean needsLayout()Returns whether this parent needs a layout update.- Returns:
- whether this parent needs a layout update
- Since:
- 2.0.0
- See Also:
-
layout
public final void layout()Recursively applies the layout to all children and itself.- Since:
- 1.0.0
-
layoutChildren
protected void layoutChildren() -
getBackground
Returns the background of this parent.- Returns:
- the background
- Since:
- 1.0.0
-
setBackground
Sets the background of this parent. It will be rendered behind all children.- Parameters:
background- the new background- Since:
- 1.0.0
-
renderPixelAt
Description copied from class:NodeReturns aPixelthat should be rendered at the given coordinates. The coordinates are relative to this parent's bounds.- Specified by:
renderPixelAtin classNode- Parameters:
x- the x coordinatey- the y coordinate- Returns:
- the pixel at the given coordinates, or null if there is no pixel at the given coordinates
-
nodeAt
Description copied from class:NodeReturns the node at the given coordinates. The coordinates are relative to this parent's bounds.
-