|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecteu.webtoolkit.jwt.WObject
eu.webtoolkit.jwt.WWidget
eu.webtoolkit.jwt.WCompositeWidget
eu.webtoolkit.jwt.WVirtualImage
public class WVirtualImage
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 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.
Styling through CSS is not applicable.
| Field Summary | |
|---|---|
static long |
Infinite
Special value for imageWidth or imageHeight. |
| Constructor Summary | |
|---|---|
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 parent)
Creates a viewport for a virtual image. |
|
| Method Summary | |
|---|---|
protected WImage |
createImage(long x,
long y,
int width,
int height)
Creates a grid image for the given rectangle. |
void |
enableDragging()
Enables mouse dragging to scroll around the image. |
long |
getCurrentBottomRightX()
Returns the current bottom right X coordinate. |
long |
getCurrentBottomRightY()
Returns the current bottom right Y coordinate. |
long |
getCurrentTopLeftX()
Returns the current top left X coordinate. |
long |
getCurrentTopLeftY()
Returns the current top left Y coordinate. |
int |
getGridImageSize()
Returns the size of a single piece. |
long |
getImageHeight()
Returns the virtual image height. |
long |
getImageWidth()
Returns the virtual image width. |
int |
getViewPortHeight()
Returns the viewport height. |
int |
getViewPortWidth()
Returns the viewport width. |
void |
redrawAll()
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. |
Signal2<java.lang.Long,java.lang.Long> |
viewPortChanged()
Signal emitted whenever the viewport changes. |
| Methods inherited from class eu.webtoolkit.jwt.WWidget |
|---|
acceptDrops, acceptDrops, addCssRule, addCssRule, addStyleClass, animateHide, animateShow, containsExposed, disable, dropEvent, enable, getDrop, getJsRef, getParent, hide, htmlText, isLayoutSizeAware, isRendered, layoutSizeChanged, positionAt, positionAt, removeStyleClass, resize, setClearSides, 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 |
|---|
addChild, getObjectName, setObjectName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final long Infinite
| Constructor Detail |
|---|
public WVirtualImage(int viewPortWidth,
int viewPortHeight,
long imageWidth,
long imageHeight,
int gridImageSize,
WContainerWidget parent)
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.
public WVirtualImage(int viewPortWidth,
int viewPortHeight,
long imageWidth,
long imageHeight)
Calls
this(viewPortWidth, viewPortHeight, imageWidth, imageHeight, 256,
(WContainerWidget)null)
public WVirtualImage(int viewPortWidth,
int viewPortHeight,
long imageWidth,
long imageHeight,
int gridImageSize)
Calls
this(viewPortWidth, viewPortHeight, imageWidth, imageHeight,
gridImageSize, (WContainerWidget)null)
| Method Detail |
|---|
public void remove()
remove in class WCompositeWidgetWContainerWidget.removeWidget(WWidget widget)public void redrawAll()
This method invalidates all current grid images, and recreates them.
public void enableDragging()
The cursor is changed to a 'move' symbol to indicate the interactivity.
public void scroll(long dx,
long dy)
scrollTo(long newX, long newY)
public void scrollTo(long newX,
long newY)
Scroll the viewport so that its top left coordinate becomes (x, y).
scroll(long dx, long dy)public long getImageWidth()
getImageHeight(),
resizeImage(long w, long h)public long getImageHeight()
getImageWidth(),
resizeImage(long w, long h)
public void resizeImage(long w,
long h)
This sets a new virtual size for the image. The viewport size sets the visible portion of the image.
getImageWidth(),
getImageHeight()public int getViewPortWidth()
getViewPortHeight()public int getViewPortHeight()
getViewPortWidth()public int getGridImageSize()
This is the size of a side of the square pieces that is used to render the visible part of the image.
public long getCurrentTopLeftX()
getCurrentTopLeftY()public long getCurrentTopLeftY()
getCurrentTopLeftX()public long getCurrentBottomRightX()
getCurrentBottomRightY()public long getCurrentBottomRightY()
getCurrentBottomRightX()public Signal2<java.lang.Long,java.lang.Long> viewPortChanged()
The viewport can be changed by the user dragging the image or through the
API methods scrollTo() and scroll().
protected WImage createImage(long x,
long y,
int width,
int height)
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(long x, long y, int width, int height)
protected WResource render(long x,
long y,
int width,
int height)
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().
createImage(long x, long y, int width, int height)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||