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

Variable Index

 o theVersion

Constructor Index

 o Document()
Create a new HTML document component.

Method Index

 o addMouseOverLinkListener(MouseOverLinkListener)
 o addPropertyChangeListener(PropertyChangeListener)
Register new PropertyChangeListener for a Document.
 o clearCache()
Clear all cached resources (applets)
 o doLayout()
 o firePropertyChange(String, Object, Object)
 o getCurrentFrame()
Get current html frame
 o getCurrentLocation()
Get current location/DocumentBase of current frame.
 o getDefaultBackground()
Get default background color.
 o getDocumentBase()
Get documentBase of current frame.
 o getDocumentBaseString()
Get documentBase property of current frame as a String.
 o getDocumentTitle()
Get current document title.
 o getEncoding()
Get default encoding.
 o getFixedFont()
Gets the base fixed font for HTML text.
 o getProportionalFont()
Gets the base proportional font for HTML text.
 o getStatusString()
Get status string.
 o getVersion()
Get ICE Browser version
 o gotoLocation(String)
Go to a location in top frame (helper method)
 o gotoLocation(String, String, String)
Go to a location in a frame (helper method)
 o gotoLocation(URL)
Go to a location in top frame (helper method)
 o htmlAppend(Reader, String)
Append HTML data of mimeType from Reader to the document in current frame.
 o htmlAppend(String)
Append HTML string to the document in current frame.
 o htmlAppend(String, String)
Append HTML data from a location to the document in current frame, sending outputString to the server.
 o htmlClear()
Clear current html frame
 o htmlInterrupt()
Interrupt parsing and loading processes in current frame.
 o htmlWait(boolean)
Wait for either parsing or parsing and loading to complete in current frame.
 o isScrollPaneMode()
Check if ScrollPane mode is enabled.
 o mouseOverLinkClicked(MouseOverLinkEvent)
Default mouseOverLinkClicked() method.
 o mouseOverLinkEntered(MouseOverLinkEvent)
Default mouseOverLinkEntered() method.
 o mouseOverLinkExited(MouseOverLinkEvent)
Default mouseOverLinkExited() method.
 o mouseOverLinkMoved(MouseOverLinkEvent)
Default mouseOverLinkMOved() method.
 o parseHTMLStream(InputStream)
Display HTML from stream in the current document. Deprecated.
 o parseHTMLString(String)
Display HTML string in the current document. Deprecated.
 o printDoc(PrintJob)
Method for printing the entire document on display.
 o processEvent(AWTEvent)
 o readExternal(ObjectInput)
The serialization facility for the Document.
 o reload()
Reload the current document.
 o removeMouseOverLinkListener(MouseOverLinkListener)
 o removePropertyChangeListener(PropertyChangeListener)
 o setCurrentFrame(String)
Set current html frame for all subsequent html operations.
 o setCurrentLocation(String)
Set the currentLocation property to display in current frame, similar to gotoLocation().
 o setDefaultBackground(Color)
Set default background color for html documents.
 o setDocumentBaseString(String)
Set DocumentBase for current frame.
 o setDocumentTitle(String)
Set current document title.
 o setEncoding(String)
Set default encoding used for html processing in this Document.
 o setFixedFont(Font)
Sets the base fixed font for HTML text.
 o setProportionalFont(Font)
Sets the base proportional font for HTML text.
 o setScrollPaneMode(boolean)
Set scrolling mode.
 o setStatusString(String)
Set status string.
 o setVersion(String)
Does not do anything.
 o writeExternal(ObjectOutput)
The serialization facility for the Document.

Variables

 o theVersion
 public static String theVersion

Constructors

 o Document
 public Document()
Create a new HTML document component.

Methods

 o getVersion
 public String getVersion()
Get ICE Browser version

Returns:
version
 o 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)

 o 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
 o getDefaultBackground
 public static Color getDefaultBackground()
Get default background color.

Returns:
default background color
 o 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
 o 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
 o 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
 o getProportionalFont
 public Font getProportionalFont()
Gets the base proportional font for HTML text.

Returns:
Proportional font used
See Also:
setProportionalFont
 o 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
 o getFixedFont
 public Font getFixedFont()
Gets the base fixed font for HTML text.

Returns:
Fixed font used
See Also:
setFixedFont
 o getDocumentTitle
 public String getDocumentTitle()
Get current document title. This returns the current documentTitle property, as previously set by setDocumentTitle(String title).

Returns:
document base
 o 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
 o getStatusString
 public String getStatusString()
Get status string.

Returns:
status string
 o 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
 o 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
 o 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
 o setCurrentFrame
 public void setCurrentFrame(String frameName)
Set current html frame for all subsequent html operations. The default is _top.

Parameters:
frameName - new current frame
 o getCurrentFrame
 public String getCurrentFrame()
Get current html frame

Returns:
name of current frame
 o 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
 o getDocumentBaseString
 public String getDocumentBaseString()
Get documentBase property of current frame as a String.

Returns:
DocumentBase
 o getDocumentBase
 public URL getDocumentBase()
Get documentBase of current frame.

Returns:
DocumentBase
 o setCurrentLocation
 public void setCurrentLocation(String loc)
Set the currentLocation property to display in current frame, similar to gotoLocation().

Parameters:
loc - new location (String)
 o getCurrentLocation
 public String getCurrentLocation()
Get current location/DocumentBase of current frame.

Returns:
DocumentBase
 o gotoLocation
 public void gotoLocation(String loc)
Go to a location in top frame (helper method)

Parameters:
loc - location to go to
 o gotoLocation
 public void gotoLocation(URL loc)
Go to a location in top frame (helper method)

Parameters:
loc - location to go to
 o 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
 o reload
 public void reload()
Reload the current document. Applets of the current document are restarted.

 o clearCache
 public void clearCache()
Clear all cached resources (applets)

 o htmlClear
 public void htmlClear()
Clear current html frame

 o 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
 o 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
 o 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.
 o 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
 o 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.

 o 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
 o 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
 o 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();
}

 o doLayout
 public void doLayout()
Overrides:
doLayout in class Container
 o processEvent
 public void processEvent(AWTEvent e)
Overrides:
processEvent in class Container
 o 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:

 o removePropertyChangeListener
 public void removePropertyChangeListener(PropertyChangeListener l)
 o firePropertyChange
 public void firePropertyChange(String name,
                                Object oldValue,
                                Object newValue)
 o 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:
  1. Create a MouseOverLinkListener
  2. remove the default listener
  3. 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());
}

 o mouseOverLinkExited
 public void mouseOverLinkExited(MouseOverLinkEvent e)
Default mouseOverLinkExited() method. Default behaviour is to set the statusString property to null.

 o mouseOverLinkMoved
 public void mouseOverLinkMoved(MouseOverLinkEvent e)
Default mouseOverLinkMOved() method. Default behaviour is a NO-OP

 o 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:

 o addMouseOverLinkListener
 public void addMouseOverLinkListener(MouseOverLinkListener l)
 o removeMouseOverLinkListener
 public void removeMouseOverLinkListener(MouseOverLinkListener l)
 o 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:

 o 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:


All Packages  Class Hierarchy  This Package  Previous  Next  Index