Package javax.swing.text

Examples of javax.swing.text.Style


   * Initialize styles shared by all MWPane instances
   */
  private static void initializeStyles() {
    synchronized (lockStyles) {
      if (!stylesInitialized) {
        Style rootStyle = styleContext.getStyle(StyleContext.DEFAULT_STYLE);

        // Style for category
        Style categoryStyle = addStyle(
            ConfigurationValueStyle.CATEGORY, rootStyle);
        categoryStyle.addAttribute(ATTRIBUTE_OCCURRENCE, Boolean.FALSE);

        // Style for comment
        Style commentStyle = addStyle(
            ConfigurationValueStyle.COMMENTS, rootStyle);
        commentStyle.addAttribute(ATTRIBUTE_OCCURRENCE, Boolean.FALSE);

        // Style for DEFAULTSORT
        Style defaultsortStyle = addStyle(
            ConfigurationValueStyle.DEFAULTSORT, rootStyle);
        defaultsortStyle.addAttribute(ATTRIBUTE_OCCURRENCE, Boolean.FALSE);

        // Style for external link
        Style externalLinkStyle = addStyle(
            ConfigurationValueStyle.EXTERNAL_LINK, rootStyle);
        externalLinkStyle.addAttribute(ATTRIBUTE_OCCURRENCE, Boolean.FALSE);

        // Style for image
        Style imageStyle = addStyle(
            ConfigurationValueStyle.IMAGE, rootStyle);
        imageStyle.addAttribute(ATTRIBUTE_OCCURRENCE, Boolean.FALSE);

        // Style for internal link
        Style internalLinkStyle = addStyle(
            ConfigurationValueStyle.INTERNAL_LINK, rootStyle);
        internalLinkStyle.addAttribute(ATTRIBUTE_OCCURRENCE, Boolean.FALSE);

        // Style for interwiki link
        Style interwikiLinkStyle = addStyle(
            ConfigurationValueStyle.INTERWIKI_LINK, rootStyle);
        interwikiLinkStyle.addAttribute(ATTRIBUTE_OCCURRENCE, Boolean.FALSE);

        // Style for language link
        Style languageLinkStyle = addStyle(
            ConfigurationValueStyle.LANGUAGE_LINK, rootStyle);
        languageLinkStyle.addAttribute(ATTRIBUTE_OCCURRENCE, Boolean.FALSE);

        // Style for parameter
        Style parameterStyle = addStyle(
            ConfigurationValueStyle.PROGRAMMING, rootStyle);
        parameterStyle.addAttribute(ATTRIBUTE_OCCURRENCE, Boolean.FALSE);

        // Style for reference contents
        Style refStyle = addStyle(ConfigurationValueStyle.REFERENCE, rootStyle);
        refStyle.addAttribute(ATTRIBUTE_OCCURRENCE, Boolean.FALSE);

        // Style for tag
        Style tagStyle = addStyle(ConfigurationValueStyle.TAG, rootStyle);
        tagStyle.addAttribute(ATTRIBUTE_OCCURRENCE, Boolean.FALSE);

        // Style for template
        Style templateStyle = addStyle(
            ConfigurationValueStyle.TEMPLATE, rootStyle);
        templateStyle.addAttribute(ATTRIBUTE_OCCURRENCE, Boolean.FALSE);

        // Style for title
        Style titleStyle = addStyle(
            ConfigurationValueStyle.TITLE, rootStyle);
        titleStyle.addAttribute(ATTRIBUTE_OCCURRENCE, Boolean.FALSE);

        // Style for disambiguation link
        Style internalLinkDabStyle = addStyle(
            ConfigurationValueStyle.INTERNAL_LINK_DAB, rootStyle);
        internalLinkDabStyle.addAttribute(ATTRIBUTE_TYPE, VALUE_DISAMBIGUATION_LINK);

        // Style for normal internal link
        Style internalLinkNormalStyle = addStyle(
            ConfigurationValueStyle.INTERNAL_LINK_NORMAL, rootStyle);
        internalLinkNormalStyle.addAttribute(ATTRIBUTE_TYPE, VALUE_NORMAL_LINK);

        // Style for redirect link
        Style internalLinkRedirectStyle = addStyle(
            ConfigurationValueStyle.INTERNAL_LINK_REDIRECT, rootStyle);
        internalLinkRedirectStyle.addAttribute(ATTRIBUTE_TYPE, VALUE_REDIRECT_LINK);

        // Style for missing link
        Style internalLinkMissingStyle = addStyle(
            ConfigurationValueStyle.INTERNAL_LINK_MISSING, rootStyle);
        internalLinkMissingStyle.addAttribute(ATTRIBUTE_TYPE, VALUE_MISSING_LINK);

        // Style for disambiguation template
        Style templateDabStyle = addStyle(
            ConfigurationValueStyle.TEMPLATE_DAB, rootStyle);
        templateDabStyle.addAttribute(ATTRIBUTE_TYPE, VALUE_DISAMBIGUATION_TEMPLATE);

        // Style for normal template
        Style templateNormalStyle = addStyle(
            ConfigurationValueStyle.TEMPLATE_NORMAL, rootStyle);
        templateNormalStyle.addAttribute(ATTRIBUTE_TYPE, VALUE_NORMAL_TEMPLATE);

        // Style for help requested
        Style helpRequestedStyle = addStyle(
            ConfigurationValueStyle.HELP_REQUESTED, rootStyle);
        helpRequestedStyle.addAttribute(ATTRIBUTE_TYPE, VALUE_HELP_REQUESTED_LINK);

        // Style for CheckWiki error
        Style checkWikiErrorStyle = addStyle(
            ConfigurationValueStyle.CHECK_WIKI_ERROR, rootStyle);
        checkWikiErrorStyle.addAttribute(ATTRIBUTE_TYPE, VALUE_CHECK_WIKI_ERROR);

        // Style for CheckWiki warning
        Style checkWikiWarningStyle = addStyle(
            ConfigurationValueStyle.CHECK_WIKI_WARNING, rootStyle);
        checkWikiWarningStyle.addAttribute(ATTRIBUTE_TYPE, VALUE_CHECK_WIKI_WARNING);

        // Style for CheckWiki OK
        Style checkWikiOkStyle = addStyle(
            ConfigurationValueStyle.CHECK_WIKI_OK, rootStyle);
        checkWikiOkStyle.addAttribute(ATTRIBUTE_TYPE, VALUE_CHECK_WIKI_OK);
        checkWikiOkStyle.addAttribute(ATTRIBUTE_OCCURRENCE, Boolean.FALSE);

        stylesInitialized = true;
      }
    }
  }
View Full Code Here


   */
  private static Style addStyle(ConfigurationValueStyle defaultStyle, Style rootStyle) {
    if (defaultStyle == null) {
      return null;
    }
    Style newStyle = styleContext.addStyle(defaultStyle.getName(), rootStyle);
    Configuration config = Configuration.getConfiguration();
    ConfigurationValueStyle.StyleProperties configStyle = config.getStyle(defaultStyle);
    if (configStyle != null) {
      formatStyleForeground(newStyle, config, configStyle);
      formatStyleBackground(newStyle, config, configStyle);
View Full Code Here

    } else if (Boolean.TRUE.equals(link.isExisting())) {
      styleType = ConfigurationValueStyle.INTERNAL_LINK_NORMAL;
    } else {
      styleType = ConfigurationValueStyle.INTERNAL_LINK_MISSING;
    }
    Style attr = doc.getStyle(styleType.getName());
    if (attr == null) {
      return;
    }
    attr = (Style) attr.copyAttributes();
    attr.addAttribute(ATTRIBUTE_PAGE, link);
    attr.addAttribute(ATTRIBUTE_TEXT, text);
    attr.addAttribute(ATTRIBUTE_UUID, UUID.randomUUID());
    doc.setCharacterAttributes(start, end - start, attr, true);
    if (start < startPosition) {
      startPosition = start;
      endPosition = end;
    }
View Full Code Here

    }

    // Format template
    int start = template.getBeginIndex();
    int end = template.getEndIndex();
    Style attr = doc.getStyle(ConfigurationValueStyle.TEMPLATE_NORMAL.getName());
    attr = (Style) attr.copyAttributes();
    attr.addAttribute(ATTRIBUTE_PAGE, link);
    attr.addAttribute(ATTRIBUTE_PAGE_ELEMENT, template);
    attr.addAttribute(ATTRIBUTE_TEMPLATE_MATCHER, matcher);
    attr.addAttribute(ATTRIBUTE_UUID, UUID.randomUUID());
    doc.setCharacterAttributes(start, end - start, attr, true);
    if (start < thirdStartPosition) {
      thirdStartPosition = start;
      thirdEndPosition = end;
    }
View Full Code Here

    }

    // Format template
    int start = template.getBeginIndex();
    int end = template.getEndIndex();
    Style attr = doc.getStyle(ConfigurationValueStyle.HELP_REQUESTED.getName());
    attr = (Style) attr.copyAttributes();
    attr.addAttribute(ATTRIBUTE_PAGE, link);
    attr.addAttribute(ATTRIBUTE_UUID, UUID.randomUUID());
    if (template.getParameterCount() > 0) {
      attr.addAttribute(
          ATTRIBUTE_TEXT,
          (template.getParameterCount() > 1) ?
              template.getParameterValue(1) : template.getParameterValue(0));
    } else {
      attr.addAttribute(ATTRIBUTE_PAGE_ELEMENT, template);
      attr.addAttribute(ATTRIBUTE_TEMPLATE_MATCHER, matcher);
    }
    doc.setCharacterAttributes(start, end - start, attr, true);
    if (start < secondStartPosition) {
      secondStartPosition = start;
      secondEndPosition = end;
View Full Code Here

    }

    // Format template
    int start = template.getBeginIndex();
    int end = template.getEndIndex();
    Style attr = doc.getStyle(ConfigurationValueStyle.TEMPLATE_DAB.getName());
    attr = (Style) attr.copyAttributes();
    attr.addAttribute(ATTRIBUTE_PAGE, link);
    attr.addAttribute(ATTRIBUTE_PAGE_ELEMENT, template);
    attr.addAttribute(ATTRIBUTE_TEMPLATE_MATCHER, matcher);
    attr.addAttribute(ATTRIBUTE_UUID, UUID.randomUUID());
    doc.setCharacterAttributes(start, end - start, attr, true);
    if (start < startPosition) {
      startPosition = start;
      endPosition = end;
    }
View Full Code Here

            } catch (NumberFormatException numberFormatException) {
              // no need to change the foreground color
            }
          }

          Style style = null;
          switch (responseLevel) {
          case 3:
            style = statsDoc.getStyle(STYLE_REDIRECT);
            break;
          case 4:
View Full Code Here

    stats.setBackground(getBackground());

    // Add styles to use for different types of status messages
    StyledDocument doc = (StyledDocument) stats.getDocument();

    Style style = doc.addStyle(STYLE_REDIRECT, null);
    StyleConstants.setForeground(style, REDIRECT_COLOR);

    style = doc.addStyle(STYLE_CLIENT_ERROR, null);
    StyleConstants.setForeground(style, CLIENT_ERROR_COLOR);
View Full Code Here

                write("<!--");
                writeLineSeparator();
                incrIndent();
                firstRule = false;
            }
            Style styleRule = ss.getStyle(styleName);
            indent();
            write(styleName);
            writeCSSAttributes(styleRule, " { ", " }");
            writeLineSeparator();
        }
View Full Code Here

    public boolean isDefined(final Object arg0) {
        Iterator it = styleList.iterator();
        boolean result = false;
        while (!result && it.hasNext()) {
            Style style = styleSheet.getStyle(it.next().toString());
            result = style.isDefined(arg0);
        }
        if (result) {
            return result;
        }
View Full Code Here

TOP

Related Classes of javax.swing.text.Style

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.