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;
) {
do {
do {
- clearPhysical();
drawToSwing();
} while (swing.getBufferStrategy().contentsRestored());
swing.getBufferStrategy().show();
Toolkit.getDefaultToolkit().sync();
} while (swing.getBufferStrategy().contentsLost());
-
} else {
// Non-triple-buffered, call drawToSwing() once
drawToSwing();
// 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;
}
cellColor.setBackColor(cell.getForeColor());
}
+ // Enable anti-aliasing
+ if ((gr instanceof Graphics2D) && (swing.getFrame() != null)) {
+ // Anti-aliasing on JComponent makes the hash character disappear
+ // for Terminus font, and also kills performance. Only enable it
+ // for JFrame.
+ ((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);
} else {
ch = key.getKeyChar();
}
- alt = key.isAltDown();
+ // Both meta and alt count as alt, thanks to Mac using alt for
+ // "symbols" so meta ("command") is the only other modifier left.
+ alt = key.isAltDown() | key.isMetaDown();
ctrl = key.isControlDown();
shift = key.isShiftDown();
/*
System.err.printf("Swing Key: %s\n", key);
System.err.printf(" isKey: %s\n", isKey);
+ System.err.printf(" meta: %s\n", key.isMetaDown());
System.err.printf(" alt: %s\n", alt);
System.err.printf(" ctrl: %s\n", ctrl);
System.err.printf(" shift: %s\n", shift);