|
||||||||||
| 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.WCanvasPaintDevice
public class WCanvasPaintDevice
A paint device for rendering using the HTML 5 <canvas> element.
The WCanvasPaintDevice is used by WPaintedWidget to render to the
browser using the HTML 5 <canvas> element. You usually will not use the
device directly, but rather rely on WPaintedWidget to use this device
when appropriate.
Note: Older browsers do not have text support in <canvas>.
Text is then rendered in an overlayed DIV and a consequence text is not
subject to rotation and scaling components of the current transformation (but
does take into account translation). On most browser you can use the
WSvgImage or WVmlImage paint devices which do support text
natively.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface eu.webtoolkit.jwt.WPaintDevice |
|---|
WPaintDevice.ChangeFlag, WPaintDevice.FeatureFlag |
| Constructor Summary | |
|---|---|
WCanvasPaintDevice(WLength width,
WLength height)
Create a canvas paint device. |
|
WCanvasPaintDevice(WLength width,
WLength height,
WObject parent)
Create a canvas paint device. |
|
WCanvasPaintDevice(WLength width,
WLength height,
WObject parent,
boolean paintUpdate)
Create a canvas paint device. |
|
| Method Summary | |
|---|---|
void |
done()
Finishes painting on the device. |
void |
drawArc(WRectF rect,
double startAngle,
double spanAngle)
Draws an arc. |
void |
drawImage(WRectF rect,
java.lang.String imgUri,
int imgWidth,
int imgHeight,
WRectF sourceRect)
Draws an image. |
void |
drawLine(double x1,
double y1,
double x2,
double y2)
Draws a line. |
void |
drawPath(WPainterPath path)
Draws a path. |
void |
drawText(WRectF rect,
java.util.EnumSet<AlignmentFlag> flags,
TextFlag textFlag,
java.lang.CharSequence text)
Draws text. |
java.util.EnumSet<WPaintDevice.FeatureFlag> |
getFeatures()
Returns device features. |
WFontMetrics |
getFontMetrics()
Returns font metrics. |
WLength |
getHeight()
Returns the device height. |
WPainter |
getPainter()
Returns the painter that is currently painting on the device. |
WLength |
getWidth()
Returns the device width. |
void |
init()
Initializes the device for painting. |
boolean |
isPaintActive()
Returns whether painting is active. |
WTextItem |
measureText(java.lang.CharSequence text)
Measures rendered text size. |
WTextItem |
measureText(java.lang.CharSequence text,
double maxWidth)
Measures rendered text size. |
WTextItem |
measureText(java.lang.CharSequence text,
double maxWidth,
boolean wordWrap)
Measures rendered text size. |
void |
setChanged(java.util.EnumSet<WPaintDevice.ChangeFlag> flags)
Indicates changes in painter state. |
void |
setChanged(WPaintDevice.ChangeFlag flag,
WPaintDevice.ChangeFlag... flags)
Indicates changes in painter state. |
void |
setPainter(WPainter painter)
Sets the painter. |
| Methods inherited from class eu.webtoolkit.jwt.WObject |
|---|
addChild, getId, getObjectName, remove, setObjectName, tr |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WCanvasPaintDevice(WLength width,
WLength height,
WObject parent,
boolean paintUpdate)
public WCanvasPaintDevice(WLength width,
WLength height)
Calls
this(width, height, (WObject)null, false)
public WCanvasPaintDevice(WLength width,
WLength height,
WObject parent)
Calls
this(width, height, parent, false)
| Method Detail |
|---|
public java.util.EnumSet<WPaintDevice.FeatureFlag> getFeatures()
WPaintDevice
getFeatures in interface WPaintDevicepublic void setChanged(java.util.EnumSet<WPaintDevice.ChangeFlag> flags)
WPaintDevice
The flags argument is the logical OR of one or more change
flags.
setChanged in interface WPaintDeviceWPaintDevice.ChangeFlag
public final void setChanged(WPaintDevice.ChangeFlag flag,
WPaintDevice.ChangeFlag... flags)
WPaintDevice
Calls setChanged(EnumSet.of(flag,
flags))
setChanged in interface WPaintDevice
public void drawArc(WRectF rect,
double startAngle,
double spanAngle)
WPaintDevice
The arc is defined as in
WPainter#drawArc()
The arc must be stroked, filled, and transformed using the current painter settings.
drawArc in interface WPaintDevice
public void drawImage(WRectF rect,
java.lang.String imgUri,
int imgWidth,
int imgHeight,
WRectF sourceRect)
WPaintDevice
Draws sourceRect from the image with URL imageUri and
original dimensions imgWidth and imgHeight to the
location, into the rectangle defined by rect.
The image is transformed using the current painter settings.
drawImage in interface WPaintDevice
public void drawLine(double x1,
double y1,
double x2,
double y2)
WPaintDeviceThe line must be stroked and transformed using the current painter settings.
drawLine in interface WPaintDevicepublic void drawPath(WPainterPath path)
WPaintDeviceThe path must be stroked, filled, and transformed using the current painter settings.
drawPath in interface WPaintDevice
public void drawText(WRectF rect,
java.util.EnumSet<AlignmentFlag> flags,
TextFlag textFlag,
java.lang.CharSequence text)
WPaintDeviceThe text must be rendered, stroked and transformed using the current painter settings.
drawText in interface WPaintDevice
public WTextItem measureText(java.lang.CharSequence text,
double maxWidth,
boolean wordWrap)
WPaintDeviceReturns the bounding rect of the given text when rendered using the current font.
If maxWidth != -1, then the text is truncated to fit in the
width.
If wordWrap = true then text is truncated only
at word boundaries. Note that in this case the whitespace at the
truncated position is included in the text but not accounted for by the
returned width (since usually you will not render the whitespace at the
end of a line).
Throws a std::logic_error if the underlying device does not provide font metrics.
measureText in interface WPaintDevicepublic final WTextItem measureText(java.lang.CharSequence text)
WPaintDevice
Returns
measureText(text, - 1, false)
measureText in interface WPaintDevice
public final WTextItem measureText(java.lang.CharSequence text,
double maxWidth)
WPaintDevice
Returns
measureText(text, maxWidth, false)
measureText in interface WPaintDevicepublic WFontMetrics getFontMetrics()
WPaintDeviceThis returns font metrics for the current font.
Throws a std::logic_error if the underlying device does not provide font metrics.
getFontMetrics in interface WPaintDevicepublic void init()
WPaintDevice
This method is called when a WPainter starts painting.
init in interface WPaintDeviceWPainter.begin(WPaintDevice device),
WPaintDevice.getPainter()public void done()
WPaintDevice
This method is called when a WPainter stopped painting.
done in interface WPaintDeviceWPainter.end()public boolean isPaintActive()
WPaintDevice
isPaintActive in interface WPaintDeviceWPaintDevice.init(),
WPaintDevice.getPainter()public WLength getWidth()
WPaintDeviceThe device width, in pixels, establishes the width of the device coordinate system.
getWidth in interface WPaintDevicepublic WLength getHeight()
WPaintDeviceThe device height, in pixels, establishes the height of the device coordinate system.
getHeight in interface WPaintDevicepublic WPainter getPainter()
WPaintDevice
getPainter in interface WPaintDeviceWPaintDevice.init()public void setPainter(WPainter painter)
WPaintDevice
setPainter in interface WPaintDevice
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||