Class ElbowConnectorShape
java.lang.Object
org.pathvisio.libgpml.model.connector.AbstractConnector
org.pathvisio.libgpml.model.connector.SegmentedConnector
org.pathvisio.libgpml.model.connector.ElbowConnectorShape
- All Implemented Interfaces:
ConnectorShape
- Direct Known Subclasses:
CurvedConnectorShape
public class ElbowConnectorShape extends SegmentedConnector
ConnectorShape implementation for the elbow connector.
- Author:
- thomas
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.pathvisio.libgpml.model.connector.ConnectorShape
ConnectorShape.Segment, ConnectorShape.WayPoint
-
Field Summary
Fields Modifier and Type Field Description private static double
SEGMENT_OFFSET
private int[][][]
waypointNumbers
Fields inherited from interface org.pathvisio.libgpml.model.connector.ConnectorShape
AXIS_X, AXIS_Y
-
Constructor Summary
Constructors Constructor Description ElbowConnectorShape()
-
Method Summary
Modifier and Type Method Description protected ConnectorShape.Segment[]
calculateSegments(ConnectorRestrictions restrictions, ConnectorShape.WayPoint[] waypoints)
protected java.awt.Shape
calculateShape()
Calculates shape from the width of the line endings.protected ConnectorShape.WayPoint
calculateWayPoint(java.awt.geom.Point2D start, java.awt.geom.Point2D end, int axis, int direction)
protected ConnectorShape.WayPoint[]
calculateWayPoints(ConnectorRestrictions restrictions)
protected ConnectorShape.Segment
createStraightSegment(java.awt.geom.Point2D start, java.awt.geom.Point2D end, int axis)
(package private) int
getDirectionX(java.awt.geom.Point2D start, java.awt.geom.Point2D end)
Get the direction of the line on the x axisprotected int
getDirectionY(java.awt.geom.Point2D start, java.awt.geom.Point2D end)
Get the direction of the line on the y axisprotected int
getNrSegments(ConnectorRestrictions restrictions)
private int
getNrWaypoints(int x, int y, int z)
private int
getOppositeAxis(int axis)
private int
getSegmentAxis(int side)
private int
getSegmentDirection(int side)
boolean
hasValidWaypoints(ConnectorRestrictions restrictions)
Checks if number of waypoints matches number of segments.private boolean
isPointOnSegment(java.lang.Double p1, java.lang.Double p2, java.lang.Double point)
void
recalculateShape(ConnectorRestrictions restrictions)
Forces the connector to redraw it's path.protected ConnectorShape.WayPoint[]
wayPointsToCenter(ConnectorShape.WayPoint[] waypoints, ConnectorShape.Segment[] segments)
Sets all waypoints to the center of the segments.Methods inherited from class org.pathvisio.libgpml.model.connector.SegmentedConnector
calculateShape, fromLineCoordinate, fromLineCoordinate, getTotalLength, toLineCoordinate
Methods inherited from class org.pathvisio.libgpml.model.connector.AbstractConnector
calculateAdjustedShape, getSegments, getShape, getWayPoints, setSegments, setShape, setWayPoints
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
SEGMENT_OFFSET
private static final double SEGMENT_OFFSET- See Also:
- Constant Field Values
-
waypointNumbers
private int[][][] waypointNumbers
-
-
Constructor Details
-
ElbowConnectorShape
public ElbowConnectorShape()
-
-
Method Details
-
recalculateShape
Forces the connector to redraw it's path. The cache for segments, waypoints and shape.- Parameters:
restrictions
- the ConnectorRestrictions that provides the start, end and preferred waypoints
-
hasValidWaypoints
Checks if number of waypoints matches number of segments.- Parameters:
restrictions
- the connector restriction.- Returns:
- true if number of waypoints matches number of segments, false otherwise.
-
wayPointsToCenter
protected ConnectorShape.WayPoint[] wayPointsToCenter(ConnectorShape.WayPoint[] waypoints, ConnectorShape.Segment[] segments)Sets all waypoints to the center of the segments.- Parameters:
waypoints
- the waypoint array.segments
- the segment array.- Returns:
- waypoints the array of waypoints.
-
calculateShape
protected java.awt.Shape calculateShape()Calculates shape from the width of the line endings.- Returns:
- the calculated shape.
-
calculateWayPoints
- Parameters:
restrictions
- the connector restriction.- Returns:
- ...
-
calculateWayPoint
protected ConnectorShape.WayPoint calculateWayPoint(java.awt.geom.Point2D start, java.awt.geom.Point2D end, int axis, int direction)- Parameters:
start
- the Point2D.end
- the Point2D.axis
- the integer.direction
- the integer.- Returns:
- new Waypoint.
-
calculateSegments
protected ConnectorShape.Segment[] calculateSegments(ConnectorRestrictions restrictions, ConnectorShape.WayPoint[] waypoints)- Parameters:
restrictions
- the connector restrictions.waypoints
- the waypoint array- Returns:
- segments the segment array.
-
createStraightSegment
protected ConnectorShape.Segment createStraightSegment(java.awt.geom.Point2D start, java.awt.geom.Point2D end, int axis)- Parameters:
start
- the Point2D.end
- the Point2D.axis
- the integer.- Returns:
- new Segment.
-
getOppositeAxis
private int getOppositeAxis(int axis)- Parameters:
axis
- the integer.
-
getSegmentDirection
private int getSegmentDirection(int side)- Parameters:
side
- the integer.- Returns:
- segment direction or 0.
-
getSegmentAxis
private int getSegmentAxis(int side)- Parameters:
side
- the integer.- Returns:
- axis or 0.
-
getNrWaypoints
private int getNrWaypoints(int x, int y, int z)- Parameters:
x
- the integer.y
- the integer.z
- the integer.- Returns:
- waypointNumbers.
-
getDirectionX
int getDirectionX(java.awt.geom.Point2D start, java.awt.geom.Point2D end)Get the direction of the line on the x axis- Parameters:
start
- The start point of the lineend
- The end point of the line- Returns:
- 1 if the direction is positive (from left to right), -1 if the direction is negative (from right to left)
-
getDirectionY
protected int getDirectionY(java.awt.geom.Point2D start, java.awt.geom.Point2D end)Get the direction of the line on the y axis- Parameters:
start
- The start point of the lineend
- The end point of the line- Returns:
- 1 if the direction is positive (from top to bottom), -1 if the direction is negative (from bottom to top)
-
getNrSegments
- Parameters:
restrictions
- the connectorRestrictions.- Returns:
- ...
-
isPointOnSegment
private boolean isPointOnSegment(java.lang.Double p1, java.lang.Double p2, java.lang.Double point)- Parameters:
p1
- the double.p2
- the double.point
- the double.- Returns:
- true or false.
-