Java Code Examples for com.smartgwt.client.widgets.Canvas#getHeight()

The following examples show how to use com.smartgwt.client.widgets.Canvas#getHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageWithCanvases.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void resize2(int newHeight) {
	if (newHeight <= 0)
		return;
	
	int newWidth = (int) ((double) newHeight * getImageAspectRatio());

	for (Canvas canvas : canvases) {
		double proportionW = (double) img.getWidth() / (double) canvas.getWidth();
		double proportionH = (double) img.getHeight() / (double) canvas.getHeight();
		double proportionX = (double) img.getWidth() / (double) canvas.getLeft();
		double proportionY = (double) img.getHeight() / (double) canvas.getTop();

		int newCanvasHeight = (int) ((double) newHeight / proportionH);
		int newCanvasWidth = (int) ((double) newWidth / proportionW);
		int newCanvasTop = (int) ((double) newHeight / proportionY);
		int newCanvasLeft = (int) ((double) newWidth / proportionX);

		if (img != null && newHeight > 100) {
			canvas.setLeft(newCanvasLeft);
			canvas.setTop(newCanvasTop);
			canvas.setWidth(newCanvasWidth);
			canvas.setHeight(newCanvasHeight);
		}
	}

	if (img != null && newHeight > 100) {
		img.setHeight(newHeight);
		img.setWidth(newWidth);
	}
}
 
Example 2
Source File: ImageWithCanvases.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public int getCanvasHeight(Canvas canvas) {
	return (int) ((double) canvas.getHeight() * (double) imageHeight / (double) img.getHeight());
}