Class ImageSize
- java.lang.Object
-
- org.apache.xmlgraphics.image.loader.ImageSize
-
public class ImageSize extends java.lang.ObjectEncapsulates the size of an image.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcalcPixelsFromSize()Calculates the size in pixels based on the size in millipoints and the resolution.voidcalcSizeFromPixels()Calculates the size in millipoints based on the size in pixels and the resolution.intgetBaselinePositionFromBottom()Returns the vertical position of the baseline of the image relative to the bottom of the image.java.awt.DimensiongetDimensionMpt()Returns the size in millipoints as a Dimension object.java.awt.geom.Dimension2DgetDimensionPt()Returns the size in points as a Dimension2D object.java.awt.DimensiongetDimensionPx()Returns the size in pixels as a Dimension object.doublegetDpiHorizontal()Returns the image's horizontal resolution in dpi (dots per inch).doublegetDpiVertical()Returns the image's vertical resolution in dpi (dots per inch).intgetHeightMpt()Returns the image's height in millipoints.intgetHeightPx()Returns the image's height in pixels.intgetWidthMpt()Returns the image's width in millipoints.intgetWidthPx()Returns the image's width in pixels.voidsetBaselinePositionFromBottom(int distance)Sets the vertical position of the baseline of the image relative to the bottom of the image.voidsetResolution(double resolution)Sets the image's resolution for interpreting the pixel size.voidsetResolution(double horizontal, double vertical)Sets the image's resolution for interpreting the pixel size.voidsetSizeInMillipoints(int width, int height)Sets the image's size in millipoints.voidsetSizeInPixels(int width, int height)Sets the image's size in pixels.java.lang.StringtoString()
-
-
-
Constructor Detail
-
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 Detail
-
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
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:
toStringin classjava.lang.Object
-
-