org.jrabbit.base.managers.window.controllers
Class BaseWindowController

java.lang.Object
  extended by org.jrabbit.base.managers.window.controllers.WindowController
      extended by org.jrabbit.base.managers.window.controllers.BaseWindowController
All Implemented Interfaces:
Createable, DataController, Destroyable, Dimensioned, Viewer, VectorTransform
Direct Known Subclasses:
CanvasWindowController, DesktopWindowController

public abstract class BaseWindowController
extends WindowController

BaseWindowController extends WindowController to provide the default implementations for window operations and handle alerting WindowListeners.

Author:
Chris Molini

Field Summary
protected  int displayHeight
          The height of the available display.
protected  int displayWidth
          The width of the available display.
protected  boolean embedded
          A flag that determines whether or not the view is embedded.
protected  int embedOffsetX
          The stored X value of how to offset the embedded view.
protected  int embedOffsetY
          The stored Y value of how to offset the embedded view.
protected  int fullSceneHeight
          The height of the scene when not embedded.
protected  int fullSceneWidth
          The width of the scene when not embedded.
protected  float sceneMultX
          The amount to multiply the mouse X coordinate for scene coordinate transformation.
protected  float sceneMultY
          The amount to multiply the mouse Y coordinate for scene coordinate transformation.
protected  float sceneOffsetX
          The offset to apply to the mouse X coordinate for scene coordinate transformation.
protected  float sceneOffsetY
          The offset to apply to the mouse Y coordinate for scene coordinate transformation.
 
Fields inherited from class org.jrabbit.base.managers.window.controllers.WindowController
sceneHeight, sceneWidth
 
Constructor Summary
BaseWindowController()
           
 
Method Summary
 void destroy()
          Destroys the Display, wiping the OpenGL context and ending all LWJGL operations.
 boolean embedded()
          Checks the state of the view.
 void resolveEmbedRequest(int sceneWidth, int sceneHeight, int offsetX, int offsetY)
          "Embeds" the active rendering area on the Display.
 void resolveFullscreenRequest(int sceneWidth, int sceneHeight, int resolutionWidth, int resolutionHeight)
          Sets the Display to have the indicated fullscreen settings.
protected  void resolveWindowRequest(int width, int height)
          Sets the Display into a window with the indicated dimensions.
 void setView(int sceneWidth, int sceneHeight, int viewportWidth, int viewportHeight, int viewportX, int viewportY)
          Sets the viewport and scene size, and updates all appropriate settings (mouse transforming, orthogonal view).
 Vector2f transform(BaseVector2f vector)
          Translates coordinates of the LWJGL Mouse into mouse coordinates in relation to the currently rendered scene.
 void unembed()
          Resets embedding settings, making the view take up all of the available screen.
 
Methods inherited from class org.jrabbit.base.managers.window.controllers.WindowController
adjustHeight, adjustWidth, beginRender, embed, embed, endRender, height, isDisplaySetTo, setFullscreen, setFullscreen, setFullscreen, setWindowed, valid, views, width
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jrabbit.base.data.Createable
create
 

Field Detail

fullSceneWidth

protected int fullSceneWidth
The width of the scene when not embedded. This is used to steady embed calls and to make resetting from an embed easier.


fullSceneHeight

protected int fullSceneHeight
The height of the scene when not embedded. This is used to steady embed calls and to make resetting from an embed easier.


sceneOffsetX

protected float sceneOffsetX
The offset to apply to the mouse X coordinate for scene coordinate transformation.


sceneOffsetY

protected float sceneOffsetY
The offset to apply to the mouse Y coordinate for scene coordinate transformation.


sceneMultX

protected float sceneMultX
The amount to multiply the mouse X coordinate for scene coordinate transformation.


sceneMultY

protected float sceneMultY
The amount to multiply the mouse Y coordinate for scene coordinate transformation.


embedded

protected boolean embedded
A flag that determines whether or not the view is embedded.


embedOffsetX

protected int embedOffsetX
The stored X value of how to offset the embedded view.


embedOffsetY

protected int embedOffsetY
The stored Y value of how to offset the embedded view.


displayWidth

protected int displayWidth
The width of the available display.


displayHeight

protected int displayHeight
The height of the available display.

Constructor Detail

BaseWindowController

public BaseWindowController()
Method Detail

destroy

public void destroy()
Destroys the Display, wiping the OpenGL context and ending all LWJGL operations.


resolveFullscreenRequest

public void resolveFullscreenRequest(int sceneWidth,
                                     int sceneHeight,
                                     int resolutionWidth,
                                     int resolutionHeight)
Sets the Display to have the indicated fullscreen settings.

Specified by:
resolveFullscreenRequest in class WindowController
Parameters:
sceneWidth - The width of the scene to render.
sceneHeight - The height of the scene to render.
resolutionWidth - The width of the DisplayMode to use.
resolutionHeight - The height of the DisplayMode to use.

resolveWindowRequest

protected void resolveWindowRequest(int width,
                                    int height)
Sets the Display into a window with the indicated dimensions.

Specified by:
resolveWindowRequest in class WindowController
Parameters:
width - The width of the desired window.
height - The height of the desired window.

resolveEmbedRequest

public void resolveEmbedRequest(int sceneWidth,
                                int sceneHeight,
                                int offsetX,
                                int offsetY)
"Embeds" the active rendering area on the Display. The size of the scene is calculated from "scene" size; the current resolution is immaterial. Therefore, if you have a fullscreen mode rendering a scene, embedding a 600x400 area will result in the same section of the scene being chosen at any resolution. The offset values are from the middle of the screen; supplied 0 to either value will cause the scene to center on that axis. As usual, +X is to the right and +Y is down. NOTE: You shouldn't use this method with a Windowed Display, as its double buffering causes unfortunate behavior.

Specified by:
resolveEmbedRequest in class WindowController
Parameters:
sceneWidth - The width of the sub-scene to render.
sceneHeight - The height of the sub-scene to render.
offsetX - The X offset of the sub-scene to render; this is based on scene size.
offsetY - The Y offset of the sub-scene to render; this is based on scene size.

unembed

public void unembed()
Resets embedding settings, making the view take up all of the available screen. Calling this results in the same scene as before any embed() calls.

Specified by:
unembed in class WindowController

embedded

public boolean embedded()
Checks the state of the view.

Specified by:
embedded in class WindowController
Returns:
Whether or not the Display view is currently embedded.

setView

public void setView(int sceneWidth,
                    int sceneHeight,
                    int viewportWidth,
                    int viewportHeight,
                    int viewportX,
                    int viewportY)
Sets the viewport and scene size, and updates all appropriate settings (mouse transforming, orthogonal view). NOTE: Unlike most other methods, the coordinates for the viewport settings are in OpenGL format. Thus, +Y is up the screen (like cartesian coordinates), the origin is the bottom left, and the size of the viewport is based on the dimensions of the current DisplayMode (not the scene being rendered).

Specified by:
setView in class WindowController
Parameters:
sceneWidth - The new width of the scene.
sceneHeight - The new height of the scene.
viewportWidth - The width of the viewport.
viewportHeight - The height of the viewport.
viewportX - The X offset of the viewport, from the bottom left of the screen.
viewportY - The Y offset of the viewport, from the bottom left of the screen.

transform

public Vector2f transform(BaseVector2f vector)
Translates coordinates of the LWJGL Mouse into mouse coordinates in relation to the currently rendered scene.

Parameters:
vector - The coordinates of the Mouse on the Display.
Returns:
The coordinates of the Mouse in the scene.