本文整理匯總了Java中javax.swing.text.SimpleAttributeSet.EMPTY屬性的典型用法代碼示例。如果您正苦於以下問題:Java SimpleAttributeSet.EMPTY屬性的具體用法?Java SimpleAttributeSet.EMPTY怎麽用?Java SimpleAttributeSet.EMPTY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類javax.swing.text.SimpleAttributeSet
的用法示例。
在下文中一共展示了SimpleAttributeSet.EMPTY屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createImmutable
/**
* Creates an immutable <code>AttributeSet</code> as a copy of <code>AttributeSet</code>s
* passed into this method. If the <code>AttributeSet</code>s
* contain attributes with the same name the resulting <code>AttributeSet</code>
* will return value of the first attribute it will find going through
* the sets in the order as they were passed in.
*
* @param sets The <code>AttributeSet</code>s which attributes will become
* a contents of the newly created <code>AttributeSet</code>.
*
* @return The new immutable <code>AttributeSet</code>.
*/
public static AttributeSet createImmutable(AttributeSet... sets) {
if (true) {
return org.netbeans.modules.editor.settings.AttrSet.merge(sets);
}
HashMap<Object, Object> map = new HashMap<Object, Object>();
for(int i = sets.length - 1; i >= 0; i--) {
AttributeSet set = sets[i];
for(Enumeration<?> keys = set.getAttributeNames(); keys.hasMoreElements(); ) {
Object attrKey = keys.nextElement();
Object attrValue = set.getAttribute(attrKey);
map.put(attrKey, attrValue);
}
}
return map.size() > 0 ? new Immutable(map) : SimpleAttributeSet.EMPTY;
}
示例2: setAttrs
void setAttrs(Lookup.Result<FontColorSettings> result) {
if (Boolean.TRUE.equals(component.getClientProperty("AsTextField"))) {
if (UIManager.get("TextField.selectionBackground") != null) {
attribs = AttributesUtilities.createImmutable(
StyleConstants.Background, (Color) UIManager.get("TextField.selectionBackground"),
StyleConstants.Foreground, (Color) UIManager.get("TextField.selectionForeground"));
} else {
final JTextField referenceTextField = (JTextField) new JComboBox<String>().getEditor().getEditorComponent();
attribs = AttributesUtilities.createImmutable(
StyleConstants.Background, referenceTextField.getSelectionColor(),
StyleConstants.Foreground, referenceTextField.getSelectedTextColor());
}
return;
}
FontColorSettings fcs = result.allInstances().iterator().next();
attribs = fcs.getFontColors(coloringName);
if (attribs == null) {
attribs = SimpleAttributeSet.EMPTY;
} else if (extendsEOL || extendsEmptyLine) {
attribs = AttributesUtilities.createImmutable(
attribs,
AttributesUtilities.createImmutable(
ATTR_EXTENDS_EOL, Boolean.valueOf(extendsEOL),
ATTR_EXTENDS_EMPTY_LINE, Boolean.valueOf(extendsEmptyLine)));
}
}
示例3: getAttribs
private AttributeSet getAttribs(String coloringName, boolean extendsEol, boolean extendsEmptyLine) {
FontColorSettings fcs = MimeLookup.getLookup(getMimeType(component)).lookup(FontColorSettings.class);
AttributeSet attribs = fcs.getFontColors(coloringName);
if (attribs == null) {
attribs = SimpleAttributeSet.EMPTY;
} else if (extendsEol || extendsEmptyLine) {
attribs = AttributesUtilities.createImmutable(
attribs,
AttributesUtilities.createImmutable(
ATTR_EXTENDS_EOL, Boolean.valueOf(extendsEol),
ATTR_EXTENDS_EMPTY_LINE, Boolean.valueOf(extendsEmptyLine))
);
}
return attribs;
}
示例4: getAttribs
private AttributeSet getAttribs(String coloringName, boolean extendsEol, boolean extendsEmptyLine) {
FontColorSettings fcs = MimeLookup.getLookup(mimeType).lookup(FontColorSettings.class);
AttributeSet attribs = fcs.getFontColors(coloringName);
if (attribs == null) {
attribs = SimpleAttributeSet.EMPTY;
} else if (extendsEol || extendsEmptyLine) {
attribs = AttributesUtilities.createImmutable(
attribs,
AttributesUtilities.createImmutable(
ATTR_EXTENDS_EOL, Boolean.valueOf(extendsEol),
ATTR_EXTENDS_EMPTY_LINE, Boolean.valueOf(extendsEmptyLine))
);
}
return attribs;
}
示例5: translateAttributes
private AttributeSet translateAttributes(Map<AttributedCharacterIterator.Attribute, ?> source) {
for(AttributedCharacterIterator.Attribute sourceKey : source.keySet()) {
Object sourceValue = source.get(sourceKey);
// Ignore any non-input method related highlights
if (!(sourceValue instanceof InputMethodHighlight)) {
continue;
}
InputMethodHighlight imh = (InputMethodHighlight) sourceValue;
if (imh.isSelected()) {
return highlightInverse;
} else {
return highlightUnderlined;
}
}
LOG.fine("No translation for " + source);
return SimpleAttributeSet.EMPTY;
}
示例6: findAttribs
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;
}
}
示例7: createComposite
/**
* Creates a proxy <code>AttributeSet</code> that will delegate to the
* <code>AttributeSet</code>s passed in as a parameter. If the <code>AttributeSet</code>s
* contain attributes with the same name the composite <code>AttributeSet</code>
* will return value of the first attribute it will find going through
* the sets in the order as they were passed in.
*
* @param sets The <code>AttributeSet</code>s to delegate to.
*
* @return The new composite <code>AttributeSet</code> that will delegate
* to the <code>sets</code> passed in.
*/
public static AttributeSet createComposite(AttributeSet... sets) {
if (true) {
return org.netbeans.modules.editor.settings.AttrSet.merge(sets);
}
if (sets.length == 0) {
return SimpleAttributeSet.EMPTY;
} else if (sets.length == 1) {
return sets[0];
} else {
LinkedList<AttributeSet> all = new LinkedList<AttributeSet>();
for(AttributeSet s : sets) {
if (s instanceof AttributesUtilities.CompositeAttributeSet) {
all.addAll(((AttributesUtilities.CompositeAttributeSet) s).getDelegates());
} else if (s != null && s != SimpleAttributeSet.EMPTY) {
all.add(s);
}
}
switch (all.size()) {
case 0: return SimpleAttributeSet.EMPTY;
case 1: return all.get(0);
case 2: return new Composite2(all.get(0), all.get(1));
case 3: return new Composite4(all.get(0), all.get(1), all.get(2), null);
case 4: return new Composite4(all.get(0), all.get(1), all.get(2), all.get(3));
default: return new BigComposite(all);
}
}
}
示例8: firstItemAttrs
private AttributeSet firstItemAttrs() {
AttributeSet attrs = highlightItems[0].getAttributes();
if (attrs == null) {
attrs = SimpleAttributeSet.EMPTY;
}
return attrs;
}
示例9: BracesMatchHighlighting
public BracesMatchHighlighting(JTextComponent component, Document document) {
this.document = document;
String mimeType = getMimeType(component);
MimePath mimePath = mimeType == null ? MimePath.EMPTY : MimePath.parse(mimeType);
// Load the colorings
FontColorSettings fcs = MimeLookup.getLookup(mimePath).lookup(FontColorSettings.class);
AttributeSet match = fcs.getFontColors(BRACES_MATCH_COLORING);
AttributeSet mismatch = fcs.getFontColors(BRACES_MISMATCH_COLORING);
AttributeSet matchMultichar = fcs.getFontColors(BRACES_MATCH_MULTICHAR_COLORING);
AttributeSet mismatchMultichar = fcs.getFontColors(BRACES_MISMATCH_MULTICHAR_COLORING);
this.bracesMatchColoring = match != null ? match : SimpleAttributeSet.EMPTY;
this.bracesMismatchColoring = mismatch != null ? mismatch : SimpleAttributeSet.EMPTY;
this.bracesMatchMulticharColoring = matchMultichar != null ? matchMultichar : SimpleAttributeSet.EMPTY;
this.bracesMismatchMulticharColoring = mismatchMultichar != null ? mismatchMultichar : SimpleAttributeSet.EMPTY;
// Create and hook up the highlights bag
this.bag = new OffsetsBag(document, true);
this.bag.addHighlightsChangeListener(this);
// Hook up the component
this.component = component;
this.component.addPropertyChangeListener(WeakListeners.propertyChange(this, this.component));
// Hook up the caret
this.caret = component.getCaret();
if (this.caret != null) {
this.caretListener = WeakListeners.change(this, this.caret);
this.caret.addChangeListener(caretListener);
}
// Refresh the layer
refresh();
}
示例10: testAreas
public void testAreas() throws Exception {
MockServices.setServices(MockMimeLookup.class);
MockMimeLookup.setInstances(MimePath.EMPTY, new TestMatcher());
AttributeSet EAS = SimpleAttributeSet.EMPTY;
JEditorPane c = new JEditorPane();
Document d = c.getDocument();
OffsetsBag bag = new OffsetsBag(d);
d.insertString(0, "text text { text } text", null);
c.putClientProperty(MasterMatcher.PROP_MAX_BACKWARD_LOOKAHEAD, 256);
c.putClientProperty(MasterMatcher.PROP_MAX_FORWARD_LOOKAHEAD, 256);
TestMatcher.origin = new int [] { 2, 3 };
TestMatcher.matches = new int [] { 10, 11 };
MasterMatcher.get(c).highlight(d, 7, bag, EAS, EAS, EAS, EAS);
TestMatcher.waitUntilCreated(1000);
{
TestMatcher tm = TestMatcher.lastMatcher;
assertNotNull("No matcher created", tm);
HighlightsSequence hs = bag.getHighlights(0, Integer.MAX_VALUE);
assertTrue("Wrong number of highlighted areas", hs.moveNext());
assertEquals("Wrong origin startOfset", 2, hs.getStartOffset());
assertEquals("Wrong origin endOfset", 3, hs.getEndOffset());
assertTrue("Wrong number of highlighted areas", hs.moveNext());
assertEquals("Wrong match startOfset", 10, hs.getStartOffset());
assertEquals("Wrong match endOfset", 11, hs.getEndOffset());
}
}
示例11: getAttributes
public AttributeSet getAttributes() {
synchronized (GuardedBlocksHighlighting.this) {
if (!init) {
throw new NoSuchElementException("Call moveNext() first."); //NOI18N
} else if (block == null) {
throw new NoSuchElementException();
}
if (attribs == null) {
FontColorSettings fcs = MimeLookup.getLookup(mimePath).lookup(FontColorSettings.class);
if (fcs != null) {
attribs = fcs.getFontColors(FontColorNames.GUARDED_COLORING);
}
if (attribs == null) {
attribs = SimpleAttributeSet.EMPTY;
} else {
attribs = AttributesUtilities.createImmutable(
attribs,
EXTENDS_EOL_ATTR_SET
);
}
}
return attribs;
}
}
示例12: getAttributes
public AttributeSet getAttributes() {
AttributeSet as = attributes;
return as == null ? SimpleAttributeSet.EMPTY : as;
}
示例13: getAttributes
/** Get attributes of this element */
public AttributeSet getAttributes() {
AttributeSet as = attrs;
return as == null ? SimpleAttributeSet.EMPTY : as;
}
示例14: getAttribs
private AttributeSet getAttribs() {
FontColorSettings fcs = MimeLookup.getLookup(mimePath).lookup(FontColorSettings.class);
AttributeSet attribs = fcs.getFontColors(FontColorNames.HIGHLIGHT_SEARCH_COLORING);
return attribs == null ? SimpleAttributeSet.EMPTY : attribs;
}
示例15: getAttributes
@Override
public AttributeSet getAttributes() {
return (element != null)
? layer.getColoring(element.coloring, element.language)
: SimpleAttributeSet.EMPTY;
}