Class ImageSize


  • public class ImageSize
    extends Object
    Encapsulates the size of an image.
    • 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 Dimension getDimensionMpt()
        Returns the size in millipoints as a Dimension object.
        Returns:
        the size in millipoints
      • getDimensionPt

        public Dimension2D getDimensionPt()
        Returns the size in points as a Dimension2D object.
        Returns:
        the size in points
      • getDimensionPx

        public 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.