Package adams.gui.visualization.image
Class ImageViewerPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- adams.gui.core.BasePanel
-
- adams.gui.visualization.image.ImageViewerPanel
-
- All Implemented Interfaces:
MenuBarProvider,ToolPluginSupporter<ImagePanel>,SendToActionSupporter,ImageObserver,MenuContainer,Serializable,Accessible
public class ImageViewerPanel extends BasePanel implements MenuBarProvider, SendToActionSupporter, ToolPluginSupporter<ImagePanel>
A simple image viewer.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- 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 StringFILENAMEthe name of the props file.protected ColorPickerDialogm_DialogColorPickerthe color picker dialog.protected ImageFileChooserm_FileChooserthe file chooser for the pictures.protected booleanm_ImagingModulePresentwhether adams-imaging is present.protected JMenuBarm_MenuBarthe menu bar, if used.protected JMenuItemm_MenuItemEditCopythe menu item "copy".protected JCheckBoxMenuItemm_MenuItemEditEnableUndothe menu item "enable undo".protected JMenuItemm_MenuItemEditRedothe menu item "redo".protected JMenuItemm_MenuItemEditUndothe menu item "undo".protected JMenuItemm_MenuItemFileClosethe menu item "close".protected JMenum_MenuItemFileLoadRecentthe "load recent" submenu.protected JMenuItemm_MenuItemFileSaveAsthe menu item "save as".protected JMenuItemm_MenuItemImageFlipHorizontallythe menu item "flip horizontally".protected JMenuItemm_MenuItemImageFlipVerticallythe menu item "flip vertically".protected JMenuItemm_MenuItemImagePickColorthe menu item "pick color".protected JMenuItemm_MenuItemImageRotateLeftthe menu item "rotate left".protected JMenuItemm_MenuItemImageRotateRightthe menu item "rotate right".protected JMenuItemm_MenuItemViewBackgroundColorthe menu item "background color".protected JMenuItemm_MenuItemViewRemoveOverlaysthe menu item "remove overlays".protected JMenuItemm_MenuItemViewShowLogthe menu item "show log".protected JMenuItemm_MenuItemViewShowPropertiesthe menu item "show properties".protected JMenuItemm_MenuItemViewZoomInthe menu item "zoom in".protected JMenuItemm_MenuItemViewZoomOutthe menu item "zoom out".protected JMenum_MenuViewZoomthe menu "zoom".protected ImageMultiPagePanem_MultiPagePanethe tabbed pane with the images.protected ImageViewerPluginManagerm_PluginManagerfor managing the plugins.protected PopupMenuCustomizerm_PopupMenuCustomizeran optional customizer for the right-click popup.protected static Propertiesm_Propertiesthe properties.protected RecentFilesHandlerWithCommandline<JMenu>m_RecentFilesHandlerthe recent files handler.protected ImageViewerPanelm_Selfthe panel itself.protected TitleGeneratorm_TitleGeneratorfor generating the title.static StringSESSION_FILEthe file to store the recent files in.-
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 ImageViewerPanel()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidapplyJAITransformer(String cmd, String operation)Applies a JAI transformer.protected voidchooseBackgroundColor()Lets the user select the background color for the image.protected voidclose()Closes the current image.protected voidcopy()Copies the current image to the clipboard.protected voidexit()Exits the viewer.protected voidflip(boolean horizontal)Flips the image.ImagePanel[]getAllPanels()Returns all the image panels.FilegetCurrentFile()Returns the current filename.BufferedImagegetCurrentImage()Returns the underlying image.ImagePanelgetCurrentPanel()Returns the image panel in the currently selected tab.FilegetFileAt(int index)Returns the current filename.BufferedImagegetImageAt(int index)Returns the underlying image.JMenuBargetMenuBar()Creates a menu bar (singleton per panel object).ImagePanelgetPanelAt(int index)Returns the image panel of the specified tab.BasePopupMenugetPopupMenu(MouseEvent e)Returns the popup menu, potentially customized.PopupMenuCustomizergetPopupMenuCustomizer()Returns the current customizer, can be null.static PropertiesgetProperties()Returns the properties that define the editor.Class[]getSendToClasses()Returns the classes that the supporter generates.ObjectgetSendToItem(Class[] cls)Returns the object to send.TitleGeneratorgetTitleGenerator()Returns the title generator in use.booleanhasSendToItem(Class[] cls)Checks whether something to send is available.protected voidinitGUI()Initializes the widgets.protected voidinitialize()Initializes the members.voidload(File file)Loads the specified file in a new panel.voidload(File file, ImageReader reader)Loads the specified file in a new panel.protected voidopen()Opens an image.protected voidpickColor()Allows the user to pick a color.voidredo()performs a redo if possible.protected voidremoveOverlays()Removes all image overlays.protected voidrotate(boolean left)Rotates the image.protected voidsaveAs()Saves the current image under a new name.voidsetPopupMenuCustomizer(PopupMenuCustomizer value)Sets the class to customize the right-click popup menu.voidundo()performs an undo if possible.protected voidupdate()Updates the title and menu.protected voidupdateMenu()updates the enabled state of the menu items.protected voidupdateTitle()Updats the title of the dialog/frame if applicable.protected voidzoom(int zoom)Zooms in/out.-
Methods inherited from class adams.gui.core.BasePanel
afterHide, afterShow, beforeHide, beforeShow, closeParent, finishInit, getParentChild, getParentDialog, getParentFrame, getParentInternalFrame, getParentTitle, initFileChooser, main, printErrorMessage, printException, saveComponent, setEnabledCascade, setEnabledCascade, setParentTitle, setVisible
-
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, 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
-
FILENAME
public static final String FILENAME
the name of the props file.- See Also:
- Constant Field Values
-
SESSION_FILE
public static final String SESSION_FILE
the file to store the recent files in.- See Also:
- Constant Field Values
-
m_Properties
protected static Properties m_Properties
the properties.
-
m_Self
protected ImageViewerPanel m_Self
the panel itself.
-
m_FileChooser
protected ImageFileChooser m_FileChooser
the file chooser for the pictures.
-
m_PopupMenuCustomizer
protected PopupMenuCustomizer m_PopupMenuCustomizer
an optional customizer for the right-click popup.
-
m_MenuBar
protected JMenuBar m_MenuBar
the menu bar, if used.
-
m_MenuItemFileLoadRecent
protected JMenu m_MenuItemFileLoadRecent
the "load recent" submenu.
-
m_MenuItemFileSaveAs
protected JMenuItem m_MenuItemFileSaveAs
the menu item "save as".
-
m_MenuItemFileClose
protected JMenuItem m_MenuItemFileClose
the menu item "close".
-
m_MenuItemEditEnableUndo
protected JCheckBoxMenuItem m_MenuItemEditEnableUndo
the menu item "enable undo".
-
m_MenuItemEditUndo
protected JMenuItem m_MenuItemEditUndo
the menu item "undo".
-
m_MenuItemEditRedo
protected JMenuItem m_MenuItemEditRedo
the menu item "redo".
-
m_MenuItemEditCopy
protected JMenuItem m_MenuItemEditCopy
the menu item "copy".
-
m_MenuItemImageRotateLeft
protected JMenuItem m_MenuItemImageRotateLeft
the menu item "rotate left".
-
m_MenuItemImageRotateRight
protected JMenuItem m_MenuItemImageRotateRight
the menu item "rotate right".
-
m_MenuItemImageFlipHorizontally
protected JMenuItem m_MenuItemImageFlipHorizontally
the menu item "flip horizontally".
-
m_MenuItemImageFlipVertically
protected JMenuItem m_MenuItemImageFlipVertically
the menu item "flip vertically".
-
m_MenuItemImagePickColor
protected JMenuItem m_MenuItemImagePickColor
the menu item "pick color".
-
m_MenuViewZoom
protected JMenu m_MenuViewZoom
the menu "zoom".
-
m_MenuItemViewZoomIn
protected JMenuItem m_MenuItemViewZoomIn
the menu item "zoom in".
-
m_MenuItemViewZoomOut
protected JMenuItem m_MenuItemViewZoomOut
the menu item "zoom out".
-
m_MenuItemViewRemoveOverlays
protected JMenuItem m_MenuItemViewRemoveOverlays
the menu item "remove overlays".
-
m_MenuItemViewBackgroundColor
protected JMenuItem m_MenuItemViewBackgroundColor
the menu item "background color".
-
m_MenuItemViewShowProperties
protected JMenuItem m_MenuItemViewShowProperties
the menu item "show properties".
-
m_MenuItemViewShowLog
protected JMenuItem m_MenuItemViewShowLog
the menu item "show log".
-
m_PluginManager
protected ImageViewerPluginManager m_PluginManager
for managing the plugins.
-
m_MultiPagePane
protected ImageMultiPagePane m_MultiPagePane
the tabbed pane with the images.
-
m_RecentFilesHandler
protected RecentFilesHandlerWithCommandline<JMenu> m_RecentFilesHandler
the recent files handler.
-
m_TitleGenerator
protected TitleGenerator m_TitleGenerator
for generating the title.
-
m_ImagingModulePresent
protected boolean m_ImagingModulePresent
whether adams-imaging is present.
-
m_DialogColorPicker
protected ColorPickerDialog m_DialogColorPicker
the color picker dialog.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classBasePanel
-
update
protected void update()
Updates the title and menu.
-
getTitleGenerator
public TitleGenerator getTitleGenerator()
Returns the title generator in use.- Returns:
- the generator
-
updateTitle
protected void updateTitle()
Updats the title of the dialog/frame if applicable.
-
updateMenu
protected void updateMenu()
updates the enabled state of the menu items.
-
getCurrentPanel
public ImagePanel getCurrentPanel()
Returns the image panel in the currently selected tab.- Specified by:
getCurrentPanelin interfaceToolPluginSupporter<ImagePanel>- Returns:
- the image panel, null if none available
-
getPanelAt
public ImagePanel getPanelAt(int index)
Returns the image panel of the specified tab.- Parameters:
index- the tab index- Returns:
- the image panel, null if none available
-
getAllPanels
public ImagePanel[] getAllPanels()
Returns all the image panels.- Returns:
- the image panels
-
getCurrentImage
public BufferedImage getCurrentImage()
Returns the underlying image.- Returns:
- the current image, can be null
-
getImageAt
public BufferedImage getImageAt(int index)
Returns the underlying image.- Parameters:
index- the tab index- Returns:
- the current image, can be null
-
getCurrentFile
public File getCurrentFile()
Returns the current filename.- Returns:
- the current filename, can be null
-
getFileAt
public File getFileAt(int index)
Returns the current filename.- Parameters:
index- the tab index- Returns:
- the current filename, can be null
-
getMenuBar
public JMenuBar getMenuBar()
Creates a menu bar (singleton per panel object). Can be used in frames.- Specified by:
getMenuBarin interfaceMenuBarProvider- Returns:
- the menu bar
-
open
protected void open()
Opens an image.
-
load
public void load(File file)
Loads the specified file in a new panel.- Parameters:
file- the file to load
-
load
public void load(File file, ImageReader reader)
Loads the specified file in a new panel.- Parameters:
file- the file to loadreader- the reader to use, null for auto-detection
-
saveAs
protected void saveAs()
Saves the current image under a new name.
-
close
protected void close()
Closes the current image.
-
exit
protected void exit()
Exits the viewer.
-
copy
protected void copy()
Copies the current image to the clipboard.
-
applyJAITransformer
protected void applyJAITransformer(String cmd, String operation)
Applies a JAI transformer. Transformer gets applied to the current image, replacing it in the process.- Parameters:
cmd- the transformer commandlineoperation- the name of the operation, to be used in error message
-
rotate
protected void rotate(boolean left)
Rotates the image.- Parameters:
left- whether to rotate 90 degrees left
-
flip
protected void flip(boolean horizontal)
Flips the image.- Parameters:
horizontal- whether to flip horizontally
-
pickColor
protected void pickColor()
Allows the user to pick a color.
-
zoom
protected void zoom(int zoom)
Zooms in/out.- Parameters:
zoom- the zoom (in percent)
-
removeOverlays
protected void removeOverlays()
Removes all image overlays.
-
chooseBackgroundColor
protected void chooseBackgroundColor()
Lets the user select the background color for the image.
-
setPopupMenuCustomizer
public void setPopupMenuCustomizer(PopupMenuCustomizer value)
Sets the class to customize the right-click popup menu.- Parameters:
value- the customizer
-
getPopupMenuCustomizer
public PopupMenuCustomizer getPopupMenuCustomizer()
Returns the current customizer, can be null.- Returns:
- the customizer
-
getPopupMenu
public BasePopupMenu getPopupMenu(MouseEvent e)
Returns the popup menu, potentially customized.- Parameters:
e- the mouse event- Returns:
- the popup menu
- See Also:
m_PopupMenuCustomizer
-
getSendToClasses
public Class[] getSendToClasses()
Returns the classes that the supporter generates.- Specified by:
getSendToClassesin interfaceSendToActionSupporter- Returns:
- the classes
-
hasSendToItem
public boolean hasSendToItem(Class[] cls)
Checks whether something to send is available.- Specified by:
hasSendToItemin interfaceSendToActionSupporter- Parameters:
cls- the classes to retrieve an item for- Returns:
- true if an object is available for sending
-
getSendToItem
public Object getSendToItem(Class[] cls)
Returns the object to send.- Specified by:
getSendToItemin interfaceSendToActionSupporter- Parameters:
cls- the classes to retrieve the item for- Returns:
- the item to send
-
undo
public void undo()
performs an undo if possible.
-
redo
public void redo()
performs a redo if possible.
-
getProperties
public static Properties getProperties()
Returns the properties that define the editor.- Returns:
- the properties
-
-