Lines 49-54
Link Here
|
49 |
import java.awt.Composite; |
49 |
import java.awt.Composite; |
50 |
import java.awt.Shape; |
50 |
import java.awt.Shape; |
51 |
import java.awt.Rectangle; |
51 |
import java.awt.Rectangle; |
|
|
52 |
import java.awt.font.FontRenderContext; |
53 |
import java.awt.font.TextLayout; |
54 |
import javax.swing.JComponent; |
52 |
import javax.swing.text.View; |
55 |
import javax.swing.text.View; |
53 |
|
56 |
|
54 |
/** Draw graphics functions as abstraction over various kinds of drawing. It's used |
57 |
/** Draw graphics functions as abstraction over various kinds of drawing. It's used |
Lines 415-420
Link Here
|
415 |
|
418 |
|
416 |
private int bufferStartOffset; |
419 |
private int bufferStartOffset; |
417 |
|
420 |
|
|
|
421 |
private JComponent component; |
422 |
|
418 |
GraphicsDG(Graphics graphics) { |
423 |
GraphicsDG(Graphics graphics) { |
419 |
this.graphics = graphics; |
424 |
this.graphics = graphics; |
420 |
// #33165 - set invalid y initially |
425 |
// #33165 - set invalid y initially |
Lines 534-539
Link Here
|
534 |
textLimitLineColor = ctx.getEditorUI().getTextLimitLineColor(); |
539 |
textLimitLineColor = ctx.getEditorUI().getTextLimitLineColor(); |
535 |
absoluteX = ctx.getEditorUI().getTextMargin().left; |
540 |
absoluteX = ctx.getEditorUI().getTextMargin().left; |
536 |
maxWidth = ctx.getEditorUI().getExtentBounds().width; |
541 |
maxWidth = ctx.getEditorUI().getExtentBounds().width; |
|
|
542 |
component = ctx.getEditorUI().getComponent(); |
537 |
} |
543 |
} |
538 |
|
544 |
|
539 |
public @Override void finish() { |
545 |
public @Override void finish() { |
Lines 659-666
Link Here
|
659 |
); |
665 |
); |
660 |
} |
666 |
} |
661 |
|
667 |
|
662 |
graphics.drawChars(buffer, startOffset, endOffset - startOffset, |
668 |
// Use TextLayout drawing |
663 |
startX, startY + lineAscent); |
669 |
drawStringTextLayout(component, graphics, |
|
|
670 |
new String(buffer, startOffset, endOffset - startOffset), |
671 |
startX, startY + lineAscent); |
672 |
|
673 |
// graphics.drawChars(buffer, startOffset, endOffset - startOffset, |
674 |
// startX, startY + lineAscent); |
664 |
|
675 |
|
665 |
if (strikeThroughColor != null) { // draw strike-through |
676 |
if (strikeThroughColor != null) { // draw strike-through |
666 |
FontMetricsCache.Info fmcInfo = FontMetricsCache.getInfo(font); |
677 |
FontMetricsCache.Info fmcInfo = FontMetricsCache.getInfo(font); |
Lines 785-790
Link Here
|
785 |
flush(true); |
796 |
flush(true); |
786 |
} |
797 |
} |
787 |
|
798 |
|
|
|
799 |
private static void drawStringTextLayout(JComponent c, Graphics g, String text, int x, int y) { |
800 |
if (!(g instanceof Graphics2D)) { |
801 |
g.drawString(text, x, y); |
802 |
} else { // Graphics2D available |
803 |
Graphics2D g2d = (Graphics2D)g; |
804 |
FontRenderContext frc = g2d.getFontRenderContext(); |
805 |
TextLayout layout = new TextLayout(text, g2d.getFont(), frc); |
806 |
layout.draw(g2d, x, y); |
807 |
} |
808 |
} |
809 |
|
788 |
} // End of GraphicsDG class |
810 |
} // End of GraphicsDG class |
789 |
|
811 |
|
790 |
static final class PrintDG extends SimpleDG { |
812 |
static final class PrintDG extends SimpleDG { |