Package org.zkoss.stateless.state
Class ICropperController
- java.lang.Object
-
- org.zkoss.stateless.state.ICropperController
-
public class ICropperController extends java.lang.Object
AnICropper
controller to control the cropper, sizing, moving, and crops.Note: this class is not thread-safe, so when it's used in multi-threading environment, the developer should handle the threading issue.
- Author:
- katherine
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ICropper
build()
Returns the immutable cropper instance that the controller to build with.void
cancel()
To cancel the selected area.void
crop()
Request cropper JavaScript widget to crop the selected area and send it back to the server.AImage
getCroppedImage()
Returns the cropped image as anAImage
.void
move(int deltaX, int deltaY)
Moves the crop area according to the delta x and y.void
moveTo(int x, int y)
Moves the crop area to the specified left and top related position.static ICropperController
of(ICropper owner)
Returns the controller instance with the givencropper
void
resize(int deltaW, int deltaH)
Resizes the crop area according to the delta width and height in pixel.void
resizeTo(int width, int height)
Resize the crop area to the specified width and height in pixel.
-
-
-
Method Detail
-
resize
public void resize(int deltaW, int deltaH)
Resizes the crop area according to the delta width and height in pixel. Positive means larger, negative means smaller.- Parameters:
deltaW
- the delta width to resizedeltaH
- the delta height to resize
-
resizeTo
public void resizeTo(int width, int height)
Resize the crop area to the specified width and height in pixel.- Parameters:
width
- the width of the crop areaheight
- the height of the crop area
-
move
public void move(int deltaX, int deltaY)
Moves the crop area according to the delta x and y. Positive for x means move right, negative means move left. Positive for y means move down, negative means move top.- Parameters:
deltaX
- the x difference to movedeltaY
- the y difference to move
-
moveTo
public void moveTo(int x, int y)
Moves the crop area to the specified left and top related position.- Parameters:
x
- the x position to move toy
- the y position to move to
-
cancel
public void cancel()
To cancel the selected area.
-
crop
public void crop()
Request cropper JavaScript widget to crop the selected area and send it back to the server. You can't callgetCroppedImage()
immediately in the same event listener. You need to complete the listener calling, let the response back to the browser to crop the image. It will fire an onCrop event to invoke onCrop event listener, then you can get cropped image in the onCrop listener.
-
of
public static ICropperController of(ICropper owner)
Returns the controller instance with the givencropper
- Parameters:
owner
- The controller to control with
-
build
public ICropper build()
Returns the immutable cropper instance that the controller to build with.
-
-