com.jfimagine.jfgraph.shape.line
Class JFQuadrant

java.lang.Object
  |
  +--com.jfimagine.jfgraph.shape.base.AbstractObject
        |
        +--com.jfimagine.jfgraph.shape.base.AbstractShape
              |
              +--com.jfimagine.jfgraph.shape.line.JFQuadrant
All Implemented Interfaces:
java.lang.Cloneable

public class JFQuadrant
extends AbstractShape

A JFQuadrant class is used to draw two perpendicular lines which divide a drawing canvas into four sections.

Version:
$Revision: 1.1 $
Author:
CookieMaker

Field Summary
static int DEFAULT_SIZE
          Default size(pixels) for perpendicular lines
protected  JFPoint m_center
          Quadrant center
protected  double m_height
          Height for the vertical line
protected  LineFormat m_lineFormat
          quadrant format of current quadrant.
protected  double m_width
          Width for the horizontal line
static int MOVEMETHOD_CENTER
          move method: move center(both lines)
static int MOVEMETHOD_HORIZONTALLINE
          move method: move horizontal line
static int MOVEMETHOD_NONE
          move method: none
static int MOVEMETHOD_VERTICALLINE
          move method: move vertical line
static java.lang.String XML_CENTERX
          A XML string tag represents the center x coordinate
static java.lang.String XML_CENTERY
          A XML string tag represents the center y coordinate
static java.lang.String XML_HEIGHT
          A XML string tag represents the quadrant height
static java.lang.String XML_QUADRANT
          A XML string tag represents a Quadrant
static java.lang.String XML_WIDTH
          A XML string tag represents the quadrant width
 
Fields inherited from class com.jfimagine.jfgraph.shape.base.AbstractShape
m_boundsNodeList, m_fontFormat, m_label, m_nodeList, m_portList, m_propertyList, XML_DISABLEMODIFYINGPROPERTIES, XML_DISABLEMOTION, XML_DISABLESCALING, XML_INVISIBLE, XML_LABEL, XML_SHOWLABEL
 
Fields inherited from class com.jfimagine.jfgraph.shape.base.AbstractObject
m_lastError, XML_OBJECTID, XML_OBJECTTYPE
 
Constructor Summary
JFQuadrant()
          Constructor for Line
JFQuadrant(double x, double y)
          Constructor for Line
JFQuadrant(double x, double y, double width, double height)
          Constructor for Line
 
Method Summary
 void addNode(double x, double y)
          Add a new node for current node list.
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 isXorMode)
          Draw current object on graphic canvas.
 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.
 boolean finishDrawing()
          Finish drawing object.
 void flipBy()
          Reverse this object by a central y coordinate of this object.
 void flipBy(double baseY)
          Reverse this object by a y coordinate.
 Rect getBounds()
          Get the bounds of this rectangle.
 JFPoint getCenter()
          Get the center of this quadrant.
 double getHeight()
          Get the height of this quadrant.
 LineFormat getLineFormat()
          Get the line format of current quadrant.
 int getMoveMethod()
          get move method.
 double getWidth()
          Get the width of this quadrant.
 int hashCode()
          Returns the hashcode for this Object.
protected  void initLabel()
          Set the intial position of this internal label.
 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 isOpenShape()
          Ask if this object is an open shape,e.g. line,curve,arc,etc.
 void loadFromStream(JFReader stream, boolean skipHead, JFVersion version)
          Load object data from a binary stream
 void mirrorBy()
          Mirror this object by a central x coordinate of this object.
 void mirrorBy(double baseX)
          Mirror this object by a x coordinate.
 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.
 void rotateBy(double theta)
          Rotate this object by an angle theta.
 void rotateBy(double baseX, double baseY, double theta)
          Rotate current object by a specified point and an angle theta.
 void saveToStream(JFWriter stream, JFVersion version)
          Save this object to a binary stream
 void scaleBy(JFPoint basePoint, double xScale, double yScale)
          Scale current object by a specified x and y scale.
 void scaleBy(JFPoint basePoint, JFPoint refPoint1, JFPoint refPoint2, double scale)
          Scale current object by specified points and scale percent.
 void setCenter(double x, double y)
          Set the center of this quadrant.
 void setCenter(JFPoint center)
          Set the center of this quadrant.
 void setHeight(double height)
          Set the height of this quadrant.
 void setLineFormat(LineFormat lineFormat)
          Set the line format of current quadrant.
 void setMoveMethod(int moveMethod)
          set move method.
 void setSize(double width, double height)
          Set the Size of this quadrant.
 void setWidth(double width)
          Set the width of this quadrant.
 java.lang.String toString()
          Convert this object to String
 
Methods inherited from class com.jfimagine.jfgraph.shape.base.AbstractShape
addNode, addPort, attachPort, attachRealPort, attachRealPort, clearAccessTimes, detachPort, drawInvisibleBounds, drawLabel, drawLabelPicked, drawPicked, drawPort, fetchSubObjects, finishMoveLabel, finishMoveNode, getAccessTimes, getArrow, getFillFormat, getFontFormat, getLabel, getMoveNodePos, getNodeByIndex, getNodeByObjectId, getNodeCount, getNodeList, getPortByIndex, getPortByObjectId, getPortCount, getPortList, getPropertyByIndex, getPropertyByObjectId, getPropertyCount, getPropertyList, ifCompleteDrawing, incAccessTimes, initBoundsNodeList, isDisableModifyingProperties, isDisableMotion, isDisableScaling, isInvisible, isRotatable, labelIntersects, labelIntersects, movePort, moveRelationalPorts, nodeIntersects, pickPort, portIntersects, removeLastNode, removePort, rotateNode, setArrow, setDisableModifyingProperties, setDisableMotion, setDisableScaling, setFillFormat, setFontFormat, setInvisible, setLabel, setNodeList, setObjectId, setParent, setPortList, setZoomScale, startMoveLabel, startMoveNode, unboundBrokenPorts
 
Methods inherited from class com.jfimagine.jfgraph.shape.base.AbstractObject
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_QUADRANT

public static final java.lang.String XML_QUADRANT
A XML string tag represents a Quadrant

See Also:
Constant Field Values

XML_CENTERX

public static final java.lang.String XML_CENTERX
A XML string tag represents the center x coordinate

See Also:
Constant Field Values

XML_CENTERY

public static final java.lang.String XML_CENTERY
A XML string tag represents the center y coordinate

See Also:
Constant Field Values

XML_WIDTH

public static final java.lang.String XML_WIDTH
A XML string tag represents the quadrant width

See Also:
Constant Field Values

XML_HEIGHT

public static final java.lang.String XML_HEIGHT
A XML string tag represents the quadrant height

See Also:
Constant Field Values

MOVEMETHOD_NONE

public static final int MOVEMETHOD_NONE
move method: none

See Also:
Constant Field Values

MOVEMETHOD_HORIZONTALLINE

public static final int MOVEMETHOD_HORIZONTALLINE
move method: move horizontal line

See Also:
Constant Field Values

MOVEMETHOD_VERTICALLINE

public static final int MOVEMETHOD_VERTICALLINE
move method: move vertical line

See Also:
Constant Field Values

MOVEMETHOD_CENTER

public static final int MOVEMETHOD_CENTER
move method: move center(both lines)

See Also:
Constant Field Values

m_lineFormat

protected LineFormat m_lineFormat
quadrant format of current quadrant.


m_center

protected JFPoint m_center
Quadrant center


DEFAULT_SIZE

public static final int DEFAULT_SIZE
Default size(pixels) for perpendicular lines

See Also:
Constant Field Values

m_width

protected double m_width
Width for the horizontal line


m_height

protected double m_height
Height for the vertical line

Constructor Detail

JFQuadrant

public JFQuadrant()
Constructor for Line


JFQuadrant

public JFQuadrant(double x,
                  double y)
Constructor for Line


JFQuadrant

public JFQuadrant(double x,
                  double y,
                  double width,
                  double height)
Constructor for Line

Method Detail

getCenter

public JFPoint getCenter()
Get the center of this quadrant.

Returns:
The center

setCenter

public void setCenter(JFPoint center)
Set the center of this quadrant.

Parameters:
center - A new center of this quadrant.

setCenter

public void setCenter(double x,
                      double y)
Set the center of this quadrant.


setWidth

public void setWidth(double width)
Set the width of this quadrant. A width is used to represent the length of horizontal line.

Parameters:
width - A new width.

getWidth

public double getWidth()
Get the width of this quadrant. A width is used to represent the length of horizontal line.

Returns:
the width of current quadrant.

setHeight

public void setHeight(double height)
Set the height of this quadrant. A height is used to represent the length of vertical line.

Parameters:
height - A new height.

getHeight

public double getHeight()
Get the height of this quadrant. A height is used to represent the length of vertical line.

Returns:
the height of current quadrant.

setSize

public void setSize(double width,
                    double height)
Set the Size of this quadrant.

Parameters:
width - A width is used to represent the length of horizontal line.
height - A height is used to represent the length of vertical line.

getLineFormat

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

Overrides:
getLineFormat in class AbstractShape
Returns:
The line format.

setLineFormat

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

Overrides:
setLineFormat in class AbstractShape
Parameters:
lineFormat - A new line format.

getMoveMethod

public int getMoveMethod()
get move method. A move method indicates if one line(horizontal or line) or center has been picked.

Returns:
the move method

setMoveMethod

public void setMoveMethod(int moveMethod)
set move method. A move method indicates if one line(horizontal or line) or center has been picked.

Parameters:
moveMethod - A new move method.

getBounds

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

Overrides:
getBounds in class AbstractShape
Returns:
The bounds rectangle of current rectangle.

isOpenShape

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

Overrides:
isOpenShape in class AbstractShape
Returns:
true if open,false closed.

initLabel

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

Overrides:
initLabel in class AbstractShape

addNode

public void addNode(double x,
                    double y)
Add a new node for current node list. here this method will always be called by DrawState class or any drawing class.

Overrides:
addNode in class AbstractShape

draw

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

Specified by:
draw in class AbstractShape
Parameters:
g - A graphic canvas.
isXorMode - If is in xor mode now.

intersects

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

Specified by:
intersects in class AbstractShape
Parameters:
pnt - A JFPoint used to test intersection.

intersects

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

Specified by:
intersects in class AbstractShape
Parameters:
rect - A Rect used to test intersection.

scaleBy

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

Specified by:
scaleBy in class AbstractShape
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 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.
Please see AbstractShape.scaleBy for detailed description.

Specified by:
scaleBy in class AbstractShape
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

moveBy

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

Specified by:
moveBy in class AbstractShape

rotateBy

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

Specified by:
rotateBy in class AbstractShape
Parameters:
theta - A rotate angle.

rotateBy

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

Specified by:
rotateBy in class AbstractShape
Parameters:
theta - A rotate angle.

mirrorBy

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

Specified by:
mirrorBy in class AbstractShape

mirrorBy

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

Specified by:
mirrorBy in class AbstractShape
Parameters:
baseX - A mirror base x coordinate.

flipBy

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

Specified by:
flipBy in class AbstractShape

flipBy

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

Specified by:
flipBy in class AbstractShape
Parameters:
baseY - A flip base y coordinate.

moveNode

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

Overrides:
moveNode in class AbstractShape
Parameters:
node - Currently moving node.
g - current drawing canvas.

finishDrawing

public boolean finishDrawing()
Finish drawing object.

Overrides:
finishDrawing in class AbstractShape

toString

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

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

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 AbstractShape
Returns:
A clone of this instance.
java.lang.CloneNotSupportedException

hashCode

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

Overrides:
hashCode in class AbstractShape
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 AbstractShape
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 AbstractShape
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 AbstractShape
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 AbstractShape
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 AbstractShape
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.