private static Color getColoring(FontColorSettings fcs, String tokenName) { AttributeSet as = fcs.getTokenFontColors(tokenName); if (as != null) { return (Color) as.getAttribute(StyleConstants.Background); //NOI18N } return null; }
@Override public AttributeSet getColor(Entity color) { synchronized(lock) { final AttributeSet tokenFontColors = fcs.getTokenFontColors(color.getResourceName()); assert tokenFontColors != null : "There is no color for "+color.getResourceName(); return tokenFontColors; } }
private AttributeSet findFontAndColors(FontColorSettings fcs, TokenId tokenId, Language lang) { // First try the token's name String name = tokenId.name(); AttributeSet attribs = fcs.getTokenFontColors(updateColoringName(name)); // Then try the primary category if (attribs == null) { String primary = tokenId.primaryCategory(); if (primary != null) { attribs = fcs.getTokenFontColors(updateColoringName(primary)); } } // Then try all the other categories if (attribs == null) { @SuppressWarnings("unchecked") //NOI18N List<String> categories = ((Language<TokenId>)lang).nonPrimaryTokenCategories(tokenId); for(String c : categories) { attribs = fcs.getTokenFontColors(updateColoringName(c)); if (attribs != null) { break; } } } return attribs; }
AttributeSet colors = fcs.getTokenFontColors(key);
public HeadersHighlighting(Document document) { this.document = document; this.document.putProperty(PROP_HIGLIGHT_HEADER_LAYER, this); FontColorSettings settings = MimeLookup.getLookup("text/x-java-preprocessor").lookup(FontColorSettings.class); //NOI18N commandHighlight = settings.getTokenFontColors("pp-command"); //NOI18N if (commandHighlight != null) { headersBag = new OffsetsBag(document); headersBag.addHighlightsChangeListener(new HighlightsChangeListener() { public void highlightChanged(HighlightsChangeEvent event) { fireHighlightsChange(event.getStartOffset(), event.getEndOffset()); } }); updateBags(); } else { headersBag = null; } }
public static String getHtml(String text) { StringBuffer buf = new StringBuffer(); // TODO - check whether we need Js highlighting or rhtml highlighting TokenHierarchy tokenH = TokenHierarchy.create(text, JsTokenId.language()); Lookup lookup = MimeLookup.getLookup(MimePath.get(JsTokenId.JAVASCRIPT_MIME_TYPE)); FontColorSettings settings = lookup.lookup(FontColorSettings.class); @SuppressWarnings("unchecked") TokenSequence<? extends TokenId> tok = tokenH.tokenSequence(); while (tok.moveNext()) { Token<? extends TokenId> token = tok.token(); String category = token.id().name(); AttributeSet set = settings.getTokenFontColors(category); if (set == null) { category = token.id().primaryCategory(); if (category == null) { category = "whitespace"; //NOI18N } set = settings.getTokenFontColors(category); } String tokenText = htmlize(token.text().toString()); buf.append(color(tokenText, set)); } return buf.toString(); }
AttributeSet as = settings.getTokenFontColors("pp-active-block"); //NOI18N if (as != null) { activeBlockHighlight = AttributesUtilities.createImmutable(as, extendsEolEmptyLine); activeBlockHighlight = null; as = settings.getTokenFontColors("pp-inactive-block"); //NOI18N if (as != null) { inactiveBlockHighlight = AttributesUtilities.createImmutable(as, extendsEolEmptyLine);
AttributeSet attribs = fcs.getTokenFontColors("default"); // NOI18N Color fg = (Color)attribs.getAttribute(StyleConstants.Foreground); if (fg != null) { AttributeSet attribs = fcs.getTokenFontColors(category); String escapedText = tokenText; try { attribs = fcs.getTokenFontColors(category);
AttributeSet set = settings.getTokenFontColors(category); buf.append(addHTMLColor(htmlize(text), set)); } else {