Loading...
Searching...
No Matches
ClusterMapObject.java
Go to the documentation of this file.
1package com.navigine.idl.java;
2
3import java.util.ArrayList;
4import java.util.concurrent.atomic.AtomicBoolean;
5
23public abstract class ClusterMapObject extends MapObject {
39 public abstract boolean setBitmap(com.navigine.image.ImageProvider bitmap);
40
55 public abstract void addListener(ClusterMapObjectListener listener);
56
71 public abstract void removeListener(ClusterMapObjectListener listener);
72
77 public abstract LocationPoint getPosition();
78
83 public abstract int getCount();
84
89 public abstract ArrayList<IconMapObject> getIconMapObjects();
90
91 private static final class CppProxy extends ClusterMapObject
92 {
93 private final long nativeRef;
94 private final AtomicBoolean destroyed = new AtomicBoolean(false);
95
96 private CppProxy(long nativeRef)
97 {
98 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
99 this.nativeRef = nativeRef;
100 }
101
102 private native void nativeDestroy(long nativeRef);
103 public void _djinni_private_destroy()
104 {
105 boolean destroyed = this.destroyed.getAndSet(true);
106 if (!destroyed) nativeDestroy(this.nativeRef);
107 }
108 protected void finalize() throws java.lang.Throwable
109 {
110 _djinni_private_destroy();
111 super.finalize();
112 }
113
114 // ClusterMapObject methods
115
116 @Override
117 public boolean setBitmap(com.navigine.image.ImageProvider bitmap)
118 {
119 assert !this.destroyed.get() : "trying to use a destroyed object";
120 return native_setBitmap(this.nativeRef, bitmap);
121 }
122 private native boolean native_setBitmap(long _nativeRef, com.navigine.image.ImageProvider bitmap);
123
124 @Override
125 public void addListener(ClusterMapObjectListener listener)
126 {
127 assert !this.destroyed.get() : "trying to use a destroyed object";
128 native_addListener(this.nativeRef, listener);
129 }
130 private native void native_addListener(long _nativeRef, ClusterMapObjectListener listener);
131
132 @Override
133 public void removeListener(ClusterMapObjectListener listener)
134 {
135 assert !this.destroyed.get() : "trying to use a destroyed object";
136 native_removeListener(this.nativeRef, listener);
137 }
138 private native void native_removeListener(long _nativeRef, ClusterMapObjectListener listener);
139
140 @Override
141 public LocationPoint getPosition()
142 {
143 assert !this.destroyed.get() : "trying to use a destroyed object";
144 return native_getPosition(this.nativeRef);
145 }
146 private native LocationPoint native_getPosition(long _nativeRef);
147
148 @Override
149 public int getCount()
150 {
151 assert !this.destroyed.get() : "trying to use a destroyed object";
152 return native_getCount(this.nativeRef);
153 }
154 private native int native_getCount(long _nativeRef);
155
156 @Override
157 public ArrayList<IconMapObject> getIconMapObjects()
158 {
159 assert !this.destroyed.get() : "trying to use a destroyed object";
160 return native_getIconMapObjects(this.nativeRef);
161 }
162 private native ArrayList<IconMapObject> native_getIconMapObjects(long _nativeRef);
163
164 // MapObject methods
165
166 @Override
167 public int getId()
168 {
169 assert !this.destroyed.get() : "trying to use a destroyed object";
170 return native_getId(this.nativeRef);
171 }
172 private native int native_getId(long _nativeRef);
173
174 @Override
175 public MapObjectType getType()
176 {
177 assert !this.destroyed.get() : "trying to use a destroyed object";
178 return native_getType(this.nativeRef);
179 }
180 private native MapObjectType native_getType(long _nativeRef);
181
182 @Override
183 public byte[] getData()
184 {
185 assert !this.destroyed.get() : "trying to use a destroyed object";
186 return native_getData(this.nativeRef);
187 }
188 private native byte[] native_getData(long _nativeRef);
189
190 @Override
191 public boolean setVisible(boolean visible)
192 {
193 assert !this.destroyed.get() : "trying to use a destroyed object";
194 return native_setVisible(this.nativeRef, visible);
195 }
196 private native boolean native_setVisible(long _nativeRef, boolean visible);
197
198 @Override
199 public boolean setInteractive(boolean interactive)
200 {
201 assert !this.destroyed.get() : "trying to use a destroyed object";
202 return native_setInteractive(this.nativeRef, interactive);
203 }
204 private native boolean native_setInteractive(long _nativeRef, boolean interactive);
205
206 @Override
207 public void setData(byte[] data)
208 {
209 assert !this.destroyed.get() : "trying to use a destroyed object";
210 native_setData(this.nativeRef, data);
211 }
212 private native void native_setData(long _nativeRef, byte[] data);
213
214 @Override
215 public boolean setTitle(String title)
216 {
217 assert !this.destroyed.get() : "trying to use a destroyed object";
218 return native_setTitle(this.nativeRef, title);
219 }
220 private native boolean native_setTitle(long _nativeRef, String title);
221
222 @Override
223 public boolean setAlpha(float alpha)
224 {
225 assert !this.destroyed.get() : "trying to use a destroyed object";
226 return native_setAlpha(this.nativeRef, alpha);
227 }
228 private native boolean native_setAlpha(long _nativeRef, float alpha);
229 }
230}