|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.awt.print.PageFormat
com.tensegrity.gui.printing.BasePageFormat
The BasePageFormat class extends the default
PageFormat implementation about several useful features to
implement sophisticated printing. While the standard PageFormat
class only provides a imageableX and -Y position, this class provides you
with a left, right, a top and bottom margins.
You can provide a header- and footer text (see
FormatItem). Each of the these items can
be separately formatted.
You can obtain a scaled version of a page format object, if you consider to use it as a basis for your (print)- preview. Set a scale factor that will get used to scale the things to be printed onto a page.
Use the build(AttributeList)method to create an instance of this
class from an AttributeList, or use serialize()to create an
AttributeList from your PageFormat instance.
| Field Summary | |
static double |
DEFAULT_MARGIN
Constant defines the default value for the left, top, right and bottom margins |
protected FormatItem[] |
footerItems
List of items used to format the footer of this page. |
protected FormatItem[] |
headerItems
List of items used to format the header of this page. |
static int |
QUALITY_COLORED
Constant field to describe the colored mode. |
static int |
QUALITY_MONO
Constant field to describe the mono mode. |
static int |
QUALITY_WIREFRAME
Constant field to describe the WireFrame mode. |
static int |
SCALEMODE_FITTOPAGE_BOTH
Constant describing the fit-to-page both scale mode. |
static int |
SCALEMODE_FITTOPAGE_HORIZONTAL
Constant describing the fit-to-page horizontal scale mode. |
static int |
SCALEMODE_FITTOPAGE_VERTICAL
Constant describing the fit-to-page vertical scale mode. |
static int |
SCALEMODE_PERCENT
Constant describing the percentage scale mode. |
| Fields inherited from class java.awt.print.PageFormat |
LANDSCAPE, PORTRAIT, REVERSE_LANDSCAPE |
| Constructor Summary | |
BasePageFormat(BasePageFormat other)
Copy constructor. |
|
BasePageFormat(java.lang.String paperName)
Constructor for BasePageFormat. |
|
| Method Summary | |
static BasePageFormat |
build(AttributeList list)
The build method tries to retrieve all the required values from the given AttributeList by using the BuilderUtilities.getAttributeValueMayBeNull(AttributeList, String, Class)
method. |
boolean |
compare(BasePageFormat aFormat)
The compare method helps users of this class to compare
two BasePageFormat instances. |
double |
getBottomMargin()
Returns the bottomMargin. |
abstract BasePageFormat |
getCopy()
Returns a copy of this BasePageFormat. |
FormatItem[] |
getFooter()
The method getFooter returns the FormatItem list. |
abstract double |
getFooterFontHeight()
The method getFooterFontHeight returns the maximum scaled font size of all 3 possible fonts of the footer items. |
FormatItem[] |
getHeader()
The method getHeader returns the FormatItem list. |
abstract double |
getHeaderFontHeight()
Returns the maximum height in pixel used by all the (scaled) header items. |
double |
getLeftMargin()
Returns the leftMargin. |
int |
getPages()
Deprecated. use #getPagesHorizontal(int) |
int |
getPagesHorizontal()
The method getPages returns the number of pages to be used when being in SCALEMODE_FITTOPAGE. |
int |
getPagesVertical()
The method getPages returns the number of pages to be used when being in SCALEMODE_FITTOPAGE. |
java.lang.String |
getPaperName()
Method getName returns the human readable name of the the underlying paper type of this PageFormat. |
int |
getPercent()
Method getPercent returns the percentage value to be used while in SCALE_PERCENT mode. |
int |
getQuality()
Returns the quality. |
double |
getRightMargin()
Returns the rightMargin. |
double |
getScale()
Returns the scale. |
FontFormat |
getScaledFont(FontFormat font)
Method getScaledrFont returns a vertically scaled font instance. |
FontFormat |
getScaledFont(FontFormat font,
int dpi)
Method getScaledFont returns a vertically scaled font instance. |
int |
getScalingMode()
Method getScalingMode returns the currently set scale mode. |
double |
getTopMargin()
Returns the topMargin. |
double |
getVerticalScaleFactor()
Calculates a vertical scale factor. |
double |
getVerticalScaleFactor(int dpi)
Calculates a vertical scale factor. |
PaintFormat |
getViewPaint()
Returns the PaintFormat of a VisualGraphView. |
boolean |
hasFooter()
The method hasFooter indicates whether one of the applied format items for the footer contains text. |
boolean |
hasHeader()
The method hasHeader indicates whether one of the applied format items for the header contains text. |
boolean |
isBothFitToPage()
Returns true if the scaling mode is FITTOPAGE_BOTH. |
boolean |
isGridPrinting()
Returns true, if the grid will be printed also |
boolean |
isHorizontalFitToPage()
Returns true if the scaling mode is set to FITTOPAGE_HORIZONTAL. |
boolean |
isPercentScaling()
Returns true if the scale mode is set to PERCENT. |
boolean |
isVerticalFitToPage()
Returns true if the scaling mode is FITTOPAGE_VERTICAL. |
boolean |
printEmptyPages()
Returns the flag whether to print empty pages or not. |
boolean |
printShadedBackground()
Returns the flag for printing the background or not. |
boolean |
printSubgraphBackground()
Returns the flag whether to print the background of subgraphs or not. |
void |
resetMargins()
Sets the margin values according to the current imageableX and -Y positions of the underlying paper. |
AttributeList |
serialize()
Combine all attributes of this PageFormat instance, which differ from the PrintUtil.DEFAULT_PAGEFORMAT, into a new AttributeList. |
void |
setBottomMargin(double bottomMargin)
Sets the bottomMargin. |
void |
setFooter(FormatItem[] items)
The method setFooter sets the item used to format the footer. |
void |
setGridPrinting(boolean printGrid)
Enables / Disables the printing of the grid |
void |
setHeader(FormatItem[] items)
The method setHeader sets the items used to format the header. |
void |
setLeftMargin(double leftMargin)
Sets the leftMargin. |
void |
setMargins(double left,
double top,
double right,
double bottom)
Sets the margins of this PageFormat. |
void |
setPages(int pages)
Deprecated. use setPagesHorizontal(int) |
void |
setPagesHorizontal(int pages)
The method setPages sets the number of pages used when being in SCALEMODE_FITTOPAGE mode. |
void |
setPagesVertical(int pages)
The method setPages sets the number of pages used when being in SCALEMODE_FITTOPAGE mode. |
void |
setPaperName(java.lang.String name)
Sets the name of this PageFormat. |
void |
setPercent(int percent)
Method setPercent sets the percent value to be used while in SCALE_PERCENT mode. |
void |
setPrintEmptyPages(boolean b)
Set the flag to indicate whether empty pages will be printed or not. |
void |
setPrintShadedBackground(boolean b)
Toggles the shaded background flag. |
void |
setPrintSubgraphBackground(boolean b)
Set the flag to indicate whether subgraph background will be printed or not. |
void |
setQuality(int quality)
Sets the quality. |
void |
setRightMargin(double rightMargin)
Sets the rightMargin. |
void |
setScale(double scale)
Sets the scale. |
void |
setScalingMode(int mode)
Method setScalingMode sets the current mode which will used to scale the printable element. |
void |
setTopMargin(double topMargin)
Sets the topMargin and corrects the imageable area of the underlying paper instance. |
void |
setViewPaint(PaintFormat format)
Sets the PaintFormat. |
java.lang.String |
toString()
Returns a human readable description of this BasePageFormat instance. |
| Methods inherited from class java.awt.print.PageFormat |
clone, getHeight, getImageableHeight, getImageableWidth, getImageableX, getImageableY, getMatrix, getOrientation, getPaper, getWidth, setOrientation, setPaper |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected FormatItem[] headerItems
protected FormatItem[] footerItems
public static final int SCALEMODE_PERCENT
public static final int SCALEMODE_FITTOPAGE_HORIZONTAL
public static final int SCALEMODE_FITTOPAGE_VERTICAL
public static final int SCALEMODE_FITTOPAGE_BOTH
public static final int QUALITY_COLORED
public static final int QUALITY_MONO
public static final int QUALITY_WIREFRAME
public static final double DEFAULT_MARGIN
| Constructor Detail |
public BasePageFormat(java.lang.String paperName)
com.tensegrity.gui.swing.print.PrintUtil#paperTypeNamesfor
available paper types.
paperName - a name of paper as String.public BasePageFormat(BasePageFormat other)
other - the format instance to obtain the values from.| Method Detail |
public static final BasePageFormat build(AttributeList list)
BuilderUtilities.getAttributeValueMayBeNull(AttributeList, String, Class)
method. This means, an empty AttributeList would result in the creation
of the PrintUtil.DEFAULT_PAGEFORMATitem. Each successful read
value from the list, will be set on the default item.
list - an AttributeList which contains several Attributes concerning
the BasePageFormat class.
public final AttributeList serialize()
PrintUtil.DEFAULT_PAGEFORMAT, into a new AttributeList.
public boolean compare(BasePageFormat aFormat)
compare method helps users of this class to compare
two BasePageFormat instances. Unlike a String.compare method, this method
will return a boolean.
aFormat - the format to compare to.
true to indicate that the two PageFormats are
equal after comparing all the relevant values.public void setHeader(FormatItem[] items)
items - the list of items to use for the header.public void setFooter(FormatItem[] items)
items - the list of items to use for the footer.public FormatItem[] getHeader()
public FormatItem[] getFooter()
public boolean hasHeader()
public boolean hasFooter()
public boolean isHorizontalFitToPage()
public boolean isVerticalFitToPage()
public boolean isBothFitToPage()
public boolean isPercentScaling()
public abstract double getFooterFontHeight()
public abstract double getHeaderFontHeight()
public abstract BasePageFormat getCopy()
BasePageFormat.
BasePageFormat.public java.lang.String getPaperName()
public FontFormat getScaledFont(FontFormat font)
font - the font you want to scale.
public FontFormat getScaledFont(FontFormat font,
int dpi)
font - the font you want to scale.dpi - the device resolution
public double getVerticalScaleFactor()
public double getVerticalScaleFactor(int dpi)
dpi - the device resolution
public double getBottomMargin()
public double getLeftMargin()
public double getRightMargin()
public double getTopMargin()
public void setLeftMargin(double leftMargin)
leftMargin - The leftMargin to setpublic void setTopMargin(double topMargin)
topMargin - The topMargin to setpublic void setRightMargin(double rightMargin)
rightMargin - The rightMargin to setpublic void setBottomMargin(double bottomMargin)
bottomMargin - The bottomMargin to set
public void setMargins(double left,
double top,
double right,
double bottom)
#updatePaper()after
assigning the values.
left - margin to the left.top - margin on top.right - margin to the right.bottom - margin to the bottom.public void resetMargins()
public double getScale()
public void setScale(double scale)
scale - The scale value to set.public void setScalingMode(int mode)
mode - the new scaling mode.SCALEMODE_FITTOPAGE_HORIZONTAL,
SCALEMODE_FITTOPAGE_VERTICAL,
SCALEMODE_FITTOPAGE_BOTH,
SCALEMODE_PERCENTpublic int getScalingMode()
public int getPercent()
public void setPercent(int percent)
percent - the percent value between 0 and 100.public void setPaperName(java.lang.String name)
name - The name to setpublic int getQuality()
public void setQuality(int quality)
quality - The quality to setQUALITY_COLORED,
QUALITY_MONO,
QUALITY_WIREFRAMEpublic int getPagesHorizontal()
public void setPagesHorizontal(int pages)
setScalingMode(SCALEMODE_FITTOPAGE_HORIZONTAL); setPages(4);
pages - number of pages to use while scaling as int.public int getPagesVertical()
public void setPagesVertical(int pages)
setScalingMode(SCALEMODE_FITTOPAGE_VERTICAL); setPages(4);
pages - number of pages to use while scaling as int.public void setPages(int pages)
setPagesHorizontal(int)
setScalingMode(SCALEMODE_FITTOPAGE_HORIZONTAL); setPages(4);
pages - number of pages to use while scaling as int.public int getPages()
#getPagesHorizontal(int)
public java.lang.String toString()
Object.toString()public boolean printShadedBackground()
true, to indicate that the shaded background of
the view should be printed, false otherwise.public void setPrintShadedBackground(boolean b)
b - the flag to indicate the "print shaded background" toggle.public void setPrintSubgraphBackground(boolean b)
b - set to true, to indicate that the background
of the subgraphs should be printed. false to
turn that off.public boolean printSubgraphBackground()
true to indicate that the backgrounds of subgraphs
are printed, false otherwise.public void setPrintEmptyPages(boolean b)
b - set to true, to indicate that empty pages
should be printed. false to turn that off.public boolean printEmptyPages()
true to indicate that empty pages should be printed.public PaintFormat getViewPaint()
public void setViewPaint(PaintFormat format)
format - the new PaintFormat to store.public void setGridPrinting(boolean printGrid)
printGrid - true, to enable printing of the gridpublic boolean isGridPrinting()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||