jfileupload.transfer.client.mdesign
Class ImagePreview

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by jfileupload.transfer.client.mdesign.FilePreview
                  extended by jfileupload.transfer.client.mdesign.ImagePreview
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener

public class ImagePreview
extends FilePreview
implements java.beans.PropertyChangeListener

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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.lang.String AVERAGESCALE
           
static int DEFAULTHEIGHT
           
static java.lang.String DEFAULTSCALE
           
static int DEFAULTWIDTH
           
protected  boolean disabledThumbnail
           
protected  boolean enabled
           
static java.lang.String FASTSCALE
           
protected  java.io.File file
           
protected  boolean forcergb
           
protected  int imageHeight
           
protected  int imageWidth
           
static int LEFTBORDER
           
protected  long maxsize
           
protected  int previewHeight
           
protected  java.lang.String previewScale
           
protected  int previewWidth
           
static int SAFEBORDER
           
protected  int scaleLevel
           
static java.lang.String SMOOTHSCALE
           
static java.lang.String SUBSAMPLESCALE
           
protected  javax.swing.ImageIcon thumbnail
           
 
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
ImagePreview()
          Dummy constructor.
ImagePreview(javax.swing.JFileChooser fc, Conf conf)
          Constructor.
 
Method Summary
 java.io.File getFile()
          Get image file.
 int getImageHeight()
           
 int getImageWidth()
           
 java.lang.String getPreviewScale()
          Get preview scale quality.
 boolean getPreviewState()
           
protected  double getScale(int w, int h, int maxw, int maxh)
          Compute scale from max width and max height and keep aspect ratio.
protected  javax.swing.ImageIcon getThumbnail(java.io.File f, int w, int h, int level)
          Scale input image.
 boolean isDisabledThumbnail()
           
 void loadImage()
          Load image and resize it if needed.
protected  void paintComponent(java.awt.Graphics g)
           
 void propertyChange(java.beans.PropertyChangeEvent e)
           
 void setDisabledThumbnail(boolean disabledThumbnail)
           
 void setFile(java.io.File file)
          Set image file.
 void setForceRGB(boolean b)
           
 void setPreviewScale(java.lang.String scale)
          Set preview scale quality.
 void setPreviewState(boolean enable)
           
 
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, 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, 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

SUBSAMPLESCALE

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

FASTSCALE

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

DEFAULTSCALE

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

AVERAGESCALE

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

SMOOTHSCALE

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

DEFAULTWIDTH

public static int DEFAULTWIDTH

DEFAULTHEIGHT

public static int DEFAULTHEIGHT

SAFEBORDER

public static int SAFEBORDER

LEFTBORDER

public static int LEFTBORDER

thumbnail

protected javax.swing.ImageIcon thumbnail

file

protected java.io.File file

previewScale

protected java.lang.String previewScale

scaleLevel

protected int scaleLevel

previewWidth

protected int previewWidth

previewHeight

protected int previewHeight

enabled

protected boolean enabled

maxsize

protected long maxsize

imageWidth

protected int imageWidth

imageHeight

protected int imageHeight

forcergb

protected boolean forcergb

disabledThumbnail

protected boolean disabledThumbnail
Constructor Detail

ImagePreview

public ImagePreview()
Dummy constructor.


ImagePreview

public ImagePreview(javax.swing.JFileChooser fc,
                    Conf conf)
Constructor.

Parameters:
fc - JFileChooser
conf - Conf
Method Detail

getImageHeight

public int getImageHeight()

getImageWidth

public int getImageWidth()

setPreviewState

public void setPreviewState(boolean enable)
Specified by:
setPreviewState in class FilePreview

getPreviewState

public boolean getPreviewState()
Specified by:
getPreviewState in class FilePreview

setPreviewScale

public void setPreviewScale(java.lang.String scale)
Set preview scale quality.

Parameters:
scale - String

setForceRGB

public void setForceRGB(boolean b)

isDisabledThumbnail

public boolean isDisabledThumbnail()

setDisabledThumbnail

public void setDisabledThumbnail(boolean disabledThumbnail)

getPreviewScale

public java.lang.String getPreviewScale()
Get preview scale quality.

Returns:
String

loadImage

public void loadImage()
Load image and resize it if needed.


getThumbnail

protected javax.swing.ImageIcon getThumbnail(java.io.File f,
                                             int w,
                                             int h,
                                             int level)
Scale input image.

Parameters:
f - File
w - int
h - int
level - int
Returns:
ImageIcon

setFile

public void setFile(java.io.File file)
Set image file.

Parameters:
file -

getFile

public java.io.File getFile()
Get image file.

Returns:

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

getScale

protected double getScale(int w,
                          int h,
                          int maxw,
                          int maxh)
Compute scale from max width and max height and keep aspect ratio.

Parameters:
w - image width
h - image height
maxw - max width
maxh - max height
Returns:

paintComponent

protected void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent