Class SurfacePaint

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener

    public class SurfacePaint
    extends java.lang.Object
    implements java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private javax.vecmath.Vector3d kPickDirection
      PickDirection, the direction of the PickShape.
      private boolean m_bEnabled
      Enables painting
      private JPanelSurface m_kPanel
      Reference to the JPanelSurface:
      private com.sun.j3d.utils.picking.PickCanvas m_kPickCanvas
      PickCanvas, for triangle picking.
      private int m_PaintMode
      Curent paint mode.
      private int mBrushSize
      current paint brush size
      private javax.swing.JTextField mBrushSizeText
      Paint brush size text field
      private javax.swing.ButtonGroup mButtonGroup
      Button group for paint functions:
      private javax.swing.JColorChooser mColorChooser
      Color Chooser dialog.
      private javax.swing.JButton mColorPaintButton
      Color selection button
      private javax.swing.JToggleButton mDropperButton
      Paint dropper button
      private javax.swing.JButton mEraseAllButton
      Erase all button
      private javax.swing.JToggleButton mEraserButton
      Eraser paint button
      private javax.media.j3d.TransformGroup mMouseRotate
      Rotation transform for transforming the triangle normal into world coordinates.
      private float mOpacity
      Current paint opacity
      private javax.swing.JButton mOpacityPaintButton
      Opacity paint button
      private javax.swing.JToggleButton mPaintBrushButton
      Paint brush button
      private javax.swing.JToggleButton mPaintCanButton
      Paint can button
      private javax.vecmath.Color4f mPaintColor
      Current paint color
      private JDialogPaintGrow mPaintGrowDialog
      Paint Grow Dialog.
      private javax.swing.JToolBar mPaintToolBar
      Paint user-interface ToolBar
      private javax.media.j3d.PickShape mPickShape
      PickShape, for picking
      static int TEXTURE
      Paint into the 3D texture map:
      static int VERTEX
      Paint the ModelTriangleMesh vertex color:
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent event)
      actionPerformed, listens for interface events.
      void dispose()
      Deletes all member variables, clean memory.
      void enableSurfacePaint​(boolean flag)
      Enables/disables the Surface per-vertex paint user-interface
      void enableSurfacePaintCan​(boolean flag)
      Enables/disables the Paint Can user-interface
      boolean getEnabled()
      Returns true if the user has enabled the paint brush.
      private void getModelColor​(javax.vecmath.Point3f kPickPoint)
      Display the ModelImage color in the JDialogPaintGrow interface.
      ModelImage getPaintImage()
      Returns the ModelImage to paint into.
      private com.sun.j3d.utils.picking.PickResult getPickResult​(java.awt.event.MouseEvent kMouseEvent)
      Returns the pick result based on the input mouse event.
      javax.swing.JToolBar getToolBar()  
      private void init()  
      void mouseClicked​(java.awt.event.MouseEvent kMouseEvent)
      One of the overrides necessary to be a MouseListener.
      void mouseDragged​(java.awt.event.MouseEvent kMouseEvent)
      mouseDragged.
      void mouseEntered​(java.awt.event.MouseEvent kMouseEvent)
      One of the overrides necessary to be a MouseListener.
      void mouseExited​(java.awt.event.MouseEvent kMouseEvent)
      One of the overrides necessary to be a MouseListener.
      void mouseMoved​(java.awt.event.MouseEvent kMouseEvent)
      Invoked when the mouse moves.
      void mousePressed​(java.awt.event.MouseEvent kMouseEvent)
      One of the overrides necessary to be a MouseListener.
      void mouseReleased​(java.awt.event.MouseEvent kMouseEvent)
      One of the overrides necessary to be a MouseListener.
      void regionGrow​(ModelImage kImage, javax.vecmath.Point3f kSeedPoint)
      Grows a region based on a starting point supplied.
      void setEnabled​(boolean flag)
      Enables/disables the user-interface
      void setOpacity​(float opacity)
      Sets the opacity of the paint.
      void setPaintMode​(int mode)
      Sets the type of paint, either vertex-color or texture value:
      void setPickCanvas​(com.sun.j3d.utils.picking.PickCanvas kPickCanvas)
      Access function to set the pickCanvas.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • VERTEX

        public static final int VERTEX
        Paint the ModelTriangleMesh vertex color:
        See Also:
        Constant Field Values
      • TEXTURE

        public static final int TEXTURE
        Paint into the 3D texture map:
        See Also:
        Constant Field Values
      • m_PaintMode

        private int m_PaintMode
        Curent paint mode.
      • m_bEnabled

        private boolean m_bEnabled
        Enables painting
      • m_kPickCanvas

        private com.sun.j3d.utils.picking.PickCanvas m_kPickCanvas
        PickCanvas, for triangle picking.
      • mPickShape

        private javax.media.j3d.PickShape mPickShape
        PickShape, for picking
      • kPickDirection

        private javax.vecmath.Vector3d kPickDirection
        PickDirection, the direction of the PickShape.
      • m_kPanel

        private JPanelSurface m_kPanel
        Reference to the JPanelSurface:
      • mPaintToolBar

        private javax.swing.JToolBar mPaintToolBar
        Paint user-interface ToolBar
      • mButtonGroup

        private javax.swing.ButtonGroup mButtonGroup
        Button group for paint functions:
      • mPaintBrushButton

        private javax.swing.JToggleButton mPaintBrushButton
        Paint brush button
      • mDropperButton

        private javax.swing.JToggleButton mDropperButton
        Paint dropper button
      • mPaintCanButton

        private javax.swing.JToggleButton mPaintCanButton
        Paint can button
      • mEraserButton

        private javax.swing.JToggleButton mEraserButton
        Eraser paint button
      • mEraseAllButton

        private javax.swing.JButton mEraseAllButton
        Erase all button
      • mBrushSizeText

        private javax.swing.JTextField mBrushSizeText
        Paint brush size text field
      • mBrushSize

        private int mBrushSize
        current paint brush size
      • mColorPaintButton

        private javax.swing.JButton mColorPaintButton
        Color selection button
      • mPaintColor

        private javax.vecmath.Color4f mPaintColor
        Current paint color
      • mOpacityPaintButton

        private javax.swing.JButton mOpacityPaintButton
        Opacity paint button
      • mOpacity

        private float mOpacity
        Current paint opacity
      • mColorChooser

        private javax.swing.JColorChooser mColorChooser
        Color Chooser dialog.
      • mPaintGrowDialog

        private JDialogPaintGrow mPaintGrowDialog
        Paint Grow Dialog.
      • mMouseRotate

        private javax.media.j3d.TransformGroup mMouseRotate
        Rotation transform for transforming the triangle normal into world coordinates.
    • Method Detail

      • init

        private void init()
      • setEnabled

        public void setEnabled​(boolean flag)
        Enables/disables the user-interface
        Parameters:
        flag - when true the user-interface is enabled, when false the user-interface is disabled.
      • enableSurfacePaintCan

        public void enableSurfacePaintCan​(boolean flag)
        Enables/disables the Paint Can user-interface
        Parameters:
        flag - when true Paint Can is enabled, when false the Paint Can is disabled.
      • enableSurfacePaint

        public void enableSurfacePaint​(boolean flag)
        Enables/disables the Surface per-vertex paint user-interface
        Parameters:
        flag - when true per-vertex paint is enabled, when false the per-vertex paint is disabled is disabled.
      • getEnabled

        public boolean getEnabled()
        Returns true if the user has enabled the paint brush.
        Returns:
        the enabled/disbled status of the paint brush.
      • getPaintImage

        public ModelImage getPaintImage()
        Returns the ModelImage to paint into.
        Returns:
        paint/texture ModelImage
      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent event)
        actionPerformed, listens for interface events.
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
        Parameters:
        event - ActionEvent generated by the interface.
      • getToolBar

        public javax.swing.JToolBar getToolBar()
      • setPaintMode

        public void setPaintMode​(int mode)
        Sets the type of paint, either vertex-color or texture value:
        Parameters:
        mode - SurfacePaint.TEXTURE or SurfacePaint.VERTEX
      • dispose

        public void dispose()
        Deletes all member variables, clean memory.
      • mouseClicked

        public void mouseClicked​(java.awt.event.MouseEvent kMouseEvent)
        One of the overrides necessary to be a MouseListener. This function is invoked when a button has been pressed and released.
        Specified by:
        mouseClicked in interface java.awt.event.MouseListener
        Parameters:
        kMouseEvent - the mouse event generated by a mouse clicked
      • mouseDragged

        public void mouseDragged​(java.awt.event.MouseEvent kMouseEvent)
        mouseDragged.
        Specified by:
        mouseDragged in interface java.awt.event.MouseMotionListener
        Parameters:
        kMouseEvent - MouseEvent
      • mouseEntered

        public void mouseEntered​(java.awt.event.MouseEvent kMouseEvent)
        One of the overrides necessary to be a MouseListener. Invoked when the mouse enters a component.
        Specified by:
        mouseEntered in interface java.awt.event.MouseListener
        Parameters:
        kMouseEvent - the mouse event generated by a mouse entered
      • mouseExited

        public void mouseExited​(java.awt.event.MouseEvent kMouseEvent)
        One of the overrides necessary to be a MouseListener. Invoked when the mouse leaves a component.
        Specified by:
        mouseExited in interface java.awt.event.MouseListener
        Parameters:
        kMouseEvent - the mouse event generated by a mouse exit
      • mouseMoved

        public void mouseMoved​(java.awt.event.MouseEvent kMouseEvent)
        Invoked when the mouse moves.
        Specified by:
        mouseMoved in interface java.awt.event.MouseMotionListener
        Parameters:
        kMouseEvent - MouseEvent
      • mousePressed

        public void mousePressed​(java.awt.event.MouseEvent kMouseEvent)
        One of the overrides necessary to be a MouseListener. Invoked when a mouse button is pressed.
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
        Parameters:
        kMouseEvent - the mouse event generated by a mouse press
      • mouseReleased

        public void mouseReleased​(java.awt.event.MouseEvent kMouseEvent)
        One of the overrides necessary to be a MouseListener. Invoked when a mouse button is released.
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
        Parameters:
        kMouseEvent - the mouse event generated by a mouse release
      • getPickResult

        private com.sun.j3d.utils.picking.PickResult getPickResult​(java.awt.event.MouseEvent kMouseEvent)
        Returns the pick result based on the input mouse event.
        Parameters:
        kMouseEvent - the current mouse position.
        Returns:
        kPickResult, the picked object.
      • setPickCanvas

        public void setPickCanvas​(com.sun.j3d.utils.picking.PickCanvas kPickCanvas)
        Access function to set the pickCanvas.
        Parameters:
        kPickCanvas - PickCanvas
      • setOpacity

        public void setOpacity​(float opacity)
        Sets the opacity of the paint.
        Parameters:
        opacity - paint opacity.
      • getModelColor

        private void getModelColor​(javax.vecmath.Point3f kPickPoint)
        Display the ModelImage color in the JDialogPaintGrow interface.
        Parameters:
        kPickPoint - the model triangle mesh point under the mouse.
      • regionGrow

        public void regionGrow​(ModelImage kImage,
                               javax.vecmath.Point3f kSeedPoint)
        Grows a region based on a starting point supplied. A voxel is added to the the paintMask mask if its intensity is between the the bounds which are also supplied.
        Parameters:
        kImage - the image to grow the region in
        kSeedPoint - the starting point in the image