Class ImageSize
java.lang.Object
org.apache.xmlgraphics.image.loader.ImageSize
Encapsulates the size of an image.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Calculates the size in pixels based on the size in millipoints and the resolution.void
Calculates the size in millipoints based on the size in pixels and the resolution.int
Returns the vertical position of the baseline of the image relative to the bottom of the image.Returns the size in millipoints as a Dimension object.Returns the size in points as a Dimension2D object.Returns the size in pixels as a Dimension object.double
Returns the image's horizontal resolution in dpi (dots per inch).double
Returns the image's vertical resolution in dpi (dots per inch).int
Returns the image's height in millipoints.int
Returns the image's height in pixels.int
Returns the image's width in millipoints.int
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.toString()
-
Constructor Details
-
ImageSize
public ImageSize(int widthPx, int heightPx, double dpiHorizontal, double dpiVertical) Constructor.- Parameters:
widthPx
- the width of the image in pixelsheightPx
- the height of the image in pixelsdpiHorizontal
- the horizontal resolution in dots per inchdpiVertical
- 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 pixelsheightPx
- the height of the image in pixelsdpi
- the resolution in dots per inch
-
ImageSize
public ImageSize()Default Constructor.
-
-
Method Details
-
setSizeInPixels
public void setSizeInPixels(int width, int height) Sets the image's size in pixels.- Parameters:
width
- the width in pixelsheight
- the height in pixels
-
setSizeInMillipoints
public void setSizeInMillipoints(int width, int height) Sets the image's size in millipoints.- Parameters:
width
- the width in millipointsheight
- 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 dpivertical
- 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
Returns the size in millipoints as a Dimension object.- Returns:
- the size in millipoints
-
getDimensionPt
Returns the size in points as a Dimension2D object.- Returns:
- the size in points
-
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
-