public class PictureFileData extends DefaultFileData
FileData
class :addRotation(int)
canRead, file, fileDir, fileModified, fileRoot, fileSize, md5sum, mimeType, uploadFlag
Constructor and Description |
---|
PictureFileData(File file,
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(String uploadFileRoot)
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, getAbsolutePath, getDirectory, getExtension, getFile, getFileExtension, getFileLength, getFileName, getLastModified, getMD5, getRelativeDir, getRoot, getTreeFileDataNode, getUploadFlag, isPreparedForUpload, setTreeFileDataNode, setUploadFlag
public PictureFileData(File file, 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(String uploadFileRoot) throws JUploadException
getUploadLength()
. This method calls
beforeUpload() if the uploadLength is unknown.beforeUpload
in interface FileData
beforeUpload
in class DefaultFileData
uploadFileRoot
- The biggest path which is common to all uploaded files. Used to calculate the relativeDir
to this root path, for each file. This relative path is sent as metadata during the uploadJUploadException
- Encapsulation of the Exception, if any error would occurs.FileUploadThread
,
FileData.getRelativeDir()
public long getUploadLength()
#beforeUpload()
is called.getUploadLength
in interface FileData
getUploadLength
in class DefaultFileData
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()
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, 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 © 2015. All rights reserved.