/** * Called when a key is pressed. * * @param keyCode * the key kode of the key that was pressed. */ protected void keyPressed(int keyCode) { switch (this.getGameAction(keyCode)) { case UP: if (screenOffset > 0) { screenOffset--; } break; case DOWN: if (lineSize * (logStrings.size() - screenOffset) > this .getHeight()) { screenOffset++; } break; default: break; } // Request screen repaint repaint(); }
public void paintDisplayable(Graphics g, int x, int y, int width, int height) { MIDletAccess ma = MIDletBridge.getMIDletAccess(); if (ma == null) { return; } DisplayAccess da = ma.getDisplayAccess(); if (da == null) { return; } Displayable current = da.getCurrent(); if (current == null) { return; } g.setColor(foregroundColor); java.awt.Shape oldclip = g.getClip(); if (!(current instanceof Canvas) || ((Canvas) current).getWidth() != displayRectangle.width || ((Canvas) current).getHeight() != displayRectangle.height) { g.translate(displayPaintable.x, displayPaintable.y); } g.setClip(x, y, width, height); Font oldf = g.getFont(); ma.getDisplayAccess().paint(new J2SEDisplayGraphics((java.awt.Graphics2D) g, getDisplayImage())); g.setFont(oldf); if (!(current instanceof Canvas) || ((Canvas) current).getWidth() != displayRectangle.width || ((Canvas) current).getHeight() != displayRectangle.height) { g.translate(-displayPaintable.x, -displayPaintable.y); } g.setClip(oldclip); }
/** * Do the logging. * * @param level * the level at which the logging shall be done. * @param message * the message to log. * @param throwable * the exception to log. */ public void doLog(String clientID, String name, long time, Level level, Object message, Throwable throwable) { if (isOpen && formatter != null) { logStrings.addElement(formatter.format(clientID, name, time, level, message, throwable)); } // Scroll down screen to show the last line entered when a new line is // added while (lineSize * (logStrings.size() - screenOffset) > this.getHeight()) { screenOffset++; } // Request screen repaint this.repaint(); }
|| ((Canvas) current).getWidth() != displayRectangle.width || ((Canvas) current).getHeight() != displayRectangle.height) { g.translate(displayPaintable.x, displayPaintable.y); g.setFont(oldf); if (!(current instanceof Canvas) || ((Canvas) current).getWidth() != displayRectangle.width || ((Canvas) current).getHeight() != displayRectangle.height) { g.translate(-displayPaintable.x, -displayPaintable.y);