fr.inria.zuist.engine
Class SceneManager

java.lang.Object
  extended by fr.inria.zuist.engine.SceneManager
All Implemented Interfaces:
CameraListener

public class SceneManager
extends Object
implements CameraListener

Multi-scale scene manager: main ZUIST class instantiated by client application. Used to parse XML descriptions of multi-scale scene configurations and manage them once instantiated.

Author:
Emmanuel Pietriga

Field Summary
static String _alpha
           
static String _anchor
           
static String _appear
           
static String _background
           
static String _bicubic
           
static String _bilinear
           
static String _bold
           
static String _boldItalic
           
static String _ceiling
           
static String _containedIn
           
static String _depth
           
static String _diappear
           
static String _fadein
           
static String _fadeout
           
static String _fill
           
static String _floor
           
static String _focusOnObject
           
static String _fontFamily
           
static String _fontSize
           
static String _fontStyle
           
static String _h
           
static String _id
           
static String _im
           
static String _include
           
static String _italic
           
static String _layer
           
static String _level
           
static String _levels
           
static String _nearestNeighbor
           
static String _none
           
static String _object
           
static String _onClick
           
static String _params
           
static String _plain
           
static String _points
           
static String _polygon
           
static String _rect
           
static String _region
           
static String _resource
           
static String _ro
           
static String _scale
           
static String _sensitive
           
static String _src
           
static String _stroke
           
static String _takesToO
           
static String _takesToR
           
static String _text
           
static String _tfll
           
static String _tful
           
static String _title
           
static String _ttll
           
static String _ttul
           
static String _type
           
static String _w
           
static String _x
           
static String _y
           
static String _zindex
           
static String COORD_SEPARATOR
           
static String PARAM_SEPARATOR
           
static short TAKES_TO_OBJECT
           
static short TAKES_TO_REGION
           
 
Constructor Summary
SceneManager(VirtualSpace[] vss, Camera[] cs)
          Scene Manager: Main ZUIST class instantiated by client application.
 
Method Summary
 void cameraMoved(Camera cam, Point2D.Double loc, double alt)
          Called back when a Camera is moved.
 ClosedShapeDescription createClosedShapeDescription(ClosedShape g, String id, int zindex, Region region, boolean sensitivity)
           
 fr.inria.zuist.engine.GlyphDescription createGlyphDescription(Glyph g, String id, int zindex, Region region, boolean sensitivity)
           
 ImageDescription createImageDescription(double x, double y, double w, double h, String id, int zindex, Region region, URL imageURL, boolean sensitivity, Color stroke, float alpha, String params)
          Creates an image and adds it to a region.
 Level createLevel(int depth, double calt, double falt)
          Create a new level in the scene.
 Region createRegion(double x, double y, double w, double h, int highestLevel, int lowestLevel, String id, String title, int li, short[] transitions, short requestOrdering, boolean sensitivity, Color fill, Color stroke)
          Create a new region.
 ResourceDescription createResourceDescription(double x, double y, String id, int zindex, Region region, URL resourceURL, String type, boolean sensitivity, Color stroke, String params)
          Creates a resource and adds it to a region.
 SceneFragmentDescription createSceneFragmentDescription(double x, double y, String id, Region region, URL resourceURL)
           
 TextDescription createTextDescription(double x, double y, String id, int zindex, Region region, float scale, String text, short anchor, Color fill, float alpha, String family, int style, int size, boolean sensitivity)
          Creates a text object and adds it to a region.
 void destroyRegion(Region r)
          Destroy a region.
 void destroyRegionsAtLevel(int l)
          Destroy all regions at a given level.
 void destroySceneFragment(SceneFragmentDescription sd)
           
 void enableRegionUpdater(boolean b)
           
 double[] findFarmostRegionCoords()
          Get the bounding box of all regions in this scene.
static URL getAbsoluteURL(String src, File sceneFileDir)
           
 Region getClosestRegionAtCurrentLevel(Point2D.Double lp)
          Get region whose center is closest to a given location at the current level.
 int getCurrentLevel()
          Get the current level.
static boolean getDebugMode()
           
static int getFontStyle(String style)
           
 double[] getGlobalView(Camera c, int d, EndAction ea)
          Get a global view of the scene.
 Level getLevel(int index)
          Get a level.
 int getLevelCount()
          Get the total number of levels in the scene.
 LevelListener getLevelListener()
           
 ObjectDescription getObject(String id)
          Get an object knowing its ID.
 int getObjectCount()
          Get the total number of objects (at any level and in any region) in the scene.
 Collection<ObjectDescription> getObjectDescriptions()
          Gets an unmodifiable view of every ObjectDescription known to this SceneManager
 Enumeration getObjectIDs()
          Get a list of all object IDs, at any level and in any region.
 ObjectListener getObjectListener()
           
 Point2D.Double getOrigin()
          Is set to something else than 0,0 when translating a scene to another location than that defined originally.
 int getPendingRequestQueueSize()
           
 Region getRegion(String id)
          Get a region knowing its ID.
 int getRegionCount()
          Get the total number of regions (at any level) in the scene.
 Enumeration getRegionIDs()
           
 RegionListener getRegionListener()
           
 Region[] getRegionsAtLevel(int level)
          Get all regions that belong to a given level.
 ResourceHandler getResourceHandler(String rType)
          Get the class handling a given type of resource.
 HashMap getSceneAttributes()
           
 VirtualSpace getSpaceByIndex(int layerIndex)
           
 Region[] loadScene(Document scene, File sceneFileDirectory, boolean reset)
          Load a multi-scale scene configuration described in an XML document.
 Region[] loadScene(Document scene, File sceneFileDirectory, boolean reset, ProgressListener pl)
          Load a multi-scale scene configuration described in an XML document.
 void objectCreated(ObjectDescription od)
          For internal use.
 void objectDestroyed(ObjectDescription od)
          For internal use.
protected static Object parseInterpolation(String im)
           
static Point2D.Double[] parseVertexCoordinates(String s, Point2D.Double orig)
           
static Document parseXML(File f)
           
 void reset()
           
static void setDebugMode(boolean b)
           
 void setFadeInDuration(int d)
           
 void setFadeOutDuration(int d)
           
 void setLevelListener(LevelListener ll)
           
 void setObjectListener(ObjectListener ol)
           
 void setOrigin(Point2D.Double p)
          Set to something else than 0,0 to translate a scene to another location than that defined originally.
 void setRegionListener(RegionListener rl)
           
 void setRegionUpdatePeriod(int period)
          Sets the RegionUpdater period.
 void setResourceHandler(String rType, ResourceHandler rh)
          Declare a ResourceHandler for a given type of resource.
 void setUpdateLevel(boolean b)
          Enable/disable level updating.
 void shutdown()
          Shuts down this SceneManager.
 void updateVisibleRegions()
          Update visible regions for all cameras.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_none

public static final String _none
See Also:
Constant Field Values

_level

public static final String _level
See Also:
Constant Field Values

_region

public static final String _region
See Also:
Constant Field Values

_object

public static final String _object
See Also:
Constant Field Values

_id

public static final String _id
See Also:
Constant Field Values

_title

public static final String _title
See Also:
Constant Field Values

_containedIn

public static final String _containedIn
See Also:
Constant Field Values

_resource

public static final String _resource
See Also:
Constant Field Values

_type

public static final String _type
See Also:
Constant Field Values

_text

public static final String _text
See Also:
Constant Field Values

_rect

public static final String _rect
See Also:
Constant Field Values

_polygon

public static final String _polygon
See Also:
Constant Field Values

_include

public static final String _include
See Also:
Constant Field Values

_x

public static final String _x
See Also:
Constant Field Values

_y

public static final String _y
See Also:
Constant Field Values

_w

public static final String _w
See Also:
Constant Field Values

_h

public static final String _h
See Also:
Constant Field Values

_points

public static final String _points
See Also:
Constant Field Values

_alpha

public static final String _alpha
See Also:
Constant Field Values

_fill

public static final String _fill
See Also:
Constant Field Values

_stroke

public static final String _stroke
See Also:
Constant Field Values

_background

public static final String _background
See Also:
Constant Field Values

_scale

public static final String _scale
See Also:
Constant Field Values

_src

public static final String _src
See Also:
Constant Field Values

_onClick

public static final String _onClick
See Also:
Constant Field Values

_focusOnObject

public static final String _focusOnObject
See Also:
Constant Field Values

_tful

public static final String _tful
See Also:
Constant Field Values

_tfll

public static final String _tfll
See Also:
Constant Field Values

_ttul

public static final String _ttul
See Also:
Constant Field Values

_ttll

public static final String _ttll
See Also:
Constant Field Values

_appear

public static final String _appear
See Also:
Constant Field Values

_diappear

public static final String _diappear
See Also:
Constant Field Values

_fadein

public static final String _fadein
See Also:
Constant Field Values

_fadeout

public static final String _fadeout
See Also:
Constant Field Values

_levels

public static final String _levels
See Also:
Constant Field Values

_depth

public static final String _depth
See Also:
Constant Field Values

_ceiling

public static final String _ceiling
See Also:
Constant Field Values

_floor

public static final String _floor
See Also:
Constant Field Values

_ro

public static final String _ro
See Also:
Constant Field Values

_takesToR

public static final String _takesToR
See Also:
Constant Field Values

_takesToO

public static final String _takesToO
See Also:
Constant Field Values

_sensitive

public static final String _sensitive
See Also:
Constant Field Values

_anchor

public static final String _anchor
See Also:
Constant Field Values

_layer

public static final String _layer
See Also:
Constant Field Values

_zindex

public static final String _zindex
See Also:
Constant Field Values

_params

public static final String _params
See Also:
Constant Field Values

_im

public static final String _im
See Also:
Constant Field Values

_nearestNeighbor

public static final String _nearestNeighbor
See Also:
Constant Field Values

_bilinear

public static final String _bilinear
See Also:
Constant Field Values

_bicubic

public static final String _bicubic
See Also:
Constant Field Values

_fontFamily

public static final String _fontFamily
See Also:
Constant Field Values

_fontStyle

public static final String _fontStyle
See Also:
Constant Field Values

_fontSize

public static final String _fontSize
See Also:
Constant Field Values

_plain

public static final String _plain
See Also:
Constant Field Values

_italic

public static final String _italic
See Also:
Constant Field Values

_bold

public static final String _bold
See Also:
Constant Field Values

_boldItalic

public static final String _boldItalic
See Also:
Constant Field Values

PARAM_SEPARATOR

public static final String PARAM_SEPARATOR
See Also:
Constant Field Values

COORD_SEPARATOR

public static final String COORD_SEPARATOR
See Also:
Constant Field Values

TAKES_TO_OBJECT

public static final short TAKES_TO_OBJECT
See Also:
Constant Field Values

TAKES_TO_REGION

public static final short TAKES_TO_REGION
See Also:
Constant Field Values
Constructor Detail

SceneManager

public SceneManager(VirtualSpace[] vss,
                    Camera[] cs)
Scene Manager: Main ZUIST class instantiated by client application.

Parameters:
vss - virtual spaces in which the scene will be loaded
cs - cameras associated to those virtual spaces, through which the scene will be observed
Method Detail

setRegionUpdatePeriod

public void setRegionUpdatePeriod(int period)
Sets the RegionUpdater period. Region updates will be spaced by at least period milliseconds.

Parameters:
period - the new period, in milliseconds.

shutdown

public void shutdown()
Shuts down this SceneManager. The SceneManager should not be used after invoking shutdown.


setResourceHandler

public void setResourceHandler(String rType,
                               ResourceHandler rh)
Declare a ResourceHandler for a given type of resource.

Parameters:
rType - type of resource to be handled, e.g., "pdf", "img", ...
rh - class implementing ResourceHandler for that type of resource

getResourceHandler

public ResourceHandler getResourceHandler(String rType)
Get the class handling a given type of resource.

Parameters:
rType - type of resource to handled, e.g., "pdf", "img", ...
Returns:
instance of class implementing ResourceHandler for that type of resource. Null if none associated with rType.

getObjectDescriptions

public Collection<ObjectDescription> getObjectDescriptions()
Gets an unmodifiable view of every ObjectDescription known to this SceneManager


setOrigin

public void setOrigin(Point2D.Double p)
Set to something else than 0,0 to translate a scene to another location than that defined originally.


getOrigin

public Point2D.Double getOrigin()
Is set to something else than 0,0 when translating a scene to another location than that defined originally.


getSceneAttributes

public HashMap getSceneAttributes()
Returns:
the actual hashmap used internally to store scene attributes.

getRegionIDs

public Enumeration getRegionIDs()

getRegion

public Region getRegion(String id)
Get a region knowing its ID.

Returns:
null if no region associated with this ID.

getObjectIDs

public Enumeration getObjectIDs()
Get a list of all object IDs, at any level and in any region.

Returns:
sequence of object IDs in no particular order

getObject

public ObjectDescription getObject(String id)
Get an object knowing its ID.

Returns:
null if no object associated with this ID.

getObjectCount

public int getObjectCount()
Get the total number of objects (at any level and in any region) in the scene.


getRegionCount

public int getRegionCount()
Get the total number of regions (at any level) in the scene.


getLevelCount

public int getLevelCount()
Get the total number of levels in the scene.


getLevel

public Level getLevel(int index)
Get a level.

Parameters:
index - index of level.
Returns:
null if level index does not correspond to an actual level.

getRegionsAtLevel

public Region[] getRegionsAtLevel(int level)
Get all regions that belong to a given level.

Parameters:
level - index of level.
Returns:
sequence of regions at this level, in no particular order. Returns null if level index does not correspond to an actual level.

setLevelListener

public void setLevelListener(LevelListener ll)

getLevelListener

public LevelListener getLevelListener()

setRegionListener

public void setRegionListener(RegionListener rl)

getRegionListener

public RegionListener getRegionListener()

getPendingRequestQueueSize

public int getPendingRequestQueueSize()

setObjectListener

public void setObjectListener(ObjectListener ol)

getObjectListener

public ObjectListener getObjectListener()

objectCreated

public void objectCreated(ObjectDescription od)
For internal use.


objectDestroyed

public void objectDestroyed(ObjectDescription od)
For internal use. Made public for outside package subclassing


reset

public void reset()

loadScene

public Region[] loadScene(Document scene,
                          File sceneFileDirectory,
                          boolean reset)
Load a multi-scale scene configuration described in an XML document.

Parameters:
scene - XML document (DOM) containing the scene description
sceneFileDirectory - absolute or relative (w.r.t exec dir) path to the directory containing that XML file (required only if the scene contains image objects whose location is indicated as relative paths to the bitmap files)
reset - reset scene (default is true) ; if false, append regions and objects to existing scene, new levels are ignored (as they would most likely conflict).

loadScene

public Region[] loadScene(Document scene,
                          File sceneFileDirectory,
                          boolean reset,
                          ProgressListener pl)
Load a multi-scale scene configuration described in an XML document.

Parameters:
scene - XML document (DOM) containing the scene description
sceneFileDirectory - absolute or relative (w.r.t exec dir) path to the directory containing that XML file (required only if the scene contains image objects whose location is indicated as relative paths to the bitmap files)
reset - reset scene (default is true) ; if false, append regions and objects to existing scene, new levels are ignored (as they would most likely conflict).

createSceneFragmentDescription

public SceneFragmentDescription createSceneFragmentDescription(double x,
                                                               double y,
                                                               String id,
                                                               Region region,
                                                               URL resourceURL)

destroySceneFragment

public void destroySceneFragment(SceneFragmentDescription sd)

createLevel

public Level createLevel(int depth,
                         double calt,
                         double falt)
Create a new level in the scene.

Parameters:
depth - of this level (0 corresponds to the highest level in terms of altitude range)
calt - ceiling altitude
falt - floor altitude

createRegion

public Region createRegion(double x,
                           double y,
                           double w,
                           double h,
                           int highestLevel,
                           int lowestLevel,
                           String id,
                           String title,
                           int li,
                           short[] transitions,
                           short requestOrdering,
                           boolean sensitivity,
                           Color fill,
                           Color stroke)
Create a new region. Important: when called directly from the client application, Region.setContainingRegion() should also be called manually (if there is any such containing region). Also important: if the region is neither visible nor sensitive at instantiation time, its associated glyph is not added to the virtual space. Note that containment relationships between regions have to be set manually through calls to Region instance methods.

Parameters:
x - center of region
y - center of region
w - width of region
h - height of region
highestLevel - index of highest level in level span for this region (highestLevel <= lowestLevel)
lowestLevel - index of lowest level in level span for this region (highestLevel <= lowestLevel)
id - region ID
title - region's title (metadata)
li - layer index (information layer/space in which objects will be put)
transitions - a 4-element array with values in Region.{FADE_IN, FADE_OUT, APPEAR, DISAPPEAR}, corresponding to transitions from upper level, from lower level, to upper level, to lower level.
requestOrdering - how requests for loading / unloading objects should be ordered when entering / leaving this region; one of Region.{ORDERING_ARRAY, ORDERING_DISTANCE}.
sensitivity - should the rectangle symbolizing the region itself be sensitive to mouse events or not.
fill - fill color of the rectangle symbolizing the region itself
stroke - border color of the rectangle symbolizing the region itself
See Also:
Region.setContainingRegion(Region r), Region.addContainedRegion(Region r)

destroyRegionsAtLevel

public void destroyRegionsAtLevel(int l)
Destroy all regions at a given level. Destroying a region destroys all object descriptions it contains.

Parameters:
l - level index

destroyRegion

public void destroyRegion(Region r)
Destroy a region. Destroying a region destroys all object descriptions it contains.

Parameters:
r - region to be destroyed

createResourceDescription

public ResourceDescription createResourceDescription(double x,
                                                     double y,
                                                     String id,
                                                     int zindex,
                                                     Region region,
                                                     URL resourceURL,
                                                     String type,
                                                     boolean sensitivity,
                                                     Color stroke,
                                                     String params)
Creates a resource and adds it to a region.

Parameters:
id - ID of object in scene
x - x-coordinate in scene
y - y-coordinate in scene
zindex - z-index (layer)
resourceURL - path to resource (should be absolute)
type - resource type ("img", "pdf", ...)
sensitivity - should the object be sensitive to mouse events or not.
stroke - border color
region - parent Region in scene
params - custom parameters for a given type of resource

createImageDescription

public ImageDescription createImageDescription(double x,
                                               double y,
                                               double w,
                                               double h,
                                               String id,
                                               int zindex,
                                               Region region,
                                               URL imageURL,
                                               boolean sensitivity,
                                               Color stroke,
                                               float alpha,
                                               String params)
Creates an image and adds it to a region.

Parameters:
id - ID of object in scene
x - x-coordinate in scene
y - y-coordinate in scene
zindex - z-index (layer)
w - width in scene
h - height in scene
imageURL - path to bitmap resource (should be absolute)
stroke - border color
sensitivity - should the object be sensitive to mouse events or not.
params - allowed parameters: "im=nearestNeighbor", "im=bilinear", "im=bicubic"
region - parent Region in scene

parseInterpolation

protected static Object parseInterpolation(String im)

createClosedShapeDescription

public ClosedShapeDescription createClosedShapeDescription(ClosedShape g,
                                                           String id,
                                                           int zindex,
                                                           Region region,
                                                           boolean sensitivity)
Parameters:
g - any ClosedShape. It must implement fr.inria.zvtm.glyphs.Translucent if fade in/out transitions are used in the parent region.

createGlyphDescription

public fr.inria.zuist.engine.GlyphDescription createGlyphDescription(Glyph g,
                                                                     String id,
                                                                     int zindex,
                                                                     Region region,
                                                                     boolean sensitivity)

parseVertexCoordinates

public static Point2D.Double[] parseVertexCoordinates(String s,
                                                      Point2D.Double orig)

getFontStyle

public static int getFontStyle(String style)

createTextDescription

public TextDescription createTextDescription(double x,
                                             double y,
                                             String id,
                                             int zindex,
                                             Region region,
                                             float scale,
                                             String text,
                                             short anchor,
                                             Color fill,
                                             float alpha,
                                             String family,
                                             int style,
                                             int size,
                                             boolean sensitivity)
Creates a text object and adds it to a region.


enableRegionUpdater

public void enableRegionUpdater(boolean b)

setUpdateLevel

public void setUpdateLevel(boolean b)
Enable/disable level updating. Calls to updateLevel(altitude) have no effect if level updating is disabled.

See Also:
updateLevel(int layerIndex, double[] cameraBounds, double altitude)

getCurrentLevel

public int getCurrentLevel()
Get the current level.

Returns:
index of level at which camera is right now (highest level is 0)

getClosestRegionAtCurrentLevel

public Region getClosestRegionAtCurrentLevel(Point2D.Double lp)
Get region whose center is closest to a given location at the current level.


updateVisibleRegions

public void updateVisibleRegions()
Update visible regions for all cameras.


setFadeInDuration

public void setFadeInDuration(int d)

setFadeOutDuration

public void setFadeOutDuration(int d)

getSpaceByIndex

public VirtualSpace getSpaceByIndex(int layerIndex)

findFarmostRegionCoords

public double[] findFarmostRegionCoords()
Get the bounding box of all regions in this scene.

Returns:
bounds in virtual space

getGlobalView

public double[] getGlobalView(Camera c,
                              int d,
                              EndAction ea)
Get a global view of the scene.

Parameters:
c - camera that should show a global view
d - duration of animation from current location to global view
ea - action to be perfomed after camera has reached its new position (can be null)
Returns:
bounds in virtual space

parseXML

public static Document parseXML(File f)

getAbsoluteURL

public static URL getAbsoluteURL(String src,
                                 File sceneFileDir)

cameraMoved

public void cameraMoved(Camera cam,
                        Point2D.Double loc,
                        double alt)
Description copied from interface: CameraListener
Called back when a Camera is moved. Callback handlers are expected to be thread-safe. Do not perform blocking or time consuming tasks within the handler. It is a bad idea to move the target Camera in a handler (infinite loop). Moving other Cameras is also probably a bad idea. To receive notifications, clients should register themselves using Camera.addListener

Specified by:
cameraMoved in interface CameraListener
Parameters:
cam - camera which was moved
loc - camera xy coordinates after the move
alt - camera altitude after the move
See Also:
Camera.addListener(fr.inria.zvtm.event.CameraListener), Camera.removeListener(fr.inria.zvtm.event.CameraListener)

setDebugMode

public static void setDebugMode(boolean b)

getDebugMode

public static boolean getDebugMode()


Copyright © 2000-2002 Xerox Corporation. All Rights Reserved
Copyright © 2003 World Wide Web Consortium. All Rights Reserved
Copyright © 2004-2011 INRIA. All Rights Reserved
Licensed under the GNU LGPL. For full terms see the file COPYING.