EECS 382 Assignment 3
Due: Thursday, October 28th
- This assignment is to introduce you to java Graphics, Font and Stack for
applications as well as applets.
- The following skeleton code is given as
hcat.java. In order to run this
Applet as a a standalone application, type: "java hcat"
and it will display the default html text. Typing:
java hcat 'html=hello, <b>EECS<bb>382'
will pass the parameter html to the hcat application.
The quotes allow special characters and spaces to be passed with
the argument in the typical shell command line.
- To run as an applet, the appletviewer hcat.html can
be used with the addition of using hcat.html.
This contains html to execute the applet within a web page. Parameters
are passed using the html PARAM tag. This also runs through your browser
with JVM installed on the browser.
- After running hcat as an application and as an applet, take some
time to read through the code and understand it.
- First enhance the html state machine getTokenType() so that tags follow the
HTML standard as described in
here.
For example, tags are case insensitive.
- getTokenType() should handle the case for quoted attributes,
(i.e. name="hello, world");
- getTokenType() should handle the special characters &...; and should
handle only the 4 common character cases
(i.e. < > & ") and return blank for all others.
- getTokenType() should handle end-tag cases.
- Move the html parser into another function, so that paint(g) calls this paintHtml(g).
- The parser should handle the following tags (including their respective end-tags):
<!-- comments -->
<BR> <P>
<B> </B>
<I> </I>
<HR>
<SUB> </SUB>
<TT> </TT>
<FONT COLOR=colorname> </FONT>
<FONT FACE="name"> </FONT>
<FONT POINT-SIZE=number> </FONT>
- Ignore all the text in between the <head> ... the </head>.
Also, ignore all other tags but still show the text following the tags
- Font and color tags should handle nesting.
<FONT COLOR=red>red text
<FONT COLOR=blue>blue text
</FONT>red again</FONT>
- This assignment will require careful manipulation of the stack for handling fonts
and sub-scripting.
Use the instanceof to distinguish items on the stack. <Sub> scripting requires you
to push the current y coordinate of the font baseline. </sub> requires you to
restore the original baseline. As the baseline shifts, you must keep
track of the maximum descent of the initial baseline at the beginning of the line.
- Use google and the Sun online documentation for information on these classes:
Stack |
Graphics |
Color |
Font |
FontMetrics |
- Submit as a standalone eecs382_a3_emailaddress.jar which uses the standard
J2EE project layout, typical builds as well as three test cases.