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 void
addListener
(@NotNull IRendererListener listener) Adds the specified listener to this renderer.final void
close()
final void
commitModelDraw
(long id) Indicates that an asynchronous drawing of the Model Layer is over.final void
drawCaptureStrokes
(int x, int y, int width, int height, @NotNull ICanvas canvas) Requests drawing of a region of the Capture layer.final void
Requests drawing of a region of the Model layer.final long
drawModelAsync
(int x, int y, int width, int height, @NotNull ICanvas canvas) Requests asynchronous drawing of a region of the Model layer.protected void
finalize()
float
getDpiX()
Returns the horizontal DPI resolution of the renderer.float
getDpiY()
Returns the vertical DPI resolution of the renderer.float
Returns the size of a pixel, in millimeters.@Nullable IRenderTarget
Returns the target to which this renderer draws.final @Nullable Point
Returns the view offset.final float
Returns the current zoom view scale.@Nullable Transform
Returns the transform that is used to map model coordinates into view coordinates.final boolean
isClosed()
Tells whether theclose()
method has been called.final void
registerStroker
(@NotNull String name, @NotNull IStrokerFactory factory) Registers a custom stroker factory.final void
removeListener
(@NotNull IRendererListener listener) Removes the specified listener from this renderer.final void
setViewOffset
(float x, float y) Sets the view offset.final void
setViewScale
(float scale) Sets the current zoom view scale.final void
unregisterStroker
(@NotNull String name) Unregister custom stroker factory.final void
zoom
(float factor) Increases zoom by a factor.final void
Increases zoom by a factor around a given point.
-
Method Details
-
finalize
-
close
public final void close()- Specified by:
close
in interfaceAutoCloseable
-
isClosed
public final boolean isClosed()Tells whether theclose()
method has been called. Once an object is closed any method will throwIllegalStateException
.- Returns:
true
if 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
- whenlistener
is null.
-
removeListener
Removes the specified listener from this renderer.- Parameters:
listener
- the listener to be removed.- Throws:
IllegalStateException
- when this renderer is closed.IllegalArgumentException
- whenlistener
is 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
- whenscale
is not a number.IllegalArgumentException
- whenscale
is negative.IllegalArgumentException
- whenscale
is zero.
-
zoom
Increases zoom by a factor.- Parameters:
factor
- the zoom modification factor.- Throws:
IllegalStateException
- when this renderer is closed.IllegalArgumentException
- whenfactor
is not a number.IllegalArgumentException
- whenfactor
is negative.IllegalArgumentException
- whenfactor
is 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
- whenfactor
is not a number.IllegalArgumentException
- whenfactor
is negative.IllegalArgumentException
- whenfactor
is 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
- whenx
is not a number.IllegalArgumentException
- whenx
is negative.IllegalArgumentException
- whenx
is zero.IllegalArgumentException
- wheny
is not a number.IllegalArgumentException
- wheny
is negative.IllegalArgumentException
- wheny
is 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
- whenfactory
is 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
- whencanvas
is 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
- whencanvas
is 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
- whencanvas
is null.
-