Package games.stendhal.client.gui

Examples of games.stendhal.client.gui.FormatTextParser


    final Font specialFont = normalFont.deriveFont(Font.ITALIC);

    try {
      // recreate the string without the # characters
      final StringBuilder temp = new StringBuilder();
      FormatTextParser parser = new FormatTextParserExtension(temp);
      parser.format(line);

      // create the attribute string including formating
      final AttributedString aStyledText = new AttributedString(temp.toString());

      parser = new FormatTextParser() {
        private int s = 0;

        @Override
        public void normalText(final String tok) {
          if (tok.length() > 0) {
            aStyledText.addAttribute(TextAttribute.FONT, normalFont, s, s
                + tok.length());
            aStyledText.addAttribute(TextAttribute.FOREGROUND, normalColor, s, s
                + tok.length());
            s += tok.length();
          }
        }

        @Override
        public void colorText(final String tok) {
          if (tok.length() > 0) {
            aStyledText.addAttribute(TextAttribute.FONT, specialFont, s, s
                + tok.length());
            aStyledText.addAttribute(TextAttribute.FOREGROUND, Color.blue, s, s
                + tok.length());
            s += tok.length();
          }
        }
      };
      parser.format(line);

      return aStyledText;
    } catch (final Exception e) {
      Logger.getLogger(TextBoxFactory.class).error(e, e);
      return null;
View Full Code Here

TOP

Related Classes of games.stendhal.client.gui.FormatTextParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.