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:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
public class ImagePanel extends javax.swing.JPanel
Creates a panel that displays anImage
. 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
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description static float
DEFAULT_ZOOM_FACTOR
static java.lang.String
DEFAULT_ZOOM_PROPERTY
Property name that indicates the default zoom level of the image has changedstatic java.lang.String
IMAGE_PROPERTY
Property name that indicates the image displayed by this panel has changedstatic java.lang.String
TRANSLATION_PROPERTY
Property name that indicates the image has been translatedprotected static int
ZOOM_FACTOR_INDEX_DEFAULT
static float[]
ZOOM_LEVELS
static java.lang.String
ZOOM_PROPERTY
Property name that indicates the zoom level of the image has changedprotected 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
-
-
Constructor Summary
Constructors Constructor Description ImagePanel()
Create an empty NavigableImagePanelImagePanel(java.awt.Image image)
Create an NavigableImagePanel with the specified image
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canZoomIn()
Determine if the image can zoom in further based on current magnification levelsboolean
canZoomOut()
Determine if the image can zoom out further based on current magnification levelsfloat
getDefaultZoomFactor()
Get the default zoom leveljava.awt.Image
getImage()
Get the currently-displayed imagejava.awt.Color
getImageBackgroundColor()
Get the current background color of this paneljava.lang.String
getText()
java.awt.Point
getTranslation()
Get the X-Y distance the image has movedfloat
getZoomFactor()
Get the current zoom factor the image is being drawn toboolean
isImageTranslationEnabled()
boolean
isImageZoomEnabled()
boolean
isTranslated()
Determine if the image has been moved from its original locationvoid
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 assetZoomFactor(float)
void
setImage(java.awt.Image image)
Set the image this panel should displayvoid
setImageBackgroundColor(java.awt.Color color)
Set the background color of the panel.void
setImageTranslationEnabled(boolean enabled)
void
setImageZoomEnabled(boolean enabled)
void
setText(java.lang.String text)
void
setZoomFactor(float zoom)
Set the magnification factor of the image.void
zoomIn()
Enlarge the image about the image centervoid
zoomIn(java.awt.Point center)
Enlarge the image about the given pointvoid
zoomOut()
Shrink the image about the image centervoid
zoomOut(java.awt.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
-
-
-
-
Field Detail
-
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 java.lang.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 java.lang.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 java.lang.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 java.lang.String TRANSLATION_PROPERTY
Property name that indicates the image has been translated- See Also:
- Constant Field Values
-
-
Method Detail
-
setImage
public void setImage(java.awt.Image image)
Set the image this panel should display- Parameters:
image
- the new image to display
-
getImage
public java.awt.Image getImage()
Get the currently-displayed image- Returns:
- the current image
-
setImageBackgroundColor
public void setImageBackgroundColor(java.awt.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 java.awt.Color getImageBackgroundColor()
Get the current background color of this panel- Returns:
- the background color
-
setText
public void setText(java.lang.String text)
-
getText
public java.lang.String getText()
-
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
-
-
getDefaultZoomFactor
public float getDefaultZoomFactor()
Get the default zoom level- Returns:
-
setDefaultZoomFactor
public void setDefaultZoomFactor(float zoom)
Set the default zoom level, adhering to the same set of constrains assetZoomFactor(float)
- Parameters:
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(java.awt.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(java.awt.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 java.awt.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)
-
-