Class CropImageAction
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.cocoon.acting.AbstractAction
org.apache.cocoon.acting.ServiceableAction
org.ametys.core.util.cocoon.AbstractCurrentUserProviderServiceableAction
org.ametys.plugins.core.upload.UploadAction
org.ametys.plugins.core.upload.image.CropImageAction
- All Implemented Interfaces:
Component
,LogEnabled
,Serviceable
,ThreadSafe
,Action
- Direct Known Subclasses:
CropImageAction
Generates a new image by cropping an already uploaded image and store it.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Represents a rectangular cropping of an image. -
Field Summary
Fields inherited from class org.ametys.plugins.core.upload.UploadAction
_uploadManager
Fields inherited from class org.apache.cocoon.acting.ServiceableAction
manager
Fields inherited from class org.apache.cocoon.acting.AbstractAction
EMPTY_MAP
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Do crop the original image and fill the result map.protected void
Do upload the file and fill the result map.protected String
_getCroppedImageFilename
(String originalName) Gets the file name of the cropped imageprotected String
_getFormatName
(String iamgeFilename) Gets the String containing the informal name of the format of the imageprotected Upload
_getUploadObject
(Request request, Parameters parameters) Gets the already uploaded imageprotected void
_storeCroppedImage
(BufferedImage croppedImage, String originalName, Map<String, Object> result) Stores the cropped image into theUploadManager
system and fill the result map.protected BufferedImage
_uploadAsBufferedImage
(Upload upload) Converts an uploaded image asUpload
into aBufferedImage
Methods inherited from class org.ametys.plugins.core.upload.UploadAction
_fillSuccess, _getPart, _getUrlForDownload, _getUrlForView, _handleStoreUploadException, _lookupComponents, _storeUpload, act
Methods inherited from class org.ametys.core.util.cocoon.AbstractCurrentUserProviderServiceableAction
_getCurrentUser
Methods inherited from class org.apache.cocoon.acting.ServiceableAction
service
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Constructor Details
-
CropImageAction
public CropImageAction()
-
-
Method Details
-
_doUpload
protected void _doUpload(Request request, Parameters parameters, Map<String, Object> result) throws ExceptionDescription copied from class:UploadAction
Do upload the file and fill the result map.- Overrides:
_doUpload
in classUploadAction
- Parameters:
request
- The requestparameters
- The parametersresult
- The result map to fill- Throws:
Exception
- if an error occurs.
-
_getUploadObject
Gets the already uploaded image- Parameters:
request
- The requestparameters
- The parameters- Returns:
- The previously uploaded image
- Throws:
ParameterException
- if theimageId
parameter is not specified
-
_doCrop
protected void _doCrop(Upload originalImage, CropImageAction.Cropping cropping, Map<String, Object> result) throws IOExceptionDo crop the original image and fill the result map.- Parameters:
originalImage
- The original image to cropcropping
- The cropping to applyresult
- The result map to fill- Throws:
IOException
- if an I/O error occurs
-
_uploadAsBufferedImage
Converts an uploaded image asUpload
into aBufferedImage
- Parameters:
upload
- The uploaded image- Returns:
- The upload image as a
BufferedImage
- Throws:
IOException
- if an I/O error occurs
-
_storeCroppedImage
protected void _storeCroppedImage(BufferedImage croppedImage, String originalName, Map<String, Object> result) throws IOExceptionStores the cropped image into theUploadManager
system and fill the result map.- Parameters:
croppedImage
- The cropped imageoriginalName
- The original image file nameresult
- The result map to fill- Throws:
IOException
- if an I/O error occurs
-
_getFormatName
Gets the String containing the informal name of the format of the image- Parameters:
iamgeFilename
- The file name- Returns:
- the String containing the informal name of the format of the image
-
_getCroppedImageFilename
Gets the file name of the cropped image- Parameters:
originalName
- The file name of the original image- Returns:
- the file name of the cropped image
-