Class WImage
public class WImage extends WInteractWidget
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 a WMouseEvent
object, it is possible to react to clicks in specific parts of the image. An alternative is to
define interactive areas on the image using addArea()
,
which in addition allows to have customized tool tips for certain image areas (using WAbstractArea#setToolTip()
).
WImage is an inline
widget.
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_
-
Constructor Summary
Constructors Constructor Description WImage()
Creates an empty image widget.WImage(WContainerWidget parent)
Creates an empty image widget.WImage(WLink link)
Creates an image widget with a given image link.WImage(WLink link, WContainerWidget parent)
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 parent)
Creates an image widget with a given image link and alternate text.WImage(WResource resource, java.lang.CharSequence altText)
Creates an image widget with given image resource and alternate text (deprecated).WImage(WResource resource, java.lang.CharSequence altText, WContainerWidget parent)
Deprecated.WImage(java.lang.String imageRef)
Creates an image widget with given image URL (deprecated).WImage(java.lang.String imageRef, WContainerWidget parent)
Deprecated.UseWImage()
instead.WImage(java.lang.String imageRef, java.lang.CharSequence altText)
Creates an image widget with given image URL and alternate text (deprecated).WImage(java.lang.String imageRef, java.lang.CharSequence altText, WContainerWidget parent)
Deprecated.UseWImage()
instead. -
Method Summary
Modifier and Type Method Description void
addArea(WAbstractArea area)
Adds an interactive area.protected void
defineJavaScript()
WString
getAlternateText()
Returns the alternate text.WAbstractArea
getArea(int index)
Returns the interactive area at the given index.java.util.List<WAbstractArea>
getAreas()
Returns the interactive areas set for this widget.protected void
getDomChanges(java.util.List<DomElement> result, WApplication app)
Get DOM changes for this widget.WLink
getImageLink()
Returns the image link.java.lang.String
getImageRef()
Deprecated.UsegetImageLink()
instead.WResource
getResource()
Deprecated.UsesetImageLink()
instead.java.lang.String
getSetAreaCoordsJS()
protected java.lang.String
getUpdateAreaCoordsJSON()
java.lang.String
getUpdateAreasJS()
EventSignal
imageLoaded()
Event emitted when the image was loaded.void
insertArea(int index, WAbstractArea area)
Inserts an interactive area.void
remove()
Destructor.void
removeArea(WAbstractArea area)
Removes an interactive area.protected void
render(java.util.EnumSet<RenderFlag> flags)
Renders the widget.void
setAlternateText(java.lang.CharSequence text)
Sets an alternate text.void
setImageLink(WLink link)
Sets the image link.void
setImageRef(java.lang.String ref)
Deprecated.UsesetImageLink()
instead.void
setResource(WResource resource)
Deprecated.UsesetImageLink()
instead.void
setTargetJS(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, 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, isCanReceiveFocus, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, jsStringLiteral, jsStringLiteral, parentResized, parentResized, propagateSetVisible, refresh, removeScript, removeStyleClass, resize, scrollVisibilityChanged, setAttributeValue, setBaseZIndex, setCanReceiveFocus, setClearSides, setDecorationStyle, setDeferredToolTip, setDisabled, setFloatSide, setFocus, setHidden, setHiddenKeepsGeometry, setHtmlTagName, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setOffsets, setPositionScheme, setScrollVisibilityEnabled, setScrollVisibilityMargin, setSelectable, setStyleClass, setTabIndex, setThemeStyleEnabled, setToolTip, setVerticalAlignment, updateSignalConnection, voidEventSignal
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, boxBorder, boxPadding, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isLayoutSizeAware, layoutSizeChanged, needsRerender, positionAt, positionAt, removeChild, removeStyleClass, render, resize, scheduleRender, scheduleRender, scheduleRender, setClearSides, setDeferredToolTip, setFocus, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setObjectName, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
Methods inherited from class eu.webtoolkit.jwt.WObject
addChild, getObjectName, setFormData
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
WImage
Creates an empty image widget. -
WImage
public WImage()Creates an empty image widget. -
WImage
Creates an image widget with a given image link.The
imageLink
may link to a URL or resource. -
WImage
Creates an image widget with a given image link. -
WImage
Creates an image widget with a given image link and alternate text.The
imageLink
may link to a URL or resource. -
WImage
Creates an image widget with a given image link and alternate text. -
WImage
Deprecated.UseWImage()
instead.Creates an image widget with given image URL (deprecated). -
WImage
public WImage(java.lang.String imageRef)Creates an image widget with given image URL (deprecated). -
WImage
Deprecated.UseWImage()
instead.Creates an image widget with given image URL and alternate text (deprecated). -
WImage
public WImage(java.lang.String imageRef, java.lang.CharSequence altText)Creates an image widget with given image URL and alternate text (deprecated). -
WImage
Deprecated.UseWImage()
instead.Creates an image widget with given image resource and alternate text (deprecated). -
WImage
Creates an image widget with given image resource and alternate text (deprecated).
-
-
Method Details
-
remove
public void remove()Description copied from class:WWidget
Destructor.Deletes a widget and all children (recursively). If the widget is contained in another widget, it is removed first.
- Overrides:
remove
in classWInteractWidget
- See Also:
WContainerWidget.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
Returns the alternate text.- See Also:
setAlternateText(CharSequence text)
-
setImageLink
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
Returns the image link. -
setImageRef
public void setImageRef(java.lang.String ref)Deprecated.UsesetImageLink()
instead.Sets the image URL (deprecated). -
getImageRef
public java.lang.String getImageRef()Deprecated.UsegetImageLink()
instead.Returns the image URL (deprecated).When the image is specified as a resource, this returns the current resource URL.
-
setResource
Deprecated.UsesetImageLink()
instead.Sets the image resource (deprecated). -
getResource
Deprecated.UsesetImageLink()
instead.Returns the image resource (deprecated.Returns
null
if no image resource was set. -
addArea
Adds an interactive area.Adds the
area
which listens to events in a specific region of the image. Areas are organized in an indexed list, to which the givenarea
is appended. When areas overlap, the area with the lowest index receives the event.Ownership of the
area
is transferred to the image. -
insertArea
Inserts an interactive area.Inserts the
area
which 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
area
is transferred to the image. -
removeArea
Removes an interactive area.Removes the
area
from this widget, and also returns the ownership.- See Also:
addArea(WAbstractArea area)
-
getArea
Returns the interactive area at the given index.Returns
null
ifindex
was invalid. -
getAreas
Returns the interactive areas set for this widget.- See Also:
addArea(WAbstractArea area)
-
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
Description copied from class:WWebWidget
Get DOM changes for this widget.This is an internal function, and should not be called directly, or be overridden!
- Overrides:
getDomChanges
in classWWebWidget
-
defineJavaScript
protected void defineJavaScript() -
render
Description copied from class:WWidget
Renders 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:
render
in classWWebWidget
-
getUpdateAreaCoordsJSON
protected java.lang.String getUpdateAreaCoordsJSON()
-
WImage()
instead.