/* * FILE: PicViewCanvas.java * AUTH: Nicholas Chihau Yang (ncy) * DATE: 13 Jan 2006 * DESC: Main class for drawing selected picture. * * PicView - Simple MIDP picture viewer * Copyright (c) 2006 Nicholas Chihau Yang * * PicView is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * PicView is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package photo; import javax.microedition.lcdui.*; import javax.microedition.lcdui.game.*; import javax.microedition.midlet.*; public class PhotoFrame extends GameCanvas implements Runnable { private Thread thread; private Graphics g; public PhotoFrame(MIDlet midlet) { super(false); g = getGraphics(); } void drawImage(Image pic) { g.drawImage(pic, 0, 0, Graphics.TOP|Graphics.LEFT); } public void destroy() { hideNotify(); } public void paint(Graphics g) { flushGraphics(); } protected void showNotify() { thread = new Thread(this); thread.start(); } protected void hideNotify() { thread = null; } public void run() { Thread mythread = Thread.currentThread(); while (mythread == thread) { if (mythread == thread) { flushGraphics(); } try { mythread.sleep(5); } catch (InterruptedException ie) { } catch (Exception e) { e.printStackTrace(); } } } }