- /*
- * Copyright 1999,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
- /*
- * Created on 2007-1-26
- *
- */
- package peaklau.eaglefund;
-
- import java.util.Calendar;
-
- import javax.microedition.lcdui.Canvas;
- import javax.microedition.lcdui.Graphics;
- /**
- * BaseCanvas class<br>
- * The subclasses of this class should overwrite paint() method .<br>
- * If the subclasses want to refresh the data, they should overwrite the execute() method. <br>
- * @author peaklau <br>
- * email:<A HREF="mailto:peaklau@hotmail.com">peaklau@hotmail.com</A> <br>
- * <a href="http://www.peaklau.com/fund/english/">HomePage</a>
- * @version $Revision: 1.2 $ $Date: 2007/10/21 14:26:23 $
- */
-
- public class BaseCanvas extends Canvas implements Runnable{
- public final static String host="www.peaklau.com";
- protected INavigator navigator;
- public BaseCanvas(INavigator navigator){
- this.navigator=navigator;
- }
- protected void refresh(){
- if(!running){
- new Thread(this).start();
- }
- }
- private boolean running=false;
- public void run(){
- execute();
- running=false;
- }
- /**
- * Subclasses can overwrite this method to get refresh some data.
- *
- */
- protected void execute(){
- }
- protected void paint(Graphics g) {
- }
- public String getCurrentTime(){
- Calendar calendar=Calendar.getInstance();
- int year=calendar.get(Calendar.YEAR);
- int month=calendar.get(Calendar.MONTH);
- int day=calendar.get(Calendar.DAY_OF_MONTH);
- int hour=calendar.get(Calendar.HOUR_OF_DAY);
- int min=calendar.get(Calendar.MINUTE);
- //year+"/"+(month+1)+"/"+day+" "+(hour<10?("0"+hour):(""+hour))+":"+(min<10?("0"+min):(""+min)));
- return (hour<10?("0"+hour):(""+hour))+":"+(min<10?("0"+min):(""+min));
- }
-
- protected void keyPressed(int keyCode) {
- navigator.keyPressed(keyCode);
- }
-
- }