y.view
Class Graph2DPrinter

java.lang.Object
  extended by 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.

 

Nested Class Summary
static class Graph2DPrinter.DefaultFooterDrawable
          Default footer drawable implementation.
static class Graph2DPrinter.DefaultTitleDrawable
          Default title drawable implementation.
static interface Graph2DPrinter.FooterDrawable
          Interface for classes that want to add a footer to the printed page.
static class Graph2DPrinter.PrintContext
          Class that encapsulates contextual information when printing a page.
static interface Graph2DPrinter.TitleDrawable
          Interface for classes that want to add a title to the printed page.
 
Field Summary
static byte CLIP_CUSTOM
          Clip type specifier constant.
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.
 Rectangle2D getCustomClip()
          Returns the custom area clip measured in world coordinates.
 Dimension getFixedScalingPosterDimension(PageFormat pf)
          Returns the best-fit poster dimension measured in number of page columns and page rows.
 Graph2DPrinter.FooterDrawable getFooterDrawable()
          Returns the footer drawable of this class.
 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 SCALING_FIX.
 byte getScalingType()
          Sets the scaling type to be applied for printing.
 Graph2DPrinter.TitleDrawable getTitleDrawable()
          Returns the title drawable of this class.
 int print(Graphics g1d, PageFormat pf, int pi)
          Printable implementation.
 void setClipType(byte clipType)
          Sets the clipping type to be applied for printing.
 void setCustomClip(Rectangle2D clip)
          Sets the custom area clip measured in world coordinates.
 void setFooterDrawable(Graph2DPrinter.FooterDrawable fd)
          Sets the footer drawable of this class.
 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 SCALING_FIX.
 void setScalingType(byte scalingType)
          Sets the scaling type to be applied for printing.
 void setTitleDrawable(Graph2DPrinter.TitleDrawable td)
          Sets the title drawable of this class.
 
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:
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:
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:
setClipType(byte), Constant Field Values

CLIP_CUSTOM

public static final byte CLIP_CUSTOM
Clip type specifier constant. Prints a rectangular area that can be specifed with method setCustomClip(Rectangle2D)

See Also:
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:
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:
setPosterRows(int)

getPosterColumns

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

See Also:
setPosterColumns(int)

setClipType

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

Parameters:
clipType - One of CLIP_VIEW, CLIP_GRAPH.

getClipType

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

See Also:
setClipType(byte)

setScalingFactor

public void setScalingFactor(double scalingFactor)
Sets the scale factor which is used when the scaling type is set to 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 SCALING_FIX.

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

setScalingType

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

Parameters:
scalingType - One of SCALING_AUTO, SCALING_FIX.

getScalingType

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

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

setCustomClip

public void setCustomClip(Rectangle2D clip)
Sets the custom area clip measured in world coordinates. The custom clip has only meaning if the clip type CLIP_CUSTOM is specified.


getCustomClip

public Rectangle2D getCustomClip()
Returns the custom area clip measured in world coordinates. The custom clip has only meaning if the clip type CLIP_CUSTOM is specified.


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
Throws:
PrinterException

getFixedScalingPosterDimension

public Dimension getFixedScalingPosterDimension(PageFormat pf)
Returns the best-fit poster dimension measured in number of page columns and page rows.

Returns:
poster columns x poster rows

setTitleDrawable

public void setTitleDrawable(Graph2DPrinter.TitleDrawable td)
Sets the title drawable of this class.


getTitleDrawable

public Graph2DPrinter.TitleDrawable getTitleDrawable()
Returns the title drawable of this class.


setFooterDrawable

public void setFooterDrawable(Graph2DPrinter.FooterDrawable fd)
Sets the footer drawable of this class.


getFooterDrawable

public Graph2DPrinter.FooterDrawable getFooterDrawable()
Returns the footer drawable of this class.


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