com.wildcrest.j2printerworks
Class VerticalGap

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

public class VerticalGap
extends java.lang.Object
implements Flowable

A Flowable that introduces a specified vertical separation between other Flowables.

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

     flowPrinter.addFlowable(flowable1);
     flowPrinter.addFlowable(new VerticalGap(1.0));
     flowPrinter.addFlowable(flowable2);
will cause a one inch vertical white space gap to appear between flowable1 and flowable2.

The vertical gap does not carry over page boundaries, so in the above sequence if pageable1 ends within one inch of the bottom of a page, then new VerticalGap(1.0) will use up the remaining space on that page, but flowable2 will start immediately at the top of the next page.

The specified vertical gap cannot be negative and the default gap size is .25 inches.

In addition, an optional "testGap" feature provides way to test for the remaining space left on a page and skip to the top of the next page if not enough space remains. This provides a way to prevent too small a portion of the next Flowable appearing at the bottom of a page.


Field Summary
static int PPI72
           
 
Constructor Summary
VerticalGap()
          Construct a VerticalGap object (default gap .25 inches)
VerticalGap(double gap)
          Construct a VerticalGap object with a given gap size in inches
VerticalGap(double testGap, double realGap)
          Construct a VerticalGap object with a given testGap size and gap size in inches.
 
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.
 double getGap()
          Returns the specified vertical gap in inches
 double getTestGap()
          Returns the specified test gap in inches
 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 setGap(double gap)
          Specifies the size of the vertical gap between successive Flowables in inches.
 void setTestGap(double testGap)
          Specifies the size of the test gap remaining on the page in inches.
 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
 

Field Detail

PPI72

public static final int PPI72
See Also:
Constant Field Values
Constructor Detail

VerticalGap

public VerticalGap()
Construct a VerticalGap object (default gap .25 inches)


VerticalGap

public VerticalGap(double gap)
Construct a VerticalGap object with a given gap size in inches


VerticalGap

public VerticalGap(double testGap,
                   double realGap)
Construct a VerticalGap object with a given testGap size and gap size in inches. The first argument is used to test the remaining space left on a page, causing a skip to the top of the next page if there is not that much space remaining, otherwise introducing a vertical gap as specified by the second argument.

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(double gap)
Specifies the size of the vertical gap between successive Flowables in inches. The vertical gap does not carry over page boundaries. Negative values will be interpreted as a gap of 0.0 inches.

Parameters:
gap - the desired vertical gap in inches.

getGap

public double getGap()
Returns the specified vertical gap in inches


setTestGap

public void setTestGap(double testGap)
Specifies the size of the test gap remaining on the page in inches. The test gap is compared to the remaining space left on a page, causing a skip to the top of the next page if there is not that much space remaining, otherwise introducing a vertical gap as specified by the setGap method. Negative values will be interpreted as a test gap of 0.0 inches.

Parameters:
testGap - the test gap in inches (default: 0.0)

getTestGap

public double getTestGap()
Returns the specified test gap in inches


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