Package gov.nih.mipav.view
Class ViewToolBarBuilder
- java.lang.Object
-
- gov.nih.mipav.view.ViewToolBarBuilder
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.ItemListener
,java.io.Serializable
,java.util.EventListener
public class ViewToolBarBuilder extends java.lang.Object implements java.awt.event.ItemListener, java.awt.event.ActionListener, java.io.Serializable
Builds the GUI toolbars for the user interface.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ViewToolBarBuilder.JScriptToolBar
Class used to indicate on the toolbar whether a script is being recorded.(package private) class
ViewToolBarBuilder.PaintBoxRenderer
DOCUMENT ME!private class
ViewToolBarBuilder.PopupListener
DOCUMENT ME!class
ViewToolBarBuilder.VOIColorButton
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Vector<javax.swing.ButtonGroup>
bgVector
Vector to hold all toggle groups for VOI toggle (and custom toggle configurations)javax.swing.JToggleButton
bogusBorderPaintButton
The button used to toggle borders around painted areas.javax.swing.JToggleButton
borderPaintButton
The button used to toggle borders around painted areas.protected javax.swing.JButton
checkerBoardButton
The button used to enable checker board display of two images.protected javax.swing.JButton
colorPaintButton
The button used to select the color of the paint used.protected javax.swing.JButton
ctButton
The button for presets used only for CT images.protected javax.swing.JComboBox
currentScriptComboBox
The combo box containing the possible choices for the current script in the script toolbar.protected java.lang.String
currentSelectedScript
The script currently selected in the scripting toolbar (null if no script is selected).protected static javax.swing.border.Border
etchedBorder
A border used for each toolbar.protected javax.swing.JSpinner
intensitySpinner
The spinner for indicating the intensity to fill the image with when commiting paint in an image.private double
intensityStep
The amount to change the value in the intensity spinner by when the user clicks it.private double
intensityValue
The current value chosen in the intensity spinner.private double
maxIntensity
The maximum value which can be chosen in the intensity spinner.private double
minIntensity
The minimum value which can be chosen in the intensity spinner.static int
NUM_BRUSHES_INTERNAL
DOCUMENT ME!protected float
opacity
The opacity of the paint, between 0 (transparent) and 1 (opaque).protected javax.swing.JComboBox
paintBox
Combo box to hold all of the paint brushes.protected javax.swing.JToggleButton
paintBrushButton
DOCUMENT ME!private java.lang.String[]
paintBrushNames
DOCUMENT ME!protected java.awt.Color
paintColor
The paint color to be used when the user paints in the image.protected javax.swing.JToggleButton
pointerVOIButton
The button for the "default" mode of the mouse, where clicking in the image shows the intensity of that voxel.private javax.swing.JPopupMenu
popup
DOCUMENT ME!private ViewToolBarBuilder.PopupListener
popupListener
DOCUMENT ME!protected static javax.swing.border.Border
pressedBorder
A border to use for pressed buttons.protected javax.swing.JToggleButton
regButton
The button used to enable the showing of a small portion of image b near the mouse cursor.protected java.util.Hashtable<java.lang.String,java.lang.String>
scriptTable
DOCUMENT ME!javax.swing.JCheckBox
scrollButton
javax.swing.JButton
syncImagesIcon
protected java.lang.Object
UI
The class which wants to listen to changes made to this components of the toolbars.static java.lang.String
USER_BRUSHES
DOCUMENT ME!protected ViewToolBarBuilder.VOIColorButton
voiColorButton
protected javax.swing.ButtonGroup
VOIGroup
A button group for all toggle buttons which change the effect of mouse usage in the image.protected javax.swing.JButton
voiRedoButton
protected javax.swing.JButton
voiUndoButton
-
Constructor Summary
Constructors Constructor Description ViewToolBarBuilder(java.lang.Object _UI)
Sets the UI.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent e)
DOCUMENT ME!private javax.swing.JToolBar
build3DVOIToolBar(javax.swing.JToolBar VOIToolBar, int numberOfDimensions, int voiIndex)
javax.swing.JToolBar
buildBasicLUTToolBar()
Builds a toolbar with just the basic lut buttons on it.javax.swing.JButton
buildButton(CustomUIBuilder.UIParams params)
Creates a JButton using a UIParams parametersjavax.swing.JButton
buildButton(java.lang.String cmd, java.lang.String tooltip, java.lang.String iconBase)
Create a new toolbar button.javax.swing.JToolBar
buildCustomToolBar(java.util.Vector<CustomUIBuilder.UIParams> paramVector)
javax.swing.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.javax.swing.JToolBar
buildLUTThresholdToolBar()
Creates the LUT thresholding toolbar.javax.swing.JToolBar
buildLUTToolBarBottom()
Builds the LUT toolbar, with buttons for quick-changing the LUT of the image.javax.swing.JToolBar
buildLUTToolBarTop()
Build the top part of the LUT toolbar.javax.swing.JToolBar
buildPaintToolBar(int type, int nDim)
Builds the paint toolbar, with buttons for widths of paint brushes, color chooser, etc.javax.swing.JToolBar
buildRGBToolBar()
Creates the RGB histogram toolbar.javax.swing.JToolBar
buildScriptToolBar(boolean isRecording)
Builds the script toolbar, for quickly recording and playing back scripts.javax.swing.JButton
buildTextButton(java.lang.String text, java.lang.String toolTip, java.lang.String action)
Helper method to build a text button for the toolbar.javax.swing.JToggleButton
buildToggleButton(CustomUIBuilder.UIParams params, javax.swing.ButtonGroup group)
Create a new toolbar togglable button.javax.swing.JToggleButton
buildToggleButton(java.lang.String cmd, int mnemonic, java.lang.String tooltip, java.lang.String iconBase, javax.swing.ButtonGroup group)
Create a new toolbar togglable button.javax.swing.JToggleButton
buildToggleButton(java.lang.String cmd, java.lang.String tooltip, java.lang.String iconBase)
Create a new toolbar togglable button.javax.swing.JToggleButton
buildToggleButton(java.lang.String cmd, java.lang.String tooltip, java.lang.String iconBase, javax.swing.ButtonGroup group)
Create a new toolbar togglable button.javax.swing.JToolBar
buildVolumeTriPlanarVOIToolBar(int numberOfDimensions, int voiIndex, boolean bTraverseImage, boolean bOpacity, javax.swing.ButtonGroup kGroup)
Builds the VOI toolbar, with buttons for creating various types of VOIs (elliptical, square, etc.), and for cut and paste operations.java.lang.String
getIntensityPaintName()
Accessor that returns the current intensity paint name (that is, the text of the intensity button, 0, 1, etc.).float
getOpacity()
Accessor that returns the current opacity of the paint.int
getPaintBrush()
Returns the selected paint brush's index.java.lang.String
getPaintBrushName(int index)
Returns the name of the paintbrush at the given index.java.awt.Color
getPaintColor()
Accessor that returns the current color of the paint.private java.lang.Integer[]
getPaintList()
DOCUMENT ME!javax.swing.JToggleButton
getPointerButton()
java.lang.String
getSelectedScriptFileName()
Returns the full path and file name of the currently selected script file in the scripting toolbar.ViewToolBarBuilder.VOIColorButton
getVOIColorButton()
Returns the VOI Color/properties buttonjavax.swing.JButton
getVOIRedoButton()
javax.swing.JButton
getVOIUndoButton()
static javax.swing.JToolBar
initToolBar()
Create a blank toolbar and set it up.void
itemStateChanged(java.awt.event.ItemEvent event)
Sets border painted or not painted depending on if the button was selected or deselected.static javax.swing.JButton
makeSeparator()
Makes a separator for the use in the toolbars - a button with the proper icon.private void
refreshPaintBox(boolean doDelete, int indexOfRemoval)
DOCUMENT ME!void
runCurrentScript()
Method to run the script currently selected in the scripting toolbar.void
setCheckboardButtonEnabled(boolean flag)
Accessor that enables or disables the checkerboard button.void
setCTButtonEnabled(boolean flag)
Accessor that enables or disables the CT button.void
setIntensityPaintName(java.lang.String stringValue)
Accessor that sets the intensity paint name (that is, the text of the intensity spinner).void
setOpacity(float op)
Accessor that sets the opacity of the paint.void
setPaintBrush(int index)
Sets the index of the paintBox (to select a different paint brush).void
setPaintBrushButtonSelected()
Accessor that sets the paint brush button to selected.void
setPaintColor(java.awt.Color color)
Accessor that sets the color of the paint.void
setPointerButton(javax.swing.JToggleButton pointerButton)
void
setPointerSelected()
Accessor that sets the pointer button to selected.void
setRegButtonEnabled(boolean flag)
Accessor that enables or disables the window region button.void
setSpinnerValues(int type)
Sets the spinner values based on image type.void
setToggleButtonSelected(java.lang.String actionCommand)
Sets the correct Toggle button to be selected (based on action command).void
setVOIGroup(javax.swing.ButtonGroup newVOIGroup)
void
updateScripts(java.lang.String dirName)
Method to update the list of scripts in the scripting toolbar based on the directory name provided.
-
-
-
Field Detail
-
pressedBorder
protected static final javax.swing.border.Border pressedBorder
A border to use for pressed buttons.
-
etchedBorder
protected static final javax.swing.border.Border etchedBorder
A border used for each toolbar.
-
NUM_BRUSHES_INTERNAL
public static final int NUM_BRUSHES_INTERNAL
DOCUMENT ME!- See Also:
- Constant Field Values
-
USER_BRUSHES
public static final java.lang.String USER_BRUSHES
DOCUMENT ME!
-
borderPaintButton
public javax.swing.JToggleButton borderPaintButton
The button used to toggle borders around painted areas.
-
bogusBorderPaintButton
public javax.swing.JToggleButton bogusBorderPaintButton
The button used to toggle borders around painted areas.
-
checkerBoardButton
protected javax.swing.JButton checkerBoardButton
The button used to enable checker board display of two images.
-
colorPaintButton
protected javax.swing.JButton colorPaintButton
The button used to select the color of the paint used.
-
ctButton
protected javax.swing.JButton ctButton
The button for presets used only for CT images.
-
scrollButton
public javax.swing.JCheckBox scrollButton
-
syncImagesIcon
public javax.swing.JButton syncImagesIcon
-
currentScriptComboBox
protected javax.swing.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 java.lang.String currentSelectedScript
The script currently selected in the scripting toolbar (null if no script is selected).
-
intensitySpinner
protected javax.swing.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 javax.swing.JComboBox paintBox
Combo box to hold all of the paint brushes.
-
paintBrushButton
protected javax.swing.JToggleButton paintBrushButton
DOCUMENT ME!
-
paintColor
protected java.awt.Color paintColor
The paint color to be used when the user paints in the image.
-
pointerVOIButton
protected javax.swing.JToggleButton pointerVOIButton
The button for the "default" mode of the mouse, where clicking in the image shows the intensity of that voxel.
-
regButton
protected javax.swing.JToggleButton regButton
The button used to enable the showing of a small portion of image b near the mouse cursor.
-
scriptTable
protected java.util.Hashtable<java.lang.String,java.lang.String> scriptTable
DOCUMENT ME!
-
UI
protected java.lang.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 javax.swing.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 javax.swing.JButton voiUndoButton
-
voiRedoButton
protected javax.swing.JButton voiRedoButton
-
bgVector
protected java.util.Vector<javax.swing.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 java.lang.String[] paintBrushNames
DOCUMENT ME!
-
popup
private javax.swing.JPopupMenu popup
DOCUMENT ME!
-
popupListener
private ViewToolBarBuilder.PopupListener popupListener
DOCUMENT ME!
-
-
Method Detail
-
initToolBar
public static final javax.swing.JToolBar initToolBar()
Create a blank toolbar and set it up.- Returns:
- a new toolbar
-
makeSeparator
public static final javax.swing.JButton makeSeparator()
Makes a separator for the use in the toolbars - a button with the proper icon.- Returns:
- The separator.
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
DOCUMENT ME!- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
- Parameters:
e
- DOCUMENT ME!
-
buildBasicLUTToolBar
public javax.swing.JToolBar buildBasicLUTToolBar()
Builds a toolbar with just the basic lut buttons on it.- Returns:
- the basic lut toolbar
-
buildButton
public final javax.swing.JButton buildButton(java.lang.String cmd, java.lang.String tooltip, java.lang.String iconBase)
Create a new toolbar button.- Parameters:
cmd
- the command generated by the buttontooltip
- tooltip for the buttoniconBase
- 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 javax.swing.JButton buildButton(CustomUIBuilder.UIParams params)
Creates a JButton using a UIParams parameters- Parameters:
params
- UIParams (static final variable from CustomUIBuilder)- Returns:
-
buildGeneralToolBar
public javax.swing.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 javax.swing.JToolBar buildLUTThresholdToolBar()
Creates the LUT thresholding toolbar.- Returns:
- the new toolbar
-
buildLUTToolBarBottom
public javax.swing.JToolBar buildLUTToolBarBottom()
Builds the LUT toolbar, with buttons for quick-changing the LUT of the image.- Returns:
- The LUT toolbar.
-
buildLUTToolBarTop
public javax.swing.JToolBar buildLUTToolBarTop()
Build the top part of the LUT toolbar.- Returns:
- the top part of the LUT toolbar
-
buildPaintToolBar
public javax.swing.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 javax.swing.JToolBar buildRGBToolBar()
Creates the RGB histogram toolbar.- Returns:
- the new toolbar
-
buildScriptToolBar
public javax.swing.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 javax.swing.JButton buildTextButton(java.lang.String text, java.lang.String toolTip, java.lang.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 javax.swing.JToggleButton buildToggleButton(java.lang.String cmd, java.lang.String tooltip, java.lang.String iconBase)
Create a new toolbar togglable button.- Parameters:
cmd
- the command generated by the buttontooltip
- tooltip for the buttoniconBase
- 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 javax.swing.JToggleButton buildToggleButton(java.lang.String cmd, java.lang.String tooltip, java.lang.String iconBase, javax.swing.ButtonGroup group)
Create a new toolbar togglable button.- Parameters:
cmd
- the command generated by the buttontooltip
- tooltip for the buttoniconBase
- 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 javax.swing.JToggleButton buildToggleButton(CustomUIBuilder.UIParams params, javax.swing.ButtonGroup group)
Create a new toolbar togglable button.- Parameters:
params
- button parameters that include actioncommand, tooltiptext, and iconbasegroup
- the button group to add the togglable button to (use null for the VOIGroup)- Returns:
- a new togglable button
-
buildToggleButton
public final javax.swing.JToggleButton buildToggleButton(java.lang.String cmd, int mnemonic, java.lang.String tooltip, java.lang.String iconBase, javax.swing.ButtonGroup group)
Create a new toolbar togglable button.- Parameters:
cmd
- the command generated by the buttonmnemonic
- short-cut mnemonic for this buttontooltip
- tooltip for the buttoniconBase
- 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 javax.swing.JToolBar buildCustomToolBar(java.util.Vector<CustomUIBuilder.UIParams> paramVector)
-
build3DVOIToolBar
private javax.swing.JToolBar build3DVOIToolBar(javax.swing.JToolBar VOIToolBar, int numberOfDimensions, int voiIndex)
-
buildVolumeTriPlanarVOIToolBar
public javax.swing.JToolBar buildVolumeTriPlanarVOIToolBar(int numberOfDimensions, int voiIndex, boolean bTraverseImage, boolean bOpacity, javax.swing.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 java.lang.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 java.lang.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 java.awt.Color getPaintColor()
Accessor that returns the current color of the paint.- Returns:
- Current color of the paint.
-
getPointerButton
public javax.swing.JToggleButton getPointerButton()
-
getSelectedScriptFileName
public java.lang.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 javax.swing.JButton getVOIUndoButton()
-
getVOIRedoButton
public javax.swing.JButton getVOIRedoButton()
-
itemStateChanged
public void itemStateChanged(java.awt.event.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 interfacejava.awt.event.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(java.lang.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(java.awt.Color color)
Accessor that sets the color of the paint.- Parameters:
color
- Color to set paint to.
-
setPointerButton
public void setPointerButton(javax.swing.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(java.lang.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(javax.swing.ButtonGroup newVOIGroup)
-
updateScripts
public void updateScripts(java.lang.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 java.lang.Integer[] getPaintList()
DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
refreshPaintBox
private void refreshPaintBox(boolean doDelete, int indexOfRemoval)
DOCUMENT ME!- Parameters:
doDelete
- DOCUMENT ME!indexOfRemoval
- DOCUMENT ME!
-
-