de.caff.util.print

## Class BasicPaperFormat

- java.lang.Object
- - de.caff.util.print.BasicPaperFormat

- All Implemented Interfaces:
    PaperFormat, java.io.Serializable

      public class BasicPaperFormat
      extends java.lang.Object
      implements PaperFormat, java.io.Serializable

  This is the basic representation of a paper format with size and margin information.
  Author:
    Rammi
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `BasicPaperFormat.Orientation` Helper class for enum describing the orientation of a paper.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static BasicPaperFormat` | `A0_PAPER` A0 paper.
    `static BasicPaperFormat` | `A1_PAPER` A1 paper.
    `static BasicPaperFormat` | `A2_PAPER` A2 paper.
    `static BasicPaperFormat` | `A3_PAPER` A3 paper.
    `static BasicPaperFormat` | `A4_PAPER` A4 paper.
    `static BasicPaperFormat` | `A5_PAPER` A5 paper.
    `static LengthUnit` | `AWT_POINTS` The AWT point unit as used in the java.awt.print.Paper class.
    `static BasicPaperFormat` | `B0_PAPER` B0 paper.
    `static BasicPaperFormat` | `B1_PAPER` B1 paper.
    `static BasicPaperFormat` | `B2_PAPER` B2 paper.
    `static BasicPaperFormat` | `B3_PAPER` B3 paper.
    `static BasicPaperFormat` | `B4_PAPER` B4 paper.
    `static BasicPaperFormat` | `B5_PAPER` B5 paper.
    `static PhysicalLength` | `DEFAULT_MARGIN` The default margin size (1 cm).
    `static BasicPaperFormat` | `EXECUTIVE_PAPER` Executive format paper.
    `static BasicPaperFormat` | `LEGAL_PAPER` Legal format paper.
    `static BasicPaperFormat` | `LETTER_PAPER` Letter format paper.
    `static BasicPaperFormat.Orientation` | `ORIENTATION_LANDSCAPE` The landscape orientation.
    `static BasicPaperFormat.Orientation` | `ORIENTATION_PORTRAIT` The portrait orientation.
    `static BasicPaperFormat.Orientation` | `ORIENTATION_SEASCAPE` The seascape orientation.
    `static BasicPaperFormat.Orientation` | `ORIENTATION_UPSIDE_DOWN` The upside-down orientation.
    `static BasicPaperFormat[]` | `PAPER_FORMATS` Supported paper formats.
    `static BasicPaperFormat` | `TABLOID_PAPER` Tabloid format paper.

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `` | `BasicPaperFormat(PaperFormat pf, PhysicalLength leftMargin, PhysicalLength rightMargin, PhysicalLength topMargin, PhysicalLength bottomMargin)` Copy constructor.
    `` | `BasicPaperFormat(PhysicalLength width, PhysicalLength height, PhysicalLength margin)` Create a paper format with a uniform margin width.
    `` | `BasicPaperFormat(PhysicalLength width, PhysicalLength height, PhysicalLength leftMargin, PhysicalLength rightMargin, PhysicalLength topMargin, PhysicalLength bottomMargin)` Create a paper format with a the given margins.
    `` | `BasicPaperFormat(java.lang.String name, PaperFormat basicPaper, BasicPaperFormat.Orientation rotation)` Create a paper from another with a possible rotation.
    `protected` | `BasicPaperFormat(java.lang.String name, java.lang.String isoName, double width, double height)` Internal constructor assuming mm units and default margin used for construction of basic papers.
    `` | `BasicPaperFormat(java.lang.String name, java.lang.String isoName, PaperFormat basicPaper, BasicPaperFormat.Orientation rotation)` Create a paper from another with a possible rotation.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(java.lang.Object o)` Is this paper format equal to another format.
    `boolean` | `equalSized(PaperFormat other)` Does the other paper have the same size and margins?
    `static BasicPaperFormat` | `fromPageFormat(java.awt.print.PageFormat pageFormat)` Creat an internal paper format from a Java AWT page format.
    `static BasicPaperFormat` | `fromPaper(java.awt.print.Paper paper)` Create an internal paper format from a Java AWT paper.
    `PhysicalLength` | `getBottomMargin()` Get the bottom margin size.
    `PhysicalLength` | `getHeight()` Get the paper's height.
    `static PhysicalLength` | `getInnerHeight(PaperFormat format)` Get the height of the printable area.
    `static PhysicalLength` | `getInnerWidth(PaperFormat format)` Get the width of the printable area.
    `PhysicalLength` | `getLeftMargin()` Get the left margin size.
    `javax.print.attribute.standard.MediaPrintableArea` | `getMediaPrintableArea()` Get the printable area of the paper.
    `javax.print.attribute.standard.MediaSize` | `getMediaSize()` Get the media size.
    `java.lang.String` | `getName()` Get the name of the paper format.
    `static BasicPaperFormat` | `getPaperFormat(java.lang.String paperName)` Get the predefined paper format for a given name.
    `PhysicalLength` | `getRightMargin()` Get the right margin size.
    `PhysicalLength` | `getTopMargin()` Get the top margin size.
    `PhysicalLength` | `getWidth()` Get the paper's width.
    `int` | `hashCode()` Get a hashcode.
    `BasicPaperFormat` | `toLandScape()` Get this paper format in landscape orientation.
    `static java.awt.print.Paper` | `toPaper(PaperFormat paperFormat)` Create a Java AWT paper from an internal paper format.
    `BasicPaperFormat` | `toSeaScape()` Get this paper format in seascape orientation.
    `java.lang.String` | `toString()` Returns a string representation of the object.
    `BasicPaperFormat` | `toUpsideDown()` Get this paper format in upside down orientation.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### ORIENTATION_PORTRAIT

          public static final BasicPaperFormat.Orientation ORIENTATION_PORTRAIT

      The portrait orientation.

    - #### ORIENTATION_LANDSCAPE

          public static final BasicPaperFormat.Orientation ORIENTATION_LANDSCAPE

      The landscape orientation.

    - #### ORIENTATION_UPSIDE_DOWN

          public static final BasicPaperFormat.Orientation ORIENTATION_UPSIDE_DOWN

      The upside-down orientation.

    - #### ORIENTATION_SEASCAPE

          public static final BasicPaperFormat.Orientation ORIENTATION_SEASCAPE

      The seascape orientation.

    - #### AWT_POINTS

          public static final LengthUnit AWT_POINTS

      The AWT point unit as used in the java.awt.print.Paper class.

    - #### DEFAULT_MARGIN

          public static final PhysicalLength DEFAULT_MARGIN

      The default margin size (1 cm).

    - #### A5_PAPER

          public static final BasicPaperFormat A5_PAPER

      A5 paper.

    - #### A4_PAPER

          public static final BasicPaperFormat A4_PAPER

      A4 paper.

    - #### A3_PAPER

          public static final BasicPaperFormat A3_PAPER

      A3 paper.

    - #### A2_PAPER

          public static final BasicPaperFormat A2_PAPER

      A2 paper.

    - #### A1_PAPER

          public static final BasicPaperFormat A1_PAPER

      A1 paper.

    - #### A0_PAPER

          public static final BasicPaperFormat A0_PAPER

      A0 paper.

    - #### B5_PAPER

          public static final BasicPaperFormat B5_PAPER

      B5 paper.

    - #### B4_PAPER

          public static final BasicPaperFormat B4_PAPER

      B4 paper.

    - #### B3_PAPER

          public static final BasicPaperFormat B3_PAPER

      B3 paper.

    - #### B2_PAPER

          public static final BasicPaperFormat B2_PAPER

      B2 paper.

    - #### B1_PAPER

          public static final BasicPaperFormat B1_PAPER

      B1 paper.

    - #### B0_PAPER

          public static final BasicPaperFormat B0_PAPER

      B0 paper.

    - #### LETTER_PAPER

          public static final BasicPaperFormat LETTER_PAPER

      Letter format paper.

    - #### LEGAL_PAPER

          public static final BasicPaperFormat LEGAL_PAPER

      Legal format paper.

    - #### EXECUTIVE_PAPER

          public static final BasicPaperFormat EXECUTIVE_PAPER

      Executive format paper.

    - #### TABLOID_PAPER

          public static final BasicPaperFormat TABLOID_PAPER

      Tabloid format paper.

    - #### PAPER_FORMATS

          public static final BasicPaperFormat[] PAPER_FORMATS

      Supported paper formats.

  - ### Constructor Detail

    - #### BasicPaperFormat

          protected BasicPaperFormat(@Nullable
                                     java.lang.String name,
                                     @Nullable
                                     java.lang.String isoName,
                                     double width,
                                     double height)

      Internal constructor assuming mm units and default margin used for construction of basic papers.
      Parameters:
        `name` - paper format name
        `isoName` - ISO name as in RFC 2911
        `width` - width in mm
        `height` - height in mm

    - #### BasicPaperFormat

          public BasicPaperFormat(@Nullable
                                  java.lang.String name,
                                  @NotNull
                                  PaperFormat basicPaper,
                                  @NotNull
                                  BasicPaperFormat.Orientation rotation)

      Create a paper from another with a possible rotation. This always assumes that the basic paper is in portrait format!
      Parameters:
        `name` - name for the newly created paper
        `basicPaper` - paper from which to construct the new paper
        `rotation` - orientation to use, assuming the `basicPaper` is in portrait format

    - #### BasicPaperFormat

          public BasicPaperFormat(@Nullable
                                  java.lang.String name,
                                  @Nullable
                                  java.lang.String isoName,
                                  @NotNull
                                  PaperFormat basicPaper,
                                  @NotNull
                                  BasicPaperFormat.Orientation rotation)

      Create a paper from another with a possible rotation. This always assumes that the basic paper is in portrait format!
      Parameters:
        `name` - name for the newly created paper
        `isoName` - ISO name as in RFC 2911
        `basicPaper` - paper from which to construct the new paper
        `rotation` - orientation to use, assuming the `basicPaper` is in portrait format

    - #### BasicPaperFormat

          public BasicPaperFormat(@NotNull
                                  PhysicalLength width,
                                  @NotNull
                                  PhysicalLength height,
                                  @NotNull
                                  PhysicalLength margin)

      Create a paper format with a uniform margin width.
      Parameters:
        `width` - paper width
        `height` - paper height
        `margin` - uniform margin size

    - #### BasicPaperFormat

          public BasicPaperFormat(@NotNull
                                  PhysicalLength width,
                                  @NotNull
                                  PhysicalLength height,
                                  @NotNull
                                  PhysicalLength leftMargin,
                                  @NotNull
                                  PhysicalLength rightMargin,
                                  @NotNull
                                  PhysicalLength topMargin,
                                  @NotNull
                                  PhysicalLength bottomMargin)

      Create a paper format with a the given margins.
      Parameters:
        `width` - paper width
        `height` - paper height
        `leftMargin` - left margin width
        `rightMargin` - right margin width
        `topMargin` - top margin width
        `bottomMargin` - bottom margin width

    - #### BasicPaperFormat

          public BasicPaperFormat(@NotNull
                                  PaperFormat pf,
                                  @NotNull
                                  PhysicalLength leftMargin,
                                  @NotNull
                                  PhysicalLength rightMargin,
                                  @NotNull
                                  PhysicalLength topMargin,
                                  @NotNull
                                  PhysicalLength bottomMargin)

      Copy constructor. This copies especially the name, but allows for other margins.
      Parameters:
        `pf` - basic paper format to copy
        `leftMargin` - left margin width
        `rightMargin` - right margin width
        `topMargin` - top margin width
        `bottomMargin` - bottom margin width

  - ### Method Detail

    - #### getWidth

          @NotNull
          public PhysicalLength getWidth()

      Get the paper's width.
      Specified by:
        `getWidth` in interface `PaperFormat`
      Returns:
        width

    - #### getHeight

          @NotNull
          public PhysicalLength getHeight()

      Get the paper's height.
      Specified by:
        `getHeight` in interface `PaperFormat`
      Returns:
        height

    - #### getLeftMargin

          @NotNull
          public PhysicalLength getLeftMargin()

      Get the left margin size.
      Specified by:
        `getLeftMargin` in interface `PaperFormat`
      Returns:
        left margin size

    - #### getRightMargin

          @NotNull
          public PhysicalLength getRightMargin()

      Get the right margin size.
      Specified by:
        `getRightMargin` in interface `PaperFormat`
      Returns:
        right margin size

    - #### getTopMargin

          @NotNull
          public PhysicalLength getTopMargin()

      Get the top margin size.
      Specified by:
        `getTopMargin` in interface `PaperFormat`
      Returns:
        top margin size

    - #### getBottomMargin

          @NotNull
          public PhysicalLength getBottomMargin()

      Get the bottom margin size.
      Specified by:
        `getBottomMargin` in interface `PaperFormat`
      Returns:
        bottom margin size

    - #### getName

          @Nullable
          public java.lang.String getName()

      Get the name of the paper format. The name is only set for standard size papers.
      Specified by:
        `getName` in interface `PaperFormat`
      Returns:
        paper format name or `null`

    - #### getInnerWidth

          @NotNull
          public static PhysicalLength getInnerWidth(PaperFormat format)

      Get the width of the printable area.
      Parameters:
        `format` - paper format
      Returns:
        inner width

    - #### getInnerHeight

          @NotNull
          public static PhysicalLength getInnerHeight(PaperFormat format)

      Get the height of the printable area.
      Parameters:
        `format` - paper format
      Returns:
        inner height

    - #### toLandScape

          @NotNull
          public BasicPaperFormat toLandScape()

      Get this paper format in landscape orientation. This assumes that this paper format is in portrait orientation, and returns a rotated version of this paper.
      Returns:
        90° counterclockwise rotated version of this paper

    - #### toSeaScape

          @NotNull
          public BasicPaperFormat toSeaScape()

      Get this paper format in seascape orientation. This assumes that this paper format is in portrait orientation, and returns a rotated version of this paper.
      Returns:
        90° clockwise rotated version of this paper

    - #### toUpsideDown

          @NotNull
          public BasicPaperFormat toUpsideDown()

      Get this paper format in upside down orientation. This assumes that this paper format is in portrait orientation, and returns a rotated version of this paper.
      Returns:
        180° rotated version of this paper

    - #### equals

          public boolean equals(java.lang.Object o)

      Is this paper format equal to another format.
      Overrides:
        `equals` in class `java.lang.Object`
      Parameters:
        `o` - object to compare to

    - #### hashCode

          public int hashCode()

      Get a hashcode.
      Overrides:
        `hashCode` in class `java.lang.Object`
      Returns:
        hash code

    - #### equalSized

          public boolean equalSized(@NotNull
                                    PaperFormat other)

      Does the other paper have the same size and margins?
      Parameters:
        `other` - other paper
      Returns:
        `true` if the other paper and this paper have equal size and margins

    - #### getMediaSize

          @NotNull
          public javax.print.attribute.standard.MediaSize getMediaSize()

      Get the media size.
      Returns:
        media size

    - #### getMediaPrintableArea

          @NotNull
          public javax.print.attribute.standard.MediaPrintableArea getMediaPrintableArea()

      Get the printable area of the paper.
      Returns:
        printable area

    - #### getPaperFormat

          @Nullable
          public static BasicPaperFormat getPaperFormat(@Nullable
                                                                  java.lang.String paperName)

      Get the predefined paper format for a given name.
      Parameters:
        `paperName` - paper format name
      Returns:
        matching format or `null`

    - #### toPaper

          @NotNull
          public static java.awt.print.Paper toPaper(@NotNull
                                                              PaperFormat paperFormat)

      Create a Java AWT paper from an internal paper format.
      Parameters:
        `paperFormat` - paper format
      Returns:
        corresponding Java AWT paper

    - #### fromPaper

          @NotNull
          public static BasicPaperFormat fromPaper(@NotNull
                                                            java.awt.print.Paper paper)

      Create an internal paper format from a Java AWT paper.
      Parameters:
        `paper` - Java AWT paper
      Returns:
        corresponding paper format

    - #### fromPageFormat

          @NotNull
          public static BasicPaperFormat fromPageFormat(@NotNull
                                                                 java.awt.print.PageFormat pageFormat)

      Creat an internal paper format from a Java AWT page format.
      Parameters:
        `pageFormat` - page format
      Returns:
        corresponding paper format

    - #### toString

          public java.lang.String toString()

      Returns a string representation of the object.
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        a string representation of the object.