APIdia Launch Partner
Top Description Fields Constructors Methods
javafx.print

public final Class PageLayout

extends Object
Class Inheritance
Static Imports
javafx.print.PageOrientation.*

A PageLayout encapsulates the information needed to lay out content. The reported width and height can be considered equivalent to the clip enforced by a Window. Applications that obtain a PageLayout instance will need to inspect the width and height to perform layout and pagination. Other information such as orientation and the Paper being used and margins outside of this area are not needed for page rendering.

Printers usually have hardware margins where they cannot print. A PageLayout instance obtained from a PrinterJob in the context of a specific printer will be correctly set up to print over the whole of that area. If an application adjusts the printable area outside of this bounds, rendering to those areas will be clipped by the device.

Within those hardware margins, the application may define any printable area it needs. The resulting printable area will define the effective dimensions of the page available to the application at printing time.

Applying a PageLayout configured based on one printer, to a job on a different printer may not work correctly, as the second printer may not support the same margins, and may not even support the same Paper. In such a case, the PageLayout must be validated against the new printer.

A PageLayout is immutable.

Since
JavaFX 8.0

Field Summary

Modifier and TypeField and Description
private double
private double
private PageOrientation
private Paper
private double
private double

Constructor Summary

AccessConstructor and Description
pack-priv
PageLayout(Paper
the paper to use
paper
,
PageOrientation
orientation of the layout
orient
)

Create a PageLayout using the specified Paper size and orientation.

pack-priv
PageLayout(Paper
the paper to use
paper
,
PageOrientation
orientation of the layout
orient
,
double
the left margin in points.
leftMargin
,
double
the left margin in points.
rightMargin
,
double
the top margin in points.
topMargin
,
double
the bottom margin in points.
bottomMargin
)

Note that the margins are to be specified as applying after the rotation due to the orientation.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object o)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public double

Returns:

bottom margin in points.
getBottomMargin
()

Returns the bottom margin of the page layout in points.

public double

Returns:

left margin in points.
getLeftMargin
()

Returns the left margin of the page layout in points.

public PageOrientation

Returns:

the PageOrientation
getPageOrientation
()

Gets the PageOrientation.

public Paper

Returns:

the Paper used for this PageLayout.
getPaper
()

The paper used.

public double

Returns:

printable height in points.
getPrintableHeight
()

Returns the height dimension of the printable area of the page, in 1/72 of an inch, taking into account the orientation.

public double

Returns:

printable width in points.
getPrintableWidth
()

Returns the width dimension of the printable area of the page, in 1/72 of an inch points, taking into account the orientation.

public double

Returns:

right margin in points.
getRightMargin
()

Returns the right margin of the page layout in points.

public double

Returns:

top margin in points.
getTopMargin
()

Returns the top margin of the page layout in points.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

bMarginback to summary
private double bMargin
lMarginback to summary
private double lMargin
orientback to summary
private PageOrientation orient
paperback to summary
private Paper paper
rMarginback to summary
private double rMargin
tMarginback to summary
private double tMargin

Constructor Detail

PageLayoutback to summary
pack-priv PageLayout(Paper paper, PageOrientation orient)

Create a PageLayout using the specified Paper size and orientation. Default margins are 0.75 inch which is 56 points. If the paper dimension is smaller than this, the margins will be reduced.

Parameters
paper:Paper

the paper to use

orient:PageOrientation

orientation of the layout

Exceptions
IllegalArgumentException:
if paper or orient is null.
PageLayoutback to summary
pack-priv PageLayout(Paper paper, PageOrientation orient, double leftMargin, double rightMargin, double topMargin, double bottomMargin)

Note that the margins are to be specified as applying after the rotation due to the orientation. Thus the left margin always defines the x origin of the printable area, and the top margin always defines its y origin.

Parameters
paper:Paper

the paper to use

orient:PageOrientation

orientation of the layout

leftMargin:double

the left margin in points.

rightMargin:double

the left margin in points.

topMargin:double

the top margin in points.

bottomMargin:double

the bottom margin in points.

Exceptions
IllegalArgumentException:
if the margins exceed the corresponding paper dimension, or are negative, or if paper or orient is null.

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
getBottomMarginback to summary
public double getBottomMargin()

Returns the bottom margin of the page layout in points. This value is in the orientation of the PageLayout.

Returns:double

bottom margin in points.

getLeftMarginback to summary
public double getLeftMargin()

Returns the left margin of the page layout in points. This value is in the orientation of the PageLayout.

Returns:double

left margin in points.

getPageOrientationback to summary
public PageOrientation getPageOrientation()

Gets the PageOrientation.

Returns:PageOrientation

the PageOrientation

getPaperback to summary
public Paper getPaper()

The paper used.

Returns:Paper

the Paper used for this PageLayout.

getPrintableHeightback to summary
public double getPrintableHeight()

Returns the height dimension of the printable area of the page, in 1/72 of an inch, taking into account the orientation.

The printable area is width or height reduced by the requested margins on each side. If the requested margins are smaller than the the hardware margins, rendering may be clipped by the device.

Since the returned value accounts for orientation, this means if if the orientation is LANDSCAPE or REVERSE_LANDSCAPE, then the top and bottom margins are subtracted from the height of the underlying paper, since it is rotated 90 degrees.

Returns:double

printable height in points.

getPrintableWidthback to summary
public double getPrintableWidth()

Returns the width dimension of the printable area of the page, in 1/72 of an inch points, taking into account the orientation.

The printable area is width or height reduced by the requested margins on each side. If the requested margins are smaller than the the hardware margins, rendering may be clipped by the device.

Since the returned value accounts for orientation, this means if if the orientation is LANDSCAPE or REVERSE_LANDSCAPE, then the left and right margins are subtracted from the height of the underlying paper, since it is rotated 90 degrees.

Returns:double

printable width in points.

getRightMarginback to summary
public double getRightMargin()

Returns the right margin of the page layout in points. This value is in the orientation of the PageLayout.

Returns:double

right margin in points.

getTopMarginback to summary
public double getTopMargin()

Returns the top margin of the page layout in points. This value is in the orientation of the PageLayout.

Returns:double

top margin in points.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override