public abstract class ViewFactory extends PropertySet
Modifier and Type | Class and Description |
---|---|
static class |
ViewFactory.Effect
Effect of an attribute change on the view of the element
having this attribute.
|
Modifier and Type | Field and Description |
---|---|
protected Document |
doc |
protected DocumentView |
docView |
properties
Modifier | Constructor and Description |
---|---|
protected |
ViewFactory(DocumentView documentView)
Constructs a factory for use by specified DocumentView.
|
Modifier and Type | Method and Description |
---|---|
ViewFactory.Effect |
attributeChanged(AttributeEvent event,
int viewIndex)
Invoked by the DocumentView when an element attribute has changed.
|
void |
beginRebuildView(Node node)
Invoked by the DocumentView at the beginning of rebuildView.
|
abstract TextNodeView |
createCommentView(Comment comment,
ElementView parentView)
Creates an TextNodeView for specified comment node.
|
abstract ElementView |
createElementView(Element element,
ElementView parentView)
Creates an ElementView for specified element.
|
abstract TextNodeView |
createProcessingInstructionView(ProcessingInstruction pi,
ElementView parentView)
Creates an TextNodeView for specified processing instruction node.
|
abstract TextNodeView |
createTextView(Text text,
ElementView parentView)
Creates an TextNodeView for specified text node.
|
void |
endRebuildView(Node node)
Invoked by the DocumentView at the end of rebuildView.
|
Document |
getDocument()
Returns document displayed by the DocumentView of this factory.
|
DocumentView |
getDocumentView()
Returns the DocumentView using this factory.
|
void |
setDocument(Document document)
Invoked by the DocumentView to notify this factory that specified
document is displayed.
|
boolean |
treeChanged(TreeEvent event,
int viewIndex)
Invoked by the DocumentView when the child nodes of an element have
been modified.
|
getProperties, getProperty, getPropertyCount, hasProperty, putProperties, putProperty, removeAllProperties, removeProperty
protected DocumentView docView
protected Document doc
protected ViewFactory(DocumentView documentView)
public DocumentView getDocumentView()
public void setDocument(Document document)
document
- document displayed by DocumentView; null
if DocumentView is empty.public Document getDocument()
public void beginRebuildView(Node node)
Default implementation does nothing at all.
public void endRebuildView(Node node)
Default implementation does nothing at all.
public ViewFactory.Effect attributeChanged(AttributeEvent event, int viewIndex)
This default implementation returns ViewFactory.Effect.REBUILD
.
event
- specifies the attribute changeviewIndex
- can be used to access the view of the element for
which an attribute has changed (with
event.getElementSource().getDocumentListenerData(viewIndex)
)ViewFactory.Effect.SKIP
or ViewFactory.Effect.REFRESH
or
ViewFactory.Effect.REBUILD
Node.getDocumentListenerData(int)
public boolean treeChanged(TreeEvent event, int viewIndex)
This default implementation returns false
.
This method is needed to properly support the :first-child, :last-child, :empty, etc, pseudo-classes in styled view factories.
event
- specifies which child nodes have been modifiedviewIndex
- can be used to access the view of the element in which
child nodes have changed (with
event.getElementSource().getDocumentListenerData(viewIndex)
)true
if the view of the element is to be rebuilt
from scratch; false
if suffice to update the view of the
element (e.g. add a view for a newly added child node)Node.getDocumentListenerData(int)
public abstract ElementView createElementView(Element element, ElementView parentView)
element
- element for which a view is to be createdparentView
- view of parent element; may be useful for some
factoriesStyledViewFactory
does this for
display: none)public abstract TextNodeView createTextView(Text text, ElementView parentView)
text
- text node for which a view is to be createdparentView
- view of parent element; may be useful for some
factoriespublic abstract TextNodeView createCommentView(Comment comment, ElementView parentView)
comment
- comment node for which a view is to be createdparentView
- view of parent element; may be useful for some
factoriespublic abstract TextNodeView createProcessingInstructionView(ProcessingInstruction pi, ElementView parentView)
pi
- processing instruction node for which a view is to be createdparentView
- view of parent element; may be useful for some
factories