com.jfimagine.jfgraph.shape.base
Class Node

java.lang.Object
  |
  +--com.jfimagine.jfgraph.shape.base.AbstractObject
        |
        +--com.jfimagine.jfgraph.shape.base.Node
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
PolyNode, RegularNode

public class Node
extends AbstractObject

Node Class. A node is used to construct, adjust or transform a shape, especially for a line object, it should always have two or more nodes to modify its shape

Version:
$Revision: 1.1 $
Author:
CookieMaker

Field Summary
protected  JFPoint m_nodePoint
          A point for x,y coordinates.
protected  AbstractObject m_parent
          A parent object of this node.
static int NODEUSAGE_MOVE
          A node used to move its parent object
static int NODEUSAGE_ROTATE
          A node used to rotate its parent object
static java.lang.String XML_NODE
          A XML string tag represents a jfnode
static java.lang.String XML_XOFFSET
          A XML string tag represents the x coordinate offset of this node
static java.lang.String XML_YOFFSET
          A XML string tag represents the y coordinate offset of this node
 
Fields inherited from class com.jfimagine.jfgraph.shape.base.AbstractObject
m_lastError, XML_OBJECTID, XML_OBJECTTYPE
 
Constructor Summary
Node()
          Constructor for Node
Node(double x, double y)
          Constructor for Node
Node(JFPoint pnt)
          Constructor for Node
 
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 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.
 void draw(java.awt.Graphics g, boolean ifRotate)
          Draw current object on graphic canvas.
protected  void drawNodeCircle(java.awt.Graphics g, java.awt.Color interColor)
          Draw current node circle on graphic canvas.
protected  void drawNodeRect(java.awt.Graphics g, java.awt.Color interColor, java.awt.Color exterColor)
          Draw current node rectangle on graphic canvas.
protected  void drawRotateSign(java.awt.Graphics g)
          Draw a rotation arrow on current node.
 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.
 JFPoint getNodePoint()
          Get the point of current node.
 AbstractObject getParent()
          Get parent object of this node.
 double getXOffset()
          Get the x offset of current node.
 double getYOffset()
          Get the y offset of current node.
 int hashCode()
          Returns the hashcode for this Object.
 boolean intersects(JFPoint pnt)
          Test if current object intersects with a specified point.
 boolean intersects(Rect rect)
          Test if current object intersects with a specified rectangle.
 boolean isRotatable()
          Ask if this node is rotatable.
 void loadFromStream(JFReader stream, boolean skipHead, JFVersion version)
          Load node data from a binary stream
 void moveBy(double x, double y)
          Move current object by an x and y offset.
 void saveToStream(JFWriter stream, JFVersion version)
          Save this node to a binary stream
 void setNodePoint(JFPoint pnt)
          Set the point of current node.
 void setParent(AbstractObject obj)
          Set parent object of this node.
 void setXOffset(double xOffset)
          Set the x offset of current node.
 void setYOffset(double yOffset)
          Set the y offset of current node.
 java.lang.String toString()
          Convert this node to String
 
Methods inherited from class com.jfimagine.jfgraph.shape.base.AbstractObject
fromDOM, getLastError, getMaxObjectId, getObjectId, getObjectType, getXMLTag, getZoomScale, isShowDesign, setLastError, setObjectId, setObjectType, setShowDesign, setValue, setXMLTag, setZoomScale, toDOM
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

XML_NODE

public static final java.lang.String XML_NODE
A XML string tag represents a jfnode

See Also:
Constant Field Values

XML_XOFFSET

public static final java.lang.String XML_XOFFSET
A XML string tag represents the x coordinate offset of this node

See Also:
Constant Field Values

XML_YOFFSET

public static final java.lang.String XML_YOFFSET
A XML string tag represents the y coordinate offset of this node

See Also:
Constant Field Values

NODEUSAGE_MOVE

public static final int NODEUSAGE_MOVE
A node used to move its parent object

See Also:
Constant Field Values

NODEUSAGE_ROTATE

public static final int NODEUSAGE_ROTATE
A node used to rotate its parent object

See Also:
Constant Field Values

m_nodePoint

protected JFPoint m_nodePoint
A point for x,y coordinates.


m_parent

protected AbstractObject m_parent
A parent object of this node.

Constructor Detail

Node

public Node()
Constructor for Node


Node

public Node(double x,
            double y)
Constructor for Node


Node

public Node(JFPoint pnt)
Constructor for Node

Method Detail

getParent

public AbstractObject getParent()
Get parent object of this node.

Returns:
parent object.

setParent

public void setParent(AbstractObject obj)
Set parent object of this node.

Parameters:
obj - A new parent object.

getXOffset

public double getXOffset()
Get the x offset of current node.

Returns:
The x offset of current node.

setXOffset

public void setXOffset(double xOffset)
Set the x offset of current node.

Parameters:
xOffset - The x offset of current node.
Returns:
No return.

getYOffset

public double getYOffset()
Get the y offset of current node.

Returns:
The y offset of current node.

setYOffset

public void setYOffset(double yOffset)
Set the y offset of current node.

Parameters:
yOffset - The y offset of current node.

getNodePoint

public JFPoint getNodePoint()
Get the point of current node.

Returns:
The x offset of current node.

setNodePoint

public void setNodePoint(JFPoint pnt)
Set the point of current node.

Parameters:
pnt - The point of current node.

drawNodeRect

protected void drawNodeRect(java.awt.Graphics g,
                            java.awt.Color interColor,
                            java.awt.Color exterColor)
Draw current node rectangle on graphic canvas.

Parameters:
g - A graphic canvas.
interColor - Interior color to fill the node rectangle.
exterColor - Exterior color to draw the outline of node rectangle.

drawNodeCircle

protected void drawNodeCircle(java.awt.Graphics g,
                              java.awt.Color interColor)
Draw current node circle on graphic canvas.

Parameters:
g - A graphic canvas.
interColor - Interior color to fill the node rectangle.

isRotatable

public boolean isRotatable()
Ask if this node is rotatable.

Returns:
true if rotatable, false otherwise.

drawRotateSign

protected void drawRotateSign(java.awt.Graphics g)
Draw a rotation arrow on current node.


draw

public void draw(java.awt.Graphics g,
                 boolean ifRotate)
Draw current object on graphic canvas.

Parameters:
g - A graphic canvas.
ifRotate - If user's operation or other actions force objects to be rotated.

intersects

public boolean intersects(JFPoint pnt)
Test if current object intersects with a specified point.

Parameters:
pnt - A JFPoint used to test intersection.

intersects

public boolean intersects(Rect rect)
Test if current object intersects with a specified rectangle.

Parameters:
rect - A Rect used to test intersection.

moveBy

public void moveBy(double x,
                   double y)
Move current object by an x and y offset.


toString

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

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

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


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