Package org.xhtmlrenderer.test
Class SwingImageReplacer
java.lang.Object
org.xhtmlrenderer.test.ElementReplacer
org.xhtmlrenderer.test.SwingImageReplacer
- Author:
- patrick
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaccept(LayoutContext context, Element element) voidbooleanprotected ReplacedElementRetrieves a ReplacedElement for an image from cache, or null if not found.protected ReplacedElementnewIrreplaceableImageElement(int cssWidth, int cssHeight) Returns a ReplacedElement for some element in the stream which should be replaceable, but is not.replace(LayoutContext context, BlockBox box, UserAgentCallback uac, int cssWidth, int cssHeight) protected ReplacedElementreplaceImage(UserAgentCallback uac, LayoutContext context, Element elem, int cssWidth, int cssHeight) Handles replacement of image elements in the document.voidreset()protected voidAdds a ReplacedElement containing an image to a cache of images for quick lookup.
-
Constructor Details
-
SwingImageReplacer
public SwingImageReplacer()
-
-
Method Details
-
isElementNameMatch
public boolean isElementNameMatch()- Specified by:
isElementNameMatchin classElementReplacer
-
getElementNameMatch
- Specified by:
getElementNameMatchin classElementReplacer
-
accept
- Specified by:
acceptin classElementReplacer
-
replace
public ReplacedElement replace(LayoutContext context, BlockBox box, UserAgentCallback uac, int cssWidth, int cssHeight) - Specified by:
replacein classElementReplacer
-
clear
- Specified by:
clearin classElementReplacer
-
reset
public void reset()- Specified by:
resetin classElementReplacer
-
replaceImage
protected ReplacedElement replaceImage(UserAgentCallback uac, LayoutContext context, Element elem, int cssWidth, int cssHeight) Handles replacement of image elements in the document. May return the same ReplacedElement for a given image on multiple calls. Image will be automatically scaled to cssWidth and cssHeight assuming these are non-zero positive values. The element is assumed to have a src attribute (e.g. it's anelement)
- Parameters:
uac- Used to retrieve images on demand from some source.elem- The element with the image referencecssWidth- Target width of the imagecssHeight- Target height of the image @return A ReplacedElement for the image; will not be null.
-
storeImageReplacedElement
Adds a ReplacedElement containing an image to a cache of images for quick lookup.- Parameters:
e- The element under which the image is keyed.cc- The replaced element containing the image, or another ReplacedElement to be used in its place (like a placeholder if the image can't be loaded).
-
lookupImageReplacedElement
Retrieves a ReplacedElement for an image from cache, or null if not found.- Parameters:
e- The element by which the image is keyed- Returns:
- The ReplacedElement for the image, or null if there is none.
-
newIrreplaceableImageElement
Returns a ReplacedElement for some element in the stream which should be replaceable, but is not. This might be the case for an element like img, where the source isn't provided.- Parameters:
cssWidth- Target width for the element.cssHeight- Target height for the element- Returns:
- A ReplacedElement to substitute for one that can't be generated.
-