net.sourceforge.barbecue.output
Class SVGOutput

java.lang.Object
  extended bynet.sourceforge.barbecue.output.AbstractOutput
      extended bynet.sourceforge.barbecue.output.SVGOutput

public class SVGOutput
extends AbstractOutput

SVG outputter to output barcodes as SVG files. Contributed by Ryan Martell.

Author:
Ryan Martell, Ian Bourke

Field Summary
 
Fields inherited from class net.sourceforge.barbecue.output.AbstractOutput
backgroundColour, barHeight, font, foregroundColour, painting, scalar
 
Constructor Summary
SVGOutput(java.io.Writer writer, java.awt.Font font, double barHeight, java.awt.Color fgColor, java.awt.Color bgColor, double scalar, java.lang.String units)
          Creates a new instance of SVGOutput.
 
Method Summary
 void beginDraw(double width, double height)
          From AbstractOutput - sets up the SVG output.
 void drawBar(int x, int y, int width, int height, boolean paintWithForegroundColor)
          From AbstractOutput - outputs the correct rectangle to the SVG output.
 double drawText(java.lang.String text, double x, double y, double width)
          From AbstractOutput - Draw the specified text to the SVG output.
 void endDraw()
          From AbstractOutput - finished up the SVG output.
 
Methods inherited from class net.sourceforge.barbecue.output.AbstractOutput
getBackgroundColour, getBarHeight, getBarWidth, getForegroundColour, setupForBlankDrawing, teardownFromBlankDrawing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SVGOutput

public SVGOutput(java.io.Writer writer,
                 java.awt.Font font,
                 double barHeight,
                 java.awt.Color fgColor,
                 java.awt.Color bgColor,
                 double scalar,
                 java.lang.String units)
Creates a new instance of SVGOutput.

Parameters:
writer - The Writer to output the SVG text to
font - The font for text rendering (only if Barcode has drawText set to true)
barHeight - The height of the barcode
fgColor - Foreground color
bgColor - Background color
scalar - The scalar value to convert to units. if barWidth is 1, and you want the smallest bar to be 1/128 of an inch, this should be set to 1.0/128, and units should be set to "in"
units - The units for the scalar, above. "in", "cm", "mm", "px" are acceptable values.
Method Detail

beginDraw

public void beginDraw(double width,
                      double height)
From AbstractOutput - sets up the SVG output.

Specified by:
beginDraw in class AbstractOutput
Parameters:
width - The output width (in pixels) of the barcode
height - The output height (in pixels) of the barcode.

endDraw

public void endDraw()
From AbstractOutput - finished up the SVG output.

Specified by:
endDraw in class AbstractOutput

drawBar

public void drawBar(int x,
                    int y,
                    int width,
                    int height,
                    boolean paintWithForegroundColor)
From AbstractOutput - outputs the correct rectangle to the SVG output.

Specified by:
drawBar in class AbstractOutput
Parameters:
x - the x coordinate
y - the y coordinate
width - the width
height - the height
paintWithForegroundColor - if true, use the foreground color, otherwise use the background color

drawText

public double drawText(java.lang.String text,
                       double x,
                       double y,
                       double width)
From AbstractOutput - Draw the specified text to the SVG output.

Specified by:
drawText in class AbstractOutput
Parameters:
text - The text to draw
x - The x position
y - The y position
width - The width of barcode (total)
Returns:
The height of this text