public class Image extends Widget implements SourcesLoadEvents, HasLoadHandlers, HasErrorHandlers, SourcesClickEvents, HasClickHandlers, HasDoubleClickHandlers, HasAllDragAndDropHandlers, HasAllGestureHandlers, HasAllMouseHandlers, HasAllTouchHandlers, SourcesMouseEvents
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.
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
DEBUG_ID_PREFIX
Modifier | Constructor and Description |
---|---|
|
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(String url)
Creates an image with a specified URL.
|
|
Image(String url,
int left,
int top,
int width,
int height)
Creates a clipped image with a specified URL and visibility rectangle.
|
Modifier and Type | Method and Description |
---|---|
HandlerRegistration |
addClickHandler(ClickHandler handler)
Adds a
ClickEvent handler. |
void |
addClickListener(ClickListener listener)
Deprecated.
|
HandlerRegistration |
addDoubleClickHandler(DoubleClickHandler handler)
Adds a
DoubleClickEvent handler. |
HandlerRegistration |
addDragEndHandler(DragEndHandler handler)
Adds a
DragEndEvent handler. |
HandlerRegistration |
addDragEnterHandler(DragEnterHandler handler)
Adds a
DragEnterEvent handler. |
HandlerRegistration |
addDragHandler(DragHandler handler)
Adds a
DragEvent handler. |
HandlerRegistration |
addDragLeaveHandler(DragLeaveHandler handler)
Adds a
DragLeaveEvent handler. |
HandlerRegistration |
addDragOverHandler(DragOverHandler handler)
Adds a
DragOverEvent handler. |
HandlerRegistration |
addDragStartHandler(DragStartHandler handler)
Adds a
DragStartEvent handler. |
HandlerRegistration |
addDropHandler(DropHandler handler)
Adds a
DropEvent handler. |
HandlerRegistration |
addErrorHandler(ErrorHandler handler)
Adds an
ErrorEvent handler. |
HandlerRegistration |
addGestureChangeHandler(GestureChangeHandler handler)
Adds a
GestureChangeEvent handler. |
HandlerRegistration |
addGestureEndHandler(GestureEndHandler handler)
Adds a
GestureEndEvent handler. |
HandlerRegistration |
addGestureStartHandler(GestureStartHandler handler)
Adds a
GestureStartEvent handler. |
HandlerRegistration |
addLoadHandler(LoadHandler handler)
Adds a
LoadEvent handler. |
void |
addLoadListener(LoadListener listener)
Deprecated.
use
LoadHandler and
ErrorHandler instead |
HandlerRegistration |
addMouseDownHandler(MouseDownHandler handler)
Adds a
MouseDownEvent handler. |
void |
addMouseListener(MouseListener listener)
Deprecated.
Use
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 |
HandlerRegistration |
addMouseMoveHandler(MouseMoveHandler handler)
Adds a
MouseMoveEvent handler. |
HandlerRegistration |
addMouseOutHandler(MouseOutHandler handler)
Adds a
MouseOutEvent handler. |
HandlerRegistration |
addMouseOverHandler(MouseOverHandler handler)
Adds a
MouseOverEvent handler. |
HandlerRegistration |
addMouseUpHandler(MouseUpHandler handler)
Adds a
MouseUpEvent handler. |
HandlerRegistration |
addMouseWheelHandler(MouseWheelHandler handler)
Adds a
MouseWheelEvent handler. |
void |
addMouseWheelListener(MouseWheelListener listener)
Deprecated.
|
HandlerRegistration |
addTouchCancelHandler(TouchCancelHandler handler)
Adds a
TouchCancelEvent handler. |
HandlerRegistration |
addTouchEndHandler(TouchEndHandler handler)
Adds a
TouchEndEvent handler. |
HandlerRegistration |
addTouchMoveHandler(TouchMoveHandler handler)
Adds a
TouchMoveEvent handler. |
HandlerRegistration |
addTouchStartHandler(TouchStartHandler handler)
Adds a
TouchStartEvent handler. |
String |
getAltText()
Gets the alternate text for the image.
|
int |
getHeight()
Gets the height of the image.
|
int |
getOriginLeft()
Gets the horizontal co-ordinate of the upper-left vertex of the image's
visibility rectangle.
|
int |
getOriginTop()
Gets the vertical co-ordinate of the upper-left vertex of the image's
visibility rectangle.
|
String |
getUrl()
Gets the URL of the image.
|
int |
getWidth()
Gets the width of the image.
|
void |
onBrowserEvent(Event event)
Fired whenever a browser event is received.
|
protected void |
onLoad()
This method is called immediately after a widget becomes attached to the
browser's document.
|
static void |
prefetch(SafeUri url)
Causes the browser to pre-fetch the image at a given URL.
|
static void |
prefetch(String url)
Causes the browser to pre-fetch the image at a given URL.
|
void |
removeClickListener(ClickListener listener)
Deprecated.
Use the
HandlerRegistration.removeHandler() method on the
object returned by addClickHandler(com.google.gwt.event.dom.client.ClickHandler) instead |
void |
removeLoadListener(LoadListener listener)
Deprecated.
Use the
HandlerRegistration.removeHandler() method on the
object returned by an add*Handler method instead |
void |
removeMouseListener(MouseListener listener)
Deprecated.
Use the
HandlerRegistration.removeHandler() method on the
object returned by an add*Handler method instead |
void |
removeMouseWheelListener(MouseWheelListener listener)
Deprecated.
Use the
HandlerRegistration.removeHandler() method on the
object returned by addMouseWheelHandler(com.google.gwt.event.dom.client.MouseWheelHandler) instead |
void |
setAltText(String altText)
Sets the alternate text of the image for user agents that can't render the
image.
|
void |
setResource(ImageResource resource)
Sets the url and the visibility rectangle for the image at the same time,
based on an ImageResource instance.
|
void |
setUrl(SafeUri url)
Sets the URL of the image to be displayed.
|
void |
setUrl(String url)
Sets the URL of the image to be displayed.
|
void |
setUrlAndVisibleRect(SafeUri url,
int left,
int top,
int width,
int height)
Sets the url and the visibility rectangle for the image at the same time.
|
void |
setUrlAndVisibleRect(String url,
int left,
int top,
int width,
int height)
Sets the url and the visibility rectangle for the image at the same time.
|
void |
setVisibleRect(int left,
int top,
int width,
int height)
Sets the visibility rectangle of an image.
|
static Image |
wrap(Element element)
Creates a Image widget that wraps an existing <img> element.
|
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onDetach, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
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
fireEvent
public Image()
public Image(ImageResource resource)
resource
- the ImageResource to be displayedpublic Image(String url)
url
- the URL of the image to be displayedpublic Image(SafeUri url)
url
- the URL of the image to be displayedpublic Image(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 usedpublic static void prefetch(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 handlerHandlerRegistration
used to remove this handler@Deprecated public void addClickListener(ClickListener listener)
addClickHandler(com.google.gwt.event.dom.client.ClickHandler)
insteadSourcesClickEvents
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 handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addDragEndHandler(DragEndHandler handler)
HasDragEndHandlers
DragEndEvent
handler.addDragEndHandler
in interface HasDragEndHandlers
handler
- the drag end handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addDragEnterHandler(DragEnterHandler handler)
HasDragEnterHandlers
DragEnterEvent
handler.addDragEnterHandler
in interface HasDragEnterHandlers
handler
- the drag end handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addDragHandler(DragHandler handler)
HasDragHandlers
DragEvent
handler.addDragHandler
in interface HasDragHandlers
handler
- the drag handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addDragLeaveHandler(DragLeaveHandler handler)
HasDragLeaveHandlers
DragLeaveEvent
handler.addDragLeaveHandler
in interface HasDragLeaveHandlers
handler
- the drag leave handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addDragOverHandler(DragOverHandler handler)
HasDragOverHandlers
DragOverEvent
handler.addDragOverHandler
in interface HasDragOverHandlers
handler
- the drag over handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addDragStartHandler(DragStartHandler handler)
HasDragStartHandlers
DragStartEvent
handler.addDragStartHandler
in interface HasDragStartHandlers
handler
- the drag start handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addDropHandler(DropHandler handler)
HasDropHandlers
DropEvent
handler.addDropHandler
in interface HasDropHandlers
handler
- the drop handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addErrorHandler(ErrorHandler handler)
HasErrorHandlers
ErrorEvent
handler.addErrorHandler
in interface HasErrorHandlers
handler
- the error handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addGestureChangeHandler(GestureChangeHandler handler)
HasGestureChangeHandlers
GestureChangeEvent
handler.addGestureChangeHandler
in interface HasGestureChangeHandlers
handler
- the gesture change handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addGestureEndHandler(GestureEndHandler handler)
HasGestureEndHandlers
GestureEndEvent
handler.addGestureEndHandler
in interface HasGestureEndHandlers
handler
- the gesture end handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addGestureStartHandler(GestureStartHandler handler)
HasGestureStartHandlers
GestureStartEvent
handler.addGestureStartHandler
in interface HasGestureStartHandlers
handler
- the gesture start handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addLoadHandler(LoadHandler handler)
HasLoadHandlers
LoadEvent
handler.addLoadHandler
in interface HasLoadHandlers
handler
- the load handlerHandlerRegistration
used to remove this handler@Deprecated public void addLoadListener(LoadListener listener)
LoadHandler
and
ErrorHandler
insteadSourcesLoadEvents
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 handlerHandlerRegistration
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)
insteadSourcesMouseEvents
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 handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addMouseOutHandler(MouseOutHandler handler)
HasMouseOutHandlers
MouseOutEvent
handler.addMouseOutHandler
in interface HasMouseOutHandlers
handler
- the mouse out handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addMouseOverHandler(MouseOverHandler handler)
HasMouseOverHandlers
MouseOverEvent
handler.addMouseOverHandler
in interface HasMouseOverHandlers
handler
- the mouse over handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addMouseUpHandler(MouseUpHandler handler)
HasMouseUpHandlers
MouseUpEvent
handler.addMouseUpHandler
in interface HasMouseUpHandlers
handler
- the mouse up handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addMouseWheelHandler(MouseWheelHandler handler)
HasMouseWheelHandlers
MouseWheelEvent
handler.addMouseWheelHandler
in interface HasMouseWheelHandlers
handler
- the mouse wheel handlerHandlerRegistration
used to remove this handler@Deprecated public void addMouseWheelListener(MouseWheelListener listener)
addMouseWheelHandler(com.google.gwt.event.dom.client.MouseWheelHandler)
insteadpublic HandlerRegistration addTouchCancelHandler(TouchCancelHandler handler)
HasTouchCancelHandlers
TouchCancelEvent
handler.addTouchCancelHandler
in interface HasTouchCancelHandlers
handler
- the touch cancel handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addTouchEndHandler(TouchEndHandler handler)
HasTouchEndHandlers
TouchEndEvent
handler.addTouchEndHandler
in interface HasTouchEndHandlers
handler
- the touch end handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addTouchMoveHandler(TouchMoveHandler handler)
HasTouchMoveHandlers
TouchMoveEvent
handler.addTouchMoveHandler
in interface HasTouchMoveHandlers
handler
- the touch move handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addTouchStartHandler(TouchStartHandler handler)
HasTouchStartHandlers
TouchStartEvent
handler.addTouchStartHandler
in interface HasTouchStartHandlers
handler
- the touch start handlerHandlerRegistration
used to remove this handlerpublic String getAltText()
public int getHeight()
public int getOriginLeft()
public int getOriginTop()
public 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)
insteadSourcesClickEvents
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 insteadSourcesLoadEvents
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 insteadSourcesMouseEvents
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)
insteadpublic void setAltText(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(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(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 rectangleCopyright © 2018. All rights reserved.