com.jfimagine.jfgraph.shape.base
Class AbstractObject

java.lang.Object
  |
  +--com.jfimagine.jfgraph.shape.base.AbstractObject
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
AbstractLibrary, AbstractShape, Arrow, CanvasFormat, FillFormat, FontFormat, JFLayer, JFLibElem, JFPage, JFPageFormat, Label, LineFormat, Node, ObjectList, Port, Property

public abstract class AbstractObject
extends java.lang.Object
implements java.lang.Cloneable

Abstract object class. All classes that can be stored to and recovered from xml/binary file must instance/extend this abstract class.

Version:
$Revision: 1.1 $
Author:
CookieMaker

Field Summary
protected  java.lang.String m_lastError
          Last error info within this object.
static java.lang.String XML_OBJECTID
          A XML string tag represents the object id
static java.lang.String XML_OBJECTTYPE
          A XML string tag represents the object type
 
Constructor Summary
AbstractObject()
           
 
Method Summary
protected  void appendChildToDOM(Element element, JFVersion version)
          Append necessary xml child for current element, this method will be called internally by toDOM.
 java.lang.Object clone()
          Creates a new AbstractObject of the same class and with the same contents as this object.
protected abstract  AbstractObject cloneMe()
          Creates a new AbstractObject of the same class and with the same contents as this 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.
 void fromDOM(Element element, JFVersion version)
          Extract an Object from a xml element
 java.lang.String getLastError()
          Get last error message within this object.
 int getMaxObjectId()
          Get a max object id of current object,object id starts at 0.
 int getObjectId()
          Get the id of current object,object id starts at 0.
 int getObjectType()
          An object type used to identify the type of an object, especially you need to store such an object type into a DataOutputStream, so we can distinguish this object type from a DataInputStream, although we can easily use an instanceof or the other type casting ways to test an object type at runtime.
 java.lang.String getXMLTag()
          All AbstractObject should be stored as XML, so here we need a XML tag for each object.
 double getZoomScale()
          get zoom scale
 int hashCode()
          Returns the hashcode for this AbstractObject.
 boolean isShowDesign()
          if current object is under show design state.
 void loadFromStream(JFReader stream, boolean skipHead, JFVersion version)
          Load AbstractObject data from a binary stream
 void saveToStream(JFWriter stream, JFVersion version)
          Save this AbstractObject to a binary stream
 void setLastError(java.lang.String lastError)
          Set last error message within this object.
 void setObjectId(int objectId)
          Set the id of current object,object id starts at 0.
 void setObjectType(int objectType)
          Set the type of current object
 void setShowDesign(boolean showDesign)
          set if show or hide current object's design info
 void setValue(AbstractObject obj)
          Set value by a new object.
 void setXMLTag(java.lang.String xmlTag)
          Set a xmlTag for this object.
 void setZoomScale(double zoomScale)
          set zoom scale
 void toDOM(Element element, JFVersion version)
          Convert this Object to a sub element of a specified element
 java.lang.String toString()
          Convert this AbstractObject to String
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

XML_OBJECTID

public static final java.lang.String XML_OBJECTID
A XML string tag represents the object id

See Also:
Constant Field Values

XML_OBJECTTYPE

public static final java.lang.String XML_OBJECTTYPE
A XML string tag represents the object type

See Also:
Constant Field Values

m_lastError

protected java.lang.String m_lastError
Last error info within this object.

Constructor Detail

AbstractObject

public AbstractObject()
Method Detail

getZoomScale

public double getZoomScale()
get zoom scale

Returns:
the zoom scale

setZoomScale

public void setZoomScale(double zoomScale)
set zoom scale

Parameters:
zoomScale - A new zoom scale.

isShowDesign

public boolean isShowDesign()
if current object is under show design state.


setShowDesign

public void setShowDesign(boolean showDesign)
set if show or hide current object's design info


getObjectType

public int getObjectType()
An object type used to identify the type of an object, especially you need to store such an object type into a DataOutputStream, so we can distinguish this object type from a DataInputStream, although we can easily use an instanceof or the other type casting ways to test an object type at runtime.

GetObjectType used to get the type of current object

Returns:
The object Type.

setObjectType

public void setObjectType(int objectType)
Set the type of current object

Parameters:
objectType - A new object type for current object.

getXMLTag

public java.lang.String getXMLTag()
All AbstractObject should be stored as XML, so here we need a XML tag for each object.

getXMLTag used to get current XML tag of this object.

Returns:
The object Type.

setXMLTag

public void setXMLTag(java.lang.String xmlTag)
Set a xmlTag for this object.

Parameters:
xmlTag - XML tag for this object.

getLastError

public java.lang.String getLastError()
Get last error message within this object.

Returns:
The last error.

setLastError

public void setLastError(java.lang.String lastError)
Set last error message within this object.

Parameters:
lastError - A new last error.

getObjectId

public int getObjectId()
Get the id of current object,object id starts at 0.

Returns:
The object id.

getMaxObjectId

public int getMaxObjectId()
Get a max object id of current object,object id starts at 0. This action is same as getObjectId when the object is an indifidual object, but is different as getObjectId when the object is just a group object.

Returns:
The object id.

setObjectId

public void setObjectId(int objectId)
Set the id of current object,object id starts at 0.

Parameters:
objectId - The object id.

setValue

public void setValue(AbstractObject obj)
Set value by a new object.


toString

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

Overrides:
toString in class java.lang.Object
Returns:
An string represents the content of the AbstractObject

cloneMe

protected abstract AbstractObject cloneMe()
                                   throws java.lang.CloneNotSupportedException
Creates a new AbstractObject of the same class and with the same contents as this object. This method should be implemented by sub classes.

Returns:
A clone of this class.
java.lang.CloneNotSupportedException

clone

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

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

hashCode

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

Overrides:
hashCode in class java.lang.Object
Returns:
hash code for this AbstractObject.

equals

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

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

toDOM

public void toDOM(Element element,
                  JFVersion version)
Convert this Object to a sub element of a specified element

Parameters:
version - A file version notification so this object can obey the rules to save data.
element - A jdom.element used to add sub content.

appendChildToDOM

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

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

fromDOM

public void fromDOM(Element element,
                    JFVersion version)
Extract an Object from a xml element

Parameters:
version - A file version notification so this object can obey the rules to fetch data.
element - A jdom element used to restore content of a BaseObject

extractChildFromDOM

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

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

saveToStream

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

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 AbstractObject data from a binary stream

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


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