org.jzy3d.plot3d.rendering.view
Class View

java.lang.Object
  extended by org.jzy3d.plot3d.rendering.view.View
Direct Known Subclasses:
ChartView, SelectableView

public class View
extends Object

A View holds a Scene, a LightSet, an ICanvas to render into. It is the responsability to layout a set of concrete AbstractViewportManagers such as the rendering the scene or an AWTImageViewport for displaying an image in the same window. On can control the Camera with a and get notifyed by a IViewPointChangedListener that the view point has changed. The control is relative to the center of the Scene and is defined using polar coordinates. The View supports post rendering through the addition of Renderer2ds whose implementation can define Java2d calls to render on top on OpenGL2. Last, the View offers the ability to get an AxeBox for embedding the Scene and getting values along axes.

Author:
Martin Pernollet

Field Summary
protected  Scene annotations
           
protected  IAxe axe
           
protected  boolean axeBoxDisplayed
           
protected  Color bgColor
           
protected  ViewBoundMode boundmode
           
protected  Camera cam
           
protected  CameraMode cameraMode
           
protected  ICanvas canvas
           
protected  Coord3d center
           
protected  Chart chart
          A view may optionnaly know its parent chart.
protected static View current
           
static Coord3d DEFAULT_VIEW
           
protected  boolean dimensionDirty
           
protected  boolean DISPLAY_AXE_WHOLE_BOUNDS
           
protected  float factorViewPointDistance
          Applies a factor to the default camera distance which is set to the radius of the scene bounds.
protected  javax.media.opengl.glu.GLU glu
           
protected  BoundingBox3d initBounds
           
protected  boolean MAINTAIN_ALL_OBJECTS_IN_VIEW
           
protected  com.jogamp.opengl.util.awt.Overlay overlay
           
protected static float PI_div2
           
protected  Quality quality
           
protected  Coord3d scaling
           
protected  Scene scene
           
protected  boolean slave
          A slave view won't clear its color and depth buffer before rendering
protected  boolean squared
           
static float STRETCH_RATIO
           
protected  BoundingBox3d viewbounds
           
protected  boolean viewDirty
          can be set to true by the Renderer3d so that the View knows it is rendering due to a canvas size change
protected  List<IViewLifecycleEventListener> viewLifecycleListeners
           
protected  ViewPositionMode viewmode
           
protected  List<IViewIsVerticalEventListener> viewOnTopListeners
           
protected  Coord3d viewpoint
           
protected  List<IViewPointChangedListener> viewPointChangedListeners
           
protected  boolean wasOnTopAtLastRendering
           
 
Constructor Summary
View(IChartComponentFactory factory, Scene scene, ICanvas canvas, Quality quality)
          Create a view attached to a Scene, with its own Camera and Axe.
 
Method Summary
 boolean addViewLifecycleChangedListener(IViewLifecycleEventListener listener)
           
 boolean addViewOnTopEventListener(IViewIsVerticalEventListener listener)
           
 boolean addViewPointChangedListener(IViewPointChangedListener listener)
           
 void clear(javax.media.opengl.GL gl)
          Clear the color and depth buffer.
 void clearColorAndDepth(javax.media.opengl.GL gl)
           
 BoundingBox3d computeScaling()
           
 Coord3d computeSceneScaling()
           
protected  void correctCameraPositionForIncludingTextLabels(javax.media.opengl.GL gl, javax.media.opengl.glu.GLU glu, ViewportConfiguration viewport)
           
static View current()
           
 void dispose()
           
protected  void fireViewLifecycleHasInit(ViewLifecycleEvent e)
           
protected  void fireViewLifecycleWillRender(ViewLifecycleEvent e)
           
protected  void fireViewOnTopEvent(boolean isOnTop)
           
protected  void fireViewPointChangedEvent(ViewPointChangedEvent e)
           
 Graph getAnnotations()
           
 IAxe getAxe()
           
 Color getBackgroundColor()
           
 BoundingBox3d getBounds()
          Get the AxeBox's BoundingBox3d
 ViewBoundMode getBoundsMode()
           
 Camera getCamera()
           
 CameraMode getCameraMode()
          Get the projection of this view, either CameraMode.ORTHOGONAL or CameraMode.PERSPECTIVE.
 ICanvas getCanvas()
           
protected  javax.media.opengl.GLAutoDrawable getCanvasAsGLAutoDrawable()
           
 Coord3d getCenter()
          Return the central point of the view scene, that is the last bounding box center set by lookToBox(BoundingBox3d box)
 Chart getChart()
           
 javax.media.opengl.GLContext getCurrentContext()
           
 javax.media.opengl.GL getCurrentGL()
           
 BoundingBox3d getInitBounds()
           
 Coord3d getLastViewScaling()
          Return the last used view scaling that was set according to the setSquared(boolean v) status.
 Scale getScale()
           
 Scene getScene()
           
 Rectangle getSceneViewportRectangle()
           
 boolean getSquared()
           
 ViewPositionMode getViewMode()
          Return the ViewPositionMode applied to this view.
 Coord3d getViewPoint()
          Get the viewpoint.
 void init(javax.media.opengl.GL gl)
          The initialization function: specifies general GL settings that impact the rendering quality and performance (computation speed).
 void initLights(javax.media.opengl.GL gl)
           
 void initQuality(javax.media.opengl.GL gl)
           
 void initResources(javax.media.opengl.GL gl)
           
 boolean isAxeBoxDisplayed()
           
 boolean isSlave()
           
 void lookToBox(BoundingBox3d box)
          Set the surrounding AxeBox dimensions and the Camera target, and the colorbar range.
 void project()
           
 Coord3d projectMouse(int x, int y)
           
 boolean removeViewLifecycleChangedListener(IViewLifecycleEventListener listener)
           
 boolean removeViewOnTopEventListener(IViewIsVerticalEventListener listener)
           
 boolean removeViewPointChangedListener(IViewPointChangedListener listener)
           
 void render(javax.media.opengl.GL gl, javax.media.opengl.glu.GLU glu)
           
 void renderAnnotations(javax.media.opengl.GL gl, javax.media.opengl.glu.GLU glu)
           
 void renderAxeBox(javax.media.opengl.GL gl, javax.media.opengl.glu.GLU glu)
           
 void renderBackground(javax.media.opengl.GL gl, javax.media.opengl.glu.GLU glu2, float f, float g)
           
 void renderBackground(javax.media.opengl.GL gl, javax.media.opengl.glu.GLU glu2, ViewportConfiguration backgroundViewPort)
           
 void renderOverlay(javax.media.opengl.GL gl)
           
 void renderOverlay(javax.media.opengl.GL gl, ViewportConfiguration viewportConfiguration)
           
 void renderScene(javax.media.opengl.GL gl, javax.media.opengl.glu.GLU glu)
           
 void renderScene(javax.media.opengl.GL gl, javax.media.opengl.glu.GLU glu, float left, float right)
           
 void renderScene(javax.media.opengl.GL gl, javax.media.opengl.glu.GLU glu, ViewportConfiguration viewport)
           
 void renderSceneGraph(javax.media.opengl.GL gl, javax.media.opengl.glu.GLU glu)
           
 void renderSceneGraph(javax.media.opengl.GL gl, javax.media.opengl.glu.GLU glu, boolean light)
           
 void rotate(Coord2d move)
          GENERAL DISPLAY CONTROLS
 void rotate(Coord2d move, boolean updateView)
           
 void setAxe(IAxe ax)
           
 void setAxeBoxDisplayed(boolean axeBoxDisplayed)
           
 void setBackgroundColor(Color color)
           
 void setBoundManual(BoundingBox3d bounds)
          Set a manual bounding box and switch the bounding mode to {ViewBoundMode.MANUAL}, meaning that any call to updateBounds() will update view bounds to the current bounds.
 void setBoundMode(ViewBoundMode mode)
          Select between an automatic bounding (that allows fitting the entire scene graph), or a custom bounding.
 void setCameraMode(CameraMode mode)
          Set the projection of this view, either Camera.ORTHOGONAL or Camera.PERSPECTIVE.
 void setChart(Chart chart)
           
 void setInitBounds(BoundingBox3d initBounds)
           
 void setMaximized(boolean status)
           
 void setScale(Scale scale)
           
 void setScale(Scale scale, boolean notify)
           
 void setSlave(boolean slave)
           
 void setSquared(boolean status)
           
 void setViewPoint(Coord3d polar)
          Set the viewpoint and query a view update.
 void setViewPoint(Coord3d polar, boolean updateView)
          Set the viewpoint using polar coordinates relative to the target (i.e.
 void setViewPositionMode(ViewPositionMode mode)
          Set the ViewPositionMode applied to this view.
 void shift(float factor)
           
 void shift(float factor, boolean updateView)
           
 void shoot()
          Current view selection into the mother Scene, and call to target canvas rendering.
protected  Coord3d squarify()
          Return a 3d scaling factor that allows scaling the scene into a square box, according to the current ViewBoundMode.
 void updateBounds()
          Set the bounds of the view according to the current ViewBoundMode , and orders a Camera.shoot().
 void updateBoundsForceUpdate(boolean refresh)
          Update the bounds according to the scene graph whatever is the current ViewBoundMode, and orders a Camera.shoot()
 void updateCamera(javax.media.opengl.GL gl, javax.media.opengl.glu.GLU glu, ViewportConfiguration viewport, BoundingBox3d boundsScaled)
           
 void updateCamera(javax.media.opengl.GL gl, javax.media.opengl.glu.GLU glu, ViewportConfiguration viewport, BoundingBox3d boundsScaled, float sceneRadiusScaled)
           
 void updateQuality(javax.media.opengl.GL gl)
           
 void zoom(float factor)
           
 void zoom(float factor, boolean updateView)
           
 void zoomX(float factor)
           
 void zoomX(float factor, boolean updateView)
           
 void zoomY(float factor)
           
 void zoomY(float factor, boolean updateView)
           
 void zoomZ(float factor)
           
 void zoomZ(float factor, boolean updateView)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

chart

protected Chart chart
A view may optionnaly know its parent chart.


glu

protected javax.media.opengl.glu.GLU glu

STRETCH_RATIO

public static float STRETCH_RATIO

MAINTAIN_ALL_OBJECTS_IN_VIEW

protected boolean MAINTAIN_ALL_OBJECTS_IN_VIEW

DISPLAY_AXE_WHOLE_BOUNDS

protected boolean DISPLAY_AXE_WHOLE_BOUNDS

axeBoxDisplayed

protected boolean axeBoxDisplayed

squared

protected boolean squared

cam

protected Camera cam

axe

protected IAxe axe

quality

protected Quality quality

overlay

protected com.jogamp.opengl.util.awt.Overlay overlay

scene

protected Scene scene

canvas

protected ICanvas canvas

annotations

protected Scene annotations

viewpoint

protected Coord3d viewpoint

center

protected Coord3d center

scaling

protected Coord3d scaling

viewbounds

protected BoundingBox3d viewbounds

cameraMode

protected CameraMode cameraMode

viewmode

protected ViewPositionMode viewmode

boundmode

protected ViewBoundMode boundmode

bgColor

protected Color bgColor

viewPointChangedListeners

protected List<IViewPointChangedListener> viewPointChangedListeners

viewOnTopListeners

protected List<IViewIsVerticalEventListener> viewOnTopListeners

viewLifecycleListeners

protected List<IViewLifecycleEventListener> viewLifecycleListeners

wasOnTopAtLastRendering

protected boolean wasOnTopAtLastRendering

PI_div2

protected static final float PI_div2
See Also:
Constant Field Values

DEFAULT_VIEW

public static final Coord3d DEFAULT_VIEW

dimensionDirty

protected boolean dimensionDirty

viewDirty

protected boolean viewDirty
can be set to true by the Renderer3d so that the View knows it is rendering due to a canvas size change


current

protected static View current

initBounds

protected BoundingBox3d initBounds

factorViewPointDistance

protected float factorViewPointDistance
Applies a factor to the default camera distance which is set to the radius of the scene bounds. Changing this value also change the camera clipping planes.


slave

protected boolean slave
A slave view won't clear its color and depth buffer before rendering

Constructor Detail

View

public View(IChartComponentFactory factory,
            Scene scene,
            ICanvas canvas,
            Quality quality)
Create a view attached to a Scene, with its own Camera and Axe. The initial view point is set at View.DEFAULT_VIEW.

The Quality allows setting the rendering capabilities that are set one time by the init() method.

Method Detail

getChart

public Chart getChart()

setChart

public void setChart(Chart chart)

isSlave

public boolean isSlave()

setSlave

public void setSlave(boolean slave)

dispose

public void dispose()

shoot

public void shoot()
Current view selection into the mother Scene, and call to target canvas rendering.


project

public void project()

projectMouse

public Coord3d projectMouse(int x,
                            int y)

rotate

public void rotate(Coord2d move)
GENERAL DISPLAY CONTROLS


rotate

public void rotate(Coord2d move,
                   boolean updateView)

shift

public void shift(float factor)

shift

public void shift(float factor,
                  boolean updateView)

zoom

public void zoom(float factor)

zoom

public void zoom(float factor,
                 boolean updateView)

zoomX

public void zoomX(float factor)

zoomX

public void zoomX(float factor,
                  boolean updateView)

zoomY

public void zoomY(float factor)

zoomY

public void zoomY(float factor,
                  boolean updateView)

zoomZ

public void zoomZ(float factor)

zoomZ

public void zoomZ(float factor,
                  boolean updateView)

setScale

public void setScale(Scale scale)

setScale

public void setScale(Scale scale,
                     boolean notify)

getScale

public Scale getScale()

lookToBox

public void lookToBox(BoundingBox3d box)
Set the surrounding AxeBox dimensions and the Camera target, and the colorbar range.


getCenter

public Coord3d getCenter()
Return the central point of the view scene, that is the last bounding box center set by lookToBox(BoundingBox3d box)


getBounds

public BoundingBox3d getBounds()
Get the AxeBox's BoundingBox3d


getBoundsMode

public ViewBoundMode getBoundsMode()

setViewPositionMode

public void setViewPositionMode(ViewPositionMode mode)
Set the ViewPositionMode applied to this view.


getViewMode

public ViewPositionMode getViewMode()
Return the ViewPositionMode applied to this view.


setViewPoint

public void setViewPoint(Coord3d polar,
                         boolean updateView)
Set the viewpoint using polar coordinates relative to the target (i.e. the center of the scene). Only X and Y dimensions are required, as the distance to center will be computed automatically by updateCamera().


setViewPoint

public void setViewPoint(Coord3d polar)
Set the viewpoint and query a view update.

See Also:
setViewPoint(Coord3d polar, boolean updateView)}

getViewPoint

public Coord3d getViewPoint()
Get the viewpoint. The Z dimension is the one defined by updateCamera(), which depends on the view scaling.

See Also:
setViewPoint(Coord3d polar, boolean updateView)}

getLastViewScaling

public Coord3d getLastViewScaling()
Return the last used view scaling that was set according to the setSquared(boolean v) status.


setAxe

public void setAxe(IAxe ax)

getAxe

public IAxe getAxe()

getSquared

public boolean getSquared()

setSquared

public void setSquared(boolean status)

isAxeBoxDisplayed

public boolean isAxeBoxDisplayed()

setAxeBoxDisplayed

public void setAxeBoxDisplayed(boolean axeBoxDisplayed)

setBackgroundColor

public void setBackgroundColor(Color color)

getBackgroundColor

public Color getBackgroundColor()

getCamera

public Camera getCamera()

setCameraMode

public void setCameraMode(CameraMode mode)
Set the projection of this view, either Camera.ORTHOGONAL or Camera.PERSPECTIVE.


getCameraMode

public CameraMode getCameraMode()
Get the projection of this view, either CameraMode.ORTHOGONAL or CameraMode.PERSPECTIVE.


setMaximized

public void setMaximized(boolean status)

getScene

public Scene getScene()

getSceneViewportRectangle

public Rectangle getSceneViewportRectangle()

getCanvas

public ICanvas getCanvas()

getAnnotations

public Graph getAnnotations()

addViewOnTopEventListener

public boolean addViewOnTopEventListener(IViewIsVerticalEventListener listener)

removeViewOnTopEventListener

public boolean removeViewOnTopEventListener(IViewIsVerticalEventListener listener)

fireViewOnTopEvent

protected void fireViewOnTopEvent(boolean isOnTop)

addViewPointChangedListener

public boolean addViewPointChangedListener(IViewPointChangedListener listener)

removeViewPointChangedListener

public boolean removeViewPointChangedListener(IViewPointChangedListener listener)

fireViewPointChangedEvent

protected void fireViewPointChangedEvent(ViewPointChangedEvent e)

addViewLifecycleChangedListener

public boolean addViewLifecycleChangedListener(IViewLifecycleEventListener listener)

removeViewLifecycleChangedListener

public boolean removeViewLifecycleChangedListener(IViewLifecycleEventListener listener)

fireViewLifecycleHasInit

protected void fireViewLifecycleHasInit(ViewLifecycleEvent e)

fireViewLifecycleWillRender

protected void fireViewLifecycleWillRender(ViewLifecycleEvent e)

setBoundMode

public void setBoundMode(ViewBoundMode mode)
Select between an automatic bounding (that allows fitting the entire scene graph), or a custom bounding.


updateBounds

public void updateBounds()
Set the bounds of the view according to the current ViewBoundMode , and orders a Camera.shoot().


updateBoundsForceUpdate

public void updateBoundsForceUpdate(boolean refresh)
Update the bounds according to the scene graph whatever is the current ViewBoundMode, and orders a Camera.shoot()


setBoundManual

public void setBoundManual(BoundingBox3d bounds)
Set a manual bounding box and switch the bounding mode to {ViewBoundMode.MANUAL}, meaning that any call to updateBounds() will update view bounds to the current bounds.


squarify

protected Coord3d squarify()
Return a 3d scaling factor that allows scaling the scene into a square box, according to the current ViewBoundMode.

If the scene bounds are Infinite, NaN or zero, for a given dimension, the scaler will be set to 1 on the given dimension.

Returns:
a scaling factor for each dimension.

getCurrentGL

public javax.media.opengl.GL getCurrentGL()

getCurrentContext

public javax.media.opengl.GLContext getCurrentContext()

getCanvasAsGLAutoDrawable

protected javax.media.opengl.GLAutoDrawable getCanvasAsGLAutoDrawable()

init

public void init(javax.media.opengl.GL gl)
The initialization function:

The rendering settings are set by the Quality given in the constructor parameters.


getInitBounds

public BoundingBox3d getInitBounds()

setInitBounds

public void setInitBounds(BoundingBox3d initBounds)

initQuality

public void initQuality(javax.media.opengl.GL gl)

initLights

public void initLights(javax.media.opengl.GL gl)

initResources

public void initResources(javax.media.opengl.GL gl)

clear

public void clear(javax.media.opengl.GL gl)
Clear the color and depth buffer.


clearColorAndDepth

public void clearColorAndDepth(javax.media.opengl.GL gl)

render

public void render(javax.media.opengl.GL gl,
                   javax.media.opengl.glu.GLU glu)

renderBackground

public void renderBackground(javax.media.opengl.GL gl,
                             javax.media.opengl.glu.GLU glu2,
                             float f,
                             float g)

renderBackground

public void renderBackground(javax.media.opengl.GL gl,
                             javax.media.opengl.glu.GLU glu2,
                             ViewportConfiguration backgroundViewPort)

renderScene

public void renderScene(javax.media.opengl.GL gl,
                        javax.media.opengl.glu.GLU glu)

renderScene

public void renderScene(javax.media.opengl.GL gl,
                        javax.media.opengl.glu.GLU glu,
                        float left,
                        float right)

renderScene

public void renderScene(javax.media.opengl.GL gl,
                        javax.media.opengl.glu.GLU glu,
                        ViewportConfiguration viewport)

updateQuality

public void updateQuality(javax.media.opengl.GL gl)

computeScaling

public BoundingBox3d computeScaling()

computeSceneScaling

public Coord3d computeSceneScaling()

updateCamera

public void updateCamera(javax.media.opengl.GL gl,
                         javax.media.opengl.glu.GLU glu,
                         ViewportConfiguration viewport,
                         BoundingBox3d boundsScaled)

updateCamera

public void updateCamera(javax.media.opengl.GL gl,
                         javax.media.opengl.glu.GLU glu,
                         ViewportConfiguration viewport,
                         BoundingBox3d boundsScaled,
                         float sceneRadiusScaled)

renderAxeBox

public void renderAxeBox(javax.media.opengl.GL gl,
                         javax.media.opengl.glu.GLU glu)

renderSceneGraph

public void renderSceneGraph(javax.media.opengl.GL gl,
                             javax.media.opengl.glu.GLU glu)

renderSceneGraph

public void renderSceneGraph(javax.media.opengl.GL gl,
                             javax.media.opengl.glu.GLU glu,
                             boolean light)

renderOverlay

public void renderOverlay(javax.media.opengl.GL gl)

renderOverlay

public void renderOverlay(javax.media.opengl.GL gl,
                          ViewportConfiguration viewportConfiguration)

renderAnnotations

public void renderAnnotations(javax.media.opengl.GL gl,
                              javax.media.opengl.glu.GLU glu)

correctCameraPositionForIncludingTextLabels

protected void correctCameraPositionForIncludingTextLabels(javax.media.opengl.GL gl,
                                                           javax.media.opengl.glu.GLU glu,
                                                           ViewportConfiguration viewport)

current

public static View current()


Copyright © 2013. All rights reserved.