- 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 boolean
addUserData(Object userData)
Add a user data in the data associated to this point.void
connectBeginToBegin(SGraphSegment segment)
Connect the begin point of this segment to the begin point of the given segment.void
connectBeginToEnd(SGraphSegment segment)
Connect the begin point of this segment to the end point of the given segment.void
connectEndToBegin(SGraphSegment segment)
Connect the end point of this segment to the begin point of the given segment.void
connectEndToEnd(SGraphSegment segment)
Connect the end point of this segment to the end point of the given segment.void
disconnectBegin()
Disconnect the begin point of this segment.void
disconnectEnd()
Disconnect the end point of this segment.Collection<Object>
getAllUserData()
Replies all the user data.SGraphPoint
getBeginPoint()
Replies the starting point of this segment.SGraphPoint
getEndPoint()
Replies the ending point of this segment.SGraph
getGraph()
Replies the graph in which this segment is.double
getLength()
Replies the length of the segment.SGraphPoint
getOtherSidePoint(SGraphPoint point)
Replies the point at the other side of the segment.Object
getUserDataAt(int index)
Replies the user data at the given index.int
getUserDataCount()
Replies the number of user data.boolean
removeUserData(Object userData)
Remove a user data from the data associated to this point.void
setLength(double length)
Set the length of the segment.void
setUserDataAt(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:GraphSegment
Replies the starting point of this segment.- Specified by:
getBeginPoint
in interfaceGraphSegment<SGraphSegment,SGraphPoint>
- Returns:
- the starting point of this segment.
-
getEndPoint
@Pure public SGraphPoint getEndPoint()
Description copied from interface:GraphSegment
Replies the ending point of this segment.- Specified by:
getEndPoint
in interfaceGraphSegment<SGraphSegment,SGraphPoint>
- Returns:
- the ending point of this segment.
-
getOtherSidePoint
@Pure public SGraphPoint getOtherSidePoint(SGraphPoint point)
Description copied from interface:GraphSegment
Replies the point at the other side of the segment.- Specified by:
getOtherSidePoint
in 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:GraphSegment
Replies the length of the segment.- Specified by:
getLength
in 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:
true
if 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:
true
if 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.
-
-