|
GWT 2.7.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.gwt.user.client.ui.UIObject com.google.gwt.user.client.ui.Widget com.google.gwt.user.client.ui.Image
public class Image
A widget that displays the image at a given URL. The image can be in 'unclipped' mode (the default) or 'clipped' mode. In clipped mode, a viewport is overlaid on top of the image so that a subset of the image will be displayed. In unclipped mode, there is no viewport - the entire image will be visible. Whether an image is in clipped or unclipped mode depends on how the image is constructed, and how it is transformed after construction. Methods will operate differently depending on the mode that the image is in. These differences are detailed in the documentation for each method.
If an image transitions between clipped mode and unclipped mode, any
Element
-specific attributes added by the user (including style
attributes, style names, and style modifiers), except for event listeners,
will be lost.
public class ImageExample implements EntryPoint { private Label lbl = new Label(); private Button btn = new Button("Clip this image"); private Button btn2 = new Button("Restore image"); 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. 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); } }
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject |
---|
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled |
Field Summary |
---|
Fields inherited from class com.google.gwt.user.client.ui.Widget |
---|
eventsToSink |
Fields inherited from class com.google.gwt.user.client.ui.UIObject |
---|
DEBUG_ID_PREFIX, MISSING_ELEMENT_ERROR, SETELEMENT_TWICE_ERROR |
Constructor Summary | |
---|---|
|
Image()
Creates an empty image. |
protected |
Image(Element element)
This constructor may be used by subclasses to explicitly use an existing element. |
|
Image(ImageResource resource)
Creates an image whose size and content are defined by an ImageResource. |
|
Image(SafeUri url)
Creates an image with a specified URL. |
|
Image(SafeUri url,
int left,
int top,
int width,
int height)
Creates a clipped image with a specified URL and visibility rectangle. |
|
Image(java.lang.String url)
Creates an image with a specified URL. |
|
Image(java.lang.String url,
int left,
int top,
int width,
int height)
Creates a clipped image with a specified URL and visibility rectangle. |
Methods inherited from class com.google.gwt.user.client.ui.Widget |
---|
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, ensureHandlers, fireEvent, getHandlerCount, getHandlerManager, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onDetach, onUnload, removeFromParent, replaceElement, setLayoutData, setParent, sinkEvents, unsinkEvents |
Methods inherited from class com.google.gwt.user.client.ui.UIObject |
---|
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.google.gwt.event.shared.HasHandlers |
---|
fireEvent |
Constructor Detail |
---|
public Image()
public Image(ImageResource resource)
resource
- the ImageResource to be displayedpublic Image(java.lang.String url)
url
- the URL of the image to be displayedpublic Image(SafeUri url)
url
- the URL of the image to be displayedpublic Image(java.lang.String url, int left, int top, int width, int height)
url
- the URL of the image to be displayedleft
- the horizontal co-ordinate of the upper-left vertex of the
visibility rectangletop
- the vertical co-ordinate of the upper-left vertex of the
visibility rectanglewidth
- the width of the visibility rectangleheight
- the height of the visibility rectanglepublic Image(SafeUri url, int left, int top, int width, int height)
url
- the URL of the image to be displayedleft
- the horizontal co-ordinate of the upper-left vertex of the
visibility rectangletop
- the vertical co-ordinate of the upper-left vertex of the
visibility rectanglewidth
- the width of the visibility rectangleheight
- the height of the visibility rectangleprotected Image(Element element)
element
- the element to be usedMethod Detail |
---|
public static void prefetch(java.lang.String url)
url
- the URL of the image to be prefetchedpublic static void prefetch(SafeUri url)
url
- the URL of the image to be prefetchedpublic static Image wrap(Element element)
RootPanel.detachNow(Widget)
.
element
- the element to be wrappedpublic HandlerRegistration addClickHandler(ClickHandler handler)
HasClickHandlers
ClickEvent
handler.
addClickHandler
in interface HasClickHandlers
handler
- the click handler
HandlerRegistration
used to remove this handler@Deprecated public void addClickListener(ClickListener listener)
addClickHandler(com.google.gwt.event.dom.client.ClickHandler)
instead
SourcesClickEvents
addClickListener
in interface SourcesClickEvents
listener
- the listener interface to addpublic HandlerRegistration addDoubleClickHandler(DoubleClickHandler handler)
HasDoubleClickHandlers
DoubleClickEvent
handler.
addDoubleClickHandler
in interface HasDoubleClickHandlers
handler
- the double click handler
HandlerRegistration
used to remove this handlerpublic HandlerRegistration addDragEndHandler(DragEndHandler handler)
HasDragEndHandlers
DragEndEvent
handler.
addDragEndHandler
in interface HasDragEndHandlers
handler
- the drag end handler
HandlerRegistration
used to remove this handlerpublic HandlerRegistration addDragEnterHandler(DragEnterHandler handler)
HasDragEnterHandlers
DragEnterEvent
handler.
addDragEnterHandler
in interface HasDragEnterHandlers
handler
- the drag end handler
HandlerRegistration
used to remove this handlerpublic HandlerRegistration addDragHandler(DragHandler handler)
HasDragHandlers
DragEvent
handler.
addDragHandler
in interface HasDragHandlers
handler
- the drag handler
HandlerRegistration
used to remove this handlerpublic HandlerRegistration addDragLeaveHandler(DragLeaveHandler handler)
HasDragLeaveHandlers
DragLeaveEvent
handler.
addDragLeaveHandler
in interface HasDragLeaveHandlers
handler
- the drag leave handler
HandlerRegistration
used to remove this handlerpublic HandlerRegistration addDragOverHandler(DragOverHandler handler)
HasDragOverHandlers
DragOverEvent
handler.
addDragOverHandler
in interface HasDragOverHandlers
handler
- the drag over handler
HandlerRegistration
used to remove this handlerpublic HandlerRegistration addDragStartHandler(DragStartHandler handler)
HasDragStartHandlers
DragStartEvent
handler.
addDragStartHandler
in interface HasDragStartHandlers
handler
- the drag start handler
HandlerRegistration
used to remove this handlerpublic HandlerRegistration addDropHandler(DropHandler handler)
HasDropHandlers
DropEvent
handler.
addDropHandler
in interface HasDropHandlers
handler
- the drop handler
HandlerRegistration
used to remove this handlerpublic HandlerRegistration addErrorHandler(ErrorHandler handler)
HasErrorHandlers
ErrorEvent
handler.
addErrorHandler
in interface HasErrorHandlers
handler
- the error handler
HandlerRegistration
used to remove this handlerpublic HandlerRegistration addGestureChangeHandler(GestureChangeHandler handler)
HasGestureChangeHandlers
GestureChangeEvent
handler.
addGestureChangeHandler
in interface HasGestureChangeHandlers
handler
- the gesture change handler
HandlerRegistration
used to remove this handlerpublic HandlerRegistration addGestureEndHandler(GestureEndHandler handler)
HasGestureEndHandlers
GestureEndEvent
handler.
addGestureEndHandler
in interface HasGestureEndHandlers
handler
- the gesture end handler
HandlerRegistration
used to remove this handlerpublic HandlerRegistration addGestureStartHandler(GestureStartHandler handler)
HasGestureStartHandlers
GestureStartEvent
handler.
addGestureStartHandler
in interface HasGestureStartHandlers
handler
- the gesture start handler
HandlerRegistration
used to remove this handlerpublic HandlerRegistration addLoadHandler(LoadHandler handler)
HasLoadHandlers
LoadEvent
handler.
addLoadHandler
in interface HasLoadHandlers
handler
- the load handler
HandlerRegistration
used to remove this handler@Deprecated public void addLoadListener(LoadListener listener)
LoadHandler
and
ErrorHandler
instead
SourcesLoadEvents
addLoadListener
in interface SourcesLoadEvents
listener
- the listener interface to addpublic HandlerRegistration addMouseDownHandler(MouseDownHandler handler)
HasMouseDownHandlers
MouseDownEvent
handler.
addMouseDownHandler
in interface HasMouseDownHandlers
handler
- the mouse down handler
HandlerRegistration
used to remove this handler@Deprecated public void addMouseListener(MouseListener listener)
addMouseOverHandler(com.google.gwt.event.dom.client.MouseOverHandler)
addMouseMoveHandler(com.google.gwt.event.dom.client.MouseMoveHandler)
,
addMouseDownHandler(com.google.gwt.event.dom.client.MouseDownHandler)
, addMouseUpHandler(com.google.gwt.event.dom.client.MouseUpHandler)
and
addMouseOutHandler(com.google.gwt.event.dom.client.MouseOutHandler)
instead
SourcesMouseEvents
addMouseListener
in interface SourcesMouseEvents
listener
- the listener interface to addpublic HandlerRegistration addMouseMoveHandler(MouseMoveHandler handler)
HasMouseMoveHandlers
MouseMoveEvent
handler.
addMouseMoveHandler
in interface HasMouseMoveHandlers
handler
- the mouse move handler
HandlerRegistration
used to remove this handlerpublic HandlerRegistration addMouseOutHandler(MouseOutHandler handler)
HasMouseOutHandlers
MouseOutEvent
handler.
addMouseOutHandler
in interface HasMouseOutHandlers
handler
- the mouse out handler
HandlerRegistration
used to remove this handlerpublic HandlerRegistration addMouseOverHandler(MouseOverHandler handler)
HasMouseOverHandlers
MouseOverEvent
handler.
addMouseOverHandler
in interface HasMouseOverHandlers
handler
- the mouse over handler
HandlerRegistration
used to remove this handlerpublic HandlerRegistration addMouseUpHandler(MouseUpHandler handler)
HasMouseUpHandlers
MouseUpEvent
handler.
addMouseUpHandler
in interface HasMouseUpHandlers
handler
- the mouse up handler
HandlerRegistration
used to remove this handlerpublic HandlerRegistration addMouseWheelHandler(MouseWheelHandler handler)
HasMouseWheelHandlers
MouseWheelEvent
handler.
addMouseWheelHandler
in interface HasMouseWheelHandlers
handler
- the mouse wheel handler
HandlerRegistration
used to remove this handler@Deprecated public void addMouseWheelListener(MouseWheelListener listener)
addMouseWheelHandler(com.google.gwt.event.dom.client.MouseWheelHandler)
instead
public HandlerRegistration addTouchCancelHandler(TouchCancelHandler handler)
HasTouchCancelHandlers
TouchCancelEvent
handler.
addTouchCancelHandler
in interface HasTouchCancelHandlers
handler
- the touch cancel handler
HandlerRegistration
used to remove this handlerpublic HandlerRegistration addTouchEndHandler(TouchEndHandler handler)
HasTouchEndHandlers
TouchEndEvent
handler.
addTouchEndHandler
in interface HasTouchEndHandlers
handler
- the touch end handler
HandlerRegistration
used to remove this handlerpublic HandlerRegistration addTouchMoveHandler(TouchMoveHandler handler)
HasTouchMoveHandlers
TouchMoveEvent
handler.
addTouchMoveHandler
in interface HasTouchMoveHandlers
handler
- the touch move handler
HandlerRegistration
used to remove this handlerpublic HandlerRegistration addTouchStartHandler(TouchStartHandler handler)
HasTouchStartHandlers
TouchStartEvent
handler.
addTouchStartHandler
in interface HasTouchStartHandlers
handler
- the touch start handler
HandlerRegistration
used to remove this handlerpublic java.lang.String getAltText()
public int getHeight()
public int getOriginLeft()
public int getOriginTop()
public java.lang.String getUrl()
public int getWidth()
public void onBrowserEvent(Event event)
EventListener
onBrowserEvent
in interface EventListener
onBrowserEvent
in class Widget
event
- the event received@Deprecated public void removeClickListener(ClickListener listener)
HandlerRegistration.removeHandler()
method on the
object returned by addClickHandler(com.google.gwt.event.dom.client.ClickHandler)
instead
SourcesClickEvents
removeClickListener
in interface SourcesClickEvents
listener
- the listener interface to remove@Deprecated public void removeLoadListener(LoadListener listener)
HandlerRegistration.removeHandler()
method on the
object returned by an add*Handler method instead
SourcesLoadEvents
removeLoadListener
in interface SourcesLoadEvents
listener
- the listener interface to remove@Deprecated public void removeMouseListener(MouseListener listener)
HandlerRegistration.removeHandler()
method on the
object returned by an add*Handler method instead
SourcesMouseEvents
removeMouseListener
in interface SourcesMouseEvents
listener
- the listener interface to remove@Deprecated public void removeMouseWheelListener(MouseWheelListener listener)
HandlerRegistration.removeHandler()
method on the
object returned by addMouseWheelHandler(com.google.gwt.event.dom.client.MouseWheelHandler)
instead
public void setAltText(java.lang.String altText)
altText
- the alternate text to set topublic void setResource(ImageResource resource)
resource
- the ImageResource to displaypublic void setUrl(SafeUri url)
url
- the image URLpublic void setUrl(java.lang.String url)
url
- the image URLpublic void setUrlAndVisibleRect(SafeUri url, int left, int top, int width, int height)
url
- the image URLleft
- the horizontal coordinate of the upper-left vertex of the
visibility rectangletop
- the vertical coordinate of the upper-left vertex of the
visibility rectanglewidth
- the width of the visibility rectangleheight
- the height of the visibility rectanglepublic void setUrlAndVisibleRect(java.lang.String url, int left, int top, int width, int height)
url
- the image URLleft
- the horizontal coordinate of the upper-left vertex of the
visibility rectangletop
- the vertical coordinate of the upper-left vertex of the
visibility rectanglewidth
- the width of the visibility rectangleheight
- the height of the visibility rectanglepublic void setVisibleRect(int left, int top, int width, int height)
left
- the horizontal coordinate of the upper-left vertex of the
visibility rectangletop
- the vertical coordinate of the upper-left vertex of the
visibility rectanglewidth
- the width of the visibility rectangleheight
- the height of the visibility rectangleprotected void onLoad()
Widget
onLoad
in class Widget
|
GWT 2.7.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |