Package com.myscript.iink
Class Renderer
java.lang.Object
com.myscript.iink.Renderer
- All Implemented Interfaces:
AutoCloseable
The Renderer implements content rendering of parts.
-
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddListener(@NotNull IRendererListener listener) Adds the specified listener to this renderer.final voidclose()final voidcommitModelDraw(long id) Indicates that an asynchronous drawing of the Model Layer is over.final voiddrawCaptureStrokes(int x, int y, int width, int height, @NotNull ICanvas canvas) Requests drawing of a region of the Capture layer.final voidRequests drawing of a region of the Model layer.final longdrawModelAsync(int x, int y, int width, int height, @NotNull ICanvas canvas) Requests asynchronous drawing of a region of the Model layer.protected voidfinalize()floatgetDpiX()Returns the horizontal DPI resolution of the renderer.floatgetDpiY()Returns the vertical DPI resolution of the renderer.floatReturns the size of a pixel, in millimeters.@Nullable IRenderTargetReturns the target to which this renderer draws.final @Nullable PointReturns the view offset.final floatReturns the current zoom view scale.@Nullable TransformReturns the transform that is used to map model coordinates into view coordinates.final booleanisClosed()Tells whether theclose()method has been called.final voidregisterStroker(@NotNull String name, @NotNull IStrokerFactory factory) Registers a custom stroker factory.final voidremoveListener(@NotNull IRendererListener listener) Removes the specified listener from this renderer.final voidsetViewOffset(float x, float y) Sets the view offset.final voidsetViewScale(float scale) Sets the current zoom view scale.final voidunregisterStroker(@NotNull String name) Unregister custom stroker factory.final voidzoom(float factor) Increases zoom by a factor.final voidIncreases zoom by a factor around a given point.
-
Method Details
-
finalize
-
close
public final void close()- Specified by:
closein interfaceAutoCloseable
-
isClosed
public final boolean isClosed()Tells whether theclose()method has been called. Once an object is closed any method will throwIllegalStateException.- Returns:
trueif this object is closed.
-
addListener
Adds the specified listener to this renderer.- Parameters:
listener- the listener to be added.- Throws:
IllegalStateException- when this renderer is closed.IllegalArgumentException- whenlisteneris null.
-
removeListener
Removes the specified listener from this renderer.- Parameters:
listener- the listener to be removed.- Throws:
IllegalStateException- when this renderer is closed.IllegalArgumentException- whenlisteneris null.
-
getDpiX
public float getDpiX()Returns the horizontal DPI resolution of the renderer.- Returns:
- the horizontal DPI.
- Throws:
IllegalStateException- when this renderer is closed.
-
getDpiY
public float getDpiY()Returns the vertical DPI resolution of the renderer.- Returns:
- the vertical DPI.
- Throws:
IllegalStateException- when this renderer is closed.
-
getPixelSize
public float getPixelSize()Returns the size of a pixel, in millimeters.- Returns:
- the size of a pixel.
- Throws:
IllegalStateException- when this renderer is closed.
-
getViewScale
public final float getViewScale()Returns the current zoom view scale.- Returns:
- the view scale.
- Throws:
IllegalStateException- when this renderer is closed.
-
setViewScale
Sets the current zoom view scale.- Parameters:
scale- the view scale.- Throws:
IllegalStateException- when this renderer is closed.IllegalArgumentException- whenscaleis not a number.IllegalArgumentException- whenscaleis negative.IllegalArgumentException- whenscaleis zero.
-
zoom
Increases zoom by a factor.- Parameters:
factor- the zoom modification factor.- Throws:
IllegalStateException- when this renderer is closed.IllegalArgumentException- whenfactoris not a number.IllegalArgumentException- whenfactoris negative.IllegalArgumentException- whenfactoris zero.
-
zoomAt
Increases zoom by a factor around a given point.- Parameters:
p- point around which to adjust the view (view coordinates in pixel).factor- the zoom modification factor.- Throws:
IllegalStateException- when this renderer is closed.IllegalArgumentException- whenfactoris not a number.IllegalArgumentException- whenfactoris negative.IllegalArgumentException- whenfactoris zero.
-
getViewOffset
Returns the view offset.- Returns:
- the view offset (view coordinates in pixel).
- Throws:
IllegalStateException- when this renderer is closed.
-
setViewOffset
public final void setViewOffset(float x, float y) Sets the view offset.- Parameters:
x- the x coordinate of the view offset (view coordinates in pixel).y- the y coordinate of the view offset (view coordinates in pixel).- Throws:
IllegalStateException- when this renderer is closed.IllegalArgumentException- whenxis not a number.IllegalArgumentException- whenxis negative.IllegalArgumentException- whenxis zero.IllegalArgumentException- whenyis not a number.IllegalArgumentException- whenyis negative.IllegalArgumentException- whenyis zero.
-
getViewTransform
Returns the transform that is used to map model coordinates into view coordinates.- Returns:
- the view transform.
- Throws:
IllegalStateException- when this renderer is closed.
-
getRenderTarget
Returns the target to which this renderer draws.- Returns:
- the render target.
-
registerStroker
public final void registerStroker(@NotNull @NotNull String name, @NotNull @NotNull IStrokerFactory factory) Registers a custom stroker factory.- Parameters:
name- the value of the -myscript-pen-brush css property that selects this stroker.factory- the user provided stroker factory.- Throws:
IllegalStateException- when this renderer is closed.IllegalArgumentException- whenfactoryis null.
-
unregisterStroker
Unregister custom stroker factory.- Parameters:
name- the stroker factory.- Throws:
IllegalStateException- when this renderer is closed.
-
drawModelAsync
public final long drawModelAsync(int x, int y, int width, int height, @NotNull @NotNull ICanvas canvas) Requests asynchronous drawing of a region of the Model layer. Completion of the drawing operation must be indicated by a call tocommitModelDraw().- Parameters:
x- top left x coordinate of the region to draw (view coordinates in pixel).y- top left y coordinate of the region to draw (view coordinates in pixel).width- width of the region to draw (view coordinates in pixel).height- height of the region to draw (view coordinates in pixel).canvas- target canvas.- Returns:
- the identifier of the drawing request.
- Throws:
IllegalStateException- when this renderer is closed.IllegalArgumentException- whencanvasis null.
-
commitModelDraw
public final void commitModelDraw(long id) Indicates that an asynchronous drawing of the Model Layer is over.- Parameters:
id- the identifier of the drawing request, as returned bydrawModelAsync().- Throws:
IllegalStateException- when this renderer is closed.
-
drawModel
Requests drawing of a region of the Model layer.- Parameters:
x- top left x coordinate of the region to draw (view coordinates in pixel).y- top left y coordinate of the region to draw (view coordinates in pixel).width- width of the region to draw (view coordinates in pixel).height- height of the region to draw (view coordinates in pixel).canvas- target canvas.- Throws:
IllegalStateException- when this renderer is closed.IllegalArgumentException- whencanvasis null.
-
drawCaptureStrokes
public final void drawCaptureStrokes(int x, int y, int width, int height, @NotNull @NotNull ICanvas canvas) Requests drawing of a region of the Capture layer.- Parameters:
x- top left x coordinate of the region to draw (view coordinates in pixel).y- top left y coordinate of the region to draw (view coordinates in pixel).width- width of the region to draw (view coordinates in pixel).height- height of the region to draw (view coordinates in pixel).canvas- target canvas.- Throws:
IllegalStateException- when this renderer is closed.IllegalArgumentException- whencanvasis null.
-