1. /*
  2. * @(#)StyleConstants.java 1.34 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.swing.text;
  8. import java.awt.Color;
  9. import java.awt.Component;
  10. import java.awt.Toolkit;
  11. import javax.swing.Icon;
  12. /**
  13. * <p>
  14. * A collection of <em>well known</em> or common attribute keys
  15. * and methods to apply to an AttributeSet or MutableAttributeSet
  16. * to get/set the properties in a typesafe manner.
  17. * <p>
  18. * The paragraph attributes form the definition of a paragraph to be rendered.
  19. * All sizes are specified in points (such as found in postscript), a
  20. * device independent measure.
  21. * </p>
  22. * <p align=center><img src="doc-files/paragraph.gif"
  23. * alt="Diagram shows SpaceAbove, FirstLineIndent, LeftIndent, RightIndent,
  24. * and SpaceBelow a paragraph."></p>
  25. * <p>
  26. *
  27. * @author Timothy Prinzing
  28. * @version 1.34 01/23/03
  29. */
  30. public class StyleConstants {
  31. /**
  32. * Name of elements used to represent components.
  33. */
  34. public static final String ComponentElementName = "component";
  35. /**
  36. * Name of elements used to represent icons.
  37. */
  38. public static final String IconElementName = "icon";
  39. /**
  40. * Attribute name used to name the collection of
  41. * attributes.
  42. */
  43. public static final Object NameAttribute = new StyleConstants("name");
  44. /**
  45. * Attribute name used to identifiy the resolving parent
  46. * set of attributes, if one is defined.
  47. */
  48. public static final Object ResolveAttribute = new StyleConstants("resolver");
  49. /**
  50. * Attribute used to identify the model for embedded
  51. * objects that have a model view separation.
  52. */
  53. public static final Object ModelAttribute = new StyleConstants("model");
  54. /**
  55. * Returns the string representation.
  56. *
  57. * @return the string
  58. */
  59. public String toString() {
  60. return representation;
  61. }
  62. // ---- character constants -----------------------------------
  63. /**
  64. * Bidirectional level of a character as assigned by the Unicode bidi
  65. * algorithm.
  66. */
  67. public static final Object BidiLevel = CharacterConstants.BidiLevel;
  68. /**
  69. * Name of the font family.
  70. */
  71. public static final Object FontFamily = CharacterConstants.Family;
  72. /**
  73. * Name of the font size.
  74. */
  75. public static final Object FontSize = CharacterConstants.Size;
  76. /**
  77. * Name of the bold attribute.
  78. */
  79. public static final Object Bold = CharacterConstants.Bold;
  80. /**
  81. * Name of the italic attribute.
  82. */
  83. public static final Object Italic = CharacterConstants.Italic;
  84. /**
  85. * Name of the underline attribute.
  86. */
  87. public static final Object Underline = CharacterConstants.Underline;
  88. /**
  89. * Name of the Strikethrough attribute.
  90. */
  91. public static final Object StrikeThrough = CharacterConstants.StrikeThrough;
  92. /**
  93. * Name of the Superscript attribute.
  94. */
  95. public static final Object Superscript = CharacterConstants.Superscript;
  96. /**
  97. * Name of the Subscript attribute.
  98. */
  99. public static final Object Subscript = CharacterConstants.Subscript;
  100. /**
  101. * Name of the foreground color attribute.
  102. */
  103. public static final Object Foreground = CharacterConstants.Foreground;
  104. /**
  105. * Name of the background color attribute.
  106. */
  107. public static final Object Background = CharacterConstants.Background;
  108. /**
  109. * Name of the component attribute.
  110. */
  111. public static final Object ComponentAttribute = CharacterConstants.ComponentAttribute;
  112. /**
  113. * Name of the icon attribute.
  114. */
  115. public static final Object IconAttribute = CharacterConstants.IconAttribute;
  116. /**
  117. * Name of the input method composed text attribute. The value of
  118. * this attribute is an instance of AttributedString which represents
  119. * the composed text.
  120. */
  121. public static final Object ComposedTextAttribute = new StyleConstants("composed text");
  122. /**
  123. * The amount of space to indent the first
  124. * line of the paragraph. This value may be negative
  125. * to offset in the reverse direction. The type
  126. * is Float and specifies the size of the space
  127. * in points.
  128. */
  129. public static final Object FirstLineIndent = ParagraphConstants.FirstLineIndent;
  130. /**
  131. * The amount to indent the left side
  132. * of the paragraph.
  133. * Type is float and specifies the size in points.
  134. */
  135. public static final Object LeftIndent = ParagraphConstants.LeftIndent;
  136. /**
  137. * The amount to indent the right side
  138. * of the paragraph.
  139. * Type is float and specifies the size in points.
  140. */
  141. public static final Object RightIndent = ParagraphConstants.RightIndent;
  142. /**
  143. * The amount of space between lines
  144. * of the paragraph.
  145. * Type is float and specifies the size as a factor of the line height
  146. */
  147. public static final Object LineSpacing = ParagraphConstants.LineSpacing;
  148. /**
  149. * The amount of space above the paragraph.
  150. * Type is float and specifies the size in points.
  151. */
  152. public static final Object SpaceAbove = ParagraphConstants.SpaceAbove;
  153. /**
  154. * The amount of space below the paragraph.
  155. * Type is float and specifies the size in points.
  156. */
  157. public static final Object SpaceBelow = ParagraphConstants.SpaceBelow;
  158. /**
  159. * Alignment for the paragraph. The type is
  160. * Integer. Valid values are:
  161. * <ul>
  162. * <li>ALIGN_LEFT
  163. * <li>ALIGN_RIGHT
  164. * <li>ALIGN_CENTER
  165. * <li>ALIGN_JUSTIFED
  166. * </ul>
  167. *
  168. */
  169. public static final Object Alignment = ParagraphConstants.Alignment;
  170. /**
  171. * TabSet for the paragraph, type is a TabSet containing
  172. * TabStops.
  173. */
  174. public static final Object TabSet = ParagraphConstants.TabSet;
  175. /**
  176. * Orientation for a paragraph.
  177. */
  178. public static final Object Orientation = ParagraphConstants.Orientation;
  179. /**
  180. * A possible value for paragraph alignment. This
  181. * specifies that the text is aligned to the left
  182. * indent and extra whitespace should be placed on
  183. * the right.
  184. */
  185. public static final int ALIGN_LEFT = 0;
  186. /**
  187. * A possible value for paragraph alignment. This
  188. * specifies that the text is aligned to the center
  189. * and extra whitespace should be placed equally on
  190. * the left and right.
  191. */
  192. public static final int ALIGN_CENTER = 1;
  193. /**
  194. * A possible value for paragraph alignment. This
  195. * specifies that the text is aligned to the right
  196. * indent and extra whitespace should be placed on
  197. * the left.
  198. */
  199. public static final int ALIGN_RIGHT = 2;
  200. /**
  201. * A possible value for paragraph alignment. This
  202. * specifies that extra whitespace should be spread
  203. * out through the rows of the paragraph with the
  204. * text lined up with the left and right indent
  205. * except on the last line which should be aligned
  206. * to the left.
  207. */
  208. public static final int ALIGN_JUSTIFIED = 3;
  209. // --- character attribute accessors ---------------------------
  210. /**
  211. * Gets the BidiLevel setting.
  212. *
  213. * @param a the attribute set
  214. * @return the value
  215. */
  216. public static int getBidiLevel(AttributeSet a) {
  217. Integer o = (Integer) a.getAttribute(BidiLevel);
  218. if (o != null) {
  219. return o.intValue();
  220. }
  221. return 0; // Level 0 is base level (non-embedded) left-to-right
  222. }
  223. /**
  224. * Sets the BidiLevel.
  225. *
  226. * @param a the attribute set
  227. * @param o the bidi level value
  228. */
  229. public static void setBidiLevel(MutableAttributeSet a, int o) {
  230. a.addAttribute(BidiLevel, new Integer(o));
  231. }
  232. /**
  233. * Gets the component setting from the attribute list.
  234. *
  235. * @param a the attribute set
  236. * @return the component, null if none
  237. */
  238. public static Component getComponent(AttributeSet a) {
  239. return (Component) a.getAttribute(ComponentAttribute);
  240. }
  241. /**
  242. * Sets the component attribute.
  243. *
  244. * @param a the attribute set
  245. * @param c the component
  246. */
  247. public static void setComponent(MutableAttributeSet a, Component c) {
  248. a.addAttribute(AbstractDocument.ElementNameAttribute, ComponentElementName);
  249. a.addAttribute(ComponentAttribute, c);
  250. }
  251. /**
  252. * Gets the icon setting from the attribute list.
  253. *
  254. * @param a the attribute set
  255. * @return the icon, null if none
  256. */
  257. public static Icon getIcon(AttributeSet a) {
  258. return (Icon) a.getAttribute(IconAttribute);
  259. }
  260. /**
  261. * Sets the icon attribute.
  262. *
  263. * @param a the attribute set
  264. * @param c the icon
  265. */
  266. public static void setIcon(MutableAttributeSet a, Icon c) {
  267. a.addAttribute(AbstractDocument.ElementNameAttribute, IconElementName);
  268. a.addAttribute(IconAttribute, c);
  269. }
  270. /**
  271. * Gets the font family setting from the attribute list.
  272. *
  273. * @param a the attribute set
  274. * @return the font family, "Monospaced" as the default
  275. */
  276. public static String getFontFamily(AttributeSet a) {
  277. String family = (String) a.getAttribute(FontFamily);
  278. if (family == null) {
  279. family = "Monospaced";
  280. }
  281. return family;
  282. }
  283. /**
  284. * Sets the font attribute.
  285. *
  286. * @param a the attribute set
  287. * @param fam the font
  288. */
  289. public static void setFontFamily(MutableAttributeSet a, String fam) {
  290. a.addAttribute(FontFamily, fam);
  291. }
  292. /**
  293. * Gets the font size setting from the attribute list.
  294. *
  295. * @param a the attribute set
  296. * @return the font size, 12 as the default
  297. */
  298. public static int getFontSize(AttributeSet a) {
  299. Integer size = (Integer) a.getAttribute(FontSize);
  300. if (size != null) {
  301. return size.intValue();
  302. }
  303. return 12;
  304. }
  305. /**
  306. * Sets the font size attribute.
  307. *
  308. * @param a the attribute set
  309. * @param s the font size
  310. */
  311. public static void setFontSize(MutableAttributeSet a, int s) {
  312. a.addAttribute(FontSize, new Integer(s));
  313. }
  314. /**
  315. * Checks whether the bold attribute is set.
  316. *
  317. * @param a the attribute set
  318. * @return true if set else false
  319. */
  320. public static boolean isBold(AttributeSet a) {
  321. Boolean bold = (Boolean) a.getAttribute(Bold);
  322. if (bold != null) {
  323. return bold.booleanValue();
  324. }
  325. return false;
  326. }
  327. /**
  328. * Sets the bold attribute.
  329. *
  330. * @param a the attribute set
  331. * @param b specifies true/false for setting the attribute
  332. */
  333. public static void setBold(MutableAttributeSet a, boolean b) {
  334. a.addAttribute(Bold, Boolean.valueOf(b));
  335. }
  336. /**
  337. * Checks whether the italic attribute is set.
  338. *
  339. * @param a the attribute set
  340. * @return true if set else false
  341. */
  342. public static boolean isItalic(AttributeSet a) {
  343. Boolean italic = (Boolean) a.getAttribute(Italic);
  344. if (italic != null) {
  345. return italic.booleanValue();
  346. }
  347. return false;
  348. }
  349. /**
  350. * Sets the italic attribute.
  351. *
  352. * @param a the attribute set
  353. * @param b specifies true/false for setting the attribute
  354. */
  355. public static void setItalic(MutableAttributeSet a, boolean b) {
  356. a.addAttribute(Italic, Boolean.valueOf(b));
  357. }
  358. /**
  359. * Checks whether the underline attribute is set.
  360. *
  361. * @param a the attribute set
  362. * @return true if set else false
  363. */
  364. public static boolean isUnderline(AttributeSet a) {
  365. Boolean underline = (Boolean) a.getAttribute(Underline);
  366. if (underline != null) {
  367. return underline.booleanValue();
  368. }
  369. return false;
  370. }
  371. /**
  372. * Checks whether the strikethrough attribute is set.
  373. *
  374. * @param a the attribute set
  375. * @return true if set else false
  376. */
  377. public static boolean isStrikeThrough(AttributeSet a) {
  378. Boolean strike = (Boolean) a.getAttribute(StrikeThrough);
  379. if (strike != null) {
  380. return strike.booleanValue();
  381. }
  382. return false;
  383. }
  384. /**
  385. * Checks whether the superscript attribute is set.
  386. *
  387. * @param a the attribute set
  388. * @return true if set else false
  389. */
  390. public static boolean isSuperscript(AttributeSet a) {
  391. Boolean superscript = (Boolean) a.getAttribute(Superscript);
  392. if (superscript != null) {
  393. return superscript.booleanValue();
  394. }
  395. return false;
  396. }
  397. /**
  398. * Checks whether the subscript attribute is set.
  399. *
  400. * @param a the attribute set
  401. * @return true if set else false
  402. */
  403. public static boolean isSubscript(AttributeSet a) {
  404. Boolean subscript = (Boolean) a.getAttribute(Subscript);
  405. if (subscript != null) {
  406. return subscript.booleanValue();
  407. }
  408. return false;
  409. }
  410. /**
  411. * Sets the underline attribute.
  412. *
  413. * @param a the attribute set
  414. * @param b specifies true/false for setting the attribute
  415. */
  416. public static void setUnderline(MutableAttributeSet a, boolean b) {
  417. a.addAttribute(Underline, Boolean.valueOf(b));
  418. }
  419. /**
  420. * Sets the strikethrough attribute.
  421. *
  422. * @param a the attribute set
  423. * @param b specifies true/false for setting the attribute
  424. */
  425. public static void setStrikeThrough(MutableAttributeSet a, boolean b) {
  426. a.addAttribute(StrikeThrough, Boolean.valueOf(b));
  427. }
  428. /**
  429. * Sets the superscript attribute.
  430. *
  431. * @param a the attribute set
  432. * @param b specifies true/false for setting the attribute
  433. */
  434. public static void setSuperscript(MutableAttributeSet a, boolean b) {
  435. a.addAttribute(Superscript, Boolean.valueOf(b));
  436. }
  437. /**
  438. * Sets the subscript attribute.
  439. *
  440. * @param a the attribute set
  441. * @param b specifies true/false for setting the attribute
  442. */
  443. public static void setSubscript(MutableAttributeSet a, boolean b) {
  444. a.addAttribute(Subscript, Boolean.valueOf(b));
  445. }
  446. /**
  447. * Gets the foreground color setting from the attribute list.
  448. *
  449. * @param a the attribute set
  450. * @return the color, Color.black as the default
  451. */
  452. public static Color getForeground(AttributeSet a) {
  453. Color fg = (Color) a.getAttribute(Foreground);
  454. if (fg == null) {
  455. fg = Color.black;
  456. }
  457. return fg;
  458. }
  459. /**
  460. * Sets the foreground color.
  461. *
  462. * @param a the attribute set
  463. * @param fg the color
  464. */
  465. public static void setForeground(MutableAttributeSet a, Color fg) {
  466. a.addAttribute(Foreground, fg);
  467. }
  468. /**
  469. * Gets the background color setting from the attribute list.
  470. *
  471. * @param a the attribute set
  472. * @return the color, Color.black as the default
  473. */
  474. public static Color getBackground(AttributeSet a) {
  475. Color fg = (Color) a.getAttribute(Background);
  476. if (fg == null) {
  477. fg = Color.black;
  478. }
  479. return fg;
  480. }
  481. /**
  482. * Sets the background color.
  483. *
  484. * @param a the attribute set
  485. * @param fg the color
  486. */
  487. public static void setBackground(MutableAttributeSet a, Color fg) {
  488. a.addAttribute(Background, fg);
  489. }
  490. // --- paragraph attribute accessors ----------------------------
  491. /**
  492. * Gets the first line indent setting.
  493. *
  494. * @param a the attribute set
  495. * @return the value, 0 if not set
  496. */
  497. public static float getFirstLineIndent(AttributeSet a) {
  498. Float indent = (Float) a.getAttribute(FirstLineIndent);
  499. if (indent != null) {
  500. return indent.floatValue();
  501. }
  502. return 0;
  503. }
  504. /**
  505. * Sets the first line indent.
  506. *
  507. * @param a the attribute set
  508. * @param i the value
  509. */
  510. public static void setFirstLineIndent(MutableAttributeSet a, float i) {
  511. a.addAttribute(FirstLineIndent, new Float(i));
  512. }
  513. /**
  514. * Gets the right indent setting.
  515. *
  516. * @param a the attribute set
  517. * @return the value, 0 if not set
  518. */
  519. public static float getRightIndent(AttributeSet a) {
  520. Float indent = (Float) a.getAttribute(RightIndent);
  521. if (indent != null) {
  522. return indent.floatValue();
  523. }
  524. return 0;
  525. }
  526. /**
  527. * Sets right indent.
  528. *
  529. * @param a the attribute set
  530. * @param i the value
  531. */
  532. public static void setRightIndent(MutableAttributeSet a, float i) {
  533. a.addAttribute(RightIndent, new Float(i));
  534. }
  535. /**
  536. * Gets the left indent setting.
  537. *
  538. * @param a the attribute set
  539. * @return the value, 0 if not set
  540. */
  541. public static float getLeftIndent(AttributeSet a) {
  542. Float indent = (Float) a.getAttribute(LeftIndent);
  543. if (indent != null) {
  544. return indent.floatValue();
  545. }
  546. return 0;
  547. }
  548. /**
  549. * Sets left indent.
  550. *
  551. * @param a the attribute set
  552. * @param i the value
  553. */
  554. public static void setLeftIndent(MutableAttributeSet a, float i) {
  555. a.addAttribute(LeftIndent, new Float(i));
  556. }
  557. /**
  558. * Gets the line spacing setting.
  559. *
  560. * @param a the attribute set
  561. * @return the value, 0 if not set
  562. */
  563. public static float getLineSpacing(AttributeSet a) {
  564. Float space = (Float) a.getAttribute(LineSpacing);
  565. if (space != null) {
  566. return space.floatValue();
  567. }
  568. return 0;
  569. }
  570. /**
  571. * Sets line spacing.
  572. *
  573. * @param a the attribute set
  574. * @param i the value
  575. */
  576. public static void setLineSpacing(MutableAttributeSet a, float i) {
  577. a.addAttribute(LineSpacing, new Float(i));
  578. }
  579. /**
  580. * Gets the space above setting.
  581. *
  582. * @param a the attribute set
  583. * @return the value, 0 if not set
  584. */
  585. public static float getSpaceAbove(AttributeSet a) {
  586. Float space = (Float) a.getAttribute(SpaceAbove);
  587. if (space != null) {
  588. return space.floatValue();
  589. }
  590. return 0;
  591. }
  592. /**
  593. * Sets space above.
  594. *
  595. * @param a the attribute set
  596. * @param i the value
  597. */
  598. public static void setSpaceAbove(MutableAttributeSet a, float i) {
  599. a.addAttribute(SpaceAbove, new Float(i));
  600. }
  601. /**
  602. * Gets the space below setting.
  603. *
  604. * @param a the attribute set
  605. * @return the value, 0 if not set
  606. */
  607. public static float getSpaceBelow(AttributeSet a) {
  608. Float space = (Float) a.getAttribute(SpaceBelow);
  609. if (space != null) {
  610. return space.floatValue();
  611. }
  612. return 0;
  613. }
  614. /**
  615. * Sets space below.
  616. *
  617. * @param a the attribute set
  618. * @param i the value
  619. */
  620. public static void setSpaceBelow(MutableAttributeSet a, float i) {
  621. a.addAttribute(SpaceBelow, new Float(i));
  622. }
  623. /**
  624. * Gets the alignment setting.
  625. *
  626. * @param a the attribute set
  627. * @return the value <code>StyleConstants.ALIGN_LEFT</code> if not set
  628. */
  629. public static int getAlignment(AttributeSet a) {
  630. Integer align = (Integer) a.getAttribute(Alignment);
  631. if (align != null) {
  632. return align.intValue();
  633. }
  634. return ALIGN_LEFT;
  635. }
  636. /**
  637. * Sets alignment.
  638. *
  639. * @param a the attribute set
  640. * @param align the alignment value
  641. */
  642. public static void setAlignment(MutableAttributeSet a, int align) {
  643. a.addAttribute(Alignment, new Integer(align));
  644. }
  645. /**
  646. * Gets the TabSet.
  647. *
  648. * @param a the attribute set
  649. * @return the <code>TabSet</code>
  650. */
  651. public static TabSet getTabSet(AttributeSet a) {
  652. TabSet tabs = (TabSet)a.getAttribute(TabSet);
  653. // PENDING: should this return a default?
  654. return tabs;
  655. }
  656. /**
  657. * Sets the TabSet.
  658. *
  659. * @param a the attribute set.
  660. * @param tabs the TabSet
  661. */
  662. public static void setTabSet(MutableAttributeSet a, TabSet tabs) {
  663. a.addAttribute(TabSet, tabs);
  664. }
  665. // --- privates ---------------------------------------------
  666. static Object[] keys = {
  667. NameAttribute, ResolveAttribute, BidiLevel,
  668. FontFamily, FontSize, Bold, Italic, Underline,
  669. StrikeThrough, Superscript, Subscript, Foreground,
  670. Background, ComponentAttribute, IconAttribute,
  671. FirstLineIndent, LeftIndent, RightIndent, LineSpacing,
  672. SpaceAbove, SpaceBelow, Alignment, TabSet, Orientation,
  673. ModelAttribute, ComposedTextAttribute
  674. };
  675. StyleConstants(String representation) {
  676. this.representation = representation;
  677. }
  678. private String representation;
  679. /**
  680. * This is a typesafe enumeration of the <em>well-known</em>
  681. * attributes that contribute to a paragraph style. These are
  682. * aliased by the outer class for general presentation.
  683. */
  684. public static class ParagraphConstants extends StyleConstants
  685. implements AttributeSet.ParagraphAttribute {
  686. /**
  687. * The amount of space to indent the first
  688. * line of the paragraph. This value may be negative
  689. * to offset in the reverse direction. The type
  690. * is Float and specifies the size of the space
  691. * in points.
  692. */
  693. public static final Object FirstLineIndent = new ParagraphConstants("FirstLineIndent");
  694. /**
  695. * The amount to indent the left side
  696. * of the paragraph.
  697. * Type is float and specifies the size in points.
  698. */
  699. public static final Object LeftIndent = new ParagraphConstants("LeftIndent");
  700. /**
  701. * The amount to indent the right side
  702. * of the paragraph.
  703. * Type is float and specifies the size in points.
  704. */
  705. public static final Object RightIndent = new ParagraphConstants("RightIndent");
  706. /**
  707. * The amount of space between lines
  708. * of the paragraph.
  709. * Type is float and specifies the size as a factor of the line height
  710. */
  711. public static final Object LineSpacing = new ParagraphConstants("LineSpacing");
  712. /**
  713. * The amount of space above the paragraph.
  714. * Type is float and specifies the size in points.
  715. */
  716. public static final Object SpaceAbove = new ParagraphConstants("SpaceAbove");
  717. /**
  718. * The amount of space below the paragraph.
  719. * Type is float and specifies the size in points.
  720. */
  721. public static final Object SpaceBelow = new ParagraphConstants("SpaceBelow");
  722. /**
  723. * Alignment for the paragraph. The type is
  724. * Integer. Valid values are:
  725. * <ul>
  726. * <li>ALIGN_LEFT
  727. * <li>ALIGN_RIGHT
  728. * <li>ALIGN_CENTER
  729. * <li>ALIGN_JUSTIFED
  730. * </ul>
  731. *
  732. */
  733. public static final Object Alignment = new ParagraphConstants("Alignment");
  734. /**
  735. * TabSet for the paragraph.
  736. */
  737. public static final Object TabSet = new ParagraphConstants("TabSet");
  738. /**
  739. * Orientation for the paragraph.
  740. */
  741. public static final Object Orientation = new ParagraphConstants("Orientation");
  742. // --- privates ---------------------------------------------
  743. private ParagraphConstants(String representation) {
  744. super(representation);
  745. }
  746. }
  747. /**
  748. * This is a typesafe enumeration of the <em>well-known</em>
  749. * attributes that contribute to a character style. These are
  750. * aliased by the outer class for general presentation.
  751. */
  752. public static class CharacterConstants extends StyleConstants
  753. implements AttributeSet.CharacterAttribute {
  754. /**
  755. * Name of the underline attribute.
  756. */
  757. public static final Object Underline = new CharacterConstants("underline");
  758. /**
  759. * Name of the strikethrough attribute.
  760. */
  761. public static final Object StrikeThrough = new CharacterConstants("strikethrough");
  762. /**
  763. * Name of the superscript attribute.
  764. */
  765. public static final Object Superscript = new CharacterConstants("superscript");
  766. /**
  767. * Name of the subscript attribute.
  768. */
  769. public static final Object Subscript = new CharacterConstants("subscript");
  770. /**
  771. * Name of the component attribute.
  772. */
  773. public static final Object ComponentAttribute = new CharacterConstants("component");
  774. /**
  775. * Name of the icon attribute.
  776. */
  777. public static final Object IconAttribute = new CharacterConstants("icon");
  778. /**
  779. * Bidirectional level of a character as assigned by the Unicode bidi
  780. * algorithm.
  781. */
  782. public static final Object BidiLevel = new CharacterConstants("bidiLevel");
  783. /**
  784. * Name of the font family.
  785. */
  786. public static final Object Family = FontConstants.Family;
  787. /**
  788. * Name of the font size.
  789. */
  790. public static final Object Size = FontConstants.Size;
  791. /**
  792. * Name of the bold attribute.
  793. */
  794. public static final Object Bold = FontConstants.Bold;
  795. /**
  796. * Name of the italic attribute.
  797. */
  798. public static final Object Italic = FontConstants.Italic;
  799. /**
  800. * Name of the foreground color attribute.
  801. */
  802. public static final Object Foreground = ColorConstants.Foreground;
  803. /**
  804. * Name of the background color attribute.
  805. */
  806. public static final Object Background = ColorConstants.Background;
  807. // --- privates ---------------------------------------------
  808. private CharacterConstants(String representation) {
  809. super(representation);
  810. }
  811. }
  812. /**
  813. * This is a typesafe enumeration of the <em>well-known</em>
  814. * attributes that contribute to a color. These are aliased
  815. * by the outer class for general presentation.
  816. */
  817. public static class ColorConstants extends StyleConstants
  818. implements AttributeSet.ColorAttribute, AttributeSet.CharacterAttribute {
  819. /**
  820. * Name of the foreground color attribute.
  821. */
  822. public static final Object Foreground = new ColorConstants("foreground");
  823. /**
  824. * Name of the background color attribute.
  825. */
  826. public static final Object Background = new ColorConstants("background");
  827. // --- privates ---------------------------------------------
  828. private ColorConstants(String representation) {
  829. super(representation);
  830. }
  831. }
  832. /**
  833. * This is a typesafe enumeration of the <em>well-known</em>
  834. * attributes that contribute to a font. These are aliased
  835. * by the outer class for general presentation.
  836. */
  837. public static class FontConstants extends StyleConstants
  838. implements AttributeSet.FontAttribute, AttributeSet.CharacterAttribute {
  839. /**
  840. * Name of the font family.
  841. */
  842. public static final Object Family = new FontConstants("family");
  843. /**
  844. * Name of the font size.
  845. */
  846. public static final Object Size = new FontConstants("size");
  847. /**
  848. * Name of the bold attribute.
  849. */
  850. public static final Object Bold = new FontConstants("bold");
  851. /**
  852. * Name of the italic attribute.
  853. */
  854. public static final Object Italic = new FontConstants("italic");
  855. // --- privates ---------------------------------------------
  856. private FontConstants(String representation) {
  857. super(representation);
  858. }
  859. }
  860. }