com.wildcrest.j2printerworks
Class HorizontalLine

java.lang.Object
  extended bycom.wildcrest.j2printerworks.HorizontalLine
All Implemented Interfaces:
Flowable

public class HorizontalLine
extends java.lang.Object
implements Flowable

A Flowable used for drawing a horizontal line separator between other Flowables. Can specify white space gap above/below line (in pixels), height of line (in pixels), width of line (in pixels wide or indented from edges), and Color of line.

For example, when using J2FlowPrinter to print a sequence of Flowables, the sequence:

     flowPrinter.addFlowable(flowable1);
     flowPrinter.addFlowable(new HorizontalLine());
     flowPrinter.addFlowable(flowable2);
will insert a default horizontal line separator between flowable1 and flowable2.


Constructor Summary
HorizontalLine()
          Construct a HorizontalLine object 4 pixels high with 16 pixels above and below (= 1/2 inch total), and width 72 pixels indented on each size (= 1 inch each), and color lightGray.
HorizontalLine(int gap, int height, int width)
          Construct a HorizontalLine object with a given gap, height, width, and color lightGray
HorizontalLine(int gap, int height, int width, java.awt.Color color)
          Construct a HorizontalLine object with a given gap, height, width, and color
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Add a PropertyChangeListener for this component
 boolean doneX()
          Returns whether there is no more of this Flowable object to print horizontally.
 boolean doneY()
          Returns whether there is no more of this Flowable object to print vertically.
 java.awt.Color getColor()
          Returns the specified Color of the horizontal line.
 int getGap()
          Returns the specified vertical gap in pixels.
 int getHeight()
          Returns the specified height of the horizontal line in pixels.
 int getWidth()
          Returns the specified width of the horizontal line in pixels.
 void printFlowable(java.awt.Graphics g, int availableWidth, int availableHeight, int nextFullPageWidth, int nextFullPageHeight)
          Print the next sequential section of this Flowable object that fits into the next incremental area.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Remove a PropertyChangeListener for this component
 void resetFlowable()
          Reset the Flowable object so that it starts printing from the beginning.
 void setColor(java.awt.Color color)
          Specifies the Color of the horizontal line.
 void setGap(int gap)
          Specifies the size of the vertical gap (white space) above and again below the horizontal line in pixels.
 void setHeight(int height)
          Specifies the height of the horizontal line in pixels.
 void setWidth(int width)
          Specifies the width of the horizontal line in pixels, specifying either the line width itself (if positive) or the distance inward from each of the left and right margins (if negative).
 int usedX()
          Returns the amount this Flowable object was able to advance horizontally in the last printFlowable call.
 int usedY()
          Returns the amount this Flowable object was able to advance vertically in the last printFlowable call.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HorizontalLine

public HorizontalLine()
Construct a HorizontalLine object 4 pixels high with 16 pixels above and below (= 1/2 inch total), and width 72 pixels indented on each size (= 1 inch each), and color lightGray.


HorizontalLine

public HorizontalLine(int gap,
                      int height,
                      int width)
Construct a HorizontalLine object with a given gap, height, width, and color lightGray


HorizontalLine

public HorizontalLine(int gap,
                      int height,
                      int width,
                      java.awt.Color color)
Construct a HorizontalLine object with a given gap, height, width, and color

Method Detail

printFlowable

public void printFlowable(java.awt.Graphics g,
                          int availableWidth,
                          int availableHeight,
                          int nextFullPageWidth,
                          int nextFullPageHeight)
Description copied from interface: Flowable
Print the next sequential section of this Flowable object that fits into the next incremental area.

Specified by:
printFlowable in interface Flowable
Parameters:
g - context into which the page is to be drawn (null means advance but don't actually print)
availableWidth - horizontal amount into which the next sequential amount of this Flowable is to be printed.
availableHeight - vertical amount into which the next sequential amount of this Flowable is to be printed.
nextFullPageWidth - horizontal size of next full page (lets Flowables decide whether to opt for next page).
nextFullPageHeight - vertical size of next full page (lets Flowables decide whether to opt for next page).

The above parameters specify a rectangular area of size width by height (height = down the page) in pixels (72 dpi printing "points"). A Flowable object is assumed to print in "raster" order (over then down). Assumes upon entry that translation and scale are already set up so that 0,0 is the upper left corner to print and width and height are already increased by the overall printer scale. Flowable object must return Graphics context translation and scale to values at entry if changed during printing. Upon return from printFlowable, the doneX, doneY, usedX, and usedY methods describe the resulting state of the Flowable, based on its ability to make progress. Return values of usedX and usedY are to be specified in same scale as availableWidth and availableHeight were given.


usedX

public int usedX()
Description copied from interface: Flowable
Returns the amount this Flowable object was able to advance horizontally in the last printFlowable call.

Specified by:
usedX in interface Flowable

usedY

public int usedY()
Description copied from interface: Flowable
Returns the amount this Flowable object was able to advance vertically in the last printFlowable call.

Specified by:
usedY in interface Flowable

doneX

public boolean doneX()
Description copied from interface: Flowable
Returns whether there is no more of this Flowable object to print horizontally.

Specified by:
doneX in interface Flowable

doneY

public boolean doneY()
Description copied from interface: Flowable
Returns whether there is no more of this Flowable object to print vertically.

Specified by:
doneY in interface Flowable

resetFlowable

public void resetFlowable()
Description copied from interface: Flowable
Reset the Flowable object so that it starts printing from the beginning.

Specified by:
resetFlowable in interface Flowable

setGap

public void setGap(int gap)
Specifies the size of the vertical gap (white space) above and again below the horizontal line in pixels. The bottom gap does not carry over page boundaries.

Parameters:
gap - the desired vertical gap in pixels.

getGap

public int getGap()
Returns the specified vertical gap in pixels.


setHeight

public void setHeight(int height)
Specifies the height of the horizontal line in pixels.

Parameters:
height - the desired height of the horizontal line in pixels.

getHeight

public int getHeight()
Returns the specified height of the horizontal line in pixels.


setWidth

public void setWidth(int width)
Specifies the width of the horizontal line in pixels, specifying either the line width itself (if positive) or the distance inward from each of the left and right margins (if negative). An argument of 0 means use full width of page (between margins), > 0 means generate a line of that width, < 0 means leave gaps of -width to left and to right of line within the margins.

Parameters:
width - the desired width of the horizontal line pixels. 0 means use full width of page (between margins), > 0 means generate a line of that width, < 0 means leave gaps of -width to left and to right of line.

getWidth

public int getWidth()
Returns the specified width of the horizontal line in pixels.


setColor

public void setColor(java.awt.Color color)
Specifies the Color of the horizontal line.

Parameters:
color - the desired Color of the horizontal line.

getColor

public java.awt.Color getColor()
Returns the specified Color of the horizontal line.


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Add a PropertyChangeListener for this component


removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Remove a PropertyChangeListener for this component