jview
Class JImageSlice

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by jview.JImageSlice
All Implemented Interfaces:
MouseMotionListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, PropertyAware, PropertyComposed

public class JImageSlice
extends JComponent
implements MouseMotionListener, PropertyChangeListener, PropertyComposed

The mouse follows the cursor and takes a slice of the viewport image assigned to the parent viewport.

See Also:
Serialized Form

Nested Class Summary
 
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
private  JViewportCanvas canvas
          The reference to the viewport.
private  Point2D center
          Normalized coordinates of last mouse move.
private static boolean DEFWORKBACKGROUND
          Per default, we work on the background.
private static int DEFXSLICE
          Default slice size.
private static int DEFYSLICE
          Default slice size.
private static boolean DEFZOOMDISPLAYED
          Per default, we do not consider image zooms on display.
private static int DEFZOOMSLICE
          Default image slice zoom factor.
private  PropertySupplying info
          My properties.
static String KEY_WORKBACKGROUND
          Work on background or on viewport image.
static String KEY_XSLICE
          Image slice size and display size
static String KEY_YSLICE
          Image slice size and display size
static String KEY_ZOOMDISPLAYED
          If true, consider display zoom of sliced image
static String KEY_ZOOMSLICE
          The zoom factor on the image slice.
private  Dimension mysize
          My size for convenience.
private  Dimension myslice
          My slice size for convenience.
private  BufferedImage slice
          The buffered image from the viewport.
private  Rectangle slicesize
          And the size.
 
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
JImageSlice(JViewportCanvas view)
          Constructs a new image slice from a viewport component.
 
Method Summary
 PropertySupplying getComposedProperties()
          Returns my properties.
 Dimension getMaximumSize()
          Returns the slice size.
 Dimension getMinimumSize()
          Returns the slice size.
 Dimension getPreferredSize()
          Returns the slice size.
 void mouseDragged(MouseEvent me)
          Called when the maous is dragged.
 void mouseMoved(MouseEvent me)
          Called when the mouse is moved.
 void paintComponent(Graphics g)
          Paints the component.
 void propertyChange(PropertyChangeEvent e)
          Notified when a viewport image has changed.
 void setComposedProperties(PropertySupplying prop)
          Constitutes my properties.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, 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, updateUI
 
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

KEY_XSLICE

public static final String KEY_XSLICE
Image slice size and display size

See Also:
Constant Field Values

KEY_YSLICE

public static final String KEY_YSLICE
Image slice size and display size

See Also:
Constant Field Values

KEY_ZOOMSLICE

public static final String KEY_ZOOMSLICE
The zoom factor on the image slice.

See Also:
Constant Field Values

KEY_WORKBACKGROUND

public static final String KEY_WORKBACKGROUND
Work on background or on viewport image.

See Also:
Constant Field Values

KEY_ZOOMDISPLAYED

public static final String KEY_ZOOMDISPLAYED
If true, consider display zoom of sliced image

See Also:
Constant Field Values

DEFXSLICE

private static final int DEFXSLICE
Default slice size.

See Also:
Constant Field Values

DEFYSLICE

private static final int DEFYSLICE
Default slice size.

See Also:
Constant Field Values

DEFZOOMSLICE

private static final int DEFZOOMSLICE
Default image slice zoom factor.

See Also:
Constant Field Values

DEFWORKBACKGROUND

private static final boolean DEFWORKBACKGROUND
Per default, we work on the background.

See Also:
Constant Field Values

DEFZOOMDISPLAYED

private static final boolean DEFZOOMDISPLAYED
Per default, we do not consider image zooms on display.

See Also:
Constant Field Values

info

private PropertySupplying info
My properties.


canvas

private JViewportCanvas canvas
The reference to the viewport.


slice

private BufferedImage slice
The buffered image from the viewport.


slicesize

private Rectangle slicesize
And the size.


mysize

private Dimension mysize
My size for convenience.


myslice

private Dimension myslice
My slice size for convenience.


center

private Point2D center
Normalized coordinates of last mouse move.

Constructor Detail

JImageSlice

public JImageSlice(JViewportCanvas view)
Constructs a new image slice from a viewport component. We register to the component as a mouse listener and a property change listener.

Method Detail

setComposedProperties

public void setComposedProperties(PropertySupplying prop)
Constitutes my properties.

Specified by:
setComposedProperties in interface PropertyAware

getComposedProperties

public PropertySupplying getComposedProperties()
Returns my properties.

Specified by:
getComposedProperties in interface PropertyComposed

getPreferredSize

public Dimension getPreferredSize()
Returns the slice size.

Overrides:
getPreferredSize in class JComponent

getMaximumSize

public Dimension getMaximumSize()
Returns the slice size.

Overrides:
getMaximumSize in class JComponent

getMinimumSize

public Dimension getMinimumSize()
Returns the slice size.

Overrides:
getMinimumSize in class JComponent

propertyChange

public void propertyChange(PropertyChangeEvent e)
Notified when a viewport image has changed.

Specified by:
propertyChange in interface PropertyChangeListener

mouseMoved

public void mouseMoved(MouseEvent me)
Called when the mouse is moved.

Specified by:
mouseMoved in interface MouseMotionListener

mouseDragged

public void mouseDragged(MouseEvent me)
Called when the maous is dragged. We do nothing here.

Specified by:
mouseDragged in interface MouseMotionListener

paintComponent

public void paintComponent(Graphics g)
Paints the component.

Overrides:
paintComponent in class JComponent