34 |
this exception to your version of the library, but you are not |
this exception to your version of the library, but you are not |
35 |
obligated to do so. If you do not wish to do so, delete this |
obligated to do so. If you do not wish to do so, delete this |
36 |
exception statement from your version. */ |
exception statement from your version. */ |
37 |
|
|
38 |
package javax.swing.text.html; |
package javax.swing.text.html; |
39 |
|
|
40 |
|
import java.util.HashMap; |
41 |
|
|
42 |
/** |
/** |
43 |
* Provides CSS attributes to be used by the HTML view classes. The constants |
* Provides CSS attributes to be used by the HTML view classes. The constants |
44 |
* defined here are used as keys for text attributes for use in |
* defined here are used as keys for text attributes for use in |
48 |
*/ |
*/ |
49 |
public class CSS |
public class CSS |
50 |
{ |
{ |
51 |
|
/** |
52 |
|
* Returns an array of all CSS attributes. |
53 |
|
* |
54 |
|
* @return All available CSS.Attribute objects. |
55 |
|
*/ |
56 |
|
public static CSS.Attribute[] getAllAttributeKeys() |
57 |
|
{ |
58 |
|
Object[] src = Attribute.attributeMap.values().toArray(); |
59 |
|
CSS.Attribute[] dst = new CSS.Attribute[ src.length ]; |
60 |
|
System.arraycopy(src, 0, dst, 0, src.length); |
61 |
|
return dst; |
62 |
|
} |
63 |
|
|
64 |
|
/** |
65 |
|
* Returns an a given CSS attribute. |
66 |
|
* |
67 |
|
* @param name - The name of the attribute. |
68 |
|
* @return The CSS attribute with the given name, or <code>null</code> if |
69 |
|
* no attribute with that name exists. |
70 |
|
*/ |
71 |
|
public static CSS.Attribute getAttribute(String name) |
72 |
|
{ |
73 |
|
return (CSS.Attribute)Attribute.attributeMap.get( name ); |
74 |
|
} |
75 |
|
|
76 |
public static final class Attribute |
public static final class Attribute |
77 |
{ |
{ |
404 |
String defaultValue; |
String defaultValue; |
405 |
|
|
406 |
/** |
/** |
407 |
|
* A HashMap of all attributes. |
408 |
|
*/ |
409 |
|
static HashMap attributeMap; |
410 |
|
|
411 |
|
/** |
412 |
* Creates a new Attribute instance with the specified values. |
* Creates a new Attribute instance with the specified values. |
413 |
* |
* |
414 |
* @param attr the attribute string |
* @param attr the attribute string |
420 |
attStr = attr; |
attStr = attr; |
421 |
isInherited = inherited; |
isInherited = inherited; |
422 |
defaultValue = def; |
defaultValue = def; |
423 |
|
if( attributeMap == null) |
424 |
|
attributeMap = new HashMap(); |
425 |
|
attributeMap.put( attr, this ); |
426 |
} |
} |
427 |
|
|
428 |
/** |
/** |