Created
June 21, 2018 16:31
-
-
Save 0xfeeddeadbeef/e655a279d94cc472994123061cbfea31 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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