public class PictureFileData extends DefaultFileData
FileData class :addRotation(int)
canRead, file, fileDir, fileModified, fileRoot, fileSize, md5sum, mimeType| Constructor and Description |
|---|
PictureFileData(File file,
File root,
PictureUploadPolicy uploadPolicy)
Standard constructor: needs a PictureFileDataPolicy.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
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,
UploadPolicy uploadPolicy)
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 |
isFileAPicture(File file)
Indicates whether a file is a picture or not.
|
boolean |
isPicture()
Indicates if this file is actually a picture or not.
|
appendFileProperties, calculateMD5Sum, canRead, getDirectory, getExtension, getFile, getFileExtension, getFileLength, getFileName, getLastModified, getMD5, getRelativeDir, getRoot, isPreparedForUploadpublic 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 policyJUploadIOException - Encapsulation of the IOException, if any would
occurs.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 FileDatabeforeUpload in class DefaultFileDataJUploadException - Encapsulation of the Exception, if any error would occurs.FileUploadThreadpublic long getUploadLength()
beforeUpload() is called.getUploadLength in interface FileDatagetUploadLength in class DefaultFileDataPictureFileDatapublic 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 FileDatagetInputStream in class DefaultFileDataJUploadException - Encapsulation of the Exception, if any would occurs.public void afterUpload()
afterUpload in interface FileDataafterUpload in class DefaultFileDatapublic 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()
DefaultFileDatagetMimeType in interface FileDatagetMimeType in class DefaultFileDataFileData.getMimeType()public void deleteTransformedPictureFile()
public void deleteWorkingCopyPictureFile()
public File getWorkingSourceFile() throws JUploadIOException
JUploadIOExceptionpublic int getOriginalWidth()
throws JUploadIOException
JUploadIOExceptionpublic int getOriginalHeight()
throws JUploadIOException
JUploadIOExceptionpublic static ImageIcon getImageIcon(File pictureFile, int maxWidth, int maxHeight, UploadPolicy uploadPolicy) throws JUploadException
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.uploadPolicy - The current upload policy, for logging when calling
freeMemory.JUploadException - If the ImageIcon can not be loaded.public static boolean isFileAPicture(File file)
file - Copyright © 2012. All Rights Reserved.