Package javax.swing.text

Examples of javax.swing.text.MutableAttributeSet


        try {
            rs = parser.parseRuleSet();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        MutableAttributeSet attrs = new SimpleAttributeSet();
        Iterator pi = rs.getProperties();
        while (pi.hasNext()) {
            Property property = (Property)pi.next();
            addCSSAttribute(attrs, CSS.getAttribute(property.getName()),
                            property.getValue());
View Full Code Here


    }

    private void addParsedSheet(final Iterator it, final boolean asResolver) {
        while (it.hasNext()) {
            RuleSet rs = (RuleSet)it.next();
            MutableAttributeSet attrs = new SimpleAttributeSet();
            Iterator pi = rs.getProperties();
            while (pi.hasNext()) {
                Property property = (Property)pi.next();
                addCSSAttribute(attrs, CSS.getAttribute(property.getName()),
                                property.getValue());
            }
            if (attrs.getAttributeCount() == 0) {
                continue;
            }

            Iterator si = rs.getSelectors();
            while (si.hasNext()) {
                String selector = new Selector((String)si.next()).toString();
                Style rr = getStyle(selector);
                if (rr == null) {
                    rr = addStyle(selector, null);
                    addStyleToCascadedStyles(selector);
                }
                if (asResolver) {
                    final AttributeSet resolver = rr.getResolveParent();
                    final MutableAttributeSet importedAttrs =
                        resolver instanceof MutableAttributeSet
                        ? (MutableAttributeSet)resolver
                        : addStyle(null, null);
                    importedAttrs.addAttributes(attrs);
                    rr.setResolveParent(importedAttrs);
                } else {
                    rr.addAttributes(attrs);
                }
            }
View Full Code Here

                                          final NameConverterEnumeration keys) {
        if (!keys.isUnderline() && !keys.isLineThrough()) {
            return super.removeAttributes(toModify, keys);
        }

        final MutableAttributeSet result = new SimpleAttributeSet(toModify);
        result.removeAttributes(keys);
        TextDecoration td =
            (TextDecoration)result.getAttribute(Attribute.TEXT_DECORATION);
        td = (TextDecoration)td.clone();

        if (keys.isUnderline() && td.isUnderline()) {
            td.setUnderline(false);
        }
        if (keys.isLineThrough() && td.isLineThrough()) {
            td.setLineThrough(false);
        }
        if (td.isNone()) {
            result.removeAttribute(Attribute.TEXT_DECORATION);
        } else {
            result.addAttribute(Attribute.TEXT_DECORATION, td);
        }
        return super.addAttributes(getEmptySet(), result);
    }
View Full Code Here

        }
        super.insertUpdate(event, contentAttr);
    }

    private void processTarget(final Element target, final String src) {
        final MutableAttributeSet targetAttr = (MutableAttributeSet)target.getAttributes();
        writeLock();
        try {
            targetAttr.addAttribute(HTML.Attribute.SRC, src);
        } finally {
            writeUnlock();
        }
        fireChangedUpdate(new DefaultDocumentEvent(target.getStartOffset(), target.getEndOffset() - target.getStartOffset(), EventType.CHANGE));
    }
View Full Code Here

        public void handleSimpleTag(final Tag tag,
                                    final MutableAttributeSet attr,
                                    final int pos) {
            final TagAction action = getAction(tag);
            MutableAttributeSet tagAttr = handleStyleAttribute(attr);
            if (action != emptyAction || !getPreservesUnknownTags()) {
                action.start(tag, tagAttr);
                action.end(tag);
            } else {
                addSpecialElement(tag, tagAttr);
View Full Code Here

            blockOpen(Tag.IMPLIED, new SimpleAttributeSet());
            impliedBlockOpen = true;
        }

        private MutableAttributeSet createMutableSet(final Object key, final Object value) {
            MutableAttributeSet specAttr = new SimpleAttributeSet();
            specAttr.addAttribute(key, value);
            return specAttr;
        }
View Full Code Here

        lastEnd = run.getEndOffset();
        if (pos == lastEnd) {
          // offset + length beyond length of document, bail.
          break;
        }
        MutableAttributeSet attr = (MutableAttributeSet) run.getAttributes();
        if ((attr != null) &&
            (attr.getAttribute(MWPaneFormatter.ATTRIBUTE_TYPE) != null) &&
            (attr.getAttribute(MWPaneFormatter.ATTRIBUTE_INFO) != null)) {
          Object attrInfo = attr.getAttribute(MWPaneFormatter.ATTRIBUTE_INFO);
          if (attrInfo instanceof CheckErrorResult) {
            int startOffset = MWPaneFormatter.getUUIDStartOffset(textPane, run);
            int endOffset = MWPaneFormatter.getUUIDEndOffet(textPane, run);
            if (originalText.equals(textPane.getText(startOffset, endOffset - startOffset))) {
              boolean possible = false;
View Full Code Here

      lastEnd = run.getEndOffset();
      if (pos == lastEnd) {
        // offset + length beyond length of document, bail.
        break;
      }
      MutableAttributeSet attr = (MutableAttributeSet) run.getAttributes();
      if ((attr != null) &&
          (attr.getAttribute(MWPaneFormatter.ATTRIBUTE_TYPE) != null) &&
          (attr.getAttribute(MWPaneFormatter.ATTRIBUTE_OCCURRENCE) != Boolean.FALSE)) {
        select(run);
        return;
      }
    }
    for (int pos = 0; pos < length; pos = lastEnd) {
      Element run = doc.getCharacterElement(pos);
      lastEnd = run.getEndOffset();
      if (pos == lastEnd) {
        // offset + length beyond length of document, bail.
        break;
      }
      MutableAttributeSet attr = (MutableAttributeSet) run.getAttributes();
      if ((attr != null) &&
          (attr.getAttribute(MWPaneFormatter.ATTRIBUTE_TYPE) != null) &&
          (attr.getAttribute(MWPaneFormatter.ATTRIBUTE_OCCURRENCE) != null)) {
        select(run);
        return;
      }
    }
  }
View Full Code Here

    StyledDocument doc = textPane.getStyledDocument();
    int lastStart = Integer.MIN_VALUE;
    for (int pos = textPane.getSelectionStart(); pos > 0; pos = lastStart) {
      Element run = doc.getCharacterElement(pos - 1);
      lastStart = run.getStartOffset();
      MutableAttributeSet attr = (MutableAttributeSet) run.getAttributes();
      if ((attr != null) &&
          (attr.getAttribute(MWPaneFormatter.ATTRIBUTE_TYPE) != null) &&
          (attr.getAttribute(MWPaneFormatter.ATTRIBUTE_OCCURRENCE) != Boolean.FALSE)) {
        select(run);
        return;
      }
    }
    selectLastOccurrence();
View Full Code Here

      lastEnd = run.getEndOffset();
      if (pos == lastEnd) {
        // offset + length beyond length of document, bail.
        break;
      }
      MutableAttributeSet attr = (MutableAttributeSet) run.getAttributes();
      if ((attr != null) &&
          (attr.getAttribute(MWPaneFormatter.ATTRIBUTE_TYPE) != null) &&
          (attr.getAttribute(MWPaneFormatter.ATTRIBUTE_OCCURRENCE) != Boolean.FALSE)) {
        select(run);
        return;
      }
    }
    selectFirstOccurrence();
View Full Code Here

TOP

Related Classes of javax.swing.text.MutableAttributeSet

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.