Package com.storedobject.ui
Class ImageMap
java.lang.Object
com.vaadin.flow.component.Component
com.storedobject.ui.ImageMap
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier
,com.vaadin.flow.component.DetachNotifier
,com.vaadin.flow.component.HasElement
,com.vaadin.flow.component.HasStyle
,Serializable
@Tag("div")
public class ImageMap
extends com.vaadin.flow.component.Component
An image component with clickable rectangular areas.
- Author:
- Syam (Original version was written by Leif Åstrand of Vaadin)
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A clickable rectangular area in an image map.static class
Event fired when an area is clicked. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddArea
(int x, int y, int width, int height) Adds a clickable rectangle area to this image map.com.vaadin.flow.shared.Registration
addClickHandler
(ClickHandler clickHandler) Add click handler.getAlt()
Gets the alternate text for the image.void
removeArea
(ImageMap.Area area) Removes an Area that was added earlier.void
Sets the alternate text for the image.void
setAreaBackground
(String areaBackground) Sets the default CSS background definition to use for areas that are not hovered.void
setAreaBorder
(String areaBorder) Sets the default CSS border definition to use for areas that are not hovered.void
setHoverBackground
(String hoverBackground) Sets the default CSS background definition to use for hovered areas.void
setHoverBorder
(String hoverBorder) Sets the default CSS border definition to use for hovered areas.void
setSource
(com.vaadin.flow.server.AbstractStreamResource source) Sets the image URL with the URL of the givenStreamResource
.void
Sets the image URL.Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Constructor Details
-
ImageMap
public ImageMap()Creates an empty image map. -
ImageMap
Creates an empty image map with the given image URL and alt text.- Parameters:
source
- The image URL to use, notnull
-
ImageMap
public ImageMap(com.vaadin.flow.server.AbstractStreamResource source) Creates an empty image map with the given image resource and alt text.- Parameters:
source
- The image resource to use, notnull
-
-
Method Details
-
addArea
Adds a clickable rectangle area to this image map. The area coordinates are relative to the upper left corner of the image map.- Parameters:
x
- The x coordinate of the area, in pixelsy
- The y coordinate of the area, in pixelswidth
- The area width, in pixelsheight
- The area height, in pixels- Returns:
- the created area, not
null
-
removeArea
Removes an Area that was added earlier.- Parameters:
area
- Area to be removed
-
addClickHandler
Add click handler.- Parameters:
clickHandler
- Click handler- Returns:
- Registration.
-
setSource
-
setSource
public void setSource(com.vaadin.flow.server.AbstractStreamResource source) Sets the image URL with the URL of the givenStreamResource
.- Parameters:
source
- The resource value, not null
-
setAlt
Sets the alternate text for the image.- Parameters:
alt
- The alternate text
-
getAlt
-
setHoverBackground
Sets the default CSS background definition to use for hovered areas. The setting can be overridden on a per-area basis usingImageMap.Area.setHoverBackground(String)
. By default, black with 90% transparency is used (defined asrgba(0,0,0,0.1)
).- Parameters:
hoverBackground
- The CSS background definition, ornull
to clear any set value and use the default
-
setHoverBorder
Sets the default CSS border definition to use for hovered areas. The setting can be overridden on a per-area basis usingImageMap.Area.setHoverBorder(String)
. By default, no border is used- Parameters:
hoverBorder
- The CSS border definition, ornull
to clear any set value and use the default
-
setAreaBackground
Sets the default CSS background definition to use for areas that are not hovered. The setting can be overridden on a per-area basis usingImageMap.Area.setBackground(String)
. By default, no background is used.- Parameters:
areaBackground
- The CSS background definition, ornull
to clear any set value and use the default
-
setAreaBorder
Sets the default CSS border definition to use for areas that are not hovered. The setting can be overridden on a per-area basis usingImageMap.Area.setBorder(String)
. By default, no border is used.- Parameters:
areaBorder
- The CSS border definition, ornull
to clear any set value and use the default
-