Package gov.nih.mipav.view.renderer
Class ViewJComponentVolOpacityBase
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- gov.nih.mipav.view.renderer.ViewJComponentVolOpacityBase
-
- All Implemented Interfaces:
java.awt.event.MouseListener,java.awt.event.MouseMotionListener,java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,java.util.EventListener
- Direct Known Subclasses:
ViewJComponentVolOpacity,ViewJComponentVolOpacityRGB
public abstract class ViewJComponentVolOpacityBase extends javax.swing.JComponent implements java.awt.event.MouseListener, java.awt.event.MouseMotionListenerAbstract class used for generating custom components, especially within images.- Version:
- 1 - Sept 6, 2005
- Author:
- Lee M Orsino, Ph.D.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanaddPointFlagDOCUMENT ME!static intALLMove all the channel transfer functions.protected static java.awt.ColorbackgroundColorThe default background color of JPanels (look and feel dependent).static intBLUEThe blue channel transfer function.protected java.awt.DimensioncomponentDimThe outer dimension of the histogram component we will be drawing.protected java.awt.DimensiondimThe histogram image dimension.static intGREENThe green channel transfer function.protected ModelHistogramhistogramThe image histogram.protected int[]histogramBufferDOCUMENT ME!protected doublehistogramMaxDOCUMENT ME!protected doublehistogramMaxLogDOCUMENT ME!protected ModelImageimageThe image whose histo lut we are displaying.protected java.awt.ImageimgDOCUMENT ME!static intINACTIVEDOCUMENT ME!protected booleanlogFlagWhether to transform the histogram data by log10.protected int[]lutIndexBufferDOCUMENT ME!protected floatmaxDOCUMENT ME!protected floatminDOCUMENT ME!protected intmodeThe current mode of the histogram component.protected intnewPointIndexDOCUMENT ME!protected intoffsetXDOCUMENT ME!protected intoffsetYDOCUMENT ME!protected ViewJComponentVolOpacityListenerparentListenerprotected JPanelVolOpacityBaseparentPanelThe container of this histogram component.protected int[]pixBufferDOCUMENT ME!protected floatrangeDOCUMENT ME!static intREDThe red channel transfer function.private static longserialVersionUIDUse serialVersionUID for interoperability.protected intstRangeDOCUMENT ME!protected inttfActiveIndexDOCUMENT ME!protected TransferFunctiontransferFunctionDOCUMENT ME!-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description ViewJComponentVolOpacityBase(JPanelVolOpacityBase parent, ModelHistogram histo, ModelImage image, java.awt.Dimension compDim)Creates object of size defined by width & height.ViewJComponentVolOpacityBase(ViewJComponentVolOpacityListener parent, ModelHistogram histo, ModelImage image, java.awt.Dimension compDim)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected floatconvertFnPtToScreenSpaceX(float point_x)This method converts a transfer function point value into screen space so that it can be displayed on the histogram.protected floatconvertScreenSpaceXToFnPt(int pixel)This method converts a point in screen space into a transfer function point value.voiddispose()Abstract method to force extended classes to implement a disposal method to clean up memory.protected voiddrawAxisAccoutrements(java.awt.Graphics2D graphics)Draw the histogram border and the stationary marker ticks (function point ticks are drawn in drawTransferFunctionHandleTicks(Graphics2D).protected voiddrawRotatedVerticalAxisLabel(java.awt.Graphics2D graphics)DOCUMENT ME!protected voiddrawTransferFunctionHandles(java.awt.Graphics2D graphics, TransferFunction tf)Draw the transfer function handles (the little squares used to drag points).private voiddrawTransferFunctionHandleTicks(java.awt.Graphics2D graphics, TransferFunction tf)This method draws the transfer function handle marks on the axes of the histogram.protected voiddrawTransferFunctionLine(java.awt.Graphics2D graphics, TransferFunction tf, java.awt.Color color)This method draws the transfer function line.protected voidfinalize()Clean up some resources.intgetActiveIndex()DOCUMENT ME!ModelImagegetImage()Access the associated image.java.awt.DimensiongetMinimumSize()Gets minimum size equal to object size.intgetMode()Get the histogram mode (ie - RED, GREEN, BLUE ).TransferFunctiongetOpacityTransferFunction()DOCUMENT ME!java.awt.DimensiongetPreferredSize()Gets preferred size to set object size to.VOIBasegetTransferFunction()Get the current transfer function we are working with.voidhorizonMode()Resets mode to linear horizontal and shows component.voidimportImage(int[] data)Creates a Image object from an array of ints that have been formatted (packed) properly (ie, aRGB).protected booleanisNearLine(int offsetMouseX, int offsetMouseY)Determines whether the mouse cursor is near the active transfer function line.voidlinearBackSlashMode()Sets mode to linear and shows component.voidlinearMode()Resets mode to linear and shows component.voidmouseClicked(java.awt.event.MouseEvent mouseEvent)DOCUMENT ME!voidmouseDragged(java.awt.event.MouseEvent mouseEvent)Continually updates the image depending on where the mouse is.voidmouseEntered(java.awt.event.MouseEvent mouseEvent)DOCUMENT ME!voidmouseExited(java.awt.event.MouseEvent mouseEvent)DOCUMENT ME!voidmouseMoved(java.awt.event.MouseEvent mouseEvent)Changes the cursor so that function can add points depending on how near the line it is.voidmousePressed(java.awt.event.MouseEvent mouseEvent)************************************************************************ ***************************** Mouse Events *****************************voidmouseReleased(java.awt.event.MouseEvent mouseEvent)DOCUMENT ME!voidpaintComponent(java.awt.Graphics graphics)Paints the component.voidsetHistogramInfo(ModelImage _image, ModelHistogram _histo)Set up the image, LUT and histogram information.voidsetLogFlag(boolean value)This flag indicates if the histogram should be displayed using a log10 scale.voidsetMode(int _mode)Accessor that sets the mode.voidshowHistogram()Show the histogram without filtering it through a LUT.abstract voidshowHistogram(ModelLUT LUT)Filters the histogram through the LUT and produces an int array (aRGB) that can be converted to a java image of the histogram for display purposes.voidupdateCursorXPos(float _mx)Update the cursor position when mouse slider is moved.voidupdateTransFunc(TransferFunction transFunc)Load preset transfer function for the image.-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Use serialVersionUID for interoperability.- See Also:
- Constant Field Values
-
RED
public static final int RED
The red channel transfer function.- See Also:
- Constant Field Values
-
GREEN
public static final int GREEN
The green channel transfer function.- See Also:
- Constant Field Values
-
BLUE
public static final int BLUE
The blue channel transfer function.- See Also:
- Constant Field Values
-
ALL
public static final int ALL
Move all the channel transfer functions.- See Also:
- Constant Field Values
-
INACTIVE
public static final int INACTIVE
DOCUMENT ME!- See Also:
- Constant Field Values
-
backgroundColor
protected static final java.awt.Color backgroundColor
The default background color of JPanels (look and feel dependent).
-
addPointFlag
protected boolean addPointFlag
DOCUMENT ME!
-
componentDim
protected java.awt.Dimension componentDim
The outer dimension of the histogram component we will be drawing.
-
dim
protected java.awt.Dimension dim
The histogram image dimension.
-
histogram
protected ModelHistogram histogram
The image histogram.
-
histogramBuffer
protected int[] histogramBuffer
DOCUMENT ME!
-
histogramMax
protected double histogramMax
DOCUMENT ME!
-
histogramMaxLog
protected double histogramMaxLog
DOCUMENT ME!
-
image
protected ModelImage image
The image whose histo lut we are displaying.
-
img
protected java.awt.Image img
DOCUMENT ME!
-
logFlag
protected boolean logFlag
Whether to transform the histogram data by log10.
-
lutIndexBuffer
protected int[] lutIndexBuffer
DOCUMENT ME!
-
min
protected float min
DOCUMENT ME!
-
max
protected float max
DOCUMENT ME!
-
mode
protected int mode
The current mode of the histogram component.
-
newPointIndex
protected int newPointIndex
DOCUMENT ME!
-
offsetX
protected int offsetX
DOCUMENT ME!
-
offsetY
protected int offsetY
DOCUMENT ME!
-
parentPanel
protected JPanelVolOpacityBase parentPanel
The container of this histogram component.
-
parentListener
protected ViewJComponentVolOpacityListener parentListener
-
pixBuffer
protected int[] pixBuffer
DOCUMENT ME!
-
range
protected float range
DOCUMENT ME!
-
stRange
protected int stRange
DOCUMENT ME!
-
tfActiveIndex
protected int tfActiveIndex
DOCUMENT ME!
-
transferFunction
protected TransferFunction transferFunction
DOCUMENT ME!
-
-
Constructor Detail
-
ViewJComponentVolOpacityBase
public ViewJComponentVolOpacityBase(JPanelVolOpacityBase parent, ModelHistogram histo, ModelImage image, java.awt.Dimension compDim)
Creates object of size defined by width & height.- Parameters:
parent- DOCUMENT ME!histo- DOCUMENT ME!image- DOCUMENT ME!compDim- width and height of component
-
ViewJComponentVolOpacityBase
public ViewJComponentVolOpacityBase(ViewJComponentVolOpacityListener parent, ModelHistogram histo, ModelImage image, java.awt.Dimension compDim)
- Parameters:
parent- ViewJComponentVolOpacityListener -- container displaying this clashisto- histogramimage- input modelImagecompDim- widht and height of component
-
-
Method Detail
-
showHistogram
public abstract void showHistogram(ModelLUT LUT)
Filters the histogram through the LUT and produces an int array (aRGB) that can be converted to a java image of the histogram for display purposes.- Parameters:
LUT- LUT to filter with
-
dispose
public void dispose()
Abstract method to force extended classes to implement a disposal method to clean up memory.
-
getActiveIndex
public int getActiveIndex()
DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
getImage
public ModelImage getImage()
Access the associated image.- Returns:
- ModelImage Reference to image instance.
-
getMinimumSize
public java.awt.Dimension getMinimumSize()
Gets minimum size equal to object size.- Overrides:
getMinimumSizein classjavax.swing.JComponent- Returns:
- Dimension with the size
-
getMode
public int getMode()
Get the histogram mode (ie - RED, GREEN, BLUE ).- Returns:
- the histogram mode
-
getOpacityTransferFunction
public TransferFunction getOpacityTransferFunction()
DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
getPreferredSize
public java.awt.Dimension getPreferredSize()
Gets preferred size to set object size to.- Overrides:
getPreferredSizein classjavax.swing.JComponent- Returns:
- Dimension with the size
-
getTransferFunction
public VOIBase getTransferFunction()
Get the current transfer function we are working with.- Returns:
- the LUT tranfer function
-
horizonMode
public void horizonMode()
Resets mode to linear horizontal and shows component.
-
importImage
public void importImage(int[] data)
Creates a Image object from an array of ints that have been formatted (packed) properly (ie, aRGB).- Parameters:
data- Data (image) to be displayed.
-
linearBackSlashMode
public void linearBackSlashMode()
Sets mode to linear and shows component.
-
linearMode
public void linearMode()
Resets mode to linear and shows component.
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent mouseEvent)
DOCUMENT ME!- Specified by:
mouseClickedin interfacejava.awt.event.MouseListener- Parameters:
mouseEvent- DOCUMENT ME!
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent mouseEvent)
Continually updates the image depending on where the mouse is.- Specified by:
mouseDraggedin interfacejava.awt.event.MouseMotionListener- Parameters:
mouseEvent- event that triggered this function
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent mouseEvent)
DOCUMENT ME!- Specified by:
mouseEnteredin interfacejava.awt.event.MouseListener- Parameters:
mouseEvent- DOCUMENT ME!
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent mouseEvent)
DOCUMENT ME!- Specified by:
mouseExitedin interfacejava.awt.event.MouseListener- Parameters:
mouseEvent- DOCUMENT ME!
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent mouseEvent)
Changes the cursor so that function can add points depending on how near the line it is.- Specified by:
mouseMovedin interfacejava.awt.event.MouseMotionListener- Parameters:
mouseEvent- event that triggered this function
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent mouseEvent)
************************************************************************ ***************************** Mouse Events *****************************.************************************************************************- Specified by:
mousePressedin interfacejava.awt.event.MouseListener- Parameters:
mouseEvent- DOCUMENT ME!
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent mouseEvent)
DOCUMENT ME!- Specified by:
mouseReleasedin interfacejava.awt.event.MouseListener- Parameters:
mouseEvent- DOCUMENT ME!
-
paintComponent
public void paintComponent(java.awt.Graphics graphics)
Paints the component.- Overrides:
paintComponentin classjavax.swing.JComponent- Parameters:
graphics- graphics to paint in
-
setHistogramInfo
public void setHistogramInfo(ModelImage _image, ModelHistogram _histo)
Set up the image, LUT and histogram information.- Parameters:
_image- image_histo- histogram of the image
-
setLogFlag
public void setLogFlag(boolean value)
This flag indicates if the histogram should be displayed using a log10 scale.- Parameters:
value-trueuse the Log scale andfalsepaint bars in linear scale
-
setMode
public void setMode(int _mode)
Accessor that sets the mode.- Parameters:
_mode- the mode of the histogram
-
showHistogram
public void showHistogram()
Show the histogram without filtering it through a LUT.
-
updateCursorXPos
public void updateCursorXPos(float _mx)
Update the cursor position when mouse slider is moved.- Parameters:
_mx- cursor x postion.
-
updateTransFunc
public void updateTransFunc(TransferFunction transFunc)
Load preset transfer function for the image.- Parameters:
transFunc- transfer function
-
convertFnPtToScreenSpaceX
protected float convertFnPtToScreenSpaceX(float point_x)
This method converts a transfer function point value into screen space so that it can be displayed on the histogram. This is necessary because the histogram that is painted on the screen is typically has a different range than the transfer function.- Parameters:
point_x- float - the point on the transfer function- Returns:
- float
-
convertScreenSpaceXToFnPt
protected float convertScreenSpaceXToFnPt(int pixel)
This method converts a point in screen space into a transfer function point value. This is necessary because the histogram that is painted on the screen is typically has a different range than the transfer function.- Parameters:
pixel- int - the pixel value to translate into a transfer function point- Returns:
- float
-
drawAxisAccoutrements
protected void drawAxisAccoutrements(java.awt.Graphics2D graphics)
Draw the histogram border and the stationary marker ticks (function point ticks are drawn in drawTransferFunctionHandleTicks(Graphics2D).- Parameters:
graphics- Graphics2D - the graphics context to draw in
-
drawRotatedVerticalAxisLabel
protected void drawRotatedVerticalAxisLabel(java.awt.Graphics2D graphics)
DOCUMENT ME!- Parameters:
graphics- DOCUMENT ME!
-
drawTransferFunctionHandles
protected void drawTransferFunctionHandles(java.awt.Graphics2D graphics, TransferFunction tf)Draw the transfer function handles (the little squares used to drag points).- Parameters:
graphics- Graphics2D - the graphics context to draw intf- TransferFunction - the TransferFunction object to draw
-
drawTransferFunctionLine
protected void drawTransferFunctionLine(java.awt.Graphics2D graphics, TransferFunction tf, java.awt.Color color)This method draws the transfer function line.- Parameters:
graphics- Graphics2D - the graphics context to draw intf- TransferFunction - the TransferFunction object to drawcolor- Color - the color used to draw the function line
-
finalize
protected void finalize() throws java.lang.ThrowableClean up some resources.- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable- if there is a problem during cleanup
-
isNearLine
protected boolean isNearLine(int offsetMouseX, int offsetMouseY)Determines whether the mouse cursor is near the active transfer function line.- Parameters:
offsetMouseX- intoffsetMouseY- int- Returns:
- boolean true if cursor is near the active transfer function line, false otherwise
-
drawTransferFunctionHandleTicks
private void drawTransferFunctionHandleTicks(java.awt.Graphics2D graphics, TransferFunction tf)This method draws the transfer function handle marks on the axes of the histogram.- Parameters:
graphics- Graphics2D - the graphics context to draw intf- TransferFunction - the TransferFunction object to draw
-
-