Landmark
Class LmsScrollableImagePanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by Landmark.LmsScrollableImagePanel
All Implemented Interfaces:
java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class LmsScrollableImagePanel
extends javax.swing.JPanel
implements java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

The LmsScrollableImagePanel class implements a scrollable Panel GUI to display an image used in the landmarking program.

Edited and refactored by Greg Thornwall, SAIC and Peter Lemkin

This work was produced by Peter Lemkin of the National Cancer Institute, an agency of the United States Government. As a work of the United States Government there is no associated copyright. It is offered as open source software under the Mozilla Public License (version 1.1) subject to the limitations noted in the accompanying LEGAL file. This notice must be included with the code. The Open2Dprot Mozilla and Legal files are available on http://Open2Dprot.sourceforge.net/.

Version:
$Date: 2005/12/22 00:18:10 $ $Revision: 1.27 $
Author:
P. Lemkin, NCI-Frederick, Frederick, MD, 21702
See Also:
Open2Dprot Home, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 boolean altMod
          ALT/Mouse
private  Landmark cs
          instance of the main Landmark class
private  LmsWizardPopup csi
          instance of the main/calling class
 boolean ctrlMod
          CTRL/Mouse
 boolean ctrlShiftMod
          CTRL-SHIFT/Mouse
 int curLMS
          current landmark set of current spot.
 java.awt.Color cursorColor
          Overlay color for cursor
private  DbSample dbS
          instance of sample
private  DbSample dbSorig
          instance of sample
 java.lang.String fontFamily
           
 java.awt.Image img
          image to display
 java.awt.Font largeFont
           
 java.awt.Color lmDBcolor
          Overlay color for user defined landmarks
 java.awt.Color lmsColor
          Overlay color for spots in the currently selected landmark set
 java.awt.Font mediumFont
           
 java.awt.Color nonLMScolor
          Overlay color for spot that are NOT in the currently selected landmark set.
 java.awt.Image oImage
          for outside/offscreen painting
 int pixHeight
          img height
 int pixWidth
          img width
 int preferredHeight
          preferred size of canvas
 int preferredWidth
          preferred size of canvas
(package private) static long serialVersionUID
          frame id
 boolean shiftMod
          SHIFT/Mouse
 ScrollableImage si
           
 java.lang.String side
          indicates left or right side by "right" or "left"
 java.awt.Font smallFont
           
 int xImg
          image address (x,y)+(xBase,yBase) where base address of ULHC of clipped image in image canvas used in last paint
 int yImg
          image address (x,y)+(xBase,yBase) where base address of ULHC of clipped image in image canvas used in last paint
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
LmsScrollableImagePanel(LmsWizardPopup csi, DbSample dbS, java.awt.Image img, int scrollPaneWidth, int scrollPaneHeight, java.lang.Object parentObj, java.lang.String side)
          ScrollableImageCanvas() - constructor.
 
Method Summary
private  void drawCircle(java.awt.Graphics g, int x, int y, int radius, java.awt.Color color)
          drawCircle() - draw circle at the specified color and radius.
 void drawOverLays(java.awt.Graphics g, java.awt.Image imgToDraw, int w, int h)
          drawOverLays() - paint the scrollable image canvas which includes the image, optional ROI's, overlay spots, optional histogram that is repainted in another class.
 java.awt.Dimension getPreferredSize()
          getPreferredSize() - getPreferredSize, must be implemented for ScrollPane to be displayed correctly.
 void keyPressed(java.awt.event.KeyEvent e)
          keyPressed() - handle key down events
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
private  boolean mapRelXYtoImage(java.awt.event.MouseEvent e)
          mapRelXYtoImage() - map (x,y) Mouse in current canvas to (xImg,yImg) as well as updating the parent.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
          mouseDragged() - display data and set coordinates of current pixel in current image.
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
          mouseMoved() - Change cursor to + when moved over this (Component)
 void mousePressed(java.awt.event.MouseEvent e)
          mousePressed() - display data and set coordinates of current pixel in current image.
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void paintPanel(java.awt.Graphics g, java.awt.Image imgToDraw, int w, int h, boolean offscreenFlag)
          paintPanel() - repaint scrollable canvas in region defined by scroll bars.
(package private)  java.lang.String showImageMousePositions(int x, int y, java.lang.String msgs)
          showImageMousePositions() - show the image mouse positions
 void update(java.awt.Graphics g)
          update() - update without background the scrollable canvas
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
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, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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
 
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, transferFocusBackward, 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, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
frame id

See Also:
Constant Field Values

csi

private LmsWizardPopup csi
instance of the main/calling class


cs

private Landmark cs
instance of the main Landmark class


dbS

private DbSample dbS
instance of sample


dbSorig

private DbSample dbSorig
instance of sample


ctrlMod

public boolean ctrlMod
CTRL/Mouse


shiftMod

public boolean shiftMod
SHIFT/Mouse


ctrlShiftMod

public boolean ctrlShiftMod
CTRL-SHIFT/Mouse


altMod

public boolean altMod
ALT/Mouse


fontFamily

public java.lang.String fontFamily

smallFont

public java.awt.Font smallFont

mediumFont

public java.awt.Font mediumFont

largeFont

public java.awt.Font largeFont

xImg

public int xImg
image address (x,y)+(xBase,yBase) where base address of ULHC of clipped image in image canvas used in last paint


yImg

public int yImg
image address (x,y)+(xBase,yBase) where base address of ULHC of clipped image in image canvas used in last paint


curLMS

public int curLMS
current landmark set of current spot. -1 if not current spot


preferredWidth

public int preferredWidth
preferred size of canvas


preferredHeight

public int preferredHeight
preferred size of canvas


cursorColor

public java.awt.Color cursorColor
Overlay color for cursor


lmDBcolor

public java.awt.Color lmDBcolor
Overlay color for user defined landmarks


lmsColor

public java.awt.Color lmsColor
Overlay color for spots in the currently selected landmark set


nonLMScolor

public java.awt.Color nonLMScolor
Overlay color for spot that are NOT in the currently selected landmark set.


si

public ScrollableImage si

side

public java.lang.String side
indicates left or right side by "right" or "left"


img

public java.awt.Image img
image to display


oImage

public java.awt.Image oImage
for outside/offscreen painting


pixWidth

public int pixWidth
img width


pixHeight

public int pixHeight
img height

Constructor Detail

LmsScrollableImagePanel

public LmsScrollableImagePanel(LmsWizardPopup csi,
                               DbSample dbS,
                               java.awt.Image img,
                               int scrollPaneWidth,
                               int scrollPaneHeight,
                               java.lang.Object parentObj,
                               java.lang.String side)
ScrollableImageCanvas() - constructor.

Parameters:
csi - is the image scroller associated with the image
dbS - DbSample
img - is the image to display
scrollPaneWidth - width of scroller window
scrollPaneHeight - height of scroller window
parentObj - for painting via invoke
side - "right" or "left" String for painting the correct upper img
Method Detail

getPreferredSize

public java.awt.Dimension getPreferredSize()
getPreferredSize() - getPreferredSize, must be implemented for ScrollPane to be displayed correctly.

Overrides:
getPreferredSize in class javax.swing.JComponent

showImageMousePositions

final java.lang.String showImageMousePositions(int x,
                                               int y,
                                               java.lang.String msgs)
showImageMousePositions() - show the image mouse positions

Parameters:
x - is relative image object position
y - is relative image object position
msgs - is message to display

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
keyPressed() - handle key down events

Specified by:
keyPressed in interface java.awt.event.KeyListener
Parameters:
e - is KeyEvent

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Specified by:
keyTyped in interface java.awt.event.KeyListener

mapRelXYtoImage

private final boolean mapRelXYtoImage(java.awt.event.MouseEvent e)
mapRelXYtoImage() - map (x,y) Mouse in current canvas to (xImg,yImg) as well as updating the parent. Set the (xImg,yImg) values which are RELATIVE to the current image. If flicker mode, then do change the Rsample coordinates.

Parameters:
e - is mouse event
Returns:
false if outside of the relative image

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
mousePressed() - display data and set coordinates of current pixel in current image. If flicker mode and in Sample, then center the Sample offset so the currently selected spots are overlyed if the images are flickered. [NOT USED]

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
e - is MouseEvent

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged() - display data and set coordinates of current pixel in current image.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Parameters:
e - is MouseEvent

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved() - Change cursor to + when moved over this (Component)

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Parameters:
e - is MouseEvent

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

update

public void update(java.awt.Graphics g)
update() - update without background the scrollable canvas

Overrides:
update in class javax.swing.JComponent
Parameters:
g - is graphics context

drawCircle

private final void drawCircle(java.awt.Graphics g,
                              int x,
                              int y,
                              int radius,
                              java.awt.Color color)
drawCircle() - draw circle at the specified color and radius.

Parameters:
g - is graphics context
x - is center of circle
y - is center of circle
radius - is the size of the circle
color - is color to draw

drawOverLays

public void drawOverLays(java.awt.Graphics g,
                         java.awt.Image imgToDraw,
                         int w,
                         int h)
drawOverLays() - paint the scrollable image canvas which includes the image, optional ROI's, overlay spots, optional histogram that is repainted in another class.

Parameters:
g - is graphics context.

paintPanel

public void paintPanel(java.awt.Graphics g,
                       java.awt.Image imgToDraw,
                       int w,
                       int h,
                       boolean offscreenFlag)
paintPanel() - repaint scrollable canvas in region defined by scroll bars. [TODO] use the csi.zoomFactor if it is > 1X to zoom the image.

Parameters:
g - is graphics context
imgToDraw - image to draw
w - width
h - height
offscreenFlag - draw g to image