com.alee.extended.image
Class WebImageDrop

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.alee.extended.image.WebImageDrop
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class WebImageDrop
extends javax.swing.JComponent

This is a custom image drop component. It serves as a drop area for images and will display dropped image preview. You can always retrieve actual and thumbnail images from this components if there are any.

Author:
Mikle Garin
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
protected  java.awt.image.BufferedImage actualImage
          Actual image placed into WebImageDrop component.
protected  int height
          Preview image area height.
protected  java.awt.image.BufferedImage image
          Preview image.
protected  int round
          Preview image corners rounding.
protected  int width
          Preview image area width.
 
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
WebImageDrop()
          Constructs new WebImageDrop component with 64x64 preview image area size.
WebImageDrop(int width, int height)
          Constructs new WebImageDrop component with the specified preview image area size.
WebImageDrop(int width, int height, java.awt.image.BufferedImage image)
          Constructs new WebImageDrop component with the specified preview image area size and actual image.
 
Method Summary
 java.awt.image.BufferedImage getImage()
          Returns actual image.
 int getImageHeight()
          Returns preview image area height.
 int getImageWidth()
          Returns preview image area width.
 java.awt.Dimension getPreferredSize()
          
 int getRound()
          Returns preview image corners rounding.
 java.awt.image.BufferedImage getThumbnail()
          Returns preview image.
protected  void paintComponent(java.awt.Graphics g)
          
 void setImage(java.awt.image.BufferedImage image)
          Sets new displayed image.
 void setImageHeight(int height)
          Sets preview image area height.
 void setImageWidth(int width)
          Sets preview image area width.
 void setRound(int round)
          Sets preview image corners rounding.
protected  void updatePreview()
          Updates image preview.
 
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, 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

round

protected int round
Preview image corners rounding.


width

protected int width
Preview image area width.


height

protected int height
Preview image area height.


actualImage

protected java.awt.image.BufferedImage actualImage
Actual image placed into WebImageDrop component.


image

protected java.awt.image.BufferedImage image
Preview image.

Constructor Detail

WebImageDrop

public WebImageDrop()
Constructs new WebImageDrop component with 64x64 preview image area size.


WebImageDrop

public WebImageDrop(int width,
                    int height)
Constructs new WebImageDrop component with the specified preview image area size.

Parameters:
width - preview image area width
height - preview image area height

WebImageDrop

public WebImageDrop(int width,
                    int height,
                    java.awt.image.BufferedImage image)
Constructs new WebImageDrop component with the specified preview image area size and actual image.

Parameters:
width - preview image area width
height - preview image area height
image - actual image
Method Detail

getImage

public java.awt.image.BufferedImage getImage()
Returns actual image.

Returns:
actual image

getThumbnail

public java.awt.image.BufferedImage getThumbnail()
Returns preview image.

Returns:
preview image

getRound

public int getRound()
Returns preview image corners rounding.

Returns:
preview image corners rounding

setRound

public void setRound(int round)
Sets preview image corners rounding.

Parameters:
round - new preview image corners rounding

getImageWidth

public int getImageWidth()
Returns preview image area width.

Returns:
preview image area width

setImageWidth

public void setImageWidth(int width)
Sets preview image area width.

Parameters:
width - preview image area width

getImageHeight

public int getImageHeight()
Returns preview image area height.

Returns:
preview image area height

setImageHeight

public void setImageHeight(int height)
Sets preview image area height.

Parameters:
height - new preview image area height

setImage

public void setImage(java.awt.image.BufferedImage image)
Sets new displayed image. This forces a new preview image to be generated so be aware that this call does some heavy work.

Parameters:
image - new displayed image

updatePreview

protected void updatePreview()
Updates image preview.


paintComponent

protected void paintComponent(java.awt.Graphics g)

Overrides:
paintComponent in class javax.swing.JComponent

getPreferredSize

public java.awt.Dimension getPreferredSize()

Overrides:
getPreferredSize in class javax.swing.JComponent