1. /*
  2. * Copyright 1999,2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package peaklau.eaglefund;
  17. import javax.microedition.lcdui.Font;
  18. import javax.microedition.lcdui.Graphics;
  19. import javax.microedition.lcdui.Image;
  20. /**
  21. * MainScreen class<br>
  22. * EagleFund logo is painted in the center of the screen, <br>
  23. * and the application version is showed at the bottom.
  24. *
  25. *
  26. * <br>
  27. * @author peaklau <br>
  28. * email:<A HREF="mailto:peaklau@hotmail.com">peaklau@hotmail.com</A> <br>
  29. * <a href="http://www.peaklau.com/fund/english/">HomePage</a>
  30. * @version $Revision: 1.1 $ $Date: 2007/05/09 16:07:04 $
  31. */
  32. public class MainScreen extends BaseCanvas {
  33. private Font defaultFont=Font.getDefaultFont();
  34. private int FONT_HEIGHT=defaultFont.getHeight();
  35. private int width=0;
  36. private int height=0;
  37. private Image logo=null;
  38. public MainScreen(INavigator navigator){
  39. super(navigator);
  40. width=getWidth();
  41. height=getHeight();
  42. try{
  43. logo=Image.createImage("/jj.png");
  44. }catch(Exception e){
  45. e.printStackTrace();
  46. }
  47. }
  48. protected void paint(Graphics g){
  49. g.setColor(0x00FFFFFF);
  50. g.fillRect(0,0,width,height);
  51. int x=(width-logo.getWidth())/2;
  52. int y=(height-logo.getHeight())/2;
  53. g.drawImage(logo,x,y,Graphics.LEFT|Graphics.TOP);
  54. String version="Version: "+navigator.getAppVersion();
  55. x=(width-defaultFont.stringWidth(version))/2;
  56. x=x<0?0:x;
  57. y=height-FONT_HEIGHT;
  58. //System.out.println(version+" "+x+" "+y);
  59. g.setColor(0x00000000);
  60. g.drawString(version,x,y,Graphics.LEFT|Graphics.TOP);
  61. }
  62. }