當前位置: 首頁>>代碼示例>>Java>>正文


Java AttributeSet.getAttribute方法代碼示例

本文整理匯總了Java中javax.swing.text.AttributeSet.getAttribute方法的典型用法代碼示例。如果您正苦於以下問題:Java AttributeSet.getAttribute方法的具體用法?Java AttributeSet.getAttribute怎麽用?Java AttributeSet.getAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.text.AttributeSet的用法示例。


在下文中一共展示了AttributeSet.getAttribute方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeEmbeddedTags

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
/**
 * Searches for embedded tags in the AttributeSet
 * and writes them out.  It also stores these tags in a vector
 * so that when appropriate the corresponding end tags can be
 * written out.
 *
 * @exception IOException on any I/O error
 */
protected void writeEmbeddedTags(AttributeSet attr) throws IOException {

    // translate css attributes to html
    attr = convertToHTML(attr, oConvAttr);

    Enumeration names = attr.getAttributeNames();
    while (names.hasMoreElements()) {
        Object name = names.nextElement();
        if (name instanceof HTML.Tag) {
            HTML.Tag tag = (HTML.Tag) name;
            if (tag == HTML.Tag.FORM || tags.contains(tag)) {
                continue;
            }
            write('<');
            write(tag.toString());
            Object o = attr.getAttribute(tag);
            if (o != null && o instanceof AttributeSet) {
                writeAttributes((AttributeSet) o);
            }
            write('>');
            tags.addElement(tag);
            tagValues.addElement(o);
        }
    }
}
 
開發者ID:ser316asu,項目名稱:SER316-Ingolstadt,代碼行數:34,代碼來源:AltHTMLWriter.java

示例2: showInThreads

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
public void showInThreads(Instance instance) {
    if (!showThreads) {
        showThreads = true;
        instanceToSelect = instance;
        refreshSummary();
        return;
    }
    String referenceId = String.valueOf(instance.getInstanceId());
    
    dataArea.scrollToReference(referenceId);
    Document d = dataArea.getDocument();
    HTMLDocument doc = (HTMLDocument) d;
    HTMLDocument.Iterator iter = doc.getIterator(HTML.Tag.A);
    for (; iter.isValid(); iter.next()) {
        AttributeSet a = iter.getAttributes();
        String nm = (String) a.getAttribute(HTML.Attribute.NAME);
        if ((nm != null) && nm.equals(referenceId)) {
            dataArea.select(iter.getStartOffset(),iter.getEndOffset());
            dataArea.requestFocusInWindow();
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:OverviewControllerUI.java

示例3: convertToHTML40

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
/**
 * Copies the given AttributeSet to a new set, converting
 * any CSS attributes found to arguments of an HTML style
 * attribute.
 */
private static void convertToHTML40(AttributeSet from, MutableAttributeSet to) {
    Enumeration keys = from.getAttributeNames();
    String value = "";
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        if (key instanceof CSS.Attribute) {
            value = value + " " + key + "=" + from.getAttribute(key) + ";";
        }
        else {
            to.addAttribute(key, from.getAttribute(key));
        }
    }
    if (value.length() > 0) {
        to.addAttribute(HTML.Attribute.STYLE, value);
    }
}
 
開發者ID:ser316asu,項目名稱:Neukoelln_SER316,代碼行數:22,代碼來源:AltHTMLWriter.java

示例4: checkMaps

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
private boolean checkMaps(Map<String, AttributeSet> savedMap, Map<String, AttributeSet> currentMap) {
    boolean isChanged = false;
    for (String name : savedMap.keySet()) {
        if (currentMap.containsKey(name)) {
            AttributeSet currentAS = currentMap.get(name);
            AttributeSet savedAS = savedMap.get(name);
            Color currentForeground = (Color) currentAS.getAttribute(StyleConstants.Foreground);
            Color savedForeground = (Color) savedAS.getAttribute(StyleConstants.Foreground);
            Color currentBackground = (Color) currentAS.getAttribute(StyleConstants.Background);
            Color savedBackground = (Color) savedAS.getAttribute(StyleConstants.Background);
            Color currentWave = (Color) currentAS.getAttribute(EditorStyleConstants.WaveUnderlineColor);
            Color savedWave = (Color) savedAS.getAttribute(EditorStyleConstants.WaveUnderlineColor);
            isChanged |= (currentForeground == null ? savedForeground != null : !currentForeground.equals(savedForeground))
                    || (currentBackground == null ? savedBackground != null : !currentBackground.equals(savedBackground))
                    || (currentWave == null ? savedWave != null : !currentWave.equals(savedWave));
            if(isChanged) { // no need to iterate further
                return true;
            }
        }
    }
    return isChanged;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:AnnotationsPanel.java

示例5: Highlighting

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
/** Creates a new instance of Highlighting */
public Highlighting(Document doc) {
    AttributeSet firstLineFontColor = MimeLookup.getLookup(MimePath.get("text/x-java")).lookup(FontColorSettings.class).getTokenFontColors("javadoc-first-sentence"); //NOI18N
    AttributeSet commentFontColor = MimeLookup.getLookup(MimePath.get("text/x-java")).lookup(FontColorSettings.class).getTokenFontColors("comment"); //NOI18N
    if(firstLineFontColor != null && commentFontColor != null) {
        Collection<Object> attrs = new LinkedList<Object>();
        for (Enumeration<?> e = firstLineFontColor.getAttributeNames(); e.hasMoreElements(); ) {
            Object key = e.nextElement();
            Object value = firstLineFontColor.getAttribute(key);

            if (!commentFontColor.containsAttribute(key, value)) {
                attrs.add(key);
                attrs.add(value);
            }
        }
        fontColor = AttributesUtilities.createImmutable(attrs.toArray());
    } else {
        fontColor = AttributesUtilities.createImmutable();
        LOG.warning("FontColorSettings for javadoc-first-sentence or comment are not available."); //NOI18N
    }
    this.document = doc;
    hierarchy = TokenHierarchy.get(document);
    if (hierarchy != null) {
        hierarchy.addTokenHierarchyListener(WeakListeners.create(TokenHierarchyListener.class, this, hierarchy));
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:Highlighting.java

示例6: createRegionContainment

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
/**
 * Creates and returns an instance of RegionContainment that can be
 * used to test if a particular point lies inside a region.
 */
protected RegionContainment createRegionContainment(AttributeSet attributes) {
    Object shape = attributes.getAttribute(HTML.Attribute.SHAPE);

    if (shape == null) {
        shape = "rect";
    }
    if (shape instanceof String) {
        String shapeString = ((String) shape).toLowerCase();
        RegionContainment rc = null;

        try {
            if (shapeString.equals("rect")) {
                rc = new RectangleRegionContainment(attributes);
            }
            else if (shapeString.equals("circle")) {
                rc = new CircleRegionContainment(attributes);
            }
            else if (shapeString.equals("poly")) {
                rc = new PolygonRegionContainment(attributes);
            }
            else if (shapeString.equals("default")) {
                rc = DefaultRegionContainment.sharedInstance();
            }
        }
        catch (RuntimeException re) {
            // Something wrong with attributes.
            rc = null;
        }
        return rc;
    }
    return null;
}
 
開發者ID:ser316asu,項目名稱:SER316-Ingolstadt,代碼行數:37,代碼來源:AltHTMLWriter.java

示例7: matchNameAttribute

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
/**
 * Returns true if the StyleConstants.NameAttribute is
 * equal to the tag that is passed in as a parameter.
 */
protected boolean matchNameAttribute(AttributeSet attr, HTML.Tag tag) {
    Object o = attr.getAttribute(StyleConstants.NameAttribute);
    if (o instanceof HTML.Tag) {
        HTML.Tag name = (HTML.Tag) o;
        if (name == tag) {
            return true;
        }
    }
    return false;
}
 
開發者ID:ser316asu,項目名稱:Neukoelln_SER316,代碼行數:15,代碼來源:AltHTMLWriter.java

示例8: if

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
/**
 * Creates and returns an instance of RegionContainment that can be
 * used to test if a particular point lies inside a region.
 */
protected RegionContainment createRegionContainment
                              (AttributeSet attributes) {
    Object     shape = attributes.getAttribute(HTML.Attribute.SHAPE);

    if (shape == null) {
        shape = "rect";
    }
    if (shape instanceof String) {
        String                shapeString = ((String)shape).toLowerCase();
        RegionContainment     rc = null;

        try {
            if (shapeString.equals("rect")) {
                rc = new RectangleRegionContainment(attributes);
            }
            else if (shapeString.equals("circle")) {
                rc = new CircleRegionContainment(attributes);
            }
            else if (shapeString.equals("poly")) {
                rc = new PolygonRegionContainment(attributes);
            }
            else if (shapeString.equals("default")) {
                rc = DefaultRegionContainment.sharedInstance();
            }
        } catch (RuntimeException re) {
            // Something wrong with attributes.
            rc = null;
        }
        return rc;
    }
    return null;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:37,代碼來源:Map.java

示例9: containsAttributes

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
@Override
public boolean containsAttributes(AttributeSet attributes) {
    for(Enumeration<?> keys = attributes.getAttributeNames(); keys.hasMoreElements(); ) {
        Object key = keys.nextElement();
        Object value = attributes.getAttribute(key);

        if (!containsAttribute(key, value)) {
            return false;
        }
    }

    return true;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:AttributesUtilities.java

示例10: getName

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
/** Get element name if defined */
public String getName() {
    AttributeSet as = attrs;
    if (as != null && as.isDefined(ElementNameAttribute)) {
        return (String)as.getAttribute(ElementNameAttribute);
    } else {
        return null;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:BaseElement.java

示例11: isBlockTag

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
/**
 * Determines if the HTML.Tag associated with the
 * element is a block tag.
 *
 * @param attr  an AttributeSet
 * @return  true if tag is block tag, false otherwise.
 */
protected boolean isBlockTag(AttributeSet attr) {
    Object o = attr.getAttribute(StyleConstants.NameAttribute);
    if (o instanceof HTML.Tag) {
        HTML.Tag name = (HTML.Tag) o;
        return name.isBlock();
    }
    return false;
}
 
開發者ID:ser316asu,項目名稱:SER316-Aachen,代碼行數:16,代碼來源:AltHTMLWriter.java

示例12: refreshUI

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
private void refreshUI () {
    int index = lCategories.getSelectedIndex ();
    if (index < 0) {
 // no category selected
        cbForeground.setEnabled (false);
        cbBackground.setEnabled (false);
        cbEffectColor.setEnabled (false);
        return;
    }
    cbForeground.setEnabled (true);
    cbBackground.setEnabled (true);
    cbEffectColor.setEnabled (true);
    
    listen = false;
    
    // set defaults
    AttributeSet defAs = getDefaultColoring();
    if (defAs != null) {
        Color inheritedForeground = (Color) defAs.getAttribute(StyleConstants.Foreground);
        if (inheritedForeground == null) {
            inheritedForeground = Color.black;
        }
        ColorComboBoxSupport.setInheritedColor((ColorComboBox)cbForeground, inheritedForeground);
        
        Color inheritedBackground = (Color) defAs.getAttribute(StyleConstants.Background);
        if (inheritedBackground == null) {
            inheritedBackground = Color.white;
        }
        ColorComboBoxSupport.setInheritedColor((ColorComboBox)cbBackground, inheritedBackground);
    }

    // set values
    List<AttributeSet> annotations = getAnnotations (currentScheme);
    AttributeSet c = annotations.get (index);
    ColorComboBoxSupport.setSelectedColor( (ColorComboBox)cbForeground, (Color) c.getAttribute (StyleConstants.Foreground));
    ColorComboBoxSupport.setSelectedColor( (ColorComboBox)cbBackground, (Color) c.getAttribute (StyleConstants.Background));
    if (c.getAttribute(EditorStyleConstants.WaveUnderlineColor) != null) {
        cbEffects.setSelectedIndex(1);
        cbEffectColor.setEnabled(true);
        ((ColorComboBox)cbEffectColor).setSelectedColor((Color) c.getAttribute (EditorStyleConstants.WaveUnderlineColor));
    } else {
        cbEffects.setSelectedIndex(0);
        cbEffectColor.setEnabled(false);
        cbEffectColor.setSelectedIndex(-1);
    } 
    listen = true;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:48,代碼來源:AnnotationsPanel.java

示例13: convertToHTML32

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
/**
 * Create an older style of HTML attributes.  This will
 * convert character level attributes that have a StyleConstants
 * mapping over to an HTML tag/attribute.  Other CSS attributes
 * will be placed in an HTML style attribute.
 */
private static void convertToHTML32(AttributeSet from, MutableAttributeSet to) {
    if (from == null) {
        return;
    }
    Enumeration keys = from.getAttributeNames();
    String value = "";
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        if (key instanceof CSS.Attribute) {
            if ((key == CSS.Attribute.FONT_FAMILY)
                || (key == CSS.Attribute.FONT_SIZE)
                || (key == CSS.Attribute.COLOR)) {

                createFontAttribute((CSS.Attribute) key, from, to);
            }
            else if (key == CSS.Attribute.FONT_WEIGHT) {
                // add a bold tag is weight is bold
                //CSS.FontWeight weightValue = (CSS.FontWeight) from.getAttribute(CSS.Attribute.FONT_WEIGHT);
                String weightValue = from.getAttribute(CSS.Attribute.FONT_WEIGHT).toString();
                if (weightValue != null) {
                    int fweight;
                    try {
                        fweight = new Integer(weightValue).intValue();
                    }
                    catch (Exception ex) {
                        fweight = -1;
                    }
                    if ((weightValue.toLowerCase().equals("bold")) || (fweight > 400))
                        to.addAttribute(HTML.Tag.B, SimpleAttributeSet.EMPTY);
                }
            }
            else if (key == CSS.Attribute.FONT_STYLE) {
                String s = from.getAttribute(key).toString();
                if (s.indexOf("italic") >= 0) {
                    to.addAttribute(HTML.Tag.I, SimpleAttributeSet.EMPTY);
                }
            }
            else if (key == CSS.Attribute.TEXT_DECORATION) {
                String decor = from.getAttribute(key).toString();
                if (decor.indexOf("underline") >= 0) {
                    to.addAttribute(HTML.Tag.U, SimpleAttributeSet.EMPTY);
                }
                if (decor.indexOf("line-through") >= 0) {
                    to.addAttribute(HTML.Tag.STRIKE, SimpleAttributeSet.EMPTY);
                }
            }
            else if (key == CSS.Attribute.VERTICAL_ALIGN) {
                String vAlign = from.getAttribute(key).toString();
                if (vAlign.indexOf("sup") >= 0) {
                    to.addAttribute(HTML.Tag.SUP, SimpleAttributeSet.EMPTY);
                }
                if (vAlign.indexOf("sub") >= 0) {
                    to.addAttribute(HTML.Tag.SUB, SimpleAttributeSet.EMPTY);
                }
            }
            else if (key == CSS.Attribute.TEXT_ALIGN) {
                to.addAttribute(HTML.Attribute.ALIGN, from.getAttribute(key).toString());
            }
            else {
                // default is to store in a HTML style attribute
                if (value.length() > 0) {
                    value = value + "; ";
                }
                value = value + key + ": " + from.getAttribute(key);
            }
        }
        else {
            to.addAttribute(key, from.getAttribute(key));
        }
    }
    if (value.length() > 0) {
        to.addAttribute(HTML.Attribute.STYLE, value);
    }
}
 
開發者ID:ser316asu,項目名稱:Wilmersdorf_SER316,代碼行數:81,代碼來源:AltHTMLWriter.java

示例14: emptyTag

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
/**
 * Writes out all empty elements (all tags that have no
 * corresponding end tag).
 *
 * @param elem   an Element
 * @exception IOException on any I/O error
 * @exception BadLocationException if pos represents an invalid
 *            location within the document.
 */
protected void emptyTag(Element elem) throws BadLocationException, IOException {

    if (!inContent && !inPre) {
        indent();
    }

    AttributeSet attr = elem.getAttributes();
    closeOutUnwantedEmbeddedTags(attr);
    writeEmbeddedTags(attr);

    if (matchNameAttribute(attr, HTML.Tag.CONTENT)) {
        inContent = true;
        text(elem);
    }
    else if (matchNameAttribute(attr, HTML.Tag.COMMENT)) {
        comment(elem);
    }
    else {
        boolean isBlock = isBlockTag(elem.getAttributes());
        if (inContent && isBlock) {
            writeLineSeparator();
            indent();
        }

        Object nameTag = (attr != null) ? attr.getAttribute(StyleConstants.NameAttribute) : null;
        Object endTag = (attr != null) ? attr.getAttribute(HTML.Attribute.ENDTAG) : null;

        boolean outputEndTag = false;
        // If an instance of an UNKNOWN Tag, or an instance of a
        // tag that is only visible during editing
        //
        if (nameTag != null && endTag != null && (endTag instanceof String) && ((String) endTag).equals("true")) {
            outputEndTag = true;
        }

        if (completeDoc && matchNameAttribute(attr, HTML.Tag.HEAD)) {

            if (outputEndTag) {
                // Write out any styles.
                writeStyles(((HTMLDocument) getDocument()).getStyleSheet());
            }
            wroteHead = true;
        }

        write('<');
        if (outputEndTag) {
            write('/');
        }
        write(elem.getName());
        writeAttributes(attr);
        write('>');

        if (matchNameAttribute(attr, HTML.Tag.TITLE) && !outputEndTag) {
            Document doc = elem.getDocument();
            String title = (String) doc.getProperty(Document.TitleProperty);
            write(title);
        }

        else if (!inContent || isBlock) {
            writeLineSeparator();
            if (isBlock && inContent) {
                indent();
            }
        }
    }
}
 
開發者ID:ser316asu,項目名稱:SER316-Ingolstadt,代碼行數:76,代碼來源:AltHTMLWriter.java


注:本文中的javax.swing.text.AttributeSet.getAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。