CADI.Viewer.Display
Class DisplayPane

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 CADI.Viewer.Display.DisplayPane
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class DisplayPane
extends javax.swing.JPanel
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

This class implements a panel where the images will be displayed. When image size is greater than the displayer panel, scrolling is supporting automatically.

This class needs an object of the parent because when a region size is selected a new window of interest must be requested. This request is performed through a method of the parent object.

Usage example:
  constructor
  setThumbnailDisplayer
  displayImage
  clear || setAction || increaseResolutionLevel || decreaseResolutionLevel || increaseQualityLayer || decreaseQualityLayer

Version:
1.0 2007/12/15
Author:
Group on Interactive Coding of Images (GICI)
See Also:
Serialized Form

Nested Class Summary
(package private)  class DisplayPane.Displayer
          This class implements the drawing area where image will be displayed.
(package private)  class DisplayPane.ScrollBarsAdjustmentListener
          This class is used to manage the scroll bars adjustment listener.
 
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
private  int action
          Indicates the action which is doing on the displayer.
private  java.awt.Cursor cursor
          Indicates the cursor type used into the image area.
private  DisplayPane.Displayer displayer
          Is the panel where images will be displayed, i.e. the drawing area.
private  int[] fsiz
          Frame size
private  int height
          Height of the panel.
private  javax.swing.JScrollBar horizontalScrollBar
          Horizontal scroll bar of the scroll pane
private  java.awt.Image image
          Image to be displayer
private  ImageData imageData
           
private  DisplayPane.ScrollBarsAdjustmentListener listener
          Scroll bars listener
static int NOTHING
           
static int PANNING
           
private  java.awt.Point panningOrigin
          Contains the initial mouse coordinates when a panning is being done.
private  javax.swing.JFrame parent
          Reference to the parent object.
private  int[] roff
          Region offset
private  int[] rsiz
          Region size
private  javax.swing.JScrollPane scroller
          Is a scroll pane where the displayer will be placed.
static int SELECTING
           
private  java.awt.Rectangle selectionArea
          Contains the rectangle coordinates (upper left corner, width and height) of the selected area on the Image Display Area.
private  java.awt.Color selectionAreaColor
          Indicates the color that will be used when a window of interes is selected
private  ThumbnailDisplay thumbnailDisplay
          Reference to the thumbnail display panel.
private  javax.swing.JScrollBar verticalScrollBar
          Vertical scroll bar of the scroll pane
static int WAITING
           
private  int width
          Width of the panel.
 
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
DisplayPane(javax.swing.JFrame parent, int width, int height, ImageData imageData)
          Constructor.
 
Method Summary
 void clear()
          Clears the thumbnail display.
 void decreaseQualityLayer()
          Reduce the quality layer reducing the of the recovered image.
 void decreaseResolutionLevel()
          Decreases the frame size.
 void displayImage(java.awt.image.BufferedImage bufImage, int[] fsiz, int[] roff, int[] rsiz)
          Displays an image in the displayer.
 java.awt.Dimension getViewportSize()
          Returns the current size of the image scroll pane's view port (the size of the image display area)
 void increaseQualityLayer()
          Gets a new quality layer to improve the quality of the recovered image..
 void increaseResolutionLevel()
          Increases the frame size.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void rePaintImage()
          This method forces to displayed image to be repainted.
 void setAction(int action)
          Set the action which is doing in the display pane.
 void setThumbnailDisplayer(ThumbnailDisplay thumbnailDisplay)
          Sets a reference to the thumbnail display panel.
 
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, 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

parent

private javax.swing.JFrame parent
Reference to the parent object.


width

private int width
Width of the panel.


height

private int height
Height of the panel.


image

private java.awt.Image image
Image to be displayer


imageData

private ImageData imageData

fsiz

private int[] fsiz
Frame size


roff

private int[] roff
Region offset


rsiz

private int[] rsiz
Region size


thumbnailDisplay

private ThumbnailDisplay thumbnailDisplay
Reference to the thumbnail display panel. It is used to update the panner, therefore, only the ThumbnailDisplay.movePanner(int, int, int, int, int, int) method is used.


action

private int action
Indicates the action which is doing on the displayer. The cursor type (see cursor) will change depending of the value of this attribue. The allowed values are:


NOTHING

public static int NOTHING

PANNING

public static int PANNING

SELECTING

public static int SELECTING

WAITING

public static int WAITING

scroller

private javax.swing.JScrollPane scroller
Is a scroll pane where the displayer will be placed.


horizontalScrollBar

private javax.swing.JScrollBar horizontalScrollBar
Horizontal scroll bar of the scroll pane

See Also:
scroller

verticalScrollBar

private javax.swing.JScrollBar verticalScrollBar
Vertical scroll bar of the scroll pane

See Also:
scroller

displayer

private DisplayPane.Displayer displayer
Is the panel where images will be displayed, i.e. the drawing area.


cursor

private java.awt.Cursor cursor
Indicates the cursor type used into the image area. The allowed values are:
Cursor.MOVE_CURSOR for doing a panning
Cursor.DEFAULT_CURSOR for the default cursor
Cursor.CROSSHAIR_CURSOR for selecting a image region

The default cursor value is Cursor.DEFAULT_CURSOR


selectionArea

private java.awt.Rectangle selectionArea
Contains the rectangle coordinates (upper left corner, width and height) of the selected area on the Image Display Area.


selectionAreaColor

private final java.awt.Color selectionAreaColor
Indicates the color that will be used when a window of interes is selected

See Also:
selectionArea

panningOrigin

private java.awt.Point panningOrigin
Contains the initial mouse coordinates when a panning is being done.


listener

private DisplayPane.ScrollBarsAdjustmentListener listener
Scroll bars listener

Constructor Detail

DisplayPane

public DisplayPane(javax.swing.JFrame parent,
                   int width,
                   int height,
                   ImageData imageData)
Constructor.

Parameters:
parent - reference to the parent window
width - width of the panel
height - height of the panel
Method Detail

setThumbnailDisplayer

public void setThumbnailDisplayer(ThumbnailDisplay thumbnailDisplay)
Sets a reference to the thumbnail display panel.

Parameters:
thumbnailDisplay - reference to the thumbnail display panel.

displayImage

public void displayImage(java.awt.image.BufferedImage bufImage,
                         int[] fsiz,
                         int[] roff,
                         int[] rsiz)
Displays an image in the displayer.

Parameters:
bufImage - the image to be displayed.

rePaintImage

public void rePaintImage()
This method forces to displayed image to be repainted.


clear

public void clear()
Clears the thumbnail display.


setAction

public void setAction(int action)
Set the action which is doing in the display pane. This actions are:

Moreover, the cursor type changes according to the action.

Parameters:
action - definition in action.
See Also:
action

increaseResolutionLevel

public void increaseResolutionLevel()
Increases the frame size.


decreaseResolutionLevel

public void decreaseResolutionLevel()
Decreases the frame size.


increaseQualityLayer

public void increaseQualityLayer()
Gets a new quality layer to improve the quality of the recovered image..


decreaseQualityLayer

public void decreaseQualityLayer()
Reduce the quality layer reducing the of the recovered image.


getViewportSize

public java.awt.Dimension getViewportSize()
Returns the current size of the image scroll pane's view port (the size of the image display area)

Returns:
The size of the image display area

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener


CADI - Copyright (C) 2007
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Group on Interactive Coding of Images (GICI) (contact)