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
public class CropImageAction extends UploadAction
Generates a new image by cropping an already uploaded image and store it.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
CropImageAction.Cropping
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
Constructors Constructor Description CropImageAction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private int
_checkValidity(int widthOrHeight, int xOrY, int originalWidthOrHeight)
protected void
_doCrop(Upload originalImage, CropImageAction.Cropping cropping, Map<String,Object> result)
Do crop the original image and fill the result map.protected void
_doUpload(Request request, Parameters parameters, Map<String,Object> result)
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 Detail
-
CropImageAction
public CropImageAction()
-
-
Method Detail
-
_doUpload
protected void _doUpload(Request request, Parameters parameters, Map<String,Object> result) throws Exception
Description 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
protected Upload _getUploadObject(Request request, Parameters parameters) throws ParameterException
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 IOException
Do 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
-
_checkValidity
private int _checkValidity(int widthOrHeight, int xOrY, int originalWidthOrHeight)
-
_uploadAsBufferedImage
protected BufferedImage _uploadAsBufferedImage(Upload upload) throws IOException
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 IOException
Stores 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
protected String _getFormatName(String iamgeFilename)
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
protected String _getCroppedImageFilename(String originalName)
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
-
-