fdubath.entrelacs
Class BackgroundGeometry

java.lang.Object
  extended by fdubath.entrelacs.BackgroundGeometry
Direct Known Subclasses:
TillingBackgroundGeometry

public class BackgroundGeometry
extends java.lang.Object

This class define a zone on which one can define Vertex and Rope. It also contains methodes to instanciate and use the Vertex and Rope. Part of the methodes are though to be overrided by specific geometry.


Field Summary
 boolean verbose
          When set to 'true' cause the Vertex and Rope manipulating methodes to output to the console when they annot comlete a request.
 
Constructor Summary
BackgroundGeometry()
           
 
Method Summary
 Rope addLoopRope(Vertex startVertex, Vertex endVertex)
          Create a closed loop Rope between two vertexes.
 Rope addRopeOnMirorBorder(Vertex startVertex, Vertex endVertex)
          Create a Rope between two vertexes on mirror borders.
 Vertex addVertex(int type, double[] position)
          Try to add a vertex to the current VertexList.
 boolean addVertexToRope(Rope rope, Vertex newVertex, Vertex previusVertex)
          On an existing rope, add a vertex after a given rope vertex.
 boolean deleteRope(Rope rope, boolean deleteAlsoVertices)
          Remove a Rope from the Rope list.
 boolean deleteVertex(Vertex vertex)
          Remove a vertex from the vertex list.
 java.lang.String geometryName()
          Get the name of the Geometry, use for the CustomFileReader in order to ensure it can extract the content of a file and assigne it to the geometry.
 double[] getBorderTangentVector(Vertex vertex)
          When a vertex is on a miror border, this methode allows to get the direction of the border at the vertex position.
 double getIdentifiedBorderRotationAngle(Vertex vertex)
          When a vertex is on a shared border, this methode allows to get the angle between the two identified border between the vertex/vertex' image positions.
 java.util.List getReadOnlyRopexList()
          Exposes the list of rope.
 java.util.List getReadOnlyVertexList()
          Exposes the list of vertices.
 double[] getVertexImagePosition(int imageNumber, Vertex vertex)
          Compute the position of a vertex image.
 boolean hasIdentifiedBorder()
          Define if the geometry has identified border - that is borders on which a Vertex has two image, causing the rope to jump from the first to the second image accross the geometry zone.
 boolean hasMirorBorder()
          Define if the geometry has mirror border - that is border on which a Rope can end.
 boolean isInside(double[] position)
          Compute if a given position is inside the geometry zone.
 void moveVertex(Vertex vertex, double[] newPosition)
          Change the position of a vertex, the input position will be processed using the placeInside()/placeOn*Border() methodes according to the Vertex type.
 int numberOfVertexImages(Vertex vertex)
          Compute the number of image of a given vertex (1 in general 2 on a identified border).
 double[] placeInside(double[] position)
          If a given position is inside the geometry zone.
 double[] placeOnIdentifiedBorder(double[] position)
          Compute the closest position on an identified border of the zone
 double[] placeOnMirorBorder(double[] position)
          Compute the closest position on a mirror border of the zone
 boolean removeVertexfromRope(Rope rope, Vertex vertexToBeRemoved)
          On an existing rope, remove a vertex.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

verbose

public boolean verbose
When set to 'true' cause the Vertex and Rope manipulating methodes to output to the console when they annot comlete a request.

Constructor Detail

BackgroundGeometry

public BackgroundGeometry()
Method Detail

getReadOnlyVertexList

public java.util.List getReadOnlyVertexList()
Exposes the list of vertices. This allow to retrive vertices (as exemple in order to move them or create a Rope).

Returns:
Unmodifiable list of Vertex definig the Rope path.
See Also:
Vertex

getReadOnlyRopexList

public java.util.List getReadOnlyRopexList()
Exposes the list of rope. This allow to retrive rope (as exemple in order to move them or change the color).

Returns:
Unmodifiable list of Rope definig the Rope path.
See Also:
Rope

addVertex

public Vertex addVertex(int type,
                        double[] position)
Try to add a vertex to the current VertexList. If the specified type is not admitted return null, otherwise the position will be updated according to the Vertex type (using placeInside()/placeOn*Border()). Check the possible vertex type using the has*Border() methodes.

Parameters:
type - 0 - bulk vertex, 1 - Vertex on a Miror border, 2 - Vertex on an Identified border.
position - the input position use to determine the final vertex position.
Returns:
An instance of Vertex (or boder Vertex subtypes) - this vertex has already beed added to the geometry VertexList - or null if the type of vertex is not compatible with the geometry.

moveVertex

public void moveVertex(Vertex vertex,
                       double[] newPosition)
Change the position of a vertex, the input position will be processed using the placeInside()/placeOn*Border() methodes according to the Vertex type.

Parameters:
vertex - the vertex to be moved.
newPosition - input position to be processed in order to obtain the vertex new position.

addRopeOnMirorBorder

public Rope addRopeOnMirorBorder(Vertex startVertex,
                                 Vertex endVertex)
Create a Rope between two vertexes on mirror borders. Return null if there is no mirror border. Note that Vertex cannot be simultaneously part of mor than one Rope.

Parameters:
startVertex - a vertexOnAMirrorBorder to be the first point of the rope.
endVertex - a vertexOnAMirrorBorder to be the last point of the rope.
Returns:
null if there is no mirror border,if the vertex are of wrong type or if they are already part of another Rope. Otherwise the newly created Rope.

addLoopRope

public Rope addLoopRope(Vertex startVertex,
                        Vertex endVertex)
Create a closed loop Rope between two vertexes. Return null if one of the vertex is on a mirror border, if they are already part of another Rope or if one vertex is on a identified border and the other is not its image.

Parameters:
startVertex - a vertex to be the first point of the rope.
endVertex - a vertex to be the last point of the rope.
Returns:
null if one of the vertex is on a mirror border, if they are already part of another Rope or if one vertex is on a identified border and the other is not its image. Otherwise the newly created Rope.

addVertexToRope

public boolean addVertexToRope(Rope rope,
                               Vertex newVertex,
                               Vertex previusVertex)
On an existing rope, add a vertex after a given rope vertex.

Parameters:
rope - The rope which recives a new vertex
newVertex - the vertex to be added on the rope
previusVertex - a vertex of the rope which define where the new vertex has to be inserted.
Returns:
true if the vertex has been successfully added.

removeVertexfromRope

public boolean removeVertexfromRope(Rope rope,
                                    Vertex vertexToBeRemoved)
On an existing rope, remove a vertex. If the Rope has only one vertex left, it is also removed from the Rope list

Parameters:
rope - The rope containig the vertex to remove.
vertexToBeRemoved - the vertex to be removed of the rope
Returns:
true if the vertex has been successfully removed.

deleteVertex

public boolean deleteVertex(Vertex vertex)
Remove a vertex from the vertex list. This is not possible if the vertex is part of a rope.

Parameters:
vertex - the vertex to be deleted/removed of the vertex list.
Returns:
true if the vertex has been successfully removed from the vertex list.

deleteRope

public boolean deleteRope(Rope rope,
                          boolean deleteAlsoVertices)
Remove a Rope from the Rope list. If asked the corresponding vertex are asle removed from the vertex list.

Parameters:
rope - the rope to be deleted/removed of the rope list.
deleteAlsoVertices - if true, remove the rope's vertex from the vertex list.
Returns:
true if the rope has been successfully removed from the rope list.

geometryName

public java.lang.String geometryName()
Get the name of the Geometry, use for the CustomFileReader in order to ensure it can extract the content of a file and assigne it to the geometry.

See Also:
CustomFileReader

hasMirorBorder

public boolean hasMirorBorder()
Define if the geometry has mirror border - that is border on which a Rope can end.

Returns:
true if mirror border exists

hasIdentifiedBorder

public boolean hasIdentifiedBorder()
Define if the geometry has identified border - that is borders on which a Vertex has two image, causing the rope to jump from the first to the second image accross the geometry zone.

Returns:
true if identified border exists

isInside

public boolean isInside(double[] position)
Compute if a given position is inside the geometry zone.

Returns:
true if the position is inside the geometry zone.

placeInside

public double[] placeInside(double[] position)
If a given position is inside the geometry zone. returns the position, otherwise compute the closest position inside the zone

Returns:
a position inside the geometry zone.

placeOnMirorBorder

public double[] placeOnMirorBorder(double[] position)
Compute the closest position on a mirror border of the zone

Returns:
a position on a mirror border.

placeOnIdentifiedBorder

public double[] placeOnIdentifiedBorder(double[] position)
Compute the closest position on an identified border of the zone

Returns:
a position on an identified border.

numberOfVertexImages

public int numberOfVertexImages(Vertex vertex)
Compute the number of image of a given vertex (1 in general 2 on a identified border).

Parameters:
vertex - the vertex for which one want to determine the numberof image
Returns:
the number of vertex's image(s).

getVertexImagePosition

public double[] getVertexImagePosition(int imageNumber,
                                       Vertex vertex)
Compute the position of a vertex image.

Parameters:
imageNumber - identify the image: 0 is the curent vertex, 1 is its other image (if it exist).
vertex - the vertex for which one want to determine the images position
Returns:
a position in geometry zone units.

getBorderTangentVector

public double[] getBorderTangentVector(Vertex vertex)
When a vertex is on a miror border, this methode allows to get the direction of the border at the vertex position.

Parameters:
vertex - the Vertex determining a position on a miror border
Returns:
direction of the border at the vertex position.

getIdentifiedBorderRotationAngle

public double getIdentifiedBorderRotationAngle(Vertex vertex)
When a vertex is on a shared border, this methode allows to get the angle between the two identified border between the vertex/vertex' image positions.

Parameters:
vertex - the Vertex determining two positions (the second one is the vertex' image position) on identified borders.
Returns:
the angle between the two image of the border.