com.ngs.image
Class ImagePanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.ngs.image.ImagePanel
All Implemented Interfaces:
ImageEventListener, ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class ImagePanel
extends JPanel
implements ImageEventListener, ActionListener

A Custom Panel for interacting with an ImageModel.

Author:
Bryan.Varner
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
 JButton btnContDn
           
 JButton btnContUp
           
 JButton btnDarken
           
 JToggleButton btnFit
           
 JToggleButton btnFitHeight
           
 JToggleButton btnFitWidth
           
 JButton btnIn
           
 JButton btnInvert
           
 JButton btnLighten
           
 JButton btnNext
           
 JButton btnOut
           
 JButton btnPrev
           
 JButton btnRotCCW
           
 JButton btnRotCW
           
protected  ImageCanvas canvas
           
 JMenuItem contrastDown
           
 JMenuItem contrastUp
           
 JMenuItem darker
           
 JCheckBoxMenuItem fitHeight
           
 JCheckBoxMenuItem fitWidth
           
 JCheckBoxMenuItem fitWindow
           
 JMenuItem invert
           
 JMenuItem lighter
           
protected  ImageModel mdlImage
           
protected  JMenu mnuImage
           
 JMenuItem nextPage
           
 JMenuItem prevPage
           
 JMenuItem rotateClockwise
           
 JMenuItem rotateCounterClockwise
           
static int SCROLL_BLOCK
           
static int SCROLL_DOWN
           
static int SCROLL_LEFT
           
static int SCROLL_RIGHT
           
static int SCROLL_UNIT
           
static int SCROLL_UP
           
protected  JScrollPane scrollPane
           
 JMenuItem toggleZoom
           
protected  JToolBar toolBar
           
 JMenuItem zoomIn
           
 JMenuItem zoomOut
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
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
ImagePanel()
           
ImagePanel(ImageModel model)
          Creates a new ImagePanel that uses the given ImageModel.
 
Method Summary
 void actionPerformed(ActionEvent ae)
          Implements ActionListener.
 void addActionListener(ActionListener al)
          Adds an ActionListener.
protected  ImageCanvas createImageCanvas()
          Allows sub-classes of ImagePanel to supply custom ImageCanvases to use as the display for Images.
 ImageCanvas getCanvas()
          Gets the ImageCanvas used to render the ImageModel.
 JMenu getMenu()
           
 ImageModel getModel()
          Gets the current ImageModel being rendered.
 Dimension getPreferredSize()
          Make sure that if we don't have a model, we're at least 400 pixels tall
 void imageChanged(ImageEvent ie)
          Implements the ImageEventListener.
 void imageError(ImageEvent ie)
          Implements the ImageEventListener.
 void removeActionListener(ActionListener al)
          Removes an ActionListener.
 void scroll(int direction, int speed)
          Programmatically scrolls based upon the given direction and speed.
 void setModel(ImageModel model)
          Sets the ImageModel to render.
 void updateToolbar()
          Updates the toolbar buttons to accurately reflect the current ImageModel state.
 
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, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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, transferFocusBackward, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SCROLL_BLOCK

public static final int SCROLL_BLOCK
See Also:
Constant Field Values

SCROLL_UNIT

public static final int SCROLL_UNIT
See Also:
Constant Field Values

SCROLL_UP

public static final int SCROLL_UP
See Also:
Constant Field Values

SCROLL_DOWN

public static final int SCROLL_DOWN
See Also:
Constant Field Values

SCROLL_LEFT

public static final int SCROLL_LEFT
See Also:
Constant Field Values

SCROLL_RIGHT

public static final int SCROLL_RIGHT
See Also:
Constant Field Values

scrollPane

protected JScrollPane scrollPane

mdlImage

protected ImageModel mdlImage

toolBar

protected JToolBar toolBar

btnPrev

public JButton btnPrev

btnNext

public JButton btnNext

btnIn

public JButton btnIn

btnOut

public JButton btnOut

btnFit

public JToggleButton btnFit

btnFitWidth

public JToggleButton btnFitWidth

btnFitHeight

public JToggleButton btnFitHeight

btnLighten

public JButton btnLighten

btnDarken

public JButton btnDarken

btnContUp

public JButton btnContUp

btnContDn

public JButton btnContDn

btnInvert

public JButton btnInvert

btnRotCW

public JButton btnRotCW

btnRotCCW

public JButton btnRotCCW

mnuImage

protected JMenu mnuImage

prevPage

public JMenuItem prevPage

nextPage

public JMenuItem nextPage

zoomIn

public JMenuItem zoomIn

zoomOut

public JMenuItem zoomOut

toggleZoom

public JMenuItem toggleZoom

invert

public JMenuItem invert

contrastUp

public JMenuItem contrastUp

contrastDown

public JMenuItem contrastDown

lighter

public JMenuItem lighter

darker

public JMenuItem darker

rotateClockwise

public JMenuItem rotateClockwise

rotateCounterClockwise

public JMenuItem rotateCounterClockwise

fitWidth

public JCheckBoxMenuItem fitWidth

fitHeight

public JCheckBoxMenuItem fitHeight

fitWindow

public JCheckBoxMenuItem fitWindow

canvas

protected ImageCanvas canvas
Constructor Detail

ImagePanel

public ImagePanel()

ImagePanel

public ImagePanel(ImageModel model)
Creates a new ImagePanel that uses the given ImageModel.

Method Detail

getMenu

public JMenu getMenu()

createImageCanvas

protected ImageCanvas createImageCanvas()
Allows sub-classes of ImagePanel to supply custom ImageCanvases to use as the display for Images.


getPreferredSize

public Dimension getPreferredSize()
Make sure that if we don't have a model, we're at least 400 pixels tall

Overrides:
getPreferredSize in class JComponent

addActionListener

public void addActionListener(ActionListener al)
Adds an ActionListener.


removeActionListener

public void removeActionListener(ActionListener al)
Removes an ActionListener.


actionPerformed

public void actionPerformed(ActionEvent ae)
Implements ActionListener. All the buttons / functions on the embedded Toolbar are processed first by the ImagePanel, then dispatched to any registered listeners.

Specified by:
actionPerformed in interface ActionListener

updateToolbar

public void updateToolbar()
Updates the toolbar buttons to accurately reflect the current ImageModel state.


setModel

public void setModel(ImageModel model)
Sets the ImageModel to render.


getModel

public ImageModel getModel()
Gets the current ImageModel being rendered.


getCanvas

public ImageCanvas getCanvas()
Gets the ImageCanvas used to render the ImageModel.


scroll

public void scroll(int direction,
                   int speed)
Programmatically scrolls based upon the given direction and speed.


imageChanged

public void imageChanged(ImageEvent ie)
Implements the ImageEventListener.

Specified by:
imageChanged in interface ImageEventListener

imageError

public void imageError(ImageEvent ie)
Implements the ImageEventListener. Any errors being emmited by the ImageModel are displayed in JOptionPane dialog boxes.

Specified by:
imageError in interface ImageEventListener