org.jfree.layouting.normalizer.content

Class ContentNormalizer

public class ContentNormalizer extends Object implements Normalizer

This class is responsible for normalizing content from the 'content' style property and for hiding content that has 'display:none' set. The ContentNormalizer also resolves all styles for elements.

Pagebreaks are determined in the model-builder or the layouter. A pagebreak is only activated if it affects a line-box; the normalizer has no information about lineboxes and therefore cannot perform any pagebreak computation at all.

Todo: Content that has been ignored because there was no 'content:contents' definition for it, should have this content moved into the '::alternate' pseudo-element. This one can be used to build footnotes and other fancy stuff.

More todo: Quote-Level cannot be resolved, until the content has been processed by the renderer. The Quote-Tokens need to be passed down to the renderer unchanged; they need the defined quotes for the current element when being printed.

The language is currently unresolved. It needs to be takes from the parent context or the xml:lang attribute. Resolving the language using stylesheets does not work, as there is a language-matching rule which depends on that value.

Todo: DisplayNone does not remove the element from the document tree. Quote:

The element is not rendered. The rendering is the same as if the element had been removed from the document tree, except for possible effects on counters (see [generated] or [paged]).

[generated]: An element that is not displayed ('display' set to 'none') cannot increment or reset a counter.

Note that :before and :after pseudo elements of this element are also not rendered, see [generated].)

Author: Thomas Morgner

Nested Class Summary
protected static classContentNormalizer.ContentNormalizerState
Constructor Summary
ContentNormalizer(LayoutProcess layoutProcess)
protected ContentNormalizer(LayoutProcess layoutProcess, boolean init)
Method Summary
voidaddText(String text)
Adds text content to the current element.
protected ContentNormalizer.ContentNormalizerStatecreateSaveState()
voidendDocument()
voidendElement()
Ends the current element.
protected voidfillState(ContentNormalizer.ContentNormalizerState state)
protected voidgenerateAfterPseudoElements(LayoutElement element)
protected booleangenerateBeforePseudoElements(LayoutElement element)
protected voidgenerateContentAfter(LayoutElement element)
protected booleangenerateContentBefore(LayoutElement element)
protected voidgenerateStrings(LayoutElement element)
RenderergetRenderer()
Returns the renderer.
StyleResolvergetStyleResolver()
voidhandlePageBreak(CSSValue pageName, PseudoPage[] pseudoPages)
protected voidrestore(ContentNormalizer.ContentNormalizerState state)
StatesaveState()
voidstartDocument()
voidstartElement(String namespace, String tag, AttributeMap attributes)
Starts a new element.
protected voidstartElementInternal(String namespace, String tag, String pseudo, AttributeMap attributes)

Constructor Detail

ContentNormalizer

public ContentNormalizer(LayoutProcess layoutProcess)

ContentNormalizer

protected ContentNormalizer(LayoutProcess layoutProcess, boolean init)

Method Detail

addText

public void addText(String text)
Adds text content to the current element.

Parameters: text

Throws: NormalizationException IOException

createSaveState

protected ContentNormalizer.ContentNormalizerState createSaveState()

endDocument

public void endDocument()

endElement

public void endElement()
Ends the current element. The namespace and tagname are given for convienience.

Throws: NormalizationException IOException

fillState

protected void fillState(ContentNormalizer.ContentNormalizerState state)

generateAfterPseudoElements

protected void generateAfterPseudoElements(LayoutElement element)

generateBeforePseudoElements

protected boolean generateBeforePseudoElements(LayoutElement element)

generateContentAfter

protected void generateContentAfter(LayoutElement element)

generateContentBefore

protected boolean generateContentBefore(LayoutElement element)

generateStrings

protected void generateStrings(LayoutElement element)

getRenderer

public Renderer getRenderer()
Returns the renderer. The renderer is the last step in the processing chain. The ModelBuilder and ContentGenerator steps are considered internal, as they may refeed the normalizer.

Returns: the current renderer

getStyleResolver

public StyleResolver getStyleResolver()

handlePageBreak

public void handlePageBreak(CSSValue pageName, PseudoPage[] pseudoPages)

restore

protected void restore(ContentNormalizer.ContentNormalizerState state)

saveState

public State saveState()

startDocument

public void startDocument()

startElement

public void startElement(String namespace, String tag, AttributeMap attributes)
Starts a new element. The element uses the given namespace and tagname. The element's attributes are given as collection, each attribute is keyed with a namespace and attributename. The values contained in the attributes are not defined.

Parameters: namespace tag attributes

Throws: NormalizationException IOException

startElementInternal

protected void startElementInternal(String namespace, String tag, String pseudo, AttributeMap attributes)