public class SwingReplacedElementFactory extends Object implements ReplacedElementFactory
| Modifier and Type | Field and Description |
|---|---|
protected LinkedHashMap |
forms
Cache of XhtmlForms keyed by Element.
|
protected Map |
imageComponents
Cache of image components (ReplacedElements) for quick lookup, keyed by Element.
|
protected RepaintListener |
repaintListener |
| Constructor and Description |
|---|
SwingReplacedElementFactory() |
SwingReplacedElementFactory(RepaintListener repaintListener) |
SwingReplacedElementFactory(RepaintListener listener,
ImageResourceLoader irl) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addForm(Element e,
XhtmlForm f)
Adds a form to a local cache for quick lookup.
|
ReplacedElement |
createReplacedElement(LayoutContext context,
BlockBox box,
UserAgentCallback uac,
int cssWidth,
int cssHeight)
NOTE: Only block equivalent elements can be replaced.
|
protected XhtmlForm |
getForm(Element e)
Returns the XhtmlForm associated with an Element in cache, or null if not found.
|
protected Element |
getParentForm(Element e,
LayoutContext context) |
protected ReplacedElement |
lookupImageReplacedElement(Element e,
String uri)
Retrieves a ReplacedElement for an image from cache, or null if not found.
|
protected ReplacedElement |
newIrreplaceableImageElement(int cssWidth,
int cssHeight)
Returns a ReplacedElement for some element in the stream which should be replaceable, but is not.
|
void |
remove(Element e)
Removes any reference to
Element e. |
protected ReplacedElement |
replaceImage(UserAgentCallback uac,
LayoutContext context,
Element elem,
int cssWidth,
int cssHeight)
Handles replacement of image elements in the document.
|
void |
reset()
Clears out any references to elements or items created by this factory so far.
|
void |
setFormSubmissionListener(FormSubmissionListener fsl)
Identifies the FSL which will be used for callbacks when a form submit action is executed; you can use a
DefaultFormSubmissionListener if you don't want any action to be taken. |
protected void |
storeImageReplacedElement(Element e,
ReplacedElement cc,
String uri,
int cssWidth,
int cssHeight)
Adds a ReplacedElement containing an image to a cache of images for quick lookup.
|
protected Map imageComponents
protected LinkedHashMap forms
protected final RepaintListener repaintListener
public SwingReplacedElementFactory()
public SwingReplacedElementFactory(RepaintListener repaintListener)
public SwingReplacedElementFactory(RepaintListener listener, ImageResourceLoader irl)
public ReplacedElement createReplacedElement(LayoutContext context, BlockBox box, UserAgentCallback uac, int cssWidth, int cssHeight)
createReplacedElement in interface ReplacedElementFactorycssWidth - The CSS width of the element in dots (or -1 if
width is auto)cssHeight - The CSS height of the element in dots (or -1
if the height should be treated as auto)ReplacedElement or null if no
ReplacedElement appliesprotected ReplacedElement replaceImage(UserAgentCallback uac, LayoutContext context, Element elem, int cssWidth, int cssHeight)
uac - Used to retrieve images on demand from some source.context - 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.protected ReplacedElement newIrreplaceableImageElement(int cssWidth, int cssHeight)
cssWidth - Target width for the element.cssHeight - Target height for the elementprotected void storeImageReplacedElement(Element e, ReplacedElement cc, String uri, int cssWidth, int cssHeight)
e - The element under which the image is keyed.cc - The replaced element containing the image, or another ReplacedElement to be used in its placeuri - cssWidth - cssHeight - protected ReplacedElement lookupImageReplacedElement(Element e, String uri)
e - The element by which the image is keyeduri - protected void addForm(Element e, XhtmlForm f)
e - The element under which the form is keyed (e.g. "f - The form element being stored.protected XhtmlForm getForm(Element e)
e - The Element to which the form is keyedprotected Element getParentForm(Element e, LayoutContext context)
e - public void reset()
reset in interface ReplacedElementFactorypublic void remove(Element e)
ReplacedElementFactoryElement e.remove in interface ReplacedElementFactorypublic void setFormSubmissionListener(FormSubmissionListener fsl)
ReplacedElementFactoryDefaultFormSubmissionListener if you don't want any action to be taken.setFormSubmissionListener in interface ReplacedElementFactoryfsl - the listener instance to receive callbacks on form submission.Copyright © 2021. All rights reserved.