antialiasing for wave underscore

This commit is contained in:
Vassiliy.Kudryashov
2014-12-26 16:31:58 +03:00
parent 6c6f165fc2
commit a108ed43da
@@ -19,8 +19,10 @@ import com.intellij.ide.BrowserUtil;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.ui.GraphicsConfig;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ui.GraphicsUtil;
import com.intellij.util.ui.JBInsets;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
@@ -37,6 +39,8 @@ import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.tree.TreeCellRenderer;
import java.awt.*;
import java.awt.geom.GeneralPath;
import java.awt.geom.PathIterator;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -682,13 +686,24 @@ public class SimpleColoredComponent extends JComponent implements Accessible, Co
}
// 2. Waved effect
if (attributes.isWaved()) {
if (attributes.getWaveColor() != null) {
g.setColor(attributes.getWaveColor());
}
final int wavedAt = textBaseline + 1;
for (int x = offset; x <= offset + fragmentWidth; x += 4) {
UIUtil.drawLine(g, x, wavedAt, x + 2, wavedAt + 2);
UIUtil.drawLine(g, x + 3, wavedAt + 1, x + 4, wavedAt);
GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
Stroke oldStroke = g.getStroke();
try {
g.setStroke(new BasicStroke(.7F));
if (attributes.getWaveColor() != null) {
g.setColor(attributes.getWaveColor());
}
final int wavedAt = textBaseline + 1;
GeneralPath wavePath = new GeneralPath(PathIterator.WIND_EVEN_ODD);
wavePath.moveTo(offset, wavedAt);
for (int x = offset; x <= offset + fragmentWidth; x += 4) {
wavePath.lineTo(x + 2, wavedAt + 2);
wavePath.lineTo(x + 4, wavedAt);
}
g.draw(wavePath);
} finally {
config.restore();
g.setStroke(oldStroke);
}
}
// 3. Underline