Package com.myscript.iink
Class Renderer
- java.lang.Object
-
- com.myscript.iink.Renderer
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class Renderer extends java.lang.Object implements java.lang.AutoCloseable
The Renderer implements content rendering of parts.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(@NotNull IRendererListener listener)
Adds the specified listener to this renderer.void
close()
void
commitModelDraw(long id)
Indicates that an asynchronous drawing of the Model Layer is over.void
drawCaptureStrokes(int x, int y, int width, int height, @NotNull ICanvas canvas)
Requests drawing of a region of the Capture layer.void
drawModel(int x, int y, int width, int height, @NotNull ICanvas canvas)
Requests drawing of a region of the Model layer.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
getPixelSize()
Returns the size of a pixel, in millimeters.@Nullable IRenderTarget
getRenderTarget()
Returns the target to which this renderer draws.@Nullable Point
getViewOffset()
Returns the view offset.float
getViewScale()
Returns the current zoom view scale.@Nullable Transform
getViewTransform()
Returns the transform that is used to map model coordinates into view coordinates.boolean
isClosed()
Tells whether theclose()
method has been called.void
registerStroker(@NotNull java.lang.String name, @NotNull IStrokerFactory factory)
Registers a custom stroker factory.void
removeListener(@NotNull IRendererListener listener)
Removes the specified listener from this renderer.void
setViewOffset(float x, float y)
Sets the view offset.void
setViewScale(float scale)
Sets the current zoom view scale.void
unregisterStroker(@NotNull java.lang.String name)
Unregister custom stroker factory.void
zoom(float factor)
Increase zoom by a factor.void
zoomAt(@NotNull Point p, float factor)
Increase zoom by a factor around a given point.
-
-
-
Method Detail
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
close
public final void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
-
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
public final void addListener(@NotNull @NotNull IRendererListener listener)
Adds the specified listener to this renderer.- Parameters:
listener
- the listener to be added.- Throws:
java.lang.IllegalStateException
- when this renderer is closed.java.lang.IllegalArgumentException
- whenlistener
is null.
-
removeListener
public final void removeListener(@NotNull @NotNull IRendererListener listener)
Removes the specified listener from this renderer.- Parameters:
listener
- the listener to be removed.- Throws:
java.lang.IllegalStateException
- when this renderer is closed.java.lang.IllegalArgumentException
- whenlistener
is null.
-
getDpiX
public float getDpiX()
Returns the horizontal DPI resolution of the renderer.- Returns:
- the horizontal DPI.
- Throws:
java.lang.IllegalStateException
- when this renderer is closed.
-
getDpiY
public float getDpiY()
Returns the vertical DPI resolution of the renderer.- Returns:
- the vertical DPI.
- Throws:
java.lang.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:
java.lang.IllegalStateException
- when this renderer is closed.
-
getViewScale
public final float getViewScale()
Returns the current zoom view scale.- Returns:
- the view scale.
- Throws:
java.lang.IllegalStateException
- when this renderer is closed.
-
setViewScale
public final void setViewScale(float scale) throws java.lang.IllegalArgumentException
Sets the current zoom view scale.- Parameters:
scale
- the view scale.- Throws:
java.lang.IllegalStateException
- when this renderer is closed.java.lang.IllegalArgumentException
- whenscale
is not a number.java.lang.IllegalArgumentException
- whenscale
is negative.java.lang.IllegalArgumentException
- whenscale
is zero.
-
zoom
public final void zoom(float factor) throws java.lang.IllegalArgumentException
Increase zoom by a factor.- Parameters:
factor
- the zoom modification factor.- Throws:
java.lang.IllegalStateException
- when this renderer is closed.java.lang.IllegalArgumentException
- whenfactor
is not a number.java.lang.IllegalArgumentException
- whenfactor
is negative.java.lang.IllegalArgumentException
- whenfactor
is zero.
-
zoomAt
public final void zoomAt(@NotNull @NotNull Point p, float factor) throws java.lang.IllegalArgumentException
Increase 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:
java.lang.IllegalStateException
- when this renderer is closed.java.lang.IllegalArgumentException
- whenfactor
is not a number.java.lang.IllegalArgumentException
- whenfactor
is negative.java.lang.IllegalArgumentException
- whenfactor
is zero.
-
getViewOffset
@Nullable public final @Nullable Point getViewOffset()
Returns the view offset.- Returns:
- the view offset (view coordinates in pixel).
- Throws:
java.lang.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:
java.lang.IllegalStateException
- when this renderer is closed.java.lang.IllegalArgumentException
- whenx
is not a number.java.lang.IllegalArgumentException
- whenx
is negative.java.lang.IllegalArgumentException
- whenx
is zero.java.lang.IllegalArgumentException
- wheny
is not a number.java.lang.IllegalArgumentException
- wheny
is negative.java.lang.IllegalArgumentException
- wheny
is zero.
-
getViewTransform
@Nullable public @Nullable Transform getViewTransform()
Returns the transform that is used to map model coordinates into view coordinates.- Returns:
- the view transform.
- Throws:
java.lang.IllegalStateException
- when this renderer is closed.
-
getRenderTarget
@Nullable public @Nullable IRenderTarget getRenderTarget()
Returns the target to which this renderer draws.- Returns:
- the render target.
-
registerStroker
public final void registerStroker(@NotNull @NotNull java.lang.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:
java.lang.IllegalStateException
- when this renderer is closed.java.lang.IllegalArgumentException
- whenfactory
is null.
-
unregisterStroker
public final void unregisterStroker(@NotNull @NotNull java.lang.String name)
Unregister custom stroker factory.- Parameters:
name
- the stroker factory.- Throws:
java.lang.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:
java.lang.IllegalStateException
- when this renderer is closed.java.lang.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:
java.lang.IllegalStateException
- when this renderer is closed.
-
drawModel
public final void drawModel(int x, int y, int width, int height, @NotNull @NotNull ICanvas canvas)
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:
java.lang.IllegalStateException
- when this renderer is closed.java.lang.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:
java.lang.IllegalStateException
- when this renderer is closed.java.lang.IllegalArgumentException
- whencanvas
is null.
-
-