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