Interface IImagemap
- All Superinterfaces:
IAnyGroup<IImagemap>,IChildable<IImagemap,,IArea> IComponent<IImagemap>,IHtmlBasedComponent<IImagemap>,IImageBase<IImagemap>,IXulElement<IImagemap>
Imagemap component
An IImagemap component is a special image. It accepts whatever attribute an IImage component accepts.
However, unlike IImage, it support IArea as its children.
The IImagemap component will translate the mouse pointer coordinates into a logical name, which is the id of the IArea that user clicked.
For example:
@RichletMapping("/example")
public IComponent example() {
return IImagemap.of(
IArea.ofId("left").withCoords("0, 0, 45, 80"),
IArea.ofId("right").withCoords("46, 0, 90, 80")
).withSrc("/stateless/ZK-Logo.gif").withAction(this::doClick);
}
@Action(type = Events.ON_CLICK)
public void doClick(MouseData mouseData) {
Clients.log(mouseData.getArea());
}
The above example shows how to use Imagemap with IArea.
The ZK-Logo.gif is a 90x80 image, we divide the image into 2 parts left and right by using IArea.withCoords(String).
Once you clicked on the area of Imagemap, you can get the id of the IArea through MouseData.
Note: Don't try to use CSS background as your image, the image map need a real image or it won't work.
- Author:
- katherine
- See Also:
-
ImagemapIArea
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classBuilds instances of typeIImagemap.static classBuilds an updater of typeIImagemapforUiAgent.smartUpdate(Locator, SmartUpdater). -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault StringReturns the client widget class.of(I... areas) Returns the instance with the givenareas.Returns the instance with the givenareas.static IImagemapReturns the instance with the givensrc.static IImagemapReturns the instance with the given id.static IImagemapReturns the instance with the givenwidthandheight.Methods inherited from interface org.zkoss.stateless.sul.IChildable
getChildren, withChildren, withChildrenMethods inherited from interface org.zkoss.stateless.sul.IComponent
getAction, getActions, getClientAttributes, getId, getMold, getWidgetListeners, getWidgetOverrides, isVisible, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withActions, withActions, withClientAttribute, withClientAttributes, withId, withMold, withVisible, withWidgetClass, withWidgetListener, withWidgetListeners, withWidgetOverride, withWidgetOverridesMethods inherited from interface org.zkoss.stateless.sul.IHtmlBasedComponent
getClientAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getSkeleton, getStyle, getTabindex, getTooltiptext, getTop, getVflex, getWidth, getZclass, getZIndex, isFocus, withClientAction, withDraggable, withDroppable, withFocus, withHeight, withHflex, withLeft, withRenderdefer, withSclass, withSkeleton, withStyle, withTabindex, withTabindex, withTooltiptext, withTop, withVflex, withWidth, withZclass, withZIndexMethods inherited from interface org.zkoss.stateless.sul.IImageBase
getContent, getHover, getSrc, isPreloadImage, withContent, withContent, withHover, withPreloadImage, withSrcMethods inherited from interface org.zkoss.stateless.sul.IXulElement
getContext, getCtrlKeys, getPopup, getTooltip, withContext, withCtrlKeys, withPopup, withTooltip
-
Field Details
-
DEFAULT
Constant for default attributes of this immutable component.
-
-
Method Details
-
getWidgetClass
Returns the client widget class.Default:
"zul.wgt.Imagemap"- Specified by:
getWidgetClassin interfaceIComponent<IImagemap>
-
of
Returns the instance with the givensrc.- Parameters:
src- The URI of the image source.
-
of
Returns the instance with the givenareas.- Parameters:
areas- TheIArealist as the children of this component.
-
of
Returns the instance with the givenareas.- Parameters:
areas- TheIAreaas the children of this component.
-
ofSize
Returns the instance with the givenwidthandheight.- Parameters:
width- The width of the image.height- The height of the image.
-
ofId
Returns the instance with the given id.- Parameters:
id- The id to identify this component
-