uk.ac.essex.common.gui.panel
Class ImagePane

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 uk.ac.essex.common.gui.panel.ImagePane
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, Focusable
Direct Known Subclasses:
IVImagePane

public class ImagePane
extends javax.swing.JPanel
implements Focusable

This class defines a pane to display a RenderedImage. A three-dimensional border is created to form the frame for the displayed image. When this pane/image is focused, the three-dimensional border is shown as the image is pressed.

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
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  javax.swing.border.Border compound
          Two compound border to imitate a three-dimensional effect when this pane or image gains/losses focus.
protected  javax.swing.border.Border compound1
           
protected  boolean displayCenter
          Indicates to display a red cross at the center of the pane or not.
protected  java.lang.String imageName
          The image name may be displayed as the title of this pane when the border is a titled border.
protected  boolean isFocused
          Indicates this pane is focused or not.
protected  java.awt.Point origin
          The origin of the pane in the image coordinate system.
protected  int referenceX
          The reference point coordinates in the image coodinate system.
protected  int referenceY
           
protected  ResizePolicy resizePolicy
          The resizing policy for this pane.
protected  int shiftX
          The translation between the display coordinate system and the image coordinate system.
protected  int shiftY
           
protected  java.awt.image.RenderedImage source
          The image to be displayed
 
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
ImagePane(java.awt.image.RenderedImage image, ResizePolicy policy, java.lang.String imageName)
          Constructor accepts a uk.ac.essex.common.gui.pane.ResizePolicy.
ImagePane(java.awt.image.RenderedImage image, java.lang.String imageName)
          Constructor.
ImagePane(java.lang.String imageName)
          The default constructor.
 
Method Summary
 java.awt.image.RenderedImage getImage()
          Return the displayed image.
 java.awt.Point getReference()
          Return the position of the reference point.
 boolean isFocused()
          Return the focus status.
 void paintComponent(java.awt.Graphics g)
          The paint procedure: paint the border based on the focus status, draw the image, and draw the red cross if the flag is set.
 void set(java.awt.image.RenderedImage im)
          Replace the displayed image.
 void set(java.awt.image.RenderedImage im, java.lang.String imageName)
          Replace the displayed image and the name of this image.
 void set(java.awt.image.RenderedImage im, java.lang.String imageName, int x, int y)
          Display a new image at the new reference position.
 void setDisplayCenter(boolean b)
          Enable/disable to display the red cross at the center of this pane.
 void setFocused(boolean b)
          Set the focus flag and process the related events.
 void setReference(int x, int y)
          Change the position of the reference point.
 void setResizePolicy(ResizePolicy policy)
          Set a new resizing policy to this uk.ac.essex.common.gui.pane.ImagePane.
 
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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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

source

protected java.awt.image.RenderedImage source
The image to be displayed


imageName

protected java.lang.String imageName
The image name may be displayed as the title of this pane when the border is a titled border.


referenceX

protected int referenceX
The reference point coordinates in the image coodinate system. The position of this reference point relative to the pane is vary with the resizing policy.

See Also:
ResizePolicy

referenceY

protected int referenceY

shiftX

protected int shiftX
The translation between the display coordinate system and the image coordinate system. To be used to draw the image and transform the coordinates back to the image coordinate system.


shiftY

protected int shiftY

origin

protected java.awt.Point origin
The origin of the pane in the image coordinate system.


compound

protected javax.swing.border.Border compound
Two compound border to imitate a three-dimensional effect when this pane or image gains/losses focus.


compound1

protected javax.swing.border.Border compound1

isFocused

protected boolean isFocused
Indicates this pane is focused or not.


displayCenter

protected boolean displayCenter
Indicates to display a red cross at the center of the pane or not.


resizePolicy

protected ResizePolicy resizePolicy
The resizing policy for this pane. The default policy is

See Also:
ResizePolicy
Constructor Detail

ImagePane

public ImagePane(java.lang.String imageName)
The default constructor. It creates the three-dimensional border. Set the layout of this pane to NoLayout.

Parameters:
imageName - The RenderedImage to be displayed in this pane.

ImagePane

public ImagePane(java.awt.image.RenderedImage image,
                 java.lang.String imageName)
Constructor. Call the default constructor to define the basic geometry of this pane. Define the original position of the image to be displayed, the preferred size of the pane and the position of the reference point based on the uk.ac.essex.common.gui.pane.ResizePolicy, the image size and the pane size.

Parameters:
image - The RenderedImage to be displayed in this pane.
imageName - The name of the provided image.

ImagePane

public ImagePane(java.awt.image.RenderedImage image,
                 ResizePolicy policy,
                 java.lang.String imageName)
Constructor accepts a uk.ac.essex.common.gui.pane.ResizePolicy.

Parameters:
image - The RenderedImage for display in this pane.
policy - The policy to move the image when this pane is resized.
imageName - The name of the provided image.
Method Detail

setResizePolicy

public void setResizePolicy(ResizePolicy policy)
Set a new resizing policy to this uk.ac.essex.common.gui.pane.ImagePane.

Parameters:
policy - The new resizing policy for the display.

setReference

public void setReference(int x,
                         int y)
Change the position of the reference point.

Parameters:
x - The x coordinate of the new reference in the image coordinate system.
y - The y coordinate of the new reference in the image coordinate system.

getReference

public java.awt.Point getReference()
Return the position of the reference point.

Returns:
Return the coordinate of the reference point in the image coordinate system.

set

public void set(java.awt.image.RenderedImage im)
Replace the displayed image.

Parameters:
im - The new image for display.

set

public void set(java.awt.image.RenderedImage im,
                java.lang.String imageName)
Replace the displayed image and the name of this image.

Parameters:
im - The new image for display.
imageName - The image name.

set

public void set(java.awt.image.RenderedImage im,
                java.lang.String imageName,
                int x,
                int y)
Display a new image at the new reference position.


getImage

public java.awt.image.RenderedImage getImage()
Return the displayed image.


setFocused

public void setFocused(boolean b)
Set the focus flag and process the related events. Override the method defined in the interface uk.ac.essex.common.gui.pane.Focusable.

Specified by:
setFocused in interface Focusable
See Also:
Focusable

isFocused

public boolean isFocused()
Return the focus status. Override the method defined in the interface uk.ac.essex.common.gui.pane.Focusable .

Specified by:
isFocused in interface Focusable
See Also:
Focusable

setDisplayCenter

public void setDisplayCenter(boolean b)
Enable/disable to display the red cross at the center of this pane.


paintComponent

public void paintComponent(java.awt.Graphics g)
The paint procedure: paint the border based on the focus status, draw the image, and draw the red cross if the flag is set.

Overrides:
paintComponent in class javax.swing.JComponent