org.netbeans.api.visual 2.10

org.netbeans.api.visual.widget
Class Scene

java.lang.Object
  extended by org.netbeans.api.visual.widget.Widget
      extended by org.netbeans.api.visual.widget.Scene
All Implemented Interfaces:
Accessible
Direct Known Subclasses:
ObjectScene

public class Scene
extends Widget

The scene is a widget which also controls and represents whole rendered area.

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
static interface Scene.SceneListener
          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
Scene()
          Creates a scene.
 
Method Summary
 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.
 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.
 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 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.
 
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, notifyRemoved, notifyStateChanged, paint, paintBackground, paintBorder, paintChildren, paintWidget, removeChild, removeChildren, removeChildren, removeDependency, removeFromParent, repaint, resolveBounds, revalidate, revalidate, setAccessibleContext, setBackground, setBorder, setBorder, setCheckClipping, setChildConstraint, setCursor, setEnabled, setFont, setForeground, setLayout, setMaximumSize, setMinimumSize, setOpaque, setPreferredBounds, setPreferredLocation, setPreferredSize, setState, setToolTipText, setVisible
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Scene

public Scene()
Creates a scene.

Method Detail

createView

public JComponent 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

public JComponent getView()
Returns an instance of created view

Returns:
the instance of created view; null if no view is created yet

createSatelliteView

public JComponent createSatelliteView()
Creates a satellite view.

Returns:
the satellite view

createBirdView

public BirdViewController createBirdView()
Creates a bird view with specific zoom factor.

Returns:
the bird view controller
Since:
2.7

getGraphics

public final Graphics2D getGraphics()
Returns an instance of Graphics2D which is used for calculating boundaries and rendering all widgets in the scene.

Overrides:
getGraphics in class Widget
Returns:
the instance of Graphics2D

validate

public final void validate(Graphics2D graphics)
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

public final void paint(Graphics2D graphics)
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

public final Rectangle getMaximumBounds()
Returns maximum bounds of the scene.

Returns:
the maximum bounds

setMaximumBounds

public final void setMaximumBounds(Rectangle maximumBounds)
Sets maximum bounds of the scene.

Parameters:
maximumBounds - the non-null maximum bounds

getDefaultFont

public Font getDefaultFont()
Returns a default font of the scene.

Returns:
the default font

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 class Widget
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 class Widget
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

public final EventProcessingType getKeyEventProcessingType()
Returns a key events processing type of the scene.

Returns:
the processing type for key events

setKeyEventProcessingType

public final void setKeyEventProcessingType(EventProcessingType keyEventProcessingType)
Sets a key events processing type of the scene.

Parameters:
keyEventProcessingType - the processing type for key events

getPriorActions

public final WidgetAction.Chain 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

public final Widget getFocusedWidget()
Returns a focused widget of the scene.

Returns:
the focused widget; null if no widget is focused

setFocusedWidget

public final void setFocusedWidget(Widget focusedWidget)
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

public final SceneAnimator getSceneAnimator()
Returns a scene animator of the scene.

Returns:
the scene animator

getLookFeel

public final LookFeel getLookFeel()
Returns a look'n'feel of the scene.

Returns:
the look'n'feel

setLookFeel

public final void setLookFeel(LookFeel lookFeel)
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

public final InputBindings getInputBindings()
Returns input bindings of the scene.

Returns:
the input bindings
Since:
2.4

getActiveTool

public final String 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

public void setActiveTool(String activeTool)
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

public final void addSceneListener(Scene.SceneListener listener)
Registers a scene listener.

Parameters:
listener - the scene listener

removeSceneListener

public final void removeSceneListener(Scene.SceneListener listener)
Unregisters a scene listener.

Parameters:
listener - the scene listener

convertSceneToView

public final Point convertSceneToView(Point sceneLocation)
Converts a location in the scene coordination system to the view coordination system.

Parameters:
sceneLocation - the scene location
Returns:
the view location

convertSceneToView

public final Rectangle convertSceneToView(Rectangle sceneRectangle)
Converts a rectangle in the scene coordination system to the view coordination system.

Parameters:
sceneRectangle - the scene rectangle
Returns:
the view rectangle

convertViewToScene

public Point convertViewToScene(Point viewLocation)
Converts a location in the view coordination system to the scene coordination system.

Parameters:
viewLocation - the view location
Returns:
the scene location

createWidgetHoverAction

public WidgetAction createWidgetHoverAction()
Creates a widget-specific hover action.

Returns:
the widget-specific hover action

org.netbeans.api.visual 2.10

Built on May 30 2008.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.