Class 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 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