public class MinimalHTMLWriter extends AbstractWriter
<html>
<head>
<style>
<!-- list of named styles
p.normal {
font-family: SansSerif;
margin-height: 0;
font-size: 14
}
-->
</style>
</head>
<body>
<p style=normal>
Bold, italic, and underline attributes
of the run are emitted as HTML tags.
The remaining attributes are emitted as
part of the style attribute of a <span> tag.
The syntax is similar to inline styles.
</p>
</body>
</html>
NEWLINE| Constructor and Description |
|---|
MinimalHTMLWriter(Writer
Creates a new MinimalHTMLWriter.
|
MinimalHTMLWriter(Writer
Creates a new MinimalHTMLWriter.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
endFontTag()
This is no longer used, instead <span> will be written out.
|
protected boolean |
inFontTag()
Returns true if we are currently in a <font> tag.
|
protected boolean |
isText(Element
Returns true if the element is a text element.
|
protected void |
startFontTag(String
This is no longer used, instead <span> will be written out.
|
protected void |
text(Element
Writes out text.
|
void |
write()
Generates HTML output from a StyledDocument.
|
protected void |
writeAttributes(AttributeSet
Writes out all the attributes for the following types: StyleConstants.ParagraphConstants, StyleConstants.CharacterConstants, StyleConstants.FontConstants, StyleConstants.ColorConstants.
|
protected void |
writeBody()
Iterates over the elements in the document and processes elements based on whether they are branch elements or leaf elements.
|
protected void |
writeComponent(Element
Responsible for handling Component Elements; deliberately unimplemented.
|
protected void |
writeContent(Element
Writes out the attribute set in an HTML-compliant manner.
|
protected void |
writeEndParagraph()
Emits an end tag for a <p> tag.
|
protected void |
writeEndTag(String
Writes out an end tag appropriately indented.
|
protected void |
writeHeader()
Writes out the <head> and <style> tags, and then invokes writeStyles() to write out all the named styles as the content of the <style> tag.
|
protected void |
writeHTMLTags(AttributeSet
Generates bold <b>, italic <i>, and <u> tags for the text based on its attribute settings.
|
protected void |
writeImage(Element
Responsible for handling Icon Elements; deliberately unimplemented.
|
protected void |
writeLeaf(Element
Responsible for writing out other non-text leaf elements.
|
protected void |
writeNonHTMLAttributes(AttributeSet
Writes out the remaining character-level attributes (attributes other than bold, italic, and underline) in an HTML-compliant way.
|
protected void |
writeStartParagraph(Element
Emits the start tag for a paragraph.
|
protected void |
writeStartTag(String
Writes out a start tag appropriately indented.
|
protected void |
writeStyles()
Writes out all the named styles as the content of the <style> tag.
|
decrIndent, getCanWrapLines, getCurrentLineLength, getDocument, getElementIterator, getEndOffset, getIndentLevel, getIndentSpace, getLineLength, getLineSeparator, getStartOffset, getText, getWriter, incrIndent, indent, inRange, isLineEmpty, output, setCanWrapLines, setCurrentLineLength, setIndentSpace, setLineLength, setLineSeparator, write, write, write, writeLineSeparatorpublic MinimalHTMLWriter(Writerw, StyledDocument doc)
w - Writer
doc - StyledDocument
public MinimalHTMLWriter(Writerw, StyledDocument doc, int pos, int len)
w - Writer
doc - StyledDocument
pos - The location in the document to fetch the content.
len - The amount to write out.
public void write()
throws IOException,
BadLocationException
write in class
AbstractWriter
IOException - on any I/O error
BadLocationException - if pos represents an invalid location within the document.
protected void writeAttributes(AttributeSetattr) throws IOException
writeAttributes in class
AbstractWriter
attr - an AttributeSet.
IOException - on any I/O error
protected void text(Elementelem) throws IOException , BadLocationException
text in class
AbstractWriter
elem - an Element.
IOException - on any I/O error
BadLocationException - if pos represents an invalid location within the document.
protected void writeStartTag(Stringtag) throws IOException
IOException - on any I/O error
protected void writeEndTag(StringendTag) throws IOException
IOException - on any I/O error
protected void writeHeader()
throws IOException
IOException - on any I/O error
protected void writeStyles()
throws IOException
IOException - on any I/O error
protected void writeBody()
throws IOException,
BadLocationException
IOException - on any I/O error
BadLocationException
protected void writeEndParagraph()
throws IOException
IOException - on any I/O error
protected void writeStartParagraph(Elementelem) throws IOException
IOException - on any I/O error
protected void writeLeaf(Elementelem) throws IOException
IOException - on any I/O error
protected void writeImage(Elementelem) throws IOException
elem - element of type StyleConstants.IconElementName
IOException
protected void writeComponent(Elementelem) throws IOException
IOException
protected boolean isText(Elementelem)
protected void writeContent(Elementelem, boolean needsIndenting) throws IOException , BadLocationException
IOException - on any I/O error
BadLocationException - if pos represents an invalid location within the document.
protected void writeHTMLTags(AttributeSetattr) throws IOException
IOException - on any I/O error
protected void writeNonHTMLAttributes(AttributeSetattr) throws IOException
IOException - on any I/O error
protected boolean inFontTag()
protected void endFontTag()
throws IOException
Writes out an end tag for the <font> tag.
IOException - on any I/O error
protected void startFontTag(Stringstyle) throws IOException
Writes out a start tag for the <font> tag. Because font tags cannot be nested, this method closes out any enclosing font tag before writing out a new start tag.
IOException - on any I/O error