y.view
Class Graph2DPrinter

java.lang.Object
  |
  +--y.view.Graph2DPrinter
All Implemented Interfaces:
Printable

public class Graph2DPrinter
extends Object
implements Printable

This class is responsible for printing the contents of a Graph2DView on one or more pages. This class implements the Printable interface and can thus be passed to a PrinterJob instance for printing.


Field Summary
static byte CLIP_GRAPH
          Clip type specifier constant.
static byte CLIP_VIEW
          Clip type specifier constant.
static byte SCALING_AUTO
          Scaling type specifier constant.
static byte SCALING_FIX
          Scaling type specifier constant.
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Constructor Summary
Graph2DPrinter(Graph2DView view)
          Instantiates a new Graph2DPrinter for the given Graph2DView.
 
Method Summary
 byte getClipType()
          Returns the clipping type to be applied for printing.
 int getPosterColumns()
          Returns the number of page columns to be used for printing.
 int getPosterRows()
          Returns the number of page rows to be used for printing.
 boolean getPrintPosterCoords()
          Whether or not to number the pages by poster coordinates.
 double getScalingFactor()
          Returns the scale factor which is used when scale type is set to Graph2DPrinter.SCALING_FIX.
 byte getScalingType()
          Sets the scaling type to be applied for printing.
 int print(Graphics g1d, PageFormat pf, int pi)
          Printable implementation.
 void setClipType(byte clipType)
          Sets the clipping type to be applied for printing.
 void setPosterColumns(int columns)
          Sets the number of page columns to be used for printing.
 void setPosterRows(int rows)
          Sets the number of page rows to be used for printing.
 void setPrintPosterCoords(boolean ppc)
          Whether or not to number the pages by poster coordinates.
 void setScalingFactor(double scalingFactor)
          Sets the scale factor which is used when the scaling type is set to Graph2DPrinter.SCALING_FIX.
 void setScalingType(byte scalingType)
          Sets the scaling type to be applied for printing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCALING_AUTO

public static final byte SCALING_AUTO
Scaling type specifier constant. The document is scaled automatically to fit in the defined poster size.

See Also:
Constant Field Values

SCALING_FIX

public static final byte SCALING_FIX
Scaling type specifier constant. The document is scaled according to a user-defined scale factor. This scaling policy implies that the number of poster columns and rows will be chosen automatically to fit the scaled graph on the poster.

See Also:
Graph2DPrinter.setScalingFactor(double), Constant Field Values

CLIP_VIEW

public static final byte CLIP_VIEW
Clip type specifier constant. Prints the part of the document that is currently seen through the viewport of the associated view.

See Also:
Graph2DPrinter.setClipType(byte), Constant Field Values

CLIP_GRAPH

public static final byte CLIP_GRAPH
Clip type specifier constant. Prints the complete Document viewable with the associated Graph2DView.

See Also:
Graph2DPrinter.setClipType(byte), Constant Field Values
Constructor Detail

Graph2DPrinter

public Graph2DPrinter(Graph2DView view)
Instantiates a new Graph2DPrinter for the given Graph2DView.

Method Detail

setPrintPosterCoords

public void setPrintPosterCoords(boolean ppc)
Whether or not to number the pages by poster coordinates. This feature is not set by default.


getPrintPosterCoords

public boolean getPrintPosterCoords()
Whether or not to number the pages by poster coordinates.

See Also:
Graph2DPrinter.setPrintPosterCoords(boolean)

setPosterRows

public void setPosterRows(int rows)
Sets the number of page rows to be used for printing. By default 1 page row is used


setPosterColumns

public void setPosterColumns(int columns)
Sets the number of page columns to be used for printing. By default 1 page row is used


getPosterRows

public int getPosterRows()
Returns the number of page rows to be used for printing.

See Also:
Graph2DPrinter.setPosterRows(int)

getPosterColumns

public int getPosterColumns()
Returns the number of page columns to be used for printing.

See Also:
Graph2DPrinter.setPosterColumns(int)

setClipType

public void setClipType(byte clipType)
Sets the clipping type to be applied for printing. By default Graph2DPrinter.CLIP_GRAPH is set.

Parameters:
clipType - One of Graph2DPrinter.CLIP_VIEW, Graph2DPrinter.CLIP_GRAPH.

getClipType

public byte getClipType()
Returns the clipping type to be applied for printing.

See Also:
Graph2DPrinter.setClipType(byte)

setScalingFactor

public void setScalingFactor(double scalingFactor)
Sets the scale factor which is used when the scaling type is set to Graph2DPrinter.SCALING_FIX.

Parameters:
scalingFactor - scale factor, must be positive.

getScalingFactor

public double getScalingFactor()
Returns the scale factor which is used when scale type is set to Graph2DPrinter.SCALING_FIX.

Returns:
a positive value.
See Also:
Graph2DPrinter.setScalingFactor(double)

setScalingType

public void setScalingType(byte scalingType)
Sets the scaling type to be applied for printing.

Parameters:
scalingType - One of Graph2DPrinter.SCALING_AUTO, Graph2DPrinter.SCALING_FIX.

getScalingType

public byte getScalingType()
Sets the scaling type to be applied for printing.

Returns:
One of Graph2DPrinter.SCALING_AUTO, Graph2DPrinter.SCALING_FIX.
See Also:
Graph2DPrinter.setScalingType(byte)

print

public int print(Graphics g1d,
                 PageFormat pf,
                 int pi)
          throws PrinterException
Printable implementation. This agent will produce getPosterColumns()*getPosterRows() number of pages. The clipped part of the document will be printed centered on these pages with maximum uniform scaling applied.

This method can also be used to produce (print) preview images. In such cases it is important that there is a clip defined on the given graphics context.

Specified by:
print in interface Printable
PrinterException

© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003