jpview.gui
Class PTMFrame

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by jpview.gui.PTMFrame
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants, PTMWindow

public class PTMFrame
extends javax.swing.JFrame
implements java.awt.event.MouseMotionListener, java.awt.event.ActionListener, java.awt.event.MouseListener, PTMWindow, java.lang.Runnable

The PTMFrame is the container for the canvas. Also, it handles callbacks and fires transforms.

Author:
clyon
See Also:
Serialized Form

Field Summary
 int h
          the height of the frame
static java.lang.Object mutex
          an object for synchronizing threads
 PTMCanvas ptmCanvas
          the canvas displayed in the frame
 int w
          the width of the frame
 
Fields inherited from class javax.swing.JFrame
EXIT_ON_CLOSE
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PTMFrame(java.lang.String name, java.awt.Container c)
          Creates a new PTMFrame instance
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Handles callbacks for the right mouse menu
 void fireTransform()
          exercises the current transform operator on the PTM data
 void forceUpdate()
          force an update for the current tranform - decache and optimizations off
 PTMControls getControls()
          Returns the controls for this frame
 int getExp()
          delegate for PTM getExp() method
 FloatingControls getFloatingControls()
          Returns the floating control panel used by the frame
 float getKDiff()
          delegate for PTM getKDiff()
 float getKSpec()
          delegate for the PTM getKSpec()
 float getLuminance()
          Get the current value for the global ambient term
 PixelTransformOp getPixelTransformOp()
          Returns the PixelTransformOp for this frame
 int getProgress()
          Returns the amount of progress made reading the PTM (doesn't work over the internet)
 PTM getPTM()
          Returns PTM object for this frame
 PTMCanvas getPTMCanvas()
          Returns the canvas for this frame
 int getPTMHeight()
          Returns the height of the current PTM
 int getPTMWidth()
          Returns the width of the current PTM
 void handlePopup(java.awt.event.MouseEvent e)
          used to handle right mouse menu display - this method consumes the event
static void main(java.lang.String[] args)
          Main method for testing
 void mouseClicked(java.awt.event.MouseEvent e)
          Clicking the mouse diplays the right mouse menu on the canvas
 void mouseDragged(java.awt.event.MouseEvent e)
          When the mouse is dragged, the position of the light moves with it
 void mouseEntered(java.awt.event.MouseEvent e)
          not implemented
 void mouseExited(java.awt.event.MouseEvent e)
          not implemented
 void mouseMoved(java.awt.event.MouseEvent e)
          Not implemented (in a previous version, this updated the x-y coordinates in a status bar
 void mousePressed(java.awt.event.MouseEvent e)
          used to handle right mouse display
 void mouseReleased(java.awt.event.MouseEvent e)
          used to handle right mouse menu display
 int mouseX()
          Returns the x value of the current mouse position
 int mouseY()
          Returns the y value of the current mouse position
 void notImplemented()
          Displays a simple dialog for unimplemented features - not used anymore!
 void refreshMap()
          Reload the environment map
 void release()
          Releases all the resources associated with this object
 void run()
          This method is called by the thread that was created in the start method.
 void setBrowser(java.awt.Container c)
          set the parent for this frame
 void setCanvas(PTMCanvas c)
          Sets the PTM Canvas to use for this frame
 void setControls(PTMControls c)
          Sets the PTMControls to use for this frame
 void setEnvironmentMap(EnvironmentMap e)
          set the current environment map
 void setExp(int i)
          Set the value of the exponent in the specular term of the Phong lighting equation for the specular transform operator
 void setKDiff(float f)
          set the value of Kd in the Phong lighting equation for the specular tranform
 void setKSpec(float f)
          Sets the KSpec term in the Phong lighting equation
 void setLuminance(float f)
          Set the current value for the global ambient term
 void setMapBlurType(int i)
          set the blur type for the map (SIMPLE,GAUSSIAN)
 void setMapGuassianBlurSigma(float f)
          set the value of sigma for the gaussian blur procedure
 void setMapKernelSize(int i)
          set the kernel size for the blur
 void setMapSampleSize(int i)
          set the sample size for the environment map
 void setPixelTransformOp(PixelTransformOp pto)
          sets the current transform operator to use when rendering a view
 void setPTM(PTM m)
          Sets the PTM to use for this frame
 void start()
          Starts the animation
 void stop()
          Suspends the animation
 
Methods inherited from class javax.swing.JFrame
getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, update
 
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jpview.gui.PTMWindow
getHeight, getLayeredPane, getWidth
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

w

public int w
the width of the frame


h

public int h
the height of the frame


ptmCanvas

public PTMCanvas ptmCanvas
the canvas displayed in the frame


mutex

public static java.lang.Object mutex
an object for synchronizing threads

Constructor Detail

PTMFrame

public PTMFrame(java.lang.String name,
                java.awt.Container c)
         throws java.io.IOException,
                java.lang.Exception
Creates a new PTMFrame instance

Parameters:
name - the name for the frame
c - the parent container
Throws:
java.io.IOException - if PTM file can't be read
java.lang.Exception - if anything else goes wrong
Method Detail

release

public void release()
Releases all the resources associated with this object


getControls

public PTMControls getControls()
Returns the controls for this frame

Returns:
the ptm controls

getPTM

public PTM getPTM()
Returns PTM object for this frame

Specified by:
getPTM in interface PTMWindow
Returns:
the PTM

getPTMCanvas

public PTMCanvas getPTMCanvas()
Returns the canvas for this frame

Returns:
the ptm canvas

getPixelTransformOp

public PixelTransformOp getPixelTransformOp()
Returns the PixelTransformOp for this frame

Returns:
the PixelTransformOp

setControls

public void setControls(PTMControls c)
Sets the PTMControls to use for this frame

Specified by:
setControls in interface PTMWindow
Parameters:
c - the controls

setPTM

public void setPTM(PTM m)
Sets the PTM to use for this frame

Parameters:
m - the PTM

setCanvas

public void setCanvas(PTMCanvas c)
Sets the PTM Canvas to use for this frame

Parameters:
c - the PTM Canvas

mouseX

public int mouseX()
Returns the x value of the current mouse position

Returns:
the x value of the current mouse position

mouseY

public int mouseY()
Returns the y value of the current mouse position

Returns:
the y value of the current mouse position

getProgress

public int getProgress()
Returns the amount of progress made reading the PTM (doesn't work over the internet)

Returns:
progress so far, 1-100.

getFloatingControls

public FloatingControls getFloatingControls()
Returns the floating control panel used by the frame

Returns:
the floating control panel

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
When the mouse is dragged, the position of the light moves with it

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Parameters:
e - the mouse event

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Not implemented (in a previous version, this updated the x-y coordinates in a status bar

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Parameters:
e - the mouse event

setPixelTransformOp

public void setPixelTransformOp(PixelTransformOp pto)
sets the current transform operator to use when rendering a view

Specified by:
setPixelTransformOp in interface PTMWindow
Parameters:
pto - the transform operator to use

start

public void start()
Starts the animation


stop

public void stop()
Suspends the animation


run

public void run()
This method is called by the thread that was created in the start method. It does the main animation.

Specified by:
run in interface java.lang.Runnable

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Handles callbacks for the right mouse menu

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - the action event

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Clicking the mouse diplays the right mouse menu on the canvas

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
e - the mouse event

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
not implemented

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Parameters:
e - the mouse event

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
not implemented

Specified by:
mouseExited in interface java.awt.event.MouseListener
Parameters:
e - the mouse event

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
used to handle right mouse display

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
e - the mouse event

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
used to handle right mouse menu display

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
e - the mouse event

handlePopup

public void handlePopup(java.awt.event.MouseEvent e)
used to handle right mouse menu display - this method consumes the event

Parameters:
e - the mouse event

fireTransform

public void fireTransform()
exercises the current transform operator on the PTM data

Specified by:
fireTransform in interface PTMWindow

notImplemented

public void notImplemented()
Displays a simple dialog for unimplemented features - not used anymore!


main

public static void main(java.lang.String[] args)
Main method for testing

Parameters:
args - the command line arguments

getExp

public int getExp()
delegate for PTM getExp() method

Specified by:
getExp in interface PTMWindow
Returns:
the current value of the exponent for specular reflection

getKDiff

public float getKDiff()
delegate for PTM getKDiff()

Specified by:
getKDiff in interface PTMWindow
Returns:
the current value Kd the PTM in the Phong lighting equation

getKSpec

public float getKSpec()
delegate for the PTM getKSpec()

Specified by:
getKSpec in interface PTMWindow
Returns:
the current value of KSpec in the Phong equation for the PTM

getPTMHeight

public int getPTMHeight()
Returns the height of the current PTM

Specified by:
getPTMHeight in interface PTMWindow
Returns:
the height of the current PTM

getPTMWidth

public int getPTMWidth()
Returns the width of the current PTM

Specified by:
getPTMWidth in interface PTMWindow
Returns:
the width of the current PTM

setKSpec

public void setKSpec(float f)
Sets the KSpec term in the Phong lighting equation

Specified by:
setKSpec in interface PTMWindow
Parameters:
f - the new value

setKDiff

public void setKDiff(float f)
set the value of Kd in the Phong lighting equation for the specular tranform

Specified by:
setKDiff in interface PTMWindow
Parameters:
f - the new value for Kd

setExp

public void setExp(int i)
Set the value of the exponent in the specular term of the Phong lighting equation for the specular transform operator

Specified by:
setExp in interface PTMWindow
Parameters:
i - the new value for the exponent

getLuminance

public float getLuminance()
Get the current value for the global ambient term

Specified by:
getLuminance in interface PTMWindow
Returns:
the current value

setLuminance

public void setLuminance(float f)
Set the current value for the global ambient term

Specified by:
setLuminance in interface PTMWindow
Parameters:
f - the new value

refreshMap

public void refreshMap()
Reload the environment map

Specified by:
refreshMap in interface PTMWindow

setMapSampleSize

public void setMapSampleSize(int i)
set the sample size for the environment map

Specified by:
setMapSampleSize in interface PTMWindow
Parameters:
i - the sample size

setMapBlurType

public void setMapBlurType(int i)
set the blur type for the map (SIMPLE,GAUSSIAN)

Specified by:
setMapBlurType in interface PTMWindow
Parameters:
i - the blur type

setMapGuassianBlurSigma

public void setMapGuassianBlurSigma(float f)
set the value of sigma for the gaussian blur procedure

Specified by:
setMapGuassianBlurSigma in interface PTMWindow
Parameters:
f - sigma

setMapKernelSize

public void setMapKernelSize(int i)
set the kernel size for the blur

Specified by:
setMapKernelSize in interface PTMWindow
Parameters:
i - the kernel size

forceUpdate

public void forceUpdate()
force an update for the current tranform - decache and optimizations off

Specified by:
forceUpdate in interface PTMWindow

setBrowser

public void setBrowser(java.awt.Container c)
set the parent for this frame

Specified by:
setBrowser in interface PTMWindow
Parameters:
c - the new parent container

setEnvironmentMap

public void setEnvironmentMap(EnvironmentMap e)
set the current environment map

Specified by:
setEnvironmentMap in interface PTMWindow
Parameters:
e - the environment map