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:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrameNested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrameNested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow, Window.TypeNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intBefore/After index values for the two displayed spheres, canvases, and display panels:.private intBefore/After index values for the two displayed spheres, canvases, and display panels:.private javax.media.j3d.Material[]Pre-defined materialsprivate booleankeeps track of whether or not color has been applied to surface (for backup on cancel)private floatspecular coefficientprivate intPreset Material's examples:.private intthe index of the surface that is being changed in the JPanelSurfaceprivate intWhich button is pressed to activate the JColorChooser:.private javax.vecmath.Color3fCurrent color values:.private JButtonMaterial Properties color buttons:.private JColorChooserColor Chooser dialog:.private javax.vecmath.Color3fdiffuse colorprivate JButtondiffuse color buttonprivate javax.vecmath.Color3femissive colorprivate JButtonemissive color buttonprivate JSplitPaneSplit pane for displaying the canvases side-by-side:.private JPanel[]Canvas display panels:.private JSplitPaneSplit pane for displaying the rendered spheres above the interface:.private javax.media.j3d.MaterialMaterials for new vales and backup:.private JPanelWindow display panels: Material properties buttons/slider panel:.private javax.media.j3d.MaterialSaved Material for backupprivate JPanelSurfaceParent class:.private JSliderShininess slider.private javax.vecmath.Color3fSpecular color componentprivate JButtonSpecular color buttonprivate static final longUse serialVersionUID for interoperability.Fields inherited from class javax.swing.JFrame
accessibleContext, rootPane, rootPaneCheckingEnabledFields 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_CURSORFields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE -
Constructor Summary
ConstructorsConstructorDescriptionJFrameSurfaceMaterialProperties(JPanelSurface kParent, int iSurface, GeneralLight[] akGeneralLights, float fOpacity, javax.media.j3d.Material kMaterial) Creates the Surface Material Editor window. -
Method Summary
Modifier and TypeMethodDescriptionvoidactionPerformed(ActionEvent kEvent) Called when a button is pressed:private voidUpdate the color changes to the Before sphere and the original surface.private JPanelBuilds the preset panel to display the preset images and buttons.private javax.media.j3d.Canvas3DCreates 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 voidUp to 6 preset materials can be defined.private voidReset 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 voidSets 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(ChangeEvent event) Called when the slider values have changed.voidwindowActivated.voidwindowClosed.voidwindowClosing Catch the windowClosing event so that the local data memebrs can be destroyed.voidwindowDeactivated.voidwindowDeiconified.voidwindowIconified.voidwindowOpened.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, updateMethods 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, setUndecoratedMethods 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, toFrontMethods 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, validateTreeMethods 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, transferFocusUpCycleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.awt.MenuContainer
getFont, postEvent
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDUse serialVersionUID for interoperability.- See Also:
-
AFTER
private int AFTERBefore/After index values for the two displayed spheres, canvases, and display panels:. -
BEFORE
private int BEFOREBefore/After index values for the two displayed spheres, canvases, and display panels:. -
m_akMaterialPreset
private javax.media.j3d.Material[] m_akMaterialPresetPre-defined materials -
m_fShininess
private float m_fShininessspecular coefficient -
m_iNumPreset
private int m_iNumPresetPreset Material's examples:. -
m_iSurfaceIndex
private int m_iSurfaceIndexthe index of the surface that is being changed in the JPanelSurface -
m_iWhichButton
private int m_iWhichButtonWhich button is pressed to activate the JColorChooser:. -
m_kAmbient
private javax.vecmath.Color3f m_kAmbientCurrent color values:. -
m_kAmbientColorButton
Material Properties color buttons:. -
m_kColorChooser
Color Chooser dialog:. -
m_kDiffuse
private javax.vecmath.Color3f m_kDiffusediffuse color -
m_kDiffuseColorButton
diffuse color button -
m_kEmissive
private javax.vecmath.Color3f m_kEmissiveemissive color -
m_kEmissiveColorButton
emissive color button -
m_kImagePane
Split pane for displaying the canvases side-by-side:. -
m_kImagePanel
Canvas display panels:. -
m_kMainPane
Split pane for displaying the rendered spheres above the interface:. -
m_kMaterialNew
private javax.media.j3d.Material m_kMaterialNewMaterials for new vales and backup:. -
m_kMaterialPanel
Window display panels: Material properties buttons/slider panel:. -
m_kMaterialSave
private javax.media.j3d.Material m_kMaterialSaveSaved Material for backup -
m_kParent
Parent class:. -
m_kShininessSlider
Shininess slider. -
m_kSpecular
private javax.vecmath.Color3f m_kSpecularSpecular color component -
m_kSpecularColorButton
Specular color button -
m_bColorApplied
private boolean m_bColorAppliedkeeps 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 surfaceiSurface- the opacity of the surfaceakGeneralLights- DOCUMENT ME!fOpacity- DOCUMENT ME!kMaterial- the original material properties.
-
-
Method Details
-
actionPerformed
Called when a button is pressed:- Specified by:
actionPerformedin interfaceActionListener- Parameters:
kEvent- action event
-
dispose
public void dispose()Deletes all local data members. -
stateChanged
Called when the slider values have changed. Reads the new shininess values and sets the Material Properties.- Specified by:
stateChangedin interfaceChangeListener- Parameters:
event- ChangeEvent state change event.
-
windowActivated
windowActivated.- Specified by:
windowActivatedin interfaceWindowListener- Parameters:
e- WindowEvent
-
windowClosed
windowClosed.- Specified by:
windowClosedin interfaceWindowListener- Parameters:
e- WindowEvent
-
windowClosing
windowClosing Catch the windowClosing event so that the local data memebrs can be destroyed.- Specified by:
windowClosingin interfaceWindowListener- Parameters:
e- WindowEvent
-
windowDeactivated
windowDeactivated.- Specified by:
windowDeactivatedin interfaceWindowListener- Parameters:
e- WindowEvent
-
windowDeiconified
windowDeiconified.- Specified by:
windowDeiconifiedin interfaceWindowListener- Parameters:
e- WindowEvent
-
windowIconified
windowIconified.- Specified by:
windowIconifiedin interfaceWindowListener- Parameters:
e- WindowEvent
-
windowOpened
windowOpened.- Specified by:
windowOpenedin interfaceWindowListener- Parameters:
e- WindowEvent
-
applyColorChange
private void applyColorChange()Update the color changes to the Before sphere and the original surface. -
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
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
-