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.AutoCloseableThe Renderer implements content rendering of parts.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(@NotNull IRendererListener listener)Adds the specified listener to this renderer.voidclose()voidcommitModelDraw(long id)Indicates that an asynchronous drawing of the Model Layer is over.voiddrawCaptureStrokes(int x, int y, int width, int height, @NotNull ICanvas canvas)Requests drawing of a region of the Capture layer.voiddrawModel(int x, int y, int width, int height, @NotNull ICanvas canvas)Requests drawing of a region of the Model layer.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.floatgetPixelSize()Returns the size of a pixel, in millimeters.@Nullable IRenderTargetgetRenderTarget()Returns the target to which this renderer draws.@Nullable PointgetViewOffset()Returns the view offset.floatgetViewScale()Returns the current zoom view scale.@Nullable TransformgetViewTransform()Returns the transform that is used to map model coordinates into view coordinates.booleanisClosed()Tells whether theclose()method has been called.voidregisterStroker(@NotNull java.lang.String name, @NotNull IStrokerFactory factory)Registers a custom stroker factory.voidremoveListener(@NotNull IRendererListener listener)Removes the specified listener from this renderer.voidsetViewOffset(float x, float y)Sets the view offset.voidsetViewScale(float scale)Sets the current zoom view scale.voidunregisterStroker(@NotNull java.lang.String name)Unregister custom stroker factory.voidzoom(float factor)Increase zoom by a factor.voidzoomAt(@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:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
close
public final void close()
- Specified by:
closein 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:
trueif 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- whenlisteneris 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- whenlisteneris 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.IllegalArgumentExceptionSets the current zoom view scale.- Parameters:
scale- the view scale.- Throws:
java.lang.IllegalStateException- when this renderer is closed.java.lang.IllegalArgumentException- whenscaleis not a number.java.lang.IllegalArgumentException- whenscaleis negative.java.lang.IllegalArgumentException- whenscaleis zero.
-
zoom
public final void zoom(float factor) throws java.lang.IllegalArgumentExceptionIncrease zoom by a factor.- Parameters:
factor- the zoom modification factor.- Throws:
java.lang.IllegalStateException- when this renderer is closed.java.lang.IllegalArgumentException- whenfactoris not a number.java.lang.IllegalArgumentException- whenfactoris negative.java.lang.IllegalArgumentException- whenfactoris zero.
-
zoomAt
public final void zoomAt(@NotNull @NotNull Point p, float factor) throws java.lang.IllegalArgumentExceptionIncrease 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- whenfactoris not a number.java.lang.IllegalArgumentException- whenfactoris negative.java.lang.IllegalArgumentException- whenfactoris 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- whenxis not a number.java.lang.IllegalArgumentException- whenxis negative.java.lang.IllegalArgumentException- whenxis zero.java.lang.IllegalArgumentException- whenyis not a number.java.lang.IllegalArgumentException- whenyis negative.java.lang.IllegalArgumentException- whenyis 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- whenfactoryis 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- 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:
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- 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:
java.lang.IllegalStateException- when this renderer is closed.java.lang.IllegalArgumentException- whencanvasis null.
-
-