Class Canvas

java.lang.Object
org.krysalis.barcode4j.output.Canvas

public class Canvas extends Object
This class is used by barcode rendering classes that paint a barcode using a coordinate system. The class delegates the call to a CanvasProvider and provides some convenience methods.
Version:
$Id: Canvas.java,v 1.4 2008-05-13 13:00:45 jmaerki Exp $
Author:
Jeremias Maerki
  • Constructor Details

    • Canvas

      public Canvas(CanvasProvider canvasImp)
      Main constructor
      Parameters:
      canvasImp - the canvas provider to use
  • Method Details

    • getCanvasImp

      public CanvasProvider getCanvasImp()
      Returns the canvas provider in use.
      Returns:
      the canvas provider
    • establishDimensions

      public void establishDimensions(BarcodeDimension dim)
      Sets the dimensions of the barcode.
      Parameters:
      dim - the barcode dimensions
    • getOrientation

      public int getOrientation()
      Returns:
      the orientation of the barcode (0, 90, 180, 270, -90, -180, -270)
    • drawRect

      public void drawRect(double x1, double y1, double x2, double y2)
      Draws a rectangle.
      Parameters:
      x1 - x coordinate of the upper left corner
      y1 - y coordinate of the upper left corner
      x2 - x coordinate of the lower right corner
      y2 - y coordinate of the lower right corner
    • drawRectWH

      public void drawRectWH(double x, double y, double w, double h)
      Draws a rectangle
      Parameters:
      x - x coordinate of the upper left corner
      y - y coordinate of the upper left corner
      w - the width
      h - the height
    • drawCenteredChar

      public void drawCenteredChar(char ch, double x1, double x2, double y1, String fontName, double fontSize)
      Draws a centered character.
      Parameters:
      ch - the character
      x1 - the left boundary
      x2 - the right boundary
      y1 - the y coordinate
      fontName - the name of the font
      fontSize - the size of the font
    • drawJustifiedText

      public void drawJustifiedText(String text, double x1, double x2, double y1, String fontName, double fontSize)
      Draws justified text.
      Parameters:
      text - the text to draw
      x1 - the left boundary
      x2 - the right boundary
      y1 - the y coordinate
      fontName - the name of the font
      fontSize - the size of the font
    • drawCenteredText

      public void drawCenteredText(String text, double x1, double x2, double y1, String fontName, double fontSize)
      Draws centered text.
      Parameters:
      text - the text to draw
      x1 - the left boundary
      x2 - the right boundary
      y1 - the y coordinate
      fontName - the name of the font
      fontSize - the size of the font
    • drawText

      public void drawText(String text, double x1, double x2, double y1, String fontName, double fontSize, TextAlignment textAlign)
      Draws text.
      Parameters:
      text - the text to draw
      x1 - the left boundary
      x2 - the right boundary
      y1 - the y coordinate
      fontName - the name of the font
      fontSize - the size of the font
      textAlign - the text alignment