Java Drawing DrawTop

Language

JP  US  UK

 

Connector

 H. Jyounishi, Tokyo Japan
 

Frame (Index), No frame                 version:0.3(latest)  

Summary:
One of the features of this application is that the connector can be connected to an arbitrary point on the a shape boundary, and the shape boundary can be connected by any number of connectors.
Classes on this page: Connection, ConnectionUtil, TargetContainer, ConnectionContainer

1. Overview
1.1 Connects a connector to a shape boundary

A straight line and polyline can be a connector which connects two shape objects. If an endpoint of a connector is moved toward a shape's boundary by the mouse drag, then then a red/blue mark will be displayed on the shape's boundary (Figure 1.1). And if the mouse button is released while the red/blue mark is displayed, then the connector will be connected to the shape's boundary very accurately.
The connection point (the red/blue mark) is represented by the Connection object which consists of the fields specifying the connector and the target shapes, and the two curve parameters representing the connection point. If the target shape is moved/resized or modified in the MoveResizeShapeLS or ModifyShapeLS object, then the connector manager (ConnectionUtil) moves the endpoints (connection points) of the connectors by referring the data of the Connection object and maintains the connections with the target shapes .
=> Connecting a connector in MoveResizeShapeLS, ConnectionLS Overview, User's guide Connector
One of the features of this application is that the connector can be connected to an arbitrary point on the a shape's boundary, and any number of connectors can be connected to the shape's boundary as shown in the Figure 1.1.



Figure 1.1 Sample drawing


1.2 Maintaining the connection
If a shape connected with connectors is moved or resized, then the connector manager (ConnectionUtil) moves the endpoints of the connectors to maintain the connections with the target shape (Figure 1.2, 1.3).


Figure 1.2 Maintaining the connection with the target shape.
The selected arrow-like-polygon was moved to the upper left from the initial position in Figure 1.1.
The small red marks represent the connection points.



Figure_(a)

Figure_(b)

Figure_(c)

Figure (d)

Figure 1.3 Maintaining the connection with the shape.

When the "keyboard" box is moved in Figure_(a), the connections (red marks) with the two solid lines are maitained and also the connections (pink marks) between the solid lines and the dotted lines are maintained (Figure_(b))
The set of Figure_(c) and (d) show an extreme case. The color marks represent the depth from the root node (the shape being moved) in graph.


Step

Description
Step1 Finding connectors The MoveResizeShapeLS.start method calls the ConnectionUtil.setTargets method which creates the list of the target shapes and the connectors.
The setTargets method creates the list of the target shapes and calls the ConnectionUtil.setConnectors method to gets connectors which are connecting the target shapes. To find other connectors which may be connecting the already found connectors, calls the setConnectors method repeatedly (Figure 1.3 (c)).
The setConnectors method calls the findConnectors method to find the connectors connecting to the target shape.
The findConnectors method tests for all the existing connectors (lines and polylines) whether their endpoints are on the target shape boundary or not. To do this test, the findConnectors method uses the Curve2DUtil.getProjectionLines and Curve2DUtil.getShortestLine method.
Step2 Maintaining the connections While the target shapes is moved or resized by the mouse drag, the MoveResizeShapeLS.mouseDragged method calls the ConnectionUtil.resizeConnectors method. The resizeConnectors method moves the endpoints of the connectors to maintain the connections with the target shapes.
Step3 Post process When the mouse button is released, the mouseReleased method of the MoveResizeShapeLS calls the ConnectionUtil.end method for the post processing.

: Connectors and target shapes have no information about their connection, even if they are connected. There is no particular reason for it. An simple reason is that the processing is possible without such information.

1.3 Auto tracking option of connectors

When the connector manager (the ConnectionUtil object) moves the endpoints of connectors, the directions and positions of the connectors are constrained by the option (auto tracking option).

∙ free direction and free position: no constrain.
∙ keep x/y direction and position: preserves the direction of a connector, if the connector's direction is x or y.

Figure 1.4 shows the example how the connectors' endpoints and direction will be changed, if the rectangle is moved downward by the mouse drag (the red marks represent connection points).
Figure 1.5 and Figure 1.6 show typical examples such as bolck diagrams, flow charts etc. The "auto tracking option" may be very useful in these applications.


original
Moves the rectangle downward

(a)option: free direction and free position

The connectors change their directions freely.

(b) option: keep x/y direction and position
The connectors don't change their directions.

(b) option: keep x/y direction and position
If the target shapes is moved largly, then some x/y connectors change to polyline connectors.

Figure 1.4 Auto tracking option of connectors






Original

If the top rectangle is moved upward, then the line connector changes it direction.
(a)option: free direction and free position

If the top rectangle is moved upward largely ,the line connector changes to a polyline connector.
(b) option: keep x/y direction and position

If the vertical line is moved upward, then the line connectors connecting to the line changes their directions.
(a)option: free direction and free position

Although the vertical line is moved upward, then the line connectors connecting to the line doesn't changes their directions. 
(b) option: keep x/y direction and position

Figure 1.5 Typical example of the auto tracking optionof connectors -1





Original

If the right rectangle is moved downward, then the line connectors change their directions.
(a)option: free direction and free position

If the right rectangle is moved downward largely, then some line connectors change to polyline connectors.
(b) option: keep x/y direction and position

Figure 1.6 Typical example of the auto tracking optionof connectors - 2


1.4 Moving a connector along guide lines (curves)
This function is used to move lines in a table. The way of the processing is similar to 1.2 with "keep x/y direction and position" option.

Moves the vertical line to the right with holding down the Ctrl key.

The connections (red marks) can be preserved.

Figure 1.7 The effect of the Ctrl key


2.Class Connection return=>page top
The Connection class represents the connection information between two shape objects (a connector shape and a target shape). The connection information includes the link to two shape objects and the connection point between them. The connection point is represented by the curve parameter on the connector and the curve parameter on the target shape boundary (see=> Parametric curve). When the target shape is moved or resized by the mouse drag, the connection point should change its (x,y) coordinates to maintain its connection, but the curve parameters of the connection points doesn't change in the most simple case (auto tracking option: direction free). It is very convenient for connector processing to represent a connection point by a curve parameter.

Field Description
target public ShapeContainer target
The target shape object
connector

public ShapeContainer connector
The connector shape object

targetParameter

public double targetParameter
The curve parameter of the connection point on the target shape boundary.

connectorParameter

public double connectorParameter
The curve parameter of the connection point on the connector.


Method Description
Constructor public Connection(ShapeContainer connector, ShapeContainer target, double connectorParameter, double targetParameter)
Sets the parameters to the corresponding field.
getTarget public ShapeContainer getTarget()
Returns the target field.
getConnector public ShapeContainer getConnector()
Returns the connector field.
getTargetParameter public double getTargetParameter()
Returns the targetParameter field.
getConnectorParameter public double getConnectorParameter()
Returns the connectorParameter field.
getTargetPT public Point2D getTargetPT()
Returns the connection point on the target shape boundary.
getConnectorPT public Point2D getConnectorPT()
Returns the connection point on the connector.
equalsInNormalData public boolean equalsInNormalData(Connection connection)
Parameters:
connection - The Connection object to be compared.
Processing:
Returns true if each field of this this object equals that of the connection parameter.
equalsInReversedData public boolean equalsInReversedData(Connection connection)
Parameters:
connection - The Connection object to be compared.
Processing:
Returns true if each field of this object equals each opposite field of the connection.
In other words, compares the connector field of this object with the target field of the connection, compares the target field of this object with the connector field of the connection, compares the connectorParameter field of this object with the targetParameter field of the connection, and finally compares the targetParameter field of this object with the connectorParameter field of the connection.
getErrorDistance public double getErrorDistance()
Returns the numerical error between the connection point on the target shape and that on the connector.
closeToMouseHitShape private boolean closeToMouseHitShape(MouseHitShape mouseHitShape)
Parameters:
mouseHitShape - The MouseHitShape object containing the mouse position and an ShapeContainer.
Returns:
Returns true, if the target shape of this object equals the shape in the mouseHitShape and the endpoint of the connector of this object is close to the mouse position of the mouseHitShape.
See=> The problem of connector
resizeConnector private void resizeConnector(Point2D oldPoint, Point2D newPoint)
Parameters:
oldPoint - The current endpoint the connector.
newPoint - The new endpoint the connector.
Processing:
This method updates the endpoint of the connector from oldPoint to newPoint.
To do this, the method calls the ShapeElement.moveEndpoint method.
resizeTarget private void resizeTarget(Point2D oldPoint, Point2D newPoint)
Parameters:
oldPoint - The current endpoint the target.
newPoint - The new endpoint the target.
Processing:
This method updates the endpoint of the target (line/open polyline) from oldPoint to newPoint. To do this, the method calls the ShapeElement.moveEndpoint method.
toString public String toString()
Returns the string representing this object.
isConnectorType
(static)
private static boolean isConnectorType(ShapeContainer connector)
Returns true if the shape denoted by connector has the qualification of the connector.
isTargetType
(static)
private static boolean isTargetType(ShapeContainer target)
Returns true if the shape denoted by target allows to be connected with a connector.


3. Class ConnectionUtil return=>page top
This class provides the easy and macro level methods for the operation of resizing or transforming the connectors which are connecting to the target shape. Only the three methods - setTargets, resizeConnectors and end - are called when the target shape is moved or resized.
Field Description
mousePositionInfo MousePositionInfo mousePositionInfo
Sets the MousePositionInfo passed from MoveResizeShapeLS
selectedContainers ShapeContainer[] selectedContainers
Sets the selectedContainers passed from MoveResizeShapeLS
auto_tracking_option int auto_tracking_option
Sets DrawParameters.CONNECTOR_AUTO_TRACKING_OPTION to this field.
connected public boolean connected
This field becomes true if a connector is moved and succeeded to connect a shape boundary (Moving/Resizing shape Fig. 2.1, 2.2).
guided public boolean guided
This field becomes true if a connector is moved along guide lines (Moving/Resizing shape Fig 1.6).
targets ShapeContainer[] targets
This array is specified by the parameter of the setTargets method and stored with the target shapes to be moved/resized. The targets[i] can be a group of shapes.
TargetList Vector TargetList
Stores TargetContainer objects referring the targets.
If the target[i] is a group of shapes, then decomposes it into single shapes and sets them to new TargetContainer objects , otherwise sets the target[i] to a new TargetContainer object.
ConnectionList Vector ConnectionList
Stores ConnectionContainer objects.
mouseHitShape MouseHitShape mouseHitShape
The MouseHitShape object representing the target shape on which the mouse button is pressed.
vector Vector vector:Vector object for work.

Method Description
start public void start(int mode, MousePositionInfo mousePositionInfo, ShapeContainer[] selectedContainers)
• Sets the arguments to the corresponding fields.
• Call the setTargets method of this class.
: This method is implemented in order to avaid that the MoveResizeShapeLS.init method becomes too complicated and called from the MoveResizeShapeLS.init method.
end public void end()
mouseDragged public void mouseDragged(MouseEvent e)
• Moves the end point of a connector(line/polyline).

Checks that the end point of a connector can be connected other shape boundary. If it can be connected, sets the connected field true (Moving/Resizing shape Fig. 2.1, 2.2).

• When a shape is moved, the connectors connecting to the moving shape are transformed to keep their connections by calling the resizeConnectors method of this class.

: This method is implemented in order to avaid that the MoveResizeShapeLS.mouseDragged method becomes too complicated and called from the MoveResizeShapeLS.mouseDragged method.
mouseReleased public void mouseReleased(MouseEvent e)
• mode=Command.MOVING_ENDPT_MODE

If the connected field is not true, calls the resizeConnectors method of this class.

• mode=Command.MOVE__MODE/RESIZE__MODEの

Calls the resizeConnectors method of this class unconditionally.
: This method is implemented in order to avaid that the MoveResizeShapeLS.mouseReleased method becomes too complicated and called from the MoveResizeShapeLS.mouseReleased method.

setTargets public void setTargets(ShapeContainer[] targets)
Parameters:
targets - The target shapes to be moved or resized. The targets[i] can be a group of shapes.
Processing:
This method decomposes each of the targets to single shape ShapeContainer objects (ShapeElement Figure 11.1 ) by the ShapeContainer.getGroupedSingleShapeContainers method and stores them to to the targetElements.
Next, this method calls the setConnectors method to list up the connectors which connect to the listed target shapes and registers their ConnectionContainer objects to the ConnectionList.
: If the listed connectors are connected with other connectors, calls the setConnectors method repeatedly until the listed connectors are not connected with any other connector (Depth, TargetList, ConnectionList)
setConnectors private ShapeContainer[] setConnectors(int depth, ShapeContainer[] targetElements)
Parameters:
depth - The depth of targetElements from the root nodes (the target shapes of depth-0) in tree structure (Depth, TargetList, ConnectionList).
targetElements - The shape (ShapeContainer) objects to which all the existing connectors are tested to connect or not.
Returns:
The connector (ShapeContainer) objects which connect to the targetElements.
Processing:
∙ First, this method creates a new TargetContainer object with the parameters of the targetElements[i] and depth, and add the TargetContainer object to the TargetList.
∙ Next, this method calls the findConnectors method to search connectors which connect to the targetElements .
The findConnectors method returns the Connection objects representing the connections with the targetElements. Each of the returned Connection objects is set to a new ConnectionContainer object, and the new ConnectionContainer object is registered to the ConnectionList, if the connector in the Connection object doesn't match to the connector in the mouseHitShape. Here the id of the new ConnectionContainer is "connector".
This matching test is done by the closeToMouseHitShape method.
∙ Finally, this method collects the connectors from the Connection objects returned from the findConnectors, and returns the connector.
findConnectors private Connection[] findConnectors(ShapeContainer target)
Parameters:
target - The target shape object.
Returns:
Returns the Connection objects which represent the connections between the target and connectors connecting to the target.
Processing:
This method is called by the setConnectors method.
This method tests for all the existing connectors whether or not the endpoints of the each connector is lying on the boundary of the target shape within the given error margin (1e-2 pixel).
To do this test, this method uses the Curve2DUtil.getShortestLine method.
setGuideLines private void setGuideLines()
This method is called from the setTragets method.
This method finds a guide line (Figure 1.7) for each of the targets with depth-0 which are registered in the TargetList. To find a guide line, this method calculates the shortest distance from an endpoint of each of the targets to an existing connector by the Curve2DUtil.getShortestLine method. If the shortest distance is lower than the predefined margin, then the guide line is found. If the guide line is found, then creates a Connection object representing the connection between one of the targets and the guide line. And sets Connection object to a new ConnectionContainer object, and registers the new ConnectionContainer object to the ConnectionList. Here the id of the new ConnectionContainer is "guide_line".
printTargerList private void printTargerList(String message)
Prints the TargetList.
printConnectionList private void printConnectionList(String message)
Prints the ConnectionList.
getTargets private ShapeContainer[] getTargets(int depth)
Parameters:
depth - The depth of from the root nodes (the target shapes to be moved/resized) in tree structure (Figure 3.1).
Returns:
The ShapeContainer objects which are stored in the TargetList as TargetContainer objects and whose depth equals the parameter depth.
getTargetIndex private int getTargetIndex(ShapeContainer target, int depth)
Parameters:
target - The target shapes (ShapeContainer objects) to be moved/resized.
depth - The depth of from the root nodes (the target shapes to be moved/resized) in tree structure (Figure 3.1).
Returns:
Returns the index of the target of the depth in the TargetList.
getConnection
Containers
private ConnectionContainer[] getConnectionContainers(String id, int depth,
ShapeContainer target, ShapeContainer connector)

Parameters:
id - The string id which is set to the ConnectionContainer. Currently, "connector" and "guide_line" are used for id.
depth - The depth of from the root nodes (the target shapes to be moved/resized) in tree structure.
if depth<0, then ConnectionContainer objects in any depth must be checked.
target - The ShapeContainer object which is compared with Connection.target in ConnectionContainer objects.
connector - The ShapeContainer object which is compared with Connection.connector in ConnectionContainer objects.
:The target or the connector can be null.
Returns:
The Connection object of the ConnectionContainer whose target equals target, whose connector equals connector and the id of the ConnectionContainer equals id.
getConnection
Containers
private ConnectionContainer[] getConnectionContainers(String id, ShapeContainer target, ShapeContainer connector) Processing:
Calls the above method as follow.
return getConnectionContainers(id, -1, target, connector);
getSameConnection
Container
private int getSameConnectionContainer(ConnectionContainer connectionContainer)
paremeters:
connectionContainer - The ConnectionContainer object.
Returns:
The index of the connectionContainer in the ConnectionList. Returns -1, if the ConnectionList does not contain the connectionContainer.
The matching test of the connectionContainer with a ConnectionContainer object in the ConnectionList is done by the equalsInNormalData and equalsInReversedData methods of the Connection.
getConnectors public ShapeContainer[] getConnectors(String id)
Retrieves the ConnectionContainer objects specified by id from the the ConnectionList, gets connectors from the the ConnectionContainer objects and returns the connectors as an array.
getTargetsAnd
Connectors
public ShapeContainer[] getTargetsAndConnectors()
Returns the connectors and the target shape objects.
resizeConnectors public void resizeConnectors(int option)
Parameters:
option - Command.FREE_DIRECTION, KEEP_XY_DIRECTION, KEEP_DIRECTION or TO_NEAREST_PT
Processing:
∙ Resizes the connectors of depth n (n=1,2,...)
Gets the connectors of depth-n by the getTargets method and resizes them by the resizeConnectors method.
: This method is called by the following methods.
∙ The mouseDragged and mouseReleased methods of the MoveResizeShapeLS.
∙ The mouseDragged method of the ModifyShapeLS
resizeConnectors private void resizeConnectors(int option, int depth, ShapeContainer[] connectors)
Parameters:
option - Command.FREE_DIRECTION, KEEP_XY_DIRECTION, KEEP_DIRECTION or TO_NEAREST_PT
depth - The depth of from the root nodes (the target shapes to be moved/resized) in tree structure.
connectors - The connectors (ShapeContainer objects) to be resized.
Processing:
This method calls the resizeConnectorByCurveParameter, resizeConnectorKeepingDirection or resizeConnectorToNearestPT method of the Connection according to the option parameter.
resizeConnectorBy
Curve
Parameterr
public void resizeConnectorByCurveParameter()
This method is called by the resizeConnectors method of the class.
This method is used for moving the endpoint of the connector to maintain the connection with the target shape when the target shape is moved or resized. The endpoint of the connector is moved under the condition that the curve parameter (targetParameter) of the connection point shouldn't change. To move the end point of the connector, this method calls the resizeConnector method of this class.
resizeConnectorTo
Nearest
PT
public void resizeConnectorToNearestPT()
This method is called by the resizeConnectors method of the class. When the target shape is largely changed, for example, a node point of a polyline/a cubic curve is deleted, this method moves the endpoint of the connector to the nearest point on the boundary of the target shape. Here, the nearest point is calculated by the ShapeElement.getSamplingCurvePTs method.
To move the end point of the connector, this method calls the resizeConnector method of this class.
: In this method, the target shape itself is changed, so the targetParameter must be changed to represent a new connection point.
resizeConnector
KeepingDirection
public boolean resizeConnectorKeepingDirection (ConnectionContainer connectionContainer)
Parameters:
connectionContainer - The ConnectionContainer object that represents a connection with a target shape and a connector.
Return:
True if resizing of the connector succeeds.
If the projection point doesn't exist on the the boundary the target shape, then resizing of the connector will fail (see the figure below). In this care this method returns false.
Processing:
This method is called by the resizeConnectors method of the class.
This method is used to move the end point of the connector with keeping the connector's direction. The end point of the connector is moved to lie on the extension of the connector. So the new end point of the connector will be one of the intersection points between the extension of the connector and the boundary of the target shape. The intersection points are calculated by the projectionPT method of this class using the Curve2DUtil.getProjectionLines method.
: In this method, the target shape itself is changed, so the targetParameter must be changed to represent a new connection point..
projectionPT private CurvePT[] projectionPT(Point2D p, Vector2D vec, Curve2D targetCurve)
Parameters:
p - The point.
vec - The projection vector.
targetCurve - The boundary curve of the target shape.
Returns:
The CurvePT objects which represent the projection points of the p on the targetCurve.
Processing:
Calculates the projection points by the Curve2DUtil.getProjectionLines method.

selectCurvePT private CurvePT selectCurvePT(ConnectionContainer connectionContainer, CurvePT[] curvePTs)
Parameters:
connectionContainer - The ConnectionContainer object of a connection with a target shape and a connector.
curvePTs - The returned values of the projectionPT method.
Returns::
The selected CurvePT object.
Processing:
Returns the nearest curvePT object to the p along vec direction in the above figure.
isChangable private boolean isChangable(ShapeContainer connector) <Parameters:
connector - The connector.
Returns::
Returns true if the line connector (connector) can be changed to a polyline conenctor, or if the polyline connector (connector) can be changed to a line conenctor.
<Processing:
Judges tru/false as follows.
∙ The connector that is originally a polyline can't be changed to a line connector.
∙ A x/y line connector can be changed to a polyline connector.
∙ The polyline connector that was changed from a line connector can be changed to a line connector.



(a) Original
Moves the ellipse downward.

(b) The line connector is changed to a polyline connector.

(c) Moves the ellipse upward, then the polyline connector returns to a line connector.

(c) Moves the ellipse upward largely, then the line connector is changed to a polyline connector again.
changeToPolyline
Connector
private void changeToPolylineConnector(ConnectionContainer connectionContainer)
Parameters:
connectionContainer - The ConnectionContainer object.
Processing:
Changes the line connector in the connectionContainer to a polyline connector.
changeToLineConnector private void changeToLineConnector(ConnectionContainer connectionContainer, CurvePT curvePT)
Parameters:
connectionContainer - The ConnectionContainer object.
curvePT - See the figure below.
Processing:
Changes the polyline connector in the connectionContainer to a line connector.

Draws the dotted line from the polyline segment and calculates the intersection (projection) point (curvePT) by the projectionPT and selectCurvePT methods.


Changes the polyline connector to the line connector that connects the round rectangle and the curvePT on the ellipse.
resizeTargetsBy
GuideLines
public boolean resizeTargetsByGuideLines()
Return:
Returns true if the targets were moved and resized along guide lines.
Processing:
Move and resize the targets of depth-0 in the TargetList along guide lines by the Connection.resizeTargetKeepingDirection method.
resizeTarget
KeepingDirection
public boolean resizeTargetKeepingDirection(ConnectionContainer connectionContainer)
Parameters:
connectionContainer - The ConnectionContainer object that represents a connection with a target shape and a connector.
Return:
True if resizing of the target succeeds.
If the projection point doesn't exist on the the boundary the connector, then resizing of the target will fail. In this care, this method returns false.
Processing:
Performs the same processing as the above method for the target shape. To resize the target shape, calls the resizeTarget method.
selectCurvePT private CurvePT selectCurvePT(Point2D p, Vector2D vec, CurvePT[] curvePTs)
Parameters:
p - The reference point to be used to select a CurvePT object.
vec - The direction vector which shows the direction of a line connector or a polyline connector.
curvePTs - The points on the target curve.
Returns:
The selected CurvePT object.
Processing:
Calculates the distances from p to curvePTs(projection points) in the direction specified by the vec and selects the minimum distance and the curvePT which achieves the minimum distance.
This method is slightly different from the selectCurvePT method mentioned above.
See=> The figure in projectionPT.
end public void end()
Terminates resizing or transforming connectors.
isXOrYvector private int isXOrYvector(Vector2D vec)
Returns:
If the vec is a x/y direction vector, then returns 1/2 respectively, otherwise returns 0.
drawMark private void drawMark(String id, String message, int depth, Connection connection)
This method draws a color mark at the point specified by the parameter.
Drawing is done by the DrawShapeUtil.drawTempShape.
drawMarks private void drawMarks(String id, String message)
This method draws color marks at the points specified by the Connection objects in the ConnectionList.
Drawing is done by the DrawShapeUtil.drawTempShape.
clearMark private void clearMark()
Clears the all marks.
moveResize
(static)
public void resizeContainer(ShapeContainer container, Rectangle2D oldBox, Rectangle2D newBox, boolean keepConnection, boolean undoSetup)
Parameters:
container - The ShapeContainer object to be resized.
oldBox - The rectangle object before resized.
newBox - The rectangle object after resized.
keepConnection - If true, then keeps the connection with connectors.
undoSetup - If true, then sets the undo setup for the container and the connector.
Processing:
Resizes the container so that the oldBox is transformed to the newBox. This method calls the ShapeElement.moveResize method. If the size of the oldBox is equal to the size of the newBox, then resize means move.
: This method is used to resize the ShapeContainer without using the mouse drag.
moveEndPoint
(static)
public static void moveEndPoint(ShapeContainer container, int movePtIndex,
Point2D oldPoint, Point2D currentPoint, boolean keepConnection, boolean undoSetting)

Parameters:
container - The ShapeContainer object which endpoint is moved
movingPtIndex - If the movingPtIndexequals 0, move the start point, otherwise move the end point.
oldPoint - The old point of the moving point.
currentPoint - The current point of the moving point.
keepConnection - If true, then keeps the connection with connectors.
undoSetup - If true, then sets the undo setup for the container and the connector.
Processing:
Move the end point of a line or a polyline. This method calls the ShapeElement.moveEndPoint.
: This method is used to move a endpoint without using the mouse drag.

: Depth, TargetList, ConnectionList
The figure below shows the case when the NW(North West) resize handle of the Round rectangle-1 is moved to upper right for resizing. The color marks shows the connection points which will be affected by resizing the Round rectangle-1 and their colors show the depths from the Round rectangle-1 in graph (tree structure). The depths are also defined on the connectors which will be affected by the resizing operation (see the list below).

Initial state

Moving the NW resize mark to upper right direction.

図3.1 Depth, TargetList, ConnectionList
TargetListとConnectionList
* TargetList
-- target=Round_Rectangle(No-1), depth=0
-- target=Line(No-2), depth=1
-- target=Line(No-3), depth=1
-- target=Line(No-4), depth=1
-- target=Line(No-5), depth=1
-- target=Line(No-6), depth=1
-- target=Line(No-5), depth=2
-- target=Line(No-6), depth=2
-- target=Line(No-7), depth=2
-- target=Line(No-8), depth=2
-- target=Line(No-9), depth=3
-- target=Line(No-10), depth=3
-- target=Line(No-11), depth=4

* ConnectiontList
-- connection[0]: depth=0, target=Round_Rectangle(No-1), connector=Line(No-2), targetP=0.069, connectorP=0.0
-- connection[1]: depth=0, target=Round_Rectangle(No-1), connector=Line(No-2), targetP=4.931, connectorP=1.0
-- connection[2]: depth=0, target=Round_Rectangle(No-1), connector=Line(No-3), targetP=0.265, connectorP=0.0
-- connection[3]: depth=0, target=Round_Rectangle(No-1), connector=Line(No-3), targetP=4.735, connectorP=1.0
-- connection[4]: depth=0, target=Round_Rectangle(No-1), connector=Line(No-4), targetP=0.998, connectorP=0.0
-- connection[5]: depth=0, target=Round_Rectangle(No-1), connector=Line(No-4), targetP=4.002, connectorP=1.0
-- connection[6]: depth=0, target=Round_Rectangle(No-1), connector=Line(No-5), targetP=6.711, connectorP=0.0
-- connection[7]: depth=0, target=Round_Rectangle(No-1), connector=Line(No-6), targetP=6.262, connectorP=0.0
-- connection[8]: depth=1, target=Line(No-2), connector=Line(No-5), targetP=0.342, connectorP=1.0
-- connection[9]: depth=1, target=Line(No-2), connector=Line(No-6), targetP=0.679, connectorP=1.0
-- connection[10]: depth=1, target=Line(No-3), connector=Line(No-7), targetP=0.289, connectorP=0.0
-- connection[11]: depth=1, target=Line(No-3), connector=Line(No-8), targetP=0.727, connectorP=0.0
-- connection[12]: depth=2, target=Line(No-7), connector=Line(No-9), targetP=0.275, connectorP=0.0
-- connection[13]: depth=2, target=Line(No-7), connector=Line(No-10), targetP=0.784, connectorP=0.0
-- connection[14]: depth=2, target=Line(No-8), connector=Line(No-9), targetP=0.275, connectorP=1.0
-- connection[15]: depth=2, target=Line(No-8), connector=Line(No-10), targetP=0.784, connectorP=1.0
*) The targetP and connectorP represent the line/curve parameters on target and connector of the connection point.

: Problem of connector
We make a polygon with four straight lines connecting their endpoints (Figure(a)). When we select one of the lines and move a end point of the selected line, we can't disconnect the selected line from others because the other line tries to maintain its connection as a connector (Figure_(b)). While in the case of Figure_(c), we can easily disconnect the selected line from others (Figure (d)).
On the other hand, if a line is connected to a closed shape, it is easy to disconnect the line from the closed shape by moving the endpoint of the line. From the point of view of operation, it is natural that the selected line can be disconnected from other shape by moving its endpoint.

Figure_(a)
Four lines connecting the endpoints.

Figure_(b)
Select the lower line and move its left side endpoint to upper, then the left side line automatically move its endpoint as a connector. Consequently the selected line can't be disconnect from others.
Figure_(c)
Two lines connected to other lines at the endpoints.

Figure (d)
Select the left side line and move its upper side endpoint to lower left, then the selected line can be disconnected from the upper line.


4. Class TargetContainer return=>page top
This object stores the ShapeContainer object with the depth.
Field Description
depth int depth
The depth of from the root nodes (the target shapes to be moved/resized) in tree structure.
container ShapeContainer container
The ShapeContainer object.

Method Description
Constructor public TargetContainer(int depth, ShapeContainer container)
Sets the parameters to the corresponding field.
getDepth public int getDepth()
Returns the depth.
getContainer public ShapeContainer getContainer()
Returns the container.


5. Class ConnectionContainer return=>page top
This object stores the Connection object with its auxiliary information. 
The field variable of the connection will be changed, because a Line connector may be changed into a polyline connector or the polyline connector may be changed into the Line connector in the resizing process (see=> changeToPolylineConnector, changeToLineConnector methods). On the other hand the field variable of the initConnection stores the initial state of the connector and won't be changed.
Field Description
id String id
The string identifier. currently, "connector" and "guide_line" are assigned.
depth int depth
The depth of from the root nodes (the target shapes to be moved/resized) in tree structure.
connection Connection connection
The Connectionn object
initConnection Connection initConnection
The Connection object which represents the connection at the start of moving/resizing target shapes.

Method Description
Constructor public ConnectionContainer(String id, int depth, Connection connection)
Set the parameters to the corresponding fiels.
Set the clone of the connection to the initConnection.
getId public String getId()
Returns the id.
getDepth public int getDepth()
Returns the depth.
getConnection public Connection getConnection()
Returns the connection.
getInitConnection public Connection getInitConnection()
Returns the initialConnection.
toString public String toString()
Return the string reperesenting this object.


Copyright (c) 2009-2013
All other trademarks are property of their respective owners.