Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save 0xfeeddeadbeef/e655a279d94cc472994123061cbfea31 to your computer and use it in GitHub Desktop.
Save 0xfeeddeadbeef/e655a279d94cc472994123061cbfea31 to your computer and use it in GitHub Desktop.
package com.gchakhidze.textsharpidea;
import com.intellij.injected.editor.DocumentWindow;
import com.intellij.openapi.editor.event.EditorFactoryEvent;
import com.intellij.util.ui.GraphicsUtil;
import org.jetbrains.annotations.NotNull;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
public class TextSharpEditorFactoryListener
implements com.intellij.openapi.editor.event.EditorFactoryListener
{
@Override
public void editorCreated(@NotNull EditorFactoryEvent editorFactoryEvent) {
// Grab text area component of the editor window:
Graphics graphics = GraphicsUtil.safelyGetGraphics(editorFactoryEvent.getEditor().getContentComponent());
if (graphics instanceof Graphics2D) {
// FAIL: `graphics' is not an instance of Graphics2D
Graphics2D graphics2D = (Graphics2D) graphics;
graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
graphics2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
System.out.println("SUCCESS: Changed editor graphics rendering hints.");
} else {
System.err.println("WARNING: Editor graphics is not Graphics2D.");
}
}
@Override
public void editorReleased(@NotNull EditorFactoryEvent editorFactoryEvent) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment