Interface WPaintDevice
-
- All Known Subinterfaces:
WVectorImage
- All Known Implementing Classes:
WCanvasPaintDevice,WMeasurePaintDevice,WPdfImage,WRasterPaintDevice,WSvgImage,WVmlImage
public interface WPaintDeviceThe abstract base class for a paint device.A WPaintDevice is a device on which may be painted using a
WPainter. You should never paint directly on a paint device.The device defines the size of the drawing area, using
getWidth()andgetHeight(). These dimensions must be defined in pixel units. In the future, additional information will be included to convert these pixel units to lengths (using DPI information).You should reimplement this class if you wish to extend the JWt paint system to paint on other devices than the ones provided by the library.
Note: this interface is subject to changes to increase optimization possibilities for the painting using different devices.
- See Also:
WPainter
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voiddone()Finishes painting on the device.voiddrawArc(WRectF rect, double startAngle, double spanAngle)Draws an arc.voiddrawImage(WRectF rect, WAbstractDataInfo imageInfo, int imgWidth, int imgHeight, WRectF sourceRect)Draws an image.voiddrawImage(WRectF rect, java.lang.String imageUri, int imgWidth, int imgHeight, WRectF sourceRect)Draws an image.voiddrawLine(double x1, double y1, double x2, double y2)Draws a line.voiddrawPath(WPainterPath path)Draws a path.voiddrawRect(WRectF rectangle)Draws a rectangle.voiddrawText(WRectF rect, java.util.EnumSet<AlignmentFlag> alignmentFlags, TextFlag textFlag, java.lang.CharSequence text, WPointF clipPoint)Draws text.java.util.EnumSet<PaintDeviceFeatureFlag>getFeatures()Returns device features.WFontMetricsgetFontMetrics()Returns font metrics.WLengthgetHeight()Returns the device height.WPaintergetPainter()Returns the painter that is currently painting on the device.WLengthgetWidth()Returns the device width.voidinit()Initializes the device for painting.booleanisPaintActive()Returns whether painting is active.default WTextItemmeasureText(java.lang.CharSequence text)Measures rendered text size.default WTextItemmeasureText(java.lang.CharSequence text, double maxWidth)Measures rendered text size.WTextItemmeasureText(java.lang.CharSequence text, double maxWidth, boolean wordWrap)Measures rendered text size.default voidsetChanged(PainterChangeFlag flag, PainterChangeFlag... flags)Indicates changes in painter state.voidsetChanged(java.util.EnumSet<PainterChangeFlag> flags)Indicates changes in painter state.voidsetPainter(WPainter painter)Sets the painter.
-
-
-
Method Detail
-
getFeatures
java.util.EnumSet<PaintDeviceFeatureFlag> getFeatures()
Returns device features.
-
getWidth
WLength getWidth()
Returns the device width.The device width, in pixels, establishes the width of the device coordinate system.
-
getHeight
WLength getHeight()
Returns the device height.The device height, in pixels, establishes the height of the device coordinate system.
-
setChanged
void setChanged(java.util.EnumSet<PainterChangeFlag> flags)
Indicates changes in painter state.The
flagsargument is the logical OR of one or more change flags.
-
setChanged
default void setChanged(PainterChangeFlag flag, PainterChangeFlag... flags)
Indicates changes in painter state.
-
drawArc
void drawArc(WRectF rect, double startAngle, double spanAngle)
Draws an arc.The arc describes the segment of an ellipse enclosed by the rect. The segment starts at
startAngle, and spans an angle given byspanAngle. These angles have as unit degree, and are measured counter-clockwise starting from the 3 o'clock position.The arc must be stroked, filled, and transformed using the current painter settings.
-
drawImage
void drawImage(WRectF rect, java.lang.String imageUri, int imgWidth, int imgHeight, WRectF sourceRect)
Draws an image.Draws sourceRect from the image with URL
imageUriand original dimensions imgWidth andimgHeightto the location, into the rectangle defined byrect.The image is transformed using the current painter settings.
-
drawImage
void drawImage(WRectF rect, WAbstractDataInfo imageInfo, int imgWidth, int imgHeight, WRectF sourceRect)
Draws an image.Draws
sourceRectfrom the image with the information contained inimageInfoand original dimensionsimgWidthandimgHeightto the location, into the rectangle defined byrect.The image is transformed using the current painter settings.
-
drawLine
void drawLine(double x1, double y1, double x2, double y2)Draws a line.The line must be stroked and transformed using the current painter settings.
-
drawPath
void drawPath(WPainterPath path)
Draws a path.The path must be stroked, filled, and transformed using the current painter settings.
-
drawRect
void drawRect(WRectF rectangle)
Draws a rectangle.The rect must be stroked, filled, and transformed using the current painter settings.
-
drawText
void drawText(WRectF rect, java.util.EnumSet<AlignmentFlag> alignmentFlags, TextFlag textFlag, java.lang.CharSequence text, WPointF clipPoint)
Draws text.The text must be rendered, stroked and transformed using the current painter settings.
If clipPoint is not null, a check is performed whether the point is inside of the current clip area. If not, the text is not drawn.
-
measureText
WTextItem measureText(java.lang.CharSequence text, double maxWidth, boolean wordWrap)
Measures rendered text size.Returns 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=truethen 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
default WTextItem measureText(java.lang.CharSequence text)
Measures rendered text size.Returns
measureText(text, - 1, false)
-
measureText
default WTextItem measureText(java.lang.CharSequence text, double maxWidth)
Measures rendered text size.
-
getFontMetrics
WFontMetrics getFontMetrics()
Returns font metrics.This returns font metrics for the current font.
Throws a std::logic_error if the underlying device does not provide font metrics.
-
init
void init()
Initializes the device for painting.This method is called when a
WPainterstarts painting.- See Also:
WPainter.begin(WPaintDevice device),getPainter()
-
done
void done()
Finishes painting on the device.This method is called when a
WPainterstopped painting.- See Also:
WPainter.end()
-
isPaintActive
boolean isPaintActive()
Returns whether painting is active.- See Also:
init(),getPainter()
-
getPainter
WPainter getPainter()
Returns the painter that is currently painting on the device.- See Also:
init()
-
setPainter
void setPainter(WPainter painter)
Sets the painter.
-
-