net.sourceforge.barbecue.output
Class AbstractOutput

java.lang.Object
  extended bynet.sourceforge.barbecue.output.AbstractOutput
Direct Known Subclasses:
GraphicsOutput, SVGOutput

public abstract class AbstractOutput
extends java.lang.Object

Abstract class of which concrete implementations provide means for outputting barcodes to different output formats.

Author:
Ian Bourke

Field Summary
protected  java.awt.Color backgroundColour
          The background colour for drawing
protected  double barHeight
          The bar height.
protected  java.awt.Font font
          The font to draw any text labels with.
protected  java.awt.Color foregroundColour
          The foreground colour for drawing
protected  boolean painting
          Flag indicating whether the barcode will actually be outputted, or is just being sized.
protected  double scalar
          The scaling factor to correctly size the barcode in the output units.
 
Constructor Summary
protected AbstractOutput(java.awt.Font font, double barWidth, double barHeight, boolean painting, double scalar, java.awt.Color foregroundColour, java.awt.Color backgroundColour)
          Populates this abstract outputter with common values.
 
Method Summary
abstract  void beginDraw(double width, double height)
          Sets up the drawing environment.
abstract  void drawBar(int x, int y, int width, int height, boolean paintWithForegroundColor)
          "Draws" a bar at the given coordinates.
abstract  double drawText(java.lang.String text, double x, double y, double width)
          Draw the specified text.
abstract  void endDraw()
          Balanced with startDraw() above, used for caching, output of epilogues (for SVG), etc.
 java.awt.Color getBackgroundColour()
          Returns the current background colour for any artifacts drawn to the graphics.
 double getBarHeight()
          Get the Height of the barcode
 double getBarWidth()
          returns the unit bar width
 java.awt.Color getForegroundColour()
          Returns the current foreground colour for any artifacts drawn to the graphics.
 void setupForBlankDrawing()
          Used by BlankModule() to prevent drawing of the white header space.
 void teardownFromBlankDrawing()
          see setupForBlankDrawing()
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

barHeight

protected final double barHeight
The bar height.


painting

protected final boolean painting
Flag indicating whether the barcode will actually be outputted, or is just being sized.


scalar

protected final double scalar
The scaling factor to correctly size the barcode in the output units.


font

protected final java.awt.Font font
The font to draw any text labels with.


backgroundColour

protected final java.awt.Color backgroundColour
The background colour for drawing


foregroundColour

protected java.awt.Color foregroundColour
The foreground colour for drawing

Constructor Detail

AbstractOutput

protected AbstractOutput(java.awt.Font font,
                         double barWidth,
                         double barHeight,
                         boolean painting,
                         double scalar,
                         java.awt.Color foregroundColour,
                         java.awt.Color backgroundColour)
Populates this abstract outputter with common values.

Parameters:
font - The font to draw text labels with
barWidth - The width of the smallest bar (in bar units)
barHeight - The height of the bars
painting - Flag indicating whether painting will actually occur
scalar - The scaling factor to size the barcode into the correct units
foregroundColour - The colour to paint in
backgroundColour - The background colour
Method Detail

setupForBlankDrawing

public void setupForBlankDrawing()
Used by BlankModule() to prevent drawing of the white header space. Must be matched with a call to tearDownFromBlankDrawing()


teardownFromBlankDrawing

public void teardownFromBlankDrawing()
see setupForBlankDrawing()


getBarWidth

public double getBarWidth()
returns the unit bar width

Returns:
the width of the smallest bar

getBarHeight

public double getBarHeight()
Get the Height of the barcode

Returns:
the height

drawBar

public abstract void drawBar(int x,
                             int y,
                             int width,
                             int height,
                             boolean paintWithForegroundColor)
"Draws" a bar at the given coordinates.

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

beginDraw

public abstract void beginDraw(double width,
                               double height)
Sets up the drawing environment. Called before drawBar(). Matched with call to endDraw() at the end. This allows for caching as needed.

Parameters:
width - The output width (in pixels) of the barcode
height - The output height (in pixels) of the barcode.

endDraw

public abstract void endDraw()
Balanced with startDraw() above, used for caching, output of epilogues (for SVG), etc.


drawText

public abstract double drawText(java.lang.String text,
                                double x,
                                double y,
                                double width)
Draw the specified text.

Parameters:
text - text to draw
x - x position
y - y position
width - width of barcode (total)
Returns:
the height of this text

getForegroundColour

public java.awt.Color getForegroundColour()
Returns the current foreground colour for any artifacts drawn to the graphics.

Returns:
The current foreground colour

getBackgroundColour

public java.awt.Color getBackgroundColour()
Returns the current background colour for any artifacts drawn to the graphics.

Returns:
The current background colour