com.jfimagine.jfgraph.shape.base
Class AbstractShape

java.lang.Object
  |
  +--com.jfimagine.jfgraph.shape.base.AbstractObject
        |
        +--com.jfimagine.jfgraph.shape.base.AbstractShape
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
AbstractArc, AbstractRectangle, JFCurve, JFGroup, JFLabelLine, JFLine, JFQuadrant, JFRegularLine

public abstract class AbstractShape
extends AbstractObject

Abstract Shape class. All shapes should extends/instances this class.

Version:
$Revision: 1.1 $
Author:
CookieMaker

Field Summary
protected  NodeList m_boundsNodeList
          A bounds node list is a four nodes list of the bounds, it's an virtual node list for showing, but not the actual node list for this shape.
protected  FontFormat m_fontFormat
          A font format for current shape and the internal label above.
protected  Label m_label
          An internal label property for any shape.
protected  NodeList m_nodeList
          Node List, all shape should has a node list.
protected  PortList m_portList
          Port List, all shape should has a port list.
protected  PropertyList m_propertyList
          Property List, all shape should has a property list.
static java.lang.String XML_DISABLEMODIFYINGPROPERTIES
          A XML string tag represents if disable or enable modifying properties
static java.lang.String XML_DISABLEMOTION
          A XML string tag represents if disable or enable motions
static java.lang.String XML_DISABLESCALING
          A XML string tag represents if disable or enable scaling
static java.lang.String XML_INVISIBLE
          A XML string tag represents if this shape is invisible
static java.lang.String XML_LABEL
          A XML string tag represents the label of a shape.
static java.lang.String XML_SHOWLABEL
          A XML string tag represents if show or hide label.
 
Fields inherited from class com.jfimagine.jfgraph.shape.base.AbstractObject
m_lastError, XML_OBJECTID, XML_OBJECTTYPE
 
Constructor Summary
AbstractShape()
           
 
Method Summary
 void addNode(double x, double y)
          Add a new node for current node list.
 void addNode(JFPoint pnt)
          Add a new node for current node list.
 Port addPort(double x, double y)
          Add a new port to this shape.
protected  void appendChildToDOM(Element element, JFVersion version)
          Append necessary xml child for current element, this method will be called internally by toDOM.
 boolean attachPort(Port port)
          Attach current shape to a specified port of other shape.
 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 list.
 void clearAccessTimes()
          Clear the access times of this object.
 java.lang.Object clone()
          Creates a new object of the same class and with the same contents as this object.
 boolean detachPort(Port port)
          Detach current shape to a specified port of other shape.
abstract  void draw(java.awt.Graphics g, boolean isXorMode)
          Draw current object on graphic canvas.
 void drawInvisibleBounds(java.awt.Graphics g, boolean isXorMode)
          Draw an invisible bounds when user hides this shape.
 void drawLabel(java.awt.Graphics g)
          Draw label of current shape.
 void drawLabelPicked(java.awt.Graphics g)
          Draw a label picked state of current shape.
 void drawPicked(java.awt.Graphics g, boolean ifRotate)
          Draw picked state of current object on graphic canvas.
 void drawPort(java.awt.Graphics g)
          Draw ports of current shape.
 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 fetchSubObjects(ObjectList objList)
          fetch all sub objects of this objects,then add them into objList.
 boolean finishDrawing()
          Finish drawing object.
protected  void finishMoveLabel()
          Finish move internal label of this shape.
 void finishMoveNode(Node node, double x, double y, java.awt.Graphics g)
          finish move/adjust a node of current object.
abstract  void flipBy()
          Reverse this object by a central y coordinate of this object.
abstract  void flipBy(double baseY)
          Reverse this rectangle by a y coordinate.
 int getAccessTimes()
          Get the access times of this object.
 Arrow getArrow()
          Get the arrow format of current object.
 Rect getBounds()
          Get the bounds of this shape.
 FillFormat getFillFormat()
          Get the fill format of current object.
 FontFormat getFontFormat()
          Get the font format of current object.
 Label getLabel()
          Get the internal label of current object.
 LineFormat getLineFormat()
          Get the line format of current object.
 JFPoint getMoveNodePos(Node node, JFPoint movePos, int moveCase)
          When moving a node, in some cases, e.g. ctrl key or shift key pressed to force preserving the form of a shape, or force equilateral shapes, we need to recalculate the actual moving node's position.
 Node getNodeByIndex(int index)
          Get a specified node by index
 Node getNodeByObjectId(int objectId)
          Get a specified node by object id
 int getNodeCount()
          Get the number of all the nodes of a AbstractShape a node is a point which is on AbstractShape and used to adjust/transform the AbstractShape
 ObjectList getNodeList()
          Get a node list of this shape.
 Port getPortByIndex(int index)
          Get a specified port by index
 Port getPortByObjectId(int objectId)
          Get a specified port by object id
 int getPortCount()
          Get a number of all the ports of a AbstractShape a port is a point which is on AbstractShape and used to connect other AbstractShapes
 ObjectList getPortList()
          Get a port list of this shape.
 Property getPropertyByIndex(int index)
          Get a specified property by index
 Property getPropertyByObjectId(int objectId)
          Get a specified property by object id
 int getPropertyCount()
          Get a number of all the properties of a AbstractShape
 ObjectList getPropertyList()
          Get a property list of this shape.
 int hashCode()
          Returns the hashcode for this Object.
 boolean ifCompleteDrawing()
          If an object has already necessary points so can be constructed.
 int incAccessTimes()
          Increase one time of the access times.
protected  void initBoundsNodeList()
          Init bounds node list method is to get the four nodes of the bounds, then rebuild the bounds node list.
protected  void initLabel()
          Set the intial position of this internal label.
abstract  boolean intersects(JFPoint pnt)
          Test if current object intersects with a specified point.
abstract  boolean intersects(Rect rect)
          Test if current object intersects with a specified rectangle.
 boolean isDisableModifyingProperties()
          get if is disabled modifying properties
 boolean isDisableMotion()
          get if is disabled motion
 boolean isDisableScaling()
          get if is disabled scaling
 boolean isInvisible()
          get if this shape is invisible
 boolean isOpenShape()
          Ask if this object is an open shape,e.g. line,curve,arc,etc.
 boolean isRotatable()
          Ask if this object is rotatable.
 Label labelIntersects(java.awt.Graphics g, JFPoint pnt)
          Get if current internal label of this shape intersects with point pnt.
 Label labelIntersects(java.awt.Graphics g, Rect rect)
          Get if current internal label of this shape intersects with point pnt.
 void loadFromStream(JFReader stream, boolean skipHead, JFVersion version)
          Load object data from a binary stream
abstract  void mirrorBy()
          Mirror this object by a central x coordinate of this object.
abstract  void mirrorBy(double baseX)
          Mirror this object by a x coordinate.
abstract  void moveBy(double x, double y)
          Move current object by an x and y offset.
 void moveNode(Node node, double x, double y, java.awt.Graphics g)
          Move/adjust a node of current object.
 boolean movePort(Port port, double x, double y)
          Move/adjust a port of current object.
 void moveRelationalPorts(ObjectList movedList)
          move relational ports while moving this object.
 Node nodeIntersects(JFPoint pnt, int usage)
          Get which node of current shape that intersects with point pnt.
 Port pickPort(double x, double y)
          Pick a port hat is on the shape, according to the current x,y position
 Port portIntersects(JFPoint pnt, AbstractObject avoidParent)
          Get which port of current shape that intersects with point pnt.
 Node removeLastNode()
          Remove last node added by addNode method.
 boolean removePort(Port port)
          Remove a port from this shape.
abstract  void rotateBy(double theta)
          Rotate current object by an angle theta.
abstract  void rotateBy(double baseX, double baseY, double theta)
          Rotate current object by a specified point and an angle theta.
 void rotateNode(JFPoint nodePoint, JFPoint rotateCenter, double x, double y, java.awt.Graphics g)
          Rotate an object by moving a node of current object.
 void saveToStream(JFWriter stream, JFVersion version)
          Save this object to a binary stream
abstract  void scaleBy(JFPoint basePoint, double xScale, double yScale)
          Scale current object by a specified x and y scale.
abstract  void scaleBy(JFPoint basePoint, JFPoint refPoint1, JFPoint refPoint2, double scale)
          Scale current object by specified points and scale percent.
 void setArrow(Arrow arrow)
          Set the arrow format of current object.
 void setDisableModifyingProperties(boolean disable)
          set disable modifying properties
 void setDisableMotion(boolean disable)
          set disable motion
 void setDisableScaling(boolean disable)
          set disable scaling
 void setFillFormat(FillFormat fillFormat)
          Set the fill format of current object.
 void setFontFormat(FontFormat fontFormat)
          Set the font format of current object.
 void setInvisible(boolean invisible)
          set invisible of this shape.
 void setLabel(Label aLabel)
          Set the internal label of current object.
 void setLineFormat(LineFormat lineFormat)
          Set the line format of current object.
 void setNodeList(ObjectList nodeList)
          Set a node list of this shape.
 void setObjectId(int objectId)
          Set the id of current object,object id starts at 0.
 void setParent()
          Set all nodes/ports/labels' parent, this method will be called after a clone method because of a clone method will not clone their parent.
 void setPortList(ObjectList portList, ObjectList shapeList)
          Set a port list of this shape.
 void setZoomScale(double zoomScale)
          set zoom scale
protected  void startMoveLabel()
          Start move internal label of this shape.
 void startMoveNode(Node node)
          Start move a node.
 java.lang.String toString()
          Convert this object to String
 void unboundBrokenPorts()
          unbound broken ports
 
Methods inherited from class com.jfimagine.jfgraph.shape.base.AbstractObject
cloneMe, fromDOM, getLastError, getMaxObjectId, getObjectId, getObjectType, getXMLTag, getZoomScale, isShowDesign, setLastError, setObjectType, setShowDesign, setValue, setXMLTag, toDOM
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

XML_LABEL

public static final java.lang.String XML_LABEL
A XML string tag represents the label of a shape.

See Also:
Constant Field Values

XML_SHOWLABEL

public static final java.lang.String XML_SHOWLABEL
A XML string tag represents if show or hide label.

See Also:
Constant Field Values

XML_DISABLESCALING

public static final java.lang.String XML_DISABLESCALING
A XML string tag represents if disable or enable scaling

See Also:
Constant Field Values

XML_DISABLEMODIFYINGPROPERTIES

public static final java.lang.String XML_DISABLEMODIFYINGPROPERTIES
A XML string tag represents if disable or enable modifying properties

See Also:
Constant Field Values

XML_DISABLEMOTION

public static final java.lang.String XML_DISABLEMOTION
A XML string tag represents if disable or enable motions

See Also:
Constant Field Values

XML_INVISIBLE

public static final java.lang.String XML_INVISIBLE
A XML string tag represents if this shape is invisible

See Also:
Constant Field Values

m_portList

protected PortList m_portList
Port List, all shape should has a port list.

A port is a shape used to connect other shapes' ports.

A line/curve shape should has only two ports, one for start point and another for end point.

A rectangular shape should has four or more ports, e.g. middle of top, middle of left, middle of right and middle of bottom.


m_nodeList

protected NodeList m_nodeList
Node List, all shape should has a node list.

A node is a point on the outline of a shape.

Nodes for line shape are used to construct a polyline shape.

A rectangular shape should has only two nodes, left-top point and right-bottom point.


m_boundsNodeList

protected NodeList m_boundsNodeList
A bounds node list is a four nodes list of the bounds, it's an virtual node list for showing, but not the actual node list for this shape. Anyone who want to use this node list must call initBoundsNodeList first.


m_propertyList

protected PropertyList m_propertyList
Property List, all shape should has a property list.

A property is customized and defined by client.

Each shape should has one or more proproties.


m_label

protected Label m_label
An internal label property for any shape.


m_fontFormat

protected FontFormat m_fontFormat
A font format for current shape and the internal label above.

Constructor Detail

AbstractShape

public AbstractShape()
Method Detail

getArrow

public Arrow getArrow()
Get the arrow format of current object.

Returns:
The arrow format.

setArrow

public void setArrow(Arrow arrow)
Set the arrow format of current object.

Parameters:
arrow - A new arrow format object.

getLineFormat

public LineFormat getLineFormat()
Get the line format of current object.

Returns:
The line format.

setLineFormat

public void setLineFormat(LineFormat lineFormat)
Set the line format of current object.

Parameters:
lineFormat - A new line format.

getFillFormat

public FillFormat getFillFormat()
Get the fill format of current object.

Returns:
The fill format.

setFillFormat

public void setFillFormat(FillFormat fillFormat)
Set the fill format of current object.

Parameters:
fillFormat - A new fill format.

getLabel

public Label getLabel()
Get the internal label of current object.

Returns:
The internal label.

setLabel

public void setLabel(Label aLabel)
Set the internal label of current object.

Parameters:
aLabel - A new internal label.

initLabel

protected void initLabel()
Set the intial position of this internal label.


isDisableScaling

public boolean isDisableScaling()
get if is disabled scaling


setDisableScaling

public void setDisableScaling(boolean disable)
set disable scaling


isDisableModifyingProperties

public boolean isDisableModifyingProperties()
get if is disabled modifying properties


setDisableModifyingProperties

public void setDisableModifyingProperties(boolean disable)
set disable modifying properties


isDisableMotion

public boolean isDisableMotion()
get if is disabled motion


setDisableMotion

public void setDisableMotion(boolean disable)
set disable motion


isInvisible

public boolean isInvisible()
get if this shape is invisible


setInvisible

public void setInvisible(boolean invisible)
set invisible of this shape.


startMoveLabel

protected void startMoveLabel()
Start move internal label of this shape.


finishMoveLabel

protected void finishMoveLabel()
Finish move internal label of this shape.


getFontFormat

public FontFormat getFontFormat()
Get the font format of current object.

Returns:
The font format.

setFontFormat

public void setFontFormat(FontFormat fontFormat)
Set the font format of current object.

Parameters:
fontFormat - A new font format.

getAccessTimes

public int getAccessTimes()
Get the access times of this object.

Returns:
The access times.

incAccessTimes

public int incAccessTimes()
Increase one time of the access times.

Returns:
The new access times.

clearAccessTimes

public void clearAccessTimes()
Clear the access times of this object.


setZoomScale

public void setZoomScale(double zoomScale)
set zoom scale

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

setObjectId

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

Overrides:
setObjectId in class AbstractObject
Parameters:
objectId - The object id.

setParent

public void setParent()
Set all nodes/ports/labels' parent, this method will be called after a clone method because of a clone method will not clone their parent.


getNodeCount

public int getNodeCount()
Get the number of all the nodes of a AbstractShape a node is a point which is on AbstractShape and used to adjust/transform the AbstractShape

Returns:
The number of nodes.

getNodeList

public ObjectList getNodeList()
Get a node list of this shape. A shape should always has a node list.

Returns:
The node list.

setNodeList

public void setNodeList(ObjectList nodeList)
Set a node list of this shape.

Parameters:
nodeList - A new node list.

getNodeByIndex

public Node getNodeByIndex(int index)
                    throws ListException
Get a specified node by index

Parameters:
index - An index of node
Returns:
The node object.
ListException

getNodeByObjectId

public Node getNodeByObjectId(int objectId)
                       throws ListException
Get a specified node by object id

Parameters:
objectId - Object id for specified node.
Returns:
The node object.
ListException

addNode

public void addNode(JFPoint pnt)
Add a new node for current node list.

Parameters:
pnt - A new point for node.

addNode

public void addNode(double x,
                    double y)
Add a new node for current node list.


isRotatable

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

Returns:
true if rotatable, false otherwise.

isOpenShape

public boolean isOpenShape()
Ask if this object is an open shape,e.g. line,curve,arc,etc.

Returns:
true if open,false closed.

rotateNode

public void rotateNode(JFPoint nodePoint,
                       JFPoint rotateCenter,
                       double x,
                       double y,
                       java.awt.Graphics g)
Rotate an object by moving a node of current object.

Parameters:
nodePoint - Currently moving node's point position. This will be actually an object's node, but also can be an fictitious node of multi objects(in multi rotation actions)
rotateCenter - A rotate center specified, if null use center point instead.
g - A graphic canvas.

getMoveNodePos

public JFPoint getMoveNodePos(Node node,
                              JFPoint movePos,
                              int moveCase)
When moving a node, in some cases, e.g. ctrl key or shift key pressed to force preserving the form of a shape, or force equilateral shapes, we need to recalculate the actual moving node's position.

Parameters:
movePos - Desire moving position of a node.
moveCase - Move case of a node, normal, shift key pressed or ctrl key pressed
Returns:
The actual moving position of a node.

startMoveNode

public void startMoveNode(Node node)
Start move a node.

Parameters:
node - The node will be moved.

moveNode

public void moveNode(Node node,
                     double x,
                     double y,
                     java.awt.Graphics g)
Move/adjust a node of current object.

Parameters:
node - Currently moving node.
g - current drawing canvas.

finishMoveNode

public void finishMoveNode(Node node,
                           double x,
                           double y,
                           java.awt.Graphics g)
finish move/adjust a node of current object.

Parameters:
node - Currently moving node.
g - current drawing canvas.

ifCompleteDrawing

public boolean ifCompleteDrawing()
If an object has already necessary points so can be constructed.

Returns:
True when complete, false otherwise.

finishDrawing

public boolean finishDrawing()
Finish drawing object.


addPort

public Port addPort(double x,
                    double y)
Add a new port to this shape.


pickPort

public Port pickPort(double x,
                     double y)
Pick a port hat is on the shape, according to the current x,y position


removePort

public boolean removePort(Port port)
Remove a port from this shape.

Parameters:
port - A port to be removed.

attachPort

public boolean attachPort(Port port)
Attach current shape to a specified port of other shape.

Parameters:
port - A new port of other shape.

detachPort

public boolean detachPort(Port port)
Detach current shape to a specified port of other shape.

Parameters:
port - A port of other shape.

fetchSubObjects

public void fetchSubObjects(ObjectList objList)
fetch all sub objects of this objects,then add them into objList.


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 list.

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

removeLastNode

public Node removeLastNode()
Remove last node added by addNode method.

Returns:
Last node that remained.

getPortCount

public int getPortCount()
Get a number of all the ports of a AbstractShape a port is a point which is on AbstractShape and used to connect other AbstractShapes

Returns:
The number of ports.

getPortList

public ObjectList getPortList()
Get a port list of this shape. A shape should always has a port list.

Returns:
The port list.

setPortList

public void setPortList(ObjectList portList,
                        ObjectList shapeList)
Set a port list of this shape.

Parameters:
portList - A new port list.
shapeList - All shape objects in a list.

getPortByIndex

public Port getPortByIndex(int index)
                    throws ListException
Get a specified port by index

Parameters:
index - An index of port
Returns:
The port object.
ListException

getPortByObjectId

public Port getPortByObjectId(int objectId)
                       throws ListException
Get a specified port by object id

Parameters:
objectId - Object id for specified port.
Returns:
The port object.
ListException

getPropertyCount

public int getPropertyCount()
Get a number of all the properties of a AbstractShape

Returns:
The number of properties.

getPropertyList

public ObjectList getPropertyList()
Get a property list of this shape. A shape should always has a property list.

Returns:
The property list.

getPropertyByIndex

public Property getPropertyByIndex(int index)
                            throws ListException
Get a specified property by index

Parameters:
index - An index of property
Returns:
The property object.
ListException

getPropertyByObjectId

public Property getPropertyByObjectId(int objectId)
                               throws ListException
Get a specified property by object id

Parameters:
objectId - Object id for specified property.
Returns:
The property object.
ListException

getBounds

public Rect getBounds()
Get the bounds of this shape.

Returns:
The bounds rectangle of current shape.

drawLabel

public void drawLabel(java.awt.Graphics g)
Draw label of current shape.

Parameters:
g - A graphic canvas.

drawLabelPicked

public void drawLabelPicked(java.awt.Graphics g)
Draw a label picked state of current shape.

Parameters:
g - A graphic canvas.

drawPort

public void drawPort(java.awt.Graphics g)
Draw ports of current shape.

Parameters:
g - A graphic canvas.

drawPicked

public void drawPicked(java.awt.Graphics g,
                       boolean ifRotate)
Draw picked state of current object on graphic canvas.

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

initBoundsNodeList

protected void initBoundsNodeList()
Init bounds node list method is to get the four nodes of the bounds, then rebuild the bounds node list.


drawInvisibleBounds

public void drawInvisibleBounds(java.awt.Graphics g,
                                boolean isXorMode)
Draw an invisible bounds when user hides this shape.

Parameters:
g - A graphic canvas.
isXorMode - If is in xor mode now.

nodeIntersects

public Node nodeIntersects(JFPoint pnt,
                           int usage)
Get which node of current shape that intersects with point pnt.

Parameters:
pnt - A JFPoint used to test intersection.
usage - Purpose to get a node intersected, e.g. move or rotate.
Returns:
A node of current shape.

portIntersects

public Port portIntersects(JFPoint pnt,
                           AbstractObject avoidParent)
Get which port of current shape that intersects with point pnt.

Parameters:
pnt - A JFPoint used to test intersection.
avoidParent - A specified avoided parent to avoid connected to self.
Returns:
A port of current shape.

labelIntersects

public Label labelIntersects(java.awt.Graphics g,
                             JFPoint pnt)
Get if current internal label of this shape intersects with point pnt.

Parameters:
g - A graphics context used to measure current text size on this graphics context.
pnt - A JFPoint used to test intersection.
Returns:
Internal label of this shape if intersected, null otherwise.

labelIntersects

public Label labelIntersects(java.awt.Graphics g,
                             Rect rect)
Get if current internal label of this shape intersects with point pnt.

Parameters:
g - A graphics context used to measure current text size on this graphics context.
rect - A rectangle used to test intersection.
Returns:
Internal label of this shape if intersected, null otherwise.

movePort

public boolean movePort(Port port,
                        double x,
                        double y)
Move/adjust a port of current object. A move port event will always occured by relative objects' moving event.

Parameters:
port - Currently moving port.
Returns:
True if successfully moved, false otherwise.

moveRelationalPorts

public void moveRelationalPorts(ObjectList movedList)
move relational ports while moving this object.

Parameters:
movedList - An object list that has already processed, so don't change them further.

unboundBrokenPorts

public void unboundBrokenPorts()
unbound broken ports


toString

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

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

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 Point2D.

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 Port 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 object 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 object 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

draw

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

Parameters:
g - A graphic canvas.
isXorMode - If is in xor mode now.

intersects

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

Parameters:
pnt - A JFPoint used to test intersection.

intersects

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

Parameters:
rect - A Rect used to test intersection.

moveBy

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


scaleBy

public abstract void scaleBy(JFPoint basePoint,
                             JFPoint refPoint1,
                             JFPoint refPoint2,
                             double scale)
Scale current object by specified points and scale percent. We only support a concurrent width-height scale here, suppose width as the length from basePoint to refPoint1, height as the length from basePoint to refPoint2, and one scale percent acts on both width and height.

Parameters:
basePoint - A base point that is unmovable.
refPoint1 - A 'width' reference point.
refPoint2 - A 'height' reference point.
scale - A reference scale percent.

scaleBy

public abstract void scaleBy(JFPoint basePoint,
                             double xScale,
                             double yScale)
Scale current object by a specified x and y scale.
This is a special scale method used to scale a shape in arbitrary x and y scale.
There would be some restrictions in this scale method:

Lines,regularlines,labellines,polygons, curves, arcs/chords/pies can be scaled in any situations.

Rectangles,diamonds,parallelograms,trapezoids,images,ellipses, hexagons and isoscelesTriangles can be scaled before they are rotated.

Rectangles,diamonds,parallelograms,trapezoids,images,ellipses, hexagons and isoscelesTriangles can only be scaled under a same x/y scale percentage after they are rotated. We will choose a smaller value between the xScale and yScale values for instead under this situation

Parameters:
basePoint - A base scale point for scaling reference.
xScale - A scale percentage in x coordinate, default to 1.0
yScale - A scale percentage in y coordinate, default to 1.0

rotateBy

public abstract void rotateBy(double theta)
Rotate current object by an angle theta.

Parameters:
theta - A rotate angle.

rotateBy

public abstract void rotateBy(double baseX,
                              double baseY,
                              double theta)
Rotate current object by a specified point and an angle theta.

Parameters:
theta - A rotate angle.

mirrorBy

public abstract void mirrorBy()
Mirror this object by a central x coordinate of this object. We make a left-right flip here.


mirrorBy

public abstract void mirrorBy(double baseX)
Mirror this object by a x coordinate. We make a left-right mirror here.

Parameters:
baseX - A mirror base x coordinate.

flipBy

public abstract void flipBy()
Reverse this object by a central y coordinate of this object. We make a up-down flip here.


flipBy

public abstract void flipBy(double baseY)
Reverse this rectangle by a y coordinate. We make a up-down flip here.

Parameters:
baseY - A flip base y coordinate.


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