|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.aerith.misao.util.PositionMap
The PositionMap
represents a rectangular map of
Position
s which consists of a list of (x,y) data and
the two Position
s at corners of the map area.
This class has functions to search data around the specified
position. This PositionMap
can be divided into some
parts. After division properly, the search will be much faster.
Field Summary | |
protected boolean |
accept_out_of_bounds
True if OutOfBoundsException must not be thrown. |
protected Position |
bottom_right
The position at the bottom-right corner. |
protected java.util.Vector |
list
The list of (x,y) positions. |
protected java.util.Vector[][] |
table
The table of divided parts. |
protected int |
table_columns
The number of columns of divided table. |
protected int |
table_rows
The number of rows of divided table. |
protected Position |
top_left
The position at the top-left corner. |
Constructor Summary | |
PositionMap(PositionList list)
Constructs a PositionMap with the list of
positions. |
|
PositionMap(PositionMap original_map)
Copies the specified PositionMap and constructs a
new PositionMap . |
|
PositionMap(Position top_left,
Position bottom_right)
Constructs an empty PositionMap with the positions
at corners. |
Method Summary | |
void |
acceptOutOfBounds()
Accepts the data out of the area, which will be shifted onto this map area. |
void |
addPosition(Position new_position)
Adds a (x,y) position on this map. |
void |
addPosition(java.util.Vector new_list)
Adds a list of (x,y) positions on this map. |
protected Position |
convertPosition(Position position)
Converts the (x,y) position into the proper system for this map. |
void |
divide(int new_rows,
int new_columns)
Divides this map into some parts for fast search. |
void |
divideByCircleCoverage(double radius)
Divides this map into some parts so that a circle with the specified radius covers each divided part. |
void |
divideByUnit(double unit_row,
double unit_column)
Divides this map into some parts for fast search, based on the specified unit. |
void |
exceptOutOfBounds()
Excepts the data out of the area and the OutOfBoundsException must be thrown. |
java.util.Vector |
getAllPositions()
Gets the list of all data in this map. |
double |
getArea()
Gets the area of this map. |
Position |
getBottomLeftCorner()
Gets the (x,y) of the bottom left corner. |
Position |
getBottomRightCorner()
Gets the (x,y) of the bottom right corner. |
Position |
getCenter()
Gets the (x,y) of the center. |
java.util.Vector |
getDividedPositionMapList()
Gets the list of divided position maps. |
double |
getHeight()
Gets the height of this map. |
java.util.Vector |
getPartialList(Position position)
Gets the partial list on the divided map where the specified position locates in. |
java.util.Vector |
getPartialListWithinRadius(Position position,
double radius)
Creates a list of elements in the partial lists on the divided map where the specified position locates in and around within the specified radius. |
java.util.Vector |
getPartialListWithinSteps(Position position,
int row_steps,
int column_steps)
Creates a list of elements in the partial lists on the divided map where the specified position locates in and around within the specified division steps. |
Position |
getTopLeftCorner()
Gets the (x,y) of the top left corner. |
Position |
getTopRightCorner()
Gets the (x,y) of the top right corner. |
double |
getWidth()
Gets the width of this map. |
boolean |
isOutOfBounds(Position position)
Checks if the specified position is out of this map area. |
protected java.lang.String |
paramString()
Returns a raw string representation of the state of this object, for debugging use. |
boolean |
removePosition(Position position)
Removes the specified position object from this map. |
java.lang.String |
toString()
Returns a string representation of the state of this object, for debugging use. |
Methods inherited from class java.lang.Object |
|
Field Detail |
protected java.util.Vector list
protected Position top_left
protected Position bottom_right
protected java.util.Vector[][] table
protected int table_rows
protected int table_columns
protected boolean accept_out_of_bounds
OutOfBoundsException
must not be thrown.Constructor Detail |
public PositionMap(Position top_left, Position bottom_right)
PositionMap
with the positions
at corners.top_left
- the position at top-left corner.bottom_right
- the position at bottom-right corner.public PositionMap(PositionMap original_map)
PositionMap
and constructs a
new PositionMap
.original_map
- the original map to copy.public PositionMap(PositionList list)
PositionMap
with the list of
positions. The top-left and bottom-right corner positions are
automatically calculated.list
- the list of (x,y) positions.Method Detail |
public void acceptOutOfBounds()
OutOfBoundsException
must not
be thrown.public void exceptOutOfBounds()
OutOfBoundsException
must be thrown.public boolean isOutOfBounds(Position position)
position
- the position to check.protected Position convertPosition(Position position)
position
- the original (x,y).public void addPosition(Position new_position) throws OutOfBoundsException
new_position
- the new (x,y) position.public void addPosition(java.util.Vector new_list) throws OutOfBoundsException
new_list
- the list of new (x,y) positions.public boolean removePosition(Position position)
position
- the position object to be removed.public double getWidth()
public double getHeight()
public Position getTopLeftCorner()
public Position getTopRightCorner()
public Position getBottomLeftCorner()
public Position getBottomRightCorner()
public Position getCenter()
public double getArea()
public java.util.Vector getAllPositions()
public java.util.Vector getDividedPositionMapList()
public java.util.Vector getPartialList(Position position) throws OutOfBoundsException
position
- the position.public java.util.Vector getPartialListWithinSteps(Position position, int row_steps, int column_steps) throws OutOfBoundsException
position
- the position.row_steps
- the number of division steps to search
vertically.column_steps
- the number of division steps to search
horizontally.public java.util.Vector getPartialListWithinRadius(Position position, double radius) throws OutOfBoundsException
position
- the position.radius
- the radius to search.public void divideByUnit(double unit_row, double unit_column)
unit_row
- the unit to divide vertically.unit_column
- the unit to divide horizontally.public void divide(int new_rows, int new_columns)
new_rows
- the number to divide vertically.new_columns
- the number to divide horizontally.public void divideByCircleCoverage(double radius)
radius
- the radius of a circle.protected java.lang.String paramString()
toString
method of the subclasses.public java.lang.String toString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |