public class Edge extends ICEObject implements IUpdateableListener, IMeshPart
This class represents a single edge in a polygon. Each edge must be registered with two Vertices. The default behavior of an Edge is that of a straight line between the two vertices.
component
iComponentListener
Constructor and Description |
---|
Edge()
A nullary constructor.
|
Edge(java.util.ArrayList<Vertex> vertices)
This constructor takes a collection of vertices.
|
Edge(Vertex start,
Vertex end)
The default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
acceptMeshVisitor(IMeshPartVisitor visitor)
This method calls the
IMeshPartVisitor 's visit method. |
java.lang.Object |
clone()
This operation returns a clone of the Edge using a deep copy.
|
void |
copy(Edge edge)
This operation copies the contents of a Edge into the current object
using a deep copy.
|
boolean |
equals(java.lang.Object otherObject)
This operation is used to check equality between this Edge and another
Edge.
|
float[] |
getEndLocation()
Gets the location of the last vertex for this edge.
|
float |
getLength()
Gets the length of the Edge.
|
float[] |
getStartLocation()
Gets the location of the first vertex for this edge.
|
int[] |
getVertexIds()
Gets the IDs of the vertices this edge connects.
|
int |
hashCode()
This operation returns the hash value of the Edge.
|
void |
unregister(IUpdateableListener listener)
Overrides the default behavior of unregister.
|
void |
update(IUpdateable component)
Updates the Edge if the Vertex's ID matches one of its stored Vertices.
|
copy, getDescription, getId, getName, register, setDescription, setId, setName, update
public Edge()
A nullary constructor. This creates an Edge with default (invalid) vertices and initializes any fields necessary for the minimal function of an Edge. Required for persistence.
public Edge(Vertex start, Vertex end)
The default constructor. It sets the edge's vertices based on the supplied starting and ending vertices. The vertices should be different and must have their IDs set to a non-negative integer. It registers the edge as a listener with the provided vertices.
start
- The first Vertex in this Edge.
end
- The second Vertex in this Edge.
public Edge(java.util.ArrayList<Vertex> vertices)
This constructor takes a collection of vertices. The collection should contain only two different vertices. They must have their IDs set to a non-negative integer. It registers the edge as a listener with the provided vertices.
vertices
- The two Vertices this Edge connects.
public int[] getVertexIds()
Gets the IDs of the vertices this edge connects.
The IDs of the vertices this edge connects.
public float[] getStartLocation()
Gets the location of the first vertex for this edge.
The location of the edge's starting vertex.
public float[] getEndLocation()
Gets the location of the last vertex for this edge.
The location of the edge's ending vertex.
public float getLength()
Gets the length of the Edge. The default value is the Euclidean distance between the Edge's vertices.
A float representing the length of the Edge.
public void update(IUpdateable component)
update
in interface IUpdateableListener
component
- The component that was updated in some way.public int hashCode()
This operation returns the hash value of the Edge.
hashCode
in interface Identifiable
hashCode
in class ICEObject
The hash of the Object.
Identifiable.hashCode()
public boolean equals(java.lang.Object otherObject)
This operation is used to check equality between this Edge and another Edge. It returns true if the Edges are equal and false if they are not.
equals
in interface Identifiable
equals
in class ICEObject
otherObject
- The other Object that should be compared with this one.
True if the Objects are equal, false otherwise.
Identifiable.equals(Object otherObject)
public void copy(Edge edge)
This operation copies the contents of a Edge into the current object using a deep copy. The copy will not be registered with its vertices.
edge
- The Object from which the values should be copied.
public java.lang.Object clone()
This operation returns a clone of the Edge using a deep copy. The copy will not be registered with its vertices.
clone
in interface Identifiable
clone
in class ICEObject
The new clone.
public void unregister(IUpdateableListener listener)
unregister
in interface IUpdateable
unregister
in class ICEObject
listener
- The listener that should no longer receive updates.
IUpdateable.unregister(IUpdateableListener listener)
public void acceptMeshVisitor(IMeshPartVisitor visitor)
This method calls the IMeshPartVisitor
's visit method.
acceptMeshVisitor
in interface IMeshPart
visitor
-
The IMeshPartVisitor
that is visiting this
IMeshPart
.