Class WImage
- java.lang.Object
-
- eu.webtoolkit.jwt.WObject
-
- eu.webtoolkit.jwt.WWidget
-
- eu.webtoolkit.jwt.WWebWidget
-
- eu.webtoolkit.jwt.WInteractWidget
-
- eu.webtoolkit.jwt.WImage
-
public class WImage extends WInteractWidget
A widget that displays an image.The image may be specified either as a URL, or may be dynamically generated by a
WResource.You may listen to events by attaching event listeners to signals such as
WInteractWidget.clicked(). Since mouse events pass the coordinates through aWMouseEventobject, it is possible to react to clicks in specific parts of the image. An alternative is to define interactive areas on the image usingaddArea(), which in addition allows to have customized tool tips for certain image areas (usingWAbstractArea#setToolTip()).WImage is an
inlinewidget.CSS
The widget corresponds to the HTML
<img>tag and does not provide styling. It can be styled using inline or external CSS as appropriate.- See Also:
WResource,WPaintedWidget
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
-
Field Summary
-
Fields inherited from class eu.webtoolkit.jwt.WInteractWidget
dragTouchEndSlot_, dragTouchSlot_, noDefault
-
Fields inherited from class eu.webtoolkit.jwt.WWidget
WT_GETEXTRAMS_JS
-
-
Constructor Summary
Constructors Constructor Description WImage()Creates an empty image widget.WImage(WContainerWidget parentContainer)Creates an empty image widget.WImage(WLink link)Creates an image widget with a given image link.WImage(WLink link, WContainerWidget parentContainer)Creates an image widget with a given image link.WImage(WLink link, java.lang.CharSequence altText)Creates an image widget with a given image link and alternate text.WImage(WLink link, java.lang.CharSequence altText, WContainerWidget parentContainer)Creates an image widget with a given image link and alternate text.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddArea(WAbstractArea area)Adds an interactive area.protected voiddefineJavaScript()WStringgetAlternateText()Returns the alternate text.java.lang.StringgetAlternativeBotUrl()Returns the alternative URL, given to bots, for this image.WAbstractAreagetArea(int index)Returns the interactive area at the given index.java.util.List<WAbstractArea>getAreas()Returns the interactive areas set for this widget.protected voidgetDomChanges(java.util.List<DomElement> result, WApplication app)Get DOM changes for this widget.WLinkgetImageLink()Returns the image link.java.lang.StringgetSetAreaCoordsJS()protected java.lang.StringgetUpdateAreaCoordsJSON()java.lang.StringgetUpdateAreasJS()EventSignalimageLoaded()Event emitted when the image was loaded.voidinsertArea(int index, WAbstractArea area)Inserts an interactive area.protected voiditerateChildren(HandleWidgetMethod method)voidremove()Destructor.WAbstractArearemoveArea(WAbstractArea area)Removes an interactive area.protected voidrender(java.util.EnumSet<RenderFlag> flags)Renders the widget.voidsetAlternateText(java.lang.CharSequence text)Sets an alternate text.voidsetAlternativeBotUrl(java.lang.String url)Sets an alternative URL, given to bots, for this image.voidsetImageLink(WLink link)Sets the image link.voidsetTargetJS(java.lang.String targetJS)-
Methods inherited from class eu.webtoolkit.jwt.WInteractWidget
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, getMouseOverDelay, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, propagateSetEnabled, setDraggable, setDraggable, setDraggable, setDraggable, setMouseOverDelay, setPopup, touchEnded, touchMoved, touchStarted, unsetDraggable
-
Methods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, beingDeleted, blurred, callJavaScriptMember, childrenChanged, createDomElement, doJavaScript, enableAjax, escapeText, escapeText, escapeText, escapeText, find, findById, focussed, getAttributeValue, getBaseZIndex, getChildren, getClearSides, getDecorationStyle, getFloatSide, getHeight, getHtmlTagName, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getScrollVisibilityMargin, getStyleClass, getTabIndex, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, hasFocus, hasStyleClass, hideToolTip, isCanReceiveFocus, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, jsStringLiteral, jsStringLiteral, manageWidget, parentResized, parentResized, propagateSetVisible, refresh, removeScript, removeStyleClass, resize, scrollVisibilityChanged, setAttributeValue, setBaseZIndex, setCanReceiveFocus, setClearSides, setDecorationStyle, setDeferredToolTip, setDisabled, setFlexBox, setFloatSide, setFocus, setHidden, setHiddenKeepsGeometry, setHtmlTagName, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setObjectName, setOffsets, setParentWidget, setPositionScheme, setScrollVisibilityEnabled, setScrollVisibilityMargin, setSelectable, setStyleClass, setTabIndex, setThemeStyleEnabled, setToolTip, setVerticalAlignment, showToolTip, showToolTipOnHover, unescapeText, updateSignalConnection, voidEventSignal, widgetAdded, widgetRemoved
-
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, applyThemeStyles, boxBorder, boxPadding, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, layoutSizeChanged, needsRerender, positionAt, positionAt, positionAt, positionAt, removeFromParent, removeStyleClass, removeWidget, render, resize, scheduleRender, scheduleRender, scheduleRender, scheduleThemeStyleApply, setClearSides, setDeferredToolTip, setFocus, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
-
Methods inherited from class eu.webtoolkit.jwt.WObject
getObjectName, setFormData
-
-
-
-
Constructor Detail
-
WImage
public WImage(WContainerWidget parentContainer)
Creates an empty image widget.
-
WImage
public WImage()
Creates an empty image widget.
-
WImage
public WImage(WLink link, WContainerWidget parentContainer)
Creates an image widget with a given image link.The
imageLinkmay link to a URL or resource.
-
WImage
public WImage(WLink link)
Creates an image widget with a given image link.
-
WImage
public WImage(WLink link, java.lang.CharSequence altText, WContainerWidget parentContainer)
Creates an image widget with a given image link and alternate text.The
imageLinkmay link to a URL or resource.
-
WImage
public WImage(WLink link, java.lang.CharSequence altText)
Creates an image widget with a given image link and alternate text.
-
-
Method Detail
-
remove
public void remove()
Description copied from class:WWidgetDestructor.Deletes a widget and all contained contents.
- Overrides:
removein classWInteractWidget- See Also:
WWidget.removeWidget(WWidget widget)
-
setAlternateText
public void setAlternateText(java.lang.CharSequence text)
Sets an alternate text.The alternate text should provide a fallback for browsers that do not display an image. If no sensible fallback text can be provided, an empty text is preferred over nonsense.
This should not be confused with
WWebWidget.getToolTip()text, which provides additional information that is displayed when the mouse hovers over the image.The default alternate text is an empty text ("").
- See Also:
getAlternateText()
-
getAlternateText
public WString getAlternateText()
Returns the alternate text.- See Also:
setAlternateText(CharSequence text)
-
setImageLink
public void setImageLink(WLink link)
Sets the image link.The image may be specified as a URL or as a resource. A resource specifies application-dependent content, which may be used to generate an image on demand.
-
getImageLink
public WLink getImageLink()
Returns the image link.
-
setAlternativeBotUrl
public void setAlternativeBotUrl(java.lang.String url)
Sets an alternative URL, given to bots, for this image.If
urlis not empty, this URL will be used instead of the regular URL when the request comes from a bot (e.g., a web crawler).By default, this is empty.
-
getAlternativeBotUrl
public java.lang.String getAlternativeBotUrl()
Returns the alternative URL, given to bots, for this image.- See Also:
setAlternativeBotUrl(String url)
-
addArea
public void addArea(WAbstractArea area)
Adds an interactive area.Adds the
areawhich listens to events in a specific region of the image. Areas are organized in an indexed list, to which the givenareais appended. When areas overlap, the area with the lowest index receives the event.Ownership of the
areais transferred to the image.Note: Currently it is not possible to add a first area after the image has been rendered. If you want to use interactive areas you need to add one immediately.
-
insertArea
public void insertArea(int index, WAbstractArea area)Inserts an interactive area.Inserts the
areawhich listens to events in the coresponding area of the image. Areas are organized in a list, and the area is inserted at indexindex. When areas overlap, the area with the lowest index receives the event.Ownership of the
areais transferred to the image.
-
removeArea
public WAbstractArea removeArea(WAbstractArea area)
Removes an interactive area.Removes the
areafrom this widget.
-
getArea
public WAbstractArea getArea(int index)
Returns the interactive area at the given index.Returns
nullifindexwas invalid.
-
getAreas
public java.util.List<WAbstractArea> getAreas()
Returns the interactive areas set for this widget.- See Also:
addArea(WAbstractArea area)
-
imageLoaded
public EventSignal imageLoaded()
Event emitted when the image was loaded.
-
setTargetJS
public void setTargetJS(java.lang.String targetJS)
-
getUpdateAreasJS
public java.lang.String getUpdateAreasJS()
-
getSetAreaCoordsJS
public java.lang.String getSetAreaCoordsJS()
-
getDomChanges
protected void getDomChanges(java.util.List<DomElement> result, WApplication app)
Description copied from class:WWebWidgetGet DOM changes for this widget.This is an internal function, and should not be called directly, or be overridden!
- Overrides:
getDomChangesin classWWebWidget
-
defineJavaScript
protected void defineJavaScript()
-
render
protected void render(java.util.EnumSet<RenderFlag> flags)
Description copied from class:WWidgetRenders the widget.This function renders the widget (or an update for the widget), after this has been scheduled using
scheduleRender().The default implementation will render the widget by serializing changes to JavaScript and HTML. You may want to reimplement this widget if you have been postponing some of the layout / rendering implementation until the latest moment possible. In that case you should make sure you call the base implementation however.
- Overrides:
renderin classWInteractWidget
-
iterateChildren
protected void iterateChildren(HandleWidgetMethod method)
- Overrides:
iterateChildrenin classWWebWidget
-
getUpdateAreaCoordsJSON
protected java.lang.String getUpdateAreaCoordsJSON()
-
-