- java.lang.Object
-
- impl.org.controlsfx.tools.rectangle.Edge2D
-
public class Edge2D extends Object
The edge of a rectangle, i.e. a vertical or horizontal line segment.
-
-
Constructor Summary
Constructors Constructor Description Edge2D(Point2D centerPoint, Orientation orientation, double length)
Creates a new edge which is specified by its center point, orientation and length.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
Point2D
getCenterPoint()
double
getLength()
Point2D
getLowerRight()
Returns the edge's lower right end point.Orientation
getOrientation()
Returns this edge's orientation.double
getOrthogonalDifference(Point2D otherPoint)
Returns the distance of the specified point to the edge in terms of the dimension orthogonal to the edge's orientation.Point2D
getUpperLeft()
Returns the edge's upper left end point.int
hashCode()
boolean
isHorizontal()
Indicates whether this is ahorizontal
edge.boolean
isVertical()
Indicates whether this is ahorizontal
edge.String
toString()
-
-
-
Constructor Detail
-
Edge2D
public Edge2D(Point2D centerPoint, Orientation orientation, double length)
Creates a new edge which is specified by its center point, orientation and length.- Parameters:
centerPoint
- the edge's center pointorientation
- the edge's orientationlength
- the edge's length; must be non-negative.
-
-
Method Detail
-
getUpperLeft
public Point2D getUpperLeft()
Returns the edge's upper left end point. It has (length
/ 2) distance from the center point and depending on the edge's orientation either the same X (forOrientation.HORIZONTAL
) or Y (forOrientation.VERTICAL
) coordinate.- Returns:
- the edge's upper left point
-
getLowerRight
public Point2D getLowerRight()
Returns the edge's lower right end point. It has (length
/ 2) distance from the center point and depending on the edge's orientation either the same X (forOrientation.HORIZONTAL
) or Y (forOrientation.VERTICAL
) coordinate.- Returns:
- the edge's lower right point
-
getOrthogonalDifference
public double getOrthogonalDifference(Point2D otherPoint)
Returns the distance of the specified point to the edge in terms of the dimension orthogonal to the edge's orientation. The sign denotes whether on which side of the edge, the point lies.
So e.g. if the edge is horizontal, only the Y coordinate's difference between the specified point and the edge is considered. If the point lies to the right of the edge, the returned value is positive.- Parameters:
otherPoint
- the point to where the distance is computed- Returns:
- the distance
-
getCenterPoint
public Point2D getCenterPoint()
- Returns:
- the edge's center point
-
getOrientation
public Orientation getOrientation()
Returns this edge's orientation. Note that the orientation can also be checked withisHorizontal()
andisVertical()
.- Returns:
- the edge's orientation
-
isHorizontal
public boolean isHorizontal()
Indicates whether this is ahorizontal
edge.- Returns:
- true if
getOrientation()
returnsOrientation.HORIZONTAL
-
isVertical
public boolean isVertical()
Indicates whether this is ahorizontal
edge.- Returns:
- true if
getOrientation()
returnsOrientation.VERTICAL
-
getLength
public double getLength()
- Returns:
- the edge's length
-
-