KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > microedition > lcdui > Canvas


1
2 /*
3  * MicroEmulator
4  * Copyright (C) 2001 Bartek Teodorczyk <barteo@it.pl>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * Contributor(s):
21  * 3GLab
22  */

23  
24 package javax.microedition.lcdui;
25
26 import com.barteo.emulator.device.DeviceFactory;
27
28
29 public abstract class Canvas extends Displayable
30 {
31
32     public static final int UP = 1;
33     public static final int DOWN = 6;
34     public static final int LEFT = 2;
35     public static final int RIGHT = 5;
36     public static final int FIRE = 8;
37
38     public static final int GAME_A = 9;
39     public static final int GAME_B = 10;
40     public static final int GAME_C = 11;
41     public static final int GAME_D = 12;
42
43   public static final int KEY_NUM0 = 48;
44   public static final int KEY_NUM1 = 49;
45   public static final int KEY_NUM2 = 50;
46   public static final int KEY_NUM3 = 51;
47   public static final int KEY_NUM4 = 52;
48   public static final int KEY_NUM5 = 53;
49   public static final int KEY_NUM6 = 54;
50   public static final int KEY_NUM7 = 55;
51   public static final int KEY_NUM8 = 56;
52   public static final int KEY_NUM9 = 57;
53
54   public static final int KEY_STAR = 42;
55   public static final int KEY_POUND = 35;
56
57
58     protected Canvas()
59     {
60     }
61
62
63     public int getGameAction(int keyCode)
64     {
65         return Display.getGameAction(keyCode);
66     }
67
68
69   public int getKeyCode(int gameAction)
70   {
71     return Display.getKeyCode(gameAction);
72   }
73
74
75   public String getKeyName(int keyCode)
76   {
77     return Integer.toString(keyCode);
78   }
79
80
81   public boolean hasPointerEvents()
82   {
83     return DeviceFactory.getDevice().hasPointerEvents();
84   }
85
86
87   public boolean hasPointerMotionEvents()
88   {
89     return DeviceFactory.getDevice().hasPointerMotionEvents();
90   }
91
92
93   public boolean hasRepeatEvents()
94   {
95     return DeviceFactory.getDevice().hasRepeatEvents();
96   }
97
98
99     public int getWidth()
100     {
101         return DeviceFactory.getDevice().getDeviceDisplay().getWidth();
102     }
103
104
105     public int getHeight()
106     {
107         return DeviceFactory.getDevice().getDeviceDisplay().getHeight();
108     }
109
110
111   protected void hideNotify()
112   {
113   }
114
115
116   public boolean isDoubleBuffered()
117   {
118     return false;
119   }
120
121
122     protected void keyPressed(int keyCode)
123     {
124     }
125
126
127     protected void keyRepeated(int keyCode)
128     {
129     }
130
131
132     protected void keyReleased(int keyCode)
133     {
134     }
135
136
137     protected abstract void paint(Graphics g);
138
139
140   protected void pointerPressed(int x, int y)
141   {
142   }
143
144
145   protected void pointerReleased(int x, int y)
146   {
147   }
148
149
150   protected void pointerDragged(int x, int y)
151   {
152   }
153
154
155     public final void repaint()
156     {
157         super.repaint();
158     }
159
160
161   public final void repaint(int x, int y, int width, int height)
162   {
163     repaint();
164   }
165
166
167   public final void serviceRepaints()
168   {
169   }
170
171   
172   protected void showNotify()
173   {
174   }
175   
176 }
177
Popular Tags