Package nl.colorize.multimedialib.math
Record Class SegmentedLine
java.lang.Object
java.lang.Record
nl.colorize.multimedialib.math.SegmentedLine
- All Implemented Interfaces:
Shape
Line that consists of multiple segments, where each segment is a straight
line but the combination still allows for more complex line shapes. The
line is defined by a number of points, where each point except the "head"
and the "tail" acts as both the end of the previous segment and the start
of the next segment. Alternatively, segments can also be described by
Line
instances using getSegments()
.-
Field Summary
-
Constructor Summary
ConstructorDescriptionSegmentedLine
(List<Point2D> points) Creates an instance of aSegmentedLine
record class. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns whether this shape contains the specified point.final boolean
Indicates whether some other object is "equal to" this one.Returns a newSegmentedLine
that consists of the same segments as this one plus one extra segment between this line's tail and the specified point.Returns the smallest possible rectangular bounding box that can fit this shape.getHead()
getTail()
final int
hashCode()
Returns a hash code value for this object.points()
Returns the value of thepoints
record component.reposition
(Point2D offset) Returns a newShape
instance that is repositioned by the specified X and Y offset.Returns a direct line that points from this segmented line's head to its tail.toString()
Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface nl.colorize.multimedialib.math.Shape
reposition
-
Constructor Details
-
SegmentedLine
Creates an instance of aSegmentedLine
record class.- Parameters:
points
- the value for thepoints
record component
-
-
Method Details
-
getSegments
-
getHead
-
getTail
-
contains
Description copied from interface:Shape
Returns whether this shape contains the specified point. -
getBoundingBox
Description copied from interface:Shape
Returns the smallest possible rectangular bounding box that can fit this shape.- Specified by:
getBoundingBox
in interfaceShape
-
reposition
Description copied from interface:Shape
Returns a newShape
instance that is repositioned by the specified X and Y offset.- Specified by:
reposition
in interfaceShape
-
toDirectLine
Returns a direct line that points from this segmented line's head to its tail. -
extend
Returns a newSegmentedLine
that consists of the same segments as this one plus one extra segment between this line's tail and the specified point. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object)
. -
points
Returns the value of thepoints
record component.- Returns:
- the value of the
points
record component
-