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:
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.ChangeListenerWindow 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.Window
java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
-
-
Field Summary
Fields Modifier and Type Field Description private intAFTERBefore/After index values for the two displayed spheres, canvases, and display panels:.private intBEFOREBefore/After index values for the two displayed spheres, canvases, and display panels:.private javax.media.j3d.Material[]m_akMaterialPresetPre-defined materialsprivate booleanm_bColorAppliedkeeps track of whether or not color has been applied to surface (for backup on cancel)private floatm_fShininessspecular coefficientprivate intm_iNumPresetPreset Material's examples:.private intm_iSurfaceIndexthe index of the surface that is being changed in the JPanelSurfaceprivate intm_iWhichButtonWhich button is pressed to activate the JColorChooser:.private javax.vecmath.Color3fm_kAmbientCurrent color values:.private javax.swing.JButtonm_kAmbientColorButtonMaterial Properties color buttons:.private javax.swing.JColorChooserm_kColorChooserColor Chooser dialog:.private javax.vecmath.Color3fm_kDiffusediffuse colorprivate javax.swing.JButtonm_kDiffuseColorButtondiffuse color buttonprivate javax.vecmath.Color3fm_kEmissiveemissive colorprivate javax.swing.JButtonm_kEmissiveColorButtonemissive color buttonprivate javax.swing.JSplitPanem_kImagePaneSplit pane for displaying the canvases side-by-side:.private javax.swing.JPanel[]m_kImagePanelCanvas display panels:.private javax.swing.JSplitPanem_kMainPaneSplit pane for displaying the rendered spheres above the interface:.private javax.media.j3d.Materialm_kMaterialNewMaterials for new vales and backup:.private javax.swing.JPanelm_kMaterialPanelWindow display panels: Material properties buttons/slider panel:.private javax.media.j3d.Materialm_kMaterialSaveSaved Material for backupprivate JPanelSurfacem_kParentParent class:.private javax.swing.JSliderm_kShininessSliderShininess slider.private javax.vecmath.Color3fm_kSpecularSpecular color componentprivate javax.swing.JButtonm_kSpecularColorButtonSpecular color buttonprivate static longserialVersionUIDUse serialVersionUID for interoperability.-
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
-
-
Constructor Summary
Constructors Constructor Description JFrameSurfaceMaterialProperties(JPanelSurface kParent, int iSurface, GeneralLight[] akGeneralLights, float fOpacity, javax.media.j3d.Material kMaterial)Creates the Surface Material Editor window.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactionPerformed(java.awt.event.ActionEvent kEvent)Called when a button is pressed:private voidapplyColorChange()Update the color changes to the Before sphere and the original surface.private javax.swing.JPanelbuildPresetPanel()Builds the preset panel to display the preset images and buttons.private javax.media.j3d.Canvas3DcreateCanvas3D()Creates the canvas.private javax.media.j3d.BranchGroupcreateSceneGraph(float fOpacity, javax.media.j3d.Material kMaterial)Creates the rendered spheres, setting the apprearance, material properties, and transparency.voiddispose()Deletes all local data members.private voidinitMaterialPreset()Up to 6 preset materials can be defined.private voidresetColorChange()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 voidsetupInterface()Sets up the user interface.private voidsetupMaterials(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 voidsetupScene(float fOpacity, GeneralLight[] akGeneralLights)Sets up the rendered scenes.voidstateChanged(javax.swing.event.ChangeEvent event)Called when the slider values have changed.voidwindowActivated(java.awt.event.WindowEvent e)windowActivated.voidwindowClosed(java.awt.event.WindowEvent e)windowClosed.voidwindowClosing(java.awt.event.WindowEvent e)windowClosing Catch the windowClosing event so that the local data memebrs can be destroyed.voidwindowDeactivated(java.awt.event.WindowEvent e)windowDeactivated.voidwindowDeiconified(java.awt.event.WindowEvent e)windowDeiconified.voidwindowIconified(java.awt.event.WindowEvent e)windowIconified.voidwindowOpened(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
-
-
-
-
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_kParent
private JPanelSurface m_kParent
Parent class:.
-
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 surfaceiSurface- the opacity of the surfaceakGeneralLights- 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:
actionPerformedin interfacejava.awt.event.ActionListener- Parameters:
kEvent- action event
-
dispose
public void dispose()
Deletes all local data members.- Overrides:
disposein classjava.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:
stateChangedin interfacejavax.swing.event.ChangeListener- Parameters:
event- ChangeEvent state change event.
-
windowActivated
public void windowActivated(java.awt.event.WindowEvent e)
windowActivated.- Specified by:
windowActivatedin interfacejava.awt.event.WindowListener- Parameters:
e- WindowEvent
-
windowClosed
public void windowClosed(java.awt.event.WindowEvent e)
windowClosed.- Specified by:
windowClosedin interfacejava.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:
windowClosingin interfacejava.awt.event.WindowListener- Parameters:
e- WindowEvent
-
windowDeactivated
public void windowDeactivated(java.awt.event.WindowEvent e)
windowDeactivated.- Specified by:
windowDeactivatedin interfacejava.awt.event.WindowListener- Parameters:
e- WindowEvent
-
windowDeiconified
public void windowDeiconified(java.awt.event.WindowEvent e)
windowDeiconified.- Specified by:
windowDeiconifiedin interfacejava.awt.event.WindowListener- Parameters:
e- WindowEvent
-
windowIconified
public void windowIconified(java.awt.event.WindowEvent e)
windowIconified.- Specified by:
windowIconifiedin interfacejava.awt.event.WindowListener- Parameters:
e- WindowEvent
-
windowOpened
public void windowOpened(java.awt.event.WindowEvent e)
windowOpened.- Specified by:
windowOpenedin interfacejava.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 opacitykMaterial- 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 valueakGeneralLights- GeneralLight[] light array
-
-