Interface Canvas

All Superinterfaces:
Positionable
All Known Subinterfaces:
Window
All Known Implementing Classes:
SwingWindow

public interface Canvas extends Positionable
Represents a rendering context, with various drawing capabilities.
  • Method Details

    • getImage

      Image getImage(String name, RegionOfInterest roi, boolean removeBackground)
      Gets image from file system.
      Parameters:
      name - (String): full name of image, not null
      roi - (RegionOfInterest): region of interest
      removeBackground - (boolean): which indicate if we need to remove an uniform background
      Returns:
      an image object, null on error
    • drawImage

      void drawImage(Image image, Transform transform, float alpha, float depth)
      Draws specified image.
      Parameters:
      image - (Image): any image associated to this context, may be null
      transform - (Transform): any affine transform, not null
      alpha - (float): transparency, between 0.0 and 1.0
      depth - (float): any real, larger values are drawn afterward, i.e. above
    • drawShape

      void drawShape(Shape shape, Transform transform, Color fillColor, Color outlineColor, float thickness, float alpha, float depth)
      Draws specified image
      Parameters:
      shape - (Shape): any shape, may be null
      transform - (Transform): any affine transform, not null
      fillColor - (Color): color used to fill the shape, may be null
      outlineColor - (Color): color used to draw shape border, may be null
      thickness - (float): border thickness
      alpha - (float): transparency, between 0.0 and 1.0
      depth - (float): any real, larger values are drawn afterward, i.e. above
    • registerFonts

      void registerFonts(String directoryName)
      Register all the font in a directory
      Parameters:
      directoryName - (String): the name of the directory
    • drawText

      void drawText(String text, float fontSize, Transform transform, Color fillColor, Color outlineColor, float thickness, String fontName, boolean bold, boolean italics, Vector anchor, TextAlign.Horizontal hAlign, TextAlign.Vertical vAlign, float alpha, float depth)
      Creates a new text graphics.
      Parameters:
      text - (String): content, not null
      fontSize - (float): size
      transform - (Transform): affine transform, not null
      fillColor - (Color): fill color, may be null
      outlineColor - (Color): outline color, may be null
      thickness - (float): outline thickness
      fontName - (String): the font name
      bold - (boolean): whether to use bold font
      italics - (boolean): whether to use italics font
      anchor - (Vector): text anchor
      hAlign - (TextAlign.Horizontal): horizontal alignment of the text around the anchor vector
      vAlign - (TextAlign.Vertical): vertical alignment of the text around the anchor vector
      alpha - (float): transparency, between 0 (invisible) and 1 (opaque)
      depth - (float): render priority, lower-values drawn first
    • convertPositionOnScreen

      Vector convertPositionOnScreen(Vector coord)
      Convert a coordinate in the canvas to a coordinate in the screen
      Parameters:
      coord - the coordinate in the canvas
      Returns:
      the coordinate in the screen
    • getWidth

      int getWidth()
      Return the canvas width
      Returns:
      width (int): the canvas width
    • getHeight

      int getHeight()
      Return the canvas height
      Returns:
      height (int): the canvas height
    • getXScale

      float getXScale()
      Return the canvas scaled width
      Returns:
      width (float): the canvas scaled width
    • getYScale

      float getYScale()
      Return the canvas scaled height
      Returns:
      height (float): the canvas scaled height
    • getScaledWidth

      float getScaledWidth()
      Return the canvas scaled width after adjusting to ratio
      Returns:
      width (float): the canvas scaled width
    • getScaledHeight

      float getScaledHeight()
      Return the canvas scaled height after adjusting to ratio
      Returns:
      height (float): the canvas scaled height