Class Resolution

java.lang.Object
com.levigo.jadice.document.Resolution

public class Resolution extends Object
A resolution specifies a point density in two dimensions (horizontal, vertical) relative to a certain measurement unit. Please note that this class is immutable, i.e. it is safe to pass around instances of it without cloning.
  • Field Details

    • BASE_RESOLUTION

      public static final Resolution BASE_RESOLUTION
      The jadice base resolution of 1/7200'th of an inch.
    • POINTS

      public static final Resolution POINTS
      Points: 1/72'th of an inch (72 DPI).
    • DPI72

      public static final Resolution DPI72
      72 DPI (the same resolution as POINTS but with a different base unit).
    • DPI96

      public static final Resolution DPI96
      96 DPI.
  • Constructor Details

    • Resolution

      public Resolution()
      Create the default base resolution.
      See Also:
    • Resolution

      public Resolution(float horizontal, float vertical)
      Create a new resolution using dots per inch.
      Parameters:
      horizontal -
      vertical -
      See Also:
    • Resolution

      public Resolution(float w, float h, Unit u)
    • Resolution

      public Resolution(Dimension2D d, Unit u)
    • Resolution

      public Resolution(float r)
      Create a uniform resolution (one being identical in both horizontally and vertically) based on a unit of dots per inch.
      Parameters:
      r -
  • Method Details

    • assertComponentsValid

      protected void assertComponentsValid()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getUnit

      public Unit getUnit()
    • convertTo

      public Resolution convertTo(Unit u)
    • getSize

      public Dimension2D getSize(Dimension2D size)
      Return the physical size of a grid of the given size with this resolution. The returned size will use the same unit as the resolution base unit.
      Parameters:
      size -
      Returns:
      the physical size
      Throws:
      NullPointerException - if the given size parameter is null
    • getSize

      public Dimension2D getSize(Dimension2D size, Unit u)
      Return the physical size of a grid of the given size with this resolution. The returned size will use the same unit as the resolution base unit.
      Parameters:
      size -
      Returns:
      the physical size
    • getX

      public float getX()
      Return the horizontal resolution.
      Returns:
      the horizontal resolution component
    • getY

      public float getY()
      Return the vertical resolution.
      Returns:
      the vertical resolution component
    • getMax

      public float getMax()
      Return the maximum of the two resolution components.
      Returns:
      the maximum resolution
    • getMin

      public float getMin()
      Return the minimum of the two resolution components.
      Returns:
      the minimum resolution
    • isHomogenous

      public boolean isHomogenous()
      Return whether the resolution is homogeneous, i.e. identical in both directions.
      Returns:
      true if both components are equal.
    • createBaseTransform

      public AffineTransform createBaseTransform(Dimension2D size)
      Create an AffineTransform scaling the unit square with this resolution to the given size at base units.
      Parameters:
      size -
      Returns:
      a scaling AffineTransform
      See Also:
    • createTransform

      public AffineTransform createTransform(Resolution r)
    • createTransform

      public AffineTransform createTransform(Dimension2D size, Unit u)
      Create an AffineTransform scaling the unit square with this resolution to the given size at the given resolution.
      Parameters:
      size -
      u -
      Returns:
      a scaling AffineTransform
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • scale

      Augment the given transform so that it scale the unit square with this resolution to the given target resolution. Please note: the given AffineTransform is modified in place.
      Parameters:
      t - the transform to augment
      r - the target resolution
      Returns:
      the scaled transformation