use of com.intellij.openapi.editor.colors.EditorFontType in project intellij-community by JetBrains.
the class EditorGutterComponentImpl method paintAnnotations.
private void paintAnnotations(Graphics2D g, int startVisualLine, int endVisualLine) {
int x = getAnnotationsAreaOffset();
int w = getAnnotationsAreaWidthEx();
if (w == 0)
return;
AffineTransform old = setMirrorTransformIfNeeded(g, x, w);
try {
Color color = myEditor.getColorsScheme().getColor(EditorColors.ANNOTATIONS_COLOR);
g.setColor(color != null ? color : JBColor.blue);
g.setFont(myEditor.getColorsScheme().getFont(EditorFontType.PLAIN));
for (int i = 0; i < myTextAnnotationGutters.size(); i++) {
TextAnnotationGutterProvider gutterProvider = myTextAnnotationGutters.get(i);
int lineHeight = myEditor.getLineHeight();
int lastLine = myEditor.logicalToVisualPosition(new LogicalPosition(endLineNumber(), 0)).line;
endVisualLine = Math.min(endVisualLine, lastLine);
if (startVisualLine > endVisualLine) {
break;
}
int annotationSize = myTextAnnotationGutterSizes.get(i);
VisualLinesIterator visLinesIterator = new VisualLinesIterator(myEditor, startVisualLine);
while (!visLinesIterator.atEnd() && visLinesIterator.getVisualLine() <= endVisualLine) {
int logLine = visLinesIterator.getStartLogicalLine();
int y = visLinesIterator.getY();
String s = gutterProvider.getLineText(logLine, myEditor);
final EditorFontType style = gutterProvider.getStyle(logLine, myEditor);
final Color bg = gutterProvider.getBgColor(logLine, myEditor);
if (bg != null) {
g.setColor(bg);
g.fillRect(x, y, annotationSize, lineHeight);
}
g.setColor(myEditor.getColorsScheme().getColor(gutterProvider.getColor(logLine, myEditor)));
g.setFont(myEditor.getColorsScheme().getFont(style));
if (!StringUtil.isEmpty(s)) {
// we leave half of the gap before the text
g.drawString(s, GAP_BETWEEN_ANNOTATIONS / 2 + x, y + myEditor.getAscent());
}
visLinesIterator.advance();
}
if (startVisualLine == 0 && endVisualLine == 0) {
//allow paining gutters for empty documents
String s = gutterProvider.getLineText(0, myEditor);
final EditorFontType style = gutterProvider.getStyle(0, myEditor);
final Color bg = gutterProvider.getBgColor(0, myEditor);
if (bg != null) {
g.setColor(bg);
g.fillRect(x, 0, annotationSize, lineHeight);
}
g.setColor(myEditor.getColorsScheme().getColor(gutterProvider.getColor(0, myEditor)));
g.setFont(myEditor.getColorsScheme().getFont(style));
if (!StringUtil.isEmpty(s)) {
g.drawString(s, GAP_BETWEEN_ANNOTATIONS / 2 + x, myEditor.getAscent());
}
}
x += annotationSize;
}
} finally {
if (old != null)
g.setTransform(old);
}
}
use of com.intellij.openapi.editor.colors.EditorFontType in project intellij-community by JetBrains.
the class EditorPainter method paintPlaceholderText.
private boolean paintPlaceholderText(Graphics2D g) {
CharSequence hintText = myEditor.getPlaceholder();
EditorComponentImpl editorComponent = myEditor.getContentComponent();
if (myDocument.getTextLength() > 0 || hintText == null || hintText.length() == 0 || KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() == editorComponent && !myEditor.getShowPlaceholderWhenFocused()) {
return false;
}
hintText = SwingUtilities.layoutCompoundLabel(g.getFontMetrics(), hintText.toString(), null, 0, 0, 0, 0, // account for insets
SwingUtilities.calculateInnerArea(editorComponent, null), new Rectangle(), new Rectangle(), 0);
EditorFontType fontType = EditorFontType.PLAIN;
Color color = myEditor.getFoldingModel().getPlaceholderAttributes().getForegroundColor();
TextAttributes attributes = myEditor.getPlaceholderAttributes();
if (attributes != null) {
int type = attributes.getFontType();
if (type == Font.ITALIC)
fontType = EditorFontType.ITALIC;
else if (type == Font.BOLD)
fontType = EditorFontType.BOLD;
else if (type == (Font.ITALIC | Font.BOLD))
fontType = EditorFontType.BOLD_ITALIC;
Color attColor = attributes.getForegroundColor();
if (attColor != null)
color = attColor;
}
g.setColor(color);
g.setFont(myEditor.getColorsScheme().getFont(fontType));
Insets insets = myView.getInsets();
g.drawString(hintText.toString(), insets.left, insets.top + myView.getAscent());
return true;
}
Aggregations