CubeTwister 2.0alpha142 2012-02-11

ch.randelshofer.gui
Class JImageWell

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by ch.randelshofer.gui.JImageWell
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, org.jhotdraw.gui.EditableComponent

public class JImageWell
extends javax.swing.JComponent
implements org.jhotdraw.gui.EditableComponent

JImageWell.

Version:
2.3.2 2010-01-10 Loading an image using the load menu did not work.
2.3.1 2010-01-04 Don't excessively recreate thumbnail.
2.2 2009-12-31 Added text property. Added busy icon.
2.1.2 2009-12-30 Removed PictImageReader.
2.1.1 2009-03-21 Increased insets for image rect.
2.1 2008-12-20 Show wait cursor while loading image.
2.0 2008-03-18 Implemented support for TransferHandler, improved usability of preview dialog.
1.0 January 6, 2006 Created.
Author:
Werner Randelshofer
See Also:
Serialized Form

Nested Class Summary
 
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
static java.lang.String BUSY_PROPERTY
           
static java.lang.String TEXT_PROPERTY
           
 
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 org.jhotdraw.gui.EditableComponent
SELECTION_EMPTY_PROPERTY
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JImageWell()
          Creates a new instance.
JImageWell(ImageWellModel m)
          Constructs a DnDJList with the specified MutableListModel.
 
Method Summary
 void clearSelection()
          Selects nothing.
 void copy()
           
 javax.swing.JPopupMenu createPopupMenu()
           
 void cut()
           
 void delete()
          Deletes the selected components or the component at (or after) the caret position.
 void duplicate()
          Duplicates the selected region.
 java.awt.Image getImage()
          Convenience method for getting an image from the model.
 ImageWellModel getModel()
           
 int getPermittedDragActions()
          This method returns an int representing the type of drag action(s) this DnDJList supports.
 int getPermittedDropActions()
          This method returns an int representing the type of drop action(s) this DnDJList supports.
 java.lang.String getText()
           
protected  boolean importTransferable(java.awt.datatransfer.Transferable transferable, int dropAction)
           
 boolean isDroppable()
           
protected  boolean isImportable(java.awt.datatransfer.DataFlavor[] flavors, int dropAction)
           
 boolean isSelectionEmpty()
          Returns true if the selection is empty.
 void loadImage()
           
 void paintComponent(java.awt.Graphics gr)
           
 void paste()
           
protected  byte[] readFile(java.io.File f)
           
protected  byte[] readImage(java.awt.Image img)
           
protected  byte[] readStream(java.io.InputStream in)
           
 void removeNotify()
           
 void repaintThumbnail()
           
 void saveImage()
           
 void selectAll()
          Selects all.
 void setImage(java.awt.Image newValue)
          Convenience method for setting an image in the model.
 void setModel(ImageWellModel newValue)
           
 void setPermittedDragActions(int actions)
          This method sets the permitted source drag action(s) for this DnDJList.
 void setPermittedDropActions(int actions)
          This method sets the permitted target drop action(s) for this DnDJList.
 void setText(java.lang.String newValue)
           
 
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, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, 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, 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
 
Methods inherited from interface org.jhotdraw.gui.EditableComponent
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

BUSY_PROPERTY

public static final java.lang.String BUSY_PROPERTY
See Also:
Constant Field Values

TEXT_PROPERTY

public static final java.lang.String TEXT_PROPERTY
See Also:
Constant Field Values
Constructor Detail

JImageWell

public JImageWell()
Creates a new instance.


JImageWell

public JImageWell(ImageWellModel m)
Constructs a DnDJList with the specified MutableListModel.

Method Detail

isSelectionEmpty

public boolean isSelectionEmpty()
Description copied from interface: org.jhotdraw.gui.EditableComponent
Returns true if the selection is empty. This is a bound property.

Specified by:
isSelectionEmpty in interface org.jhotdraw.gui.EditableComponent

getText

public java.lang.String getText()
Returns:
the text

setText

public void setText(java.lang.String newValue)
Parameters:
newValue - the text to set

createPopupMenu

public javax.swing.JPopupMenu createPopupMenu()

getModel

public ImageWellModel getModel()

setModel

public void setModel(ImageWellModel newValue)

paintComponent

public void paintComponent(java.awt.Graphics gr)
Overrides:
paintComponent in class javax.swing.JComponent

removeNotify

public void removeNotify()
Overrides:
removeNotify in class javax.swing.JComponent

setPermittedDragActions

public void setPermittedDragActions(int actions)
This method sets the permitted source drag action(s) for this DnDJList.

This is a bound property.

Parameters:
actions - the permitted source drag action(s). The value is constructed by doing a logical OR of the desired actions specified by the DnDConstants.ACTION_... constants.
See Also:
DnDConstants

getPermittedDragActions

public int getPermittedDragActions()
This method returns an int representing the type of drag action(s) this DnDJList supports.

Returns:
the currently permitted drag action(s) The value is constructed by doing a logical OR of the desired actions specified by the DnDConstants.ACTION_... constants.
See Also:
DnDConstants

setPermittedDropActions

public void setPermittedDropActions(int actions)
This method sets the permitted target drop action(s) for this DnDJList.

Parameters:
actions - the permitted target drop action(s). The value is constructed by doing a logical OR of the desired actions specified by the DnDConstants.ACTION_... constants.
See Also:
DnDConstants

getPermittedDropActions

public int getPermittedDropActions()
This method returns an int representing the type of drop action(s) this DnDJList supports.

Returns:
the currently permitted drop action(s) The value is constructed by doing a logical OR of the desired actions specified by the DnDConstants.ACTION_... constants.
See Also:
DnDConstants

isDroppable

public boolean isDroppable()

isImportable

protected boolean isImportable(java.awt.datatransfer.DataFlavor[] flavors,
                               int dropAction)

importTransferable

protected boolean importTransferable(java.awt.datatransfer.Transferable transferable,
                                     int dropAction)

readFile

protected byte[] readFile(java.io.File f)
                   throws java.io.IOException
Throws:
java.io.IOException

readStream

protected byte[] readStream(java.io.InputStream in)
                     throws java.io.IOException
Throws:
java.io.IOException

readImage

protected byte[] readImage(java.awt.Image img)
                    throws java.io.IOException
Throws:
java.io.IOException

copy

public void copy()

cut

public void cut()

delete

public void delete()
Description copied from interface: org.jhotdraw.gui.EditableComponent
Deletes the selected components or the component at (or after) the caret position.

Specified by:
delete in interface org.jhotdraw.gui.EditableComponent

paste

public void paste()

saveImage

public void saveImage()

loadImage

public void loadImage()

setImage

public void setImage(java.awt.Image newValue)
Convenience method for setting an image in the model. Note that "image" is not a bound property. This method is used by the TransferHandler of JImageWell.

Parameters:
newValue -

getImage

public java.awt.Image getImage()
Convenience method for getting an image from the model. Note that "image" is not a bound property. This method is used by the TransferHandler of JImageWell.


duplicate

public void duplicate()
Description copied from interface: org.jhotdraw.gui.EditableComponent
Duplicates the selected region.

Specified by:
duplicate in interface org.jhotdraw.gui.EditableComponent

selectAll

public void selectAll()
Description copied from interface: org.jhotdraw.gui.EditableComponent
Selects all.

Specified by:
selectAll in interface org.jhotdraw.gui.EditableComponent

repaintThumbnail

public void repaintThumbnail()

clearSelection

public void clearSelection()
Description copied from interface: org.jhotdraw.gui.EditableComponent
Selects nothing.

Specified by:
clearSelection in interface org.jhotdraw.gui.EditableComponent

(c) Werner Randelshofer.
All rights reserved.