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
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:
-
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
Modifier and TypeFieldDescriptionstatic final float
static final String
Property name that indicates the default zoom level of the image has changedstatic final String
Property name that indicates the image displayed by this panel has changedstatic final String
Property name that indicates the image has been translatedprotected static final int
static final float[]
static final String
Property name that indicates the zoom level of the image has changedprotected int
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
ConstructorDescriptionCreate an empty NavigableImagePanelImagePanel
(Image image) Create an NavigableImagePanel with the specified image -
Method Summary
Modifier and TypeMethodDescriptionboolean
Determine if the image can zoom in further based on current magnification levelsboolean
Determine if the image can zoom out further based on current magnification levelsfloat
Get the default zoom factorygetImage()
Get the currently-displayed imageGet the current background color of this panelgetText()
Deprecated, for removal: This API element is subject to removal in a future version.unusedGet the X-Y distance the image has movedfloat
Get the current zoom factor the image is being drawn toboolean
boolean
boolean
Determine if the image has been moved from its original locationvoid
Move the image back to the center.void
void
setDefaultZoomFactor
(float zoom) Set the default zoom level, adhering to the same set of constrains assetZoomFactor(float)
void
Set the image this panel should displayvoid
setImageBackgroundColor
(Color color) Set the background color of the panel.void
setImageTranslationEnabled
(boolean enabled) void
setImageZoomEnabled
(boolean enabled) void
Deprecated, for removal: This API element is subject to removal in a future version.unusedvoid
setZoomFactor
(float zoom) Set the magnification factor of the image.void
zoomIn()
Enlarge the image about the image centervoid
Enlarge the image about the given pointvoid
zoomOut()
Shrink the image about the image centervoid
Shrink the image about the given pointMethods 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
-
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:
-
IMAGE_PROPERTY
Property name that indicates the image displayed by this panel has changed- See Also:
-
ZOOM_PROPERTY
Property name that indicates the zoom level of the image has changed- See Also:
-
DEFAULT_ZOOM_PROPERTY
Property name that indicates the default zoom level of the image has changed- See Also:
-
TRANSLATION_PROPERTY
Property name that indicates the image has been translated- See Also:
-
-
Constructor Details
-
ImagePanel
public ImagePanel()Create an empty NavigableImagePanel -
ImagePanel
Create an NavigableImagePanel with the specified image- Parameters:
image
- the image
-
-
Method Details
-
setImage
Set the image this panel should display- Parameters:
image
- the new image to display
-
getImage
Get the currently-displayed image- Returns:
- the current image
-
setImageBackgroundColor
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
Get the current background color of this panel- Returns:
- the background color
-
setText
Deprecated, for removal: This API element is subject to removal in a future version.unusedUnused- Parameters:
text
- unused
-
getText
Deprecated, for removal: This API element is subject to removal in a future version.unusedUnused- 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 assetZoomFactor(float)
- Parameters:
zoom
- the zoom- See Also:
-
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
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
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
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)
-