-
public class Scene<T extends ComponentView>
Baseclass for BGW scenes.
-
-
Field Summary
Fields Modifier and Type Field Description private final DynamicComponentView
draggedComponent
private final RootComponent<T>
rootNode
private final Double
width
private final Double
height
private Visual
background
private final List<T>
components
private Double
opacity
private Function1<KeyEvent, Unit>
onKeyPressed
private Function1<KeyEvent, Unit>
onKeyReleased
private Function1<KeyEvent, Unit>
onKeyTyped
-
Method Summary
Modifier and Type Method Description final DynamicComponentView
getDraggedComponent()
final RootComponent<T>
getRootNode()
The root node of this Scene. final Double
getWidth()
The width of this Scene in virtual coordinates. final Double
getHeight()
The height of this Scene in virtual coordinates. final Visual
getBackground()
final Unit
setBackground(Visual background)
final List<T>
getComponents()
final Double
getOpacity()
final Unit
setOpacity(Double opacity)
final Function1<KeyEvent, Unit>
getOnKeyPressed()
Gets invoked with a KeyEvent whenever a key is pressed. final Unit
setOnKeyPressed(Function1<KeyEvent, Unit> onKeyPressed)
Gets invoked with a KeyEvent whenever a key is pressed. final Function1<KeyEvent, Unit>
getOnKeyReleased()
Gets invoked with a KeyEvent whenever a key is released. final Unit
setOnKeyReleased(Function1<KeyEvent, Unit> onKeyReleased)
Gets invoked with a KeyEvent whenever a key is released. final Function1<KeyEvent, Unit>
getOnKeyTyped()
Gets invoked with a KeyEvent whenever a key is typed. final Unit
setOnKeyTyped(Function1<KeyEvent, Unit> onKeyTyped)
Gets invoked with a KeyEvent whenever a key is typed. final Unit
addComponents(T components)
Adds all given ComponentViews to the root node and rootComponents list. final Unit
removeComponents(T components)
Removes all given ComponentViews from the root node and rootComponents list. final Unit
clearComponents()
Removes all ComponentViews from the root node and rootComponents list. final Unit
playAnimation(Animation animation)
Plays given Animation. final List<ComponentView>
findPathToChild(ComponentView node)
Searches node recursively through the visual tree and logs path where the node appears as first component and the rootNode as last. -
-
Method Detail
-
getDraggedComponent
final DynamicComponentView getDraggedComponent()
-
getRootNode
final RootComponent<T> getRootNode()
The root node of this Scene.
Use it to compare the parent Property of any ComponentView to find out whether it was directly added to the Scene.
-
getBackground
final Visual getBackground()
-
setBackground
final Unit setBackground(Visual background)
-
getComponents
final List<T> getComponents()
-
getOpacity
final Double getOpacity()
-
setOpacity
final Unit setOpacity(Double opacity)
-
getOnKeyPressed
final Function1<KeyEvent, Unit> getOnKeyPressed()
Gets invoked with a KeyEvent whenever a key is pressed.
-
setOnKeyPressed
final Unit setOnKeyPressed(Function1<KeyEvent, Unit> onKeyPressed)
Gets invoked with a KeyEvent whenever a key is pressed.
-
getOnKeyReleased
final Function1<KeyEvent, Unit> getOnKeyReleased()
Gets invoked with a KeyEvent whenever a key is released.
-
setOnKeyReleased
final Unit setOnKeyReleased(Function1<KeyEvent, Unit> onKeyReleased)
Gets invoked with a KeyEvent whenever a key is released.
-
getOnKeyTyped
final Function1<KeyEvent, Unit> getOnKeyTyped()
Gets invoked with a KeyEvent whenever a key is typed. Gets invoked after onKeyPressed.
-
setOnKeyTyped
final Unit setOnKeyTyped(Function1<KeyEvent, Unit> onKeyTyped)
Gets invoked with a KeyEvent whenever a key is typed. Gets invoked after onKeyPressed.
-
addComponents
final Unit addComponents(T components)
Adds all given ComponentViews to the root node and rootComponents list.
- Parameters:
components
- Components to add.
-
removeComponents
final Unit removeComponents(T components)
Removes all given ComponentViews from the root node and rootComponents list.
- Parameters:
components
- Components to remove.
-
clearComponents
final Unit clearComponents()
Removes all ComponentViews from the root node and rootComponents list.
-
playAnimation
final Unit playAnimation(Animation animation)
Plays given Animation.
- Parameters:
animation
- Animation to play.
-
findPathToChild
final List<ComponentView> findPathToChild(ComponentView node)
Searches node recursively through the visual tree and logs path where the node appears as first component and the rootNode as last.
- Parameters:
node
- Child to find.
-
-
-
-