Class Scene
- All Implemented Interfaces:
Accessible
,org.openide.util.Lookup.Provider
- Direct Known Subclasses:
ObjectScene
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
The scene listener which is notified about repainting, validating progress.Nested classes/interfaces inherited from class org.netbeans.api.visual.widget.Widget
Widget.Dependency
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addSceneListener
(Scene.SceneListener listener) Registers a scene listener.final Point
convertSceneToView
(Point sceneLocation) Converts a location in the scene coordination system to the view coordination system.final Rectangle
convertSceneToView
(Rectangle sceneRectangle) Converts a rectangle in the scene coordination system to the view coordination system.convertViewToScene
(Point viewLocation) Converts a location in the view coordination system to the scene coordination system.convertViewToScene
(Rectangle viewRect) Converts a rectangle in the view coordination system into the scene one.Creates a bird view with specific zoom factor.Creates a satellite view.Creates a view.Creates a widget-specific hover action.final String
Returns an active tool of the scene.Returns a default font of the scene.final Widget
Returns a focused widget of the scene.final Graphics2D
Returns an instance of Graphics2D which is used for calculating boundaries and rendering all widgets in the scene.final InputBindings
Returns input bindings of the scene.final EventProcessingType
Returns a key events processing type of the scene.final LookFeel
Returns a look'n'feel of the scene.final Rectangle
Returns maximum bounds of the scene.final WidgetAction.Chain
Returns a prior actions.Retreives the widgets resource table.final SceneAnimator
Returns a scene animator of the scene.getView()
Returns an instance of created viewfinal double
Returns a zoom factor.protected boolean
Returns whether the layer widget requires to repainted after revalidation.boolean
Returns whether the whole scene is validated and there is no widget or region that has to be revalidated.final void
paint
(Graphics2D graphics) Paints the whole scene into the graphics instance.final void
removeSceneListener
(Scene.SceneListener listener) Unregisters a scene listener.void
setActiveTool
(String activeTool) Sets an active tool.final void
setFocusedWidget
(Widget focusedWidget) Sets a focused widget of the scene.final void
setKeyEventProcessingType
(EventProcessingType keyEventProcessingType) Sets a key events processing type of the scene.final void
setLookFeel
(LookFeel lookFeel) Sets a look'n'feel of the scene.final void
setMaximumBounds
(Rectangle maximumBounds) Sets maximum bounds of the scene.void
setResourceTable
(ResourceTable table) Sets the resource table.final void
setZoomFactor
(double zoomFactor) Sets a zoom factor for the scene.final void
validate()
Validates all widget in the whole scene.final void
validate
(Graphics2D graphics) This method invokes Scene.validate method with a specific Graphics2D instance.Methods inherited from class org.netbeans.api.visual.widget.Widget
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
-
Constructor Details
-
Scene
public Scene()Creates a scene.
-
-
Method Details
-
createView
Creates a view. This method could be called once only. Call the getView method for getting created instance of a view.- Returns:
- the created view
-
getView
Returns an instance of created view- Returns:
- the instance of created view; null if no view is created yet
-
createSatelliteView
-
createBirdView
Creates a bird view with specific zoom factor.- Returns:
- the bird view controller
- Since:
- 2.7
-
getGraphics
Returns an instance of Graphics2D which is used for calculating boundaries and rendering all widgets in the scene.- Overrides:
getGraphics
in classWidget
- Returns:
- the instance of Graphics2D
-
validate
This method invokes Scene.validate method with a specific Graphics2D instance. This is useful for rendering a scene off-screen without creating and showning the main scene view. See test.view.OffscreenRenderingTest example for usages.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.
- Parameters:
graphics
- the graphics instance used for validation- Since:
- 2.7
-
paint
Paints the whole scene into the graphics instance. The method calls validate before rendering.- Parameters:
graphics
- the Graphics2D instance where the scene is going to be painted
-
getMaximumBounds
Returns maximum bounds of the scene.- Returns:
- the maximum bounds
-
setMaximumBounds
Sets maximum bounds of the scene.- Parameters:
maximumBounds
- the non-null maximum bounds
-
getDefaultFont
-
isValidated
public boolean isValidated()Returns whether the whole scene is validated and there is no widget or region that has to be revalidated.- Overrides:
isValidated
in classWidget
- Returns:
- true, if the whole scene is validated
-
isRepaintRequiredForRevalidating
protected boolean isRepaintRequiredForRevalidating()Returns whether the layer widget requires to repainted after revalidation.- Overrides:
isRepaintRequiredForRevalidating
in classWidget
- Returns:
- always false
-
validate
public final void validate()Validates all widget in the whole scene. The validation is done repeatively until there is no invalid widget in the scene after validating process. It also schedules invalid regions in the view for repainting. -
getKeyEventProcessingType
Returns a key events processing type of the scene.- Returns:
- the processing type for key events
-
setKeyEventProcessingType
Sets a key events processing type of the scene.- Parameters:
keyEventProcessingType
- the processing type for key events
-
getPriorActions
Returns a prior actions. These actions are executed before any other action in the scene. If any of these actions consumes an event that the event processsing is stopped. Action locking is ignored.- Returns:
- the prior actions
-
getFocusedWidget
Returns a focused widget of the scene.- Returns:
- the focused widget; null if no widget is focused
-
setFocusedWidget
Sets a focused widget of the scene.- Parameters:
focusedWidget
- the focused widget; if null, then the scene itself is taken as the focused widget
-
getZoomFactor
public final double getZoomFactor()Returns a zoom factor.- Returns:
- the zoom factor
-
setZoomFactor
public final void setZoomFactor(double zoomFactor) Sets a zoom factor for the scene.- Parameters:
zoomFactor
- the zoom factor
-
getSceneAnimator
Returns a scene animator of the scene.- Returns:
- the scene animator
-
getLookFeel
-
setLookFeel
Sets a look'n'feel of the scene. This method does affect current state of the scene - already created components will not be refreshed.- Parameters:
lookFeel
- the look'n'feel
-
getInputBindings
Returns input bindings of the scene.- Returns:
- the input bindings
- Since:
- 2.4
-
getActiveTool
Returns an active tool of the scene.- Returns:
- the active tool; if null, then only default action chain of widgets will be used
-
setActiveTool
Sets an active tool.- Parameters:
activeTool
- the active tool; if null, then the active tool is unset and only default action chain of widgets will be used
-
addSceneListener
Registers a scene listener.- Parameters:
listener
- the scene listener
-
removeSceneListener
Unregisters a scene listener.- Parameters:
listener
- the scene listener
-
convertSceneToView
-
convertSceneToView
-
convertViewToScene
Converts a rectangle in the view coordination system into the scene one. It is just the inverse fiunction toconvertSceneToView(java.awt.Rectangle)
.- Parameters:
viewRect
- the rectangle, in view coordinates- Returns:
- the same rectangle, in scene coordinates
- Since:
- 2.49
-
convertViewToScene
-
createWidgetHoverAction
Creates a widget-specific hover action.- Returns:
- the widget-specific hover action
-
setResourceTable
Description copied from class:Widget
Sets the resource table.- Overrides:
setResourceTable
in classWidget
- Parameters:
table
- The widgets resource table.
-
getResourceTable
Description copied from class:Widget
Retreives the widgets resource table. If the widgets resource table is not set then the widgets parent resource table it retrieved.- Overrides:
getResourceTable
in classWidget
- Returns:
- The resource table.
-