com.jfimagine.jfgraph.shape.base
Class PortList

java.lang.Object
  |
  +--com.jfimagine.jfgraph.shape.base.AbstractObject
        |
        +--com.jfimagine.jfgraph.shape.base.ObjectList
              |
              +--com.jfimagine.jfgraph.shape.base.PortList
All Implemented Interfaces:
java.lang.Cloneable

public class PortList
extends ObjectList

PortList class. A port list is used to manipulate port issues.

Version:
$Revision: 1.1 $
Author:
CookieMaker

Field Summary
static java.lang.String XML_PORTLIST
          A XML string tag represents a Node List
 
Fields inherited from class com.jfimagine.jfgraph.shape.base.ObjectList
m_objectList, XML_OBJECTCOUNT, XML_OBJECTLIST
 
Fields inherited from class com.jfimagine.jfgraph.shape.base.AbstractObject
m_lastError, XML_OBJECTID, XML_OBJECTTYPE
 
Constructor Summary
PortList()
          Constructor for PortList
 
Method Summary
 Port addPort(Port port)
          Add a new port to port list.
 boolean attachPort(Port port)
          Attach one of current port list to a specified port of other shape.
 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 this list.
protected  AbstractObject cloneMe()
          Creates a new AbstractObject of the same class and with the same contents as this object.
 boolean detachAll()
          Detach all ports attached to this port list.
 boolean detachPort(Port port)
          Detach current port list to a specified port of other shape.
 void dividePort(JFPoint startPoint, JFPoint endPoint, JFPoint midPoint)
          Divide end points pair of all ports by a middle point of end points.
 void draw(java.awt.Graphics g)
          Draw current object on graphic canvas.
 void finishMoveNode(JFPoint newMoveNode, JFPoint newRefNode1, JFPoint newRefNode2, JFPoint newRefNode3)
          When finish move node, all of its relational ports will be moved concurrently,
 void flipBy(double baseY)
          Reverse this object by a y coordinate.
 int getIndex(Port port)
          Get the index of a port within the list.
 JFPoint getMoveNode()
          Get the moveNode point.
 int getMoveNodeType()
          Get type of the moving node.
 JFPoint getRefNode1()
          Get the refNode1 point.
 JFPoint getRefNode2()
          Get the refNode2 point.
 JFPoint getRefNode3()
          Get the refNode3 point.
 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 movePort(JFPoint startPoint, JFPoint endPoint, JFPoint newStartPoint, JFPoint newEndPoint)
          Move ports that between the two end points, to two new end points position.
 void moveRelationalPorts(ObjectList movedList)
          move relational ports.
 Port pickPort(double x, double y)
          Pick a port within this port list, according to the current x,y position
 Port portIntersects(JFPoint pnt)
          Get which port that intersects with point pnt.
 boolean removePort(Port port)
          Remove a port from this shape.
 void rotateBy(double baseX, double baseY, double theta)
          Rotate current object by a specified point and an angle theta.
 void scaleBy(JFPoint basePoint, double xScale, double yScale)
          Scale current portlist by a specified x and y scale.
 void scaleBy(JFPoint center, JFPoint basePoint, JFPoint refPoint1, JFPoint refPoint2, double scale)
          Scale current port list by specified points and scale percent.
 void setParent(AbstractObject obj)
          Set parent object of each port in the list.
 void setParentId(int parentId)
          Set parent object id of each port in the list.
 void setZoomScale(double zoomScale)
          set zoom scale of all ports.
 void startMoveNode(JFPoint moveNode, JFPoint refNode1, JFPoint refNode2, JFPoint refNode3, int nodeType)
          When start move node, all of its relational ports will be moved concurrently, so we 'register' a start moving node event here.
 void unboundBrokenPorts()
          unbound broken ports.
 
Methods inherited from class com.jfimagine.jfgraph.shape.base.ObjectList
add, add, appendChildToDOM, attachRealPort, bringToFront, clear, clone, contains, equals, extractChildFromDOM, getBounds, getByIndex, getByObjectId, getFromGroupsByObjectId, getIndexByObjectId, getList, hashCode, loadFromStream, moveObject, newObjectId, removeAll, removeByIndex, removeByObjectId, saveToStream, sendToBack, setList, setShowDesign, size, toString
 
Methods inherited from class com.jfimagine.jfgraph.shape.base.AbstractObject
fromDOM, getLastError, getMaxObjectId, getObjectId, getObjectType, getXMLTag, getZoomScale, isShowDesign, setLastError, setObjectId, setObjectType, setValue, setXMLTag, toDOM
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

XML_PORTLIST

public static final java.lang.String XML_PORTLIST
A XML string tag represents a Node List

See Also:
Constant Field Values
Constructor Detail

PortList

public PortList()
Constructor for PortList

Method Detail

addPort

public Port addPort(Port port)
Add a new port to port list.

Parameters:
port - A new port.
Returns:
the port to be added.

getIndex

public int getIndex(Port port)
Get the index of a port within the list.

Parameters:
port - A port to be found.
Returns:
The index.

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.

Overrides:
cloneMe in class ObjectList
Returns:
A clone of this class.
java.lang.CloneNotSupportedException

draw

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

Parameters:
g - A graphic canvas.

getMoveNode

public JFPoint getMoveNode()
Get the moveNode point.

Returns:
the moveNode point

getRefNode1

public JFPoint getRefNode1()
Get the refNode1 point.

Returns:
the refNode1 point

getRefNode2

public JFPoint getRefNode2()
Get the refNode2 point.

Returns:
the refNode2 point

getRefNode3

public JFPoint getRefNode3()
Get the refNode3 point.

Returns:
the refNode3 point

getMoveNodeType

public int getMoveNodeType()
Get type of the moving node.

Returns:
the type of the moving node.

startMoveNode

public void startMoveNode(JFPoint moveNode,
                          JFPoint refNode1,
                          JFPoint refNode2,
                          JFPoint refNode3,
                          int nodeType)
When start move node, all of its relational ports will be moved concurrently, so we 'register' a start moving node event here.

Parameters:
moveNode - Currently moving node.
nodeType - The type of the moving node(defined in JFPointNode).

finishMoveNode

public void finishMoveNode(JFPoint newMoveNode,
                           JFPoint newRefNode1,
                           JFPoint newRefNode2,
                           JFPoint newRefNode3)
When finish move node, all of its relational ports will be moved concurrently,

Parameters:
newMoveNode - Currently moving node.

movePort

public void movePort(JFPoint startPoint,
                     JFPoint endPoint,
                     JFPoint newStartPoint,
                     JFPoint newEndPoint)
Move ports that between the two end points, to two new end points position.


dividePort

public void dividePort(JFPoint startPoint,
                       JFPoint endPoint,
                       JFPoint midPoint)
Divide end points pair of all ports by a middle point of end points.

Parameters:
midPoint - A middle point to divide ports' end points.

pickPort

public Port pickPort(double x,
                     double y)
Pick a port within this port list, 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.

scaleBy

public void scaleBy(JFPoint center,
                    JFPoint basePoint,
                    JFPoint refPoint1,
                    JFPoint refPoint2,
                    double scale)
Scale current port list 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:
center - A center point of these all ports.
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 portlist 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.

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.


rotateBy

public 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 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 void flipBy(double baseY)
Reverse this object by a y coordinate. We make a up-down flip here.

Parameters:
baseY - A flip base y coordinate.

attachPort

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

Parameters:
port - A new port of other shape.

detachPort

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

Parameters:
port - A port of other shape.

detachAll

public boolean detachAll()
Detach all ports attached to this port list.


moveRelationalPorts

public void moveRelationalPorts(ObjectList movedList)
move relational ports.

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

unboundBrokenPorts

public void unboundBrokenPorts()
unbound broken ports.


setParentId

public void setParentId(int parentId)
Set parent object id of each port in the list.

Parameters:
parentId - A new id of a parent object.

setParent

public void setParent(AbstractObject obj)
Set parent object of each port in the list.

Parameters:
obj - A new parent object.

portIntersects

public Port portIntersects(JFPoint pnt)
Get which port that intersects with point pnt.

Parameters:
pnt - A JFPoint used to test intersection.
Returns:
A port intersects the point.

setZoomScale

public void setZoomScale(double zoomScale)
set zoom scale of all ports.

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

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

Overrides:
attachRealPort in class ObjectList
Parameters:
shapeList - A shapeList used to pick out their ports for ports' attached list


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