ij.gui
Class ImageCanvas

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by ij.gui.ImageCanvas
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Cloneable, java.util.EventListener

public class ImageCanvas
extends javax.swing.JComponent
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.lang.Cloneable

This is a Canvas used to display images in a Window.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
static boolean usePointer
           
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
ImageCanvas(ImagePlus imp)
           
 
Method Summary
 boolean cursorOverImage()
          Returns 'true' if the cursor is over this image.
 void disablePopupMenu(boolean status)
          Disable/enable popup menu.
 void fitToWindow()
           
 java.awt.Point getCursorLoc()
          Returns the current cursor location in image coordinates.
 boolean getCustomRoi()
           
 java.util.Vector getDisplayList()
          Deprecated. replaced by ImagePlus.getOverlay()
static double getHigherZoomLevel(double currentMag)
           
 ImagePlus getImage()
          Returns the ImagePlus object that is associated with this ImageCanvas.
static double getLowerZoomLevel(double currentMag)
           
 double getMagnification()
           
 boolean getMagnifier()
          Returns true if this is a Magnifier is selected.
 int getModifiers()
          Returns the mouse event modifiers.
 Overlay getOverlay()
          Use ImagePlus.getOverlay().
 java.awt.Dimension getPreferredSize()
           
static java.awt.Color getShowAllColor()
          Returns the color used for "Show All" mode.
 Overlay getShowAllList()
          Return the ROI Manager "Show All" list as an overlay.
 boolean getShowAllROIs()
          Returns the state of the ROI Manager "Show All" flag.
 int getSliceNumber(java.lang.String label)
           
 java.awt.Rectangle getSrcRect()
           
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 int offScreenX(int sx)
          Converts a screen x-coordinate to an offscreen x-coordinate.
 double offScreenXD(int sx)
          Converts a screen x-coordinate to a floating-point offscreen x-coordinate.
 int offScreenY(int sy)
          Converts a screen y-coordinate to an offscreen y-coordinate.
 double offScreenYD(int sy)
          Converts a screen y-coordinate to a floating-point offscreen y-coordinate.
 void paint(java.awt.Graphics g)
           
 void resetDoubleBuffer()
           
 int screenX(int ox)
          Converts an offscreen x-coordinate to a screen x-coordinate.
 int screenXD(double ox)
          Converts a floating-point offscreen x-coordinate to a screen x-coordinate.
 int screenY(int oy)
          Converts an offscreen y-coordinate to a screen y-coordinate.
 int screenYD(double oy)
          Converts a floating-point offscreen x-coordinate to a screen x-coordinate.
 void set2Magnifier(java.lang.String title)
           
 void setCursor(int sx, int sy, int ox, int oy)
          Sets the cursor based on the current tool and cursor location.
 void setCustomRoi(boolean customRoi)
          Allows plugins (e.g., Orthogonal_Views) to create a custom ROI using a display list.
 void setDisplayList(Roi roi, java.awt.Color color)
          Deprecated. replaced by ImagePlus.setOverlay(Roi, Color, int, Color)
 void setDisplayList(java.awt.Shape shape, java.awt.Color color, java.awt.BasicStroke stroke)
          Deprecated. replaced by ImagePlus.setOverlay(Shape, Color, BasicStroke)
 void setDisplayList(java.util.Vector list)
          Deprecated. replaced by ImagePlus.setOverlay(ij.gui.Overlay)
 void setDrawingSize(int width, int height)
           
 void setImageUpdated()
          ImagePlus.updateAndDraw calls this method to force the paint() method to update the image from the ImageProcessor.
 void setMagnification(double magnification)
           
static void setMagnifier(boolean isMag)
          This is a version of setMagnifier() that accepts a Boolean argument.
 void setOverlay(Overlay overlay)
          Use ImagePlus.setOverlay(ij.gui.Overlay).
static void setShowAllColor(java.awt.Color c)
          Sets the color used used for the ROI Manager "Show All" mode.
 void setShowAllROIs(boolean showAllROIs)
          Enables/disables the ROI Manager "Show All" mode.
 void setShowCursorStatus(boolean status)
          Called by IJ.showStatus() to prevent status bar text from being overwritten until the cursor moves at least 12 pixels.
 void setSourceRect(java.awt.Rectangle r)
           
 void unzoom()
          Implements the Image/Zoom/Original Scale command.
 void update(java.awt.Graphics g)
           
 void zoom100Percent()
          Implements the Image/Zoom/View 100% command.
 void zoomIn(int sx, int sy)
          Zooms in by making the window bigger.
 void zoomOut(int x, int y)
          Zooms out by making the source rectangle (srcRect) larger and centering it on (x,y).
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

usePointer

public static boolean usePointer
Constructor Detail

ImageCanvas

public ImageCanvas(ImagePlus imp)
Method Detail

setSourceRect

public void setSourceRect(java.awt.Rectangle r)

getSrcRect

public java.awt.Rectangle getSrcRect()

setDrawingSize

public void setDrawingSize(int width,
                           int height)

setImageUpdated

public void setImageUpdated()
ImagePlus.updateAndDraw calls this method to force the paint() method to update the image from the ImageProcessor.


update

public void update(java.awt.Graphics g)
Overrides:
update in class javax.swing.JComponent

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class javax.swing.JComponent

getSliceNumber

public int getSliceNumber(java.lang.String label)

resetDoubleBuffer

public void resetDoubleBuffer()

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class javax.swing.JComponent

getCursorLoc

public java.awt.Point getCursorLoc()
Returns the current cursor location in image coordinates.


cursorOverImage

public boolean cursorOverImage()
Returns 'true' if the cursor is over this image.


getModifiers

public int getModifiers()
Returns the mouse event modifiers.


getImage

public ImagePlus getImage()
Returns the ImagePlus object that is associated with this ImageCanvas.


setCursor

public void setCursor(int sx,
                      int sy,
                      int ox,
                      int oy)
Sets the cursor based on the current tool and cursor location.


offScreenX

public int offScreenX(int sx)
Converts a screen x-coordinate to an offscreen x-coordinate.


offScreenY

public int offScreenY(int sy)
Converts a screen y-coordinate to an offscreen y-coordinate.


offScreenXD

public double offScreenXD(int sx)
Converts a screen x-coordinate to a floating-point offscreen x-coordinate.


offScreenYD

public double offScreenYD(int sy)
Converts a screen y-coordinate to a floating-point offscreen y-coordinate.


screenX

public int screenX(int ox)
Converts an offscreen x-coordinate to a screen x-coordinate.


screenY

public int screenY(int oy)
Converts an offscreen y-coordinate to a screen y-coordinate.


screenXD

public int screenXD(double ox)
Converts a floating-point offscreen x-coordinate to a screen x-coordinate.


screenYD

public int screenYD(double oy)
Converts a floating-point offscreen x-coordinate to a screen x-coordinate.


getMagnification

public double getMagnification()

setMagnification

public void setMagnification(double magnification)

setMagnifier

public static void setMagnifier(boolean isMag)
This is a version of setMagnifier() that accepts a Boolean argument.


getMagnifier

public boolean getMagnifier()
Returns true if this is a Magnifier is selected.


set2Magnifier

public void set2Magnifier(java.lang.String title)

fitToWindow

public void fitToWindow()

getLowerZoomLevel

public static double getLowerZoomLevel(double currentMag)

getHigherZoomLevel

public static double getHigherZoomLevel(double currentMag)

zoomIn

public void zoomIn(int sx,
                   int sy)
Zooms in by making the window bigger. If it can't be made bigger, then make the source rectangle (srcRect) smaller and center it at (sx,sy). Note that sx and sy are screen coordinates.


zoomOut

public void zoomOut(int x,
                    int y)
Zooms out by making the source rectangle (srcRect) larger and centering it on (x,y). If we can't make it larger, then make the window smaller.


unzoom

public void unzoom()
Implements the Image/Zoom/Original Scale command.


zoom100Percent

public void zoom100Percent()
Implements the Image/Zoom/View 100% command.


mousePressed

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

mouseExited

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

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

disablePopupMenu

public void disablePopupMenu(boolean status)
Disable/enable popup menu.


setShowAllROIs

public void setShowAllROIs(boolean showAllROIs)
Enables/disables the ROI Manager "Show All" mode.


getShowAllROIs

public boolean getShowAllROIs()
Returns the state of the ROI Manager "Show All" flag.


getShowAllList

public Overlay getShowAllList()
Return the ROI Manager "Show All" list as an overlay.


getShowAllColor

public static java.awt.Color getShowAllColor()
Returns the color used for "Show All" mode.


setShowAllColor

public static void setShowAllColor(java.awt.Color c)
Sets the color used used for the ROI Manager "Show All" mode.


setOverlay

public void setOverlay(Overlay overlay)
Use ImagePlus.setOverlay(ij.gui.Overlay).


getOverlay

public Overlay getOverlay()
Use ImagePlus.getOverlay().


setDisplayList

public void setDisplayList(java.util.Vector list)
Deprecated. replaced by ImagePlus.setOverlay(ij.gui.Overlay)


setDisplayList

public void setDisplayList(java.awt.Shape shape,
                           java.awt.Color color,
                           java.awt.BasicStroke stroke)
Deprecated. replaced by ImagePlus.setOverlay(Shape, Color, BasicStroke)


setDisplayList

public void setDisplayList(Roi roi,
                           java.awt.Color color)
Deprecated. replaced by ImagePlus.setOverlay(Roi, Color, int, Color)


getDisplayList

public java.util.Vector getDisplayList()
Deprecated. replaced by ImagePlus.getOverlay()


setCustomRoi

public void setCustomRoi(boolean customRoi)
Allows plugins (e.g., Orthogonal_Views) to create a custom ROI using a display list.


getCustomRoi

public boolean getCustomRoi()

setShowCursorStatus

public void setShowCursorStatus(boolean status)
Called by IJ.showStatus() to prevent status bar text from being overwritten until the cursor moves at least 12 pixels.


mouseReleased

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

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseEntered

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

mouseClicked

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