Class ElbowConnectorShape

java.lang.Object
All Implemented Interfaces:
ConnectorShape
Direct Known Subclasses:
CurvedConnectorShape

public class ElbowConnectorShape
extends SegmentedConnector
ConnectorShape implementation for the elbow connector.
Author:
thomas
  • 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

      public void recalculateShape​(ConnectorRestrictions restrictions)
      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

      public boolean hasValidWaypoints​(ConnectorRestrictions restrictions)
      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

      protected ConnectorShape.WayPoint[] calculateWayPoints​(ConnectorRestrictions restrictions)
      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 line
      end - 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 line
      end - 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

      protected int getNrSegments​(ConnectorRestrictions restrictions)
      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.