Class Scene

java.lang.Object
org.netbeans.api.visual.widget.Widget
org.netbeans.api.visual.widget.Scene
All Implemented Interfaces:
Accessible, org.openide.util.Lookup.Provider
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.

  • Constructor Details

    • Scene

      public Scene()
      Creates a scene.
  • Method Details

    • 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 Rectangle convertViewToScene(Rectangle viewRect)
      Converts a rectangle in the view coordination system into the scene one. It is just the inverse fiunction to convertSceneToView(java.awt.Rectangle).
      Parameters:
      viewRect - the rectangle, in view coordinates
      Returns:
      the same rectangle, in scene coordinates
      Since:
      2.49
    • 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
    • setResourceTable

      public void setResourceTable(ResourceTable table)
      Description copied from class: Widget
      Sets the resource table.
      Overrides:
      setResourceTable in class Widget
      Parameters:
      table - The widgets resource table.
    • getResourceTable

      public ResourceTable 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 class Widget
      Returns:
      The resource table.