Class WVirtualImage
- java.lang.Object
-
- eu.webtoolkit.jwt.WObject
-
- eu.webtoolkit.jwt.WWidget
-
- eu.webtoolkit.jwt.WCompositeWidget
-
- eu.webtoolkit.jwt.WVirtualImage
-
public class WVirtualImage extends WCompositeWidget
An abstract widget that shows a viewport to a virtually large image.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
WImagefor every grid piece, or you provide aWResourcewhich renders the contents for aWImagefor 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
Fields Modifier and Type Field Description static longInfiniteSpecial value for imageWidth or imageHeight.-
Fields inherited from class eu.webtoolkit.jwt.WWidget
WT_GETEXTRAMS_JS
-
-
Constructor Summary
Constructors Constructor Description WVirtualImage(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected WImagecreateImage(long x, long y, int width, int height)Creates a grid image for the given rectangle.voidenableDragging()Enables mouse dragging to scroll around the image.longgetCurrentBottomRightX()Returns the current bottom right X coordinate.longgetCurrentBottomRightY()Returns the current bottom right Y coordinate.longgetCurrentTopLeftX()Returns the current top left X coordinate.longgetCurrentTopLeftY()Returns the current top left Y coordinate.intgetGridImageSize()Returns the size of a single piece.longgetImageHeight()Returns the virtual image height.longgetImageWidth()Returns the virtual image width.intgetViewPortHeight()Returns the viewport height.intgetViewPortWidth()Returns the viewport width.voidredrawAll()Regenerates and redraws the image pieces.voidremove()Destructor.protected WResourcerender(long x, long y, int width, int height)Render a grid image for the given rectangle.voidresizeImage(long w, long h)Resizes the virtual image.voidscroll(long dx, long dy)Scrolls the viewport of the image over a distance.voidscrollTo(long newX, long newY)Scrolls the viewport of the image to a specific coordinate.Signal2<java.lang.Long,java.lang.Long>viewPortChanged()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, setParentWidget, 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, applyThemeStyles, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, isRendered, layoutSizeChanged, needsRerender, positionAt, positionAt, positionAt, positionAt, removeFromParent, removeStyleClass, render, resize, scheduleRender, scheduleRender, scheduleRender, scheduleThemeStyleApply, 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 Detail
-
Infinite
public static final long Infinite
Special value for imageWidth or imageHeight.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 Detail
-
remove
public void remove()
Destructor.- Overrides:
removein classWCompositeWidget- See Also:
WWidget.removeWidget(WWidget widget)
-
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(long newX, long newY)
-
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:
scroll(long dx, long dy)
-
getImageWidth
public long getImageWidth()
Returns the virtual image width.- See Also:
getImageHeight(),resizeImage(long w, long h)
-
getImageHeight
public long getImageHeight()
Returns the virtual image height.- See Also:
getImageWidth(),resizeImage(long w, long h)
-
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:
getImageWidth(),getImageHeight()
-
getViewPortWidth
public int getViewPortWidth()
Returns the viewport width.- See Also:
getViewPortHeight()
-
getViewPortHeight
public int getViewPortHeight()
Returns the viewport height.- See Also:
getViewPortWidth()
-
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()
-
getCurrentTopLeftY
public long getCurrentTopLeftY()
Returns the current top left Y coordinate.- See Also:
getCurrentTopLeftX()
-
getCurrentBottomRightX
public long getCurrentBottomRightX()
Returns the current bottom right X coordinate.- See Also:
getCurrentBottomRightY()
-
getCurrentBottomRightY
public long getCurrentBottomRightY()
Returns the current bottom right Y coordinate.- See Also:
getCurrentBottomRightX()
-
viewPortChanged
public Signal2<java.lang.Long,java.lang.Long> 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
protected WImage createImage(long x, long y, int width, int height)
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
protected WResource render(long x, long y, int width, int height)
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().
-
-