List of usage examples for com.vaadin.ui Image getWidth
@Override public float getWidth()
From source file:com.foc.vaadin.gui.components.FVBlobDisplay.java
License:Apache License
private Image displayImage(BlobResource blobResource) { Image image = new Image(); image.setSource(blobResource);// w w w. j a va 2 s . c o m FVImageField imageField = new FVImageField(null, getAttributes()); image = imageField.resizeImage(image, MAX_WIDTH, MAX_HEIGHT); setWidth(image.getWidth() + "px"); setHeight(image.getHeight() + "px"); return image; }
From source file:com.foc.vaadin.gui.components.FVImageField.java
License:Apache License
public Image resizeImage(Image image, int maxWidth, int maxHeight) { if (image != null) { double ratio = getRatio(image, maxWidth, maxHeight); String newHeight = Integer.toString((int) (image.getHeight() * ratio)); String newWidth = Integer.toString((int) (image.getWidth() * ratio)); image.setWidth(newWidth + "px"); image.setHeight(newHeight + "px"); setWidth(newWidth + "px"); setHeight(newHeight + "px"); }//w w w. j a va2 s .c om return image; }