Implement this interface (diorcustomelementrenderer) but have not had any effect
Do i need add a config in plugin.xml file? Thank you.
this is my test class:
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorCustomElementRenderer;
import com.intellij.openapi.editor.Inlay;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.EditorFontType;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.ui.components.JBTextArea;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
public class MyInlayRendererImp implements EditorCustomElementRenderer {
private JBTextArea textArea;
private Color color;
public MyInlayRendererImp(final String problemMessage, Color color) {
textArea = new JBTextArea(problemMessage);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
this.color = color;
}
@Override
public int calcWidthInPixels(@NotNull Inlay inlay) {
return 50;
}
@Override
public int calcHeightInPixels(@NotNull Inlay inlay) {
return 50;
}
@Override
public void paint(@NotNull Inlay inlay, @NotNull Graphics graphics, @NotNull Rectangle targetRegion, @NotNull TextAttributes textAttributes) {
Editor editor = inlay.getEditor();
EditorColorsScheme colorsScheme = editor.getColorsScheme();
graphics.setFont(colorsScheme.getFont(EditorFontType.PLAIN));
graphics.setColor(color);
// todo how to draw the textArea instead of the string?
graphics.drawString(textArea.getText(), targetRegion.x, targetRegion.y + editor.getAscent());
}
}
请先登录再写评论。