public class Scene extends Widget
After all changes in a scene is done, the validate method have to be called for validating changed and calculating new locations and boundaries of all modified widgets.
The scene allows to create a view JComponent which can be used anywhere in Swing based application. Only one view can be created using the createView method. The scene allows to create multiple satellite views using the createSatelliteView method. The satellite view is just showing the scene and allows quick navigator and panning using a mouse.
The scene contains additional scene-specific properties like lookFeel, activeTool, defaultFont, animator.
It is able to create a widget-specific hover action.
Modifier and Type | Class and Description |
---|---|
static interface |
Scene.SceneListener
The scene listener which is notified about repainting, validating progress.
|
Widget.Dependency
Constructor and Description |
---|
Scene()
Creates a scene.
|
Modifier and Type | Method and Description |
---|---|
void |
addSceneListener(Scene.SceneListener listener)
Registers a scene listener.
|
Point |
convertSceneToView(Point sceneLocation)
Converts a location in the scene coordination system to the view coordination system.
|
Rectangle |
convertSceneToView(Rectangle sceneRectangle)
Converts a rectangle in the scene coordination system to the view coordination system.
|
Point |
convertViewToScene(Point viewLocation)
Converts a location in the view coordination system to the scene coordination system.
|
Rectangle |
convertViewToScene(Rectangle viewRect)
Converts a rectangle in the view coordination system into the scene one.
|
BirdViewController |
createBirdView()
Creates a bird view with specific zoom factor.
|
JComponent |
createSatelliteView()
Creates a satellite view.
|
JComponent |
createView()
Creates a view.
|
WidgetAction |
createWidgetHoverAction()
Creates a widget-specific hover action.
|
String |
getActiveTool()
Returns an active tool of the scene.
|
Font |
getDefaultFont()
Returns a default font of the scene.
|
Widget |
getFocusedWidget()
Returns a focused widget of the scene.
|
Graphics2D |
getGraphics()
Returns an instance of Graphics2D which is used for calculating boundaries and rendering all widgets in the scene.
|
InputBindings |
getInputBindings()
Returns input bindings of the scene.
|
EventProcessingType |
getKeyEventProcessingType()
Returns a key events processing type of the scene.
|
LookFeel |
getLookFeel()
Returns a look'n'feel of the scene.
|
Rectangle |
getMaximumBounds()
Returns maximum bounds of the scene.
|
WidgetAction.Chain |
getPriorActions()
Returns a prior actions.
|
ResourceTable |
getResourceTable()
Retreives the widgets resource table.
|
SceneAnimator |
getSceneAnimator()
Returns a scene animator of the scene.
|
JComponent |
getView()
Returns an instance of created view
|
double |
getZoomFactor()
Returns a zoom factor.
|
protected boolean |
isRepaintRequiredForRevalidating()
Returns whether the layer widget requires to repainted after revalidation.
|
boolean |
isValidated()
Returns whether the whole scene is validated and there is no widget or region that has to be revalidated.
|
void |
paint(Graphics2D graphics)
Paints the whole scene into the graphics instance.
|
void |
removeSceneListener(Scene.SceneListener listener)
Unregisters a scene listener.
|
void |
setActiveTool(String activeTool)
Sets an active tool.
|
void |
setFocusedWidget(Widget focusedWidget)
Sets a focused widget of the scene.
|
void |
setKeyEventProcessingType(EventProcessingType keyEventProcessingType)
Sets a key events processing type of the scene.
|
void |
setLookFeel(LookFeel lookFeel)
Sets a look'n'feel of the scene.
|
void |
setMaximumBounds(Rectangle maximumBounds)
Sets maximum bounds of the scene.
|
void |
setResourceTable(ResourceTable table)
Sets the resource table.
|
void |
setZoomFactor(double zoomFactor)
Sets a zoom factor for the scene.
|
void |
validate()
Validates all widget in the whole scene.
|
void |
validate(Graphics2D graphics)
This method invokes Scene.validate method with a specific Graphics2D instance.
|
addChild, addChild, addChild, addChild, addChildren, addDependency, bringToBack, bringToFront, calculateClientArea, convertLocalToScene, convertLocalToScene, convertSceneToLocal, convertSceneToLocal, createActions, equals, getAccessibleContext, getActions, getActions, getBackground, getBorder, getBounds, getChildConstraint, getChildren, getClientArea, getCursor, getCursorAt, getDependencies, getFont, getForeground, getLayout, getLocation, getLookup, getMaximumSize, getMinimumSize, getParentWidget, getPreferredBounds, getPreferredLocation, getPreferredSize, getScene, getState, getToolTipText, hashCode, isCheckClipping, isEnabled, isHitAt, isOpaque, isPreferredBoundsSet, isVisible, notifyAdded, notifyBackgroundChanged, notifyFontChanged, notifyForegroundChanged, notifyRemoved, notifyStateChanged, paint, paintBackground, paintBorder, paintChildren, paintWidget, removeChild, removeChildren, removeChildren, removeDependency, removeFromParent, repaint, resolveBounds, revalidate, revalidate, setAccessibleContext, setBackground, setBackgroundFromResource, setBorder, setBorder, setCheckClipping, setChildConstraint, setCursor, setEnabled, setFont, setFontFromResource, setForeground, setForegroundFromResource, setLayout, setMaximumSize, setMinimumSize, setOpaque, setPreferredBounds, setPreferredLocation, setPreferredSize, setState, setToolTipText, setVisible, updateResources
public JComponent createView()
public JComponent getView()
public JComponent createSatelliteView()
public BirdViewController createBirdView()
public final Graphics2D getGraphics()
getGraphics
in class Widget
public final void validate(Graphics2D graphics)
Note: Do not call this method unless you know the consequences. The scene is going to be validated using the specified Graphics2D instance even after the method call therefore it may break scene layout when your main scene view is finally created and shown.
graphics
- the graphics instance used for validationpublic final void paint(Graphics2D graphics)
graphics
- the Graphics2D instance where the scene is going to be paintedpublic final Rectangle getMaximumBounds()
public final void setMaximumBounds(Rectangle maximumBounds)
maximumBounds
- the non-null maximum boundspublic Font getDefaultFont()
public boolean isValidated()
isValidated
in class Widget
protected boolean isRepaintRequiredForRevalidating()
isRepaintRequiredForRevalidating
in class Widget
public final void validate()
public final EventProcessingType getKeyEventProcessingType()
public final void setKeyEventProcessingType(EventProcessingType keyEventProcessingType)
keyEventProcessingType
- the processing type for key eventspublic final WidgetAction.Chain getPriorActions()
public final Widget getFocusedWidget()
public final void setFocusedWidget(Widget focusedWidget)
focusedWidget
- the focused widget; if null, then the scene itself is taken as the focused widgetpublic final double getZoomFactor()
public final void setZoomFactor(double zoomFactor)
zoomFactor
- the zoom factorpublic final SceneAnimator getSceneAnimator()
public final LookFeel getLookFeel()
public final void setLookFeel(LookFeel lookFeel)
lookFeel
- the look'n'feelpublic final InputBindings getInputBindings()
public final String getActiveTool()
public void setActiveTool(String activeTool)
activeTool
- the active tool; if null, then the active tool is unset and only default action chain of widgets will be usedpublic final void addSceneListener(Scene.SceneListener listener)
listener
- the scene listenerpublic final void removeSceneListener(Scene.SceneListener listener)
listener
- the scene listenerpublic final Point convertSceneToView(Point sceneLocation)
sceneLocation
- the scene locationpublic final Rectangle convertSceneToView(Rectangle sceneRectangle)
sceneRectangle
- the scene rectanglepublic Rectangle convertViewToScene(Rectangle viewRect)
Scene.convertSceneToView(java.awt.Rectangle)
.viewRect
- the rectangle, in view coordinatespublic Point convertViewToScene(Point viewLocation)
viewLocation
- the view locationpublic WidgetAction createWidgetHoverAction()
public void setResourceTable(ResourceTable table)
Widget
setResourceTable
in class Widget
table
- The widgets resource table.public ResourceTable getResourceTable()
Widget
getResourceTable
in class Widget