Class WVirtualImage
WVirtualImage is an abstract class which renders a large image in small pieces. The large image is broken down, and rendered as a grid of smaller square images parts.
The WVirtualImage may provide interactive navigation using the mouse, by reacting to dragging of the mouse on the image.
The WVirtualImage renders pieces in and bordering the current viewport. In this way, provided the individual pieces load sufficiently fast, the user has effectively the impression of scrolling through a single large image, without glitches. Whenever the image is navigated, if necessary, new images are rendered to maintain the border. Images that are too far from the current viewport are pruned away, so that browser memory remains bounded.
To use this class, you must reimplement one of two virtual methods to specify the contents of
each grid piece. Either you provide a suitable WImage
for every grid piece, or you
provide a WResource
which renders the contents for a WImage
for every grid piece.
The total image dimensions are (0, 0) to (imageWidth, imageHeight) for a finite image, and become unbounded (including negative numbers) for each dimension which is Infinite.
CSS
Styling through CSS is not applicable.
-
Nested Class Summary
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
Special value for imageWidth or imageHeight. -
Constructor Summary
ConstructorsConstructorDescriptionWVirtualImage
(int viewPortWidth, int viewPortHeight, long imageWidth, long imageHeight) Creates a viewport for a virtual image.WVirtualImage
(int viewPortWidth, int viewPortHeight, long imageWidth, long imageHeight, int gridImageSize) Creates a viewport for a virtual image.WVirtualImage
(int viewPortWidth, int viewPortHeight, long imageWidth, long imageHeight, int gridImageSize, WContainerWidget parentContainer) Creates a viewport for a virtual image. -
Method Summary
Modifier and TypeMethodDescriptionprotected WImage
createImage
(long x, long y, int width, int height) Creates a grid image for the given rectangle.void
Enables mouse dragging to scroll around the image.long
Returns the current bottom right X coordinate.long
Returns the current bottom right Y coordinate.long
Returns the current top left X coordinate.long
Returns the current top left Y coordinate.int
Returns the size of a single piece.long
Returns the virtual image height.long
Returns the virtual image width.int
Returns the viewport height.int
Returns the viewport width.void
Regenerates and redraws the image pieces.void
remove()
Destructor.protected WResource
render
(long x, long y, int width, int height) Render a grid image for the given rectangle.void
resizeImage
(long w, long h) Resizes the virtual image.void
scroll
(long dx, long dy) Scrolls the viewport of the image over a distance.void
scrollTo
(long newX, long newY) Scrolls the viewport of the image to a specific coordinate.Signal emitted whenever the viewport changes.Methods inherited from class eu.webtoolkit.jwt.WCompositeWidget
addStyleClass, boxBorder, boxPadding, callJavaScriptMember, doJavaScript, enableAjax, find, findById, getAttributeValue, getBaseZIndex, getChildren, getClearSides, getDecorationStyle, getFloatSide, getHeight, getId, getImplementation, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getObjectName, getOffset, getPositionScheme, getScrollVisibilityMargin, getStyleClass, getTabIndex, getTakeImplementation, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, hasFocus, hasStyleClass, isCanReceiveFocus, isDisabled, isEnabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, load, propagateSetEnabled, propagateSetVisible, refresh, removeStyleClass, removeWidget, render, resize, scrollVisibilityChanged, setAttributeValue, setCanReceiveFocus, setClearSides, setDecorationStyle, setDeferredToolTip, setDisabled, setFloatSide, setFocus, setHidden, setHiddenKeepsGeometry, setId, setImplementation, setInline, setJavaScriptMember, setLineHeight, setMargin, setMaximumSize, setMinimumSize, setObjectName, setOffsets, setPopup, setPositionScheme, setScrollVisibilityEnabled, setScrollVisibilityMargin, setSelectable, setStyleClass, setTabIndex, setThemeStyleEnabled, setToolTip, setVerticalAlignment
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, isRendered, layoutSizeChanged, needsRerender, positionAt, positionAt, removeFromParent, removeStyleClass, render, resize, scheduleRender, scheduleRender, scheduleRender, setClearSides, setDeferredToolTip, setFocus, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
Methods inherited from class eu.webtoolkit.jwt.WObject
setFormData
-
Field Details
-
Infinite
public static final long InfiniteSpecial value for imageWidth or imageHeight.- See Also:
-
-
Constructor Details
-
WVirtualImage
public WVirtualImage(int viewPortWidth, int viewPortHeight, long imageWidth, long imageHeight, int gridImageSize, WContainerWidget parentContainer) Creates a viewport for a virtual image.You must specify the size of the viewport, and the size of the virtual image. The latter dimensions may be the special value Infinite, indicating that in one or more dimensions, the image size is infinite (in practice limited by the maximum integer value).
In addition, you must specify the size of each square grid item. The default is 256 by 256.
-
WVirtualImage
public WVirtualImage(int viewPortWidth, int viewPortHeight, long imageWidth, long imageHeight) Creates a viewport for a virtual image.Calls
this(viewPortWidth, viewPortHeight, imageWidth, imageHeight, 256, (WContainerWidget)null)
-
WVirtualImage
public WVirtualImage(int viewPortWidth, int viewPortHeight, long imageWidth, long imageHeight, int gridImageSize) Creates a viewport for a virtual image.Calls
this(viewPortWidth, viewPortHeight, imageWidth, imageHeight, gridImageSize, (WContainerWidget)null)
-
-
Method Details
-
remove
public void remove()Destructor.- Overrides:
remove
in classWCompositeWidget
- See Also:
-
redrawAll
public void redrawAll()Regenerates and redraws the image pieces.This method invalidates all current grid images, and recreates them.
-
enableDragging
public void enableDragging()Enables mouse dragging to scroll around the image.The cursor is changed to a 'move' symbol to indicate the interactivity.
-
scroll
public void scroll(long dx, long dy) Scrolls the viewport of the image over a distance.- See Also:
-
scrollTo
public void scrollTo(long newX, long newY) Scrolls the viewport of the image to a specific coordinate.Scroll the viewport so that its top left coordinate becomes (x, y).
- See Also:
-
getImageWidth
public long getImageWidth()Returns the virtual image width.- See Also:
-
getImageHeight
public long getImageHeight()Returns the virtual image height.- See Also:
-
resizeImage
public void resizeImage(long w, long h) Resizes the virtual image.This sets a new virtual size for the image. The viewport size sets the visible portion of the image.
- See Also:
-
getViewPortWidth
public int getViewPortWidth()Returns the viewport width.- See Also:
-
getViewPortHeight
public int getViewPortHeight()Returns the viewport height.- See Also:
-
getGridImageSize
public int getGridImageSize()Returns the size of a single piece.This is the size of a side of the square pieces that is used to render the visible part of the image.
-
getCurrentTopLeftX
public long getCurrentTopLeftX()Returns the current top left X coordinate.- See Also:
-
getCurrentTopLeftY
public long getCurrentTopLeftY()Returns the current top left Y coordinate.- See Also:
-
getCurrentBottomRightX
public long getCurrentBottomRightX()Returns the current bottom right X coordinate.- See Also:
-
getCurrentBottomRightY
public long getCurrentBottomRightY()Returns the current bottom right Y coordinate.- See Also:
-
viewPortChanged
Signal emitted whenever the viewport changes.The viewport can be changed by the user dragging the image or through the API methods
scrollTo()
andscroll()
. -
createImage
Creates a grid image for the given rectangle.Create the image which spans image coordinates with left upper corner (x, y) and given width and height.
Width and height will not necesarilly equal
getGridImageSize()
, if the the image is not infinite sized.The default implementation calls
render()
and creates an image for the resource returned.You should override this method if you wish to serve for example static image content.
-
render
Render a grid image for the given rectangle.Returns a resource that streams an image which renders the rectangle which spans image coordinates with left upper corner (x, y) and given width and height.
Width and height will not necesarilly equal to
getGridImageSize()
, if the the image is not infinite sized.The default implementation throws an Exception. You must reimplement this method unless you reimplement
createImage()
.
-