texturesynthesis.wangtilesynthesizer.wangtiles
Class WangTileSet

java.lang.Object
  extended by texturesynthesis.wangtilesynthesizer.wangtiles.WangTileSet

public class WangTileSet
extends java.lang.Object

This class represents a collection of Wang tiles. It contains zero or more Wang tiles with similiar coloring. It contains at most one of each kind of a Wang tile.

Author:
Aki Koskinen

Field Summary
private  int horizontalColoring
          Number of possible colors in the horizontal direction.
private  java.util.Vector<WangTile> tileSet
          Space for the tiles.
private  int verticalColoring
          Number of possible colors in the vertical direction.
 
Constructor Summary
WangTileSet(int horizontal, int vertical)
          Constructs a Wang tile set that contains tiles with the given coloring limits.
 
Method Summary
 void add(WangTile wt)
          Adds a new Wang tile to this tile set if it isn't there yet.
 boolean canFillPlane()
          Checks if this tile set can fill a plane.
 void generateTileSet(int nTiles)
          Generates a tile set.
 WangTile get(int index)
          Returns the tile at the specified position in this tile set.
 int getHorizontalColoring()
          Gets the number of colors in the horizontal direction.
 int getMaximumNumberOfTiles()
          Returns the maximum number of tiles this kind of set can contain.
 int getVerticalColoring()
          Gets the number of colors in the vertical direction.
 boolean isInSet(WangTile wt)
          Tests if a similiar tile is in the set.
 int size()
          Returns the number of tiles in this tile set.
 java.lang.String toString()
          A string representation of this tile set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tileSet

private java.util.Vector<WangTile> tileSet
Space for the tiles.


horizontalColoring

private int horizontalColoring
Number of possible colors in the horizontal direction.


verticalColoring

private int verticalColoring
Number of possible colors in the vertical direction.

Constructor Detail

WangTileSet

public WangTileSet(int horizontal,
                   int vertical)
            throws java.lang.IllegalArgumentException
Constructs a Wang tile set that contains tiles with the given coloring limits.

Parameters:
horizontal - the number of colors in horizontal direction.
vertical - the number of colors in vertical direction.
Throws:
java.lang.IllegalArgumentException - if at least one of the arguments is less than two.
Method Detail

getHorizontalColoring

public int getHorizontalColoring()
Gets the number of colors in the horizontal direction.

Returns:
Returns the horizontalColoring.

getVerticalColoring

public int getVerticalColoring()
Gets the number of colors in the vertical direction.

Returns:
Returns the verticalColoring.

add

public void add(WangTile wt)
Adds a new Wang tile to this tile set if it isn't there yet.

Parameters:
wt - the new Wang tile.

generateTileSet

public void generateTileSet(int nTiles)
Generates a tile set. All the tiles will be different. If the argument is too big (there are not so many different tiles) the maximum amount of different tiles is generated.

Parameters:
nTiles - the number of tiles to be generated

isInSet

public boolean isInSet(WangTile wt)
Tests if a similiar tile is in the set.

Parameters:
wt - the tile
Returns:
true if a similiar tile is in the tile set

getMaximumNumberOfTiles

public int getMaximumNumberOfTiles()
Returns the maximum number of tiles this kind of set can contain. The horizontal and vertical coloring limits define the maximum.

Returns:
the maximum number of tiles.

size

public int size()
Returns the number of tiles in this tile set.

Returns:
the number of tiles in the tile set

get

public WangTile get(int index)
Returns the tile at the specified position in this tile set.

Parameters:
index - index of tile to return.
Returns:
the tile at the specified index

canFillPlane

public boolean canFillPlane()
Checks if this tile set can fill a plane.

Returns:
true if this file set can fill a plane.

toString

public java.lang.String toString()
A string representation of this tile set.

Overrides:
toString in class java.lang.Object
Returns:
a string