当前位置: 首页>>代码示例>>Java>>正文


Java AttributeSet类代码示例

本文整理汇总了Java中javax.swing.text.AttributeSet的典型用法代码示例。如果您正苦于以下问题:Java AttributeSet类的具体用法?Java AttributeSet怎么用?Java AttributeSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AttributeSet类属于javax.swing.text包,在下文中一共展示了AttributeSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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,项目名称:Reinickendorf_SER316,代码行数:22,代码来源:AltHTMLWriter.java

示例2: EmbeddedSectionsHighlighting

import javax.swing.text.AttributeSet; //导入依赖的package包/类
EmbeddedSectionsHighlighting(Document document) {
    this.document = document;

    // load the background color for the embedding token
    AttributeSet attribs = null;
    String mimeType = (String) document.getProperty("mimeType"); //NOI18N
    FontColorSettings fcs = MimeLookup.getLookup(mimeType).lookup(FontColorSettings.class);
    if (fcs != null) {
        Color jsBC = getColoring(fcs, YamlTokenId.RUBY.primaryCategory());
        if (jsBC != null) {
            attribs = AttributesUtilities.createImmutable(
                    StyleConstants.Background, jsBC,
                    ATTR_EXTENDS_EOL, Boolean.TRUE);
        }
    }
    rubyBackground = attribs;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:EmbeddedSectionsHighlighting.java

示例3: testAddRightMatchSmallerOverlap

import javax.swing.text.AttributeSet; //导入依赖的package包/类
public void testAddRightMatchSmallerOverlap() {
    PositionsBag hs = new PositionsBag(doc, true);
    SimpleAttributeSet attribsA = new SimpleAttributeSet();
    SimpleAttributeSet attribsB = new SimpleAttributeSet();
    
    attribsA.addAttribute("set-A", "attribsA");
    attribsB.addAttribute("set-B", "attribsB");
    
    hs.addHighlight(pos(10), pos(20), attribsA);
    hs.addHighlight(pos(15), pos(20), attribsB);
    GapList<Position> marks = hs.getMarks();
    GapList<AttributeSet> attributes = hs.getAttributes();
    
    assertEquals("Wrong number of highlights", 3, marks.size());
    assertEquals("1. highlight - wrong start offset", 10, marks.get(0).getOffset());
    assertEquals("1. highlight - wrong end offset", 15, marks.get(1).getOffset());
    assertAttribs("1. highlight - wrong attribs", attributes.get(0), "set-A");
    
    assertEquals("2. highlight - wrong start offset", 15, marks.get(1).getOffset());
    assertEquals("2. highlight - wrong end offset", 20, marks.get(2).getOffset());
    assertAttribs("2. highlight - wrong attribs", attributes.get(1), "set-A", "set-B");
    assertNull("2. highlight - wrong end", attributes.get(2));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:MergingPositionsBagTest.java

示例4: testConcurrentModification

import javax.swing.text.AttributeSet; //导入依赖的package包/类
public void testConcurrentModification() throws Exception {
    PlainDocument doc = new PlainDocument();
    PositionsBag bag = createRandomBag(doc, "layer");
    HighlightsContainer [] layers = new HighlightsContainer [] { bag };
    
    CompoundHighlightsContainer hb = new CompoundHighlightsContainer(doc, layers);
    HighlightsSequence hs = hb.getHighlights(0, Integer.MAX_VALUE);
    
    assertTrue("No highlights", hs.moveNext());
    int s = hs.getStartOffset();
    int e = hs.getEndOffset();
    AttributeSet a = hs.getAttributes();

    // Change the layers
    hb.setLayers(doc, layers);
    
    assertEquals("Different startOffset", s, hs.getStartOffset());
    assertEquals("Different endOffset", e, hs.getEndOffset());
    assertEquals("Different attributes", a, hs.getAttributes());
    
    assertFalse("There should be no further highlighs after co-modification", hs.moveNext());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:CompoundHighlightsContainerTest.java

示例5: getCurrentColors

import javax.swing.text.AttributeSet; //导入依赖的package包/类
private static Map getCurrentColors(Language l) {
    // current colors
    FontColorSettingsFactory fcsf = EditorSettings.getDefault().
            getFontColorSettings(new String[] {l.getMimeType()});
    Collection<AttributeSet> colors = fcsf.getAllFontColors("NetBeans");
    Map<String,AttributeSet> colorsMap = new HashMap<String,AttributeSet> ();
    Iterator<AttributeSet> it = colors.iterator();
    while (it.hasNext()) {
        AttributeSet as = it.next();
        colorsMap.put(
                (String) as.getAttribute(StyleConstants.NameAttribute),
                as
                );
    }
    return colorsMap;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ColorsManager.java

示例6: replace

import javax.swing.text.AttributeSet; //导入依赖的package包/类
@Override
public void replace(FilterBypass fb, int offset, int length, String text,
      AttributeSet attrs) throws BadLocationException {

   Document doc = fb.getDocument();
   StringBuilder sb = new StringBuilder();
   sb.append(doc.getText(0, doc.getLength()));
   sb.replace(offset, offset + length, text);

   if (test(sb.toString())) {
      super.replace(fb, offset, length, text, attrs);
   } else {
 	  	 JOptionPane.showMessageDialog(null,  "STOP ! You're only allowed to encode numbers !", "Warning", JOptionPane.ERROR_MESSAGE);
   }

}
 
开发者ID:cetic,项目名称:SimQRI,代码行数:17,代码来源:IntFilter.java

示例7: testRemoveLeftOverlapClip

import javax.swing.text.AttributeSet; //导入依赖的package包/类
public void testRemoveLeftOverlapClip() {
    PositionsBag hs = new PositionsBag(doc);
    SimpleAttributeSet attribsA = new SimpleAttributeSet();
    
    attribsA.addAttribute("set-name", "attribsA");
    
    hs.addHighlight(pos(10), pos(20), attribsA);
    hs.removeHighlights(pos(5), pos(15), true);
    GapList<Position> marks = hs.getMarks();
    GapList<AttributeSet> atttributes = hs.getAttributes();
    
    assertEquals("Wrong number of highlights", 2, marks.size());
    assertEquals("1. highlight - wrong start offset", 15, marks.get(0).getOffset());
    assertEquals("1. highlight - wrong end offset", 20, marks.get(1).getOffset());
    assertEquals("1. highlight - wrong attribs", "attribsA", atttributes.get(0).getAttribute("set-name"));
    assertNull("  1. highlight - wrong end", atttributes.get(1));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:PositionsBagTest.java

示例8: VersioningSystemColors

import javax.swing.text.AttributeSet; //导入依赖的package包/类
public VersioningSystemColors(OptionsPanelColorProvider provider) {
    this.colors = provider.getColors();
    if (colors == null) {
        throw new NullPointerException("Null colors for " + provider); // NOI18N
    }
    this.provider = provider;
    // initialize saved colors list
    savedColorAttributes = new ArrayList<AttributeSet>(colors.size());
    for (Map.Entry<String, Color[]> e : colors.entrySet()) {
        SimpleAttributeSet sas = new SimpleAttributeSet();
        StyleConstants.setBackground(sas, e.getValue()[0]);
        sas.addAttribute(StyleConstants.NameAttribute, e.getKey());
        sas.addAttribute(EditorStyleConstants.DisplayName, e.getKey());
        savedColorAttributes.add(sas);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:AnnotationColorsPanel.java

示例9: getAttribute

import javax.swing.text.AttributeSet; //导入依赖的package包/类
@Override public String getAttribute(final String name) {
    if ("text".equals(name)) {
        return getText();
    }
    if ("hRefIndex".equals(name)) {
        return getHRefIndex() + "";
    }
    if ("textIndex".equals(name)) {
        return getTextIndex() + "";
    }
    return EventQueueWait.exec(new Callable<String>() {
        @Override public String call() throws Exception {
            Iterator iterator = findTag((HTMLDocument) ((JEditorPane) parent.getComponent()).getDocument());
            AttributeSet attributes = iterator.getAttributes();
            Attribute attr = findAttribute(name);
            if (attr != null && attributes.isDefined(attr)) {
                return attributes.getAttribute(attr).toString();
            }
            return null;
        }
    });
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:23,代码来源:JEditorPaneTagJavaElement.java

示例10: applyChanges

import javax.swing.text.AttributeSet; //导入依赖的package包/类
@Override
public void applyChanges() {
    if (colorModel == null) return;
    for(String profile : toBeSaved.keySet()) {
        Set<String> toBeSavedLanguages = toBeSaved.get(profile);
        Map<String, List<AttributeSet>> schemeMap = profiles.get(profile);
        for(String languageName : toBeSavedLanguages) {
            colorModel.setCategories(
                profile,
                languageName,
                schemeMap.get(languageName)
            );
        }
    }
    toBeSaved = new HashMap<String, Set<String>>();
    profiles = new HashMap<String, Map<String, List<AttributeSet>>>();
    changed = false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:SyntaxColoringPanel.java

示例11: findAttribs

import javax.swing.text.AttributeSet; //导入依赖的package包/类
private AttributeSet findAttribs(TokenItem tokenItem) {
    synchronized (this) {
        AttributeSet attribs = attribsCache.get(tokenItem.getTokenID());

        if (attribs == null) {
            FontColorSettings fcs = MimeLookup.getLookup(mimePath).lookup(FontColorSettings.class);
            if (fcs != null) {
                attribs = findFontAndColors(fcs, tokenItem);
                if (attribs == null) {
                    attribs = SimpleAttributeSet.EMPTY;
                }
                
                attribsCache.put(tokenItem.getTokenID(), attribs);
            } else {
                LOG.warning("Can't find FCS for mime path: '" + mimePath.getPath() + "'"); //NOI18N
            }
        }

        return attribs == null ? SimpleAttributeSet.EMPTY : attribs;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:NonLexerSyntaxHighlighting.java

示例12: getListCellRendererComponent

import javax.swing.text.AttributeSet; //导入依赖的package包/类
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    setComponentOrientation(list.getComponentOrientation());
    if (isSelected) {
        setBackground(list.getSelectionBackground ());
        setForeground(list.getSelectionForeground ());
    } else {
        setBackground(list.getBackground ());
        setForeground(list.getForeground ());
    }
    setIcon((Icon) ((AttributeSet) value).getAttribute ("icon"));
    setText((String) ((AttributeSet) value).getAttribute (EditorStyleConstants.DisplayName));

    setEnabled(list.isEnabled());
    setFont(list.getFont());
    setBorder(cellHasFocus ? UIManager.getBorder ("List.focusCellHighlightBorder") : noFocusBorder);
    return this;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:CategoryRenderer.java

示例13: CircleRegionContainment

import javax.swing.text.AttributeSet; //导入依赖的package包/类
public CircleRegionContainment(AttributeSet as) {
    int[] coords = extractCoords(as.getAttribute(HTML.Attribute.COORDS));

    if (coords == null || coords.length != 3) {
        throw new RuntimeException("Unable to parse circular area");
    }
    x = coords[0];
    y = coords[1];
    radiusSquared = coords[2] * coords[2];
    if (coords[0] < 0 || coords[1] < 0 || coords[2] < 0) {
        lastWidth = lastHeight = -1;
        percentValues = new float[3];
        for (int counter = 0; counter < 3; counter++) {
            if (coords[counter] < 0) {
                percentValues[counter] = coords[counter] / -100.0f;
            }
            else {
                percentValues[counter] = -1.0f;
            }
        }
    }
    else {
        percentValues = null;
    }
}
 
开发者ID:ser316asu,项目名称:SER316-Munich,代码行数:26,代码来源:AltHTMLWriter.java

示例14: testConcurrentModification

import javax.swing.text.AttributeSet; //导入依赖的package包/类
public void testConcurrentModification() {
    PositionsBag hb = new PositionsBag(doc);

    // Modify the bag
    hb.addHighlight(pos(5), pos(10), EMPTY);
    hb.addHighlight(pos(15), pos(20), EMPTY);
    hb.addHighlight(pos(25), pos(30), EMPTY);
    
    HighlightsSequence hs = hb.getHighlights(Integer.MIN_VALUE, Integer.MAX_VALUE);
    assertTrue("There should be some highlights", hs.moveNext());
    
    int s = hs.getStartOffset();
    int e = hs.getEndOffset();
    AttributeSet a = hs.getAttributes();
    
    // Modification after the sequence was acquired
    hb.addHighlight(pos(100), pos(110), EMPTY);
    
    assertEquals("Wrong highlight start", s, hs.getStartOffset());
    assertEquals("Wrong highlight end", e, hs.getEndOffset());
    assertEquals("Wrong highlight attributes", a, hs.getAttributes());
    assertFalse("There should be no more highlights after co-modification", hs.moveNext());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:PositionsBagTest.java

示例15: testAddCompleteMatchOverlap

import javax.swing.text.AttributeSet; //导入依赖的package包/类
public void testAddCompleteMatchOverlap() {
    PositionsBag hs = new PositionsBag(doc, true);
    SimpleAttributeSet attribsA = new SimpleAttributeSet();
    SimpleAttributeSet attribsB = new SimpleAttributeSet();
    
    attribsA.addAttribute("set-A", "attribsA");
    attribsB.addAttribute("set-B", "attribsB");
    
    hs.addHighlight(pos(10), pos(20), attribsA);
    hs.addHighlight(pos(10), pos(20), attribsB);
    GapList<Position> marks = hs.getMarks();
    GapList<AttributeSet> attributes = hs.getAttributes();
    
    assertEquals("Wrong number of highlights", 2, marks.size());
    assertEquals("1. highlight - wrong start offset", 10, marks.get(0).getOffset());
    assertEquals("1. highlight - wrong end offset", 20, marks.get(1).getOffset());
    assertAttribs("1. highlight - wrong attribs", attributes.get(0), "set-A", "set-B");
    assertNull("1. highlight - wrong end", attributes.get(1));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:MergingPositionsBagTest.java


注:本文中的javax.swing.text.AttributeSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。