Package org.xhtmlrenderer.swing
Class ImageReplacedElement
java.lang.Object
org.xhtmlrenderer.swing.ImageReplacedElement
- All Implemented Interfaces:
ReplacedElement
- Direct Known Subclasses:
DeferredImageReplacedElement
An ImageReplacedElement is a
ReplacedElement
that contains a Image
. It's used as a
container for images included within XML being rendered. The image contained is immutable.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ImageReplacedElement
(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 greater than -1), otherwise original size is preserved. -
Method Summary
Modifier and TypeMethodDescriptionvoid
int
getImage()
The image we're replacingint
int
Returns the current location where the element will be rendered on the canvasboolean
boolean
void
setLocation
(int x, int y) Assigns the new locations where the element will be rendered.
-
Field Details
-
_image
-
_location
-
-
Constructor Details
-
ImageReplacedElement
protected ImageReplacedElement() -
ImageReplacedElement
Creates a new ImageReplacedElement and scales it to the size specified if either width or height has a valid value (values are greater than -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 Details
-
detach
- Specified by:
detach
in interfaceReplacedElement
-
getIntrinsicHeight
public int getIntrinsicHeight()- Specified by:
getIntrinsicHeight
in interfaceReplacedElement
-
getIntrinsicWidth
public int getIntrinsicWidth()- Specified by:
getIntrinsicWidth
in interfaceReplacedElement
-
getLocation
Description copied from interface:ReplacedElement
Returns the current location where the element will be rendered on the canvas- Specified by:
getLocation
in interfaceReplacedElement
-
isRequiresInteractivePaint
public boolean isRequiresInteractivePaint()- Specified by:
isRequiresInteractivePaint
in interfaceReplacedElement
-
setLocation
public void setLocation(int x, int y) Description copied from interface:ReplacedElement
Assigns the new locations where the element will be rendered.- Specified by:
setLocation
in interfaceReplacedElement
- Parameters:
x
- new horizontal positiony
- new vertical position
-
getImage
The image we're replacing -
getBaseline
public int getBaseline()- Specified by:
getBaseline
in interfaceReplacedElement
-
hasBaseline
public boolean hasBaseline()- Specified by:
hasBaseline
in interfaceReplacedElement
-