Package org.xhtmlrenderer.swing
Class ImageReplacedElement
- java.lang.Object
-
- org.xhtmlrenderer.swing.ImageReplacedElement
-
- All Implemented Interfaces:
ReplacedElement
public class ImageReplacedElement extends java.lang.Object implements ReplacedElement
An ImageReplacedElement is aReplacedElementthat contains aImage. It's used as a container for images included within XML being rendered. The image contained is immutable.
-
-
Constructor Summary
Constructors Constructor Description ImageReplacedElement(java.awt.Image image, int targetWidth, int targetHeight)Creates a new ImageReplacedElement and scales it to the size specified if either width or height has a valid value (values are > -1), otherwise original size is preserved.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddetach(LayoutContext c)intgetBaseline()java.awt.ImagegetImage()The image we're replacing.intgetIntrinsicHeight()intgetIntrinsicWidth()java.awt.PointgetLocation()Returns the current location where the element will be rendered on the canvasbooleanhasBaseline()booleanisRequiresInteractivePaint()voidsetLocation(int x, int y)Assigns the new locations where the element will be rendered.
-
-
-
Constructor Detail
-
ImageReplacedElement
public ImageReplacedElement(java.awt.Image image, int targetWidth, int targetHeight)Creates a new ImageReplacedElement and scales it to the size specified if either width or height has a valid value (values are > -1), otherwise original size is preserved. The idea is that the image was loaded at a certain size (that's the Image instance here) and that at the time we create the ImageReplacedElement we have a target W/H we want to use.- Parameters:
image- An image.targetWidth- The width we'd like the image to have, in pixels.targetHeight- The height we'd like the image to have, in pixels.
-
-
Method Detail
-
detach
public void detach(LayoutContext c)
- Specified by:
detachin interfaceReplacedElement
-
getIntrinsicHeight
public int getIntrinsicHeight()
- Specified by:
getIntrinsicHeightin interfaceReplacedElement
-
getIntrinsicWidth
public int getIntrinsicWidth()
- Specified by:
getIntrinsicWidthin interfaceReplacedElement
-
getLocation
public java.awt.Point getLocation()
Returns the current location where the element will be rendered on the canvas- Specified by:
getLocationin interfaceReplacedElement- Returns:
- see desc
-
isRequiresInteractivePaint
public boolean isRequiresInteractivePaint()
- Specified by:
isRequiresInteractivePaintin interfaceReplacedElement
-
setLocation
public void setLocation(int x, int y)Assigns the new locations where the element will be rendered.- Specified by:
setLocationin interfaceReplacedElement- Parameters:
x- new horizontal posy- new vertical pos
-
getImage
public java.awt.Image getImage()
The image we're replacing.- Returns:
- see desc
-
getBaseline
public int getBaseline()
- Specified by:
getBaselinein interfaceReplacedElement
-
hasBaseline
public boolean hasBaseline()
- Specified by:
hasBaselinein interfaceReplacedElement
-
-