ImageSize
Date: 2016-04-28

org.apache.xmlgraphics.image.loader

## Class ImageSize

- java.lang.Object
- - org.apache.xmlgraphics.image.loader.ImageSize

-     public class ImageSize
      extends java.lang.Object

  Encapsulates the size of an image.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ImageSize()` Default Constructor.
    `ImageSize(int widthPx, int heightPx, double dpi)` Constructor.
    `ImageSize(int widthPx, int heightPx, double dpiHorizontal, double dpiVertical)` Constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `calcPixelsFromSize()` Calculates the size in pixels based on the size in millipoints and the resolution.
    `void` | `calcSizeFromPixels()` Calculates the size in millipoints based on the size in pixels and the resolution.
    `int` | `getBaselinePositionFromBottom()` Returns the vertical position of the baseline of the image relative to the bottom of the image.
    `java.awt.Dimension` | `getDimensionMpt()` Returns the size in millipoints as a Dimension object.
    `java.awt.geom.Dimension2D` | `getDimensionPt()` Returns the size in points as a Dimension2D object.
    `java.awt.Dimension` | `getDimensionPx()` Returns the size in pixels as a Dimension object.
    `double` | `getDpiHorizontal()` Returns the image's horizontal resolution in dpi (dots per inch).
    `double` | `getDpiVertical()` Returns the image's vertical resolution in dpi (dots per inch).
    `int` | `getHeightMpt()` Returns the image's height in millipoints.
    `int` | `getHeightPx()` Returns the image's height in pixels.
    `int` | `getWidthMpt()` Returns the image's width in millipoints.
    `int` | `getWidthPx()` Returns the image's width in pixels.
    `void` | `setBaselinePositionFromBottom(int distance)` Sets the vertical position of the baseline of the image relative to the bottom of the image.
    `void` | `setResolution(double resolution)` Sets the image's resolution for interpreting the pixel size.
    `void` | `setResolution(double horizontal, double vertical)` Sets the image's resolution for interpreting the pixel size.
    `void` | `setSizeInMillipoints(int width, int height)` Sets the image's size in millipoints.
    `void` | `setSizeInPixels(int width, int height)` Sets the image's size in pixels.
    `java.lang.String` | `toString()`

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

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

- - ### Constructor Detail

    - #### ImageSize

          public ImageSize(int widthPx,
                   int heightPx,
                   double dpiHorizontal,
                   double dpiVertical)

      Constructor.
      Parameters:
        `widthPx` - the width of the image in pixels
        `heightPx` - the height of the image in pixels
        `dpiHorizontal` - the horizontal resolution in dots per inch
        `dpiVertical` - the vertical resolution in dots per inch

    - #### ImageSize

          public ImageSize(int widthPx,
                   int heightPx,
                   double dpi)

      Constructor.
      Parameters:
        `widthPx` - the width of the image in pixels
        `heightPx` - the height of the image in pixels
        `dpi` - the resolution in dots per inch

    - #### ImageSize

          public ImageSize()

      Default Constructor.

  - ### Method Detail

    - #### setSizeInPixels

          public void setSizeInPixels(int width,
                             int height)

      Sets the image's size in pixels.
      Parameters:
        `width` - the width in pixels
        `height` - the height in pixels

    - #### setSizeInMillipoints

          public void setSizeInMillipoints(int width,
                                  int height)

      Sets the image's size in millipoints.
      Parameters:
        `width` - the width in millipoints
        `height` - the height in millipoints

    - #### setResolution

          public void setResolution(double horizontal,
                           double vertical)

      Sets the image's resolution for interpreting the pixel size.
      Parameters:
        `horizontal` - the horizontal resolution in dpi
        `vertical` - the vertical resolution in dpi

    - #### setResolution

          public void setResolution(double resolution)

      Sets the image's resolution for interpreting the pixel size.
      Parameters:
        `resolution` - the resolution in dpi

    - #### setBaselinePositionFromBottom

          public void setBaselinePositionFromBottom(int distance)

      Sets the vertical position of the baseline of the image relative to the bottom of the image. The default is 0mpt (i.e. the image is bottom-aligned). This is used for MathML images, for example, which have a baseline. Using the value the images can be properly aligned with other text. Most other image don't have an implicit baseline.
      Parameters:
        `distance` - the distance from the bottom of the image in millipoints

    - #### getBaselinePositionFromBottom

          public int getBaselinePositionFromBottom()

      Returns the vertical position of the baseline of the image relative to the bottom of the image. The default is 0mpt (i.e. the image is bottom-aligned). This is used for MathML images, for example, which have a baseline. Using the value the images can be properly aligned with other text. Most other image don't have an implicit baseline.
      Returns:
        the distance from the bottom of the image in millipoints

    - #### getWidthPx

          public int getWidthPx()

      Returns the image's width in pixels.
      Returns:
        the width in pixels

    - #### getHeightPx

          public int getHeightPx()

      Returns the image's height in pixels.
      Returns:
        the height in pixels

    - #### getWidthMpt

          public int getWidthMpt()

      Returns the image's width in millipoints.
      Returns:
        the width in millipoints

    - #### getHeightMpt

          public int getHeightMpt()

      Returns the image's height in millipoints.
      Returns:
        the height in millipoints

    - #### getDpiHorizontal

          public double getDpiHorizontal()

      Returns the image's horizontal resolution in dpi (dots per inch).
      Returns:
        the horizontal resolution in dpi

    - #### getDpiVertical

          public double getDpiVertical()

      Returns the image's vertical resolution in dpi (dots per inch).
      Returns:
        the vertical resolution in dpi

    - #### getDimensionMpt

          public java.awt.Dimension getDimensionMpt()

      Returns the size in millipoints as a Dimension object.
      Returns:
        the size in millipoints

    - #### getDimensionPt

          public java.awt.geom.Dimension2D getDimensionPt()

      Returns the size in points as a Dimension2D object.
      Returns:
        the size in points

    - #### getDimensionPx

          public java.awt.Dimension getDimensionPx()

      Returns the size in pixels as a Dimension object.
      Returns:
        the size in pixels

    - #### calcSizeFromPixels

          public void calcSizeFromPixels()

      Calculates the size in millipoints based on the size in pixels and the resolution.

    - #### calcPixelsFromSize

          public void calcPixelsFromSize()

      Calculates the size in pixels based on the size in millipoints and the resolution.

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`