Class WRasterPaintDevice
- java.lang.Object
-
- eu.webtoolkit.jwt.WObject
-
- eu.webtoolkit.jwt.WResource
-
- eu.webtoolkit.jwt.WRasterPaintDevice
-
- All Implemented Interfaces:
WPaintDevice
public class WRasterPaintDevice extends WResource implements WPaintDevice
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WResource
WResource.DispositionType
-
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
-
Constructor Summary
Constructors Constructor Description WRasterPaintDevice(java.lang.String format, WLength width, WLength height)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears the image (resets the background to solid white).static java.awt.ColorcreateColor(WColor color)Converts a jwt.WColor to an awt.Colorstatic java.awt.ShapecreateShape(WPainterPath path)Converts a jwt.WPainterPath to an awt.Shapestatic java.awt.StrokecreateStroke(WPainter painter, WPen pen)converts a jwt.WPen to an awt.Strokevoiddone()Finishes painting on the device.voiddrawArc(WRectF rect, double startAngle, double spanAngle)Draws an arc.voiddrawImage(WRectF rect, WAbstractDataInfo imgInfo, 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 rect)Draws a rectangle.voiddrawText(WRectF rect, java.util.EnumSet<AlignmentFlag> flags, TextFlag textFlag, java.lang.CharSequence text, WPointF clipPoint)Draws text.WResourcegetBotResource()Creates a new bot resource.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.protected voidhandleRequest(WebRequest request, WebResponse response)Handles a request.voidinit()Initializes the device for painting.booleanisPaintActive()Returns whether painting is active.WTextItemmeasureText(java.lang.CharSequence text)Measures rendered text size.WTextItemmeasureText(java.lang.CharSequence text, double maxWidth)Measures rendered text size.WTextItemmeasureText(java.lang.CharSequence text, double maxWidth, boolean wordWrap)Measures rendered text size.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.-
Methods inherited from class eu.webtoolkit.jwt.WResource
dataChanged, dataExceeded, dataReceived, generateUrl, getAlternativeBotUrl, getBotResourceId, getDispositionType, getInternalPath, getSuggestedFileName, getUrl, getVersion, incrementVersion, isAllowAutoRemoval, isInvalidAfterChanged, setAllowAutoRemoval, setAlternativeBotUrl, setBotResourceId, setChanged, setDispositionType, setInternalPath, setInvalidAfterChanged, setTakesUpdateLock, setUploadProgress, suggestFileName, suggestFileName, takesUpdateLock, useCustomBotResourceId, write, write, writeToMemory
-
Methods inherited from class eu.webtoolkit.jwt.WObject
getId, getObjectName, remove, setFormData, setObjectName, tr
-
-
-
-
Method Detail
-
handleRequest
protected void handleRequest(WebRequest request, WebResponse response) throws java.io.IOException
Description copied from class:WResourceHandles a request.Reimplement this method so that a proper response is generated for the given request. From the request object you can access request parameters and whether the request is a continuation request. In the response object, you should set the mime type and stream the output data.
- Specified by:
handleRequestin classWResource- Parameters:
request- The request informationresponse- The response object- Throws:
java.io.IOException
-
done
public void done()
Description copied from interface:WPaintDeviceFinishes painting on the device.This method is called when a
WPainterstopped painting.- Specified by:
donein interfaceWPaintDevice- See Also:
WPainter.end()
-
drawArc
public void drawArc(WRectF rect, double startAngle, double spanAngle)
Description copied from interface:WPaintDeviceDraws 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.
- Specified by:
drawArcin interfaceWPaintDevice
-
drawImage
public void drawImage(WRectF rect, java.lang.String imageUri, int imgWidth, int imgHeight, WRectF sourceRect)
Description copied from interface:WPaintDeviceDraws 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.
- Specified by:
drawImagein interfaceWPaintDevice
-
drawImage
public void drawImage(WRectF rect, WAbstractDataInfo imgInfo, int imgWidth, int imgHeight, WRectF sourceRect)
Description copied from interface:WPaintDeviceDraws 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.
- Specified by:
drawImagein interfaceWPaintDevice
-
drawLine
public void drawLine(double x1, double y1, double x2, double y2)Description copied from interface:WPaintDeviceDraws a line.The line must be stroked and transformed using the current painter settings.
- Specified by:
drawLinein interfaceWPaintDevice
-
drawRect
public void drawRect(WRectF rect)
Description copied from interface:WPaintDeviceDraws a rectangle.The rect must be stroked, filled, and transformed using the current painter settings.
- Specified by:
drawRectin interfaceWPaintDevice
-
drawPath
public void drawPath(WPainterPath path)
Description copied from interface:WPaintDeviceDraws a path.The path must be stroked, filled, and transformed using the current painter settings.
- Specified by:
drawPathin interfaceWPaintDevice
-
createShape
public static java.awt.Shape createShape(WPainterPath path)
Converts a jwt.WPainterPath to an awt.Shape- Parameters:
path-- Returns:
- a shape that represents the path
-
drawText
public void drawText(WRectF rect, java.util.EnumSet<AlignmentFlag> flags, TextFlag textFlag, java.lang.CharSequence text, WPointF clipPoint)
Description copied from interface:WPaintDeviceDraws 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.
- Specified by:
drawTextin interfaceWPaintDevice
-
getHeight
public WLength getHeight()
Description copied from interface:WPaintDeviceReturns the device height.The device height, in pixels, establishes the height of the device coordinate system.
- Specified by:
getHeightin interfaceWPaintDevice
-
getPainter
public WPainter getPainter()
Description copied from interface:WPaintDeviceReturns the painter that is currently painting on the device.- Specified by:
getPainterin interfaceWPaintDevice- See Also:
WPaintDevice.init()
-
getWidth
public WLength getWidth()
Description copied from interface:WPaintDeviceReturns the device width.The device width, in pixels, establishes the width of the device coordinate system.
- Specified by:
getWidthin interfaceWPaintDevice
-
init
public void init()
Description copied from interface:WPaintDeviceInitializes the device for painting.This method is called when a
WPainterstarts painting.- Specified by:
initin interfaceWPaintDevice- See Also:
WPainter.begin(WPaintDevice device),WPaintDevice.getPainter()
-
isPaintActive
public boolean isPaintActive()
Description copied from interface:WPaintDeviceReturns whether painting is active.- Specified by:
isPaintActivein interfaceWPaintDevice- See Also:
WPaintDevice.init(),WPaintDevice.getPainter()
-
setChanged
public void setChanged(java.util.EnumSet<PainterChangeFlag> flags)
Description copied from interface:WPaintDeviceIndicates changes in painter state.The
flagsargument is the logical OR of one or more change flags.- Specified by:
setChangedin interfaceWPaintDevice
-
setChanged
public void setChanged(PainterChangeFlag flag, PainterChangeFlag... flags)
Description copied from interface:WPaintDeviceIndicates changes in painter state.- Specified by:
setChangedin interfaceWPaintDevice
-
setPainter
public void setPainter(WPainter painter)
Description copied from interface:WPaintDeviceSets the painter.- Specified by:
setPainterin interfaceWPaintDevice
-
getBotResource
public WResource getBotResource()
Creates a new bot resource.By default, this returns a
WMemoryResource, if theWResource.getBotResourceId()was set, or aWSelfDeletingResourceotherwise.In both cases, the resource will serve the image data as if it was served just before the destruction of the
WApplication(still after the execution ofWApplication.destroy()).- Overrides:
getBotResourcein classWResource- See Also:
WResource.setBotResourceId(String id)
-
createColor
public static java.awt.Color createColor(WColor color)
Converts a jwt.WColor to an awt.Color- Parameters:
color- the JWt color- Returns:
- the corresponding AWT color
-
createStroke
public static java.awt.Stroke createStroke(WPainter painter, WPen pen)
converts a jwt.WPen to an awt.Stroke- Parameters:
painter- the painter used to take into account transformations for the pen widthpen- the JWt pen- Returns:
- the corresponding AWT Stroke
-
clear
public void clear()
Clears the image (resets the background to solid white).
-
getFontMetrics
public WFontMetrics getFontMetrics()
Description copied from interface:WPaintDeviceReturns font metrics.This returns font metrics for the current font.
Throws a std::logic_error if the underlying device does not provide font metrics.
- Specified by:
getFontMetricsin interfaceWPaintDevice
-
measureText
public WTextItem measureText(java.lang.CharSequence text, double maxWidth, boolean wordWrap)
Description copied from interface:WPaintDeviceMeasures 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.
- Specified by:
measureTextin interfaceWPaintDevice
-
measureText
public WTextItem measureText(java.lang.CharSequence text)
Description copied from interface:WPaintDeviceMeasures rendered text size.Returns
measureText(text, - 1, false)- Specified by:
measureTextin interfaceWPaintDevice
-
measureText
public WTextItem measureText(java.lang.CharSequence text, double maxWidth)
Description copied from interface:WPaintDeviceMeasures rendered text size.- Specified by:
measureTextin interfaceWPaintDevice
-
getFeatures
public java.util.EnumSet<PaintDeviceFeatureFlag> getFeatures()
Description copied from interface:WPaintDeviceReturns device features.- Specified by:
getFeaturesin interfaceWPaintDevice
-
-