Source code: com/siemens/mp/game/GraphicObjectManager.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.game;
20
21 import java.util.Vector;
22 import javax.microedition.lcdui.*;
23
24 /**
25 *
26 * @author markus
27 * @version
28 */
29 public class GraphicObjectManager extends com.siemens.mp.misc.NativeMem{
30 Vector v=new Vector();
31
32 public void addObject(GraphicObject gobject) {
33 //System.out.println("void addObject(GraphicObject "+gobject+")");
34 v.addElement(gobject);
35 }
36
37 public static byte[] createTextureBits(int width, int height, byte[] texture) {
38 System.out.println("static byte[] createTextureBits(int width, int height, byte[] texture)");
39 return null;
40 }
41
42
43 public void deleteObject(GraphicObject gobject) {
44 //System.out.println("void deleteObject(GraphicObject gobject)");
45 v.removeElement(gobject);
46 }
47
48
49 public void deleteObject(int position) {
50 //System.out.println("void deleteObject(int position)");
51 v.removeElementAt(position);
52 }
53
54
55 public GraphicObject getObjectAt(int index) {
56 //System.out.println("GraphicObject getObjectAt(int index)");
57 Object o=v.elementAt(index);
58 return (GraphicObject)o;
59 }
60
61
62 public int getObjectPosition(GraphicObject gobject) {
63 //System.out.println("int getObjectPosition(GraphicObject gobject)");
64 return v.indexOf(gobject);
65 }
66
67
68 public void insertObject(GraphicObject gobject, int position) {
69 //System.out.println("void insertObject(GraphicObject gobject, int position)");
70 v.insertElementAt(gobject, position);
71 }
72
73
74 public void paint(ExtendedImage eimage, int x, int y) {
75 this.paint(eimage.getImage(),x,y);
76 }
77
78
79 public void paint(Image image, int x, int y) {
80 Graphics g=image.getGraphics();
81 g.translate(x, y);
82
83 for (int i=0;i<v.size();i++) {
84 GraphicObject go=(GraphicObject)v.elementAt(i);
85 go.paint(g);
86 }
87 g.translate(-x, -y);
88
89 }
90
91 }