/* 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. */ package javax.swing.text.html; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.io.IOException; import java.io.Reader; import java.io.Serializable; import java.io.StringReader; import java.net.MalformedURLException; import java.net.URL; import java.util.Enumeration; import java.util.Vector; import javax.swing.text.AttributeSet; import javax.swing.text.Element; import javax.swing.text.MutableAttributeSet; import javax.swing.text.SimpleAttributeSet; import javax.swing.text.Style; import javax.swing.text.StyleContext; import javax.swing.text.View; /** * 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. * * @author Lillian Angel (langel@redhat.com) */ public class StyleSheet extends StyleContext { /** The base URL */ URL base; /** Base font size (int) */ int baseFontSize; /** The style sheets stored. */ StyleSheet[] styleSheet; /** * Constructs a StyleSheet. */ public StyleSheet() { super(); baseFontSize = 4; // Default font size from CSS } /** * 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. * * @param t - the tag to translate to visual attributes * @param e - the element representing the tag * @return the set of CSS attributes to use to render the tag. */ public Style getRule(HTML.Tag t, Element e) { // FIXME: Not implemented. return null; } /** * 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. * * @param selector - the element names separated by spaces * @return the set of CSS attributes to use to render */ public Style getRule(String selector) { // FIXME: Not implemented. return null; } /** * Adds a set if rules to the sheet. The rules are expected to be in valid * CSS format. This is called as a result of parsing a