Class JFrameSurfaceMaterialProperties

java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
gov.nih.mipav.view.renderer.J3D.surfaceview.JFrameSurfaceMaterialProperties
All Implemented Interfaces:
ActionListener, WindowListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, ChangeListener, RootPaneContainer, WindowConstants

public class JFrameSurfaceMaterialProperties extends JFrame implements WindowListener, ActionListener, 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:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Use serialVersionUID for interoperability.
      See Also:
    • 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 JButton m_kAmbientColorButton
      Material Properties color buttons:.
    • m_kColorChooser

      private JColorChooser m_kColorChooser
      Color Chooser dialog:.
    • m_kDiffuse

      private javax.vecmath.Color3f m_kDiffuse
      diffuse color
    • m_kDiffuseColorButton

      private JButton m_kDiffuseColorButton
      diffuse color button
    • m_kEmissive

      private javax.vecmath.Color3f m_kEmissive
      emissive color
    • m_kEmissiveColorButton

      private JButton m_kEmissiveColorButton
      emissive color button
    • m_kImagePane

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

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

      private 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 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_kParent

      private JPanelSurface m_kParent
      Parent class:.
    • m_kShininessSlider

      private JSlider m_kShininessSlider
      Shininess slider.
    • m_kSpecular

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

      private 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 Details

    • 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 Details

    • actionPerformed

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

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

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

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

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

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

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

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

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

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

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

      private 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