|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.tensegrity.gui.printing.PrintUtil
Class PrintUtil provides useful methods for printing operations
inside the Tensegrity API. Furthermore it defines a static
BookParameter class which holds information describing how
a VisualGraphView is devided into several pages of a given page format.
Use the createBookParameter() methods to obtain an instance of
this class. Beside that, this method contains several methods to convert mm
in inch, or vice versa. It provides a predefined set of paper types and
their sizes.
| Nested Class Summary | |
static class |
PrintUtil.BookParameter
Class PrintUtilBookParameter is used to encapsulate all the
parameters needed to specify a printout. |
| Field Summary | |
static BasePageFormat |
DEFAULT_PAGEFORMAT
The default PageFormat based on DinA4 and a Portrait orientation. |
static java.util.Map |
paperMap
Maps paper names to paper sizes. |
static java.lang.String[] |
paperTypeNames
constant list of available paper type names. |
static java.lang.Object[] |
paperTypeSizes
Constant list of sizes in mm of the predefined paper types. |
static double |
PRINT_DPI
The Java print resolution is at 72 dpi. |
| Method Summary | |
static void |
adjustBrokenMargins(BasePageFormat cpf)
This method tries to adjust the margins of a page format, which margins seem broken. |
static void |
adjustMargins(BasePageFormat aFormat)
Adjusts the margins of a PageFormat to the default margins of the original imageable size, if a certain margin is out of the imageable bounds. |
static PrintUtil.BookParameter |
calculateRowsAndColumns(BasePageFormat cpf,
double pageWidth,
double pageHeight,
Boundary bboxComposites)
The method calcuatRowsAndColumns calculates the required number of pages according to a page format, current page width and height, view's metrics. |
static boolean |
checkMargins(BasePageFormat aFormat)
This method validates the margins of the given CustomPageFormat parameter against the default
PageFormat of this paper type. |
static PrintUtil.BookParameter |
createBookParameter(BasePageFormat pageFormat,
VisualGraphView view)
Creates a BookParameter instance which describes the amount
of pages needed to print the given view with the specified page format. |
static PrintUtil.BookParameter |
createBookParameter(BasePageFormat pageFormat,
VisualGraphView view,
int dpi)
Creates a BookParameter instance which describes the amount
of pages needed to print the given view with the specified page format
using a certain resolution. |
static boolean |
differsFromDefaultMargin(BasePageFormat aFormat)
Checks whether one of the margins of the given PageFormat differs from the original default margin. |
static BasePageFormat |
getPageFormat(java.lang.String paperName,
int orientation)
Returns a PageFormat for the given Paper type, which will be validated by the PrinterJob to determine the printable area. |
static double[] |
getPaperSize(java.lang.String key)
Method getPaperSize fetches the array of double's holding the size of the given paper type and returns it, or null if no
such type has been mapped yet. |
static int |
getPaperTypeIndex(java.lang.String type)
Method getPaperTypeIndex returns the index within the paperTypeNames array of the parameter type specifier. |
static Renderer |
getRenderer(BasePageFormat cpf,
double aViewscaleX,
double aViewscaleY)
Method getRenderer returns the renderer according to the parameter PageFormat quality setting. |
static Boundary |
getViewBounds(VisualGraphView view)
Calculates the boundaries of the view that should be used for printing |
static void |
growBoundingBoxForStrokeZoom(VisualGraphView view,
Boundary bboxComposites)
This method resizes a bounding box to include the strokes that are lying on the border of the bounds. |
static double |
inch2mm(double inch)
Converts an inch value to mm. |
static double |
mm2pt(double mm)
Converts an mm value to point. |
static double |
mm2px(double mm)
This is always required when dealing with the margins of a paper. |
static double |
px2mm(double pixel)
Converts pixels to millimeter by using fixed resolution and constant mmPerInch. |
static java.lang.String |
replaceIdentifier(java.lang.String text,
int pageIndex,
int pageCount)
The method replaceIdentifier replaces all occurrences in the parameter String. |
static boolean |
validMargins(BasePageFormat aFormat)
This method simply checks whether the margins of the parameter format are greater or equal 0.0. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final double PRINT_DPI
public static final java.lang.String[] paperTypeNames
public static final java.lang.Object[] paperTypeSizes
public static final java.util.Map paperMap
public static final BasePageFormat DEFAULT_PAGEFORMAT
| Method Detail |
public static final double[] getPaperSize(java.lang.String key)
null if no
such type has been mapped yet.
key - the paper type of which you like to receive the size from.
public static final BasePageFormat getPageFormat(java.lang.String paperName,
int orientation)
paperName - the name as String of the PaperType as their are
listed in paperTypeNames.orientation - papers orientation.
PageFormat.PORTRAIT,
PageFormat.LANDSCAPEpublic static boolean validMargins(BasePageFormat aFormat)
aFormat - a format to check.
true, if all margins are greater or equal 0.0.public static void adjustBrokenMargins(BasePageFormat cpf)
cpf - the format to adjust.public static double px2mm(double pixel)
pixel - the number of pixels you like to convert to mm.
public static double mm2px(double mm)
mm - the amount of millimeter which needs to be converted to pixel.
public static double inch2mm(double inch)
inch - The distance in inch
public static double mm2pt(double mm)
mm - The distance in mm
public static final int getPaperTypeIndex(java.lang.String type)
throws java.lang.IllegalArgumentException
paperTypeNames array of the parameter type specifier.
type - the type of paper of which you like to receive the index from.
java.lang.IllegalArgumentException - thrown if the type is not found.
public static final PrintUtil.BookParameter calculateRowsAndColumns(BasePageFormat cpf,
double pageWidth,
double pageHeight,
Boundary bboxComposites)
According to the currently used scale mode the passed boundary instances are modified. When using the fit-to-page mode, both boundary instances are modified so, that they fit into the desired pages.
cpf - The PageFormat to base on.pageWidth - the pageWidthpageHeight - the pageHeightbboxComposites - the boundary (will not be modified!)
public static final PrintUtil.BookParameter createBookParameter(BasePageFormat pageFormat,
VisualGraphView view)
BookParameter instance which describes the amount
of pages needed to print the given view with the specified page format.
pageFormat - The PageFormat to create the book for,view - the view which needs to be book'ed.
PageFormat.
public static final PrintUtil.BookParameter createBookParameter(BasePageFormat pageFormat,
VisualGraphView view,
int dpi)
BookParameter instance which describes the amount
of pages needed to print the given view with the specified page format
using a certain resolution.
pageFormat - The PageFormat to create the book for,view - the view which needs to be book'ed.dpi - the dpi of the printer
PageFormat.public static final boolean checkMargins(BasePageFormat aFormat)
CustomPageFormat parameter against the default
PageFormat of this paper type. Therefore it creates a reference PageFormat
and compares the margins to each other. Is one margin of the parameter
PageFormat smaller than the margin of the reference Format,
false is returned.
aFormat - the PageFormat to check.
true if the margins of the given PageFormat still
cover the printable area of the paper.public static final boolean differsFromDefaultMargin(BasePageFormat aFormat)
aFormat - a PageFormat to check.
true, if one of the margins is !=
PrintUtil#defaultMargin.public static final void adjustMargins(BasePageFormat aFormat)
aFormat - the PageFormat which needs to be adjusted.
public static java.lang.String replaceIdentifier(java.lang.String text,
int pageIndex,
int pageCount)
text - the text to operate on.pageIndex - the current page index.pageCount - the total amount of pages.
public static final Renderer getRenderer(BasePageFormat cpf,
double aViewscaleX,
double aViewscaleY)
cpf - The page formataViewscaleX - The scale in x directionaViewscaleY - The scale in y direction
public static void growBoundingBoxForStrokeZoom(VisualGraphView view,
Boundary bboxComposites)
view - The viewbboxComposites - The bounding box to extendpublic static Boundary getViewBounds(VisualGraphView view)
view - The view to get the boundaries of
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||