fr.inria.zvtm.engine
Class Camera

java.lang.Object
  extended by fr.inria.zvtm.engine.Camera

public class Camera
extends Object

a Camera is used to observe the virtual space which owns it - all cameras have unique IDs, as glyph - (x,y) coordinates, observation altitude and focal distance can be changed

Author:
Emmanuel Pietriga

Field Summary
 double altitude
          Altitude of observation (controls zoom factor).
static float DEFAULT_FOCAL
           
protected  double dx
           
protected  double dy
           
protected  double dz
           
 double focal
          Focal distance.
 double vx
          Coordinates in virtual space.
 double vy
          Coordinates in virtual space.
protected  boolean zile
           
protected  double zilX
           
protected  double zilY
           
 
Method Summary
 void addListener(CameraListener listener)
          Registers a CameraListener for this Camera
 void altitudeOffset(double a)
          Set camera altitude (relative value).
 void altitudeOffset(double a, boolean repaint)
          Set camera altitude (relative value).
 void enableCustomZoomInvariantLocation(boolean b)
          Use a specific zoom-invariant point or use the camera's (x,y) coords are used (default).
 double getAltitude()
          get camera altitude
 double[] getBounds()
          Gets the horizontal bounds for this Camera.
 double getFocal()
          get camera focal distance
 int getIndex()
          get camera index (w.r.t owning virtual space)
 boolean getLaziness()
          get camera repaint mode (eager or lazy)
 Location getLocation()
          get camera location
 VirtualSpace getOwningSpace()
          get virtual space owning this camera
 View getOwningView()
          get view owning this camera
 Camera[] getStickedCameraArray()
          return the list of cameras sticked to this camera (null if none)
 Glyph[] getStickedGlyphArray()
          return the list of glyphs sticked to this camera (null if none)
 double getXspeed()
          Get the camera's horizontal speed
 double getYspeed()
          Get the camera's vertical speed
 double getZilX()
          Get zoom-invariant point's x-coordinate in virtual space.
 double getZilY()
          Get zoom-invariant point's y-coordinate in virtual space.
 double getZoomCeiling()
          Get the zoom-out limit/minimum magnification (like a ceiling the camera cannot go through).
 double getZoomFloor()
          get the zoom-in limit/maximum magnification (like a floor the camera cannot go through)
default value 0 means that, at maximum magnification, the size of observed glyphs corresponds to their real size (e.g.
 double getZspeed()
          Get the camera's zooming speed
 boolean isCustomZoomInvariantLocationEnabled()
          Tells whether a specific zoom-invariant point is being used or if the camera's (x,y) coords are used (default).
 boolean isEnabled()
          Tells whether the camera is enabled or disabled.
 void move(double x, double y)
          relative translation (offset) - will trigger a repaint, whereas directly assigning values to vx, vy will not
 void moveTo(double x, double y)
          absolute translation - will trigger a repaint, whereas directly assigning values to vx, vy will not
protected  void notifyMoved()
          Sends a notification to camera listeners currently observing this Camera instance of a camera movement
 void propagateAltitudeChange(double alt)
          Propagate this camera's altitude change to all cameras attached to it.
 void propagateMove(double x, double y)
          Propagate this camera's movement to all glyphs and cameras attached to it.
 void removeListener(CameraListener listener)
          Un-registers a CameraListener for this Camera
 void repaint()
          the content seen through this camera will be repainted in the next owning view's paint loop
 void setAltitude(double a)
          Set camera altitude (absolute value).
 void setAltitude(double a, boolean repaint)
          Set camera altitude (absolute value).
 void setBounds(double[] wnes)
          Sets the horizontal bounds for this Camera.
 void setEnabled(boolean b)
          Enable or disable camera.
 void setFocal(double f)
          set camera focal distance (absolute value)
 void setLaziness(boolean b)
          set eager or lazy mode
 void setLocation(Location l)
          Set camera location
protected  void setOwningSpace(VirtualSpace vs)
          set virtual space owning this camera
 void setOwningView(View vi)
          set view owning this camera.
 void setXspeed(double dx)
          Sets the camera's horizontal speed
 void setYspeed(double dy)
          Sets the camera's vertical speed
 void setZoomCeiling(double a)
          Set a zoom-out limit/minimum magnification (like a ceiling the camera cannot go through)
.
 void setZoomFloor(double a)
          set a zoom-in limit/maximum magnification (like a floor the camera cannot go through)
value 0 means that, at maximum magnification, the size of observed glyphs corresponds to their real size (e.g.
 void setZoomInvariantLocation(double x, double y)
          Set zoom-invariant point's coordinates in virtual space.
 void setZspeed(double dz)
          Sets the camera's zooming speed
protected  boolean shouldRepaint()
           
 void stick(Camera c)
          Attach a camera to this camera.
 void stick(Camera c, boolean stickAlt)
          Attach a camera to this camera.
 void stick(Glyph g)
          attach glyph to this camera
static void stickToCamera(Glyph g, Camera c)
          Stick glyph g to camera c.
 String toString()
          returns a String with ID, position, altitude and focal distance
 void unstick(Camera c)
          detach camera from this camera
 void unstick(Glyph g)
          detach glyph from this camera
 void unstickAllCameras()
          detach all cameras attached to this camera
 void unstickAllGlyphs()
          detach all glyphs attached to this camera
static void unstickAllGlyphs(Camera c)
          Unstick all glyphs sticked to Camera c.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_FOCAL

public static final float DEFAULT_FOCAL
See Also:
Constant Field Values

vx

public double vx
Coordinates in virtual space.


vy

public double vy
Coordinates in virtual space.


altitude

public double altitude
Altitude of observation (controls zoom factor).


focal

public double focal
Focal distance.


dx

protected volatile double dx

dy

protected volatile double dy

dz

protected volatile double dz

zile

protected volatile boolean zile

zilX

protected volatile double zilX

zilY

protected volatile double zilY
Method Detail

setZoomFloor

public void setZoomFloor(double a)
set a zoom-in limit/maximum magnification (like a floor the camera cannot go through)
value 0 means that, at maximum magnification, the size of observed glyphs corresponds to their real size (e.g. if a circle has a declared radius of 50 in the virtual space, then its radius at max magnification is 50)
if the floor is set to a negative value, you will be able to zoom in further (meaning that you will be able to magnify objects beyond their declared size)

Parameters:
a - the altitude of the floor - the default value is 0 (put a negative value if you want to be able to magnify objects beyond their normal size)

getZoomFloor

public double getZoomFloor()
get the zoom-in limit/maximum magnification (like a floor the camera cannot go through)
default value 0 means that, at maximum magnification, the size of observed glyphs corresponds to their real size (e.g. if a circle has a declared radius of 50 in the virtual space, then its radius at max magnification is 50)
if the floor is set to a negative value, you will be able to zoom in further (meaning that you will be able to magnify objects beyond their declared size)


setZoomCeiling

public void setZoomCeiling(double a)
Set a zoom-out limit/minimum magnification (like a ceiling the camera cannot go through)
. Note: if the ceiling is set below the current Camera altitude, the Camera will not be moved automatically. This is up to the application developer.

Parameters:
a - the altitude of the ceiling - the default value is Double.MAX_VALUE

getZoomCeiling

public double getZoomCeiling()
Get the zoom-out limit/minimum magnification (like a ceiling the camera cannot go through). The default value is Double.MAX_VALUE.


setBounds

public void setBounds(double[] wnes)
Sets the horizontal bounds for this Camera. Note: This does not move the Camera if it currently lies outside the bounds.


getBounds

public double[] getBounds()
Gets the horizontal bounds for this Camera.

Returns:
a double array of size 4, containing the {west, north, east, south} borders.

move

public void move(double x,
                 double y)
relative translation (offset) - will trigger a repaint, whereas directly assigning values to vx, vy will not


moveTo

public void moveTo(double x,
                   double y)
absolute translation - will trigger a repaint, whereas directly assigning values to vx, vy will not


setAltitude

public void setAltitude(double a)
Set camera altitude (absolute value). Do not automatically refresh associated view.

Parameters:
a - new altitude value

altitudeOffset

public void altitudeOffset(double a)
Set camera altitude (relative value). Do not automatically refresh associated view.

Parameters:
a - offset value

setAltitude

public void setAltitude(double a,
                        boolean repaint)
Set camera altitude (absolute value).

Parameters:
a - new altitude value
repaint - refresh the associated view or not

altitudeOffset

public void altitudeOffset(double a,
                           boolean repaint)
Set camera altitude (relative value).

Parameters:
a - offset value
repaint - refresh the associated view or not

getAltitude

public double getAltitude()
get camera altitude


setLocation

public void setLocation(Location l)
Set camera location


getLocation

public Location getLocation()
get camera location


setXspeed

public void setXspeed(double dx)
Sets the camera's horizontal speed

Parameters:
dx - camera's x-axis speed
See Also:
setYspeed(double dy), setZspeed(double dz), getXspeed(), getYspeed(), getZspeed()

setYspeed

public void setYspeed(double dy)
Sets the camera's vertical speed

Parameters:
dy - camera's y-axis speed
See Also:
setXspeed(double dx), setZspeed(double dz), getXspeed(), getYspeed(), getZspeed()

setZspeed

public void setZspeed(double dz)
Sets the camera's zooming speed

Parameters:
dz - camera's z-axis speed
See Also:
setXspeed(double dx), setYspeed(double dy), getXspeed(), getYspeed(), getZspeed()

setZoomInvariantLocation

public void setZoomInvariantLocation(double x,
                                     double y)
Set zoom-invariant point's coordinates in virtual space.

See Also:
enableCustomZoomInvariantLocation(boolean b), isCustomZoomInvariantLocationEnabled(), getZilX(), getZilY()

enableCustomZoomInvariantLocation

public void enableCustomZoomInvariantLocation(boolean b)
Use a specific zoom-invariant point or use the camera's (x,y) coords are used (default).

See Also:
setZoomInvariantLocation(double x, double y), isCustomZoomInvariantLocationEnabled(), getZilX(), getZilY()

getZilX

public double getZilX()
Get zoom-invariant point's x-coordinate in virtual space.

See Also:
setZoomInvariantLocation(double x, double y), enableCustomZoomInvariantLocation(boolean b), isCustomZoomInvariantLocationEnabled(), getZilY()

getZilY

public double getZilY()
Get zoom-invariant point's y-coordinate in virtual space.

See Also:
setZoomInvariantLocation(double x, double y), enableCustomZoomInvariantLocation(boolean b), isCustomZoomInvariantLocationEnabled(), getZilX()

isCustomZoomInvariantLocationEnabled

public boolean isCustomZoomInvariantLocationEnabled()
Tells whether a specific zoom-invariant point is being used or if the camera's (x,y) coords are used (default).

See Also:
setZoomInvariantLocation(double x, double y), enableCustomZoomInvariantLocation(boolean b), getZilX(), getZilY()

getXspeed

public double getXspeed()
Get the camera's horizontal speed

See Also:
setXspeed(double dx), setYspeed(double dy), setZspeed(double dz), getYspeed(), getZspeed()

getYspeed

public double getYspeed()
Get the camera's vertical speed

See Also:
setXspeed(double dx), setYspeed(double dy), setZspeed(double dz), getXspeed(), getZspeed()

getZspeed

public double getZspeed()
Get the camera's zooming speed

See Also:
setXspeed(double dx), setYspeed(double dy), setZspeed(double dz), getXspeed(), getYspeed()

addListener

public void addListener(CameraListener listener)
Registers a CameraListener for this Camera


removeListener

public void removeListener(CameraListener listener)
Un-registers a CameraListener for this Camera


notifyMoved

protected void notifyMoved()
Sends a notification to camera listeners currently observing this Camera instance of a camera movement


setFocal

public void setFocal(double f)
set camera focal distance (absolute value)


getFocal

public double getFocal()
get camera focal distance


propagateMove

public void propagateMove(double x,
                          double y)
Propagate this camera's movement to all glyphs and cameras attached to it.


propagateAltitudeChange

public void propagateAltitudeChange(double alt)
Propagate this camera's altitude change to all cameras attached to it.


getIndex

public int getIndex()
get camera index (w.r.t owning virtual space)


setOwningSpace

protected void setOwningSpace(VirtualSpace vs)
set virtual space owning this camera


getOwningSpace

public VirtualSpace getOwningSpace()
get virtual space owning this camera


setOwningView

public void setOwningView(View vi)
set view owning this camera. CALLED INTERNALLY - NOT FOR PUBLIC USE


getOwningView

public View getOwningView()
get view owning this camera


stick

public void stick(Glyph g)
attach glyph to this camera

Parameters:
g - glyph to be attached to this camera
See Also:
unstick(Glyph g), unstickAllGlyphs()

unstick

public void unstick(Glyph g)
detach glyph from this camera

Parameters:
g - glyph to be detached
See Also:
stick(Glyph g), unstickAllGlyphs()

unstickAllGlyphs

public void unstickAllGlyphs()
detach all glyphs attached to this camera

See Also:
unstick(Glyph g), stick(Glyph g)

getStickedGlyphArray

public Glyph[] getStickedGlyphArray()
return the list of glyphs sticked to this camera (null if none)


stick

public void stick(Camera c)
Attach a camera to this camera. Both cameras will have the same location.

Parameters:
c - camera to be attached to this camera
See Also:
unstick(Camera c), unstickAllCameras()

stick

public void stick(Camera c,
                  boolean stickAlt)
Attach a camera to this camera. Both cameras will have the same location.

Parameters:
c - camera to be attached to this camera.
stickAlt - also propagate altitude changes, in addition to translations.
See Also:
unstick(Camera c), unstickAllCameras()

unstick

public void unstick(Camera c)
detach camera from this camera

Parameters:
c - camera to be detached
See Also:
stick(Camera c), unstickAllCameras()

unstickAllCameras

public void unstickAllCameras()
detach all cameras attached to this camera

See Also:
unstick(Camera c), stick(Camera c)

getStickedCameraArray

public Camera[] getStickedCameraArray()
return the list of cameras sticked to this camera (null if none)


setEnabled

public void setEnabled(boolean b)
Enable or disable camera. What is seen through the camera will (or will not) be painted in the View.

See Also:
isEnabled()

isEnabled

public boolean isEnabled()
Tells whether the camera is enabled or disabled.

See Also:
setEnabled(boolean b)

setLaziness

public void setLaziness(boolean b)
set eager or lazy mode

Parameters:
b - true=lazy, false=eager

getLaziness

public boolean getLaziness()
get camera repaint mode (eager or lazy)

Returns:
true=lazy, false=eager

repaint

public void repaint()
the content seen through this camera will be repainted in the next owning view's paint loop


shouldRepaint

protected boolean shouldRepaint()

toString

public String toString()
returns a String with ID, position, altitude and focal distance

Overrides:
toString in class Object

stickToCamera

public static void stickToCamera(Glyph g,
                                 Camera c)
Stick glyph g to camera c. Behaves like a one-way constraint.


unstickAllGlyphs

public static void unstickAllGlyphs(Camera c)
Unstick all glyphs sticked to Camera c.



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.