Class SVGCanvasProvider

All Implemented Interfaces:
CanvasProvider

public class SVGCanvasProvider extends AbstractSVGGeneratingCanvasProvider
Implementation that outputs to a W3C DOM.
Version:
$Id: SVGCanvasProvider.java,v 1.6 2009-04-21 15:33:46 jmaerki Exp $
Author:
Jeremias Maerki
  • Constructor Details

    • SVGCanvasProvider

      public SVGCanvasProvider(String namespacePrefix, int orientation) throws BarcodeCanvasSetupException
      Creates a new SVGCanvasProvider with namespaces enabled.
      Parameters:
      namespacePrefix - the namespace prefix to use, null for no prefix
      orientation - the barcode orientation (0, 90, 180, 270)
      Throws:
      BarcodeCanvasSetupException - if setting up the provider fails
    • SVGCanvasProvider

      public SVGCanvasProvider(DOMImplementation domImpl, String namespacePrefix, int orientation) throws BarcodeCanvasSetupException
      Creates a new SVGCanvasProvider with namespaces enabled.
      Parameters:
      domImpl - DOMImplementation to use (JAXP default is used when this is null)
      namespacePrefix - the namespace prefix to use, null for no prefix
      orientation - the barcode orientation (0, 90, 180, 270)
      Throws:
      BarcodeCanvasSetupException - if setting up the provider fails
    • SVGCanvasProvider

      public SVGCanvasProvider(boolean useNamespace, int orientation) throws BarcodeCanvasSetupException
      Creates a new SVGCanvasProvider.
      Parameters:
      useNamespace - Controls whether namespaces should be used
      orientation - the barcode orientation (0, 90, 180, 270)
      Throws:
      BarcodeCanvasSetupException - if setting up the provider fails
    • SVGCanvasProvider

      public SVGCanvasProvider(DOMImplementation domImpl, boolean useNamespace, int orientation) throws BarcodeCanvasSetupException
      Creates a new SVGCanvasProvider.
      Parameters:
      domImpl - DOMImplementation to use (JAXP default is used when this is null)
      useNamespace - Controls whether namespaces should be used
      orientation - the barcode orientation (0, 90, 180, 270)
      Throws:
      BarcodeCanvasSetupException - if setting up the provider fails
    • SVGCanvasProvider

      public SVGCanvasProvider(int orientation) throws BarcodeCanvasSetupException
      Creates a new SVGCanvasProvider with default settings (with namespaces, but without namespace prefix).
      Parameters:
      orientation - the barcode orientation (0, 90, 180, 270)
      Throws:
      BarcodeCanvasSetupException - if setting up the provider fails
  • Method Details

    • getDOM

      public Document getDOM()
      Returns the DOM document containing the SVG barcode.
      Returns:
      the DOM document
    • getDOMFragment

      public DocumentFragment getDOMFragment()
      Returns the DOM fragment containing the SVG barcode.
      Returns:
      the DOM fragment
    • establishDimensions

      public void establishDimensions(BarcodeDimension dim)
      Sets the dimensions of the barcode.
      Specified by:
      establishDimensions in interface CanvasProvider
      Overrides:
      establishDimensions in class AbstractCanvasProvider
      Parameters:
      dim - the dimensions of the barcode
    • deviceFillRect

      public void deviceFillRect(double x, double y, double w, double h)
      Paints a filled rectangle.
      Parameters:
      x - x coordinate of the upper left corner
      y - y coordinate of the upper left corner
      w - the width
      h - the height
    • deviceText

      public void deviceText(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