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 String
FILENAME
the name of the props file.protected ColorPickerDialog
m_DialogColorPicker
the color picker dialog.protected ImageFileChooser
m_FileChooser
the file chooser for the pictures.protected boolean
m_ImagingModulePresent
whether adams-imaging is present.protected JMenuBar
m_MenuBar
the menu bar, if used.protected JMenuItem
m_MenuItemEditCopy
the menu item "copy".protected JCheckBoxMenuItem
m_MenuItemEditEnableUndo
the menu item "enable undo".protected JMenuItem
m_MenuItemEditRedo
the menu item "redo".protected JMenuItem
m_MenuItemEditUndo
the menu item "undo".protected JMenuItem
m_MenuItemFileClose
the menu item "close".protected JMenu
m_MenuItemFileLoadRecent
the "load recent" submenu.protected JMenuItem
m_MenuItemFileSaveAs
the menu item "save as".protected JMenuItem
m_MenuItemImageFlipHorizontally
the menu item "flip horizontally".protected JMenuItem
m_MenuItemImageFlipVertically
the menu item "flip vertically".protected JMenuItem
m_MenuItemImagePickColor
the menu item "pick color".protected JMenuItem
m_MenuItemImageRotateLeft
the menu item "rotate left".protected JMenuItem
m_MenuItemImageRotateRight
the menu item "rotate right".protected JMenuItem
m_MenuItemViewBackgroundColor
the menu item "background color".protected JMenuItem
m_MenuItemViewRemoveOverlays
the menu item "remove overlays".protected JMenuItem
m_MenuItemViewShowLog
the menu item "show log".protected JMenuItem
m_MenuItemViewShowProperties
the menu item "show properties".protected JMenuItem
m_MenuItemViewZoomIn
the menu item "zoom in".protected JMenuItem
m_MenuItemViewZoomOut
the menu item "zoom out".protected JMenu
m_MenuViewZoom
the menu "zoom".protected ImageMultiPagePane
m_MultiPagePane
the tabbed pane with the images.protected ImageViewerPluginManager
m_PluginManager
for managing the plugins.protected PopupMenuCustomizer
m_PopupMenuCustomizer
an optional customizer for the right-click popup.protected static Properties
m_Properties
the properties.protected RecentFilesHandlerWithCommandline<JMenu>
m_RecentFilesHandler
the recent files handler.protected ImageViewerPanel
m_Self
the panel itself.protected TitleGenerator
m_TitleGenerator
for generating the title.static String
SESSION_FILE
the 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 void
applyJAITransformer(String cmd, String operation)
Applies a JAI transformer.protected void
chooseBackgroundColor()
Lets the user select the background color for the image.protected void
close()
Closes the current image.protected void
copy()
Copies the current image to the clipboard.protected void
exit()
Exits the viewer.protected void
flip(boolean horizontal)
Flips the image.ImagePanel[]
getAllPanels()
Returns all the image panels.File
getCurrentFile()
Returns the current filename.BufferedImage
getCurrentImage()
Returns the underlying image.ImagePanel
getCurrentPanel()
Returns the image panel in the currently selected tab.File
getFileAt(int index)
Returns the current filename.BufferedImage
getImageAt(int index)
Returns the underlying image.JMenuBar
getMenuBar()
Creates a menu bar (singleton per panel object).ImagePanel
getPanelAt(int index)
Returns the image panel of the specified tab.BasePopupMenu
getPopupMenu(MouseEvent e)
Returns the popup menu, potentially customized.PopupMenuCustomizer
getPopupMenuCustomizer()
Returns the current customizer, can be null.static Properties
getProperties()
Returns the properties that define the editor.Class[]
getSendToClasses()
Returns the classes that the supporter generates.Object
getSendToItem(Class[] cls)
Returns the object to send.TitleGenerator
getTitleGenerator()
Returns the title generator in use.boolean
hasSendToItem(Class[] cls)
Checks whether something to send is available.protected void
initGUI()
Initializes the widgets.protected void
initialize()
Initializes the members.void
load(File file)
Loads the specified file in a new panel.void
load(File file, ImageReader reader)
Loads the specified file in a new panel.protected void
open()
Opens an image.protected void
pickColor()
Allows the user to pick a color.void
redo()
performs a redo if possible.protected void
removeOverlays()
Removes all image overlays.protected void
rotate(boolean left)
Rotates the image.protected void
saveAs()
Saves the current image under a new name.void
setPopupMenuCustomizer(PopupMenuCustomizer value)
Sets the class to customize the right-click popup menu.void
undo()
performs an undo if possible.protected void
update()
Updates the title and menu.protected void
updateMenu()
updates the enabled state of the menu items.protected void
updateTitle()
Updats the title of the dialog/frame if applicable.protected void
zoom(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:
initialize
in 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:
getCurrentPanel
in 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:
getMenuBar
in 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:
getSendToClasses
in interfaceSendToActionSupporter
- Returns:
- the classes
-
hasSendToItem
public boolean hasSendToItem(Class[] cls)
Checks whether something to send is available.- Specified by:
hasSendToItem
in 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:
getSendToItem
in 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
-
-