Class ContentNormalizer
- java.lang.Object
-
- org.jfree.layouting.normalizer.content.ContentNormalizer
-
- All Implemented Interfaces:
Normalizer,StatefullComponent
public class ContentNormalizer extends java.lang.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
Nested Classes Modifier and Type Class Description protected static classContentNormalizer.ContentNormalizerState
-
Constructor Summary
Constructors Modifier Constructor Description ContentNormalizer(LayoutProcess layoutProcess)protectedContentNormalizer(LayoutProcess layoutProcess, boolean init)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddText(java.lang.String text)Adds text content to the current element.protected ContentNormalizer.ContentNormalizerStatecreateSaveState()voidendDocument()Ends the document.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()Start document is the first call to the normalizer.voidstartElement(java.lang.String namespace, java.lang.String tag, AttributeMap attributes)Starts a new element.protected voidstartElementInternal(java.lang.String namespace, java.lang.String tag, java.lang.String pseudo, AttributeMap attributes)
-
-
-
Constructor Detail
-
ContentNormalizer
public ContentNormalizer(LayoutProcess layoutProcess)
-
ContentNormalizer
protected ContentNormalizer(LayoutProcess layoutProcess, boolean init)
-
-
Method Detail
-
startDocument
public void startDocument() throws java.io.IOException, NormalizationExceptionDescription copied from interface:NormalizerStart document is the first call to the normalizer. At this point, all meta-data has been given and the document context is filled correctly. Starting the document also starts a new PageContext.- Specified by:
startDocumentin interfaceNormalizer- Throws:
java.io.IOExceptionNormalizationException
-
startElement
public void startElement(java.lang.String namespace, java.lang.String tag, AttributeMap attributes) throws NormalizationException, java.io.IOExceptionStarts 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.- Specified by:
startElementin interfaceNormalizer- Parameters:
namespace-tag-attributes-- Throws:
NormalizationExceptionjava.io.IOException
-
startElementInternal
protected void startElementInternal(java.lang.String namespace, java.lang.String tag, java.lang.String pseudo, AttributeMap attributes) throws NormalizationException, java.io.IOException- Throws:
NormalizationExceptionjava.io.IOException
-
generateBeforePseudoElements
protected boolean generateBeforePseudoElements(LayoutElement element) throws java.io.IOException, NormalizationException
- Throws:
java.io.IOExceptionNormalizationException
-
generateContentBefore
protected boolean generateContentBefore(LayoutElement element) throws java.io.IOException, NormalizationException
- Throws:
java.io.IOExceptionNormalizationException
-
generateContentAfter
protected void generateContentAfter(LayoutElement element) throws java.io.IOException, NormalizationException
- Throws:
java.io.IOExceptionNormalizationException
-
generateStrings
protected void generateStrings(LayoutElement element) throws java.io.IOException, NormalizationException
- Throws:
java.io.IOExceptionNormalizationException
-
generateAfterPseudoElements
protected void generateAfterPseudoElements(LayoutElement element) throws java.io.IOException, NormalizationException
- Throws:
java.io.IOExceptionNormalizationException
-
addText
public void addText(java.lang.String text) throws NormalizationException, java.io.IOExceptionAdds text content to the current element.- Specified by:
addTextin interfaceNormalizer- Parameters:
text-- Throws:
NormalizationExceptionjava.io.IOException
-
endElement
public void endElement() throws NormalizationException, java.io.IOExceptionEnds the current element. The namespace and tagname are given for convienience.- Specified by:
endElementin interfaceNormalizer- Throws:
NormalizationExceptionjava.io.IOException
-
endDocument
public void endDocument() throws java.io.IOException, NormalizationExceptionDescription copied from interface:NormalizerEnds the document. No other events will be fired against this normalizer once this method has been called.- Specified by:
endDocumentin interfaceNormalizer- Throws:
java.io.IOExceptionNormalizationException
-
handlePageBreak
public void handlePageBreak(CSSValue pageName, PseudoPage[] pseudoPages)
- Specified by:
handlePageBreakin interfaceNormalizer
-
createSaveState
protected ContentNormalizer.ContentNormalizerState createSaveState()
-
fillState
protected void fillState(ContentNormalizer.ContentNormalizerState state) throws StateException
- Throws:
StateException
-
saveState
public State saveState() throws StateException
- Specified by:
saveStatein interfaceStatefullComponent- Throws:
StateException
-
restore
protected void restore(ContentNormalizer.ContentNormalizerState state) throws StateException
- Throws:
StateException
-
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.- Specified by:
getRendererin interfaceNormalizer- Returns:
- the current renderer
-
getStyleResolver
public StyleResolver getStyleResolver()
-
-