public class StandardPCPolicy extends java.lang.Object implements ProjectionChangePolicy
Modifier and Type | Field and Description |
---|---|
protected boolean |
alwaysSpawnThread
A flag to tell the policy to always spawn a thread.
|
protected int |
graphicCutoff
The number of OMGraphics that have to be on the layer's OMGraphicList
before a thread is spawned.
|
protected OMGraphicHandlerLayer |
layer
The OMGraphicHandlerLayer using this policy.
|
Constructor and Description |
---|
StandardPCPolicy()
You must set a layer at some point before using this class.
|
StandardPCPolicy(OMGraphicHandlerLayer layer)
Don't pass in a null layer.
|
StandardPCPolicy(OMGraphicHandlerLayer layer,
boolean alwaysSpawnThreadForPrepare)
Don't pass in a null layer.
|
Modifier and Type | Method and Description |
---|---|
boolean |
getAlwaysSpawnThread() |
int |
getGraphicCutoff() |
OMGraphicHandlerLayer |
getLayer()
Get the OMGraphicHandlerLayer to work with.
|
void |
projectionChanged(ProjectionEvent pe)
When the projection changes, the StandardPCPolicy sets the current
projection on the layer, and calls prepare() on the layer.
|
void |
setAlwaysSpawnThread(boolean val)
Tell the policy whether to spawn a thread when projectionChanged() is
called with a new projection.
|
void |
setGraphicCutoff(int number)
Set the number of OMGraphics that have to be on the list before a thread
gets spawned to call generate() on them.
|
void |
setLayer(OMGraphicHandlerLayer l)
Set the OMGraphicHandlerLayer to work with.
|
protected boolean |
shouldSpawnThreadForPrepare()
We're assuming that the list is somewhat constant for the layer.
|
void |
workerComplete(OMGraphicList aList)
This is a subtle call, that dictates what should happen when the
LayerWorker has completed working in it's thread.
|
protected OMGraphicHandlerLayer layer
protected int graphicCutoff
protected boolean alwaysSpawnThread
public StandardPCPolicy()
public StandardPCPolicy(OMGraphicHandlerLayer layer)
public StandardPCPolicy(OMGraphicHandlerLayer layer, boolean alwaysSpawnThreadForPrepare)
layer
- layer to work foralwaysSpawnThreadForPrepare
- should be true if the layer's prepare
method takes a while. Normally, the policy looks at the number of
OMGraphics on the list to determine if a thread should be spawned.
True by default.public void setLayer(OMGraphicHandlerLayer l)
ProjectionChangePolicy
setLayer
in interface ProjectionChangePolicy
public OMGraphicHandlerLayer getLayer()
ProjectionChangePolicy
getLayer
in interface ProjectionChangePolicy
public void setAlwaysSpawnThread(boolean val)
public boolean getAlwaysSpawnThread()
public void projectionChanged(ProjectionEvent pe)
If a Layer is using this PC policy, then it's kind of assumed that the layer is setting the list and generating the same list over and over again with the new projection. So, when we look at the min and max scales set on the layer, we don't want to clear out that list if the projection scale is outside of the acceptable range of good projection scales. Instead, we want to skip the prepare() method call as to not waste CPU cycles generating things we won't see, and let the RenderPolicy check to see if the list should be painted.
projectionChanged
in interface ProjectionChangePolicy
public void workerComplete(OMGraphicList aList)
workerComplete
in interface ProjectionChangePolicy
protected boolean shouldSpawnThreadForPrepare()
public void setGraphicCutoff(int number)
public int getGraphicCutoff()
Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details