Class ViewToolBarBuilder

java.lang.Object
gov.nih.mipav.view.ViewToolBarBuilder
All Implemented Interfaces:
ActionListener, ItemListener, Serializable, EventListener

public class ViewToolBarBuilder extends Object implements ItemListener, ActionListener, Serializable
Builds the GUI toolbars for the user interface.
See Also:
  • Field Details

    • pressedBorder

      protected static final Border pressedBorder
      A border to use for pressed buttons.
    • etchedBorder

      protected static final Border etchedBorder
      A border used for each toolbar.
    • NUM_BRUSHES_INTERNAL

      public static final int NUM_BRUSHES_INTERNAL
      DOCUMENT ME!
      See Also:
    • USER_BRUSHES

      public static final String USER_BRUSHES
      DOCUMENT ME!
    • borderPaintButton

      public JToggleButton borderPaintButton
      The button used to toggle borders around painted areas.
    • bogusBorderPaintButton

      public JToggleButton bogusBorderPaintButton
      The button used to toggle borders around painted areas.
    • checkerBoardButton

      protected JButton checkerBoardButton
      The button used to enable checker board display of two images.
    • colorPaintButton

      protected JButton colorPaintButton
      The button used to select the color of the paint used.
    • ctButton

      protected JButton ctButton
      The button for presets used only for CT images.
    • scrollButton

      public JCheckBox scrollButton
    • syncImagesIcon

      public JButton syncImagesIcon
    • currentScriptComboBox

      protected JComboBox currentScriptComboBox
      The combo box containing the possible choices for the current script in the script toolbar. Filled with entries from the currently selected "Scripting directory".
    • currentSelectedScript

      protected String currentSelectedScript
      The script currently selected in the scripting toolbar (null if no script is selected).
    • intensitySpinner

      protected JSpinner intensitySpinner
      The spinner for indicating the intensity to fill the image with when commiting paint in an image.
    • opacity

      protected float opacity
      The opacity of the paint, between 0 (transparent) and 1 (opaque). Set from the opacity dialog.
    • paintBox

      protected JComboBox paintBox
      Combo box to hold all of the paint brushes.
    • paintBrushButton

      protected JToggleButton paintBrushButton
      DOCUMENT ME!
    • paintColor

      protected Color paintColor
      The paint color to be used when the user paints in the image.
    • pointerVOIButton

      protected JToggleButton pointerVOIButton
      The button for the "default" mode of the mouse, where clicking in the image shows the intensity of that voxel.
    • regButton

      protected JToggleButton regButton
      The button used to enable the showing of a small portion of image b near the mouse cursor.
    • scriptTable

      protected Hashtable<String,String> scriptTable
      DOCUMENT ME!
    • UI

      protected Object UI
      The class which wants to listen to changes made to this components of the toolbars. May have to be a ActionListener, MouseListener, ChangeListener, or ViewJFrameBase depending on which toolbars are being used in a particular dialog or frame.
    • VOIGroup

      protected ButtonGroup VOIGroup
      A button group for all toggle buttons which change the effect of mouse usage in the image.
    • voiColorButton

      protected ViewToolBarBuilder.VOIColorButton voiColorButton
    • voiUndoButton

      protected JButton voiUndoButton
    • voiRedoButton

      protected JButton voiRedoButton
    • bgVector

      protected Vector<ButtonGroup> bgVector
      Vector to hold all toggle groups for VOI toggle (and custom toggle configurations)
    • intensityStep

      private double intensityStep
      The amount to change the value in the intensity spinner by when the user clicks it.
    • intensityValue

      private double intensityValue
      The current value chosen in the intensity spinner.
    • maxIntensity

      private double maxIntensity
      The maximum value which can be chosen in the intensity spinner.
    • minIntensity

      private double minIntensity
      The minimum value which can be chosen in the intensity spinner.
    • paintBrushNames

      private String[] paintBrushNames
      DOCUMENT ME!
    • popupListener

      private ViewToolBarBuilder.PopupListener popupListener
      DOCUMENT ME!
  • Constructor Details

    • ViewToolBarBuilder

      public ViewToolBarBuilder(Object _UI)
      Sets the UI.
      Parameters:
      _UI - The user interface pointer.
  • Method Details

    • initToolBar

      public static final JToolBar initToolBar()
      Create a blank toolbar and set it up.
      Returns:
      a new toolbar
    • makeSeparator

      public static final JButton makeSeparator()
      Makes a separator for the use in the toolbars - a button with the proper icon.
      Returns:
      The separator.
    • actionPerformed

      public void actionPerformed(ActionEvent e)
      DOCUMENT ME!
      Specified by:
      actionPerformed in interface ActionListener
      Parameters:
      e - DOCUMENT ME!
    • buildBasicLUTToolBar

      public JToolBar buildBasicLUTToolBar()
      Builds a toolbar with just the basic lut buttons on it.
      Returns:
      the basic lut toolbar
    • buildButton

      public final JButton buildButton(String cmd, String tooltip, String iconBase)
      Create a new toolbar button.
      Parameters:
      cmd - the command generated by the button
      tooltip - tooltip for the button
      iconBase - the base of the icon file names (eg - "icon.gif" and "iconroll.gif" would have an "icon" iconBase
      Returns:
      a new button
    • buildButton

      public final JButton buildButton(CustomUIBuilder.UIParams params)
      Creates a JButton using a UIParams parameters
      Parameters:
      params - UIParams (static final variable from CustomUIBuilder)
      Returns:
    • buildGeneralToolBar

      public JToolBar buildGeneralToolBar(int numberOfDimensions, int type)
      Builds the general image toolbar, with buttons for saving the image, the histogram, etc., and a slider for a 3D image.
      Parameters:
      numberOfDimensions - Number of dimensions of the image.
      type - Data type of image (really only care about color vs. the rest).
      Returns:
      The general image toolbar.
    • buildLUTThresholdToolBar

      public JToolBar buildLUTThresholdToolBar()
      Creates the LUT thresholding toolbar.
      Returns:
      the new toolbar
    • buildLUTToolBarBottom

      public JToolBar buildLUTToolBarBottom()
      Builds the LUT toolbar, with buttons for quick-changing the LUT of the image.
      Returns:
      The LUT toolbar.
    • buildLUTToolBarTop

      public JToolBar buildLUTToolBarTop()
      Build the top part of the LUT toolbar.
      Returns:
      the top part of the LUT toolbar
    • buildPaintToolBar

      public JToolBar buildPaintToolBar(int type, int nDim)
      Builds the paint toolbar, with buttons for widths of paint brushes, color chooser, etc.
      Parameters:
      type - Data type of image (really color vs. the rest).
      nDim - The number of dimensions in the image.
      Returns:
      The paint toolbar.
    • buildRGBToolBar

      public JToolBar buildRGBToolBar()
      Creates the RGB histogram toolbar.
      Returns:
      the new toolbar
    • buildScriptToolBar

      public JToolBar buildScriptToolBar(boolean isRecording)
      Builds the script toolbar, for quickly recording and playing back scripts.
      Parameters:
      isRecording - whether we are recording a script
      Returns:
      The script toolbar.
    • buildTextButton

      public final JButton buildTextButton(String text, String toolTip, String action)
      Helper method to build a text button for the toolbar.
      Parameters:
      text - Text for button.
      toolTip - Tool tip to be associated with button.
      action - Action command for button.
      Returns:
      a new text button
    • buildToggleButton

      public final JToggleButton buildToggleButton(String cmd, String tooltip, String iconBase)
      Create a new toolbar togglable button.
      Parameters:
      cmd - the command generated by the button
      tooltip - tooltip for the button
      iconBase - the base of the icon file names (eg - "icon.gif" and "iconroll.gif" would have an "icon" iconBase
      Returns:
      a new togglable button
    • buildToggleButton

      public final JToggleButton buildToggleButton(String cmd, String tooltip, String iconBase, ButtonGroup group)
      Create a new toolbar togglable button.
      Parameters:
      cmd - the command generated by the button
      tooltip - tooltip for the button
      iconBase - the base of the icon file names (eg - "icon.gif" and "iconroll.gif" would have an "icon" iconBase
      group - the button group to add the togglable button to (use null for the VOIGroup)
      Returns:
      a new togglable button
    • buildToggleButton

      public final JToggleButton buildToggleButton(CustomUIBuilder.UIParams params, ButtonGroup group)
      Create a new toolbar togglable button.
      Parameters:
      params - button parameters that include actioncommand, tooltiptext, and iconbase
      group - the button group to add the togglable button to (use null for the VOIGroup)
      Returns:
      a new togglable button
    • buildToggleButton

      public final JToggleButton buildToggleButton(String cmd, int mnemonic, String tooltip, String iconBase, ButtonGroup group)
      Create a new toolbar togglable button.
      Parameters:
      cmd - the command generated by the button
      mnemonic - short-cut mnemonic for this button
      tooltip - tooltip for the button
      iconBase - the base of the icon file names (eg - "icon.gif" and "iconroll.gif" would have an "icon" iconBase
      group - the button group to add the togglable button to
      Returns:
      a new togglable button
    • buildCustomToolBar

      public JToolBar buildCustomToolBar(Vector<CustomUIBuilder.UIParams> paramVector)
    • build3DVOIToolBar

      private JToolBar build3DVOIToolBar(JToolBar VOIToolBar, int numberOfDimensions, int voiIndex)
    • buildVolumeTriPlanarVOIToolBar

      public JToolBar buildVolumeTriPlanarVOIToolBar(int numberOfDimensions, int voiIndex, boolean bTraverseImage, boolean bOpacity, ButtonGroup kGroup)
      Builds the VOI toolbar, with buttons for creating various types of VOIs (elliptical, square, etc.), and for cut and paste operations.
      Returns:
      the VOI toolbar
    • getIntensityPaintName

      public String getIntensityPaintName()
      Accessor that returns the current intensity paint name (that is, the text of the intensity button, 0, 1, etc.).
      Returns:
      Current intensity paint name.
    • getOpacity

      public float getOpacity()
      Accessor that returns the current opacity of the paint.
      Returns:
      Current opacity of the paint.
    • getPaintBrush

      public int getPaintBrush()
      Returns the selected paint brush's index.
      Returns:
      DOCUMENT ME!
    • getPaintBrushName

      public String getPaintBrushName(int index)
      Returns the name of the paintbrush at the given index.
      Parameters:
      index - the index of the paint brush
      Returns:
      the name
    • getPaintColor

      public Color getPaintColor()
      Accessor that returns the current color of the paint.
      Returns:
      Current color of the paint.
    • getPointerButton

      public JToggleButton getPointerButton()
    • getSelectedScriptFileName

      public String getSelectedScriptFileName()
      Returns the full path and file name of the currently selected script file in the scripting toolbar.
      Returns:
      The full path and file name of the currently selected script.
    • getVOIColorButton

      public ViewToolBarBuilder.VOIColorButton getVOIColorButton()
      Returns the VOI Color/properties button
      Returns:
      voi color button
    • getVOIUndoButton

      public JButton getVOIUndoButton()
    • getVOIRedoButton

      public JButton getVOIRedoButton()
    • itemStateChanged

      public void itemStateChanged(ItemEvent event)
      Sets border painted or not painted depending on if the button was selected or deselected. Changes the currently selected script.
      Specified by:
      itemStateChanged in interface ItemListener
      Parameters:
      event - Event that triggered this function.
    • runCurrentScript

      public void runCurrentScript()
      Method to run the script currently selected in the scripting toolbar.
    • setCheckboardButtonEnabled

      public void setCheckboardButtonEnabled(boolean flag)
      Accessor that enables or disables the checkerboard button.
      Parameters:
      flag - true to enable, false to disable.
    • setCTButtonEnabled

      public void setCTButtonEnabled(boolean flag)
      Accessor that enables or disables the CT button.
      Parameters:
      flag - true to enable, false to disable.
    • setIntensityPaintName

      public void setIntensityPaintName(String stringValue)
      Accessor that sets the intensity paint name (that is, the text of the intensity spinner).
      Parameters:
      stringValue - Value to set it to.
    • setOpacity

      public void setOpacity(float op)
      Accessor that sets the opacity of the paint.
      Parameters:
      op - Opacity to set to.
    • setPaintBrush

      public void setPaintBrush(int index)
      Sets the index of the paintBox (to select a different paint brush).
      Parameters:
      index - index of the paint box (brush) to select
    • setPaintBrushButtonSelected

      public void setPaintBrushButtonSelected()
      Accessor that sets the paint brush button to selected.
    • setPaintColor

      public void setPaintColor(Color color)
      Accessor that sets the color of the paint.
      Parameters:
      color - Color to set paint to.
    • setPointerButton

      public void setPointerButton(JToggleButton pointerButton)
    • setPointerSelected

      public void setPointerSelected()
      Accessor that sets the pointer button to selected.
    • setRegButtonEnabled

      public void setRegButtonEnabled(boolean flag)
      Accessor that enables or disables the window region button.
      Parameters:
      flag - true to enable, false to disable.
    • setSpinnerValues

      public void setSpinnerValues(int type)
      Sets the spinner values based on image type.
      Parameters:
      type - Image type (BYTE, FLOAT, ...)
    • setToggleButtonSelected

      public void setToggleButtonSelected(String actionCommand)
      Sets the correct Toggle button to be selected (based on action command).
      Parameters:
      command - String the action command of the VOI Button (easiest)
    • setVOIGroup

      public void setVOIGroup(ButtonGroup newVOIGroup)
    • updateScripts

      public void updateScripts(String dirName)
      Method to update the list of scripts in the scripting toolbar based on the directory name provided. It is assumed that all scripts end with an .sct extension.
      Parameters:
      dirName - The name of the directory containing the scripts
    • getPaintList

      private Integer[] getPaintList()
      DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • refreshPaintBox

      private void refreshPaintBox(boolean doDelete, int indexOfRemoval)
      DOCUMENT ME!
      Parameters:
      doDelete - DOCUMENT ME!
      indexOfRemoval - DOCUMENT ME!