Directory

← Back

CropField

A vaadin Field that allows selecting a cropping area in your image

Author

Rating

Popularity

<100

The CropField component is a vaadin Field that shows a single image and overlays it with capabilities to select, transform and move a cropping area within it.

Basically, it is a jCrop clone for Vaadin/GWT.

Features include:

  • adding handlers to be notified when selection changes
  • setting min/max size of the selection
  • forcing an aspect ratio on the selection
  • selecting in the true size coordinate system of scaled images

Sample code

final Label selectionLabel = new Label();

final CropField cropField = new CropField(new ExternalResource("flowers.jpg"));
cropField.setImmediate(true);
cropField.addListener(new ValueChangeListener() {
		private static final long serialVersionUID = -8317773834498970664L;

		@Override
		public void valueChange(ValueChangeEvent event) {
			VCropSelection newSelection = (VCropSelection) event
					.getProperty().getValue();
			int x1 = newSelection.getXTopLeft();
			int y1 = newSelection.getYTopLeft();
			int x2 = newSelection.getXBottomRight();
			int y2 = newSelection.getYBottomRight();
			selectionLabel.setValue("Selection: x1: " + x1 + ", y1: " + y1 + ", x2: " + x2 + ", y2: " + y2);
		}
	}
});

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

made VCropSelection serializable, so it can be published to Google AppEngine

Released
2011-09-29
Maturity
BETA
License
GNU Lesser General Public License v3.0 only

Compatibility

Framework
Vaadin 6.6+
Browser
Internet Explorer
Internet Explorer
Firefox
Opera
Safari
Google Chrome
Internet Explorer

CropField - Vaadin Add-on Directory

A vaadin Field that allows selecting a cropping area in your image CropField - Vaadin Add-on Directory
The CropField component is a vaadin Field that shows a single image and overlays it with capabilities to select, transform and move a cropping area within it. Basically, it is a jCrop clone for Vaadin/GWT. Features include: - adding handlers to be notified when selection changes - setting min/max size of the selection - forcing an aspect ratio on the selection - selecting in the true size coordinate system of scaled images
Online