wjhk.jupload2.gui
Class PicturePanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by wjhk.jupload2.gui.PicturePanel
All Implemented Interfaces:
ComponentListener, MouseListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible
Direct Known Subclasses:
DialogPicturePanel

public class PicturePanel
extends Canvas
implements MouseListener, ComponentListener

This panel is used to preview picture, when PictureUploadPolicy (or one of its inherited policy) is used. Manages the panel where pictures are displayed.
Each time a user selects a file in the panel file, the PictureUploadPolicy calls setPictureFile(PictureFileData, AbstractButton, AbstractButton). I did an attempt to store the Image generated for the Panel size into the PictureFileData, to avoid to calculate the offscreenPicture each time the user select the same file again. But it doesn't work: the applet quickly runs out of memory, even after numerous calls of System.gc and finalize.

This file is taken from the PictureApplet ((C) 2002 Guillaume Chamberland-Larose), available here: To contact Guillaume Chamberland-Larose for bugs, patches, suggestions: Please use the forums on the sourceforge web page for this project, located at: http://sourceforge.net/projects/picture-applet/ Updated : 2006 etienne_sf
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.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Canvas
Canvas.AccessibleAWTCanvas
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  UploadPolicy uploadPolicy
          The current upload policy.
 
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
PicturePanel(boolean hasToStoreOffscreenPicture, UploadPolicy uploadPolicy)
          Standard constructor.
 
Method Summary
 void componentHidden(ComponentEvent arg0)
           
 void componentMoved(ComponentEvent arg0)
           
 void componentResized(ComponentEvent arg0)
           
 void componentShown(ComponentEvent arg0)
           
protected  void finalize()
          Is it really useful ??
 void mouseClicked(MouseEvent arg0)
           
 void mouseEntered(MouseEvent arg0)
           
 void mouseExited(MouseEvent arg0)
           
 void mousePressed(MouseEvent arg0)
           
 void mouseReleased(MouseEvent arg0)
           
 void paint(Graphics g)
           
 void rotate(int quarter)
          This function adds a quarter rotation to the current picture.
 void setPictureFile(PictureFileData pictureFileData, AbstractButton button1, AbstractButton button2)
          This setter is called by PictureFileData to set the picture that is to be previewed.
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, update
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

uploadPolicy

protected UploadPolicy uploadPolicy
The current upload policy.

Constructor Detail

PicturePanel

public PicturePanel(boolean hasToStoreOffscreenPicture,
                    UploadPolicy uploadPolicy)
Standard constructor.

Parameters:
hasToStoreOffscreenPicture -
uploadPolicy - The current upload policy
Method Detail

setPictureFile

public void setPictureFile(PictureFileData pictureFileData,
                           AbstractButton button1,
                           AbstractButton button2)
This setter is called by PictureFileData to set the picture that is to be previewed.

Parameters:
pictureFileData - The FileData for the image to be displayed. Null if no picture should be displayed.
button1 - A button that will be activated or not, depending of the pictures was correctly set into the panel. May be null, if not button is to be enabled.
button2 - Another button that will be activated or not. May also be null.

paint

public void paint(Graphics g)
Overrides:
paint in class Canvas
See Also:
Canvas.paint(java.awt.Graphics)

rotate

public void rotate(int quarter)
This function adds a quarter rotation to the current picture.

Parameters:
quarter - Number of quarters (90�) the picture should rotate. 1 means rotating of 90� clockwise (?). Can be negative (counterclockwise), more than 1...

finalize

protected void finalize()
                 throws Throwable
Is it really useful ??

Overrides:
finalize in class Object
Throws:
Throwable

mouseClicked

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

mouseEntered

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

mouseExited

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

mousePressed

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

mouseReleased

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

componentHidden

public void componentHidden(ComponentEvent arg0)
Specified by:
componentHidden in interface ComponentListener
See Also:
ComponentListener.componentHidden(java.awt.event.ComponentEvent)

componentMoved

public void componentMoved(ComponentEvent arg0)
Specified by:
componentMoved in interface ComponentListener
See Also:
ComponentListener.componentMoved(java.awt.event.ComponentEvent)

componentResized

public void componentResized(ComponentEvent arg0)
Specified by:
componentResized in interface ComponentListener
See Also:
ComponentListener.componentResized(java.awt.event.ComponentEvent)

componentShown

public void componentShown(ComponentEvent arg0)
Specified by:
componentShown in interface ComponentListener
See Also:
ComponentListener.componentShown(java.awt.event.ComponentEvent)