org.jdesktop.wonderland.client.cell
Class Cell

java.lang.Object
  extended by org.jdesktop.wonderland.client.cell.Cell
Direct Known Subclasses:
EnvironmentCell, ModelCell, ViewCell

public class Cell
extends java.lang.Object

The client side representation of a cell. Cells are created via the CellCache and should not be instantiated directly by the user on the client.

Author:
paulby

Nested Class Summary
static class Cell.RendererType
          An enum representing the various render types supported by Wonderland.
 
Field Summary
protected static java.util.logging.Logger logger
          The logger for Cell (and possibly it's subclasses)
 
Constructor Summary
Cell(CellID cellID, CellCache cellCache)
          Instantiate a new cell
 
Method Summary
 void addChild(Cell child)
          Add the child to the set of children of this cell.
 void addChildrenChangeListener(CellChildrenChangeListener listener)
          Add a children change listener to this cell.
 void addComponent(CellComponent component)
          Add a component to this cell.
 void addComponent(CellComponent component, java.lang.Class componentClass)
          Add a component to this cell, with the specified componentClass.
 void addComponentChangeListener(ComponentChangeListener listener)
          Add a ComponentChangeListener to this cell.
 void addParentChangeListener(CellParentChangeListener listener)
          Add a parent change listener to this cell.
 void addStatusChangeListener(CellStatusChangeListener listener)
          Add a status change listener to this cell.
 void addTransformChangeListener(TransformChangeListener listener)
          Add a TransformChangeListener to this cell.
protected  CellRenderer createCellRenderer(Cell.RendererType rendererType)
          Create the renderer for this cell
protected  void fireCellStatusChanged(CellStatus status)
          Notify listeners that the cell status has changed.
 CellCache getCellCache()
          Return the cell cache which instantiated and owns this cell.
 CellID getCellID()
          Return the unique id of this cell
 CellRenderer getCellRenderer(Cell.RendererType rendererType)
          Return the renderer of the given type for this cell.
 java.util.List<Cell> getChildren()
          Return the list of children for this cell, or an empty list if there are no children
<T extends CellComponent>
T
getComponent(java.lang.Class<T> cellComponentClass)
          Return this cells instance of the specified component class if defined.
 java.util.Collection<CellComponent> getComponents()
          Return a collection of all the components in this cell.
 com.jme.bounding.BoundingVolume getLocalBounds()
          Get the local bounds for this cell.
 CellTransform getLocalToWorldTransform()
          Return the local to Virtual World transform for this cell.
 CellTransform getLocalTransform()
          Return the transform for this cell
 java.lang.String getName()
          Return the name for this cell (defaults to cellID)
 int getNumChildren()
          Return the number of children
 Cell getParent()
          Return the cells parent, or null if it have no parent
 CellStatus getStatus()
          Returns the status of this cell Cell states DISK - Cell is on disk with no memory footprint INACTIVE - Cell object is in memory with bounds initialized, NO geometry is loaded INACTIVE - All cell data is in memory ACTIVE - Cell is within the avatars proximity bounds VISIBLE - Cell is in the view frustum
 com.jme.bounding.BoundingVolume getWorldBounds()
          Returns the world bounds, this is the local bounds transformed into VW coordinates.
 CellTransform getWorldTransform()
          Return the world transform of the cell.
 void removeChild(Cell child)
          Remove the specified cell from the set of children of this cell.
 void removeChildChangeListener(CellChildrenChangeListener listener)
          Remove a child change listener from this cell
 void removeComponent(java.lang.Class<? extends CellComponent> componentClass)
          Remove the cell component of the specified class, the components setStatus method will be called with CellStatus.DISK to trigger cleanup of any component state.
 void removeComponentChangeListener(ComponentChangeListener listener)
          Remove the specified listener.
 void removeParentChangeListener(CellParentChangeListener listener)
          Remove a parent change listener from this cell
 void removeStatusChangeListener(CellStatusChangeListener listener)
          Remove a status change listener from this cell
 void removeTransformChangeListener(TransformChangeListener listener)
          Remove the specified listener.
 void sendCellMessage(CellMessage message)
          A utility routine that fetches the channel component of the cell and sends a message on it.
 ResponseMessage sendCellMessageAndWait(CellMessage message)
          A utility routine that fetches the channel component of the cell and sends a message on it.
 void setClientState(CellClientState configData)
          Called when the cell is initially created and any time there is a major configuration change.
 void setLocalBounds(com.jme.bounding.BoundingVolume localBounds)
          Set the local bounds for this cell
 void setName(java.lang.String name)
          Set a name for the cell
protected  void setStatus(CellStatus status, boolean increasing)
          Set the status of this cell Cell states DISK - Cell is on disk with no memory footprint INACTIVE - Cell object is in memory with bounds initialized, NO geometry is loaded INACTIVE - All cell data is in memory ACTIVE - Cell is within the avatars proximity bounds VISIBLE - Cell is in the view frustum The system guarantees that if a change is made between non adjacent status, say from INACTIVE to VISIBLE that setStatus will automatically be called for the intermediate values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static java.util.logging.Logger logger
The logger for Cell (and possibly it's subclasses)

Constructor Detail

Cell

public Cell(CellID cellID,
            CellCache cellCache)
Instantiate a new cell

Parameters:
cellID - the cells unique ID
cellCache - the cell cache which instantiated, and owns, this cell
Method Detail

getCellID

public CellID getCellID()
Return the unique id of this cell

Returns:
the cell id

getParent

public Cell getParent()
Return the cells parent, or null if it have no parent

Returns:

getChildren

public java.util.List<Cell> getChildren()
Return the list of children for this cell, or an empty list if there are no children

Returns:

addChild

public void addChild(Cell child)
              throws MultipleParentException
Add the child to the set of children of this cell. Throws a MultipleParentException if child is already a child to another cell

Parameters:
child - to add
Throws:
MultipleParentException

removeChild

public void removeChild(Cell child)
Remove the specified cell from the set of children of this cell. Returns silently if the supplied cell is not a child of this cell. TODO Test me

Parameters:
child -

getComponent

public <T extends CellComponent> T getComponent(java.lang.Class<T> cellComponentClass)
Return this cells instance of the specified component class if defined. Otherwise return null.

Type Parameters:
T - The class of the component being queried
Returns:
the cells component of the requested class (or null)

addComponent

public void addComponent(CellComponent component)
Add a component to this cell. Only a single instance of each component class can be added to a cell. Adding duplicate components will result in an IllegalArgumentException. When a component is added component.setStatus is called automatically with the current status of this cell.

Parameters:
component - the componnet to be added

addComponent

public void addComponent(CellComponent component,
                         java.lang.Class componentClass)
Add a component to this cell, with the specified componentClass. This allows for specialized subclasses to be registered with a higher level interface/class. Only a single instance of each component class can be added to a cell. Adding duplicate components will result in an IllegalArgumentException. When a component is added component.setStatus is called automatically with the current status of this cell.

Parameters:
component - the componnet to be added

removeComponent

public void removeComponent(java.lang.Class<? extends CellComponent> componentClass)
Remove the cell component of the specified class, the components setStatus method will be called with CellStatus.DISK to trigger cleanup of any component state. TODO Test me

Parameters:
componentClass -

getComponents

public java.util.Collection<CellComponent> getComponents()
Return a collection of all the components in this cell. The collection is a clone of the internal data structure, so this is a snapshot of the component set.

Returns:

getNumChildren

public int getNumChildren()
Return the number of children

Returns:

getLocalTransform

public CellTransform getLocalTransform()
Return the transform for this cell

Returns:

getLocalToWorldTransform

public CellTransform getLocalToWorldTransform()
Return the local to Virtual World transform for this cell.

Returns:
cells local to VWorld transform

getWorldTransform

public CellTransform getWorldTransform()
Return the world transform of the cell.

Returns:
the world transform of this cell.

getWorldBounds

public com.jme.bounding.BoundingVolume getWorldBounds()
Returns the world bounds, this is the local bounds transformed into VW coordinates. These bounds do not include the subgraph bounds. This call is only valid for live cells.

Returns:
world bounds

getName

public java.lang.String getName()
Return the name for this cell (defaults to cellID)

Returns:

setName

public void setName(java.lang.String name)
Set a name for the cell

Parameters:
name -

getLocalBounds

public com.jme.bounding.BoundingVolume getLocalBounds()
Get the local bounds for this cell. Local bounds are in the cells coordinate system

Returns:
local bounds for this cell

setLocalBounds

public void setLocalBounds(com.jme.bounding.BoundingVolume localBounds)
Set the local bounds for this cell

Parameters:
localBounds -

getCellCache

public CellCache getCellCache()
Return the cell cache which instantiated and owns this cell.

Returns:
the cell cache which instantiated this cell.

getStatus

public CellStatus getStatus()
Returns the status of this cell Cell states DISK - Cell is on disk with no memory footprint INACTIVE - Cell object is in memory with bounds initialized, NO geometry is loaded INACTIVE - All cell data is in memory ACTIVE - Cell is within the avatars proximity bounds VISIBLE - Cell is in the view frustum

Returns:
returns CellStatus

setStatus

protected void setStatus(CellStatus status,
                         boolean increasing)
Set the status of this cell Cell states DISK - Cell is on disk with no memory footprint INACTIVE - Cell object is in memory with bounds initialized, NO geometry is loaded INACTIVE - All cell data is in memory ACTIVE - Cell is within the avatars proximity bounds VISIBLE - Cell is in the view frustum The system guarantees that if a change is made between non adjacent status, say from INACTIVE to VISIBLE that setStatus will automatically be called for the intermediate values. If you overload this method in your own class you must call super.setStatus(...) as the first operation in your method. Note users should not call this method directly, it should only be called from implementations of the cache.

Parameters:
status - the cell status
increasing - indicates if the status is increasing

fireCellStatusChanged

protected void fireCellStatusChanged(CellStatus status)
Notify listeners that the cell status has changed. If you manually call setStatus() on the cell, you must also call this method to notify listeners, after the call to setStatus() completes.

Parameters:
status - the new status

setClientState

public void setClientState(CellClientState configData)
Called when the cell is initially created and any time there is a major configuration change. The cell will already be attached to it's parent before the initial call of this method

Parameters:
configData - the configuration data for the cell

sendCellMessage

public void sendCellMessage(CellMessage message)
A utility routine that fetches the channel component of the cell and sends a message on it. If there is no channel component (should never happen), this method logs an error message.

Parameters:
message - The CellMessage

sendCellMessageAndWait

public ResponseMessage sendCellMessageAndWait(CellMessage message)
A utility routine that fetches the channel component of the cell and sends a message on it. This method also waits for and returns the response. If there is no channel component (should never happen), this method logs an error message and returns null.

Parameters:
message - The CellMessage

createCellRenderer

protected CellRenderer createCellRenderer(Cell.RendererType rendererType)
Create the renderer for this cell

Parameters:
rendererType - The type of renderer required
Returns:
the renderer for the specified type if available, or null

getCellRenderer

public CellRenderer getCellRenderer(Cell.RendererType rendererType)
Return the renderer of the given type for this cell. If a renderer of the requested type is not available, or the cell is not in at least the RENDERING state null will be returned

Parameters:
rendererType - the type of the render to return
Returns:
the renderer, or null if no renderer of the specified type is available

addTransformChangeListener

public void addTransformChangeListener(TransformChangeListener listener)
Add a TransformChangeListener to this cell. The listener will be called for any changes to the cells transform

Parameters:
listener - to add

removeTransformChangeListener

public void removeTransformChangeListener(TransformChangeListener listener)
Remove the specified listener.

Parameters:
listener - to be removed

addComponentChangeListener

public void addComponentChangeListener(ComponentChangeListener listener)
Add a ComponentChangeListener to this cell. The listener will be called for any changes to the cell's list of components

Parameters:
listener - to add

removeComponentChangeListener

public void removeComponentChangeListener(ComponentChangeListener listener)
Remove the specified listener.

Parameters:
listener - to be removed

addStatusChangeListener

public void addStatusChangeListener(CellStatusChangeListener listener)
Add a status change listener to this cell. The listener will be called for any change to this cell's status. For changes to any cell's status, use CellManager.

Parameters:
listener - the listener to add

removeStatusChangeListener

public void removeStatusChangeListener(CellStatusChangeListener listener)
Remove a status change listener from this cell

Parameters:
listener - the listener to remove

addParentChangeListener

public void addParentChangeListener(CellParentChangeListener listener)
Add a parent change listener to this cell. The listener will be called for any change to this cell's parent.

Parameters:
listener - the listener to add

removeParentChangeListener

public void removeParentChangeListener(CellParentChangeListener listener)
Remove a parent change listener from this cell

Parameters:
listener - the listener to remove

addChildrenChangeListener

public void addChildrenChangeListener(CellChildrenChangeListener listener)
Add a children change listener to this cell. The listener will be called for any change to this cell's children.

Parameters:
listener - the listener to add

removeChildChangeListener

public void removeChildChangeListener(CellChildrenChangeListener listener)
Remove a child change listener from this cell

Parameters:
listener - the listener to remove


Open Wonderland - http://openwonderland.org