Class HtmlCanvas

java.lang.Object
  |
  +--com.nttdocomo.ui.Frame
        |
        +--com.nttdocomo.ui.Canvas
              |
              +--HtmlCanvas
All Implemented Interfaces:
com.nttdocomo.ui.ComponentListener, com.nttdocomo.util.EventListener, com.nttdocomo.ui.KeyListener, com.nttdocomo.ui.SoftKeyListener

public class HtmlCanvas
extends com.nttdocomo.ui.Canvas
implements com.nttdocomo.ui.SoftKeyListener, com.nttdocomo.ui.KeyListener, com.nttdocomo.ui.ComponentListener

The PicoBrower is a tiny HTML browser for the NTT DoCoMo Java iAppli phones.

It is designed to support display and browsing of documents containing a minimal subset of HTML.

The purpose of this module is not so much general web browsing, which can be done using the microbrowser in the phones, but rather the ability to display documents within a Java IApplication.

The problem is that the NTT platform framework has no integration between the phone's microbrowser and it's Java VM, so there appears to be no easy way to give your Java applet the ability to display HTML output.

HTML documents are a wonderful way to display information to users, and to provide interaction, via clicking on hyperlinks or submitting forms. Ideally the Java application could call out to display HTML on the phone's microbrowser, and the phone could submit data back to the application. In essence, the application would be a servlet engine. The NTT platform API designers have not yet taken this useful step, however. So the current design dicates that if we want HTML browsing capability from out application, that we write a browser in Java.

Unfortunately, the current size limit of 10kbytes for an IApplication force the PicoBrowser to have a very bare-bones set of capabilities.

The PicoBrower supports the following HTML tags. Note that there are some restrictions on the syntax, as document below. Note also that we are aiming at compatibility with XHTML BASIC (the subset of XHTML proposed for mobile devices) at some point in the future. But you don't need to close your P tags.

Element TagAction
BRLinebreak
PParagraph break
B, STRONGBold font
A HREF="URL" A hyperlink. The URL value must be enclosed within double quotes. The URL may be an absolute URL, such as "http://www.foo.com/bar.html", or it may be a relative URL, such as "foo.html". Relative URLs will be resolved with respect to the current document's base URL.

The HREF value may also be a local application resource, such as "resource:///foo.gif".

Because the code for deducing the base URL is quite stupid, if you want to use relative URLs within your HTML document, you must specify the target URL of the page as a full path and filename, such as "http://foo.com/index.html".

This is because the algorithm used to compute the base URL is simply to find the last '/' in the target URL and to strip off everything after it.

PRE Preformat text region. Whitespace is preserved, and fixed width font is used.
FONT COLOR="#rrggbb" You may specify a font color, using the hex RGB values. Double quotes are required around the value.
IMG SRC="URL" An inline image. The URL value must be contained in double quotes. URL may be a absolute or relative URL. You may also refer to a local resource of the form "resource:///foo.gif".
CENTERDisplay text centered on the screen
I, EM Italic font. Bold-Italic may be specified by nesting the I and B tags, like <B><I>This is bold italic</I></B>.
Entities Supported entities: &amp;, &lt; &gt; &quot; &#ddd; &NBSP;

The PicoBrowser does not support forms embedded in HTML documents.

Key Bindings

The PicoBrowser application has the following key bindings:

UP, DOWNPrev, Next page/hyperlink
LEFTBack (previous URL)
SELECTFetch selected hyperlink
RIGHTunused
SOFT1Scroll to prev page
SOFT2Scroll to next page
1Smooth Scroll down
2Home (fetches resource:///index.html)
3Smooth Scroll up
*Enter New URL from keyboard
#Exit Application
The PicoBrowser could be pared down to even smaller footprint by removing pieces of code that you don't need. For example, if you only need to render HTML, and don't need a full browser, you could get rid of the Panel UI for allowing users to enter new URLs in a TextBox.


Fields inherited from class com.nttdocomo.ui.Frame
a, b, c, d, f, g, h, i, j, k, l, SOFT_KEY_1, SOFT_KEY_2, SOFT_KEY_3
 
Fields inherited from interface com.nttdocomo.ui.ComponentListener
BUTTON_PRESSED, SELECTION_CHANGED, TEXT_CHANGED
 
Constructor Summary
HtmlCanvas()
           
 
Method Summary
 void componentAction(com.nttdocomo.ui.Component source, int type, int param)
           
 void keyPressed(com.nttdocomo.ui.Panel p, int key)
           
 void keyReleased(com.nttdocomo.ui.Panel p, int key)
           
 void paint(com.nttdocomo.ui.Graphics g)
          Redisplay the current page.
 void processEvent(int nType, int nParm)
          Handle a keypad event
 void setText(java.lang.String text)
          Set the HTML text of the current page.
 void setURL(java.lang.String url)
          Tell browser to load data from URL.
 void softKeyPressed(int key)
           
 void softKeyReleased(int key)
           
 
Methods inherited from class com.nttdocomo.ui.Canvas
a, getGraphics, getKeypadState, repaint, repaint
 
Methods inherited from class com.nttdocomo.ui.Frame
a, a, b, f, getHeight, getWidth, setBackground, setSoftLabel
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HtmlCanvas

public HtmlCanvas()
Method Detail

setURL

public void setURL(java.lang.String url)
Tell browser to load data from URL. Valid protocols are "http://", "resource:///" and "local://" for servlets.

setText

public void setText(java.lang.String text)
Set the HTML text of the current page. This will parse the HTML into HtmlItem objects, and assign them layout positions on a virtual page.

paint

public void paint(com.nttdocomo.ui.Graphics g)
Redisplay the current page. Highlights any selected element which is visible on the current page.
Overrides:
paint in class com.nttdocomo.ui.Canvas

processEvent

public void processEvent(int nType,
                         int nParm)
Handle a keypad event
Overrides:
processEvent in class com.nttdocomo.ui.Canvas

softKeyPressed

public void softKeyPressed(int key)
Specified by:
softKeyPressed in interface com.nttdocomo.ui.SoftKeyListener

softKeyReleased

public void softKeyReleased(int key)
Specified by:
softKeyReleased in interface com.nttdocomo.ui.SoftKeyListener

keyPressed

public void keyPressed(com.nttdocomo.ui.Panel p,
                       int key)
Specified by:
keyPressed in interface com.nttdocomo.ui.KeyListener

keyReleased

public void keyReleased(com.nttdocomo.ui.Panel p,
                        int key)
Specified by:
keyReleased in interface com.nttdocomo.ui.KeyListener

componentAction

public void componentAction(com.nttdocomo.ui.Component source,
                            int type,
                            int param)
Specified by:
componentAction in interface com.nttdocomo.ui.ComponentListener