List of usage examples for com.google.gwt.user.client.ui Image setVisibleRect
public void setVisibleRect(int left, int top, int width, int height)
From source file:com.google.gwt.examples.ImageExample.java
License:Apache License
public void onModuleLoad() { // Create an image, not yet referencing a URL. We make it final so that we // can manipulate the image object within the ClickHandlers for the buttons. final Image image = new Image(); // Hook up an error handler, so that we can be informed if the image fails // to load.//www. j a va 2 s . c o m image.addErrorHandler(new ErrorHandler() { public void onError(ErrorEvent event) { lbl.setText("An error occurred while loading."); } }); // Point the image at a real URL. image.setUrl("http://www.google.com/images/logo.gif"); // When the user clicks this button, we want to clip the image. btn.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { image.setVisibleRect(70, 0, 47, 110); } }); btn.setWidth("120px"); // When the user clicks this button, we want to restore the image to its // unclipped state. btn2.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { image.setUrl("http://www.google.com/images/logo.gif"); } }); btn2.setWidth("120px"); // Add the image, label, and clip/restore buttons to the root panel. VerticalPanel panel = new VerticalPanel(); panel.add(lbl); panel.add(image); HorizontalPanel buttonPanel = new HorizontalPanel(); buttonPanel.add(btn); buttonPanel.add(btn2); panel.add(buttonPanel); RootPanel.get().add(panel); }
From source file:com.sun.labs.aura.music.wsitm.client.items.ArtistDetails.java
License:Open Source License
/** * Get the artist's image and use an album cover as a fallback * @param thumbnail return a thumbnail sized image * @return//from w w w.jav a 2 s . c om */ public Image getBestArtistImage(boolean thumbnail) { Image img = null; if (photos.length > 0) { if (thumbnail) { img = new Image(photos[0].getThumbNailImageUrl()); } else { img = new Image(photos[0].getSmallImageUrl()); } } else if (albums.length > 0) { img = new Image(albums[0].getAlbumArt()); if (thumbnail) { img.setVisibleRect(0, 0, 75, 75); } } return img; }
From source file:org.nuxeo.opensocial.wysiwyg.client.RichTextToolbar.java
License:Open Source License
/** Method to create a Toggle button for the toolbar **/ private ToggleButton createToggleButton(ImageResource resource, Integer top, Integer left, Integer width, Integer height, String tip) { Image extract = new Image(resource); extract.setVisibleRect(left, top, width, height); ToggleButton tb = new ToggleButton(extract); tb.setHeight(height + "px"); tb.setWidth(width + "px"); tb.addClickHandler(evHandler);//from www .ja v a 2s . c o m if (tip != null) { tb.setTitle(tip); } return tb; }
From source file:org.nuxeo.opensocial.wysiwyg.client.RichTextToolbar.java
License:Open Source License
/** Method to create a Push button for the toolbar **/ private PushButton createPushButton(ImageResource resource, Integer top, Integer left, Integer width, Integer height, String tip) { Image extract = new Image(resource); extract.setVisibleRect(left, top, width, height); PushButton tb = new PushButton(extract); tb.setHeight(height + "px"); tb.setWidth(width + "px"); tb.addClickHandler(evHandler);/*from ww w.j av a2 s . c o m*/ if (tip != null) { tb.setTitle(tip); } return tb; }