Class MeshDemo

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--MeshDemo

public final class MeshDemo
extends JPanel
implements ActionListener, TreeSelectionListener, KeyListener

The Mesh Demo GUI code.

Author:
Sasmito Adibowo - 1299000029.
See Also:
Serialized Form

Inner Class Summary
private static class MeshDemo.DrawingPanel
           
 
Inner classes inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent, JComponent.IntVector, JComponent.KeyboardBinding, JComponent.KeyboardState
 
Inner classes inherited from class java.awt.Component
Component.AWTTreeLock
 
Field Summary
private  JButton btAbout
          The "About" button.
private  JButton btCameraMoveDown
          Move camera down.
private  JButton btCameraMoveIn
          Move Camera in.
private  JButton btCameraMoveLeft
          Move camera left.
private  JButton btCameraMoveOut
          Move camera out.
private  JButton btCameraMoveRight
          Move camera right.
private  JButton btCameraMoveUp
          Move camera up.
private  JButton btCameraRotateDown
          Rotate Camera down
private  JButton btCameraRotateLeft
          Rotate camera left
private  JButton btCameraRotateRight
          Rotate camera right.
private  JButton btCameraRotateUp
          Rotate camera up
private  JButton btCameraTiltLeft
          Tilt camera left
private  JButton btCameraTiltRight
          Tilt camera right
private  JButton btCoorSysMoveDown
          Move the coorsys down.
private  JButton btCoorSysMoveIn
          Move the CoorSys in.
private  JButton btCoorSysMoveLeft
          Move the CoorSys left.
private  JButton btCoorSysMoveOut
          Move the CoorSys out.
private  JButton btCoorSysMoveRight
          Move the CoorSys right.
private  JButton btCoorSysMoveUp
          Move the CoorSys up.
private  JButton btCoorSysRotateDown
          Rotate the CoorSys down.
private  JButton btCoorSysRotateLeft
          Rotate the CoorSys left.
private  JButton btCoorSysRotateRight
          Rotate the CoorSys right.
private  JButton btCoorSysRotateUp
          Rotate the CoorSys up.
private  JButton btCoorSysTiltLeft
          Tilt the CoorSys left.
private  JButton btCoorSysTiltRight
          Tilt the CoorSys right.
private  JButton btRedraw
          The "Redraw" button.
private  JButton btReload
          The "Reload" button.
private  MeshDemo.DrawingPanel canvas
          The drawing canvas to display rendered images.
private  File curFile
          current file loaded
private  JLabel lbCoorSysRotate
          The "Rotate ..." label.
private  JLabel lbCoorSysTranslate
          The "Translate ..." label
private  JLabel lbCurCoorSysMatrix
          the current coorsys matrix name
private  DefaultListModel lsmCoorSys
          The list model of lstCoorsys
private  JTree lstCoorSys
          The list of available CoorSys
 JMenuItem mnFileOpen
          File|Open menu
private  JPanel pnCamera
          The "Camera" panel.
private  JPanel pnCameraPos
          The "Camera Position" panel
private  JPanel pnCameraView
          The "Camera View" panel
private  JPanel pnCoorSys
          The "CoorSys" panel
private  Renderer renderer
          The renderer object
private  JTabbedPane rightTabs
          The right tab pane
private  JLabel statusBar
          the status bar
private  JTextField tfCameraMoveDelta
          How far should one move be?
private  JTextField tfCameraRotateDelta
          How far should the camera rotates (in degrees).
private  JTextField tfCoorSysMoveDelta
          How far should the coorsys be moved at one click.
private  JTextField tfCoorSysRotateDelta
          The rotation angle.
private  JToolBar toolBar
          The bottom-right button bar.
private  JTextField[] txtCameraVPN
          The camera VPN, [0] = x, [1] = y, [2] = z
private  JTextField[] txtCameraVRP
          The camera VRP, [0] = x, [1] = y, [2] = z
private  JTextField[] txtCameraVUP
          The camera VUP, [0] = x, [1] = y, [2] = z
private  JTextField[][] txtCoorSysMatrix
          The matrix of CoorSys
private  WindowBoundaries windowBoundaries
          The window boundaries
 
Fields inherited from class javax.swing.JPanel
defaultLayout, uiClassID
 
Fields inherited from class javax.swing.JComponent
_bounds, accessibleContext, alignmentX, alignmentY, ANCESTOR_USING_BUFFER, ancestorNotifier, autoscroller, border, changeSupport, clientProperties, flags, HAS_FOCUS, IS_DOUBLE_BUFFERED, IS_OPAQUE, IS_PAINTING_TILE, KEYBOARD_BINDINGS_KEY, listenerList, maximumSize, minimumSize, NEXT_FOCUS, paintImmediatelyClip, paintingChild, preferredSize, readObjectCallbacks, REQUEST_FOCUS_DISABLED, tmpRect, TOOL_TIP_TEXT_KEY, ui, uiClassID, UNDEFINED_CONDITION, vetoableChangeSupport, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
component, containerListener, containerSerializedDataVersion, dispatcher, layoutMgr, maxSize, ncomponents, serialVersionUID
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, assert, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, serialVersionUID, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
 
Constructor Summary
MeshDemo()
          Constructs the object, create child components.
 
Method Summary
 void actionPerformed(ActionEvent e)
          Handles action events by child components.
private  void coorSys_valueChanged()
          Called when the selection in coorsys changes.
private  void displayCoorSys(String name)
          Called to display a coordinate system on the panel.
 void doLoad(Reader r)
          Loads a metafile.
 String getInfo()
          Returns the copyright information.
 void keyPressed(KeyEvent e)
          Responds to keyboard events.
 void keyReleased(KeyEvent e)
           
 void keyTyped(KeyEvent e)
           
private  void layoutComponents()
          Creates and lays out child components.
 void loadCoorSys()
          loads the lstCoorSys list
static void main(String[] args)
          Main function when run as an application.
 void moveCamera(double dx, double dy, double dz)
          Translates the camera.
 void performAbout()
          Displays name and copyright information.
 void performFileOpen()
          Handles file open command.
 void performRedraw()
          Handles redraw command.
 void performReload()
          Handles the Reload command.
 void rotateCameraX(double degs)
          Rotates the camera by the X axis.
 void rotateCameraY(double degs)
          Rotates the camera by the Y axis.
 void rotateCameraZ(double degs)
          Rotates the camera by the Z axis.
 void rotateCoorSysX(String name, double degs)
          Rotates a coordinate system by the X axis.
 void rotateCoorSysY(String name, double degs)
          Rotates a coordinate system by the Y axis.
 void rotateCoorSysZ(String name, double degs)
          Rotates a coordinate system by the Z axis.
 void setStatus(String s)
          Sets the status.
 void translateCoorSys(String name, double dx, double dy, double dz)
          Translates a coordinate system.
 void valueChanged(TreeSelectionEvent e)
           
 
Methods inherited from class javax.swing.JPanel
, getAccessibleContext, getUIClassID, paramString, updateUI, writeObject
 
Methods inherited from class javax.swing.JComponent
_paintImmediately, addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, adjustPaintFlags, alwaysOnTop, bindingForKeyStroke, checkIfChildObscuredBySibling, computeVisibleRect, computeVisibleRect, contains, createToolTip, enableSerialization, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperties, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getFlag, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, keyboardBindings, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paintWithBuffer, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyBindings, processKeyBindingsForAllComponents, processKeyEvent, processMouseMotionEvent, putClientProperty, readObject, rectangleIsObscured, rectangleIsObscuredBySibling, registerKeyboardAction, registerKeyboardAction, registerWithKeyboardManager, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFlag, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPaintingChild, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, shouldDebugGraphics, superProcessMouseMotionEvent, unregisterKeyboardAction, unregisterWithKeyboardManager, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyOrientation, countComponents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getCursorTarget, getLayout, getMouseEventTarget, getWindow, initIDs, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPrint, list, list, locate, minimumSize, nextFocus, paintComponents, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, print, printComponents, printOneComponent, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, remove, remove, removeAll, removeContainerListener, setCursor, setFocusOwner, setLayout, transferFocus, updateCursor, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, constructComponentName, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getIntrinsicCursor, getLocale, getLocation, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getToolkit, getToolkitImpl, getTreeLock, getWindowForObject, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isEnabledImpl, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

curFile

private File curFile
current file loaded

windowBoundaries

private WindowBoundaries windowBoundaries
The window boundaries

renderer

private Renderer renderer
The renderer object

pnCoorSys

private JPanel pnCoorSys
The "CoorSys" panel

mnFileOpen

public JMenuItem mnFileOpen
File|Open menu

txtCoorSysMatrix

private JTextField[][] txtCoorSysMatrix
The matrix of CoorSys

lstCoorSys

private JTree lstCoorSys
The list of available CoorSys

lsmCoorSys

private DefaultListModel lsmCoorSys
The list model of lstCoorsys
See Also:
lstCoorSys

lbCurCoorSysMatrix

private JLabel lbCurCoorSysMatrix
the current coorsys matrix name

tfCoorSysMoveDelta

private JTextField tfCoorSysMoveDelta
How far should the coorsys be moved at one click.

btCoorSysMoveDown

private JButton btCoorSysMoveDown
Move the coorsys down.

btCoorSysMoveUp

private JButton btCoorSysMoveUp
Move the CoorSys up.

btCoorSysMoveLeft

private JButton btCoorSysMoveLeft
Move the CoorSys left.

btCoorSysMoveRight

private JButton btCoorSysMoveRight
Move the CoorSys right.

btCoorSysMoveIn

private JButton btCoorSysMoveIn
Move the CoorSys in.

btCoorSysMoveOut

private JButton btCoorSysMoveOut
Move the CoorSys out.

tfCoorSysRotateDelta

private JTextField tfCoorSysRotateDelta
The rotation angle.

btCoorSysRotateLeft

private JButton btCoorSysRotateLeft
Rotate the CoorSys left.

btCoorSysRotateRight

private JButton btCoorSysRotateRight
Rotate the CoorSys right.

btCoorSysRotateUp

private JButton btCoorSysRotateUp
Rotate the CoorSys up.

btCoorSysRotateDown

private JButton btCoorSysRotateDown
Rotate the CoorSys down.

btCoorSysTiltLeft

private JButton btCoorSysTiltLeft
Tilt the CoorSys left.

btCoorSysTiltRight

private JButton btCoorSysTiltRight
Tilt the CoorSys right.

lbCoorSysTranslate

private JLabel lbCoorSysTranslate
The "Translate ..." label

lbCoorSysRotate

private JLabel lbCoorSysRotate
The "Rotate ..." label.

pnCamera

private JPanel pnCamera
The "Camera" panel.

txtCameraVRP

private JTextField[] txtCameraVRP
The camera VRP, [0] = x, [1] = y, [2] = z

txtCameraVUP

private JTextField[] txtCameraVUP
The camera VUP, [0] = x, [1] = y, [2] = z

txtCameraVPN

private JTextField[] txtCameraVPN
The camera VPN, [0] = x, [1] = y, [2] = z

pnCameraPos

private JPanel pnCameraPos
The "Camera Position" panel

btCameraMoveUp

private JButton btCameraMoveUp
Move camera up.

btCameraMoveDown

private JButton btCameraMoveDown
Move camera down.

btCameraMoveLeft

private JButton btCameraMoveLeft
Move camera left.

btCameraMoveRight

private JButton btCameraMoveRight
Move camera right.

btCameraMoveIn

private JButton btCameraMoveIn
Move Camera in.

btCameraMoveOut

private JButton btCameraMoveOut
Move camera out.

tfCameraMoveDelta

private JTextField tfCameraMoveDelta
How far should one move be?

pnCameraView

private JPanel pnCameraView
The "Camera View" panel

btCameraRotateUp

private JButton btCameraRotateUp
Rotate camera up

btCameraRotateDown

private JButton btCameraRotateDown
Rotate Camera down

btCameraRotateLeft

private JButton btCameraRotateLeft
Rotate camera left

btCameraRotateRight

private JButton btCameraRotateRight
Rotate camera right.

btCameraTiltLeft

private JButton btCameraTiltLeft
Tilt camera left

btCameraTiltRight

private JButton btCameraTiltRight
Tilt camera right

tfCameraRotateDelta

private JTextField tfCameraRotateDelta
How far should the camera rotates (in degrees).

canvas

private MeshDemo.DrawingPanel canvas
The drawing canvas to display rendered images.

rightTabs

private JTabbedPane rightTabs
The right tab pane

statusBar

private JLabel statusBar
the status bar

toolBar

private JToolBar toolBar
The bottom-right button bar.

btRedraw

private JButton btRedraw
The "Redraw" button.

btReload

private JButton btReload
The "Reload" button.

btAbout

private JButton btAbout
The "About" button.
Constructor Detail

MeshDemo

public MeshDemo()
Constructs the object, create child components.
Method Detail

layoutComponents

private void layoutComponents()
Creates and lays out child components.

getInfo

public String getInfo()
Returns the copyright information.

actionPerformed

public void actionPerformed(ActionEvent e)
Handles action events by child components.
Specified by:
actionPerformed in interface ActionListener

valueChanged

public void valueChanged(TreeSelectionEvent e)
Specified by:
valueChanged in interface TreeSelectionListener

keyPressed

public void keyPressed(KeyEvent e)
Responds to keyboard events.
Specified by:
keyPressed in interface KeyListener

keyReleased

public void keyReleased(KeyEvent e)
Specified by:
keyReleased in interface KeyListener

keyTyped

public void keyTyped(KeyEvent e)
Specified by:
keyTyped in interface KeyListener

coorSys_valueChanged

private void coorSys_valueChanged()
Called when the selection in coorsys changes.

displayCoorSys

private void displayCoorSys(String name)
Called to display a coordinate system on the panel.
Parameters:
name - the name of the coordinate system.

performFileOpen

public void performFileOpen()
Handles file open command.

performRedraw

public void performRedraw()
Handles redraw command.

performReload

public void performReload()
Handles the Reload command.

performAbout

public void performAbout()
Displays name and copyright information.

moveCamera

public void moveCamera(double dx,
                       double dy,
                       double dz)
Translates the camera.
Parameters:
dx - x-delta.
dy - y-delta.
dz - z-delta.

rotateCameraX

public void rotateCameraX(double degs)
Rotates the camera by the X axis.
Parameters:
degs - the rotation angle, in degrees.

rotateCameraY

public void rotateCameraY(double degs)
Rotates the camera by the Y axis.
Parameters:
degs - the rotation angle, in degrees.

rotateCameraZ

public void rotateCameraZ(double degs)
Rotates the camera by the Z axis.
Parameters:
degs - the rotation angle, in degrees.

translateCoorSys

public void translateCoorSys(String name,
                             double dx,
                             double dy,
                             double dz)
Translates a coordinate system. Does nothing if the coordinate system specified cannot be found.
Parameters:
name - the coordinate system name.
dx - x-delta.
dy - y-delta.
dz - z-delta.

rotateCoorSysX

public void rotateCoorSysX(String name,
                           double degs)
Rotates a coordinate system by the X axis. Does nothing if the coordinate system specified cannot be found.
Parameters:
name - the coordinate system name.
degs - the rotation angle, in degrees.

rotateCoorSysY

public void rotateCoorSysY(String name,
                           double degs)
Rotates a coordinate system by the Y axis. Does nothing if the coordinate system specified cannot be found.
Parameters:
name - the coordinate system name.
degs - the rotation angle, in degrees.

rotateCoorSysZ

public void rotateCoorSysZ(String name,
                           double degs)
Rotates a coordinate system by the Z axis. Does nothing if the coordinate system specified cannot be found.
Parameters:
name - the coordinate system name.
degs - the rotation angle, in degrees.

doLoad

public void doLoad(Reader r)
            throws IOException
Loads a metafile.
Parameters:
r - stream input for the metafile.

setStatus

public void setStatus(String s)
Sets the status.
Parameters:
s - status

loadCoorSys

public void loadCoorSys()
loads the lstCoorSys list

main

public static void main(String[] args)
                 throws IOException
Main function when run as an application.
Parameters:
args - command-line arguments.