org.geotools.swing
Class RenderingExecutor

Object
  extended by RenderingExecutor

public class RenderingExecutor
extends Object

This class is used by JMapPane to handle the scheduling and running of rendering tasks on a background thread. It functions as a single thread, non- queueing executor, ie. only one rendering task can run at any given time and, while it is running, any other submitted tasks will be rejected.

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


     ReferencedEnvelope areaToDraw = ...
     Graphics2D graphicsToDrawInto = ...
     boolean accepted = renderingExecutor.submit(areaToDraw, graphicsToDrawInto);
 
The status of the executor can also be checked at any time like this:

     boolean busy = renderingExecutor.isRunning();
 
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:

     RenderingExecutor re = new RenderingExecutor( mapPane );
     re.setPollingInterval( 150 );  // 150 milliseconds
 

Since:
2.7
Author:
Michael Bedward
See Also:
JMapPane
Module:
modules/unsupported/swing (gt-swing.jar)

Nested Class Summary
static class RenderingExecutor.TaskResult
          Constants to indicate the result of a rendering task
 
Field Summary
static long DEFAULT_POLLING_INTERVAL
          The default interval (milliseconds) for polling the result of a rendering task
 
Constructor Summary
RenderingExecutor(JMapPane mapPane)
          Constructor.
 
Method Summary
 void cancelTask()
          Cancel the current rendering task if one is running
protected  void finalize()
           
 long getPollingInterval()
          Get the interval for polling the result of a rendering task
 boolean isRunning()
           
 void setPollingInterval(long interval)
          Set the interval for polling the result of a rendering task
 boolean submit(ReferencedEnvelope envelope, Rectangle paintArea, Graphics2D graphics)
          Submit a new rendering task.
 
Methods inherited from class Object
clone, equals, 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

RenderingExecutor

public RenderingExecutor(JMapPane mapPane)
Constructor. Creates a new executor to service the specified map pane.

Parameters:
mapPane - the map pane to be serviced
Method Detail

getPollingInterval

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

Returns:
polling interval in milliseconds

setPollingInterval

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

Parameters:
interval - interval in milliseconds (values <= 0 are ignored)

submit

public boolean submit(ReferencedEnvelope envelope,
                      Rectangle paintArea,
                      Graphics2D graphics)
Submit a new rendering task. If no rendering task is presently running this new task will be accepted; otherwise it will be rejected (ie. there is no task queue).

Parameters:
envelope - the map area (world coordinates) to be rendered
graphics - the graphics object to draw on
Returns:
true if the rendering task was accepted; false if it was rejected

cancelTask

public void cancelTask()
Cancel the current rendering task if one is running


isRunning

public boolean isRunning()

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable


Copyright © 1996-2010 Geotools. All Rights Reserved.