Package com.openhtmltopdf.swing
Class DeferredImageReplacedElement
- java.lang.Object
-
- com.openhtmltopdf.swing.ImageReplacedElement
-
- com.openhtmltopdf.swing.DeferredImageReplacedElement
-
- All Implemented Interfaces:
ReplacedElement
public class DeferredImageReplacedElement extends ImageReplacedElement
An DeferredImageReplacedElement is aReplacedElementthat contains aImagewhich by default is simply a transparent image scaled to the size provided to the constructor. The DeferredImageReplacedElement also has a reference to an ImageResource which points to the image which will be returned for this replaced element. That Image may be loaded some time after this DeferredImageReplacedElement is created. Calling getImage() on instances of DeferredImageReplacedElement will return either the original dummy image, or the actual image loaded into the ImageResource.
-
-
Field Summary
-
Fields inherited from class com.openhtmltopdf.swing.ImageReplacedElement
_image
-
-
Constructor Summary
Constructors Constructor Description DeferredImageReplacedElement(ImageResource imageResource, RepaintListener repaintListener, int w, int h)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
Modifier and Type Method Description voiddetach(LayoutContext c)intgetBaseline()ImagegetImage()The image we're replacing.intgetIntrinsicHeight()intgetIntrinsicWidth()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
-
DeferredImageReplacedElement
public DeferredImageReplacedElement(ImageResource imageResource, RepaintListener repaintListener, int w, int h)
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:
imageResource-repaintListener-
-
-
Method Detail
-
detach
public void detach(LayoutContext c)
- Specified by:
detachin interfaceReplacedElement- Overrides:
detachin classImageReplacedElement
-
getIntrinsicHeight
public int getIntrinsicHeight()
- Specified by:
getIntrinsicHeightin interfaceReplacedElement- Overrides:
getIntrinsicHeightin classImageReplacedElement
-
getIntrinsicWidth
public int getIntrinsicWidth()
- Specified by:
getIntrinsicWidthin interfaceReplacedElement- Overrides:
getIntrinsicWidthin classImageReplacedElement
-
getLocation
public Point getLocation()
Returns the current location where the element will be rendered on the canvas- Specified by:
getLocationin interfaceReplacedElement- Overrides:
getLocationin classImageReplacedElement- Returns:
- see desc
-
isRequiresInteractivePaint
public boolean isRequiresInteractivePaint()
- Specified by:
isRequiresInteractivePaintin interfaceReplacedElement- Overrides:
isRequiresInteractivePaintin classImageReplacedElement
-
setLocation
public void setLocation(int x, int y)Assigns the new locations where the element will be rendered.- Specified by:
setLocationin interfaceReplacedElement- Overrides:
setLocationin classImageReplacedElement- Parameters:
x- new horizontal posy- new vertical pos
-
getImage
public Image getImage()
The image we're replacing.- Overrides:
getImagein classImageReplacedElement- Returns:
- see desc
-
getBaseline
public int getBaseline()
- Specified by:
getBaselinein interfaceReplacedElement- Overrides:
getBaselinein classImageReplacedElement
-
hasBaseline
public boolean hasBaseline()
- Specified by:
hasBaselinein interfaceReplacedElement- Overrides:
hasBaselinein classImageReplacedElement
-
-