* @param always if true, always resize the cells
*/
private void sizeToImage(final boolean always) {
- int textWidth = 16;
- int textHeight = 20;
-
- if (getScreen() instanceof SwingTerminal) {
- SwingTerminal terminal = (SwingTerminal) getScreen();
-
- textWidth = terminal.getTextWidth();
- textHeight = terminal.getTextHeight();
- } if (getScreen() instanceof MultiScreen) {
- MultiScreen terminal = (MultiScreen) getScreen();
-
- textWidth = terminal.getTextWidth();
- textHeight = terminal.getTextHeight();
- } else if (getScreen() instanceof ECMA48Terminal) {
- ECMA48Terminal terminal = (ECMA48Terminal) getScreen();
-
- textWidth = terminal.getTextWidth();
- textHeight = terminal.getTextHeight();
- }
+ int textWidth = getScreen().getTextWidth();
+ int textHeight = getScreen().getTextHeight();
if (image == null) {
image = rotateImage(originalImage, clockwise);
newStatusBar(i18n.getString("statusBarRunning"));
// Pass the correct text cell width/height to the emulator
- int textWidth = 16;
- int textHeight = 20;
- if (getScreen() instanceof SwingTerminal) {
- SwingTerminal terminal = (SwingTerminal) getScreen();
-
- textWidth = terminal.getTextWidth();
- textHeight = terminal.getTextHeight();
- } else if (getScreen() instanceof ECMA48Terminal) {
- ECMA48Terminal terminal = (ECMA48Terminal) getScreen();
- textWidth = terminal.getTextWidth();
- textHeight = terminal.getTextHeight();
- }
- emulator.setTextWidth(textWidth);
- emulator.setTextHeight(textHeight);
+ emulator.setTextWidth(getScreen().getTextWidth());
+ emulator.setTextHeight(getScreen().getTextHeight());
}
/**
private void putDoubleWidthCharXY(final DisplayLine line, final int x,
final int y, final Cell cell) {
- int textWidth = 16;
- int textHeight = 20;
+ int textWidth = getScreen().getTextWidth();
+ int textHeight = getScreen().getTextHeight();
boolean cursorBlinkVisible = true;
if (getScreen() instanceof SwingTerminal) {
SwingTerminal terminal = (SwingTerminal) getScreen();
-
- textWidth = terminal.getTextWidth();
- textHeight = terminal.getTextHeight();
cursorBlinkVisible = terminal.getCursorBlinkVisible();
} else if (getScreen() instanceof ECMA48Terminal) {
ECMA48Terminal terminal = (ECMA48Terminal) getScreen();
putCharXY(x + 1, y, ' ', cell);
return;
}
-
- textWidth = terminal.getTextWidth();
- textHeight = terminal.getTextHeight();
cursorBlinkVisible = blinkState;
} else {
// We don't know how to dray glyphs to this screen, draw them as
// Screen -----------------------------------------------------------------
// ------------------------------------------------------------------------
+ /**
+ * Get the width of a character cell in pixels.
+ *
+ * @return the width in pixels of a character cell
+ */
+ public int getTextWidth() {
+ // Default width is 16 pixels.
+ return 16;
+ }
+
+ /**
+ * Get the height of a character cell in pixels.
+ *
+ * @return the height in pixels of a character cell
+ */
+ public int getTextHeight() {
+ // Default height is 20 pixels.
+ return 20;
+ }
+
/**
* Set drawing offset for x.
*
public int getTextWidth() {
int textWidth = 16;
for (Screen screen: screens) {
- int newTextWidth = textWidth;
- if (screen instanceof MultiScreen) {
- newTextWidth = ((MultiScreen) screen).getTextWidth();
- } else if (screen instanceof ECMA48Terminal) {
- newTextWidth = ((ECMA48Terminal) screen).getTextWidth();
- } else if (screen instanceof SwingTerminal) {
- newTextWidth = ((SwingTerminal) screen).getTextWidth();
- }
+ int newTextWidth = screen.getTextWidth();
if (newTextWidth < textWidth) {
textWidth = newTextWidth;
}
public int getTextHeight() {
int textHeight = 20;
for (Screen screen: screens) {
- int newTextHeight = textHeight;
- if (screen instanceof MultiScreen) {
- newTextHeight = ((MultiScreen) screen).getTextHeight();
- } else if (screen instanceof ECMA48Terminal) {
- newTextHeight = ((ECMA48Terminal) screen).getTextHeight();
- } else if (screen instanceof SwingTerminal) {
- newTextHeight = ((SwingTerminal) screen).getTextHeight();
- }
+ int newTextHeight = screen.getTextHeight();
if (newTextHeight < textHeight) {
textHeight = newTextHeight;
}
*/
public void setTitle(final String title);
+ /**
+ * Get the width of a character cell in pixels.
+ *
+ * @return the width in pixels of a character cell
+ */
+ public int getTextWidth();
+
+ /**
+ * Get the height of a character cell in pixels.
+ *
+ * @return the height in pixels of a character cell
+ */
+ public int getTextHeight();
+
}
window.setHeight(getHeight() + 2);
}
+ /**
+ * Get the width of a character cell in pixels.
+ *
+ * @return the width in pixels of a character cell
+ */
+ @Override
+ public int getTextWidth() {
+ return window.getScreen().getTextWidth();
+ }
+
+ /**
+ * Get the height of a character cell in pixels.
+ *
+ * @return the height in pixels of a character cell
+ */
+ @Override
+ public int getTextHeight() {
+ return window.getScreen().getTextHeight();
+ }
+
}
BufferedImage newImage = new BufferedImage(newWidth, newHeight,
BufferedImage.TYPE_INT_ARGB);
+ if (DEBUG) {
+ System.err.println("resizeImage(); old " + image.getWidth() + "x" +
+ image.getHeight() + " new " + newWidth + "x" + newHeight);
+ }
+
Graphics2D gr = newImage.createGraphics();
gr.drawImage(image, 0, 0, image.getWidth(), image.getHeight(), null);
gr.dispose();
toGround();
}
- if (height + 6 < image.getHeight()) {
+ height += 6;
+ x = 0;
+
+ if (height + 6 > image.getHeight()) {
// Resize the image, give us another HEIGHT_INCREASE
// pixels of vertical length.
resizeImage(image.getWidth(),
image.getHeight() + HEIGHT_INCREASE);
}
- height += 6;
- x = 0;
return;
}