Customizing Java for CSS

Before we can look at how to build GUI and functionality for font manipulation, we need to understand the way, HTML documents are handled in Java a little more.

As shown previously, text and HTML are used in a model-view-controller environment consisting of EditorKit, Document and EditorPane. However, up to Java 2 Standard Edition version 1.4 this environment supports HTML 3.2 only. Especially it does not totally support CSS elements although attributes are stored partly in CSS format already.

SimplyHTML is based on CSS for dealing with styles and font settings belong to styles so consequently, font settings are implemented using CSS as well.

Design approach

In stage 3 of SimplyHTML font manipulation is enabled for a contiguous run of characters. HTML has tag SPAN to set font attributes for a contiguous run of characters using CSS . In addition there are tags FONT, B, I etc. allowign the same without using CSS.

In SimplyHTML universal usage of CSS has been chosen because almost any part of a HTML structure can be formatted with CSS regardless of its type.

Solution approach

To show and manipulate font information for documents with SimplyHTML using CSS on character level, support for the SPAN tag has to be built into the MVC environment for HTML documents in Java.

SimplyHTML does this by extending classes HTMLDocument, HTMLDocument.HTMLReader, HTMLEditorKit and HTMLWriter accordingly, as described in the next chapters.