This class adds support for defining the visual characteristics of HTML views
being rendered. This enables views to be customized by a look-and-feel, mulitple
views over the same model can be rendered differently. Each EditorPane has its
own StyleSheet, but by default one sheet will be shared by all of the HTMLEditorKit
instances. An HTMLDocument can also have a StyleSheet, which holds specific CSS
specs.
In order for Views to store less state and therefore be more lightweight,
the StyleSheet can act as a factory for painters that handle some of the
rendering tasks. Since the StyleSheet may be used by views over multiple
documents the HTML attributes don't effect the selector being used.
The rules are stored as named styles, and other information is stored to
translate the context of an element to a rule.
Adds an attribute to the given set and returns a new set. This is implemented
to convert StyleConstants attributes to CSS before forwarding them to the superclass.
The StyleConstants attribute do not have corresponding CSS entry, the attribute
is stored (but will likely not be used).
Adds a set of attributes to the element. If any of these attributes are
StyleConstants, they will be converted to CSS before forwarding to the
superclass.
Adds a CSS attribute to the given set.
This method parses the value argument from HTML based on key.
Returns true if it finds a valid value for the given key,
and false otherwise.
Adds the rules from ss to those of the receiver. ss's rules will
override the old rules. An added StyleSheet will never override the rules
of the receiving style sheet.
Creates a large set of attributes. This set is not shared. This is a hook
for subclasses that want to change the behaviour of the larger attribute
storage format.
Gets the rule that best matches the selector. selector is a space
separated String of element names. The attributes of the returned
Style will change as rules are added and removed.
Parameters:
selector - - the element names separated by spaces
Gets the style used to render the given tag. The element represents the tag
and can be used to determine the nesting, where the attributes will differ
if there is nesting inside of elements.
Parameters:
t - - the tag to translate to visual attributes
e - - the element representing the tag
Returns:
the set of CSS attributes to use to render the tag.
Loads a set of rules that have been specified in terms of CSS grammar.
If there are any conflicts with existing rules, the new rule is added.
Parameters:
in - - the stream to read the CSS grammar from.
ref - - the reference URL. It is the location of the stream, it may
be null. All relative URLs specified in the stream will be based upon this
parameter.
Removes a set of attributes for the element. If any of the attributes is a
StyleConstants, they will be converted to CSS before forwarding to the
superclass.
Sets the base font size from the String. It can either identify
a specific font size (between 1 and 7) or identify a relative
font size such as +1 or -2.
Converts a set of HTML attributes to an equivalent set of CSS attributes.
Parameters:
htmlAttrSet - - the set containing the HTML attributes.
Returns:
the set of CSS attributes
StyleSheet.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.