org.geotools.swing
Class DefaultRenderingExecutor

Object
  extended by DefaultRenderingExecutor
All Implemented Interfaces:
RenderingExecutor

public class DefaultRenderingExecutor
extends Object
implements RenderingExecutor

The default implementation of RenderingExecutor which is used by JMapPane and JLayeredMapPane. It runs no more than one rendering task at any given time, although that task may involve multiple threads (e.g. each layer of a map being rendered into separate destinations. While a task is running any other submitted tasks are rejected.

Whether a rendering task is accepted or rejected can be tested on submission:


 taskId = executor.submit(areaToDraw, graphicsToDrawInto);
 if (taskId == RenderingExecutor.TASK_REJECTED) {
     ...
 }
 
While a rendering task is running it is regularly polled to see if it has completed and, if so, whether it finished normally, was cancelled or failed. The interval between polling can be adjusted which might be useful to tune the executor for particular applications:

     executor.setPollingInterval( 10 );  // 10 milliseconds
 

Since:
2.7
Author:
Michael Bedward
See Also:
RenderingExecutorListener

Field Summary
static long DEFAULT_POLLING_INTERVAL
          The default interval (milliseconds) for polling the result of a rendering task
 
Fields inherited from interface RenderingExecutor
TASK_REJECTED
 
Constructor Summary
DefaultRenderingExecutor()
          Creates a new executor.
 
Method Summary
 void cancel(long taskId)
          Cancels a specific rendering task.
 void cancelAll()
           Since this task can only ever have a single task running, and no tasks queued, this method simply checks for a running task and, if one exists, cancels it.
 long getPollingInterval()
          Get the interval for polling the result of a rendering task
 boolean isShutdown()
          Checks whether RenderingExecutor.shutdown() has been called.
 void setPollingInterval(long interval)
          Set the interval for polling the result of a rendering task
 void shutdown()
          Stops any current rendering tasks and cleans up resources.
 long submit(MapContent mapContent, GTRenderer renderer, Graphics2D graphics, RenderingExecutorListener listener)
          Submits a new rendering task to the executor.
 long submit(MapContent mapContent, List<RenderingOperands> operands, RenderingExecutorListener listener)
          Submits a new rendering task to the executor.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_POLLING_INTERVAL

public static final long DEFAULT_POLLING_INTERVAL
The default interval (milliseconds) for polling the result of a rendering task

See Also:
Constant Field Values
Constructor Detail

DefaultRenderingExecutor

public DefaultRenderingExecutor()
Creates a new executor.

Method Detail

getPollingInterval

public long getPollingInterval()
Get the interval for polling the result of a rendering task

Specified by:
getPollingInterval in interface RenderingExecutor
Returns:
polling interval in milliseconds

setPollingInterval

public void setPollingInterval(long interval)
Set the interval for polling the result of a rendering task

Specified by:
setPollingInterval in interface RenderingExecutor
Parameters:
interval - interval in milliseconds (values <= 0 are ignored)

submit

public long submit(MapContent mapContent,
                   GTRenderer renderer,
                   Graphics2D graphics,
                   RenderingExecutorListener listener)
Submits a new rendering task to the executor. The specified listener will be notified of task progress. If the task is rejected by the executor for any reason, this method returns RenderingExecutor.TASK_REJECTED instead of a task ID value. If no rendering task is presently running this new task will be accepted, otherwise it will be rejected (ie. there is no task queue).

Specified by:
submit in interface RenderingExecutor
Parameters:
mapContent - the map content holding the layers to be rendered
renderer - the renderer to use
graphics - the graphics object to draw into
listener - the listener to be notified of task progress
Returns:
either a task ID value (which should be positive and unique across all executors and rendering tasks) if the task was accepted; or RenderingExecutor.TASK_REJECTED

submit

public long submit(MapContent mapContent,
                   List<RenderingOperands> operands,
                   RenderingExecutorListener listener)
Description copied from interface: RenderingExecutor
Submits a new rendering task to the executor. The specified listener will be notified of task progress. If the task is rejected by the executor for any reason, this method returns RenderingExecutor.TASK_REJECTED instead of a task ID value.

Specified by:
submit in interface RenderingExecutor
Parameters:
mapContent - the map content holding the layers to be rendered
operands - operands for each of the sub-tasks composing this task
listener - the listener to be notified of task progress
Returns:
either a task ID value (which should be positive and unique across all executors and rendering tasks) if the task was accepted; or RenderingExecutor.TASK_REJECTED

cancel

public void cancel(long taskId)
Cancels a specific rendering task.

Specified by:
cancel in interface RenderingExecutor
Parameters:
taskId - the ID value of the task

cancelAll

public void cancelAll()
Since this task can only ever have a single task running, and no tasks queued, this method simply checks for a running task and, if one exists, cancels it.

Specified by:
cancelAll in interface RenderingExecutor

shutdown

public void shutdown()
Stops any current rendering tasks and cleans up resources. After calling this method the executor is no longer usable.

Specified by:
shutdown in interface RenderingExecutor

isShutdown

public boolean isShutdown()
Checks whether RenderingExecutor.shutdown() has been called.

Specified by:
isShutdown in interface RenderingExecutor
Returns:
true if the executor has been shut down


Copyright © 1996-2014 Geotools. All Rights Reserved.