Class Background
The set of nodes that can be added to a BranchGroup associated with a Background node is limited. All Group nodes except ViewSpecificGroup are legal in a background geometry branch graph. The only Leaf nodes that are legal are Shape3D (except OrientedShape3D), Morph, Light, and Fog. The presence of any other Leaf node, including OrientedShape3D, or of a ViewSpecificGroup node will cause an IllegalSceneGraphException to be thrown. Note that Link nodes are not allowed; a background geometry branch graph must not reference shared subgraphs. NodeComponent objects can be shared between background branches and ordinary (non-background) branches or among different background branches, however.
Light and Fog nodes in a background geometry branch graph do not affect nodes outside of the background geometry branch graph, and vice versa. Light and Fog nodes that appear in a background geometry branch graph must not be hierarchically scoped to any group node outside of that background geometry branch graph. Conversely, Light and Fog nodes that appear outside of a particular background geometry branch graph must not be hierarchically scoped to any group node in that background geometry branch graph. Any attempt to do so will be ignored.
The influencing bounds of any Light or Fog node in a background geometry branch graph is effectively infinite (meaning that all lights can affect all geometry objects nodes within the background geometry graph, and that an arbitrary fog is selected). An application wishing to limit the scope of a Light or Fog node must use hierarchical scoping.
Picking and collision is ignored for nodes inside a background geometry branch graph.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intSpecifies that the Background allows read access to its application bounds and bounding leaf at runtime.static final intSpecifies that the Background allows write access to its application bounds and bounding leaf at runtime.static final intSpecifies that the Background allows read access to its color at runtime.static final intSpecifies that the Background allows write access to its color at runtime.static final intSpecifies that the Background allows read access to its background geometry at runtime.static final intSpecifies that the Background allows write access to its background geometry at runtime.static final intSpecifies that the Background allows read access to its image at runtime.static final intSpecifies that the Background allows read access to its image scale mode at runtime.static final intSpecifies that the Background allows write access to its image scale mode at runtime.static final intSpecifies that the Background allows write access to its image at runtime.static final intIndicates that the background image is scaled to fit the window.static final intIndicates that the background image is uniformly scaled to fit the window such that the entire window is filled.static final intIndicates that the background image is uniformly scaled to fit the window such that the entire image is visible.static final intIndicates that no scaling of the background image is done.static final intIndicates that the background image is centered in the window and that no scaling of the image is done.static final intIndicates that the background image is tiled to fill the entire window.Fields inherited from class javax.media.j3d.Node
ALLOW_AUTO_COMPUTE_BOUNDS_READ, ALLOW_AUTO_COMPUTE_BOUNDS_WRITE, ALLOW_BOUNDS_READ, ALLOW_BOUNDS_WRITE, ALLOW_COLLIDABLE_READ, ALLOW_COLLIDABLE_WRITE, ALLOW_LOCAL_TO_VWORLD_READ, ALLOW_LOCALE_READ, ALLOW_PARENT_READ, ALLOW_PICKABLE_READ, ALLOW_PICKABLE_WRITE, ENABLE_COLLISION_REPORTING, ENABLE_PICK_REPORTING -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a Background node with default parameters.Background(float r, float g, float b) Constructs a Background node with the specified color.Background(BranchGroup branch) Constructs a Background node with the specified geometry.Background(ImageComponent2D image) Constructs a Background node with the specified image.Background(javax.vecmath.Color3f color) Constructs a Background node with the specified color. -
Method Summary
Modifier and TypeMethodDescriptioncloneNode(boolean forceDuplicate) Creates a new instance of the node.voidduplicateNode(Node originalNode, boolean forceDuplicate) Copies all node information fromoriginalNodeinto the current node.Retrieves the Background node's application bounding leaf.Retrieves the Background node's application bounds.voidgetColor(javax.vecmath.Color3f color) Retrieves the background color.Retrieves the background geometry.getImage()Retrieves the background image.intRetrieves the current image scale mode.voidSet the Background's application region to the specified bounding leaf.voidsetApplicationBounds(Bounds region) Set the Background's application region to the specified bounds.voidsetColor(float r, float g, float b) Sets the background color to the specified color.voidsetColor(javax.vecmath.Color3f color) Sets the background color to the specified color.voidsetGeometry(BranchGroup branch) Sets the background geometry to the specified BranchGroup node.voidsetImage(ImageComponent2D image) Sets the background image to the specified image.voidsetImageScaleMode(int imageScaleMode) Sets the image scale mode for this Background node.voidupdateNodeReferences(NodeReferenceTable referenceTable) Callback used to allow a node to check if any scene graph objects referenced by that node have been duplicated via a call tocloneTree.Methods inherited from class javax.media.j3d.Node
cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, getBounds, getBoundsAutoCompute, getCollidable, getLocale, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickableMethods inherited from class javax.media.j3d.SceneGraphObject
clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString
-
Field Details
-
ALLOW_APPLICATION_BOUNDS_READ
public static final int ALLOW_APPLICATION_BOUNDS_READSpecifies that the Background allows read access to its application bounds and bounding leaf at runtime.- See Also:
-
ALLOW_APPLICATION_BOUNDS_WRITE
public static final int ALLOW_APPLICATION_BOUNDS_WRITESpecifies that the Background allows write access to its application bounds and bounding leaf at runtime.- See Also:
-
ALLOW_IMAGE_READ
public static final int ALLOW_IMAGE_READSpecifies that the Background allows read access to its image at runtime.- See Also:
-
ALLOW_IMAGE_WRITE
public static final int ALLOW_IMAGE_WRITESpecifies that the Background allows write access to its image at runtime.- See Also:
-
ALLOW_COLOR_READ
public static final int ALLOW_COLOR_READSpecifies that the Background allows read access to its color at runtime.- See Also:
-
ALLOW_COLOR_WRITE
public static final int ALLOW_COLOR_WRITESpecifies that the Background allows write access to its color at runtime.- See Also:
-
ALLOW_GEOMETRY_READ
public static final int ALLOW_GEOMETRY_READSpecifies that the Background allows read access to its background geometry at runtime.- See Also:
-
ALLOW_GEOMETRY_WRITE
public static final int ALLOW_GEOMETRY_WRITESpecifies that the Background allows write access to its background geometry at runtime.- See Also:
-
ALLOW_IMAGE_SCALE_MODE_READ
public static final int ALLOW_IMAGE_SCALE_MODE_READSpecifies that the Background allows read access to its image scale mode at runtime.- Since:
- Java 3D 1.3
- See Also:
-
ALLOW_IMAGE_SCALE_MODE_WRITE
public static final int ALLOW_IMAGE_SCALE_MODE_WRITESpecifies that the Background allows write access to its image scale mode at runtime.- Since:
- Java 3D 1.3
- See Also:
-
SCALE_NONE
Indicates that no scaling of the background image is done. The image will be drawn in its actual size. If the window is smaller than the image, the image will be clipped. If the window is larger than the image, the portion of the window not filled by the image will be filled with the background color. In all cases, the upper left corner of the image is anchored at the upper-left corner of the window. This is the default mode.- Since:
- Java 3D 1.3
- See Also:
-
SCALE_FIT_MIN
Indicates that the background image is uniformly scaled to fit the window such that the entire image is visible. The image is scaled by the smaller ofwindow.width/image.widthandwindow.height/image.height. The image will exactly fill either the width or height of the window, but not necessarily both. The portion of the window not filled by the image will be filled with the background color. The upper left corner of the image is anchored at the upper-left corner of the window.- Since:
- Java 3D 1.3
- See Also:
-
SCALE_FIT_MAX
Indicates that the background image is uniformly scaled to fit the window such that the entire window is filled. The image is scaled by the larger ofwindow.width/image.widthandwindow.height/image.height. The image will entirely fill the window, but may by clipped either in X or Y. The upper left corner of the image is anchored at the upper-left corner of the window.- Since:
- Java 3D 1.3
- See Also:
-
SCALE_FIT_ALL
Indicates that the background image is scaled to fit the window. The image is scaled non-uniformly in x and y bywindow.width/image.widthand andwindow.height/image.height, respectively. The image will entirely fill the window.- Since:
- Java 3D 1.3
- See Also:
-
SCALE_REPEAT
Indicates that the background image is tiled to fill the entire window. The image is not scaled. The upper left corner of the image is anchored at the upper-left corner of the window.- Since:
- Java 3D 1.3
- See Also:
-
SCALE_NONE_CENTER
Indicates that the background image is centered in the window and that no scaling of the image is done. The image will be drawn in its actual size. If the window is smaller than the image, the image will be clipped. If the window is larger than the image, the portion of the window not filled by the image will be filled with the background color.- Since:
- Java 3D 1.3
- See Also:
-
-
Constructor Details
-
Background
public Background()Constructs a Background node with default parameters. The default values are as follows:-
color : black (0,0,0)
image : null
geometry : null
image scale mode : SCALE_NONE
application bounds : null
application bounding leaf : null
-
Background
public Background(javax.vecmath.Color3f color) Constructs a Background node with the specified color. This color is used to fill the window prior to drawing any objects in the scene. -
Background
public Background(float r, float g, float b) Constructs a Background node with the specified color. This color is used to fill the window prior to drawing any objects in the scene. -
Background
Constructs a Background node with the specified image. If this image is non-null, it is rendered to the window prior to drawing any objects in the scene. If the image is smaller than the window, then that portion of the window not covered by the image is filled with the background color.- Parameters:
image- pixel array object used as the background image- Throws:
IllegalArgumentException- if the image class of the specified ImageComponent2D is ImageClass.NIO_IMAGE_BUFFER.
-
Background
Constructs a Background node with the specified geometry. If non-null, this background geometry is drawn on top of the background color and image using a projection matrix that essentially puts the geometry at infinity. The geometry should be pre-tessellated onto a unit sphere.- Parameters:
branch- the root of the background geometry- Throws:
IllegalSharingException- if the BranchGroup node is a child of any Group node, or is already attached to a Locale, or is already referenced by another Background node.IllegalSceneGraphException- if specified branch graph contains an illegal node.
-
-
Method Details
-
setColor
public void setColor(javax.vecmath.Color3f color) Sets the background color to the specified color. This color is used to fill the window prior to drawing any objects in the scene.- Parameters:
color- the new background color- Throws:
CapabilityNotSetException- if appropriate capability is not set and this object is part of live or compiled scene graph
-
setColor
public void setColor(float r, float g, float b) Sets the background color to the specified color. This color is used to fill the window prior to drawing any objects in the scene.- Parameters:
r- the red component of the background colorg- the green component of the background colorb- the blue component of the background color- Throws:
CapabilityNotSetException- if appropriate capability is not set and this object is part of live or compiled scene graph
-
getColor
public void getColor(javax.vecmath.Color3f color) Retrieves the background color.- Parameters:
color- the vector that will receive the current background color- Throws:
CapabilityNotSetException- if appropriate capability is not set and this object is part of live or compiled scene graph
-
setImage
Sets the background image to the specified image. If this image is non-null, it is rendered to the window prior to drawing any objects in the scene. If the image is smaller than the window, then that portion of the window not covered by the image is filled with the background color.- Parameters:
image- new pixel array object used as the background image- Throws:
CapabilityNotSetException- if appropriate capability is not set and this object is part of live or compiled scene graphIllegalSharingException- if this Background is live and the specified image is being used by a Canvas3D as an off-screen buffer.IllegalSharingException- if this Background is being used by an immediate mode context and the specified image is being used by a Canvas3D as an off-screen buffer.IllegalArgumentException- if the image class of the specified ImageComponent2D is ImageClass.NIO_IMAGE_BUFFER.
-
getImage
Retrieves the background image.- Returns:
- the current background image
- Throws:
CapabilityNotSetException- if appropriate capability is not set and this object is part of live or compiled scene graph
-
setImageScaleMode
public void setImageScaleMode(int imageScaleMode) Sets the image scale mode for this Background node.- Parameters:
imageScaleMode- the new image scale mode, one of: SCALE_NONE, SCALE_FIT_MIN, SCALE_FIT_MAX, SCALE_FIT_ALL, SCALE_REPEAT, or SCALE_NONE_CENTER.- Throws:
IllegalArgumentException- ifimageScaleModeis a value other than SCALE_NONE, SCALE_FIT_MIN, SCALE_FIT_MAX, SCALE_FIT_ALL, SCALE_REPEAT, or SCALE_NONE_CENTER.CapabilityNotSetException- if appropriate capability is not set and this object is part of live or compiled scene graph- Since:
- Java 3D 1.3
-
getImageScaleMode
public int getImageScaleMode()Retrieves the current image scale mode.- Returns:
- the current image scale mode, one of: SCALE_NONE, SCALE_FIT_MIN, SCALE_FIT_MAX, SCALE_FIT_ALL, SCALE_REPEAT, or SCALE_NONE_CENTER.
- Throws:
CapabilityNotSetException- if appropriate capability is not set and this object is part of live or compiled scene graph- Since:
- Java 3D 1.3
-
setGeometry
Sets the background geometry to the specified BranchGroup node. If non-null, this background geometry is drawn on top of the background color and image using a projection matrix that essentially puts the geometry at infinity. The geometry should be pre-tessellated onto a unit sphere.- Parameters:
branch- the root of the background geometry- Throws:
CapabilityNotSetException- if appropriate capability is not set and this object is part of live or compiled scene graphIllegalSharingException- if the BranchGroup node is a child of any Group node, or is already attached to a Locale, or is already referenced by another Background node.IllegalSceneGraphException- if specified branch graph contains an illegal node.
-
getGeometry
Retrieves the background geometry.- Returns:
- the BranchGroup node that is the root of the background geometry
- Throws:
CapabilityNotSetException- if appropriate capability is not set and this object is part of live or compiled scene graph
-
setApplicationBounds
Set the Background's application region to the specified bounds. This is used when the application bounding leaf is set to null.- Parameters:
region- the bounds that contains the Background's new application region.- Throws:
CapabilityNotSetException- if appropriate capability is not set and this object is part of live or compiled scene graph
-
getApplicationBounds
Retrieves the Background node's application bounds.- Returns:
- this Background's application bounds information
- Throws:
CapabilityNotSetException- if appropriate capability is not set and this object is part of live or compiled scene graph
-
setApplicationBoundingLeaf
Set the Background's application region to the specified bounding leaf. When set to a value other than null, this overrides the application bounds object.- Parameters:
region- the bounding leaf node used to specify the Background node's new application region.- Throws:
CapabilityNotSetException- if appropriate capability is not set and this object is part of live or compiled scene graph
-
getApplicationBoundingLeaf
Retrieves the Background node's application bounding leaf.- Returns:
- this Background's application bounding leaf information
- Throws:
CapabilityNotSetException- if appropriate capability is not set and this object is part of live or compiled scene graph
-
cloneNode
Creates a new instance of the node. This routine is called bycloneTreeto duplicate the current node.- Overrides:
cloneNodein classNode- Parameters:
forceDuplicate- when set totrue, causes theduplicateOnCloneTreeflag to be ignored. Whenfalse, the value of each node'sduplicateOnCloneTreevariable determines whether NodeComponent data is duplicated or copied.
Background geometry will not clone in this operation. It is the user's responsibility to callcloneTreeon that branchGroup.- See Also:
-
duplicateNode
Copies all node information fromoriginalNodeinto the current node. This method is called from thecloneNodemethod which is, in turn, called by thecloneTreemethod.For any
NodeComponentobjects contained by the object being duplicated, eachNodeComponentobject'sduplicateOnCloneTreevalue is used to determine whether theNodeComponentshould be duplicated in the new node or if just a reference to the current node should be placed in the new node. This flag can be overridden by setting theforceDuplicateparameter in thecloneTreemethod totrue.
NOTE: Applications should not call this method directly. It should only be called by the cloneNode method.- Overrides:
duplicateNodein classNode- Parameters:
originalNode- the original node to duplicate.forceDuplicate- when set totrue, causes theduplicateOnCloneTreeflag to be ignored. Whenfalse, the value of each node'sduplicateOnCloneTreevariable determines whether NodeComponent data is duplicated or copied.- Throws:
ClassCastException- if originalNode is not an instance ofBackground- See Also:
-
updateNodeReferences
Callback used to allow a node to check if any scene graph objects referenced by that node have been duplicated via a call tocloneTree. This method is called bycloneTreeafter all nodes in the sub-graph have been duplicated. The cloned Leaf node's method will be called and the Leaf node can then look up any object references by using thegetNewObjectReferencemethod found in theNodeReferenceTableobject. If a match is found, a reference to the corresponding object in the newly cloned sub-graph is returned. If no corresponding reference is found, either a DanglingReferenceException is thrown or a reference to the original object is returned depending on the value of theallowDanglingReferencesparameter passed in thecloneTreecall.NOTE: Applications should not call this method directly. It should only be called by the cloneTree method.
- Overrides:
updateNodeReferencesin classSceneGraphObject- Parameters:
referenceTable- a NodeReferenceTableObject that contains thegetNewObjectReferencemethod needed to search for new object instances- See Also:
-