cz.cuni.utils.math.vertexSpace.vertex2Dspace
Class Vertex2DSpaceSimple

java.lang.Object
  extended by cz.cuni.utils.math.vertexSpace.vertex2Dspace.Vertex2DSpaceSimple
All Implemented Interfaces:
Vertex2DSpaceInterface

public class Vertex2DSpaceSimple
extends java.lang.Object
implements Vertex2DSpaceInterface

In graphics we're in fact are working with discreet space. In math.M you have constants EPSILON / etc. which defines precision we're counting with. Vertex hash codes are created with respect to this precision (as they may not have doubles in x, y but long ~ discreet space). Idea behind this class is, that we're filling HashMap with vertexes and when we want to add vertex to a place where already someone is, we returns reference to an existing vertex instead.


Field Summary
 Vertex2DFactoryInterface vertexFactory
           
 java.util.HashMap vertices
           
 
Constructor Summary
Vertex2DSpaceSimple(Vertex2DFactoryInterface vfi)
           
 
Method Summary
 void clear()
          Clears information about vertices, which have been created.
 Vertex2D get(double x, double y)
          Should return existing or new vertex which has "equal" coordinates.
 Vertex2D get(Tuple2D t)
          Should return existing or new vertex which has "equal" coordinates.
 void remove(Vertex2D v)
          Vertex must be removed from the space
 void set(Vertex2D v)
          You have to insert this vertex into space, possibly overwriting the existing one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vertexFactory

public final Vertex2DFactoryInterface vertexFactory

vertices

public java.util.HashMap vertices
Constructor Detail

Vertex2DSpaceSimple

public Vertex2DSpaceSimple(Vertex2DFactoryInterface vfi)
Method Detail

get

public Vertex2D get(Tuple2D t)
Description copied from interface: Vertex2DSpaceInterface
Should return existing or new vertex which has "equal" coordinates.

Specified by:
get in interface Vertex2DSpaceInterface
Returns:
Vertex2D

get

public Vertex2D get(double x,
                    double y)
Description copied from interface: Vertex2DSpaceInterface
Should return existing or new vertex which has "equal" coordinates.

Specified by:
get in interface Vertex2DSpaceInterface
Parameters:
x - coordinate
y - coordinate
Returns:
Vertex2D

set

public void set(Vertex2D v)
Description copied from interface: Vertex2DSpaceInterface
You have to insert this vertex into space, possibly overwriting the existing one.

Specified by:
set in interface Vertex2DSpaceInterface

remove

public void remove(Vertex2D v)
Description copied from interface: Vertex2DSpaceInterface
Vertex must be removed from the space

Specified by:
remove in interface Vertex2DSpaceInterface

clear

public void clear()
Clears information about vertices, which have been created.

Specified by:
clear in interface Vertex2DSpaceInterface