All Packages Class Hierarchy This Package Previous Next Index
Class ice.htmlbrowser.Document
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----ice.htmlbrowser.Document
- public class Document
- extends Panel
- implements Externalizable, MouseOverLinkListener
Document is an HTML component. It can be used either to display
contents of a URL or to parse and render a given HTML string.
Document supports resource access from inside jar files. This
means that you can package entire file system hierarchies
inside a JAR file, and then access html and other resources as
if they were on a web site. A word of caution: the JAR loader
is currently implemented as a byte array in memory, so all jar
file resources are loaded into a hash table in memory. Large
jar files could cause memory problems.
To access resources
from a jar file use the JAM protocol, and escape the URL of the
jar file. For example:
jam://http%3a%2f%2fwww.icesoft.no%2fICEBrowser%2fResourceTest.jar/AboutDialog.txt
In the above example, the JAR file located at the URL:
http://www.icesoft.no/ICEBrowser/ResourceTest.jar
Will be downloaded. The actual resource
"AboutDialog.txt" will then be accessed directly from
that jar file.
As a shortcut you can initially specify this resource by:
http://www.icesoft.no/ICEBrowser/ResourceTest.jar#AboutDialog.txt
- Version:
- 4.01
- Author:
- Alexey Goloshubin, Jeremy Cook
-
theVersion
-
-
Document()
- Create a new HTML document component.
-
addMouseOverLinkListener(MouseOverLinkListener)
-
-
addPropertyChangeListener(PropertyChangeListener)
- Register new PropertyChangeListener for a Document.
-
clearCache()
- Clear all cached resources (applets)
-
doLayout()
-
-
firePropertyChange(String, Object, Object)
-
-
getCurrentFrame()
- Get current html frame
-
getCurrentLocation()
- Get current location/DocumentBase of current frame.
-
getDefaultBackground()
- Get default background color.
-
getDocumentBase()
- Get documentBase of current frame.
-
getDocumentBaseString()
- Get documentBase property of current frame as a String.
-
getDocumentTitle()
- Get current document title.
-
getEncoding()
- Get default encoding.
-
getFixedFont()
- Gets the base fixed font for HTML text.
-
getProportionalFont()
- Gets the base proportional font for HTML text.
-
getStatusString()
- Get status string.
-
getVersion()
- Get ICE Browser version
-
gotoLocation(String)
- Go to a location in top frame (helper method)
-
gotoLocation(String, String, String)
- Go to a location in a frame (helper method)
-
gotoLocation(URL)
- Go to a location in top frame (helper method)
-
htmlAppend(Reader, String)
- Append HTML data of mimeType from Reader to the document in current frame.
-
htmlAppend(String)
- Append HTML string to the document in current frame.
-
htmlAppend(String, String)
- Append HTML data from a location to the document in current frame, sending
outputString to the server.
-
htmlClear()
- Clear current html frame
-
htmlInterrupt()
- Interrupt parsing and loading processes in current frame.
-
htmlWait(boolean)
- Wait for either parsing or parsing and loading to complete in current frame.
-
isScrollPaneMode()
- Check if ScrollPane mode is enabled.
-
mouseOverLinkClicked(MouseOverLinkEvent)
- Default mouseOverLinkClicked() method.
-
mouseOverLinkEntered(MouseOverLinkEvent)
- Default mouseOverLinkEntered() method.
-
mouseOverLinkExited(MouseOverLinkEvent)
- Default mouseOverLinkExited() method.
-
mouseOverLinkMoved(MouseOverLinkEvent)
- Default mouseOverLinkMOved() method.
-
parseHTMLStream(InputStream)
- Display HTML from stream in the current document.
Deprecated.
-
parseHTMLString(String)
- Display HTML string in the current document.
Deprecated.
-
printDoc(PrintJob)
- Method for printing the entire document on display.
-
processEvent(AWTEvent)
-
-
readExternal(ObjectInput)
- The serialization facility for the Document.
-
reload()
- Reload the current document.
-
removeMouseOverLinkListener(MouseOverLinkListener)
-
-
removePropertyChangeListener(PropertyChangeListener)
-
-
setCurrentFrame(String)
- Set current html frame for all subsequent html operations.
-
setCurrentLocation(String)
-
Set the currentLocation property
to display in current frame, similar to gotoLocation().
-
setDefaultBackground(Color)
- Set default background color for html documents.
-
setDocumentBaseString(String)
- Set DocumentBase for current frame.
-
setDocumentTitle(String)
- Set current document title.
-
setEncoding(String)
- Set default encoding used for html processing in this Document.
-
setFixedFont(Font)
- Sets the base fixed font for HTML text.
-
setProportionalFont(Font)
- Sets the base proportional font for HTML text.
-
setScrollPaneMode(boolean)
- Set scrolling mode.
-
setStatusString(String)
- Set status string.
-
setVersion(String)
- Does not do anything.
-
writeExternal(ObjectOutput)
- The serialization facility for the Document.
theVersion
public static String theVersion
Document
public Document()
- Create a new HTML document component.
getVersion
public String getVersion()
- Get ICE Browser version
- Returns:
- version
setVersion
public void setVersion(String str)
- Does not do anything. This is a dummy to implement the version
property as read-only (read-only propertes do not show in some IDE's)
setDefaultBackground
public static void setDefaultBackground(Color bg)
- Set default background color for html documents.
Use this method to change what colour will be used
as the background of each HTML document if the document
does not specify a colour. The default value is white.
- Parameters:
- bg - default background color
getDefaultBackground
public static Color getDefaultBackground()
- Get default background color.
- Returns:
- default background color
setScrollPaneMode
public void setScrollPaneMode(boolean flag)
- Set scrolling mode.
The Document class can use either proprietary (very rapid) scrolling
pane or it can use the AWT ScrollPane class. The ScrollPane class
is quite buggy (especially on large documents), but it can scroll
embedded applets without blinking. The proprietary scrolling
panel cannot scroll embedded applets without blinking.
The default is to use proprietary scrolling (flag=false).
- Parameters:
- flag - true - use ScrollPane, false - use proprietory scrolling
- See Also:
- isScrollPaneMode
isScrollPaneMode
public boolean isScrollPaneMode()
- Check if ScrollPane mode is enabled.
- Returns:
- true if ScrollPane is used, false if proprietory scrolling is used
- See Also:
- setScrollPaneMode
setProportionalFont
public void setProportionalFont(Font font)
- Sets the base proportional font for HTML text.
When the method is called, 6 other document fonts are automatically
initialised, 3 larger and 3 smaller than the base font. Bold and
italic fonts are also initialised.
- Parameters:
- font - Proportional font to use
- See Also:
- getProportionalFont
getProportionalFont
public Font getProportionalFont()
- Gets the base proportional font for HTML text.
- Returns:
- Proportional font used
- See Also:
- setProportionalFont
setFixedFont
public void setFixedFont(Font font)
- Sets the base fixed font for HTML text.
When the method is called, 6 other document fonts are automatically
initialised, 3 larger and 3 smaller than the base font. Bold and
italic fonts are also initialised.
- Parameters:
- font - Fixed font to use
- See Also:
- getFixedFont
getFixedFont
public Font getFixedFont()
- Gets the base fixed font for HTML text.
- Returns:
- Fixed font used
- See Also:
- setFixedFont
getDocumentTitle
public String getDocumentTitle()
- Get current document title.
This returns the current documentTitle property, as previously
set by setDocumentTitle(String title).
- Returns:
- document base
setDocumentTitle
public void setDocumentTitle(String title)
- Set current document title.
This method is called by Document when the HTML document
changes. The default title is the URL of the document, but
if the HTML document specifies its own title in
a <TITLE>...</TITLE> tag then this
will be set as the title. Property change listeners that
are registered with this Document will be notified when this
property changes.
- Parameters:
- title - document title
- See Also:
- getDocumentTitle, addPropertyChangeListener
getStatusString
public String getStatusString()
- Get status string.
- Returns:
- status string
setStatusString
public void setStatusString(String str)
- Set status string. The status property is set by the Document
when the mouse is over a link
and by Applets. ICE Browser users can create their own
status indicators and update them when this property changes.
Property change listeners that
are registered with this Document will be notified when this
property changes.
- Parameters:
- str - status string
- See Also:
- addPropertyChangeListener, showStatus
setEncoding
public void setEncoding(String enc)
- Set default encoding used for html processing in this Document.
The default encoding is controlled by the user's LOCALE setting.
Documents can specify their own encoding using the HTTP_EQUIV
Attribute of the META tag. HTTP protocol can also specify the encoding.
If your local installation supports it you can view other
languages using the correct encoding for that language. The Document
class will automagically switch the encoding to that specified in the
document or by HTTP. In some cases, the author will not have specified
the encoding. This can be handled by manually specifying the encoding
through the encoding property.
- Parameters:
- enc - new default encoding
- See Also:
- getEncoding
getEncoding
public String getEncoding()
- Get default encoding.
The default encoding is controlled by the user's LOCALE setting.
Documents can specify their own encoding using the HTTP_EQUIV
Attribute of the META tag. HTTP protocol can also specify the encoding.
If your local installation supports it you can view other
languages using the correct encoding for that language. The Document
class will automagically switch the encoding to that specified in the
document or by HTTP. In some cases, the author will not have specified
the encoding. This can be handled by manually specifying the encoding
through the encoding property.
- Returns:
- default encoding
- See Also:
- setEncoding
setCurrentFrame
public void setCurrentFrame(String frameName)
- Set current html frame for all subsequent html operations.
The default is _top.
- Parameters:
- frameName - new current frame
getCurrentFrame
public String getCurrentFrame()
- Get current html frame
- Returns:
- name of current frame
setDocumentBaseString
public void setDocumentBaseString(String base) throws MalformedURLException
- Set DocumentBase for current frame.
If you are generating html text on the fly and
want it to be able to find resources in a directory,
this is the method to use. You might be including
relative URL's in your document. All relative URL's are
relative to the documentBase property. Documents originating
from internal sources will need to set a DocumentBase for
relative URL's to work.
- Parameters:
- base - new DocumentBase
- See Also:
- htmlAppend, htmlAppend
getDocumentBaseString
public String getDocumentBaseString()
- Get documentBase property of current frame as a String.
- Returns:
- DocumentBase
getDocumentBase
public URL getDocumentBase()
- Get documentBase of current frame.
- Returns:
- DocumentBase
setCurrentLocation
public void setCurrentLocation(String loc)
- Set the currentLocation property
to display in current frame, similar to gotoLocation().
- Parameters:
- loc - new location (String)
getCurrentLocation
public String getCurrentLocation()
- Get current location/DocumentBase of current frame.
- Returns:
- DocumentBase
gotoLocation
public void gotoLocation(String loc)
- Go to a location in top frame (helper method)
- Parameters:
- loc - location to go to
gotoLocation
public void gotoLocation(URL loc)
- Go to a location in top frame (helper method)
- Parameters:
- loc - location to go to
gotoLocation
public void gotoLocation(String loc,
String targetFrame,
String outputString)
- Go to a location in a frame (helper method)
- Parameters:
- loc - location to go to
- targetFrame - frame to display the text into
- outputString - data to send to http server
reload
public void reload()
- Reload the current document. Applets of the
current document are restarted.
clearCache
public void clearCache()
- Clear all cached resources (applets)
htmlClear
public void htmlClear()
- Clear current html frame
htmlAppend
public void htmlAppend(String str)
- Append HTML string to the document in current frame.
This method is used to generate HTML from another source or
internally in your application. If you are using htmlAppend()
multiple times it is important to call htmlWait(boolean) before each subsequent call to htmlAppend(). This will
wait until the rendering thread has caught up with all current
rendering operations.
- Parameters:
- str - HTML string to append
- See Also:
- htmlWait
htmlAppend
public void htmlAppend(Reader reader,
String mimeType)
- Append HTML data of mimeType from Reader to the document in current frame.
This method is used to generate HTML from another source or
internally in your application. If you are using htmlAppend()
multiple times it is important to call
htmlWait(boolean) before each subsequent call to htmlAppend(). This will
wait until the rendering thread has caught up with all current
rendering operations.
- Parameters:
- reader - Reader to append
- mimeType - mime type of the data
- See Also:
- htmlWait
htmlAppend
public void htmlAppend(String loc,
String outputString)
- Append HTML data from a location to the document in current frame, sending
outputString to the server.
- Parameters:
- loc - location to go to
- outputString - output string to send to the server for POST operations.
htmlWait
public void htmlWait(boolean all)
- Wait for either parsing or parsing and loading to complete in current frame.
If you plan to append multiple html sources to the same frame, you must
use this method with false parameter to avoid
overwriting previous html contents.
- Parameters:
- all - false - just wait for parsing, true - wait for parsing and image loading
htmlInterrupt
public void htmlInterrupt()
- Interrupt parsing and loading processes in current frame.
Use this method when you want to stop all current loaing, parsing and
rendering operations.
parseHTMLString
public void parseHTMLString(String str)
- Note: parseHTMLString() is deprecated.
Replaced by htmlAppend(String)
- Display HTML string in the current document. This is
a convenience function which does htmlClear().. htmlAppend(str).
- Parameters:
- str - HTML string to display
- See Also:
- htmlClear, htmlAppend
parseHTMLStream
public void parseHTMLStream(InputStream stream)
- Note: parseHTMLStream() is deprecated.
Replaced by htmlAppend(Reader, String)
- Display HTML from stream in the current document. This is
a convenience function which does htmlClear().. htmlAppend(stream).
- Parameters:
- stream - InputStream of HTML to display
- See Also:
- htmlClear, htmlAppend
printDoc
public void printDoc(PrintJob pj)
- Method for printing the entire document on display.
The best way to use this method is to create a PrintJob
and pass it as a parameter to printDoc(). For
example:
Document doc = new Document("http://your url");
myPanel.add(doc);
PrintJob pj = getToolkit().getPrintJob(this, "ICE Browser", null);
if (pj != null) {
doc.printDoc(pj);
pj.end();
}
doLayout
public void doLayout()
- Overrides:
- doLayout in class Container
processEvent
public void processEvent(AWTEvent e)
- Overrides:
- processEvent in class Container
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener l)
- Register new PropertyChangeListener for a Document.
A number of properties can be monitored for changes
in a Document by adding your own PropertyChangeListener.
The properties monitored are:
- statusString
- documentTitle
- currentFrame
- currentLocation
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener l)
firePropertyChange
public void firePropertyChange(String name,
Object oldValue,
Object newValue)
mouseOverLinkEntered
public void mouseOverLinkEntered(MouseOverLinkEvent e)
- Default mouseOverLinkEntered() method. Default behaviour
is to set the statusString property to the name of the link.
public void mouseOverLinkEntered(MouseOverLinkEvent e) {
setStatusString(e.getLink());
}
To completely override Document behaviour when the mouse
is over a link, do the following:
- Create a MouseOverLinkListener
- remove the default listener
- add your own listener
for example:
Browser ib = new Browser();
ib.removeMouseOverLinkListener(ib);
ib.addMouseOverLinkListener(yourListener);
Note that the above is also valid for the Document class.
The default MouseOverLinkListener implementation in Document is (you should have
something similar):
public void mouseOverLinkEntered(MouseOverLinkEvent e) {
setStatusString(e.getLink());
}
public void mouseOverLinkExited(MouseOverLinkEvent e) {
setStatusString("");
}
public void mouseOverLinkMoved(MouseOverLinkEvent e) {}
public void mouseOverLinkClicked(MouseOverLinkEvent e) {
gotoLocation(e.getLink(),e.getTargetFrame(),e.getOutputString());
}
mouseOverLinkExited
public void mouseOverLinkExited(MouseOverLinkEvent e)
- Default mouseOverLinkExited() method. Default behaviour
is to set the statusString property to null.
mouseOverLinkMoved
public void mouseOverLinkMoved(MouseOverLinkEvent e)
- Default mouseOverLinkMOved() method. Default behaviour
is a NO-OP
mouseOverLinkClicked
public void mouseOverLinkClicked(MouseOverLinkEvent e)
- Default mouseOverLinkClicked() method. Default behaviour
is to set currentLocation property to the location
specified by the link.
To completely override Document behaviour when the mouse
is over a link, do the following:
addMouseOverLinkListener
public void addMouseOverLinkListener(MouseOverLinkListener l)
removeMouseOverLinkListener
public void removeMouseOverLinkListener(MouseOverLinkListener l)
writeExternal
public void writeExternal(ObjectOutput out)
- The serialization facility for the Document.
This method is called when any class tries to serialize
a Document class.
The properties that are serialized are:
- documentBaseString
- size
- name
readExternal
public void readExternal(ObjectInput in)
- The serialization facility for the Document.
This method is called when any class tries to deserialize
a Document class.
The properties that are serialized are:
- documentBaseString
- size
- name
All Packages Class Hierarchy This Package Previous Next Index