Package org.geotools.swing
Class DefaultRenderingExecutor
Object
DefaultRenderingExecutor
- All Implemented Interfaces:
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe default interval (milliseconds) for polling the result of a rendering taskFields inherited from interface RenderingExecutor
TASK_REJECTED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel(long taskId) Cancels a specific rendering task.voidSince 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.longGet the interval for polling the result of a rendering taskbooleanChecks whetherRenderingExecutor.shutdown()has been called.voidsetPollingInterval(long interval) Set the interval for polling the result of a rendering taskvoidshutdown()Stops any current rendering tasks and cleans up resources.longsubmit(MapContent mapContent, List<RenderingOperands> operands, RenderingExecutorListener listener) Submits a new rendering task to the executor.longsubmit(MapContent mapContent, GTRenderer renderer, Graphics2D graphics, RenderingExecutorListener listener) Submits a new rendering task to the executor.
-
Field Details
-
DEFAULT_POLLING_INTERVAL
public static final long DEFAULT_POLLING_INTERVALThe default interval (milliseconds) for polling the result of a rendering task- See Also:
-
-
Constructor Details
-
DefaultRenderingExecutor
public DefaultRenderingExecutor()Creates a new executor.
-
-
Method Details
-
getPollingInterval
public long getPollingInterval()Get the interval for polling the result of a rendering task- Specified by:
getPollingIntervalin interfaceRenderingExecutor- Returns:
- polling interval in milliseconds
-
setPollingInterval
public void setPollingInterval(long interval) Set the interval for polling the result of a rendering task- Specified by:
setPollingIntervalin interfaceRenderingExecutor- 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 returnsRenderingExecutor.TASK_REJECTEDinstead 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:
submitin interfaceRenderingExecutor- Parameters:
mapContent- the map content holding the layers to be renderedrenderer- the renderer to usegraphics- the graphics object to draw intolistener- 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:RenderingExecutorSubmits 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 returnsRenderingExecutor.TASK_REJECTEDinstead of a task ID value.- Specified by:
submitin interfaceRenderingExecutor- Parameters:
mapContent- the map content holding the layers to be renderedoperands- operands for each of the sub-tasks composing this tasklistener- 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:
cancelin interfaceRenderingExecutor- 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:
cancelAllin interfaceRenderingExecutor
-
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:
shutdownin interfaceRenderingExecutor
-
isShutdown
public boolean isShutdown()Checks whetherRenderingExecutor.shutdown()has been called.- Specified by:
isShutdownin interfaceRenderingExecutor- Returns:
trueif the executor has been shut down
-