DeclutterMatrix (OpenMap API)
Date: 2016-12-09

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bbn.openmap.layer
Class DeclutterMatrix

    java.lang.Object
      com.bbn.openmap.layer.DeclutterMatrix

    public class DeclutterMatrix

extends java.lang.Object

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

### height

    protected int height

  The height of the screen to be covered by the matrix, in pixels. The number of vertical matrix cell is the height/y_pix_interval.

### width

    protected int width

  The width of the screen to be covered by the matrix, in pixels. The number of horizontal matrix cell is the width/x_pix_interval.

### x_pix_interval

    protected int x_pix_interval

  The number of horizontal pixels per matrix cell

### y_pix_interval

    protected int y_pix_interval

  The number of vertical pixels per matrix cell

### matrix

    protected boolean[][] matrix

  The matrix itself, width x height.

### maxx

    protected int maxx

  The maximum index for the horizontal locations within the matrix.

### maxy

    protected int maxy

  The maximum index for the vertical locations within the matrix.

### allowPartials

    protected boolean allowPartials

  Whether or not objects are allowed to appear partially off the matrix. If true, cells off the matrix will be automatically counted as clear. The default is true.

### indexes

    protected DeclutterMatrix.MatrixIndexes indexes

  A set of matrix indexes that get set for a particular object for a search. This is to limit the number of off matrix indexes used.

### needToRecreate

    protected boolean needToRecreate

  A flag to force a recreation of the matrix if the dimensions change.

### DCP_MIDDLE

    public static final int DCP_MIDDLE

See Also:
  Constant Field Values

### DCP_EAST

    public static final int DCP_EAST

See Also:
  Constant Field Values

### DCP_NORTH

    public static final int DCP_NORTH

See Also:
  Constant Field Values

### DCP_SOUTH

    public static final int DCP_SOUTH

See Also:
  Constant Field Values

### DCP_WEST

    public static final int DCP_WEST

See Also:
  Constant Field Values

### DCP_NEAST

    public static final int DCP_NEAST

See Also:
  Constant Field Values

### DCP_SEAST

    public static final int DCP_SEAST

See Also:
  Constant Field Values

### DCP_SWEST

    public static final int DCP_SWEST

See Also:
  Constant Field Values

### DCP_NWEST

    public static final int DCP_NWEST

See Also:
  Constant Field Values

### DCD_NS

    public static final int DCD_NS

See Also:
  Constant Field Values

### DCD_EW

    public static final int DCD_EW

See Also:
  Constant Field Values

### DCD_NONE

    public static final int DCD_NONE

See Also:
  Constant Field Values

### dcPos

    public static final DeclutterMatrix.PositionParameters[] dcPos

  This is an ordering of the possible positions around a matrix tile.

Constructor Detail

### DeclutterMatrix

    public 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

### DeclutterMatrix

    public DeclutterMatrix(int width,
                           int height)

  Construct a new matrix, given the screen dimensions, and using the default matrix cell size

### DeclutterMatrix

    public DeclutterMatrix()

  Create a new matrix, with null dimensions

Method Detail

### setAllowPartials

    public void setAllowPartials(boolean value)

  Set whether names can appear partially on/off the map. True means they can, i.e., the spaces off the map are by default, clear.

### isAllowPartials

    public boolean isAllowPartials()

  Find out whether the spaces off the map are counted as clear and available. If they are, then objects can appear partially on the map.

### setXInterval

    public void setXInterval(int x_pix_interval)

### setYInterval

    public void setYInterval(int y_pix_interval)

### setWidth

    public void setWidth(int width)

### setHeight

    public void setHeight(int height)

### create

    public boolean create()

  Allocate the matrix.

  Returns:
    true if successful, and if the height and width settings were valid (>0).

### isClear

    protected boolean isClear(DeclutterMatrix.MatrixIndexes indexes,
                              boolean markAsTaken)

  Query whether the matrix is clear, given a set of indexes.

  Parameters:
    `indexes` - the set of indexes
    `markAsTaken` - mark the spaces as used if they are previously clear.
  Returns:
    true if they were clear previously.

### isMatrixLocationTaken

    protected boolean isMatrixLocationTaken(int horizontalIndex,
                                            int verticalIndex,
                                            int numCellsToCheck)

  Check a vertical portion of the matrix, to see if it has already been taken. If a query occurs that is outside the matrix, this returns false.

  Parameters:
    `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.
  Returns:
    true if taken, false if available.

### setTaken

    protected void setTaken(int horizontalIndex,
                            int verticalIndex,
                            int numCellsToMark)

  Mark a vertical portion of the matrix as taken.

  Parameters:
    `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.

### setTaken

    protected boolean setTaken(DeclutterMatrix.MatrixIndexes indexes)

  SetTaken returns true if the space was clear before the it was taken, false if it was not. Either way, the spaces are marked. Except if the matrix is not built, in which case false is returned anyway.

  Parameters:
    `indexes` - the start and end matrix indexes for an object.
  Returns:
    true if successful.

### setTaken

    public boolean setTaken(java.awt.Point point,
                            int pixelLength)

  Set an area as taken, given a point and a length of pixels. The length is checked from left to right.

### setTaken

    public 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. The length is from left to right, the height from the bottom to top (NOT like screen coordinates)

### setNextOpen

    public 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.

  Parameters:
    `point` - the window point
    `pixelLength` - the pixel length of space from left to right.
    `pixelHeight` - the pixel height from bottom to top.
  Returns:
    Point of closest open space.

### setNextOpen

    public 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.

  Parameters:
    `point` - the window point
    `pixelLength` - 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.
  Returns:
    Point of closest open space.

### isAreaClearR

    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.

  Returns:
    point for a good clear space, null if not.

### isAreaClearBWT

    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. This just checks for all the way to the right, and all the way to the left.

  Returns:
    Point for a good space, null if not.

### isAreaClearBW

    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. This method will look all the way to the rigth, and then check incrementally to the left until it's looking all the way there.

  Returns:
    point of some good place is found, null if not.

### getGraphics

    public 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. DO NOT write anything into this thing.

  Returns:
    java.awt.Graphics2D

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details