Class PrintDimensions


  • public final class PrintDimensions
    extends java.lang.Object
    An immutable representation of the printed size of a sheet, measured in points.
    Since:
    3.0
    Author:
    Chris Jennings
    • Constructor Summary

      Constructors 
      Constructor Description
      PrintDimensions​(double width, double height)
      Creates a new print dimensions instance with the specified width and height (in points).
      PrintDimensions​(java.awt.image.BufferedImage image, double pixelsPerInch, double finalBleedMargin, double includedBleedMargin)
      Creates a new print dimensions instance based on a source image (typically, a rendering of a Sheet).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(PrintDimensions other)
      Returns true if other represents the same printed size as this.
      boolean equals​(java.lang.Object obj)
      Returns true if obj is a print dimensions instance that represents the same printed size as this instance.
      double getHeight()
      Returns the height of the printed item, in points.
      double getHeightInUnit​(int unit)
      Returns the height of the printed item, in a specific unit.
      double getWidth()
      Returns the width of the printed item, in points.
      double getWidthInUnit​(int unit)
      Returns the width of the printed item, in a specific unit.
      int hashCode()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • PrintDimensions

        public PrintDimensions​(double width,
                               double height)
        Creates a new print dimensions instance with the specified width and height (in points).
        Parameters:
        width - the print width, in points; must be non-negative
        height - the print height, in points; must be non-negative
      • PrintDimensions

        public PrintDimensions​(java.awt.image.BufferedImage image,
                               double pixelsPerInch,
                               double finalBleedMargin,
                               double includedBleedMargin)
        Creates a new print dimensions instance based on a source image (typically, a rendering of a Sheet).
        Parameters:
        image - the image whose pixel width and height will be used
        pixelsPerInch - the image resolution, in pixels per inch
        finalBleedMargin - the size of the final desired bleed margin, measured in points
        includedBleedMargin - the size of any bleed margin already included in the image, measured in points
        Throws:
        java.lang.NullPointerException - if image is null
    • Method Detail

      • getWidth

        public double getWidth()
        Returns the width of the printed item, in points.
        Returns:
        the print width
      • getHeight

        public double getHeight()
        Returns the height of the printed item, in points.
        Returns:
        the print height
      • getWidthInUnit

        public double getWidthInUnit​(int unit)
        Returns the width of the printed item, in a specific unit.
        Parameters:
        unit - one of the Length unit constants
        Returns:
        the print width, in the requested unit
      • getHeightInUnit

        public double getHeightInUnit​(int unit)
        Returns the height of the printed item, in a specific unit.
        Parameters:
        unit - one of the Length unit constants
        Returns:
        the print height, in the requested unit
      • equals

        public boolean equals​(java.lang.Object obj)
        Returns true if obj is a print dimensions instance that represents the same printed size as this instance.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the object to compare this to
        Returns:
        true if and only if they are print dimensions of the same size, within one one hundred thousandth of a point in any dimension
      • equals

        public boolean equals​(PrintDimensions other)
        Returns true if other represents the same printed size as this.
        Parameters:
        other - the object to compare this to
        Returns:
        true if and only if they are print dimensions of the same size, within one one hundred thousandth of a point in any dimension
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object