|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bbn.openmap.layer.DeclutterMatrix
public class DeclutterMatrix
This class represents the screen divided up into sections, and tracks the sections that are marked, for any reason. The pix_intervals are the height and width of the sections. isClear() returns 1 if the space is clear, and setTaken returns true if the space was clear and the space is now marked taken.
Nested Class Summary | |
---|---|
class |
DeclutterMatrix.MatrixIndexes
|
static class |
DeclutterMatrix.PositionParameters
This Denotes the parameters of one of the 8 possible positions around a decluttermatrix tile. |
Field Summary | |
---|---|
protected boolean |
allowPartials
Whether or not objects are allowed to appear partially off the matrix. |
static int |
DCD_EW
|
static int |
DCD_NONE
|
static int |
DCD_NS
|
static int |
DCP_EAST
|
static int |
DCP_MIDDLE
|
static int |
DCP_NEAST
|
static int |
DCP_NORTH
|
static int |
DCP_NWEST
|
static int |
DCP_SEAST
|
static int |
DCP_SOUTH
|
static int |
DCP_SWEST
|
static int |
DCP_WEST
|
static DeclutterMatrix.PositionParameters[] |
dcPos
This is an ordering of the possible positions around a matrix tile. |
protected int |
height
The height of the screen to be covered by the matrix, in pixels. |
protected DeclutterMatrix.MatrixIndexes |
indexes
A set of matrix indexes that get set for a particular object for a search. |
protected boolean[][] |
matrix
The matrix itself, width x height. |
protected int |
maxx
The maximum index for the horizontal locations within the matrix. |
protected int |
maxy
The maximum index for the vertical locations within the matrix. |
protected boolean |
needToRecreate
A flag to force a recreation of the matrix if the dimensions change. |
protected int |
width
The width of the screen to be covered by the matrix, in pixels. |
protected int |
x_pix_interval
The number of horizontal pixels per matrix cell |
protected int |
y_pix_interval
The number of vertical pixels per matrix cell |
Constructor Summary | |
---|---|
DeclutterMatrix()
Create a new matrix, with null dimensions |
|
DeclutterMatrix(int width,
int height)
Construct a new matrix, given the screen dimensions, and using the default matrix cell size |
|
DeclutterMatrix(int width,
int height,
int x_pix_interval,
int y_pix_interval)
Construct a new DeclutterMatrix, given the screen dimensions and the size of the matrix cells |
Method Summary | |
---|---|
boolean |
create()
Allocate the matrix. |
static java.awt.Graphics2D |
getGraphics()
This is a graphics that is only available to fiddle around with text and fonts, in order to get pre-measurements. |
boolean |
isAllowPartials()
Find out whether the spaces off the map are counted as clear and available. |
protected java.awt.Point |
isAreaClearBW(int xPoint,
int yPoint,
java.awt.Point point)
Looks both ways for a clear space BW = Both ways = look both ways = check left and right. |
protected java.awt.Point |
isAreaClearBWT(int xPoint,
int yPoint,
java.awt.Point point)
Check to see if there is space to the left and right. |
protected java.awt.Point |
isAreaClearR(int xPoint,
int yPoint,
java.awt.Point point)
Check to see if there is space to the right of the desired place. |
protected boolean |
isClear(DeclutterMatrix.MatrixIndexes indexes,
boolean markAsTaken)
Query whether the matrix is clear, given a set of indexes. |
protected boolean |
isMatrixLocationTaken(int horizontalIndex,
int verticalIndex,
int numCellsToCheck)
Check a vertical portion of the matrix, to see if it has already been taken. |
void |
setAllowPartials(boolean value)
Set whether names can appear partially on/off the map. |
void |
setHeight(int height)
|
java.awt.geom.Point2D |
setNextOpen(java.awt.geom.Point2D point,
int pixelLength,
int pixelHeight)
The method to call if you are trying to set something in an open place, anywhere on the map. |
java.awt.geom.Point2D |
setNextOpen(java.awt.geom.Point2D point,
int pixelLength,
int pixelHeight,
int pixelAwayLimit)
The method to call if you are trying to set something in an open place, but want to limit how far away the object could be placed. |
protected boolean |
setTaken(DeclutterMatrix.MatrixIndexes indexes)
SetTaken returns true if the space was clear before the it was taken, false if it was not. |
protected void |
setTaken(int horizontalIndex,
int verticalIndex,
int numCellsToMark)
Mark a vertical portion of the matrix as taken. |
boolean |
setTaken(java.awt.Point point,
int pixelLength)
Set an area as taken, given a point and a length of pixels. |
boolean |
setTaken(java.awt.Point point,
int pixelLength,
int pixelHeight)
Set an area as taken, given a point, a length of pixels and a height of pixels. |
void |
setWidth(int width)
|
void |
setXInterval(int x_pix_interval)
|
void |
setYInterval(int y_pix_interval)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int height
protected int width
protected int x_pix_interval
protected int y_pix_interval
protected boolean[][] matrix
protected int maxx
protected int maxy
protected boolean allowPartials
protected DeclutterMatrix.MatrixIndexes indexes
protected boolean needToRecreate
public static final int DCP_MIDDLE
public static final int DCP_EAST
public static final int DCP_NORTH
public static final int DCP_SOUTH
public static final int DCP_WEST
public static final int DCP_NEAST
public static final int DCP_SEAST
public static final int DCP_SWEST
public static final int DCP_NWEST
public static final int DCD_NS
public static final int DCD_EW
public static final int DCD_NONE
public static final DeclutterMatrix.PositionParameters[] dcPos
Constructor Detail |
---|
public DeclutterMatrix(int width, int height, int x_pix_interval, int y_pix_interval)
public DeclutterMatrix(int width, int height)
public DeclutterMatrix()
Method Detail |
---|
public void setAllowPartials(boolean value)
public boolean isAllowPartials()
public void setXInterval(int x_pix_interval)
public void setYInterval(int y_pix_interval)
public void setWidth(int width)
public void setHeight(int height)
public boolean create()
protected boolean isClear(DeclutterMatrix.MatrixIndexes indexes, boolean markAsTaken)
indexes
- the set of indexesmarkAsTaken
- mark the spaces as used if they are previously clear.
protected boolean isMatrixLocationTaken(int horizontalIndex, int verticalIndex, int numCellsToCheck)
horizontalIndex
- the horizontal index of the matrix to check.verticalIndex
- the vertical starting index of the matrix to check.numCellsToCheck
- the number of matrix cells to check for taken.
protected void setTaken(int horizontalIndex, int verticalIndex, int numCellsToMark)
horizontalIndex
- the horizontal index of the matrix to mark.verticalIndex
- the vertical starting index of the matrix to mark.numCellsToMark
- the number of matrix cells to mark as taken.protected boolean setTaken(DeclutterMatrix.MatrixIndexes indexes)
indexes
- the start and end matrix indexes for an object.
public boolean setTaken(java.awt.Point point, int pixelLength)
public boolean setTaken(java.awt.Point point, int pixelLength, int pixelHeight)
public java.awt.geom.Point2D setNextOpen(java.awt.geom.Point2D point, int pixelLength, int pixelHeight)
point
- the window pointpixelLength
- the pixel length of space from left to right.pixelHeight
- the pixel height from bottom to top.
public java.awt.geom.Point2D setNextOpen(java.awt.geom.Point2D point, int pixelLength, int pixelHeight, int pixelAwayLimit)
point
- the window pointpixelLength
- the pixel length of space from left to right.pixelHeight
- the pixel height from bottom to top.pixelAwayLimit
- the pixel distance away from the original location
that where an object will be discarded if it's not at least that
close. -1 means find anywhere on the map where the object will
fit.
protected java.awt.Point isAreaClearR(int xPoint, int yPoint, java.awt.Point point)
protected java.awt.Point isAreaClearBWT(int xPoint, int yPoint, java.awt.Point point)
protected java.awt.Point isAreaClearBW(int xPoint, int yPoint, java.awt.Point point)
public static java.awt.Graphics2D getGraphics()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |