GridView
Class Controller

java.lang.Object
  extended by GridView.Controller

public class Controller
extends java.lang.Object

Controller class. This class is the glue between viewer and model (data manager).

Since:
1.0
See Also:
GeomDataManager, Viewer

Field Summary
private  boolean bFileSpecified
          Has the file defining the scene been specified?
private  GeomDataManager mDataManager
          Model instance (manages the data stored).
private  OutputPanel mOutPanel
           
 
Constructor Summary
Controller()
          Class constructor.
 
Method Summary
 void ApplyTransform(float[] coord, float[] outputCoord)
          Transform a point using the current transformation matrix.
 void ConstructArbitRotMatrix(float[] axisDirCosine, float thetaRadian)
          Constructs rotation transformation matrix about an arbitrary axis (using Rodrigues formula) and appends it to the current transformation matrix.
 void ConstructArbitRotMatrix(float[] axisDirCosine, float sine, float cosine)
          Constructs rotation transformation matrix about an arbitrary axis (using Rodrigues formula) and appends it to the current transformation matrix.
 void ConstructOnePtPerspMatrix(float centerProj)
          Constructs a one point perspective transformation matrix from the current transformation matrix.
 void ConstructRotMatrix(Defs.Axis ax, float sine, float cosine)
          Constructs rotation matrix by rotating one of X, Y, or X axes by a given angle.
 void ConstructThreePtPerspMatrix(float center1, float center2, float center3)
          Constructs a three point perspective transformation matrix from the current transformation matrix.
 void ConstructTwoPtPerspMatrix(Defs.Axis ax1, Defs.Axis ax2, float center1, float center2)
          Constructs a two point perspective transformation matrix from the current transformation matrix.
 void CutObject(int x1, int y1, int x2, int y2)
          Cut an object across a cut plane whose physical coordinates have ben specified.
 void DecreaseZoom()
          Decreases the zoom level by a factor of 2.
 boolean DeleteObject(java.lang.String shortFileName)
          Delete the object that was loaded from a specified file.
 void DrawCameraImage(DrawingCanvas canvas, java.awt.Graphics g, float[] camera_coor, float[] center_proj, boolean onlySurface, boolean onlyWireframe)
          Draws the surface model with camera positioned at (X, Y, Z).
 void DrawCrinkleCut(DrawingCanvas canvas, java.awt.Graphics g, float[] plane)
          Draw the face of objects in the scene cut by a specified cutting plane.
 void DrawSurface(DrawingCanvas canvas, java.awt.Graphics g)
          Draw the surface of objects comprising the scene.
 void DrawSurfaceOnly(DrawingCanvas canvas, java.awt.Graphics g)
          Draw only the surface of objects comprising the scene (no edges).
 void DrawWireFrame(DrawingCanvas canvas, java.awt.Graphics g)
          Draw wire frame picture of the scene.
 GeomObject GetCurrZoomedObject()
          Get the object that is currently focused on the screen (was zoomed to most recently).
 GeomDataManager GetGeomDataManager()
          Get the instance of GeomDataManager.
 GeomObject GetObjectFromFileName(java.lang.String shortFileName)
          Get the object that was created from a specified file.
 void IncreaseZoom()
          Increases the zoom level by a factor of 2.
 float MeasureDistance(int x1, int y1, int x2, int y2)
          Measure the distance in physical coordinates between two points whose screen coordinates are known.
 void PanDown(float dist)
          Pan down relative to the current (drawn) image.
 void PanLeft(float dist)
          Pan to left of the currently (drawn) image.
 void PanRight(float dist)
          Pan to right of the currently (drawn) image.
 void PanUp(float dist)
          Pan up relative to the current (drawn) image.
 PlotData<java.lang.Float> PriceOpenFFT(PlotData<java.lang.Float> data)
           
 boolean Read2DPlotFile(java.lang.String fileName, TwoDPlotter<java.lang.Float> plotter, boolean isHistogram)
           
 boolean ReadFinanceDataFile(java.lang.String fileName, TwoDPlotter<java.lang.Float> plotter)
           
 boolean ReadFromDataFile(java.lang.String fileName)
          Read the data from specified file, The format of the file needs to be specified.
 void RegisterProgressBar(javax.swing.JProgressBar progBar)
          Register the progress bar with data manager.
 void RequestZoomToHome()
          Request the view to zoom to original focus for the last loaded object.
 void ResetJavaCoordUserMatrix()
          Resets the java coordinate user-specified transformation matrix.
 void ResetUserDefinedTransMatrix()
          Resets the transformation matrix to unity.
 void ResetViewMatrix()
          Resets the view matrix to identity matrix.
 void SetOutputPanel(OutputPanel outPanel)
          Record the output panel instance, so that error info etc can be dumped onto the panel.
 void TranslateMatrix(float[] moveToPos)
          Constructs transformation matrix by moving the origin to moveToPos and appends it to the current transformation matrix.
 void ZoomInROI(float roiLen, float screenLen, float x0, float y0)
          Zoom into a drawn region of interest (ROI) on the screen.
 void ZoomOutROI(float roiLen, float screenLen, float x0, float y0)
          Zoom out of a drawn region of interest (ROI) on the screen.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mDataManager

private GeomDataManager mDataManager
Model instance (manages the data stored).


bFileSpecified

private boolean bFileSpecified
Has the file defining the scene been specified?


mOutPanel

private OutputPanel mOutPanel
Constructor Detail

Controller

public Controller()
Class constructor. Instantiates the data manager class. An input file needs to be specified from where the geometric data for the scene will be retrieved.

Method Detail

IncreaseZoom

public void IncreaseZoom()
Increases the zoom level by a factor of 2.


DecreaseZoom

public void DecreaseZoom()
Decreases the zoom level by a factor of 2.


RegisterProgressBar

public void RegisterProgressBar(javax.swing.JProgressBar progBar)
Register the progress bar with data manager. Many jobs performed by data manager need to keep track of job status and progress. This function provides a reference to the progress bar to data manager instance.

Parameters:
progBar - Progress bar instance.

GetGeomDataManager

public GeomDataManager GetGeomDataManager()
Get the instance of GeomDataManager.

Returns:
GeomDataManager instance.
See Also:
GeomDataManager

SetOutputPanel

public void SetOutputPanel(OutputPanel outPanel)
Record the output panel instance, so that error info etc can be dumped onto the panel.

Parameters:
outPanel - Instance of OutputPanel used on the main viewer.
See Also:
OutputPanel

DrawWireFrame

public void DrawWireFrame(DrawingCanvas canvas,
                          java.awt.Graphics g)
Draw wire frame picture of the scene. Draws the edges constituting the boundary of objects forming the scene.

Parameters:
canvas - Instance of DrawingCanvas object (needed for converting to screen coordinates).
g - Graphics instance onto which the drawing needs to be done.
See Also:
DrawingCanvas

DrawSurface

public void DrawSurface(DrawingCanvas canvas,
                        java.awt.Graphics g)
Draw the surface of objects comprising the scene.

Parameters:
canvas - Instance of DrawingCanvas object (needed for converting to screen coordinates).
g - Graphics instance onto which the drawing needs to be done.
See Also:
DrawingCanvas

DrawSurfaceOnly

public void DrawSurfaceOnly(DrawingCanvas canvas,
                            java.awt.Graphics g)
Draw only the surface of objects comprising the scene (no edges).

Parameters:
canvas - Instance of DrawingCanvas object (needed for converting to screen coordinates).
g - Graphics instance onto which the drawing needs to be done.
See Also:
DrawingCanvas

DrawCrinkleCut

public void DrawCrinkleCut(DrawingCanvas canvas,
                           java.awt.Graphics g,
                           float[] plane)
Draw the face of objects in the scene cut by a specified cutting plane. Cutting plane is defined as plane[0]*x + plane[1]*y + plane[2]*z + plane[3] = 0;

Parameters:
canvas - Instance of DrawingCanvas object (needed for converting to screen coordinates).
g - Graphics instance onto which the drawing needs to be done.
plane - Coefficients in plane equation (Ax+By+Cz+D=0).
See Also:
DrawingCanvas

ReadFromDataFile

public boolean ReadFromDataFile(java.lang.String fileName)
Read the data from specified file, The format of the file needs to be specified. This function must be called to define the object to be visualized. It is a precursor to most of the visualization routines.

Parameters:
fileName - Name of the file containing object definition.
Returns:
boolean indicating if the file read was successful (true) or not (false).

RequestZoomToHome

public void RequestZoomToHome()
Request the view to zoom to original focus for the last loaded object. After this function, RegenerateImage() and repaint() need to be invoked on DrawingCanvas to zoom to the desired position.

See Also:
DrawingCanvas.RegenerateImage(), DrawingCanvas.paintComponent(java.awt.Graphics)

Read2DPlotFile

public boolean Read2DPlotFile(java.lang.String fileName,
                              TwoDPlotter<java.lang.Float> plotter,
                              boolean isHistogram)

ReadFinanceDataFile

public boolean ReadFinanceDataFile(java.lang.String fileName,
                                   TwoDPlotter<java.lang.Float> plotter)

PriceOpenFFT

public PlotData<java.lang.Float> PriceOpenFFT(PlotData<java.lang.Float> data)

ResetUserDefinedTransMatrix

public void ResetUserDefinedTransMatrix()
Resets the transformation matrix to unity. Relays the request to GeomDataManager.

See Also:
GeomDataManager.ResetUserDefinedTransMatrix()

ResetViewMatrix

public void ResetViewMatrix()
Resets the view matrix to identity matrix.

See Also:
GeomDataManager.mViewMatrix

ResetJavaCoordUserMatrix

public void ResetJavaCoordUserMatrix()
Resets the java coordinate user-specified transformation matrix.

See Also:
GeomDataManager.mJavaCoordUserMatrix

ZoomInROI

public void ZoomInROI(float roiLen,
                      float screenLen,
                      float x0,
                      float y0)
Zoom into a drawn region of interest (ROI) on the screen. Screen is square, and so is ROI to prevent any distortion due to unequal scaling along X and Y axes.

Parameters:
roiLen - Length of region of interest (square)
screenLen - Length of screen
x0 - X Coordinate of upper left corner of ROI
y0 - Y Coordinate of upper left corner of ROI (region of interest).

ZoomOutROI

public void ZoomOutROI(float roiLen,
                       float screenLen,
                       float x0,
                       float y0)
Zoom out of a drawn region of interest (ROI) on the screen. Screen is square, and so is ROI to prevent any distortion due to unequal scaling along X and Y axes.

Parameters:
roiLen - Length of region of interest (square, so width = length)
screenLen - Length of screen
x0 - X Coordinate of upper left corner of ROI
y0 - Y Coordinate of upper left corner of ROI (region of interest).

PanRight

public void PanRight(float dist)
Pan to right of the currently (drawn) image.

Parameters:
dist - Distance by which to transpose.

PanLeft

public void PanLeft(float dist)
Pan to left of the currently (drawn) image.

Parameters:
dist - Distance by which to transpose.

PanDown

public void PanDown(float dist)
Pan down relative to the current (drawn) image.

Parameters:
dist - Distance by which to transpose.

PanUp

public void PanUp(float dist)
Pan up relative to the current (drawn) image.

Parameters:
dist - Distance by which to transpose.

GetCurrZoomedObject

public GeomObject GetCurrZoomedObject()
Get the object that is currently focused on the screen (was zoomed to most recently).

Returns:
GeomObject that was zoomed to last on the screen, or null if no object has been loaded.
See Also:
GeomObject

GetObjectFromFileName

public GeomObject GetObjectFromFileName(java.lang.String shortFileName)
Get the object that was created from a specified file.

Parameters:
shortFileName - Last part of file name, eg: /path/file.gts will have a short file name of file.gts
Returns:
GeomObject instance (first instance found with a matching short file name), null if nothing is found.
See Also:
GeomObject

ApplyTransform

public void ApplyTransform(float[] coord,
                           float[] outputCoord)
Transform a point using the current transformation matrix.

Parameters:
coord - A 3 element array having X, Y, Z coordinates.
outputCoord - A 3 element array containing output transformed coordinates.
See Also:
GeomDataManager.mTransMatrix

TranslateMatrix

public void TranslateMatrix(float[] moveToPos)
Constructs transformation matrix by moving the origin to moveToPos and appends it to the current transformation matrix. Relays the request to GeomDataManager.

Parameters:
moveToPos - X, Y, Z coordinates of the point to translate the origin to.
See Also:
GeomDataManager.TranslateMatrix(float[])

MeasureDistance

public float MeasureDistance(int x1,
                             int y1,
                             int x2,
                             int y2)
Measure the distance in physical coordinates between two points whose screen coordinates are known. Z coordinate of both these points is assumed to be 0 (screen is located at z = 0).

Parameters:
x1 - x coordinate of point 1 (in screen units, i.e. pixels)
y1 - y coordinate of point 1 (in screen units, i.e. pixels)
x2 - x coordinate of point 2 (in screen units, i.e. pixels)
y2 - y coordinate of point 2 (in screen units, i.e. pixels)
Returns:
distance in physical coordinates.

ConstructRotMatrix

public void ConstructRotMatrix(Defs.Axis ax,
                               float sine,
                               float cosine)
Constructs rotation matrix by rotating one of X, Y, or X axes by a given angle.

Parameters:
ax - Axis about which rotation is performed.
sine - sin() of the rotation angle.
cosine - cos of the rotation angle.
See Also:
GeomDataManager.ConstructRotMatrix(Defs.Axis, float, float), Defs.Axis

ConstructArbitRotMatrix

public void ConstructArbitRotMatrix(float[] axisDirCosine,
                                    float thetaRadian)
Constructs rotation transformation matrix about an arbitrary axis (using Rodrigues formula) and appends it to the current transformation matrix. Relays the request to GeomDataManager

Parameters:
axisDirCosine - Direction cosines of the rotation axis.
thetaRadian - Rotation angle in radians.
See Also:
GeomDataManager.ConstructArbitRotMatrix(float[], float, float)

ConstructArbitRotMatrix

public void ConstructArbitRotMatrix(float[] axisDirCosine,
                                    float sine,
                                    float cosine)
Constructs rotation transformation matrix about an arbitrary axis (using Rodrigues formula) and appends it to the current transformation matrix. Relays the request to GeomDataManager

Parameters:
axisDirCosine - Direction cosines of the rotation axis.
sine - sin() of the rotation angle.
cosine - cos() of the rotation angle.
See Also:
GeomDataManager.ConstructArbitRotMatrix(float[], float)

ConstructOnePtPerspMatrix

public void ConstructOnePtPerspMatrix(float centerProj)
Constructs a one point perspective transformation matrix from the current transformation matrix.

The vanishing point is X=0, Y=0, Z=-centerProj. Hence r = -1/centerProj.

Parameters:
centerProj - Center of projection (observer's eye) along the negative Z axis. centerProj is given as a signed quantity. Relays the request to GeomDataManager.
See Also:
GeomDataManager.ConstructOnePtPerspMatrix(float)

ConstructTwoPtPerspMatrix

public void ConstructTwoPtPerspMatrix(Defs.Axis ax1,
                                      Defs.Axis ax2,
                                      float center1,
                                      float center2)
Constructs a two point perspective transformation matrix from the current transformation matrix. The 2 vanishing points are: -center1 along ax1 and -center2 along ax2

Parameters:
ax1 - Axis for center of projection 1 (@see Common.Defs.Axis)
ax2 - Axis for center of projection 2 (@see Common.Defs.Axis)
center1 - Center of projection along ax1.
center2 - Center of projection along ax2. Relays the request to GeomDataManager.
See Also:
GeomDataManager.ConstructTwoPtPerspMatrix(Defs.Axis, Defs.Axis, float, float)

ConstructThreePtPerspMatrix

public void ConstructThreePtPerspMatrix(float center1,
                                        float center2,
                                        float center3)
Constructs a three point perspective transformation matrix from the current transformation matrix. The three vanishing points are -center1 (X axis), -center2 (Y axis), -center3 (Z axis).

Parameters:
center1 - Center of projection along the X axis.
center2 - Center of projection along the Y axis.
center3 - Center of projection along the Z axis. Relays the request to GeomDataManager.
See Also:
GeomDataManager.ConstructThreePtPerspMatrix(float, float, float)

DrawCameraImage

public void DrawCameraImage(DrawingCanvas canvas,
                            java.awt.Graphics g,
                            float[] camera_coor,
                            float[] center_proj,
                            boolean onlySurface,
                            boolean onlyWireframe)
Draws the surface model with camera positioned at (X, Y, Z).


DeleteObject

public boolean DeleteObject(java.lang.String shortFileName)
Delete the object that was loaded from a specified file.

Parameters:
shortFileName - Short name of the file (no path)
Returns:
true if the object was deleted, false otherwise, eg, if the file name did not correspond to any loaded file.

CutObject

public void CutObject(int x1,
                      int y1,
                      int x2,
                      int y2)
Cut an object across a cut plane whose physical coordinates have ben specified. These need to be converted to screen coordinates. Z coordinate of both these points is assumed to be 0 The two points specify the section of cut plane on Z = 0. The cut plane is assumed to be perpendicular to z=0 plane (along XY plane).

Parameters:
x1 - x coordinate of point 1 (in screen units, i.e. pixels)
y1 - y coordinate of point 1 (in screen units, i.e. pixels)
x2 - x coordinate of point 2 (in screen units, i.e. pixels)
y2 - y coordinate of point 2 (in screen units, i.e. pixels)