Class PageSpec

java.lang.Object
com.codename1.wordprocessing.PageSpec

public final class PageSpec extends Object
Immutable page geometry in points: paper size and the four margins.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final PageSpec
    ISO A4 with 0.75 inch margins.
    final float
    The bottom margin.
    final float
    The space between columns, in points.
    final int
    The number of text columns, 1 to 12.
    final float
    The paper height.
    final float
    The left margin.
    static final PageSpec
    US Letter with one inch margins.
    final float
    The right margin.
    final float
    The top margin.
    final float
    The paper width.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PageSpec(float width, float height, float top, float right, float bottom, float left)
    Creates a page.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    The width of one column.
    float
    The height between the margins.
    float
    The width between the margins.
    boolean
    Two pages are equal when their size and margins are.
    int
    A hash consistent with equals.
    A copy turned to the other orientation, margins rotating with the paper.
    withColumns(int count, float gap)
    A copy with the text set in columns.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • A4

      public static final PageSpec A4
      ISO A4 with 0.75 inch margins.
    • LETTER

      public static final PageSpec LETTER
      US Letter with one inch margins.
    • width

      public final float width
      The paper width.
    • height

      public final float height
      The paper height.
    • top

      public final float top
      The top margin.
    • bottom

      public final float bottom
      The bottom margin.
    • left

      public final float left
      The left margin.
    • columns

      public final int columns
      The number of text columns, 1 to 12.
    • columnGap

      public final float columnGap
      The space between columns, in points.
  • Constructor Details

    • PageSpec

      public PageSpec(float width, float height, float top, float right, float bottom, float left)

      Creates a page.

      Parameters
      • width: the paper width, at least one inch

      • height: the paper height, at least one inch

      • top: the top margin

      • right: the right margin

      • bottom: the bottom margin

      • left: the left margin

  • Method Details

    • withColumns

      public PageSpec withColumns(int count, float gap)

      A copy with the text set in columns.

      Parameters
      • count: 1 to 12; fewer are used when the columns would be narrower than 36 points

      • gap: the space between columns, 0 to 144 points

      Returns

      the copy

    • rotated

      public PageSpec rotated()

      A copy turned to the other orientation, margins rotating with the paper.

      Returns

      the copy

    • columnWidth

      public float columnWidth()

      The width of one column.

      Returns

      the width in points

    • contentWidth

      public float contentWidth()

      The width between the margins.

      Returns

      the text width

    • contentHeight

      public float contentHeight()

      The height between the margins.

      Returns

      the text height

    • equals

      public boolean equals(Object o)

      Two pages are equal when their size and margins are.

      Parameters
      • o: the other object
      Returns

      true when equal

      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()

      A hash consistent with equals.

      Returns

      the hash

      Overrides:
      hashCode in class Object