Package docking.widgets.imagepanel

# Class ImagePanel

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
docking.widgets.imagepanel.ImagePanel

All Implemented Interfaces:
  `ImageObserver`, `MenuContainer`, `Serializable`, `Accessible`

public class ImagePanel extends JPanel
Creates a panel that displays an `Image`. Users may pan the image as desired and zoom the image according to specific zoom levels.

See Also:
  - Serialized Form

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class javax.swing.JPanel

  `JPanel.AccessibleJPanel`

  ## Nested classes/interfaces inherited from class javax.swing.JComponent

  `JComponent.AccessibleJComponent`

  ## Nested classes/interfaces inherited from class java.awt.Container

  `Container.AccessibleAWTContainer`

  ## Nested classes/interfaces inherited from class java.awt.Component

  `Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final float`
  `DEFAULT_ZOOM_FACTOR`
  `static final String`
  `DEFAULT_ZOOM_PROPERTY`
  Property name that indicates the default zoom level of the image has changed
  `static final String`
  `IMAGE_PROPERTY`
  Property name that indicates the image displayed by this panel has changed
  `static final String`
  `TRANSLATION_PROPERTY`
  Property name that indicates the image has been translated
  `protected static final int`
  `ZOOM_FACTOR_INDEX_DEFAULT`
  `static final float[]`
  `ZOOM_LEVELS`
  `static final String`
  `ZOOM_PROPERTY`
  Property name that indicates the zoom level of the image has changed
  `protected int`
  `zoomLevelIndex`

  ### 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`

  ### Fields inherited from class java.awt.Component

  `accessibleContext, 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

  Constructors
  Constructor
  Description
  `ImagePanel()`
  Create an empty NavigableImagePanel
  `ImagePanel(Image image)`
  Create an NavigableImagePanel with the specified image

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `canZoomIn()`
  Determine if the image can zoom in further based on current magnification levels
  `boolean`
  `canZoomOut()`
  Determine if the image can zoom out further based on current magnification levels
  `float`
  `getDefaultZoomFactor()`
  Get the default zoom factory
  `Image`
  `getImage()`
  Get the currently-displayed image
  `Color`
  `getImageBackgroundColor()`
  Get the current background color of this panel
  `String`
  `getText()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  unused
  `Point`
  `getTranslation()`
  Get the X-Y distance the image has moved
  `float`
  `getZoomFactor()`
  Get the current zoom factor the image is being drawn to
  `boolean`
  `isImageTranslationEnabled()`
  `boolean`
  `isImageZoomEnabled()`
  `boolean`
  `isTranslated()`
  Determine if the image has been moved from its original location
  `void`
  `resetImageTranslation()`
  Move the image back to the center.
  `void`
  `resetZoom()`
  `void`
  `setDefaultZoomFactor(float zoom)`
  Set the default zoom level, adhering to the same set of constrains as `setZoomFactor(float)`
  `void`
  `setImage(Image image)`
  Set the image this panel should display
  `void`
  `setImageBackgroundColor(Color color)`
  Set the background color of the panel.
  `void`
  `setImageTranslationEnabled(boolean enabled)`
  `void`
  `setImageZoomEnabled(boolean enabled)`
  `void`
  `setText(String text)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  unused
  `void`
  `setZoomFactor(float zoom)`
  Set the magnification factor of the image.
  `void`
  `zoomIn()`
  Enlarge the image about the image center
  `void`
  `zoomIn(Point center)`
  Enlarge the image about the given point
  `void`
  `zoomOut()`
  Shrink the image about the image center
  `void`
  `zoomOut(Point center)`
  Shrink the image about the given point

  ### 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, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, update`

  ### 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, 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`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### ZOOM_LEVELS

    public static final float[] ZOOM_LEVELS

  - ### ZOOM_FACTOR_INDEX_DEFAULT

    protected static final int ZOOM_FACTOR_INDEX_DEFAULT

  - ### zoomLevelIndex

    protected int zoomLevelIndex

  - ### DEFAULT_ZOOM_FACTOR

    public static final float DEFAULT_ZOOM_FACTOR
    See Also:
      - Constant Field Values

  - ### IMAGE_PROPERTY

    public static final String IMAGE_PROPERTY
    Property name that indicates the image displayed by this panel has changed
    See Also:
      - Constant Field Values

  - ### ZOOM_PROPERTY

    public static final String ZOOM_PROPERTY
    Property name that indicates the zoom level of the image has changed
    See Also:
      - Constant Field Values

  - ### DEFAULT_ZOOM_PROPERTY

    public static final String DEFAULT_ZOOM_PROPERTY
    Property name that indicates the default zoom level of the image has changed
    See Also:
      - Constant Field Values

  - ### TRANSLATION_PROPERTY

    public static final String TRANSLATION_PROPERTY
    Property name that indicates the image has been translated
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### ImagePanel

    public ImagePanel()
    Create an empty NavigableImagePanel

  - ### ImagePanel

    public ImagePanel(Image image)
    Create an NavigableImagePanel with the specified image
    Parameters:
      `image` - the image

- ## Method Details

  - ### setImage

    public void setImage(Image image)
    Set the image this panel should display
    Parameters:
      `image` - the new image to display

  - ### getImage

    public Image getImage()
    Get the currently-displayed image
    Returns:
      the current image

  - ### setImageBackgroundColor

    public void setImageBackgroundColor(Color color)
    Set the background color of the panel. If the specified color is null, the default color for panel backgrounds is used.
    Parameters:
      `color` - the new background color

  - ### getImageBackgroundColor

    public Color getImageBackgroundColor()
    Get the current background color of this panel
    Returns:
      the background color

  - ### setText

    @Deprecated(since="10.2", forRemoval=true) public void setText(String text)
    Deprecated, for removal: This API element is subject to removal in a future version.
    unused
    Unused
    Parameters:
      `text` - unused

  - ### getText

    @Deprecated(since="10.2", forRemoval=true) public String getText()
    Deprecated, for removal: This API element is subject to removal in a future version.
    unused
    Unused
    Returns:
      unused

  - ### getZoomFactor

    public float getZoomFactor()
    Get the current zoom factor the image is being drawn to
    Returns:
      the image magnification factor

  - ### setZoomFactor

    public void setZoomFactor(float zoom)
    Set the magnification factor of the image. The zoom parameter is aligned to the nearest pre-configured magnification factor, rounding down for zoom factors less than 1.0, and up for factors greater than 1.0. Zoom factors outside the pre-configured range are limited to the nearest range extent.
    Parameters:
      `zoom` - the zoom

  - ### getDefaultZoomFactor

    public float getDefaultZoomFactor()
    Get the default zoom factory
    Returns:
      the zoom factor

  - ### setDefaultZoomFactor

    public void setDefaultZoomFactor(float zoom)
    Set the default zoom level, adhering to the same set of constrains as `setZoomFactor(float)`
    Parameters:
      `zoom` - the zoom
    See Also:
      - `setZoomFactor(float)`
      - `resetZoom()`

  - ### resetZoom

    public void resetZoom()

  - ### canZoomIn

    public boolean canZoomIn()
    Determine if the image can zoom in further based on current magnification levels
    Returns:
      True if magnification steps are available, false otherwise

  - ### zoomIn

    public void zoomIn()
    Enlarge the image about the image center

  - ### zoomIn

    public void zoomIn(Point center)
    Enlarge the image about the given point
    Parameters:
      `center` - location to enlarge the image around

  - ### canZoomOut

    public boolean canZoomOut()
    Determine if the image can zoom out further based on current magnification levels
    Returns:
      True if (de-)magnification steps are available, false otherwise

  - ### zoomOut

    public void zoomOut()
    Shrink the image about the image center

  - ### zoomOut

    public void zoomOut(Point center)
    Shrink the image about the given point
    Parameters:
      `center` - location to shrink the image around

  - ### isImageZoomEnabled

    public boolean isImageZoomEnabled()

  - ### setImageZoomEnabled

    public void setImageZoomEnabled(boolean enabled)

  - ### resetImageTranslation

    public void resetImageTranslation()
    Move the image back to the center. Zoom factor is unmodified.

  - ### isTranslated

    public boolean isTranslated()
    Determine if the image has been moved from its original location
    Returns:
      True if the image has moved, false otherwise

  - ### getTranslation

    public Point getTranslation()
    Get the X-Y distance the image has moved
    Returns:
      the X-Y distances the image has moved

  - ### isImageTranslationEnabled

    public boolean isImageTranslationEnabled()

  - ### setImageTranslationEnabled

    public void setImageTranslationEnabled(boolean enabled)