com.jfimagine.jfgraph.shape.base
Class ObjectList

java.lang.Object
  |
  +--com.jfimagine.jfgraph.shape.base.AbstractObject
        |
        +--com.jfimagine.jfgraph.shape.base.ObjectList
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
NodeList, PortList, PropertyList

public class ObjectList
extends AbstractObject

ObjectList class. A major type of object list class used in CAD.

Version:
$Revision: 1.1 $
Author:
CookieMaker

Field Summary
protected  java.util.List m_objectList
          A java.util.List used to store all AbstractObjects.
static java.lang.String XML_OBJECTCOUNT
          A XML string tag represents the number of objects in this list.
static java.lang.String XML_OBJECTLIST
          A XML string tag represents a ObjectList
 
Fields inherited from class com.jfimagine.jfgraph.shape.base.AbstractObject
m_lastError, XML_OBJECTID, XML_OBJECTTYPE
 
Constructor Summary
ObjectList()
          Constructor for ObjectList
 
Method Summary
 int add(AbstractObject obj)
          Add a new object at the end of the list.
 void add(java.util.List list)
          Add a new object list at the end of the list.
protected  void appendChildToDOM(Element element, JFVersion version)
          Append necessary xml child for current element, this method will be called internally by toDOM.
 void attachRealPort()
          A loadFromStream method should only load an parentId-objectId list of ports attached, So here we use an attachRealPort to ACTUALLY attach some ports to the ports in list.
 void attachRealPort(ObjectList shapeList)
          A loadFromStream method should only load an parentId-objectId list of ports attached, So here we use an attachRealPort to ACTUALLY attach some ports to the ports in this list.
 void bringToFront(java.util.List objList)
          Send a sub-collection of this object list to front.
 void clear()
          Clear all objects in list.
 java.lang.Object clone()
          Creates a new object of the same class and with the same contents as this object.
protected  AbstractObject cloneMe()
          Creates a new AbstractObject of the same class and with the same contents as this object.
 boolean contains(AbstractObject obj)
          If this objectList has already contains such an object.
 boolean equals(java.lang.Object obj)
          Determines whether or not two objects are equal.
protected  void extractChildFromDOM(Element element, JFVersion version)
          Extract needed xml child from current element, this method will be called internally by fromDOM.
 Rect getBounds()
          Get the bounds of this object list.
 AbstractObject getByIndex(int index)
          Get an object by an index
 AbstractObject getByObjectId(int objectId)
          Get an object by an object id
 AbstractObject getFromGroupsByObjectId(int objectId, boolean returnGroup)
          Get an object from groups by an object id
 int getIndexByObjectId(int objectId)
          Get the index of an object by an object id.
 java.util.List getList()
          Get a java.util.List object encapsulates AbstractObjects
 int hashCode()
          Returns the hashcode for this Object.
 void loadFromStream(JFReader stream, boolean skipHead, JFVersion version)
          Load node data from a binary stream
 void moveObject(int objectId, int index)
          Move one object within this list to a specified index position.
 int newObjectId()
          Generate a new object id.
 void removeAll(java.util.List objList)
          Remove a sub-collection of this list.
 void removeByIndex(int index)
          Remove an object by index
 void removeByObjectId(int objectId)
          Remove an object by object id.
 void saveToStream(JFWriter stream, JFVersion version)
          Save this node to a binary stream
 void sendToBack(java.util.List objList)
          Send a sub-collection of this object list to back.
 void setList(java.util.List objList)
          Set a new object list.
 void setShowDesign(boolean showDesign)
          set if show or hide the design info of objects in this list
 void setZoomScale(double zoomScale)
          set zoom scale
 int size()
          Get the number of AbstractObject in list.
 java.lang.String toString()
          Convert this list to String
 
Methods inherited from class com.jfimagine.jfgraph.shape.base.AbstractObject
fromDOM, getLastError, getMaxObjectId, getObjectId, getObjectType, getXMLTag, getZoomScale, isShowDesign, setLastError, setObjectId, setObjectType, setValue, setXMLTag, toDOM
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

XML_OBJECTCOUNT

public static final java.lang.String XML_OBJECTCOUNT
A XML string tag represents the number of objects in this list.

See Also:
Constant Field Values

XML_OBJECTLIST

public static final java.lang.String XML_OBJECTLIST
A XML string tag represents a ObjectList

See Also:
Constant Field Values

m_objectList

protected java.util.List m_objectList
A java.util.List used to store all AbstractObjects.

Constructor Detail

ObjectList

public ObjectList()
Constructor for ObjectList

Method Detail

getList

public java.util.List getList()
Get a java.util.List object encapsulates AbstractObjects

Returns:
A java.util.List.

setList

public void setList(java.util.List objList)
Set a new object list.


getByIndex

public AbstractObject getByIndex(int index)
                          throws ListException
Get an object by an index

Parameters:
index - An index.
Returns:
An AbstractObject
Throws:
com.jfimagine.utils.exception.ListException, - An exception while processing list operations.
ListException

getByObjectId

public AbstractObject getByObjectId(int objectId)
                             throws ListException
Get an object by an object id

Parameters:
objectId - An object id.
Returns:
An AbstractObject
Throws:
com.jfimagine.utils.exception.ListException, - An exception while processing list operations.
ListException

getFromGroupsByObjectId

public AbstractObject getFromGroupsByObjectId(int objectId,
                                              boolean returnGroup)
                                       throws ListException
Get an object from groups by an object id

Parameters:
objectId - An object id.
returnGroup - True if return the group, false return the object itself.
Returns:
An AbstractObject
Throws:
com.jfimagine.utils.exception.ListException, - An exception while processing list operations.
ListException

setShowDesign

public void setShowDesign(boolean showDesign)
set if show or hide the design info of objects in this list

Overrides:
setShowDesign in class AbstractObject

contains

public boolean contains(AbstractObject obj)
If this objectList has already contains such an object.

Parameters:
obj - A new AbstractObject.
Returns:
If obj is already inside the object list, then return true,otherwise false.

getIndexByObjectId

public int getIndexByObjectId(int objectId)
Get the index of an object by an object id.

Parameters:
objectId - An object id.
Returns:
The index.

newObjectId

public int newObjectId()
Generate a new object id. An object id is always unique one in this list and starts at 1. Anyone who want to make a new Abstractobject, should need a new object id. This method should also be used by add method.

Returns:
A new object id.
Throws:
com.jfimagine.utils.exception.ListException, - An exception while processing list operations.

add

public int add(AbstractObject obj)
Add a new object at the end of the list.

Parameters:
obj - A new AbstractObject.
Returns:
The index the object located in the list.

add

public void add(java.util.List list)
Add a new object list at the end of the list. We don't care about the object id here.

Parameters:
list - A new AbstractObject list.

removeByIndex

public void removeByIndex(int index)
                   throws ListException
Remove an object by index

Parameters:
index - A index.
Throws:
com.jfimagine.utils.exception.ListException, - An exception while processing list operations.
ListException

removeByObjectId

public void removeByObjectId(int objectId)
                      throws ListException
Remove an object by object id.

Parameters:
objectId - An object id.
Throws:
com.jfimagine.utils.exception.ListException, - An exception while processing list operations.
ListException

removeAll

public void removeAll(java.util.List objList)
Remove a sub-collection of this list.

Parameters:
objList - A sub collection.

sendToBack

public void sendToBack(java.util.List objList)
Send a sub-collection of this object list to back.


bringToFront

public void bringToFront(java.util.List objList)
Send a sub-collection of this object list to front.


moveObject

public void moveObject(int objectId,
                       int index)
Move one object within this list to a specified index position.

Parameters:
objectId - Id of an obect.
index - New position to move to.

clear

public void clear()
           throws ListException
Clear all objects in list.

Throws:
com.jfimagine.utils.exception.ListException, - An exception while processing list operations.
ListException

size

public int size()
Get the number of AbstractObject in list.

Returns:
The number of AbstractObject.

getBounds

public Rect getBounds()
Get the bounds of this object list. Objects that are not AbstractShape would not be cauclated in result.

Returns:
The bounds rectangle.

toString

public java.lang.String toString()
Convert this list to String

Overrides:
toString in class AbstractObject
Returns:
An string represents the content of current list

cloneMe

protected AbstractObject cloneMe()
                          throws java.lang.CloneNotSupportedException
Creates a new AbstractObject of the same class and with the same contents as this object. This method implements the method defined in AbstractObject.

Specified by:
cloneMe in class AbstractObject
Returns:
A clone of this class.
java.lang.CloneNotSupportedException

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Creates a new object of the same class and with the same contents as this object.

Overrides:
clone in class AbstractObject
Returns:
A clone of this instance.
java.lang.CloneNotSupportedException

hashCode

public int hashCode()
Returns the hashcode for this Object.

Overrides:
hashCode in class AbstractObject
Returns:
hash code for this Node.

equals

public boolean equals(java.lang.Object obj)
Determines whether or not two objects are equal.

Overrides:
equals in class AbstractObject
Parameters:
obj - an object to be compared with this object
Returns:
true if the object to be compared is an instance of Node and has the same values; false otherwise.

appendChildToDOM

protected void appendChildToDOM(Element element,
                                JFVersion version)
Append necessary xml child for current element, this method will be called internally by toDOM.

Overrides:
appendChildToDOM in class AbstractObject
Parameters:
element - A XML element to append child xml nodes
version - A file version notification so this object can obey the rules to save data.

extractChildFromDOM

protected void extractChildFromDOM(Element element,
                                   JFVersion version)
Extract needed xml child from current element, this method will be called internally by fromDOM.

Overrides:
extractChildFromDOM in class AbstractObject
Parameters:
element - An element used to extract needed xml child
version - A file version notification so this object can obey the rules to fetch data.

saveToStream

public void saveToStream(JFWriter stream,
                         JFVersion version)
                  throws java.io.IOException
Save this node to a binary stream

Overrides:
saveToStream in class AbstractObject
Parameters:
stream - An binary output stream
version - A file version notification so this object can obey the rules to save data.
Throws:
java.io.IOException

loadFromStream

public void loadFromStream(JFReader stream,
                           boolean skipHead,
                           JFVersion version)
                    throws java.io.IOException
Load node data from a binary stream

Overrides:
loadFromStream in class AbstractObject
Parameters:
stream - An binary input stream
skipHead - Skip head 'TYPE' check, an shape object should always has its own shape-type stored, if this shape-type has already been readed, this loadFromStream should/could not read the type anymore.
version - A file version notification so this object can obey the rules to fetch data.
Throws:
java.io.IOException

attachRealPort

public void attachRealPort()
A loadFromStream method should only load an parentId-objectId list of ports attached, So here we use an attachRealPort to ACTUALLY attach some ports to the ports in list.


attachRealPort

public void attachRealPort(ObjectList shapeList)
A loadFromStream method should only load an parentId-objectId list of ports attached, So here we use an attachRealPort to ACTUALLY attach some ports to the ports in this list.

Parameters:
shapeList - A shapeList used to pick out their ports for ports' attached list

setZoomScale

public void setZoomScale(double zoomScale)
set zoom scale

Overrides:
setZoomScale in class AbstractObject
Parameters:
zoomScale - A new zoom scale.


Copyright 2004 ~ 2005 JingFei International Cooperation LTD. All Rights Reserved.