com.sun.scenario.scenegraph
Class SGNode

java.lang.Object
  extended by com.sun.scenario.scenegraph.SGNode
Direct Known Subclasses:
SGLeaf, SGParent

public abstract class SGNode
extends java.lang.Object

Base class for scene graph nodes. Nodes define a "local" coordinate system like the one used by AWT/Swing: x increases to the right, y increases downwards.


Constructor Summary
SGNode()
           
 
Method Summary
 void addFocusListener(SGFocusListener listener)
           
 void addKeyListener(SGKeyListener listener)
           
 void addMouseListener(SGMouseListener listener)
           
 void addNodeListener(SGNodeListener listener)
           
 boolean contains(java.awt.geom.Point2D point)
          Returns true if the given point (specified in the local/untransformed coordinate space of this node) is contained within the visual bounds of this node.
 java.lang.Object getAttribute(java.lang.String key)
           
 java.awt.geom.Rectangle2D getBounds()
          Returns the bounding box of this node in the coordinate space inherited from the parent.
abstract  java.awt.geom.Rectangle2D getBounds(java.awt.geom.AffineTransform transform)
          Returns the bounding box of this node relative to the specified coordinate space.
 java.lang.String getID()
           
 JSGPanel getPanel()
           
 SGParent getParent()
           
 java.awt.geom.Point2D globalToLocal(java.awt.geom.Point2D global, java.awt.geom.Point2D local)
          Transforms a point from the global coordinate system of the root node (typically a JSGPanel) into the local coordinate space of this SGNode.
 boolean isVisible()
           
 java.awt.geom.Point2D localToGlobal(java.awt.geom.Point2D local, java.awt.geom.Point2D global)
          Transforms a point from the local coordinate space of this SGNode into the global coordinate system of the root node (typically a JSGPanel).
 java.util.List<SGNode> pick(java.awt.geom.Point2D p)
          Returns a list of the visible nodes that overlap the specified point in the same order they'd be considered for event dispatching, topmost leaf first.
 void putAttribute(java.lang.String key, java.lang.Object value)
           
 void removeFocusListener(SGFocusListener listener)
           
 void removeKeyListener(SGKeyListener listener)
           
 void removeMouseListener(SGMouseListener listener)
           
 void removeNodeListener(SGNodeListener listener)
           
 void requestFocus()
           
 void setID(java.lang.String id)
           
 void setVisible(boolean visible)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SGNode

public SGNode()
Method Detail

isVisible

public final boolean isVisible()

setVisible

public void setVisible(boolean visible)

getID

public final java.lang.String getID()

setID

public final void setID(java.lang.String id)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getParent

public SGParent getParent()

getPanel

public JSGPanel getPanel()

getBounds

public final java.awt.geom.Rectangle2D getBounds()
Returns the bounding box of this node in the coordinate space inherited from the parent. This is a convenience method, equivalent to calling getBounds(null).


getBounds

public abstract java.awt.geom.Rectangle2D getBounds(java.awt.geom.AffineTransform transform)
Returns the bounding box of this node relative to the specified coordinate space.

Parameters:
transform - the transform applied to the geometry

globalToLocal

public java.awt.geom.Point2D globalToLocal(java.awt.geom.Point2D global,
                                           java.awt.geom.Point2D local)
Transforms a point from the global coordinate system of the root node (typically a JSGPanel) into the local coordinate space of this SGNode. The global parameter must not be null. If the local parameter is null then a new Point2D object will be created and returned after transforming the point. The global and local parameters may be the same object and the coordinates will be correctly updated with the transformed coordinates.

Parameters:
global - the coordinates in the global coordinate system to be transformed
local - a Point2D object to store the results in
Returns:
a Point2D object containig the transformed coordinates

localToGlobal

public java.awt.geom.Point2D localToGlobal(java.awt.geom.Point2D local,
                                           java.awt.geom.Point2D global)
Transforms a point from the local coordinate space of this SGNode into the global coordinate system of the root node (typically a JSGPanel). The local parameter must not be null. If the global parameter is null then a new Point2D object will be created and returned after transforming the point. The local and global parameters may be the same object and the coordinates will be correctly updated with the transformed coordinates.

Parameters:
local - the coordinates in the local coordinate system to be transformed
global - a Point2D object to store the results in
Returns:
a Point2D object containig the transformed coordinates

contains

public boolean contains(java.awt.geom.Point2D point)
Returns true if the given point (specified in the local/untransformed coordinate space of this node) is contained within the visual bounds of this node. Note that this method does not take visibility into account, the test is based on the node's geometry only.

Parameters:
point - a point in the local coordinate space of this node
Returns:
true if the given point is contained within the visual bounds of this node
Throws:
java.lang.IllegalArgumentException - if point is null

pick

public java.util.List<SGNode> pick(java.awt.geom.Point2D p)
Returns a list of the visible nodes that overlap the specified point in the same order they'd be considered for event dispatching, topmost leaf first. The point p is specified in local coordinates.


addMouseListener

public void addMouseListener(SGMouseListener listener)

removeMouseListener

public void removeMouseListener(SGMouseListener listener)

getAttribute

public final java.lang.Object getAttribute(java.lang.String key)

putAttribute

public final void putAttribute(java.lang.String key,
                               java.lang.Object value)

addNodeListener

public void addNodeListener(SGNodeListener listener)

removeNodeListener

public void removeNodeListener(SGNodeListener listener)

addKeyListener

public void addKeyListener(SGKeyListener listener)

removeKeyListener

public void removeKeyListener(SGKeyListener listener)

addFocusListener

public void addFocusListener(SGFocusListener listener)

removeFocusListener

public void removeFocusListener(SGFocusListener listener)

requestFocus

public final void requestFocus()