Examples of AttributeSet


Examples of javax.swing.text.AttributeSet

  private void configureStyle(final javax.swing.text.Element textElement, final Element result)
  {
    final HTMLDocument htmlDocument = (HTMLDocument) textElement.getDocument();
    final StyleSheet sheet = htmlDocument.getStyleSheet();
    final AttributeSet attr = computeStyle(textElement, sheet);
    parseBorderAndBackgroundStyle(result, sheet, attr);
    parseBoxStyle(result, attr);

    final Font font = sheet.getFont(attr);
    if (font != null)
    {
      result.getStyle().setStyleProperty(TextStyleKeys.FONT, font.getFamily());
      result.getStyle().setStyleProperty(TextStyleKeys.FONTSIZE, new Integer(font.getSize()));
      result.getStyle().setBooleanStyleProperty(TextStyleKeys.ITALIC, font.isItalic());
      result.getStyle().setBooleanStyleProperty(TextStyleKeys.BOLD, font.isBold());
    }

    final Object letterSpacing = attr.getAttribute(CSS.Attribute.LETTER_SPACING);
    if (letterSpacing != null)
    {
      result.getStyle().setStyleProperty
          (TextStyleKeys.X_OPTIMUM_LETTER_SPACING, parseLength(String.valueOf(letterSpacing)));
    }

    final Object wordSpacing = attr.getAttribute(CSS.Attribute.WORD_SPACING);
    if (wordSpacing != null)
    {
      result.getStyle().setStyleProperty
          (TextStyleKeys.WORD_SPACING, parseLength(String.valueOf(wordSpacing)));
    }

    final Object lineHeight = attr.getAttribute(CSS.Attribute.LINE_HEIGHT);
    if (lineHeight != null)
    {
      result.getStyle().setStyleProperty
          (TextStyleKeys.LINEHEIGHT, parseLength(String.valueOf(lineHeight)));
    }
    final Object textAlign = attr.getAttribute(CSS.Attribute.TEXT_ALIGN);
    if (textAlign != null)
    {
      try
      {
        result.getStyle().setStyleProperty(ElementStyleKeys.ALIGNMENT,
            ReportParserUtil.parseHorizontalElementAlignment(String.valueOf(textAlign), null));
      }
      catch (ParseException e)
      {
        // ignore ..
      }
    }

    final Object textDecoration = attr.getAttribute(CSS.Attribute.TEXT_DECORATION);
    if (textDecoration != null)
    {
      final String[] strings = StringUtils.split(String.valueOf(textDecoration));
      result.getStyle().setStyleProperty(TextStyleKeys.STRIKETHROUGH, Boolean.FALSE);
      result.getStyle().setStyleProperty(TextStyleKeys.UNDERLINED, Boolean.FALSE);

      for (int i = 0; i < strings.length; i++)
      {
        final String value = strings[i];
        if ("line-through".equals(value))
        {
          result.getStyle().setStyleProperty(TextStyleKeys.STRIKETHROUGH, Boolean.TRUE);
        }
        if ("underline".equals(value))
        {
          result.getStyle().setStyleProperty(TextStyleKeys.UNDERLINED, Boolean.TRUE);
        }
      }
    }


    final Object valign = attr.getAttribute(CSS.Attribute.VERTICAL_ALIGN);
    if (valign != null)
    {
      final VerticalTextAlign valignValue = VerticalTextAlign.valueOf(String.valueOf(valign));
      result.getStyle().setStyleProperty(TextStyleKeys.VERTICAL_TEXT_ALIGNMENT, valignValue);
      try
      {
        result.getStyle().setStyleProperty(ElementStyleKeys.VALIGNMENT,
            ReportParserUtil.parseVerticalElementAlignment(String.valueOf(valign), null));
      }
      catch (ParseException e)
      {
        // ignore ..
      }
    }

    final Object whitespaceText = attr.getAttribute(CSS.Attribute.WHITE_SPACE);
    if (whitespaceText != null)
    {
      final String value = String.valueOf(whitespaceText);
      if ("pre".equals(value))
      {
        result.getStyle().setStyleProperty(TextStyleKeys.WHITE_SPACE_COLLAPSE, WhitespaceCollapse.PRESERVE);
        result.getStyle().setStyleProperty(TextStyleKeys.TEXT_WRAP, TextWrap.NONE);
      }
      else if ("nowrap".equals(value))
      {
        result.getStyle().setStyleProperty(TextStyleKeys.WHITE_SPACE_COLLAPSE, WhitespaceCollapse.PRESERVE_BREAKS);
        result.getStyle().setStyleProperty(TextStyleKeys.TEXT_WRAP, TextWrap.NONE);
      }
      else
      {
        result.getStyle().setStyleProperty(TextStyleKeys.WHITE_SPACE_COLLAPSE, WhitespaceCollapse.COLLAPSE);
        result.getStyle().setStyleProperty(TextStyleKeys.TEXT_WRAP, TextWrap.WRAP);
      }
    }
    else
    {
      result.getStyle().setStyleProperty(TextStyleKeys.WHITE_SPACE_COLLAPSE, WhitespaceCollapse.COLLAPSE);
      result.getStyle().setStyleProperty(TextStyleKeys.TEXT_WRAP, TextWrap.WRAP);
    }

    final Object alignAttribute = attr.getAttribute(HTML.Attribute.ALIGN);
    if (alignAttribute != null)
    {
      try
      {
        result.getStyle().setStyleProperty(ElementStyleKeys.ALIGNMENT,
            ReportParserUtil.parseHorizontalElementAlignment(String.valueOf(alignAttribute), null));
      }
      catch (ParseException e)
      {
        // ignore ..
      }
    }

    final Object titleAttribute = attr.getAttribute(HTML.Attribute.TITLE);
    if (titleAttribute != null)
    {
      result.setAttribute(AttributeNames.Html.NAMESPACE, AttributeNames.Html.TITLE,
          String.valueOf(titleAttribute));
    }

    final Object textIndentStyle = attr.getAttribute(CSS.Attribute.TEXT_INDENT);
    if (textIndentStyle != null)
    {
      result.getStyle().setStyleProperty
          (TextStyleKeys.FIRST_LINE_INDENT, parseLength(String.valueOf(textIndentStyle)));
    }
View Full Code Here

Examples of javax.swing.text.AttributeSet

      chunk = null;
      element = (Element)elements.get(i);
      parent = element.getParentElement();
      startOffset = element.getStartOffset();
      endOffset = element.getEndOffset();
      AttributeSet attrs = element.getAttributes();

      Object elementName = attrs.getAttribute(AbstractDocument.ElementNameAttribute);
      Object object = (elementName != null) ? null : attrs.getAttribute(StyleConstants.NameAttribute);
      if (object instanceof HTML.Tag)
      {
       
        HTML.Tag htmlTag = (HTML.Tag) object;
        if(htmlTag == Tag.BODY)
        {
          bodyOccurred = true;
          crtOffset = - startOffset;
        }
        else if(htmlTag == Tag.BR)
        {
          chunk = "\n";
        }
        else if(htmlTag == Tag.OL)
        {
          orderedListIndex[i] = 0;
          String parentName = parent.getName().toLowerCase();
          whitespaces[i] = whitespaces[elements.indexOf(parent)] + whitespace;
          if(parentName.equals("li"))
          {
            chunk = "";
          }
          else
          {
            chunk = "\n";
            ++crtOffset;
          }
        }
        else if(htmlTag == Tag.UL)
        {
          whitespaces[i] = whitespaces[elements.indexOf(parent)] + whitespace;

          String parentName = parent.getName().toLowerCase();
          if(parentName.equals("li"))
          {
            chunk = "";
          }
          else
          {
            chunk = "\n";
            ++crtOffset;
          }
         
        }
        else if(htmlTag == Tag.LI)
        {
         
          whitespaces[i] = whitespaces[elements.indexOf(parent)];
          if(element.getElement(0) != null &&
              (element.getElement(0).getName().toLowerCase().equals("ol") || element.getElement(0).getName().toLowerCase().equals("ul"))
              )
          {
            chunk = "";
          }
          else if(parent.getName().equals("ol"))
          {
            int index = elements.indexOf(parent);
            chunk = whitespaces[index] + String.valueOf(++orderedListIndex[index]) + ".  ";
          }
          else
          {
            chunk = whitespaces[elements.indexOf(parent)] + "\u2022  ";
          }
          crtOffset += chunk.length();
        }
        else if (element instanceof LeafElement)
        {
          if (element instanceof RunElement)
          {
            RunElement runElement = (RunElement)element;
            AttributeSet attrSet = (AttributeSet)runElement.getAttribute(Tag.A);
            if (attrSet != null)
            {
              hyperlink = new JRBasePrintHyperlink();
              hyperlink.setHyperlinkType(HyperlinkTypeEnum.REFERENCE);
              hyperlink.setHyperlinkReference((String)attrSet.getAttribute(HTML.Attribute.HREF));
              hyperlink.setLinkTarget((String)attrSet.getAttribute(HTML.Attribute.TARGET));
            }
          }
          try
          {
            chunk = document.getText(startOffset, endOffset - startOffset);
View Full Code Here

Examples of javax.swing.text.AttributeSet

    index = ((Integer) matches.get(index)).intValue();
    String word = getLastWord();
    String value = (String) values.get(index);
    value = value.substring(word.length(), value.length());
    try {
      AttributeSet set = getTextField().getDocument().getRootElements()[0]
          .getAttributes();
      getTextField().getDocument().insertString(
          getTextField().getCaretPosition(), value, set);
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

Examples of javax.swing.text.AttributeSet

        textPane.getStyledDocument().setCharacterAttributes(0, text.length(), SimpleAttributeSet.EMPTY, true);

        /** Apply the style for each token */
        for (Integer idx : inputTokenIndexes) {
            DBInputTextTokenInfo info = indexToTokenInfoMap.get(idx);
            AttributeSet attribute = indexToConsumeAttributeMap.get(idx);
            if (attribute == null)
                attribute = attributeNonConsumed;

            /** LT attribute override the other */
            if (lookaheadTokenIndexes.contains(idx))
View Full Code Here

Examples of javax.swing.text.AttributeSet

        StyleConstants.setBold(blockAttr, true);
    }

    @Override
    public AttributeSet getAttributeForToken(ATEToken token) {
        AttributeSet attr = super.getAttributeForToken(token);
        switch(token.type) {
            case GrammarSyntaxLexer.TOKEN_DECL:
            case GrammarSyntaxLexer.TOKEN_REFERENCE:
                if(((ElementToken)token).lexer)
                    attr = lexerRefAttr;
View Full Code Here

Examples of javax.swing.text.AttributeSet

        applyAttribute(commentAttr, AWPrefs.PREF_SYNTAX_COMMENT);
        applyAttribute(templateAttr, AWPrefs.PREF_SYNTAX_PARSER);
    }

    public AttributeSet getAttributeForToken(ATEToken token) {
        AttributeSet attr = super.getAttributeForToken(token);
        if (token.scope instanceof ElementTemplateArgumentBlock) {
            if (attr == null)
                attr = labelAttr;
        }
        switch(token.type) {
View Full Code Here

Examples of javax.swing.text.AttributeSet

        // No parser need for generic computer language
        return null;
    }

    public AttributeSet getAttributeForToken(ATEToken token) {
        AttributeSet attr = null;
        switch(token.type) {
            case ATESyntaxLexer.TOKEN_COMPLEX_COMMENT:
            case ATESyntaxLexer.TOKEN_SINGLE_COMMENT:
                attr = commentAttr;
                break;
View Full Code Here

Examples of javax.swing.text.AttributeSet

  }

  public void print(final Object o, final Font font, final Color color) {
    invokeAndWait(new Runnable() {
      public void run() {
        AttributeSet old = getStyle();
        setStyle(font, color);
        append(String.valueOf(o));
        resetCommandStart();
        text.setCaretPosition(cmdStart);
        setStyle(old, true);
View Full Code Here

Examples of javax.swing.text.AttributeSet

      final boolean underline
  )
  {
    invokeAndWait(new Runnable() {
      public void run() {
        AttributeSet old = getStyle();
        setStyle(fontFamilyName, size, color, bold,  italic,  underline);
        append(String.valueOf(o));
        resetCommandStart();
        text.setCaretPosition(cmdStart);
        setStyle(old, true);
View Full Code Here

Examples of javax.swing.text.AttributeSet

    {
        Object value = attribs.get( key  );

        if ( value == null )
        {
            AttributeSet parent = getResolveParent();

            if ( parent != null )
            {
                value = parent.getAttribute( key  );
            }
        }

        return value;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.