StandardPCPolicy (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.policy
Class StandardPCPolicy

    java.lang.Object
      com.bbn.openmap.layer.policy.AbstractProjectionChangePolicy
          com.bbn.openmap.layer.policy.StandardPCPolicy

All Implemented Interfaces:
  ProjectionChangePolicy

    public class StandardPCPolicy

extends AbstractProjectionChangePolicy

ProjectionChangePolicy that uses a Layer SwingWorker to kick off a thread to call layer.prepare() and doesn't delete the OMGraphicList between projection changes. The standard behavior for simple layers that maintain a constant list of OMGraphics.

Field Summary
`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.

Fields inherited from class com.bbn.openmap.layer.policy.AbstractProjectionChangePolicy
`layer`

Constructor Summary
`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.

Method Summary
`boolean` | `getAlwaysSpawnThread()`
`int` | `getGraphicCutoff()`
`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)`
`protected boolean` | `shouldSpawnThreadForPrepare()` We're assuming that the list is somewhat constant for the layer.

Methods inherited from class com.bbn.openmap.layer.policy.AbstractProjectionChangePolicy
`getLayer, setLayer, workerComplete`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### graphicCutoff

    protected int graphicCutoff

  The number of OMGraphics that have to be on the layer's OMGraphicList before a thread is spawned. The default is 50;

### alwaysSpawnThread

    protected boolean alwaysSpawnThread

  A flag to tell the policy to always spawn a thread.

Constructor Detail

### StandardPCPolicy

    public StandardPCPolicy()

  You must set a layer at some point before using this class.

### StandardPCPolicy

    public StandardPCPolicy(OMGraphicHandlerLayer layer)

  Don't pass in a null layer.

### StandardPCPolicy

    public StandardPCPolicy(OMGraphicHandlerLayer layer,
                            boolean alwaysSpawnThreadForPrepare)

  Don't pass in a null layer.

  Parameters:
    `layer` - layer to work for
    `alwaysSpawnThreadForPrepare` - 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.

Method Detail

### setAlwaysSpawnThread

    public void setAlwaysSpawnThread(boolean val)

  Tell the policy whether to spawn a thread when projectionChanged() is called with a new projection.

  Parameters:
    `val` - setting for always spawning thread for every projection change.

### getAlwaysSpawnThread

    public boolean getAlwaysSpawnThread()

### projectionChanged

    public void projectionChanged(ProjectionEvent pe)

  When the projection changes, the StandardPCPolicy sets the current projection on the layer, and calls prepare() on the layer. repaint() will be automatically called. This method does not generate the OMGraphics in the list. The layer is still expected to do that in prepare(), as well as return that list from prepare.

  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.

  Parameters:
    `pe` - The ProjectionEvent received from the MapBean.

### shouldSpawnThreadForPrepare

    protected boolean shouldSpawnThreadForPrepare()

  We're assuming that the list is somewhat constant for the layer. If the number of OMGraphics on the layer's list is more than the cutoff number, a thread should be launched to generate them with the new projection. You can extend this method so that different criteria may be considered.

  Returns:
    true of thread should always be spawned.

### setGraphicCutoff

    public void setGraphicCutoff(int number)

  Parameters:
    `number` - Set the number of OMGraphics that have to be on the list before a thread gets spawned to call generate() on them.

### getGraphicCutoff

    public int getGraphicCutoff()

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