X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fbackend%2FSwingTerminal.java;h=37f99d56c2371f489afebea9bb98e68d70237739;hb=7ed28054941adbb9e7f2b4487fa9d2325b12a752;hp=c2b335f43380e2b1e22ae4ee7b0d5556baad2ab0;hpb=6e9daafbcbfa145fa1f7c9ca839f2a05ccf024c2;p=fanfix.git diff --git a/src/jexer/backend/SwingTerminal.java b/src/jexer/backend/SwingTerminal.java index c2b335f..37f99d5 100644 --- a/src/jexer/backend/SwingTerminal.java +++ b/src/jexer/backend/SwingTerminal.java @@ -36,6 +36,7 @@ import java.awt.Graphics2D; import java.awt.Graphics; import java.awt.Insets; import java.awt.Rectangle; +import java.awt.RenderingHints; import java.awt.Toolkit; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; @@ -1238,15 +1239,26 @@ public class SwingTerminal extends LogicalScreen // Draw the background rectangle, then the foreground character. assert (cell.isImage()); + + // Enable anti-aliasing + if (gr instanceof Graphics2D) { + ((Graphics2D) gr).setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + ((Graphics2D) gr).setRenderingHint(RenderingHints.KEY_RENDERING, + RenderingHints.VALUE_RENDER_QUALITY); + } + gr.setColor(cell.getBackground()); gr.fillRect(xPixel, yPixel, textWidth, textHeight); BufferedImage image = cell.getImage(); if (image != null) { if (swing.getFrame() != null) { - gr.drawImage(image, xPixel, yPixel, swing.getFrame()); + gr.drawImage(image, xPixel, yPixel, getTextWidth(), + getTextHeight(), swing.getFrame()); } else { - gr.drawImage(image, xPixel, yPixel, swing.getComponent()); + gr.drawImage(image, xPixel, yPixel, getTextWidth(), + getTextHeight(),swing.getComponent()); } return; } @@ -1308,10 +1320,19 @@ public class SwingTerminal extends LogicalScreen cellColor.setBackColor(cell.getForeColor()); } + // Enable anti-aliasing + if (gr instanceof Graphics2D) { + ((Graphics2D) gr).setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + ((Graphics2D) gr).setRenderingHint(RenderingHints.KEY_RENDERING, + RenderingHints.VALUE_RENDER_QUALITY); + } + // Draw the background rectangle, then the foreground character. gr2.setColor(attrToBackgroundColor(cellColor)); gr2.fillRect(gr2x, gr2y, textWidth, textHeight); + // Handle blink and underline if (!cell.isBlink() || (cell.isBlink() && cursorBlinkVisible)