|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--com.jfimagine.jfgraph.shape.base.AbstractObject
|
+--com.jfimagine.jfgraph.shape.base.AbstractShape
Abstract Shape class. All shapes should extends/instances this class.
| 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 |
public static final java.lang.String XML_LABEL
public static final java.lang.String XML_SHOWLABEL
public static final java.lang.String XML_DISABLESCALING
public static final java.lang.String XML_DISABLEMODIFYINGPROPERTIES
public static final java.lang.String XML_DISABLEMOTION
public static final java.lang.String XML_INVISIBLE
protected PortList m_portList
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.
protected NodeList m_nodeList
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.
protected NodeList m_boundsNodeList
protected PropertyList m_propertyList
A property is customized and defined by client.
Each shape should has one or more proproties.
protected Label m_label
protected FontFormat m_fontFormat
| Constructor Detail |
public AbstractShape()
| Method Detail |
public Arrow getArrow()
public void setArrow(Arrow arrow)
arrow - A new arrow format object.public LineFormat getLineFormat()
public void setLineFormat(LineFormat lineFormat)
lineFormat - A new line format.public FillFormat getFillFormat()
public void setFillFormat(FillFormat fillFormat)
fillFormat - A new fill format.public Label getLabel()
public void setLabel(Label aLabel)
aLabel - A new internal label.protected void initLabel()
public boolean isDisableScaling()
public void setDisableScaling(boolean disable)
public boolean isDisableModifyingProperties()
public void setDisableModifyingProperties(boolean disable)
public boolean isDisableMotion()
public void setDisableMotion(boolean disable)
public boolean isInvisible()
public void setInvisible(boolean invisible)
protected void startMoveLabel()
protected void finishMoveLabel()
public FontFormat getFontFormat()
public void setFontFormat(FontFormat fontFormat)
fontFormat - A new font format.public int getAccessTimes()
public int incAccessTimes()
public void clearAccessTimes()
public void setZoomScale(double zoomScale)
setZoomScale in class AbstractObjectzoomScale - A new zoom scale.public void setObjectId(int objectId)
setObjectId in class AbstractObjectobjectId - The object id.public void setParent()
public int getNodeCount()
public ObjectList getNodeList()
public void setNodeList(ObjectList nodeList)
nodeList - A new node list.
public Node getNodeByIndex(int index)
throws ListException
index - An index of node
ListException
public Node getNodeByObjectId(int objectId)
throws ListException
objectId - Object id for specified node.
ListExceptionpublic void addNode(JFPoint pnt)
pnt - A new point for node.
public void addNode(double x,
double y)
public boolean isRotatable()
public boolean isOpenShape()
public void rotateNode(JFPoint nodePoint,
JFPoint rotateCenter,
double x,
double y,
java.awt.Graphics g)
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.
public JFPoint getMoveNodePos(Node node,
JFPoint movePos,
int moveCase)
movePos - Desire moving position of a node.moveCase - Move case of a node, normal, shift key pressed or ctrl key pressed
public void startMoveNode(Node node)
node - The node will be moved.
public void moveNode(Node node,
double x,
double y,
java.awt.Graphics g)
node - Currently moving node.g - current drawing canvas.
public void finishMoveNode(Node node,
double x,
double y,
java.awt.Graphics g)
node - Currently moving node.g - current drawing canvas.public boolean ifCompleteDrawing()
public boolean finishDrawing()
public Port addPort(double x,
double y)
public Port pickPort(double x,
double y)
public boolean removePort(Port port)
port - A port to be removed.public boolean attachPort(Port port)
port - A new port of other shape.public boolean detachPort(Port port)
port - A port of other shape.public void fetchSubObjects(ObjectList objList)
public void attachRealPort()
public void attachRealPort(ObjectList shapeList)
shapeList - A shapeList used to pick out their ports for ports' attached listpublic Node removeLastNode()
public int getPortCount()
public ObjectList getPortList()
public void setPortList(ObjectList portList,
ObjectList shapeList)
portList - A new port list.shapeList - All shape objects in a list.
public Port getPortByIndex(int index)
throws ListException
index - An index of port
ListException
public Port getPortByObjectId(int objectId)
throws ListException
objectId - Object id for specified port.
ListExceptionpublic int getPropertyCount()
public ObjectList getPropertyList()
public Property getPropertyByIndex(int index)
throws ListException
index - An index of property
ListException
public Property getPropertyByObjectId(int objectId)
throws ListException
objectId - Object id for specified property.
ListExceptionpublic Rect getBounds()
public void drawLabel(java.awt.Graphics g)
g - A graphic canvas.public void drawLabelPicked(java.awt.Graphics g)
g - A graphic canvas.public void drawPort(java.awt.Graphics g)
g - A graphic canvas.
public void drawPicked(java.awt.Graphics g,
boolean ifRotate)
g - A graphic canvas.ifRotate - If user's operation or other actions force objects to be rotated.protected void initBoundsNodeList()
public void drawInvisibleBounds(java.awt.Graphics g,
boolean isXorMode)
g - A graphic canvas.isXorMode - If is in xor mode now.
public Node nodeIntersects(JFPoint pnt,
int usage)
pnt - A JFPoint used to test intersection.usage - Purpose to get a node intersected, e.g. move or rotate.
public Port portIntersects(JFPoint pnt,
AbstractObject avoidParent)
pnt - A JFPoint used to test intersection.avoidParent - A specified avoided parent to avoid connected to self.
public Label labelIntersects(java.awt.Graphics g,
JFPoint pnt)
g - A graphics context used to measure current text size on this graphics context.pnt - A JFPoint used to test intersection.
public Label labelIntersects(java.awt.Graphics g,
Rect rect)
g - A graphics context used to measure current text size on this graphics context.rect - A rectangle used to test intersection.
public boolean movePort(Port port,
double x,
double y)
port - Currently moving port.
public void moveRelationalPorts(ObjectList movedList)
movedList - An object list that has already processed, so don't change them further.public void unboundBrokenPorts()
public java.lang.String toString()
toString in class AbstractObject
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class AbstractObjectjava.lang.CloneNotSupportedExceptionpublic int hashCode()
hashCode in class AbstractObjectpublic boolean equals(java.lang.Object obj)
equals in class AbstractObjectobj - an object to be compared with this object
protected void appendChildToDOM(Element element,
JFVersion version)
appendChildToDOM in class AbstractObjectelement - A XML element to append child xml nodesversion - A file version notification so this object can obey the rules to save data.
protected void extractChildFromDOM(Element element,
JFVersion version)
extractChildFromDOM in class AbstractObjectelement - An element used to extract needed xml childversion - A file version notification so this object can obey the rules to fetch data.
public void saveToStream(JFWriter stream,
JFVersion version)
throws java.io.IOException
saveToStream in class AbstractObjectstream - An binary output streamversion - A file version notification so this object can obey the rules to save data.
java.io.IOException
public void loadFromStream(JFReader stream,
boolean skipHead,
JFVersion version)
throws java.io.IOException
loadFromStream in class AbstractObjectstream - An binary input streamskipHead - 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.
java.io.IOException
public abstract void draw(java.awt.Graphics g,
boolean isXorMode)
g - A graphic canvas.isXorMode - If is in xor mode now.public abstract boolean intersects(JFPoint pnt)
pnt - A JFPoint used to test intersection.public abstract boolean intersects(Rect rect)
rect - A Rect used to test intersection.
public abstract void moveBy(double x,
double y)
public abstract void scaleBy(JFPoint basePoint,
JFPoint refPoint1,
JFPoint refPoint2,
double scale)
basePoint - A base point that is unmovable.refPoint1 - A 'width' reference point.refPoint2 - A 'height' reference point.scale - A reference scale percent.
public abstract void scaleBy(JFPoint basePoint,
double xScale,
double yScale)
basePoint - A base scale point for scaling reference.xScale - A scale percentage in x coordinate, default to 1.0yScale - A scale percentage in y coordinate, default to 1.0public abstract void rotateBy(double theta)
theta - A rotate angle.
public abstract void rotateBy(double baseX,
double baseY,
double theta)
theta - A rotate angle.public abstract void mirrorBy()
public abstract void mirrorBy(double baseX)
baseX - A mirror base x coordinate.public abstract void flipBy()
public abstract void flipBy(double baseY)
baseY - A flip base y coordinate.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||