de.fhg.igd.earth.model.graph
Class Group

java.lang.Object
  extended byde.fhg.igd.earth.model.graph.ProjectorObject
      extended byde.fhg.igd.earth.model.graph.ModelGraphObject
          extended byde.fhg.igd.earth.model.graph.Node
              extended byde.fhg.igd.earth.model.graph.Group
All Implemented Interfaces:
Cloneable, Serializable
Direct Known Subclasses:
BranchGroup, LatchGroup, ModelGraph, SwitchGroup, TransformGroup, WireBoxGroup

public class Group
extends Node
implements Serializable, Cloneable

This class represents a group. A group can have children. The number of children can be limited. All children are stored in the children_ Vector. If one child will be removed from this vector it will be added to the erasedChildren list. Title : Earth Copyright : Copyright (c) 2001 Organisation : IGD FhG

Version:
: 1.0
Author:
: Werner Beutel
See Also:
Serialized Form

Field Summary
private  Vector children_
          A vector with the childen nodes
private  Vector erasedChildren_
          A vector with the erased children nodes
protected  int maxNumChildren_
          maximum number of children.
 
Fields inherited from class de.fhg.igd.earth.model.graph.Node
boundless_, collidable_, icon_, parent_, pickable_
 
Fields inherited from class de.fhg.igd.earth.model.graph.ModelGraphObject
CHANGE_AddChild, CHANGE_Anything, CHANGE_Appearance, CHANGE_Color, CHANGE_Create, CHANGE_Delete, CHANGE_Focus, CHANGE_HistoryGroup, CHANGE_InfoTable, CHANGE_Object, CHANGE_RemoveChild, CHANGE_Shape, CHANGE_Trace, CHANGE_Update, CHANGE_Visibility, changes_, infoTable_, mutable_, name_, subChanges_, SUBTYPE_BackGround, SUBTYPE_Box, SUBTYPE_BranchGroup, SUBTYPE_Cone, SUBTYPE_Cylinder, SUBTYPE_DetailGroup, SUBTYPE_DistanceDetailGroup, SUBTYPE_Group, SUBTYPE_HistoryGroup, SUBTYPE_LatchGroup, SUBTYPE_ModelGraph, SUBTYPE_Polygon, SUBTYPE_Primitive, SUBTYPE_Sphere, SUBTYPE_Text, SUBTYPE_TransformGroup, SUBTYPE_WireBoxGroup, timeStamp_, trace_, traceable_, TYPE_Group, TYPE_Leaf
 
Fields inherited from class de.fhg.igd.earth.model.graph.ProjectorObject
projectorObject_
 
Constructor Summary
Group()
          Constructs and initializes a default group.
 
Method Summary
 boolean addChild(Node n)
          Adds the given node to this group.
protected  boolean allowChildAddEvent(Node n)
          This method is called BEFORE the given node is added to this group.
 void calcBoundingBox(cBoundingBox boundingBox)
          Calculates the bounding box of this node.
protected  void childAddedEvent(int index)
          This method is called AFTER a new child was added to this group.
protected  void childRemovedEvent(int index)
          This method is called AFTER a child was removed.
 Object clone()
          Clones this group
protected  void createLeafList(Vector list)
          Inserts all sub leafs to a given Vector.
protected  void createSubGroupList(Vector list)
          Inserts all sub groups to a given Vector.
protected  void createSubNodeList(Vector list)
          Inserts all subnodes to a given Vector.
protected  void detach()
          This method sets the CHANGED_DELETED flag of this node and all sub nodes.
protected  void detachedEvent()
          This method is called AFTER a node was detached.
 Enumeration getAllChildren()
          Returns an Enumeration of all children.
protected  Node getChild(int index)
          Returns the node at the given index.
 Enumeration getErasedChildren()
          Returns an enumeration of all erased children.
 int getSubType()
          Returns SUBTYPE_Group.
 int getType()
          Returns TYPE_Group.
 int numChildren()
          Returns the number of children
 boolean removeAllChildren()
          Removes all children in this group (blocked by mutable).
protected  boolean removeChild(int index)
          Removes a child at a spezial index (blocked by mutable).
 boolean removeChild(Node o)
          Removes a given child from the child vector (blocked by mutable).
protected  void resetChanges()
          Resets all changes in this group and clear the erasedChildren vector.
 Enumeration searchDown(int type)
          Search method which walks down the tree and searches by type.
 Node searchDown(int type, int subType)
          Search method which walks down the tree and searches by type and subtype.
 Enumeration searchDown(String group)
          Search method which walks down the tree and searches by group.
 Node searchDown(String group, String name)
          Search method which walks down the tree and searches by group and name.
protected  void searchDownInserter(int type, Vector result)
          This method inserts all nodes with the given type into the result Vector.
protected  void searchDownInserter(String group, Vector result)
          This method inserts all nodes with the given group name into the result Vector.
protected  void setChildAt(Node c, int index)
          Set child at index.
 boolean setColor(Color c)
          Sets the color of all leafs.
 boolean setHighLight(boolean on)
          Sets the HighLight flag of all leafs.
protected  void setMutable(boolean m)
          Sets the mutable flag for this group and all sub nodes.
 void setVisible(boolean v)
          Sets the visibility of this node and all subnodes.
 
Methods inherited from class de.fhg.igd.earth.model.graph.Node
broadcastCreation, broadcastResetChanges, createParentGroupList, delete, delete, getBoundingBox, getBoundless, getBranchGroup, getCollidable, getGroup, getIcon, getLeafList, getModelGraph, getParent, getParentGroupList, getPickable, getSubGroupList, getSubNodeList, isFocused, move, move, moveTo, publishChanges, resetProjectorObject, searchUp, searchUp, searchUp, searchUp, setBoundless, setCollidable, setIcon, setParent, setPickable
 
Methods inherited from class de.fhg.igd.earth.model.graph.ModelGraphObject
anyChanges, anySubChanges, getChanges, getChanges, getInfoTable, getInfoTableElements, getInfoTableKeys, getInfoTableSize, getInfoTableValues, getMutable, getName, getSubChanges, getSubChanges, getSubTypeName, getTimeStamp, getTrace, getTraceable, putInfo, setChanges, setInfoTable, setName, setSubChanges, setTrace, VectorClone
 
Methods inherited from class de.fhg.igd.earth.model.graph.ProjectorObject
getProjectorObject, setProjectorObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

children_

private Vector children_
A vector with the childen nodes


erasedChildren_

private Vector erasedChildren_
A vector with the erased children nodes


maxNumChildren_

protected int maxNumChildren_
maximum number of children. -1 = infinite

Constructor Detail

Group

public Group()
Constructs and initializes a default group. Maximum of children is set to infinite (-1)

Method Detail

getType

public int getType()
Returns TYPE_Group. Defined in ModelGraphObject

Specified by:
getType in class ModelGraphObject
Returns:
type (always TYPE_Group)

getSubType

public int getSubType()
Returns SUBTYPE_Group. Defined in ModelGraphObject

Specified by:
getSubType in class ModelGraphObject
Returns:
subType (always SUBTYPE_Group)

resetChanges

protected void resetChanges()
Resets all changes in this group and clear the erasedChildren vector. This method is used by Node.broadcastResetChanges()

Overrides:
resetChanges in class ModelGraphObject

searchDown

public Node searchDown(String group,
                       String name)
Search method which walks down the tree and searches by group and name. It returns a node which has the given name and group. The search includes this node.

Specified by:
searchDown in class Node
Parameters:
group - The searched group
name - The searched name
Returns:
node or null

searchDown

public Enumeration searchDown(String group)
Search method which walks down the tree and searches by group. It returns an Enumeration of nodes which has the given group. The search includes this node.

Specified by:
searchDown in class Node
Parameters:
group - The searched group
Returns:
Enumeration of nodes

searchDownInserter

protected void searchDownInserter(String group,
                                  Vector result)
This method inserts all nodes with the given group name into the result Vector. The search includes this node.

Specified by:
searchDownInserter in class Node
Parameters:
group - The searched group
result - The Vector to insert into

searchDown

public Node searchDown(int type,
                       int subType)
Search method which walks down the tree and searches by type and subtype. It returns a node which has the given type and subtype. The search includes this node.

Specified by:
searchDown in class Node
Parameters:
type - The searched type
Returns:
node or null

searchDown

public Enumeration searchDown(int type)
Search method which walks down the tree and searches by type. It returns an Enumeration of nodes which has the given type. The search includes this node.

Specified by:
searchDown in class Node
Returns:
Enumeration of nodes

searchDownInserter

protected void searchDownInserter(int type,
                                  Vector result)
This method inserts all nodes with the given type into the result Vector. The search includes this node.

Specified by:
searchDownInserter in class Node
Parameters:
type - The searched type
result - The Vector to insert into

calcBoundingBox

public void calcBoundingBox(cBoundingBox boundingBox)
Calculates the bounding box of this node. This method is used by Node.getBoundingBox().

Specified by:
calcBoundingBox in class Node
Parameters:
boundingBox - which will be combined with

setVisible

public void setVisible(boolean v)
Sets the visibility of this node and all subnodes.

Specified by:
setVisible in class Node
Parameters:
v - visibility

setColor

public boolean setColor(Color c)
Sets the color of all leafs.

Specified by:
setColor in class Node
Parameters:
c - Color
Returns:
true on success

setHighLight

public boolean setHighLight(boolean on)
Sets the HighLight flag of all leafs. (under construction)

Specified by:
setHighLight in class Node
Parameters:
on - The new HighLight flag
Returns:
true on success

setMutable

protected void setMutable(boolean m)
Sets the mutable flag for this group and all sub nodes. Overwrites the abstract methode in ModelGraphObject

Specified by:
setMutable in class ModelGraphObject
Parameters:
m - new mutable flag (true=is mutable)

addChild

public boolean addChild(Node n)
Adds the given node to this group. Released changes: CHANGE_ADDCHILD Released subchanges: CHANGE_CREAT

Parameters:
n - Node to add
Returns:
true on success.

allowChildAddEvent

protected boolean allowChildAddEvent(Node n)
This method is called BEFORE the given node is added to this group. It will be called by the addChild() method. Here you can decide if you want to allow the insertion.

Parameters:
n - Node to check
Returns:
true if it's allowed to add this node

childAddedEvent

protected void childAddedEvent(int index)
This method is called AFTER a new child was added to this group. It will be called by the addChild() method. Here you can do additional routines.

Parameters:
index - Index of the new node

getChild

protected Node getChild(int index)
Returns the node at the given index.

Returns:
children_[index]

setChildAt

protected void setChildAt(Node c,
                          int index)
Set child at index.

Parameters:
c - Child
index - Index

getAllChildren

public Enumeration getAllChildren()
Returns an Enumeration of all children.

Returns:
Enumeration of all children

numChildren

public int numChildren()
Returns the number of children

Returns:
Number of children

removeAllChildren

public boolean removeAllChildren()
Removes all children in this group (blocked by mutable).

Returns:
true on success

removeChild

public boolean removeChild(Node o)
Removes a given child from the child vector (blocked by mutable).

Parameters:
o - Child to remove
Returns:
true on success

removeChild

protected boolean removeChild(int index)
Removes a child at a spezial index (blocked by mutable). Released changes: CHANGE_UPDATE, CHANGE_REMOVECHILD Released subchanges: CHANGE_DELETE

Parameters:
index - Index of the child to remove
Returns:
true on success

childRemovedEvent

protected void childRemovedEvent(int index)
This method is called AFTER a child was removed.


getErasedChildren

public Enumeration getErasedChildren()
Returns an enumeration of all erased children.

Returns:
enumeration of all erased children

detach

protected void detach()
This method sets the CHANGED_DELETED flag of this node and all sub nodes. It is used by removeChild() Released changes: CHANGE_DELETE

Specified by:
detach in class Node

detachedEvent

protected void detachedEvent()
This method is called AFTER a node was detached.


createSubNodeList

protected void createSubNodeList(Vector list)
Inserts all subnodes to a given Vector. This method is used by Node.getSubNodeList().

Specified by:
createSubNodeList in class Node
Parameters:
list - Vector to add into

createSubGroupList

protected void createSubGroupList(Vector list)
Inserts all sub groups to a given Vector. This method is used by Node.getSubGroupList().

Specified by:
createSubGroupList in class Node
Parameters:
list - Vector to add into

createLeafList

protected void createLeafList(Vector list)
Inserts all sub leafs to a given Vector. This method is used by Node.getSubLeafList().

Specified by:
createLeafList in class Node
Parameters:
list - Vector to add into

clone

public Object clone()
Clones this group

Overrides:
clone in class Node


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.