|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wjhk.jupload2.filedata.DefaultFileData wjhk.jupload2.filedata.PictureFileData
public class PictureFileData
This class contains all data about files to upload as a picture. It adds the
following elements to the FileData
class :
addRotation(int)
Field Summary | |
---|---|
(package private) int |
originalHeight
Same as originalWidth , for the height of the first image in the
picture file. |
(package private) int |
originalWidth
Width of the original picture. |
(package private) int |
quarterRotation
quarterRotation contains the current rotation that will be applied to the picture. |
Fields inherited from class wjhk.jupload2.filedata.DefaultFileData |
---|
mimeType, preparedForUpload, uploadPolicy |
Constructor Summary | |
---|---|
PictureFileData(File file,
File root,
PictureUploadPolicy uploadPolicy)
Standard constructor: needs a PictureFileDataPolicy. |
Method Summary | |
---|---|
void |
addRotation(int quarter)
This function is used to rotate the picture. |
void |
afterUpload()
Cleaning of the temporary file on the hard drive, if any. |
void |
beforeUpload()
If this pictures needs transformation, a temporary file is created. |
(package private) void |
createTranformedPictureFile(wjhk.jupload2.filedata.helper.ImageHelper imageHelper)
Creates a transformed picture file of the given max width and max height. |
void |
deleteTransformedPictureFile()
File.deleteOnExit() is pretty unreliable, especially in applets. |
void |
deleteWorkingCopyPictureFile()
File.deleteOnExit() is pretty unreliable, especially in applets. |
static void |
freeMemory(String caller,
UploadPolicy uploadPolicy)
Free any available memory. |
Image |
getImage(Canvas canvas,
boolean shadow)
This method creates a new Image, from the current picture. |
static ImageIcon |
getImageIcon(File pictureFile,
int maxWidth,
int maxHeight)
Returns an ImageIcon for the given file, resized according to the given dimensions. |
InputStream |
getInputStream()
This function create an input stream for this file. |
String |
getMimeType()
This function return the FileData content type. |
int |
getOriginalHeight()
|
int |
getOriginalWidth()
|
long |
getUploadLength()
Returns the number of bytes, for this upload. |
File |
getWorkingSourceFile()
Get the file that contains the original picture. |
static boolean |
isFileAPictrue(File file)
Indicates whether a file is a picture or not. |
boolean |
isPicture()
Indicates if this file is actually a picture or not. |
Methods inherited from class wjhk.jupload2.filedata.DefaultFileData |
---|
appendFileProperties, canRead, getDirectory, getExtension, getFile, getFileExtension, getFileLength, getFileName, getLastModified, getRelativeDir, getRoot, isPreparedForUpload |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
int quarterRotation
addRotation(int)
method.
int originalWidth
PictureFileData(File, File, PictureUploadPolicy)
constructor.
int originalHeight
originalWidth
, for the height of the first image in the
picture file.
Constructor Detail |
---|
public PictureFileData(File file, File root, PictureUploadPolicy uploadPolicy) throws JUploadIOException
file
- The files which data are to be handled by this instance.root
- The root directory, to calculate the relative dir (see
DefaultFileData.getRelativeDir()
.uploadPolicy
- The current upload policy
JUploadIOException
- Encapsulation of the IOException, if any would
occurs.Method Detail |
---|
public static void freeMemory(String caller, UploadPolicy uploadPolicy)
caller
- Indicate the method or treatment from which this method is
called.uploadPolicy
- The current upload policy is not available, to this
static method...public void beforeUpload() throws JUploadException
getUploadLength()
. This method calls beforeUpload() if the
uploadLength is unknown.
beforeUpload
in interface FileData
beforeUpload
in class DefaultFileData
JUploadException
- Encapsulation of the Exception, if any would
occurs.FileUploadThread
public long getUploadLength() throws JUploadException
beforeUpload()
is called.
getUploadLength
in interface FileData
getUploadLength
in class DefaultFileData
JUploadException
- Encapsulation of the Exception, if any would
occurs.PictureFileData
public InputStream getInputStream() throws JUploadException
getUploadLength()
method has
already be called : it is responsible for creating the temporary file (if
needed). If not called, the original file will be sent.
getInputStream
in interface FileData
getInputStream
in class DefaultFileData
JUploadException
- Encapsulation of the Exception, if any would
occurs.public void afterUpload()
afterUpload
in interface FileData
afterUpload
in class DefaultFileData
public Image getImage(Canvas canvas, boolean shadow) throws JUploadException
canvas
- The canvas on which the picture will be displayed.shadow
- True if the pictureFileData should store this picture.
False if the pictureFileData instance should not store this
picture. Store this picture avoid calculating the image each
time the user selects it in the file panel.
JUploadException
- Encapsulation of the Exception, if any would
occurs.public void addRotation(int quarter)
quarter
- Number of quarters (90 degrees) the picture should rotate.
1 means rotating of 90 degrees clockwise. Can be negative.public boolean isPicture()
public String getMimeType()
DefaultFileData
getMimeType
in interface FileData
getMimeType
in class DefaultFileData
FileData.getMimeType()
public void deleteTransformedPictureFile()
void createTranformedPictureFile(wjhk.jupload2.filedata.helper.ImageHelper imageHelper) throws JUploadException
transformedPictureFile
attribute is not set before
calling this method, it will be set. If set before, the existing
transformedPictureFile
is replaced by the newly transformed
picture file. It is cleared if an error occured.
imageHelper
- The ImageHelper
that was initialized with
current parameters.
JUploadException
public void deleteWorkingCopyPictureFile()
public File getWorkingSourceFile() throws JUploadIOException
JUploadIOException
public int getOriginalWidth() throws JUploadIOException
JUploadIOException
public int getOriginalHeight() throws JUploadIOException
JUploadIOException
public static ImageIcon getImageIcon(File pictureFile, int maxWidth, int maxHeight)
pictureFile
- The file, containing a picture, from which the user
wants to extract a static picture.maxWidth
- The maximum allowed width for the static picture to
generate.maxHeight
- The maximum allowed height for the static picture to
generate.
public static boolean isFileAPictrue(File file)
file
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |