|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bbn.openmap.omGraphics.geom.BasicGeometry com.bbn.openmap.omGraphics.OMGraphicAdapter com.bbn.openmap.omGraphics.OMList<T>
public abstract class OMList<T extends OMGeometry>
This class encapsulates a List of OMGraphics.
There are several things that this list does that make it better that any ol' List. You can make several common OMGraphic modification calls on the list, and the list handles the iteration and changing of all the graphics while taking into account a traverse order.
An additional benefit is that because the OMGraphicList extends OMGraphic it can contain other instances of OMGraphicList. This way you can manage groupings of graphics, (for instance, an OMGraphicList of OMGraphicLists which each have an OMRaster and OMText).
Many methods, such as generate() and findClosest() traverse the items in the GraphicsList recursively. The direction that the list is traversed is controlled by then traverseMode variable. The traverseMode mode lets you set whether the first or last object added to the list (FIRST_ADDED_ON_TOP or LAST_ADDED_ON_TOP) is drawn on top of the list and considered first for searches.
Nested Class Summary | |
---|---|
protected static class |
OMList.OMDist<T>
RetVal for closest object/distance calculations. |
Field Summary | |
---|---|
protected boolean |
allowDuplicates
Flag used to allow duplicates in the OMGraphicList. |
static int |
FIRST_ADDED_ON_TOP
Used to set the order in which the list is traversed to draw or search the objects. |
protected java.util.List<T> |
graphics
The List that actually contains the the OMGeometry/OMGraphic objects. |
static int |
LAST_ADDED_ON_TOP
Used to set the order in which the list is traversed to draw or search the objects. |
static int |
NONE
Used for searches, when OMDist doesn't have a graphic. |
protected boolean |
processAllGeometries
Override flag for shouldProcess method. |
protected int |
traverseMode
List traversal mode. |
protected boolean |
vague
Flag to adjust behavior of OMGraphicList for certain queries. |
Fields inherited from class com.bbn.openmap.omGraphics.OMGraphicAdapter |
---|
declutterType, displayPaint, edgeMatchesFill, fillPaint, hasLabel, linePaint, matted, mattingPaint, renderType, selected, selectPaint, showEditablePalette, stroke, textureMask |
Fields inherited from class com.bbn.openmap.omGraphics.geom.BasicGeometry |
---|
attributes, lineType, needToRegenerate, shape, visible |
Constructor Summary | |
---|---|
OMList()
Construct an OMGraphicList. |
|
OMList(int initialCapacity)
|
Method Summary | ||
---|---|---|
void |
add(int index,
T g)
|
|
boolean |
add(T g)
Add an OMGraphic to the list. |
|
protected void |
checkForDuplicate(T g)
Convenience function for methods that may add a OMGraphic. |
|
void |
clear()
|
|
boolean |
contains(java.lang.Object o)
|
|
boolean |
contains(OMGraphic g)
Checks if an OMGraphic is on this list. |
|
boolean |
containsAll(java.util.Collection<?> c)
|
|
abstract OMList<T> |
create()
|
|
protected abstract OMList.OMDist<T> |
createDist()
|
|
void |
deselect()
If you call deselect() on an OMGraphicList, it calls deselect() all the graphics it contains, as well as the deselect method on it's super class. |
|
float |
distance(double x,
double y)
Finds the distance to the closest OMGraphic. |
|
void |
doAction(T graphic,
OMAction action)
Perform an action on the provided geometry. |
|
OMList<T> |
findAll(int x,
int y,
float limit)
Find all of the OMGraphics on this list that are located within the pixel limit of the x, y pixel location. |
|
OMList<T> |
findAll(int x,
int y,
float limit,
boolean resetSelect,
OMList<T> addTo)
Find all of the OMGraphics on this list that are located within the pixel limit of the x, y pixel location. |
|
protected boolean |
findAllTest(int x,
int y,
float limit,
boolean resetSelect,
OMList<T> addTo,
OMGeometry geometry,
OMList.OMDist<T> omd)
Test to find out if an OMGraphic is located within the pixel limit of the x, y pixel location. |
|
T |
findClosest(double x,
double y,
float limit)
Finds the object located the closest to the point, if the object distance away is within the limit. |
|
OMList.OMDist<T> |
findClosest(double x,
double y,
float limit,
boolean resetSelect)
Find the closest Object and its distance. |
|
T |
findClosest(int x,
int y)
Finds the object located the closest to the point, regardless of how far away it is. |
|
protected OMList.OMDist<T> |
findClosestTest(OMList.OMDist<T> current,
int index,
OMGeometry graphic,
double x,
double y,
float limit,
boolean resetSelect)
Test the graphic distance away from the x, y point, and compare it to the current OMDist passed in. |
|
int |
findIndexOfClosest(int x,
int y)
Finds the object located the closest to the point, regardless of how far away it is. |
|
int |
findIndexOfClosest(int x,
int y,
float limit)
Finds the object located the closest to the point, if the object distance away is within the limit. |
|
boolean |
generate(Projection p)
Prepare the graphics for rendering. |
|
boolean |
generate(Projection p,
boolean forceProjectAll)
Prepare the graphics for rendering. |
|
boolean |
getAllowDuplicates()
Get whether the list will allow duplicate entries added. |
|
T |
getContains(int x,
int y)
Finds the first OMGraphic (the one on top) that is under this pixel. |
|
java.util.List<T> |
getCopy()
|
|
java.lang.String |
getDescription()
OMGraphicList method for returning a simple description of the list. |
|
java.lang.String |
getDescription(int level)
OMGraphic method, for returning a simple description if the contents of the list. |
|
boolean |
getProcessAllGeometries()
Get the settings for the programmatic override for shouldProcess method to always process geometries. |
|
int |
getTraverseMode()
Get the order in which the list is traversed to draw or search the objects. |
|
int |
indexOf(java.lang.Object o)
|
|
boolean |
isEmpty()
|
|
boolean |
isVague()
Get whether the list returns the specific OMGraphic in response to a query, or itself. |
|
boolean |
isVisible()
Get the visibility variable. |
|
java.util.Iterator<T> |
iterator()
|
|
int |
lastIndexOf(java.lang.Object o)
|
|
java.util.ListIterator<T> |
listIterator()
|
|
java.util.ListIterator<T> |
listIterator(int size)
|
|
void |
moveIndexedOneToBack(int location)
Moves the graphic at the given index toward the back of the list by one spot, sliding the other graphic up on in the list in order. |
|
void |
moveIndexedOneToBottom(int location)
Moves the graphic at the given index to the part of the list where it will be drawn under one of the other graphics, its neighbor on the list. |
|
void |
moveIndexedOneToFront(int location)
Moves the graphic at the given index toward the front of the list by one spot, sliding the other graphic back on in the list in order. |
|
void |
moveIndexedOneToTop(int location)
Moves the graphic at the given index to the part of the list where it will be drawn on top of one of the other graphics which is its neighbor on the list. |
|
void |
moveIndexedToBottom(int location)
Moves the graphic at the given index to the part of the list where it will be drawn under all of the other graphics. |
|
void |
moveIndexedToFirst(int location)
Moves the graphic at the given index to the front of the list, sliding the other graphics back on in the list in order. |
|
void |
moveIndexedToLast(int location)
Moves the graphic at the given index to the end of the list, sliding the other graphics up on in the list in order. |
|
void |
moveIndexedToTop(int location)
Moves the graphic at the given index to the part of the list where it will be drawn on top of the other graphics. |
|
protected OMGraphic |
objectToOMGraphic(java.lang.Object obj)
Convenience method to cast an object to an OMGraphic if it is one. |
|
void |
project(Projection p)
Projects any graphics needing projection. |
|
void |
project(Projection p,
boolean forceProjectAll)
Projects the OMGraphics on the list. |
|
T |
remove(int index)
|
|
boolean |
remove(java.lang.Object geometry)
Remove the graphic. |
|
boolean |
removeAll(java.util.Collection<?> c)
|
|
void |
render(java.awt.Graphics gr)
Renders all the objects in the list a graphics context. |
|
void |
renderAllAsSelected(java.awt.Graphics gr)
Renders all the objects in the list a graphics context, in their 'selected' mode. |
|
void |
restore(OMGeometry source)
You need to make sure that the Generic type of the source matches the generic type of this list. |
|
boolean |
retainAll(java.util.Collection<?> c)
|
|
void |
select()
Calls select() on all the items on the graphic list, as well as select() on the super class. |
|
T |
selectClosest(int x,
int y)
Finds the object located the closest to the coordinates, regardless of how far away it is. |
|
T |
selectClosest(int x,
int y,
float limit)
Finds the object located the closest to the point, if the object distance away is within the limit, and sets the paint of that graphic to its select paint. |
|
protected OMList.OMDist<T> |
selectClosestTest(OMList.OMDist<T> current,
int index,
OMGeometry graphic,
int x,
int y,
float limit)
A variation on findClosestTest, manages select() and deselect(). |
|
void |
setAllowDuplicates(boolean set)
Set whether the list will allow duplicate entries added. |
|
void |
setProcessAllGeometries(boolean set)
Set the programmatic override for shouldProcess method to always process geometries. |
|
void |
setTraverseMode(int mode)
Set the order in which the list is traversed to draw or search the objects. |
|
void |
setVague(boolean value)
Set whether the list returns the specific OMGraphic in response to a query, or itself. |
|
void |
setVisible(boolean visible)
Set the visibility variable. |
|
protected boolean |
shouldProcess(OMGeometry graphic)
This method is called internally for those methods where skipping invisible OMGeometries would save processing time and effort. |
|
int |
size()
|
|
void |
sort()
This sort method is a place-holder for OMGraphicList extensions to implement their own particular criteria for sorting an OMGraphicList. |
|
java.util.List<T> |
subList(int fromIndex,
int toIndex)
|
|
java.lang.Object[] |
toArray()
|
|
|
toArray(E[] a)
|
Methods inherited from class com.bbn.openmap.omGraphics.geom.BasicGeometry |
---|
_distance, appendShapeEdge, appendShapeEdge, appendShapeEdge, appendShapeEdge, clearAttributes, contains, createAttributeMap, createBoxShape, createShape, createShape, describeShapeDetail, describeShapeDetail, distanceToEdge, distanceToEdge, draw, draw, fill, fill, getAppObject, getAttribute, getAttributes, getLineType, getNeedToRegenerate, getShape, isRenderable, isRenderable, putAttribute, removeAttribute, setAppObject, setAttributes, setLineType, setNeedToRegenerate, setShape |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
addAll, addAll, equals, get, hashCode, set |
Methods inherited from interface com.bbn.openmap.omGraphics.OMGeometry |
---|
clearAttributes, contains, distanceToEdge, draw, draw, fill, fill, getAppObject, getAttribute, getAttributes, getLineType, getNeedToRegenerate, getShape, isRenderable, isRenderable, putAttribute, removeAttribute, setAppObject, setAttributes, setLineType, setNeedToRegenerate, setShape |
Field Detail |
---|
public static final transient int LAST_ADDED_ON_TOP
public static final transient int FIRST_ADDED_ON_TOP
public static final int NONE
protected int traverseMode
protected boolean vague
protected boolean allowDuplicates
protected java.util.List<T extends OMGeometry> graphics
protected boolean processAllGeometries
Constructor Detail |
---|
public OMList()
public OMList(int initialCapacity)
Method Detail |
---|
public java.lang.String getDescription()
getDescription
in interface OMGeometry
getDescription
in class BasicGeometry
public java.lang.String getDescription(int level)
public void setVague(boolean value)
public boolean isVague()
public java.util.Iterator<T> iterator()
iterator
in interface java.lang.Iterable<T extends OMGeometry>
iterator
in interface java.util.Collection<T extends OMGeometry>
iterator
in interface java.util.List<T extends OMGeometry>
public java.util.ListIterator<T> listIterator()
listIterator
in interface java.util.List<T extends OMGeometry>
public java.util.ListIterator<T> listIterator(int size)
listIterator
in interface java.util.List<T extends OMGeometry>
public java.util.List<T> subList(int fromIndex, int toIndex)
subList
in interface java.util.List<T extends OMGeometry>
public int size()
size
in interface java.util.Collection<T extends OMGeometry>
size
in interface java.util.List<T extends OMGeometry>
public boolean isEmpty()
isEmpty
in interface java.util.Collection<T extends OMGeometry>
isEmpty
in interface java.util.List<T extends OMGeometry>
public void clear()
clear
in interface java.util.Collection<T extends OMGeometry>
clear
in interface java.util.List<T extends OMGeometry>
public int indexOf(java.lang.Object o)
indexOf
in interface java.util.List<T extends OMGeometry>
public int lastIndexOf(java.lang.Object o)
lastIndexOf
in interface java.util.List<T extends OMGeometry>
public boolean removeAll(java.util.Collection<?> c)
removeAll
in interface java.util.Collection<T extends OMGeometry>
removeAll
in interface java.util.List<T extends OMGeometry>
public boolean retainAll(java.util.Collection<?> c)
retainAll
in interface java.util.Collection<T extends OMGeometry>
retainAll
in interface java.util.List<T extends OMGeometry>
public boolean contains(java.lang.Object o)
contains
in interface java.util.Collection<T extends OMGeometry>
contains
in interface java.util.List<T extends OMGeometry>
public boolean containsAll(java.util.Collection<?> c)
containsAll
in interface java.util.Collection<T extends OMGeometry>
containsAll
in interface java.util.List<T extends OMGeometry>
public boolean add(T g)
add
in interface java.util.Collection<T extends OMGeometry>
add
in interface java.util.List<T extends OMGeometry>
public void add(int index, T g)
add
in interface java.util.List<T extends OMGeometry>
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection<T extends OMGeometry>
toArray
in interface java.util.List<T extends OMGeometry>
public <E> E[] toArray(E[] a)
toArray
in interface java.util.Collection<T extends OMGeometry>
toArray
in interface java.util.List<T extends OMGeometry>
public void setTraverseMode(int mode)
mode
- traversal modepublic int getTraverseMode()
public boolean remove(java.lang.Object geometry)
remove
in interface java.util.Collection<T extends OMGeometry>
remove
in interface java.util.List<T extends OMGeometry>
geometry
- the object to remove.
public T remove(int index)
remove
in interface java.util.List<T extends OMGeometry>
public final java.util.List<T> getCopy()
public void moveIndexedOneToTop(int location)
location
- the index location of the graphic to move.moveIndexedOneToFront(int)
,
moveIndexedOneToBack(int)
public void moveIndexedToTop(int location)
location
- the index location of the graphic to move.public void moveIndexedOneToBottom(int location)
location
- the index location of the graphic to move.moveIndexedOneToFront(int)
,
moveIndexedOneToBack(int)
public void moveIndexedToBottom(int location)
location
- the index location of the graphic to move.public void moveIndexedToFirst(int location)
location
- the index of the graphic to move.moveIndexedToBottom(int)
,
moveIndexedToTop(int)
public void moveIndexedOneToFront(int location)
location
- the index of the graphic to move.public void moveIndexedToLast(int location)
location
- the index of the graphic to move.moveIndexedToBottom(int)
,
moveIndexedToTop(int)
public void moveIndexedOneToBack(int location)
location
- the index of the graphic to move.public void project(Projection p)
generate(Projection, boolean)
with
forceProjectAll
set to true
. This is the same
as calling generate(p, false)
p
- a Projection
generate(Projection, boolean)
public void project(Projection p, boolean forceProjectAll)
generate(p, forceProjectAll)
.
p
- a Projection
forceProjectAll
- if true, all the graphics on the list are
generated with the new projection. If false they are only
generated if getNeedToRegenerate() returns truegenerate(Projection, boolean)
public boolean generate(Projection p)
project(p, true)
.
generate
in interface OMGeometry
generate
in class OMGraphicAdapter
p
- a Projection
generate(Projection, boolean)
public boolean generate(Projection p, boolean forceProjectAll)
render()
! This recursively calls generate() on the
OMGraphics on the list.
p
- a Projection
forceProjectAll
- if true, all the graphics on the list are
generated with the new projection. If false they are only
generated if getNeedToRegenerate() returns true
OMGeometry.generate(com.bbn.openmap.proj.Projection)
,
OMGraphic.regenerate(com.bbn.openmap.proj.Projection)
public void render(java.awt.Graphics gr)
paint()
for AWT components. The graphics are rendered in
the order of traverseMode. Any graphics where isVisible()
returns false are not rendered.
render
in interface OMGeometry
render
in class OMGraphicAdapter
gr
- the AWT Graphics contextpublic void renderAllAsSelected(java.awt.Graphics gr)
paint()
for AWT
components. The graphics are rendered in the order of traverseMode. Any
graphics where isVisible()
returns false are not rendered.
All of the graphics on the list are returned to their deselected state.
gr
- the AWT Graphics contextprotected boolean shouldProcess(OMGeometry graphic)
public void setProcessAllGeometries(boolean set)
public boolean getProcessAllGeometries()
public float distance(double x, double y)
distance
in interface OMGeometry
distance
in class OMGraphicAdapter
x
- x coordinatey
- y coordinate
findClosest(double, double, float)
protected abstract OMList.OMDist<T> createDist()
public OMList.OMDist<T> findClosest(double x, double y, float limit, boolean resetSelect)
x
- x coordinatey
- y coordinatelimit
- the max distance that a graphic has to be within to be
returned, in pixels.resetSelect
- deselect any OMGraphic touched.
protected OMList.OMDist<T> findClosestTest(OMList.OMDist<T> current, int index, OMGeometry graphic, double x, double y, float limit, boolean resetSelect)
current
- the OMDist that contains the current best result of a
search.index
- the index in the graphic list of the provided OMGraphicgraphic
- the OMGraphic to testx
- the window horizontal pixel value.y
- the window vertical pixel value.resetSelect
- flag to call deselect on any OMGraphic contacted. Used
here to pass on in case the OMGraphic provided is an
OMGraphicList, and to use to decide if deselect should be called
on the provided graphic.
public T findClosest(double x, double y, float limit)
isVisible()
returns false are not considered.
x
- the x coordinate on the component the graphics are displayed on.y
- the y coordinate on the component the graphics are displayed on.limit
- the max distance that a graphic has to be within to be
returned, in pixels.
public OMList<T> findAll(int x, int y, float limit)
x
- the x coordinate on the component the graphics are displayed on.y
- the y coordinate on the component the graphics are displayed on.limit
- the max distance that a graphic has to be within to be
returned, in pixels.
public OMList<T> findAll(int x, int y, float limit, boolean resetSelect, OMList<T> addTo)
x
- the x coordinate on the component the graphics are displayed on.y
- the y coordinate on the component the graphics are displayed on.limit
- the max distance that a graphic has to be within to be
returned, in pixels.resetSelect
- call deselect on OMGraphics not within limit.addTo
- OMGraphicList to add found OMGraphics to, if null a list
will be created.
public abstract OMList<T> create()
protected boolean findAllTest(int x, int y, float limit, boolean resetSelect, OMList<T> addTo, OMGeometry geometry, OMList.OMDist<T> omd)
x
- the x coordinate on the component the graphics are displayed on.y
- the y coordinate on the component the graphics are displayed on.limit
- the max distance that a graphic has to be within to be
returned, in pixels.resetSelect
- call deselect on OMGraphic not within limit.addTo
- OMGraphicList to add found OMGeometries to, if null a list
will be created.geometry
- OMGraphic to test.omd
- OMDist to use for test, provided to avoid recurring memory
allocations for loops.
public T findClosest(int x, int y)
findClosest(x, y, Float.MAX_VALUE)
.
x
- the horizontal pixel position of the window, from the left of
the window.y
- the vertical pixel position of the window, from the top of the
window.
findClosest(double, double, float)
public int findIndexOfClosest(int x, int y, float limit)
isVisible()
returns false are not considered.
x
- the x coordinate on the component the graphics are displayed on.y
- the y coordinate on the component the graphics are displayed on.limit
- the max distance that a graphic has to be within to be
returned, in pixels.
public int findIndexOfClosest(int x, int y)
findClosest(x, y, Float.MAX_VALUE)
.
x
- the horizontal pixel position of the window, from the left of
the window.y
- the vertical pixel position of the window, from the top of the
window.
findIndexOfClosest(int, int, float)
public T selectClosest(int x, int y)
x
- the x coordinate on the component the graphics are displayed on.y
- the y coordinate on the component the graphics are displayed on.
public T selectClosest(int x, int y, float limit)
isVisible()
returns false are not considered.
x
- the horizontal pixel position of the window, from the left of
the window.y
- the vertical pixel position of the window, from the top of the
window.limit
- the max distance that a graphic has to be within to be
returned, in pixels.
protected OMList.OMDist<T> selectClosestTest(OMList.OMDist<T> current, int index, OMGeometry graphic, int x, int y, float limit)
current
- the OMDist that contains the current best result of a
search.index
- the index in the graphic list of the provided OMGraphicgraphic
- the OMGraphic to testx
- the window horizontal pixel value.y
- the window vertical pixel value.
public T getContains(int x, int y)
x
- the horizontal pixel position of the window, from the left of
the window.y
- the vertical pixel position of the window, from the top of the
window.
public void deselect()
deselect
in interface OMGeometry
deselect
in interface OMGraphic
deselect
in class OMGraphicAdapter
public void select()
select
in interface OMGeometry
select
in interface OMGraphic
select
in class OMGraphicAdapter
public void doAction(T graphic, OMAction action)
public void setVisible(boolean visible)
setVisible
in interface OMGeometry
setVisible
in class BasicGeometry
visible
- booleanpublic boolean isVisible()
isVisible
in interface OMGeometry
isVisible
in class BasicGeometry
public void setAllowDuplicates(boolean set)
public boolean getAllowDuplicates()
protected void checkForDuplicate(T g)
public boolean contains(OMGraphic g)
public void sort()
protected OMGraphic objectToOMGraphic(java.lang.Object obj)
public void restore(OMGeometry source)
restore
in interface OMGeometry
restore
in class OMGraphicAdapter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |