|Other Swing Changes|
Default HTML Font Is Now SerifHTML text -- including HTML text used in labels, buttons, and so on -- used to be in SansSerif font by default. As of v 1.3, the default font is Serif.
HTMLEditorKit insertAtBoundry => insertAtBoundaryA method in HTMLEditorKit.InsertHTMLTextAction, insertAtBoundry, was misspelled. It's been deprecated and insertAtBoundary has been added.
Automatic Handling of DocumentEvents
The default functionality of managing the DocumentEvent has been moved (from CompositeView) and raised from package private to public. Subclassing has been made much easier as the management of the DocumentEvent is now distributed to the protected methods:
To accomplish its behavior, the methods managing the children of the view also needed to be moved from CompositeView to View.
The following methods were added to the javax.swing.text.View:
- protected boolean updateChildren(DocumentEvent.ElementChange ec, DocumentEvent e, ViewFactory f)
- protected void forwardUpdate(DocumentEvent.ElementChange ec, DocumentEvent e, Shape a, ViewFactory f)
- protected void forwardUpdateToView(View v, DocumentEvent e, Shape a, ViewFactory f)
- protected void updateLayout(DocumentEvent.ElementChange ec, DocumentEvent e, Shape a)
- public void removeAll()
- public void remove(int i)
- public void insert(int offs, View v)
- public void append(View v)
- public void replace(int offset, int length, View views)
BoxView: Add axis property, layoutChanged MethodBoxView has an axis argument which subclasses previously could not get at. A subclass that sets it's axis based upon i18n considerations needs this as a property. The layout of the box should also be treated seperate from the requested size as in some cases (such as a table) the layout may become invalid independant of the children's preferences.
The following methods have been added to javax.swing.text.BoxView:
ParagraphView now extends FlowViewThe View protocol supports building flows, but the only previous implementation had been ParagraphView which creates relatively simple paragraph flows. The functionality can be generalized substantially to do things like shaped flows, page breaking, etc. Generalizing the functionality will make the creation of alternative flows much easier.
A new class called FlowView takes a strategy to translate the logical structure to a physical structure. The strategy is defined by a nested static class called FlowStrategy. ParagraphView extends FlowView adding just that behavior which is paragraph-specific (i.e line spacing, first line indent, alignment, etc). This change adds the following method to the javax.swing.text.View class:
FormView Localization; SUBMIT, RESET deprecatedClass
javax.swing.text.html.FormViewwas not previously localizable. There are two public static final Strings, SUBMIT and RESET, that are used to determine the text for <form> elements in an HTML document. As they are public static final they can not be localized. SUBMIT and RESET have been deprecated, the values are now obtained from the UIManager properties:
SerializationHere's a summary of the serialization related changes in the swing.text package:
javax.swing.text.html.parser.ParserDelegatornow implements Serializable.
- Added a nullary constructor to the public static innner class
HTML.Tagto allow serialization of subclasses to work.
HTML Package: Expose More of AbstractWriterAbstractWriter is used as a base class for developers wishing to provide custom writing out of a text Document. For example, HTMLWriter extends AbstractWriter, and is used in the html package to output html. The problem with AbstractWriter was that most of the methods and ivars it provided were private. Subclasses had to resort to copying numerous methods and ivars to be useful. HTMLWriter extends AbstractWriter, but ended up copying all the ivars, and overriding almost all the methods. The following changes open up the API in AbstractWriter, making it more useful by itself. This makes HTMLWriter much simpler, and it won't have to copy as much from AbstractWriter.
- public int getStartOffset()
- public int getEndOffset()
- protected Writer getWriter()
- protected int getLineLength()
- protected void setCurrentLineLength(int length)
- protected int getCurrentLineLength()
- protected boolean isLineEmpty()
- protected void setCanWrapLines(boolean newValue)
- protected boolean getCanWrapLines()
- public void setLineSeparator(String value)
- public String getLineSeparator()
- protected int getIndentLevel()
- protected void writeLineSeparator() throws IOException
- protected void write(char chars, int startIndex, int length) throws IOException
- protected void output(char content, int start, int length) throws IOException
HTML Package: Expose More CSS1 Support
The html package supports CSS 1. One of the abilities of CSS is to support cascading of style sheets (as the name implies), that is more than one style sheet can influence the presentation simultaneously. For example a browser usually has a style sheet that defines the default styles, a particular page might also have a style sheet that overrides those provided by the browser. The following methods expose this to developers, allowing them to link style sheets:
- public synchronized void addStyleSheet(StyleSheet ss)
- public synchronized void removeStyleSheet(StyleSheet ss)
- public StyleSheet getStyleSheets()
Simplify HTML InsertionsPreviously it was not very easy for developers to insert arbitrary html into an existing html document. To accomplish this, the developer needed to have an intimate knowledge of the swing text package, as well as the html package. Many developers have used dynamic html, which provides a handful of methods that make it trivial to insert html into an existing page. To accomodate these users we now expose methods that closely mirror those provided by dynamic html:
- public void setInnerHTML(Element elem, String htmlText) throws BadLocationException, IOException
- public void setOuterHTML(Element elem, String htmlText) throws BadLocationException, IOException
- public void insertAfterStart(Element elem, String htmlText) throws BadLocationException, IOException
- public void insertBeforeEnd(Element elem, String htmlText) throws BadLocationException, IOException
- public void insertBeforeStart(Element elem, String htmlText) throws BadLocationException, IOException
- public void insertAfterEnd(Element elem, String htmlText) throws BadLocationException, IOException
- public Element getElement(String id)
- public Element getElement(Element e, Object attribute, Object value)
And this is constant has been added to class HTMLEditorKit.ParserCallback:
New text Package ZoneView classProblem:
The swing text package uses View objects to represent a presentation of the document model for the sake of layout and rendering. If the model is large, the number of view objects that get created is large, in spite of only being able to view a small number of them. A View implementation is needed that defers creation of the objects until they are actually needed for display. This can be done by building zones with an estimated size that get replaced with the actual View objects when they are needed. This can substantially reduce the amount of memory used for large documents.
The following class called ZoneView supports zones that don't consume much memory until actively viewed or edited. WrappedPlainView which will become more heavyweight with its support of bidi for i18n will benefit substantially from this class by changing it's superclass from BoxView to ZoneView (which is a BoxView).
New text Package AsyncBoxView classProblem:
The swing text package uses View objects to represent a view of the document model to handle layout and rendering. Layout is done on the event handling thread like most other things. Layout is sometimes quite expensive in terms of cpu time, and causes the user interface to freeze while performing layout. The text package has some support of concurrency however, so this should be extended to include performing layout asynchronous to the gui event handling thread. A View implementation is needed that performs layout asynchronously.
To address this need, the following classes are being added to the text package. For more information visit The Swing Connection.
Add getGraphics Method to text View ClassA method is included on the javax.swing.text.View class to fetch the Graphics object that will be used to render.
|firstname.lastname@example.org. This is not a subscription list.||