Class Renderer

java.lang.Object
com.myscript.iink.Renderer
All Implemented Interfaces:
AutoCloseable

public class Renderer extends Object implements AutoCloseable
The Renderer implements content rendering of parts.
  • Method Details

    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • close

      public final void close()
      Specified by:
      close in interface AutoCloseable
    • isClosed

      public final boolean isClosed()
      Tells whether the close() method has been called. Once an object is closed any method will throw IllegalStateException.
      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:
      IllegalStateException - when this renderer is closed.
      IllegalArgumentException - when listener 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:
      IllegalStateException - when this renderer is closed.
      IllegalArgumentException - when listener 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

      public final void setViewScale(float scale) throws IllegalArgumentException
      Sets the current zoom view scale.
      Parameters:
      scale - the view scale.
      Throws:
      IllegalStateException - when this renderer is closed.
      IllegalArgumentException - when scale is not a number.
      IllegalArgumentException - when scale is negative.
      IllegalArgumentException - when scale is zero.
    • zoom

      public final void zoom(float factor) throws IllegalArgumentException
      Increases zoom by a factor.
      Parameters:
      factor - the zoom modification factor.
      Throws:
      IllegalStateException - when this renderer is closed.
      IllegalArgumentException - when factor is not a number.
      IllegalArgumentException - when factor is negative.
      IllegalArgumentException - when factor is zero.
    • zoomAt

      public final void zoomAt(@NotNull @NotNull Point p, float factor) throws IllegalArgumentException
      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 - when factor is not a number.
      IllegalArgumentException - when factor is negative.
      IllegalArgumentException - when factor is zero.
    • getViewOffset

      @Nullable public final @Nullable Point 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 - when x is not a number.
      IllegalArgumentException - when x is negative.
      IllegalArgumentException - when x is zero.
      IllegalArgumentException - when y is not a number.
      IllegalArgumentException - when y is negative.
      IllegalArgumentException - when y 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:
      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 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 - when factory is null.
    • unregisterStroker

      public final void unregisterStroker(@NotNull @NotNull String name)
      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 to commitModelDraw().
      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 - when canvas 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 by drawModelAsync().
      Throws:
      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:
      IllegalStateException - when this renderer is closed.
      IllegalArgumentException - when canvas 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 - when canvas is null.