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:
MouseListener,MouseMotionListener,ImageObserver,MenuContainer,Serializable,EventListener
- Direct Known Subclasses:
ViewJComponentVolOpacity,ViewJComponentVolOpacityRGB
public abstract class ViewJComponentVolOpacityBase
extends JComponent
implements MouseListener, MouseMotionListener
Abstract class used for generating custom components, especially within images.
- Version:
- 1 - Sept 6, 2005
- Author:
- Lee M Orsino, Ph.D.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested 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 TypeFieldDescriptionprotected booleanDOCUMENT ME!static final intMove all the channel transfer functions.protected static final ColorThe default background color of JPanels (look and feel dependent).static final intThe blue channel transfer function.protected DimensionThe outer dimension of the histogram component we will be drawing.protected DimensionThe histogram image dimension.static final intThe green channel transfer function.protected ModelHistogramThe image histogram.protected int[]DOCUMENT ME!protected doubleDOCUMENT ME!protected doubleDOCUMENT ME!protected ModelImageThe image whose histo lut we are displaying.protected ImageDOCUMENT ME!static final intDOCUMENT ME!protected booleanWhether to transform the histogram data by log10.protected int[]DOCUMENT ME!protected floatDOCUMENT ME!protected floatDOCUMENT ME!protected intThe current mode of the histogram component.protected intDOCUMENT ME!protected intDOCUMENT ME!protected intDOCUMENT ME!protected ViewJComponentVolOpacityListenerprotected JPanelVolOpacityBaseThe container of this histogram component.protected int[]DOCUMENT ME!protected floatDOCUMENT ME!static final intThe red channel transfer function.private static final longUse serialVersionUID for interoperability.protected intDOCUMENT ME!protected intDOCUMENT ME!protected TransferFunctionDOCUMENT 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_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionViewJComponentVolOpacityBase(JPanelVolOpacityBase parent, ModelHistogram histo, ModelImage image, Dimension compDim) Creates object of size defined by width & height.ViewJComponentVolOpacityBase(ViewJComponentVolOpacityListener parent, ModelHistogram histo, ModelImage image, Dimension compDim) -
Method Summary
Modifier and TypeMethodDescriptionprotected 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(Graphics2D graphics) Draw the histogram border and the stationary marker ticks (function point ticks are drawn in drawTransferFunctionHandleTicks(Graphics2D).protected voiddrawRotatedVerticalAxisLabel(Graphics2D graphics) DOCUMENT ME!protected voiddrawTransferFunctionHandles(Graphics2D graphics, TransferFunction tf) Draw the transfer function handles (the little squares used to drag points).private voiddrawTransferFunctionHandleTicks(Graphics2D graphics, TransferFunction tf) This method draws the transfer function handle marks on the axes of the histogram.protected voiddrawTransferFunctionLine(Graphics2D graphics, TransferFunction tf, Color color) This method draws the transfer function line.protected voidfinalize()Clean up some resources.intDOCUMENT ME!getImage()Access the associated image.Gets minimum size equal to object size.intgetMode()Get the histogram mode (ie - RED, GREEN, BLUE ).DOCUMENT ME!Gets preferred size to set object size to.Get the current transfer function we are working with.voidResets 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.voidSets mode to linear and shows component.voidResets mode to linear and shows component.voidmouseClicked(MouseEvent mouseEvent) DOCUMENT ME!voidmouseDragged(MouseEvent mouseEvent) Continually updates the image depending on where the mouse is.voidmouseEntered(MouseEvent mouseEvent) DOCUMENT ME!voidmouseExited(MouseEvent mouseEvent) DOCUMENT ME!voidmouseMoved(MouseEvent mouseEvent) Changes the cursor so that function can add points depending on how near the line it is.voidmousePressed(MouseEvent mouseEvent) ************************************************************************ ***************************** Mouse Events *****************************voidmouseReleased(MouseEvent mouseEvent) DOCUMENT ME!voidpaintComponent(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.voidShow 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, updateUIMethods 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, validateTreeMethods 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 Details
-
serialVersionUID
private static final long serialVersionUIDUse serialVersionUID for interoperability.- See Also:
-
RED
public static final int REDThe red channel transfer function.- See Also:
-
GREEN
public static final int GREENThe green channel transfer function.- See Also:
-
BLUE
public static final int BLUEThe blue channel transfer function.- See Also:
-
ALL
public static final int ALLMove all the channel transfer functions.- See Also:
-
INACTIVE
public static final int INACTIVEDOCUMENT ME!- See Also:
-
backgroundColor
The default background color of JPanels (look and feel dependent). -
addPointFlag
protected boolean addPointFlagDOCUMENT ME! -
componentDim
The outer dimension of the histogram component we will be drawing. -
dim
The histogram image dimension. -
histogram
The image histogram. -
histogramBuffer
protected int[] histogramBufferDOCUMENT ME! -
histogramMax
protected double histogramMaxDOCUMENT ME! -
histogramMaxLog
protected double histogramMaxLogDOCUMENT ME! -
image
The image whose histo lut we are displaying. -
img
DOCUMENT ME! -
logFlag
protected boolean logFlagWhether to transform the histogram data by log10. -
lutIndexBuffer
protected int[] lutIndexBufferDOCUMENT ME! -
min
protected float minDOCUMENT ME! -
max
protected float maxDOCUMENT ME! -
mode
protected int modeThe current mode of the histogram component. -
newPointIndex
protected int newPointIndexDOCUMENT ME! -
offsetX
protected int offsetXDOCUMENT ME! -
offsetY
protected int offsetYDOCUMENT ME! -
parentPanel
The container of this histogram component. -
parentListener
-
pixBuffer
protected int[] pixBufferDOCUMENT ME! -
range
protected float rangeDOCUMENT ME! -
stRange
protected int stRangeDOCUMENT ME! -
tfActiveIndex
protected int tfActiveIndexDOCUMENT ME! -
transferFunction
DOCUMENT ME!
-
-
Constructor Details
-
ViewJComponentVolOpacityBase
public ViewJComponentVolOpacityBase(JPanelVolOpacityBase parent, ModelHistogram histo, ModelImage image, 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, Dimension compDim) - Parameters:
parent- ViewJComponentVolOpacityListener -- container displaying this clashisto- histogramimage- input modelImagecompDim- widht and height of component
-
-
Method Details
-
showHistogram
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
Access the associated image.- Returns:
- ModelImage Reference to image instance.
-
getMinimumSize
Gets minimum size equal to object size.- Overrides:
getMinimumSizein classJComponent- Returns:
- Dimension with the size
-
getMode
public int getMode()Get the histogram mode (ie - RED, GREEN, BLUE ).- Returns:
- the histogram mode
-
getOpacityTransferFunction
DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
getPreferredSize
Gets preferred size to set object size to.- Overrides:
getPreferredSizein classJComponent- Returns:
- Dimension with the size
-
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
DOCUMENT ME!- Specified by:
mouseClickedin interfaceMouseListener- Parameters:
mouseEvent- DOCUMENT ME!
-
mouseDragged
Continually updates the image depending on where the mouse is.- Specified by:
mouseDraggedin interfaceMouseMotionListener- Parameters:
mouseEvent- event that triggered this function
-
mouseEntered
DOCUMENT ME!- Specified by:
mouseEnteredin interfaceMouseListener- Parameters:
mouseEvent- DOCUMENT ME!
-
mouseExited
DOCUMENT ME!- Specified by:
mouseExitedin interfaceMouseListener- Parameters:
mouseEvent- DOCUMENT ME!
-
mouseMoved
Changes the cursor so that function can add points depending on how near the line it is.- Specified by:
mouseMovedin interfaceMouseMotionListener- Parameters:
mouseEvent- event that triggered this function
-
mousePressed
************************************************************************ ***************************** Mouse Events *****************************.************************************************************************- Specified by:
mousePressedin interfaceMouseListener- Parameters:
mouseEvent- DOCUMENT ME!
-
mouseReleased
DOCUMENT ME!- Specified by:
mouseReleasedin interfaceMouseListener- Parameters:
mouseEvent- DOCUMENT ME!
-
paintComponent
Paints the component.- Overrides:
paintComponentin classJComponent- Parameters:
graphics- graphics to paint in
-
setHistogramInfo
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
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
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
DOCUMENT ME!- Parameters:
graphics- DOCUMENT ME!
-
drawTransferFunctionHandles
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
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
Clean up some resources. -
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
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
-