ilog.views.tiling
Class IlvThreadedTileLoader

java.lang.Object
  extended by ilog.views.tiling.IlvThreadedTileLoader
All Implemented Interfaces:
IlvPersistentObject, IlvTileLoader

public class IlvThreadedTileLoader
extends Object
implements IlvTileLoader

This tile loader class delegates actual tile loading to the tile loader set at construction time. It will load tiles in another thread and update the thread monitoring information.

Since:
JViews 7.5

Field Summary
static int CANCEL_OPPOSITE_TASK
          Indicates what to do when a unload and load have to be managed at the same time: none will be done.
static int PROCESS_ALL_TASKS
          Indicates what to do when a unload and load have to be managed at the same time: will do both
static int REPAINT_AFTER_ALL_TILES
          Indicates whether the tiles should be redrawn only after all have been loaded.
static int REPAINT_AFTER_EACH_TILE
          Indicates whether the tiles should be redrawn after each tile is loaded.
static int REPLACE_OPPOSITE_TASK
          Indicates what to do when a unload and load have to be managed at the same time: only last task will be processed.
 
Constructor Summary
IlvThreadedTileLoader(IlvInputStream stream)
          Reads a threaded tile loader from an input stream.
IlvThreadedTileLoader(IlvTileLoader tileLoader, boolean threaded)
          Creates a tile loader loading tiles on a background thread.
 
Method Summary
 void addNonCancellableTask(IlvTile currentTile)
          Specify that a task related to the given tile can not be cancel.
 void dispose()
          Disposes of the resources used by this loader.
 int getActiveTasksCount()
          Returns the number of tiles to load.
 IlvTileLoader getDelegateLoader()
          Returns the delegate IlvTileLoader of this threaded loader.
 int getEnqueuePolicy()
          Returns the current enqueue Policy.
 int getRepaintPolicy()
          Returns the repaint policy.
 int getThreadPriority()
          Returns the priority of threads used by this threaded loader.
 boolean isPersistent()
          Returns true if the object must be saved by a tile controller.
 boolean isThreaded()
          Returns true if the load/release work is performed in a separate thread.
 void load(IlvTile tile)
          Function called when a tile has to be loaded.
 void release(IlvTile tile)
          Function called when a tile has to be released.
 void setEnqueuePolicy(int enqueuePolicy)
          Sets the enqueue policy.
 void setRepaintPolicy(int repaintPolicy)
          Sets the new repaint policy.
 void setThreaded(boolean threaded, boolean wait)
          Sets whether the load/release work should be performed in a separate thread.
 void setThreadPriority(int threadPriority)
          Set the priority of threads used by this loader.
 void write(IlvOutputStream stream)
          Writes the attributes of a persistent object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REPAINT_AFTER_EACH_TILE

public static int REPAINT_AFTER_EACH_TILE
Indicates whether the tiles should be redrawn after each tile is loaded.


REPAINT_AFTER_ALL_TILES

public static int REPAINT_AFTER_ALL_TILES
Indicates whether the tiles should be redrawn only after all have been loaded.


PROCESS_ALL_TASKS

public static int PROCESS_ALL_TASKS
Indicates what to do when a unload and load have to be managed at the same time: will do both


CANCEL_OPPOSITE_TASK

public static int CANCEL_OPPOSITE_TASK
Indicates what to do when a unload and load have to be managed at the same time: none will be done.


REPLACE_OPPOSITE_TASK

public static int REPLACE_OPPOSITE_TASK
Indicates what to do when a unload and load have to be managed at the same time: only last task will be processed.

Constructor Detail

IlvThreadedTileLoader

public IlvThreadedTileLoader(IlvTileLoader tileLoader,
                             boolean threaded)
Creates a tile loader loading tiles on a background thread.

Parameters:
tileLoader - delegate that does the real loading and unloading
threaded - true if load/release should be performed in a separate thread

IlvThreadedTileLoader

public IlvThreadedTileLoader(IlvInputStream stream)
                      throws IlvReadFileException
Reads a threaded tile loader from an input stream.

Parameters:
stream - stream to read from.
Throws:
IlvReadFileException
Method Detail

getActiveTasksCount

public int getActiveTasksCount()
Returns the number of tiles to load.


isThreaded

public boolean isThreaded()
Returns true if the load/release work is performed in a separate thread.


setThreaded

public void setThreaded(boolean threaded,
                        boolean wait)
Sets whether the load/release work should be performed in a separate thread.

Parameters:
threaded - true if the load/release work should be performed in a separate thread.
wait - true to wait for all current tiles being loaded before switching to non-threaded mode.

load

public void load(IlvTile tile)
          throws Exception
Function called when a tile has to be loaded. When the tile loader has finished its operation, it should call the function IlvTile.loadComplete to notify the tile listeners.

Specified by:
load in interface IlvTileLoader
Throws:
Exception

release

public void release(IlvTile tile)
Function called when a tile has to be released.

Specified by:
release in interface IlvTileLoader

isPersistent

public boolean isPersistent()
Returns true if the object must be saved by a tile controller.

Specified by:
isPersistent in interface IlvTileLoader

write

public void write(IlvOutputStream stream)
           throws IOException
Writes the attributes of a persistent object.

Specified by:
write in interface IlvPersistentObject
Specified by:
write in interface IlvTileLoader
Parameters:
stream - the output stream
Throws:
IOException - thrown when an exception occurs during the write operation for this object.

getRepaintPolicy

public int getRepaintPolicy()
Returns the repaint policy.

See Also:
REPAINT_AFTER_ALL_TILES, REPAINT_AFTER_EACH_TILE

setRepaintPolicy

public void setRepaintPolicy(int repaintPolicy)
Sets the new repaint policy.

Parameters:
repaintPolicy - The policy to set. Possible values are REPAINT_AFTER_ALL_TILES and REPAINT_AFTER_EACH_TILE
See Also:
REPAINT_AFTER_ALL_TILES, REPAINT_AFTER_EACH_TILE

addNonCancellableTask

public void addNonCancellableTask(IlvTile currentTile)
Specify that a task related to the given tile can not be cancel.

Parameters:
currentTile - the tile

getDelegateLoader

public IlvTileLoader getDelegateLoader()
Returns the delegate IlvTileLoader of this threaded loader.


getThreadPriority

public int getThreadPriority()
Returns the priority of threads used by this threaded loader.


setThreadPriority

public void setThreadPriority(int threadPriority)
Set the priority of threads used by this loader.

Parameters:
threadPriority - The threadPriority to set.

getEnqueuePolicy

public int getEnqueuePolicy()
Returns the current enqueue Policy.

See Also:
CANCEL_OPPOSITE_TASK, PROCESS_ALL_TASKS, REPLACE_OPPOSITE_TASK

setEnqueuePolicy

public void setEnqueuePolicy(int enqueuePolicy)
Sets the enqueue policy.

Parameters:
enqueuePolicy - The policy to set. Possible values are : CANCEL_OPPOSITE_TASK, PROCESS_ALL_TASKS or REPLACE_OPPOSITE_TASK
See Also:
CANCEL_OPPOSITE_TASK, PROCESS_ALL_TASKS, REPLACE_OPPOSITE_TASK

dispose

public void dispose()
Disposes of the resources used by this loader. Interrupts all the threads managed by this ThreadedLoader.



Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.