public class PageFormat
extends java.lang.Object
PECanvas
.
This class provides a convenient way of converting b/w millimeters (ie model) coordinates and pixel coordinates. The dot-per-mm scale factor is computed from the AWT's ToolKit.
[SR:todo] adapt to fit with java.awt.print.PageFormat
.
Modifier and Type | Class and Description |
---|---|
static class |
PageFormat.Customizer
a dialog box used to change a PageFormat
|
Modifier and Type | Field and Description |
---|---|
static double |
bottomMarginMmDEFAULT |
static double |
DPMM
screen dot per mm ; used during coordinates translation from model to view.
the effect is to render 1 cm as a "true" cm (or approximately) on the screen |
static double |
heightMmDEFAULT |
static java.lang.String |
KEY_PAGE_FORMAT
key used to retrieve parameters from Properties
|
static double |
leftMarginMmDEFAULT |
static double |
widthMmDEFAULT |
Constructor and Description |
---|
PageFormat()
Construct a new PageFormat with the default values (170,100,5,5)
|
PageFormat(double widthMm,
double heightMm)
Constructor a new PageFormat with length given in mm.
|
PageFormat(double widthMm,
double heightMm,
double leftMarginMm,
double bottomMarginMm)
Construct a new PageFormat with lengths given in mm.
|
PageFormat(java.util.Properties preferences)
Construct a new PageFormat with values fetched from the given Properties :
Key = KEY_PAGE_FORMAT Value = width height leftMargin bottomMargin (separated with spaces) If some values aren't found (including Properties's default), the local default values are used. |
Modifier and Type | Method and Description |
---|---|
PageFormat.Customizer |
createCustomizer()
Return a dialog for editing this PageFormat
|
static PageFormat.Customizer |
createCustomizer(java.util.Properties preferences)
Return a dialog for editing the PageFormat's values stored in the given Properties.
|
void |
enlargeTo(java.awt.geom.Rectangle2D r)
Adjusts this PageFormat so that it is not smaller than the given rectangle (in mm)
|
void |
fitTo(java.awt.geom.Rectangle2D r)
Adjusts this PageFormat so that it fits to the given rectangle (in mm)
|
double |
getBottomMarginMm()
Return the bottom-margin in mm
|
double |
getHeightMm()
Return the page height in mm.
|
int |
getHeightPx(double zoom)
Return the page height in pixels.
|
double |
getLeftMarginMm()
Return the left-margin in mm
|
java.awt.geom.AffineTransform |
getModel2ViewTransform(double zoom)
x' = zoom * DPMM * (x + leftMarginMm)
y' = zoom * DPMM * (-y + heightMm-bottomMarginMm) Return the AffineTransform that translates from model to view coordinate using the given zoom factor and this page format (ie most notably the left and bottom margins) |
PicPoint |
getOrgPx(double zoom)
Return (x,y) double-precision pixel-coordinates of the (0,0) model origin.
|
java.awt.Dimension |
getSizePx(double zoom)
Return the page dimension (w,h) in pixels.
|
java.awt.geom.AffineTransform |
getView2ModelTransform(double zoom)
x' = zoom * DPMM * (x + leftMarginMm)
y' = zoom * DPMM * (-y + heightMm-bottomMarginMm) |
double |
getWidthMm()
Return the page width in mm.
|
int |
getWidthPx(double zoom)
Return the page width in pixels.
|
int |
getXOrgPx(double zoom)
Return the left margin in pixels, ie the x-coordinate of the (0,0) model origin.
|
int |
getYOrgPx(double zoom)
Return the y-coordinate in pixels (starting from the canvas's top-side) of the (0,0) model origin.
|
boolean |
isFitInto(java.awt.geom.Rectangle2D r)
Returns whether the given rectangle (in mm units) fits into this page.
|
void |
setBottomMarginMm(double margin)
Set the bottom margin in mm
|
void |
setHeightMm(double h)
Set the page height in mm.
|
void |
setLeftMarginMm(double margin)
Set the left margin in mm
|
void |
setMarginsMm(double left,
double bottom)
Set the page margins in mm
|
void |
setSizeMm(double w,
double h)
Sets the page size in millimeters
|
void |
setWidthMm(double w)
Set the page width in mm.
|
public static final double DPMM
public static final java.lang.String KEY_PAGE_FORMAT
public static final double widthMmDEFAULT
public static final double heightMmDEFAULT
public static final double leftMarginMmDEFAULT
public static final double bottomMarginMmDEFAULT
public PageFormat()
public PageFormat(java.util.Properties preferences)
public PageFormat(double widthMm, double heightMm, double leftMarginMm, double bottomMarginMm)
widthMm
- page width in mmheightMm
- page height in mmleftMarginMm
- left margin in mmbottomMarginMm
- bottom margin in mmpublic PageFormat(double widthMm, double heightMm)
widthMm
- page width in mmheightMm
- page height in mmpublic double getWidthMm()
public void setWidthMm(double w)
public void setHeightMm(double h)
public double getHeightMm()
public void setSizeMm(double w, double h)
public double getLeftMarginMm()
public double getBottomMarginMm()
public void setLeftMarginMm(double margin)
public void setBottomMarginMm(double margin)
public void setMarginsMm(double left, double bottom)
public boolean isFitInto(java.awt.geom.Rectangle2D r)
public void fitTo(java.awt.geom.Rectangle2D r)
public void enlargeTo(java.awt.geom.Rectangle2D r)
public int getWidthPx(double zoom)
zoom
- the current zoom factorpublic int getHeightPx(double zoom)
zoom
- the current zoom factorpublic java.awt.Dimension getSizePx(double zoom)
zoom
- the current zoom factorpublic int getXOrgPx(double zoom)
zoom
- the current zoom factorpublic int getYOrgPx(double zoom)
zoom
- the current zoom factorpublic PicPoint getOrgPx(double zoom)
zoom
- the current zoom factorpublic java.awt.geom.AffineTransform getModel2ViewTransform(double zoom)
zoom
- the current zoom factorpublic java.awt.geom.AffineTransform getView2ModelTransform(double zoom)
zoom
- the current zoom factorpublic PageFormat.Customizer createCustomizer()
public static PageFormat.Customizer createCustomizer(java.util.Properties preferences)
Submit a bug : syd@jpicedt.org