Source code: com/siemens/mp/color_game/Layer.java
1 /*
2 * Siemens API for MicroEmulator
3 * Copyright (C) 2003 Markus Heberling <markus@heberling.net>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 package com.siemens.mp.color_game;
20
21 import javax.microedition.lcdui.Graphics;
22 import javax.microedition.lcdui.Image;
23
24 public abstract class Layer {
25 Image image;
26 protected Layer(int width, int height) {
27 this.width=width;
28 this.height=height;
29 }
30
31 protected Layer(Image img) {
32 this(img.getWidth(),img.getHeight());
33 image=img;
34 }
35
36 protected void copyAllLayerVariables(com.siemens.mp.color_game.Layer l) {
37 l.width=width;
38 l.height=height;
39 l.x=x;
40 l.y=y;
41 l.image=image;
42 }
43
44 protected void setLayerImage(Image img) {
45 image=img;
46 }
47
48 protected javax.microedition.lcdui.Image getLayerImage() {
49 return image;
50 }
51
52 public void setPosition(int x, int y) {
53 this.x = x;
54 this.y = y;
55 }
56
57
58 public void move(int dx, int dy) {
59 x += dx;
60 y += dy;
61 }
62
63
64 public final int getX() {
65 return x;
66 }
67
68
69 public final int getY() {
70 return y;
71 }
72
73 public final int getWidth() {
74 return width;
75 }
76
77
78 public final int getHeight() {
79 return height;
80 }
81
82
83 public void setVisible(boolean visible) {
84 this.visible = visible;
85 }
86
87
88 public final boolean isVisible() {
89 return visible;
90 }
91
92 public abstract void paint(Graphics g);
93
94 void setWidthImpl(int w){
95 width=w;
96 }
97
98 void setHeightImpl(int h){
99 height=h;
100 }
101
102 int x; // = 0;
103 int y; // = 0;
104 int width; // = 0;
105 int height; // = 0;
106 boolean visible = true;
107
108 }