public class HTMLProcessor extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
CELL_HEAD_TAG |
static String |
CELL_TAG |
protected String |
code |
static boolean |
DEBUG |
protected HTMLDocument |
document |
protected HTMLEditorKit |
editor |
static String |
END_CELL_HEAD_TAG |
static String |
END_CELL_TAG |
static String |
END_ROW_TAG |
static String |
END_TABLE_TAG |
protected String |
footId |
protected String |
headId |
static String |
ROW_TAG |
static String |
TABLE_TAG |
protected JTextPane |
textPane |
| Constructor and Description |
|---|
HTMLProcessor(String htmlCode,
URL base)
Creates a processor class using the html code
|
HTMLProcessor(URL fileURL)
Builds a new processor using the html file with the specified URL
|
HTMLProcessor(URL fileURL,
URL base)
Builds a new processor using the file with the specified URL
|
| Modifier and Type | Method and Description |
|---|---|
void |
advancedPrint(PageFormat pf,
int height) |
HTMLDocument |
getDocument()
Get the document used for this processor to can use it in a text panel
|
HTMLEditorKit |
getEditorKit()
Get the EditorKit used for this processor to can use it in a text panel
|
String |
getHTML() |
JTextPane |
getJTextPane()
Get a JTextPanel with the current document text The processor save a
reference to the returned panel
|
Printable |
getPrintable(PageFormat pf,
int height) |
String |
insertTable(String text,
Hashtable tableValues) |
String |
insertTable(String text,
Hashtable tableValues,
Vector sortColumns)
Insert a table using its values, replacing in the html code the key word
text with the table HTML equivalence. |
void |
print(PageFormat pf,
int height) |
void |
replaceTextInHTML(String text,
byte[] imageBytes,
int width,
int height)
Replace the
text in the html code with the image represented
by the bytes array. |
void |
replaceTextInHTML(String text,
String newText)
Replaces the
text in the string HTML with the
newTextThis replaces the code in the same html code and this method must be used carefully. |
void |
reset()
Undo all the changes in the html code and set the original value again
|
void |
setFoot(String id)
Fixes the element with attribute
id as footer in the
template for all the pages.If the element has children the children will
be in the footer too. |
void |
setHead(String id)
Fixes the element with attribute
id as header in the
template for all the pages. |
Vector |
toPages(PageFormat pageFormat)
Gets a vector of JTextPane with the document separated by pages with the
specified page format.
|
void |
updateTextPane()
Update the values of the JTextPane with the last changes in the HTML
|
public static final boolean DEBUG
public static final String TABLE_TAG
public static final String ROW_TAG
public static final String CELL_HEAD_TAG
public static final String CELL_TAG
public static final String END_ROW_TAG
public static final String END_CELL_HEAD_TAG
public static final String END_CELL_TAG
public static final String END_TABLE_TAG
protected String code
protected HTMLDocument document
protected HTMLEditorKit editor
protected JTextPane textPane
protected String headId
protected String footId
public HTMLProcessor(String htmlCode, URL base) throws Exception
htmlCode - base - Exceptionpublic HTMLProcessor(URL fileURL, URL base) throws Exception
fileURL - base - Exceptionpublic void replaceTextInHTML(String text, String newText)
text in the string HTML with the
newTexttext - Text to replacenewText - New text to setpublic void replaceTextInHTML(String text, byte[] imageBytes, int width, int height)
text in the html code with the image represented
by the bytes array.width or height are 0 then the image size
will be the realtext - imageBytes - width - height - public HTMLEditorKit getEditorKit()
public HTMLDocument getDocument()
public String getHTML()
public JTextPane getJTextPane()
public void updateTextPane()
public void reset()
throws Exception
Exceptionpublic String insertTable(String text, Hashtable tableValues, Vector sortColumns)
text with the table HTML equivalence.text - tableValues - The keys of this hashtable are the names of the table columns
and the values are vectors whit the column values. If some of
these values are hashtables then they are new tables in the
appropriate cell.sortColumns - This vector contains the name of the table columns in the
order to put them in the table. These columns must be the keys
of the tableValues hashtablepublic Vector toPages(PageFormat pageFormat)
pageFormat - public void print(PageFormat pf, int height)
public void setHead(String id)
id as header in the
template for all the pages. If the element has children the children will
be in the header too.id - public void setFoot(String id)
id as footer in the
template for all the pages.If the element has children the children will
be in the footer too.id - public void advancedPrint(PageFormat pf, int height)
pf - Page format to use in the printing methodheight - Height in pixels from the text pane of this processorpublic Printable getPrintable(PageFormat pf, int height)
Copyright © 2016 Imatia Innovation S.L.. All rights reserved.