Package org.geotools.swing
Class DefaultRenderingExecutor
- Object
-
- DefaultRenderingExecutor
-
- All Implemented Interfaces:
RenderingExecutor
public class DefaultRenderingExecutor extends Object implements RenderingExecutor
The default implementation ofRenderingExecutor
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:
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:taskId = executor.submit(areaToDraw, graphicsToDrawInto); if (taskId == RenderingExecutor.TASK_REJECTED) { ... }
executor.setPollingInterval( 10 ); // 10 milliseconds
- Since:
- 2.7
- Author:
- Michael Bedward
- See Also:
RenderingExecutorListener
-
-
Field Summary
Fields Modifier and Type Field Description 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
Constructors Constructor Description DefaultRenderingExecutor()
Creates a new executor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 taskboolean
isShutdown()
Checks whetherRenderingExecutor.shutdown()
has been called.void
setPollingInterval(long interval)
Set the interval for polling the result of a rendering taskvoid
shutdown()
Stops any current rendering tasks and cleans up resources.long
submit(MapContent mapContent, List<RenderingOperands> operands, RenderingExecutorListener listener)
Submits a new rendering task to the executor.long
submit(MapContent mapContent, GTRenderer renderer, Graphics2D graphics, RenderingExecutorListener listener)
Submits a new rendering task to the executor.
-
-
-
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
-
-
Method Detail
-
getPollingInterval
public long getPollingInterval()
Get the interval for polling the result of a rendering task- Specified by:
getPollingInterval
in 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:
setPollingInterval
in 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_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 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: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 returnsRenderingExecutor.TASK_REJECTED
instead of a task ID value.- Specified by:
submit
in 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:
cancel
in 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:
cancelAll
in 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:
shutdown
in interfaceRenderingExecutor
-
isShutdown
public boolean isShutdown()
Checks whetherRenderingExecutor.shutdown()
has been called.- Specified by:
isShutdown
in interfaceRenderingExecutor
- Returns:
true
if the executor has been shut down
-
-