Interface IImagemap

  • All Superinterfaces:
    IAnyGroup<IImagemap>, IChildable<IImagemap,​IArea>, IComponent<IImagemap>, IHtmlBasedComponent<IImagemap>, IImageBase<IImagemap>, IXulElement<IImagemap>

    public interface IImagemap
    extends IImageBase<IImagemap>, IChildable<IImagemap,​IArea>, IAnyGroup<IImagemap>
    Immutable 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:
    Imagemap, IArea
    • Field Detail

      • DEFAULT

        static final IImagemap DEFAULT
        Constant for default attributes of this immutable component.
    • Method Detail

      • getWidgetClass

        default java.lang.String getWidgetClass()
        Returns the client widget class.

        Default: "zul.wgt.Imagemap"

        Specified by:
        getWidgetClass in interface IComponent<IImagemap>
      • of

        static IImagemap of​(java.lang.String src)
        Returns the instance with the given src.
        Parameters:
        src - The URI of the image source.
      • of

        static <I extends IAreaIImagemap of​(java.lang.Iterable<? extends I> areas)
        Returns the instance with the given areas.
        Parameters:
        areas - The IArea list as the children of this component.
      • of

        static <I extends IAreaIImagemap of​(I... areas)
        Returns the instance with the given areas.
        Parameters:
        areas - The IArea as the children of this component.
      • ofSize

        static IImagemap ofSize​(java.lang.String width,
                                java.lang.String height)
        Returns the instance with the given width and height.
        Parameters:
        width - The width of the image.
        height - The height of the image.
      • ofId

        static IImagemap ofId​(java.lang.String id)
        Returns the instance with the given id.
        Parameters:
        id - The id to identify this component