- java.lang.Object
-
- org.arakhne.afc.math.graph.simple.SGraphSegment
-
- All Implemented Interfaces:
GraphSegment<SGraphSegment,SGraphPoint>
public class SGraphSegment extends Object implements GraphSegment<SGraphSegment,SGraphPoint>
This class provides a simple implementation of a graph's segment for aSGraph.- Since:
- 13.0
- Version:
- 17.0 2020-01-04 14:41:42
- Author:
- Stéphane GALLAND
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- mathgraph
-
-
Constructor Summary
Constructors Constructor Description SGraphSegment(SGraph graph1)Constructor.SGraphSegment(SGraph graph1, double length1)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddUserData(Object userData)Add a user data in the data associated to this point.voidconnectBeginToBegin(SGraphSegment segment)Connect the begin point of this segment to the begin point of the given segment.voidconnectBeginToEnd(SGraphSegment segment)Connect the begin point of this segment to the end point of the given segment.voidconnectEndToBegin(SGraphSegment segment)Connect the end point of this segment to the begin point of the given segment.voidconnectEndToEnd(SGraphSegment segment)Connect the end point of this segment to the end point of the given segment.voiddisconnectBegin()Disconnect the begin point of this segment.voiddisconnectEnd()Disconnect the end point of this segment.Collection<Object>getAllUserData()Replies all the user data.SGraphPointgetBeginPoint()Replies the starting point of this segment.SGraphPointgetEndPoint()Replies the ending point of this segment.SGraphgetGraph()Replies the graph in which this segment is.doublegetLength()Replies the length of the segment.SGraphPointgetOtherSidePoint(SGraphPoint point)Replies the point at the other side of the segment.ObjectgetUserDataAt(int index)Replies the user data at the given index.intgetUserDataCount()Replies the number of user data.booleanremoveUserData(Object userData)Remove a user data from the data associated to this point.voidsetLength(double length)Set the length of the segment.voidsetUserDataAt(int index, Object data)Set the user data at the given index.
-
-
-
Constructor Detail
-
SGraphSegment
public SGraphSegment(SGraph graph1)
Constructor.- Parameters:
graph1- is the graph in which the segment is.
-
SGraphSegment
public SGraphSegment(SGraph graph1, double length1)
Constructor.- Parameters:
graph1- is the graph in which the segment is.length1- is the length of the segment.
-
-
Method Detail
-
getGraph
@Pure public SGraph getGraph()
Replies the graph in which this segment is.- Returns:
- the graph in which this segment is.
-
connectBeginToBegin
public void connectBeginToBegin(SGraphSegment segment)
Connect the begin point of this segment to the begin point of the given segment. This function change the connection points of the two segments.- Parameters:
segment- the segment.- Throws:
IllegalArgumentException- if the given segment is not in the same graph.
-
connectBeginToEnd
public void connectBeginToEnd(SGraphSegment segment)
Connect the begin point of this segment to the end point of the given segment. This function change the connection points of the two segments.- Parameters:
segment- the segment.- Throws:
IllegalArgumentException- if the given segment is not in the same graph.
-
connectEndToBegin
public void connectEndToBegin(SGraphSegment segment)
Connect the end point of this segment to the begin point of the given segment. This function change the connection points of the two segments.- Parameters:
segment- the segment.- Throws:
IllegalArgumentException- if the given segment is not in the same graph.
-
connectEndToEnd
public void connectEndToEnd(SGraphSegment segment)
Connect the end point of this segment to the end point of the given segment. This function change the connection points of the two segments.- Parameters:
segment- the segment.- Throws:
IllegalArgumentException- if the given segment is not in the samegraph.
-
disconnectBegin
public void disconnectBegin()
Disconnect the begin point of this segment.
-
disconnectEnd
public void disconnectEnd()
Disconnect the end point of this segment.
-
getBeginPoint
public SGraphPoint getBeginPoint()
Description copied from interface:GraphSegmentReplies the starting point of this segment.- Specified by:
getBeginPointin interfaceGraphSegment<SGraphSegment,SGraphPoint>- Returns:
- the starting point of this segment.
-
getEndPoint
@Pure public SGraphPoint getEndPoint()
Description copied from interface:GraphSegmentReplies the ending point of this segment.- Specified by:
getEndPointin interfaceGraphSegment<SGraphSegment,SGraphPoint>- Returns:
- the ending point of this segment.
-
getOtherSidePoint
@Pure public SGraphPoint getOtherSidePoint(SGraphPoint point)
Description copied from interface:GraphSegmentReplies the point at the other side of the segment.- Specified by:
getOtherSidePointin interfaceGraphSegment<SGraphSegment,SGraphPoint>- Parameters:
point- the reference point.- Returns:
- the point at the other side of the segment.
-
getLength
@Pure public double getLength()
Description copied from interface:GraphSegmentReplies the length of the segment.- Specified by:
getLengthin interfaceGraphSegment<SGraphSegment,SGraphPoint>- Returns:
- the length of the segment.
-
setLength
public void setLength(double length)
Set the length of the segment.- Parameters:
length- is the length of the segment.
-
addUserData
public boolean addUserData(Object userData)
Add a user data in the data associated to this point.- Parameters:
userData- the user data to add.- Returns:
trueif the data was added; otherwisefalse.
-
removeUserData
public boolean removeUserData(Object userData)
Remove a user data from the data associated to this point.- Parameters:
userData- the user data to remove.- Returns:
trueif the data was removed; otherwisefalse.
-
getUserDataCount
@Pure public int getUserDataCount()
Replies the number of user data.- Returns:
- the number of user data.
-
getUserDataAt
@Pure public Object getUserDataAt(int index)
Replies the user data at the given index.- Parameters:
index- is the index of the data.- Returns:
- the data
-
setUserDataAt
public void setUserDataAt(int index, Object data)Set the user data at the given index.- Parameters:
index- is the index of the data.data- is the data
-
getAllUserData
@Pure public Collection<Object> getAllUserData()
Replies all the user data.- Returns:
- an unmodifiable collection of user data.
-
-