本文整理匯總了Java中com.intellij.openapi.editor.markup.TextAttributes.setForegroundColor方法的典型用法代碼示例。如果您正苦於以下問題:Java TextAttributes.setForegroundColor方法的具體用法?Java TextAttributes.setForegroundColor怎麽用?Java TextAttributes.setForegroundColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.openapi.editor.markup.TextAttributes
的用法示例。
在下文中一共展示了TextAttributes.setForegroundColor方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTextAttributes
import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
@Nullable
@Override
public TextAttributes getTextAttributes(@NotNull EditorColorsScheme scheme, @NotNull ArrangementSettingsToken token, boolean selected) {
if (selected) {
TextAttributes attributes = new TextAttributes();
attributes.setForegroundColor(scheme.getColor(EditorColors.SELECTION_FOREGROUND_COLOR));
attributes.setBackgroundColor(scheme.getColor(EditorColors.SELECTION_BACKGROUND_COLOR));
return attributes;
}
else if (SUPPORTED_TYPES.contains(token)) {
return getAttributes(scheme, JavaHighlightingColors.KEYWORD);
}
else if (SUPPORTED_MODIFIERS.contains(token)) {
getAttributes(scheme, JavaHighlightingColors.KEYWORD);
}
return null;
}
示例2: update
import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
@Override
public void update(PresentationData presentation) {
String newName = getValue().getName();
int nameEndOffset = newName.length();
int todoItemCount = getTodoItemCount(getValue());
int fileCount = getFileCount(getValue());
newName = IdeBundle.message("node.todo.group", newName, todoItemCount, fileCount);
myHighlightedRegions.clear();
TextAttributes textAttributes = new TextAttributes();
if (CopyPasteManager.getInstance().isCutElement(getValue())) {
textAttributes.setForegroundColor(CopyPasteManager.CUT_COLOR);
}
myHighlightedRegions.add(new HighlightedRegion(0, nameEndOffset, textAttributes));
EditorColorsScheme colorsScheme = UsageTreeColorsScheme.getInstance().getScheme();
myHighlightedRegions.add(
new HighlightedRegion(nameEndOffset, newName.length(), colorsScheme.getAttributes(UsageTreeColors.NUMBER_OF_USAGES)));
presentation.setIcon(ModuleType.get(getValue()).getIcon());
presentation.setPresentableText(newName);
}
示例3: getAttributes
import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
@Nullable
private static TextAttributes getAttributes(@NotNull EditorColorsScheme scheme, @NotNull TextAttributesKey ... keys) {
TextAttributes result = null;
for (TextAttributesKey key : keys) {
TextAttributes attributes = scheme.getAttributes(key);
if (attributes == null) {
continue;
}
if (result == null) {
result = attributes;
}
Color currentForegroundColor = result.getForegroundColor();
if (currentForegroundColor == null) {
result.setForegroundColor(attributes.getForegroundColor());
}
Color currentBackgroundColor = result.getBackgroundColor();
if (currentBackgroundColor == null) {
result.setBackgroundColor(attributes.getBackgroundColor());
}
if (result.getForegroundColor() != null && result.getBackgroundColor() != null) {
return result;
}
}
if (result != null && result.getForegroundColor() == null) {
return null;
}
if (result != null && result.getBackgroundColor() == null) {
result.setBackgroundColor(scheme.getDefaultBackground());
}
return result;
}
示例4: addColorToSimpleTextAttributes
import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
private static SimpleTextAttributes addColorToSimpleTextAttributes(SimpleTextAttributes simpleTextAttributes, Color color) {
if (color != null) {
final TextAttributes textAttributes = simpleTextAttributes.toTextAttributes();
textAttributes.setForegroundColor(color);
simpleTextAttributes = SimpleTextAttributes.fromTextAttributes(textAttributes);
}
return simpleTextAttributes;
}
示例5: getTextAttributes
import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
@Override
public TextAttributes getTextAttributes() {
if (myTextAttributes == null) {
TextAttributes textAttributes = new TextAttributes();
EditorColorsScheme scheme = myEditor.getColorsScheme();
textAttributes.setForegroundColor(scheme.getColor(EditorColors.SELECTION_FOREGROUND_COLOR));
textAttributes.setBackgroundColor(scheme.getColor(EditorColors.SELECTION_BACKGROUND_COLOR));
myTextAttributes = textAttributes;
}
return myTextAttributes;
}
示例6: getGrayedHyperlinkAttributes
import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
@Nullable
private static TextAttributes getGrayedHyperlinkAttributes(@NotNull TextAttributesKey normalHyperlinkAttrsKey) {
EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();
TextAttributes grayedHyperlinkAttrs = GRAYED_BY_NORMAL_CACHE.get(normalHyperlinkAttrsKey);
if (grayedHyperlinkAttrs == null) {
TextAttributes normalHyperlinkAttrs = globalScheme.getAttributes(normalHyperlinkAttrsKey);
if (normalHyperlinkAttrs != null) {
grayedHyperlinkAttrs = normalHyperlinkAttrs.clone();
grayedHyperlinkAttrs.setForegroundColor(UIUtil.getInactiveTextColor());
grayedHyperlinkAttrs.setEffectColor(UIUtil.getInactiveTextColor());
GRAYED_BY_NORMAL_CACHE.put(normalHyperlinkAttrsKey, grayedHyperlinkAttrs);
}
}
return grayedHyperlinkAttrs;
}
示例7: patchAttributesColor
import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
/**
* Patches attributes to be visible under debugger active line
*/
@SuppressWarnings("UseJBColor")
public static TextAttributes patchAttributesColor(TextAttributes attributes, @NotNull TextRange range, @NotNull Editor editor) {
MarkupModel model = DocumentMarkupModel.forDocument(editor.getDocument(), editor.getProject(), false);
if (model != null) {
if (!((MarkupModelEx)model).processRangeHighlightersOverlappingWith(range.getStartOffset(), range.getEndOffset(),
new Processor<RangeHighlighterEx>() {
@Override
public boolean process(RangeHighlighterEx highlighter) {
if (highlighter.isValid() && highlighter.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE) {
TextAttributes textAttributes = highlighter.getTextAttributes();
if (textAttributes != null) {
Color color = textAttributes.getBackgroundColor();
return !(color != null && color.getBlue() > 128 && color.getRed() < 128 && color.getGreen() < 128);
}
}
return true;
}
})) {
TextAttributes clone = attributes.clone();
clone.setForegroundColor(Color.orange);
clone.setEffectColor(Color.orange);
return clone;
}
}
return attributes;
}
示例8: setInheritedAttributes
import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
private void setInheritedAttributes(@NotNull TextAttributes attributes) {
attributes.setFontType(myFallbackAttributes.getFontType());
attributes.setForegroundColor(myFallbackAttributes.getForegroundColor());
attributes.setBackgroundColor(myFallbackAttributes.getBackgroundColor());
attributes.setErrorStripeColor(myFallbackAttributes.getErrorStripeColor());
attributes.setEffectColor(myFallbackAttributes.getEffectColor());
attributes.setEffectType(myFallbackAttributes.getEffectType());
}
示例9: updateImpl
import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
@Override
protected void updateImpl(PresentationData data) {
super.updateImpl(data);
int fileCount = getFileCount(getValue());
if (getValue() == null || !getValue().isValid() || fileCount == 0) {
setValue(null);
return;
}
VirtualFile directory = getValue().getVirtualFile();
boolean isProjectRoot = !ProjectRootManager.getInstance(getProject()).getFileIndex().isInContent(directory);
String newName = isProjectRoot || getStructure().getIsFlattenPackages() ? getValue().getVirtualFile().getPresentableUrl() : getValue().getName();
int nameEndOffset = newName.length();
int todoItemCount = getTodoItemCount(getValue());
newName = IdeBundle.message("node.todo.group", newName, todoItemCount, fileCount);
myHighlightedRegions.clear();
TextAttributes textAttributes = new TextAttributes();
Color newColor = FileStatusManager.getInstance(getProject()).getStatus(getValue().getVirtualFile()).getColor();
if (CopyPasteManager.getInstance().isCutElement(getValue())) {
newColor = CopyPasteManager.CUT_COLOR;
}
textAttributes.setForegroundColor(newColor);
myHighlightedRegions.add(new HighlightedRegion(0, nameEndOffset, textAttributes));
EditorColorsScheme colorsScheme = UsageTreeColorsScheme.getInstance().getScheme();
myHighlightedRegions.add(
new HighlightedRegion(nameEndOffset, newName.length(), colorsScheme.getAttributes(UsageTreeColors.NUMBER_OF_USAGES)));
data.setPresentableText(newName);
}
示例10: updateImpl
import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
@Override
protected void updateImpl(PresentationData data) {
super.updateImpl(data);
String newName;
if(myBuilder.getTodoTreeStructure().isPackagesShown()){
newName=getValue().getName();
}else{
newName=mySingleFileMode ? getValue().getName() : getValue().getVirtualFile().getPresentableUrl();
}
int nameEndOffset=newName.length();
int todoItemCount;
try {
todoItemCount = myBuilder.getTodoTreeStructure().getTodoItemCount(getValue());
}
catch (IndexNotReadyException e) {
return;
}
if(mySingleFileMode){
if(todoItemCount==0){
newName = IdeBundle.message("node.todo.no.items.found", newName);
} else {
newName = IdeBundle.message("node.todo.found.items", newName, todoItemCount);
}
}else{
newName = IdeBundle.message("node.todo.items", newName, todoItemCount);
}
myHighlightedRegions.clear();
TextAttributes textAttributes=new TextAttributes();
textAttributes.setForegroundColor(myColor);
myHighlightedRegions.add(new HighlightedRegion(0,nameEndOffset,textAttributes));
EditorColorsScheme colorsScheme=UsageTreeColorsScheme.getInstance().getScheme();
myHighlightedRegions.add(
new HighlightedRegion(nameEndOffset,newName.length(),colorsScheme.getAttributes(UsageTreeColors.NUMBER_OF_USAGES))
);
}
示例11: createCompilationErrorAttr
import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
private static TextAttributes createCompilationErrorAttr() {
TextAttributes attr = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.HYPERLINK_ATTRIBUTES).clone();
attr.setForegroundColor(JBColor.RED);
attr.setEffectColor(JBColor.RED);
attr.setEffectType(EffectType.LINE_UNDERSCORE);
attr.setFontType(Font.PLAIN);
return attr;
}
示例12: apply
import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
@Override
public void apply(@NotNull TextAttributes ta) {
int fontType = Font.PLAIN;
if (myCbBold.isSelected()) {
fontType |= Font.BOLD;
}
if (myCbItalic.isSelected()) {
fontType |= Font.ITALIC;
}
ta.setFontType(fontType);
if (myCbForeground.isSelected()) {
ta.setForegroundColor(myForegroundChooser.getSelectedColor());
} else {
ta.setForegroundColor(null);
}
if (myCbBackground.isSelected()) {
ta.setBackgroundColor(myBackgroundChooser.getSelectedColor());
} else {
ta.setBackgroundColor(null);
}
if (myCbErrorStripe.isSelected()) {
ta.setErrorStripeColor(myErrorStripeColorChooser.getSelectedColor());
} else {
ta.setErrorStripeColor(null);
}
if (myCbEffects.isSelected()) {
Color effectColor = myEffectsColorChooser.getSelectedColor();
ta.setEffectColor(effectColor);
//noinspection SuspiciousMethodCalls
if (effectColor == null) {
ta.setEffectType(null);
} else {
//noinspection SuspiciousMethodCalls
ta.setEffectType(myEffectsMap.get(myEffectsCombo.getModel().getSelectedItem()));
}
} else {
ta.setEffectColor(null);
ta.setEffectType(null);
}
}
示例13: execute
import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
public void execute(final String line, final int textEndOffset) {
myResult = null;
myInfo = parseExceptionLine(line);
if (myInfo == null) {
return;
}
myMethod = myInfo.getSecond().substring(line);
final int lparenthIndex = myInfo.third.getStartOffset();
final int rparenthIndex = myInfo.third.getEndOffset();
final String fileAndLine = line.substring(lparenthIndex + 1, rparenthIndex).trim();
final int colonIndex = fileAndLine.lastIndexOf(':');
if (colonIndex < 0) return;
final int lineNumber = getLineNumber(fileAndLine.substring(colonIndex + 1));
if (lineNumber < 0) return;
Pair<PsiClass[], PsiFile[]> pair = myCache.resolveClass(myInfo.first.substring(line).trim());
myClasses = pair.first;
myFiles = pair.second;
if (myFiles.length == 0) {
// try find the file with the required name
//todo[nik] it would be better to use FilenameIndex here to honor the scope by it isn't accessible in Open API
myFiles = PsiShortNamesCache.getInstance(myProject).getFilesByName(fileAndLine.substring(0, colonIndex).trim());
}
if (myFiles.length == 0) return;
/*
IDEADEV-4976: Some scramblers put something like SourceFile mock instead of real class name.
final String filePath = fileAndLine.substring(0, colonIndex).replace('/', File.separatorChar);
final int slashIndex = filePath.lastIndexOf(File.separatorChar);
final String shortFileName = slashIndex < 0 ? filePath : filePath.substring(slashIndex + 1);
if (!file.getName().equalsIgnoreCase(shortFileName)) return null;
*/
final int textStartOffset = textEndOffset - line.length();
final int highlightStartOffset = textStartOffset + lparenthIndex + 1;
final int highlightEndOffset = textStartOffset + rparenthIndex;
ProjectFileIndex index = ProjectRootManager.getInstance(myProject).getFileIndex();
List<VirtualFile> virtualFilesInLibraries = new ArrayList<VirtualFile>();
List<VirtualFile> virtualFilesInContent = new ArrayList<VirtualFile>();
for (PsiFile file : myFiles) {
VirtualFile virtualFile = file.getVirtualFile();
if (index.isInContent(virtualFile)) {
virtualFilesInContent.add(virtualFile);
}
else {
virtualFilesInLibraries.add(virtualFile);
}
}
List<VirtualFile> virtualFiles;
TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.HYPERLINK_ATTRIBUTES);
if (virtualFilesInContent.isEmpty()) {
Color libTextColor = UIUtil.getInactiveTextColor();
attributes = attributes.clone();
attributes.setForegroundColor(libTextColor);
attributes.setEffectColor(libTextColor);
virtualFiles = virtualFilesInLibraries;
}
else {
virtualFiles = virtualFilesInContent;
}
HyperlinkInfo linkInfo = HyperlinkInfoFactory.getInstance().createMultipleFilesHyperlinkInfo(virtualFiles, lineNumber - 1, myProject);
myResult = new Filter.Result(highlightStartOffset, highlightEndOffset, linkInfo, attributes);
}
示例14: update
import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
@Override
protected void update(PresentationData data) {
super.update(data);
final PackageElement packageElement = getValue();
try {
if (packageElement == null || !packageElement.getPackage().isValid()) {
setValue(null);
return;
}
int fileCount = getFileCount(packageElement);
if (fileCount == 0){
setValue(null);
return;
}
PsiPackage aPackage = packageElement.getPackage();
String newName;
if (getStructure().areFlattenPackages()) {
newName = aPackage.getQualifiedName();
}
else {
newName = myPresentationName != null ? myPresentationName : "";
}
int nameEndOffset = newName.length();
int todoItemCount = getTodoItemCount(packageElement);
newName = IdeBundle.message("node.todo.group", newName, todoItemCount, fileCount);
myHighlightedRegions.clear();
TextAttributes textAttributes = new TextAttributes();
Color newColor = null;
if (CopyPasteManager.getInstance().isCutElement(packageElement)) {
newColor = CopyPasteManager.CUT_COLOR;
}
textAttributes.setForegroundColor(newColor);
myHighlightedRegions.add(new HighlightedRegion(0, nameEndOffset, textAttributes));
EditorColorsScheme colorsScheme = UsageTreeColorsScheme.getInstance().getScheme();
myHighlightedRegions.add(
new HighlightedRegion(nameEndOffset, newName.length(), colorsScheme.getAttributes(UsageTreeColors.NUMBER_OF_USAGES)));
data.setPresentableText(newName);
}
catch (IndexNotReadyException e) {
LOG.info(e);
data.setPresentableText("N/A");
}
}
示例15: getOutputKey
import com.intellij.openapi.editor.markup.TextAttributes; //導入方法依賴的package包/類
@NotNull
public Key getOutputKey(@NonNls String attribute) {
final String completeAttribute = attribute;
if (attribute.startsWith("\u001B[")) {
attribute = attribute.substring(2);
}
else if (attribute.startsWith("[")) {
attribute = attribute.substring(1);
}
if (attribute.endsWith("m")) {
attribute = attribute.substring(0, attribute.length() - 1);
}
if (attribute.equals("0")) {
return ProcessOutputTypes.STDOUT;
}
TextAttributes attrs = new TextAttributes();
final String[] strings = attribute.split(";");
for (String string : strings) {
int value;
try {
value = Integer.parseInt(string);
}
catch (NumberFormatException e) {
continue;
}
if (value == 1) {
attrs.setFontType(Font.BOLD);
}
else if (value == 4) {
attrs.setEffectType(EffectType.LINE_UNDERSCORE);
}
else if (value == 22) {
attrs.setFontType(Font.PLAIN);
}
else if (value == 24) { //not underlined
attrs.setEffectType(null);
}
else if (value >= 30 && value <= 37) {
attrs.setForegroundColor(getAnsiColor(value - 30));
}
else if (value == 38) {
//TODO: 256 colors foreground
}
else if (value == 39) {
attrs.setForegroundColor(getColorByKey(ConsoleViewContentType.NORMAL_OUTPUT_KEY));
}
else if (value >= 40 && value <= 47) {
attrs.setBackgroundColor(getAnsiColor(value - 40));
}
else if (value == 48) {
//TODO: 256 colors background
}
else if (value == 49) {
attrs.setBackgroundColor(getColorByKey(ConsoleViewContentType.NORMAL_OUTPUT_KEY));
}
else if (value >= 90 && value <= 97) {
attrs.setForegroundColor(
getAnsiColor(value - 82));
}
else if (value >= 100 && value <= 107) {
attrs.setBackgroundColor(
getAnsiColor(value - 92));
}
}
if (attrs.getEffectType() == EffectType.LINE_UNDERSCORE) {
attrs.setEffectColor(attrs.getForegroundColor());
}
Key newKey = new Key(completeAttribute);
ConsoleViewContentType contentType = new ConsoleViewContentType(completeAttribute, attrs);
ConsoleViewContentType.registerNewConsoleViewType(newKey, contentType);
return newKey;
}