Package com.storedobject.ui
Class ImageViewer
java.lang.Object
com.storedobject.vaadin.View
com.storedobject.ui.ImageViewer
- All Implemented Interfaces:
ClickHandler,ExecutableView,ValueChangeHandler,com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.ClickEvent<? extends com.vaadin.flow.component.Component>>,com.vaadin.flow.component.HasValue.ValueChangeListener,Serializable,Runnable,EventListener
- Direct Known Subclasses:
SiteView
A
View that shows a background image, a parent image and other overlay-components relative to the parent
image. The background image and/or parent image may be absent.- Author:
- Syam
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.storedobject.vaadin.ClickHandler
ClickHandler.ModifiedClickEvent<C extends com.vaadin.flow.component.Component> -
Constructor Summary
ConstructorsConstructorDescriptionImageViewer(String caption) Create an empty view.ImageViewer(String caption, MediaFile mediaFileForBackground) Create the image view from the given media image.ImageViewer(String caption, Image backgroundImage) Create the image view from the given image.ImageViewer(String caption, com.vaadin.flow.server.AbstractStreamResource backgroundImageResource) Create the image view with a background image from a resource.ImageViewer(String caption, String backgroundImageURL) Create the image view with a background image from a URL. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(com.vaadin.flow.component.Component component, int x, int y) Add a component at the given location (relative to the parent component if exists, otherwise relative the origin - origin (0, 0) in the upper left corner).voidadd(com.vaadin.flow.component.Component component, int x, int y, boolean absolute) Add a component at the given location.voidAdd a component at the given location (relative to the parent component if exists, otherwise relative the origin - origin (0, 0) in the upper left corner).voidadd(com.vaadin.flow.dom.Element element, int x, int y) Add an element at the given location (relative to the parent component if exists, otherwise relative the origin - origin (0, 0) in the upper left corner).voidadd(com.vaadin.flow.dom.Element element, int x, int y, boolean absolute) Add an element at the given location.final voidInvoke this method (typically from your constructor) if you want to allow dynamic movement (drag and drop) of overlaid components.voidThis will be invoked by theApplicationjust before making the component of this view visible.intGet the X-offset of the parent image.intGet the Y-offset of the parent image.protected voidinitUI()This method is invoked when the view wants to determine its "content" to be displayed and nothing exists at that moment.final booleanCheck whether movement is allowed or not.voidremove(com.vaadin.flow.component.Component component) Remove a component.voidremove(com.vaadin.flow.dom.Element element) Remove an element.voidRemove all components.voidRemove the parent image.voidreposition(com.vaadin.flow.component.Component component, int x, int y) Re-position a component.voidreposition(com.vaadin.flow.dom.Element element, int x, int y) Re-position an element.protected booleansavePosition(Object item, int x, int y) Save the position.voidsetBackgroundSource(MediaFile mediaFile) Set the source of the background image content.voidsetBackgroundSource(com.vaadin.flow.server.AbstractStreamResource source) Set the source of the background image content.voidsetBackgroundSource(String source) Set the source of the background image content.voidsetParentImage(Image parentImage, int offsetX, int offsetY) Set a parent image.Methods inherited from class com.storedobject.vaadin.View
abort, aborted, addClosedListener, addOpenedListener, clean, close, createCloseableView, createWindow, execute, execute, execute, executing, focus, focus, focusAny, getApplication, getCaption, getComponent, getContent, getCreatedBy, getEmbeddedView, getMenuItem, getMenuItem, getView, invoke, isFullScreen, isScrollable, isWindowMode, select, setCaption, setComponent, setCreatedBy, setDefaultPadding, setEmbeddedView, setFirstFocus, setFullScreen, setScrollable, setWindowMode, skipFirstFocusMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.storedobject.vaadin.ClickHandler
clicked, doubleClicked, onComponentEvent, rightClickedMethods inherited from interface com.storedobject.vaadin.ExecutableView
clearAlerts, clicked, createMenuItem, error, getMenuIconName, getView, isCloseable, isHomeView, log, log, message, returnedFrom, run, setClickable, speak, trackValueChange, tray, valueChanged, warningMethods inherited from interface com.storedobject.vaadin.ValueChangeHandler
valueChanged
-
Constructor Details
-
ImageViewer
Create an empty view. Images and components can be set later.- Parameters:
caption- Caption.
-
ImageViewer
-
ImageViewer
public ImageViewer(String caption, com.vaadin.flow.server.AbstractStreamResource backgroundImageResource) Create the image view with a background image from a resource.- Parameters:
caption- Caption.backgroundImageResource- Resource for the background image.
-
ImageViewer
-
ImageViewer
-
-
Method Details
-
initUI
protected void initUI()Description copied from class:ViewThis method is invoked when the view wants to determine its "content" to be displayed and nothing exists at that moment.View.setComponent(Component)may be called from within this method. -
decorateComponent
public void decorateComponent()Description copied from class:ViewThis will be invoked by theApplicationjust before making the component of this view visible. The default implementation does the following to the component:If it is a
Dialog, just returns without making any changes.Will set the size to 'full' by invoking
HasSize.setSizeFull()if it is an instance ofHasSizeso that it covers the entire content area.Padding will be set to 5px (unless changed via
View.setDefaultPadding(int)) and box-sizing to border-box. So, if you want to fill the component to the entire content area, you will have to override this method and set the padding to 0px.If the component is an instance of
Div, its "display" style will be set to "flex" and its "flex-direction" will be set to "column".- Overrides:
decorateComponentin classView
-
setBackgroundSource
Set the source of the background image content.- Parameters:
source- URL resource.
-
setBackgroundSource
public void setBackgroundSource(com.vaadin.flow.server.AbstractStreamResource source) Set the source of the background image content.- Parameters:
source- Stream resource of the image content.
-
setBackgroundSource
Set the source of the background image content.- Parameters:
mediaFile- Image source
-
allowMovement
public final void allowMovement()Invoke this method (typically from your constructor) if you want to allow dynamic movement (drag and drop) of overlaid components. -
isMovementAllowed
public final boolean isMovementAllowed()Check whether movement is allowed or not.- Returns:
- True/false.
-
add
public void add(com.vaadin.flow.component.Component component, int x, int y) Add a component at the given location (relative to the parent component if exists, otherwise relative the origin - origin (0, 0) in the upper left corner).- Parameters:
component- Component to add.x- X-coordinate.y- Y-coordinate.
-
add
public void add(com.vaadin.flow.component.Component component, int x, int y, boolean absolute) Add a component at the given location.- Parameters:
component- Component to add.x- X-coordinate.y- Y-coordinate.absolute- Whether the (X, Y) values given are absolute values or not.
-
add
Add a component at the given location (relative to the parent component if exists, otherwise relative the origin - origin (0, 0) in the upper left corner).- Parameters:
component- Component to add.x- X-coordinate.y- Y-coordinate.itemData- Associated item-data.
-
remove
public void remove(com.vaadin.flow.component.Component component) Remove a component.- Parameters:
component- Component to remove.
-
add
public void add(com.vaadin.flow.dom.Element element, int x, int y) Add an element at the given location (relative to the parent component if exists, otherwise relative the origin - origin (0, 0) in the upper left corner).- Parameters:
element- Element to add.x- X-coordinate.y- Y-coordinate.
-
add
public void add(com.vaadin.flow.dom.Element element, int x, int y, boolean absolute) Add an element at the given location.- Parameters:
element- Element to add.x- X-coordinate.y- Y-coordinate.absolute- Whether the (X, Y) values given are absolute values or not.
-
remove
public void remove(com.vaadin.flow.dom.Element element) Remove an element.- Parameters:
element- Element to remove.
-
reposition
public void reposition(com.vaadin.flow.component.Component component, int x, int y) Re-position a component.- Parameters:
component- Component to re-position.x- X-coordinate.y- Y-coordinate.
-
reposition
public void reposition(com.vaadin.flow.dom.Element element, int x, int y) Re-position an element.- Parameters:
element- Element to re-position.x- X-coordinate.y- Y-coordinate.
-
removeAll
public void removeAll()Remove all components. -
removeParentImage
public void removeParentImage()Remove the parent image. -
setParentImage
Set a parent image.- Parameters:
parentImage- Parent image.offsetX- X-offset of the image.offsetY- Y-offset of the image.
-
getParentOffsetX
public int getParentOffsetX()Get the X-offset of the parent image.- Returns:
- X-offset.
-
getParentOffsetY
public int getParentOffsetY()Get the Y-offset of the parent image.- Returns:
- Y-offset.
-
savePosition
Save the position. This will be called when a component is dropped by the user (via drag and drop).- Parameters:
item- Associate item (This could be saved).x- X-coordinate at which it was dropped.y- Y-coordinate at which it was dropped.- Returns:
- Should return
trueif the save was successful. If the return value isfalse, the component will be placed back at its original location.
-