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