Class JFrameSurfaceMaterialProperties

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.WindowListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ChangeListener, javax.swing.RootPaneContainer, javax.swing.WindowConstants

    public class JFrameSurfaceMaterialProperties
    extends javax.swing.JFrame
    implements java.awt.event.WindowListener, java.awt.event.ActionListener, javax.swing.event.ChangeListener
    Window for setting the surface material properties. The window displays two sample spheres: a "before" and "after" sphere. Both are initialized to the current material properties and transparency of the surface. The user can change the ambient, diffuse, specular, and emmissive colors with a color control dialog. The user can also change the specular coefficient, or "shininess" through a slider interface.

    Pressing the "apply" button the user can see the changes applied to sthe surface. Pressing the "reset" button resets the surface and material properties interface to the original surface parameters. Pressing "OK" applies the changes to the surface and closes the window, Pressing "cancel" resets the changes and closes the window.

    Author:
    Alexandra Bokinsky
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JFrame

        javax.swing.JFrame.AccessibleJFrame
      • Nested classes/interfaces inherited from class java.awt.Frame

        java.awt.Frame.AccessibleAWTFrame
      • Nested classes/interfaces inherited from class java.awt.Window

        java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int AFTER
      Before/After index values for the two displayed spheres, canvases, and display panels:.
      private int BEFORE
      Before/After index values for the two displayed spheres, canvases, and display panels:.
      private javax.media.j3d.Material[] m_akMaterialPreset
      Pre-defined materials
      private boolean m_bColorApplied
      keeps track of whether or not color has been applied to surface (for backup on cancel)
      private float m_fShininess
      specular coefficient
      private int m_iNumPreset
      Preset Material's examples:.
      private int m_iSurfaceIndex
      the index of the surface that is being changed in the JPanelSurface
      private int m_iWhichButton
      Which button is pressed to activate the JColorChooser:.
      private javax.vecmath.Color3f m_kAmbient
      Current color values:.
      private javax.swing.JButton m_kAmbientColorButton
      Material Properties color buttons:.
      private javax.swing.JColorChooser m_kColorChooser
      Color Chooser dialog:.
      private javax.vecmath.Color3f m_kDiffuse
      diffuse color
      private javax.swing.JButton m_kDiffuseColorButton
      diffuse color button
      private javax.vecmath.Color3f m_kEmissive
      emissive color
      private javax.swing.JButton m_kEmissiveColorButton
      emissive color button
      private javax.swing.JSplitPane m_kImagePane
      Split pane for displaying the canvases side-by-side:.
      private javax.swing.JPanel[] m_kImagePanel
      Canvas display panels:.
      private javax.swing.JSplitPane m_kMainPane
      Split pane for displaying the rendered spheres above the interface:.
      private javax.media.j3d.Material m_kMaterialNew
      Materials for new vales and backup:.
      private javax.swing.JPanel m_kMaterialPanel
      Window display panels: Material properties buttons/slider panel:.
      private javax.media.j3d.Material m_kMaterialSave
      Saved Material for backup
      private JPanelSurface m_kParent
      Parent class:.
      private javax.swing.JSlider m_kShininessSlider
      Shininess slider.
      private javax.vecmath.Color3f m_kSpecular
      Specular color component
      private javax.swing.JButton m_kSpecularColorButton
      Specular color button
      private static long serialVersionUID
      Use serialVersionUID for interoperability.
      • Fields inherited from class javax.swing.JFrame

        accessibleContext, rootPane, rootPaneCheckingEnabled
      • 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 java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
      • Fields inherited from interface javax.swing.WindowConstants

        DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent kEvent)
      Called when a button is pressed:
      private void applyColorChange()
      Update the color changes to the Before sphere and the original surface.
      private javax.swing.JPanel buildPresetPanel()
      Builds the preset panel to display the preset images and buttons.
      private javax.media.j3d.Canvas3D createCanvas3D()
      Creates the canvas.
      private javax.media.j3d.BranchGroup createSceneGraph​(float fOpacity, javax.media.j3d.Material kMaterial)
      Creates the rendered spheres, setting the apprearance, material properties, and transparency.
      void dispose()
      Deletes all local data members.
      private void initMaterialPreset()
      Up to 6 preset materials can be defined.
      private void resetColorChange()
      Reset the color changes for the Before sphere and the original surface, based on the original surface material properties, also update the user-interface buttons to the original values.
      private void setupInterface()
      Sets up the user interface.
      private void setupMaterials​(javax.media.j3d.Material kMaterial)
      Reads the current color values from the Material and sets the values for the two spheres displayed in the interface.
      private void setupScene​(float fOpacity, GeneralLight[] akGeneralLights)
      Sets up the rendered scenes.
      void stateChanged​(javax.swing.event.ChangeEvent event)
      Called when the slider values have changed.
      void windowActivated​(java.awt.event.WindowEvent e)
      windowActivated.
      void windowClosed​(java.awt.event.WindowEvent e)
      windowClosed.
      void windowClosing​(java.awt.event.WindowEvent e)
      windowClosing Catch the windowClosing event so that the local data memebrs can be destroyed.
      void windowDeactivated​(java.awt.event.WindowEvent e)
      windowDeactivated.
      void windowDeiconified​(java.awt.event.WindowEvent e)
      windowDeiconified.
      void windowIconified​(java.awt.event.WindowEvent e)
      windowIconified.
      void windowOpened​(java.awt.event.WindowEvent e)
      windowOpened.
      • Methods inherited from class javax.swing.JFrame

        addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
      • Methods inherited from class java.awt.Frame

        addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
      • Methods inherited from class java.awt.Window

        addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, 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, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
      • Methods inherited from class java.awt.Component

        action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, 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, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.awt.MenuContainer

        getFont, postEvent
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        Use serialVersionUID for interoperability.
        See Also:
        Constant Field Values
      • AFTER

        private int AFTER
        Before/After index values for the two displayed spheres, canvases, and display panels:.
      • BEFORE

        private int BEFORE
        Before/After index values for the two displayed spheres, canvases, and display panels:.
      • m_akMaterialPreset

        private javax.media.j3d.Material[] m_akMaterialPreset
        Pre-defined materials
      • m_fShininess

        private float m_fShininess
        specular coefficient
      • m_iNumPreset

        private int m_iNumPreset
        Preset Material's examples:.
      • m_iSurfaceIndex

        private int m_iSurfaceIndex
        the index of the surface that is being changed in the JPanelSurface
      • m_iWhichButton

        private int m_iWhichButton
        Which button is pressed to activate the JColorChooser:.
      • m_kAmbient

        private javax.vecmath.Color3f m_kAmbient
        Current color values:.
      • m_kAmbientColorButton

        private javax.swing.JButton m_kAmbientColorButton
        Material Properties color buttons:.
      • m_kColorChooser

        private javax.swing.JColorChooser m_kColorChooser
        Color Chooser dialog:.
      • m_kDiffuse

        private javax.vecmath.Color3f m_kDiffuse
        diffuse color
      • m_kDiffuseColorButton

        private javax.swing.JButton m_kDiffuseColorButton
        diffuse color button
      • m_kEmissive

        private javax.vecmath.Color3f m_kEmissive
        emissive color
      • m_kEmissiveColorButton

        private javax.swing.JButton m_kEmissiveColorButton
        emissive color button
      • m_kImagePane

        private javax.swing.JSplitPane m_kImagePane
        Split pane for displaying the canvases side-by-side:.
      • m_kImagePanel

        private javax.swing.JPanel[] m_kImagePanel
        Canvas display panels:.
      • m_kMainPane

        private javax.swing.JSplitPane m_kMainPane
        Split pane for displaying the rendered spheres above the interface:.
      • m_kMaterialNew

        private javax.media.j3d.Material m_kMaterialNew
        Materials for new vales and backup:.
      • m_kMaterialPanel

        private javax.swing.JPanel m_kMaterialPanel
        Window display panels: Material properties buttons/slider panel:.
      • m_kMaterialSave

        private javax.media.j3d.Material m_kMaterialSave
        Saved Material for backup
      • m_kShininessSlider

        private javax.swing.JSlider m_kShininessSlider
        Shininess slider.
      • m_kSpecular

        private javax.vecmath.Color3f m_kSpecular
        Specular color component
      • m_kSpecularColorButton

        private javax.swing.JButton m_kSpecularColorButton
        Specular color button
      • m_bColorApplied

        private boolean m_bColorApplied
        keeps track of whether or not color has been applied to surface (for backup on cancel)
    • Constructor Detail

      • JFrameSurfaceMaterialProperties

        public JFrameSurfaceMaterialProperties​(JPanelSurface kParent,
                                               int iSurface,
                                               GeneralLight[] akGeneralLights,
                                               float fOpacity,
                                               javax.media.j3d.Material kMaterial)
        Creates the Surface Material Editor window. The two example spheres are displayed with the same lights, opacity, and material properties as the surface.
        Parameters:
        kParent - the array of lights that are used to light the surface
        iSurface - the opacity of the surface
        akGeneralLights - DOCUMENT ME!
        fOpacity - DOCUMENT ME!
        kMaterial - the original material properties.
    • Method Detail

      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent kEvent)
        Called when a button is pressed:
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
        Parameters:
        kEvent - action event
      • dispose

        public void dispose()
        Deletes all local data members.
        Overrides:
        dispose in class java.awt.Window
      • stateChanged

        public void stateChanged​(javax.swing.event.ChangeEvent event)
        Called when the slider values have changed. Reads the new shininess values and sets the Material Properties.
        Specified by:
        stateChanged in interface javax.swing.event.ChangeListener
        Parameters:
        event - ChangeEvent state change event.
      • windowActivated

        public void windowActivated​(java.awt.event.WindowEvent e)
        windowActivated.
        Specified by:
        windowActivated in interface java.awt.event.WindowListener
        Parameters:
        e - WindowEvent
      • windowClosed

        public void windowClosed​(java.awt.event.WindowEvent e)
        windowClosed.
        Specified by:
        windowClosed in interface java.awt.event.WindowListener
        Parameters:
        e - WindowEvent
      • windowClosing

        public void windowClosing​(java.awt.event.WindowEvent e)
        windowClosing Catch the windowClosing event so that the local data memebrs can be destroyed.
        Specified by:
        windowClosing in interface java.awt.event.WindowListener
        Parameters:
        e - WindowEvent
      • windowDeactivated

        public void windowDeactivated​(java.awt.event.WindowEvent e)
        windowDeactivated.
        Specified by:
        windowDeactivated in interface java.awt.event.WindowListener
        Parameters:
        e - WindowEvent
      • windowDeiconified

        public void windowDeiconified​(java.awt.event.WindowEvent e)
        windowDeiconified.
        Specified by:
        windowDeiconified in interface java.awt.event.WindowListener
        Parameters:
        e - WindowEvent
      • windowIconified

        public void windowIconified​(java.awt.event.WindowEvent e)
        windowIconified.
        Specified by:
        windowIconified in interface java.awt.event.WindowListener
        Parameters:
        e - WindowEvent
      • windowOpened

        public void windowOpened​(java.awt.event.WindowEvent e)
        windowOpened.
        Specified by:
        windowOpened in interface java.awt.event.WindowListener
        Parameters:
        e - WindowEvent
      • applyColorChange

        private void applyColorChange()
        Update the color changes to the Before sphere and the original surface.
      • buildPresetPanel

        private javax.swing.JPanel buildPresetPanel()
        Builds the preset panel to display the preset images and buttons.
        Returns:
        the preset panel to display the preset images and buttons.
      • createCanvas3D

        private javax.media.j3d.Canvas3D createCanvas3D()
        Creates the canvas.
        Returns:
        Canvas3D
      • createSceneGraph

        private javax.media.j3d.BranchGroup createSceneGraph​(float fOpacity,
                                                             javax.media.j3d.Material kMaterial)
        Creates the rendered spheres, setting the apprearance, material properties, and transparency.
        Parameters:
        fOpacity - default opacity
        kMaterial - initial Material
        Returns:
        BranchGroup
      • initMaterialPreset

        private void initMaterialPreset()
        Up to 6 preset materials can be defined.
      • resetColorChange

        private void resetColorChange()
        Reset the color changes for the Before sphere and the original surface, based on the original surface material properties, also update the user-interface buttons to the original values.
      • setupInterface

        private void setupInterface()
        Sets up the user interface. Button and slider.
      • setupMaterials

        private void setupMaterials​(javax.media.j3d.Material kMaterial)
        Reads the current color values from the Material and sets the values for the two spheres displayed in the interface. Saves the original values in case the Reset button is pressed.
        Parameters:
        kMaterial - material reference.
      • setupScene

        private void setupScene​(float fOpacity,
                                GeneralLight[] akGeneralLights)
        Sets up the rendered scenes. Two spheres, each displayed in a separate canvas window with the same lighting, material, and transparency parameters as the original surface. The "Before" sphere only changes when the "Apply" button is presesd, the "After" sphere changes each time one of the color buttons or the shininess slider is changed
        Parameters:
        fOpacity - float opacity value
        akGeneralLights - GeneralLight[] light array