Package javax.swing.text

Examples of javax.swing.text.AttributeSet


        private void generateDocument(ResultItem<String>[] diffResults) {
            Document doc = getDocument();

            for (int i = 0; i < diffResults.length; ++i) {
                ResultItem<String> currentResult = diffResults[i];
                AttributeSet attrToUse = null;
               
                if (currentResult.isInsertedByA())
                    attrToUse = attrAddedLocally;
                else if (currentResult.isInsertedByB())
                    attrToUse = attrAddedByOther;
View Full Code Here


       
        private String getStyleNameAt(int pos) {
            try {
                StyledDocument doc = (StyledDocument) getDocument();
                Element elem = doc.getCharacterElement(pos);
                AttributeSet attrs = elem.getAttributes();
                Object result = attrs.getAttribute(StyleConstants.NameAttribute);
                return (String) result;
            } catch (Exception e) {
                return null;
            }
        }
View Full Code Here

        if (s == null || start == end) {
            return null;
        }
        AttributedString attributedString = new AttributedString(s);
        for (int i = start; i < end; i++) {
            AttributeSet ass = getAttributeSet(i);
            Enumeration<?> names;
            for (names = ass.getAttributeNames();
                 names.hasMoreElements();) {
                Object key = names.nextElement();
                if (key instanceof AttributedCharacterIterator.Attribute) {
                    AttributedCharacterIterator.Attribute attribute =
                        (AttributedCharacterIterator.Attribute)key;
                    Object value = ass.getAttribute(key);
                    attributedString.addAttribute(attribute, value,
                                                  i - start,
                                                  i + 1 - start);
                }
            }
View Full Code Here

    if (element == null) {
      return null;
    }

    // Check if it's for Check Wiki
    AttributeSet attributes = element.getAttributes();
    Object attrInfo = attributes.getAttribute(MWPaneFormatter.ATTRIBUTE_INFO);
    if (!(attrInfo instanceof CheckErrorResult)) {
      return null;
    }

    CheckErrorResult info = (CheckErrorResult) attrInfo;
View Full Code Here

    }
    int startOffset = MWPaneFormatter.getUUIDStartOffset(textPane, element);
    int endOffset = MWPaneFormatter.getUUIDEndOffet(textPane, element);

    // Retrieve main attributes
    AttributeSet attributes = element.getAttributes();
    Object attrPage = attributes.getAttribute(MWPaneFormatter.ATTRIBUTE_PAGE);
    Object attrPageElement = attributes.getAttribute(MWPaneFormatter.ATTRIBUTE_PAGE_ELEMENT);
    Object attrTemplateMatcher = attributes.getAttribute(MWPaneFormatter.ATTRIBUTE_TEMPLATE_MATCHER);
    Object attrText = attributes.getAttribute(MWPaneFormatter.ATTRIBUTE_TEXT);

    Page page = (attrPage instanceof Page) ? (Page) attrPage : null;
    TemplateMatcher matcher = (attrTemplateMatcher instanceof TemplateMatcher) ?
        (TemplateMatcher) attrTemplateMatcher : null;
    MWPaneDisambiguationMenuCreator menu = new MWPaneDisambiguationMenuCreator();
View Full Code Here

           
            Caret caret = text.getCaret();
            int dot = caret.getDot();
            dot = dot > 0 ? dot - 1 : dot;
            Element elem = document.getCharacterElement(dot);
            AttributeSet set = elem.getAttributes();
           
            setBoldEnabled(editable);
            setBoldSelected(StyleConstants.isBold(set));
            setItalicEnabled(editable);
            setItalicSelected(StyleConstants.isItalic(set));
View Full Code Here

    }
   
    private void flushBuffer() {
        String txt = new String(buffer, 0, count);
        count = 0;
        AttributeSet style = getStyle(txt);
        _sink.setCharacterAttributes(style, true);
        _sink.appendText(txt);
    }
View Full Code Here

        Object resolveRelativeValue(final View view) {
            if (view == null) {
                return ZERO;
            }

            final AttributeSet attr = view.getAttributes();

            switch (relativeUnits) {
            case RELATIVE_UNITS_EM:
            case RELATIVE_UNITS_EX:
                final Object fs = attr.getAttribute(Attribute.FONT_SIZE);
                final float fontSize = fs != null
                                       ? ((Length)fs).floatValue(view)
                                       : FontSize.getDefaultValue().floatValue();

                float result = fontSize * theValue.floatValue();
 
View Full Code Here

            final View parent = view.getParent();
            if (parent == null) {
                return getDefaultValue();
            }

            final AttributeSet attr = parent.getAttributes();
            final Object fs = attr.getAttribute(Attribute.FONT_SIZE);
            final int fontSize = fs != null ? ((Length)fs).intValue(parent)
                                            : getDefaultValue().intValue();
            int sizeValueIndex;

            // calculation is defined by CSS1, http://www.w3.org/TR/CSS1#length-units
View Full Code Here

            Document eDoc = editor.getDocument();
            if (eDoc instanceof DefaultStyledDocument) {
              DefaultStyledDocument hdoc =
                (DefaultStyledDocument) eDoc;
              Element e = hdoc.getCharacterElement(pos);
              AttributeSet a = e.getAttributes();
              AttributeSet tagA = (AttributeSet) a.getAttribute(HTML.Tag.A);
              String href = null;
              if (tagA!=null){
                  href = (String)tagA.getAttribute(HTML.Attribute.HREF);
              }
              if (href != null) {
                  editor.setToolTipText(href);
                  if (editor.getCursor().getType() != Cursor.HAND_CURSOR) {
                      editor.setCursor(new Cursor(Cursor.HAND_CURSOR));
View Full Code Here

TOP

Related Classes of javax.swing.text.AttributeSet

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.