Loading...
Searching...
No Matches
ModelMapObject.java
Go to the documentation of this file.
1package com.navigine.idl.java;
2
3import java.util.concurrent.atomic.AtomicBoolean;
4
20public abstract class ModelMapObject extends MapObject {
36 public abstract boolean setPosition(LocationPoint point);
37
55 public abstract boolean setPositionAnimated(LocationPoint point, float duration, AnimationType type);
56
72 public abstract boolean setModel(com.navigine.model.ModelProvider model);
73
88 public abstract boolean setSize(float width, float height);
89
104 public abstract boolean setCollisionEnabled(boolean enabled);
105
120 public abstract boolean setAngle(float angle);
121
136 public abstract boolean setAngleAnimated(float angle, float duration, AnimationType type);
137
152 public abstract boolean setBuffer(float width, float height);
153
168 public abstract boolean setPriority(float priority);
169
170 private static final class CppProxy extends ModelMapObject
171 {
172 private final long nativeRef;
173 private final AtomicBoolean destroyed = new AtomicBoolean(false);
174
175 private CppProxy(long nativeRef)
176 {
177 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
178 this.nativeRef = nativeRef;
179 }
180
181 private native void nativeDestroy(long nativeRef);
182 public void _djinni_private_destroy()
183 {
184 boolean destroyed = this.destroyed.getAndSet(true);
185 if (!destroyed) nativeDestroy(this.nativeRef);
186 }
187 protected void finalize() throws java.lang.Throwable
188 {
189 _djinni_private_destroy();
190 super.finalize();
191 }
192
193 // ModelMapObject methods
194
195 @Override
196 public boolean setPosition(LocationPoint point)
197 {
198 assert !this.destroyed.get() : "trying to use a destroyed object";
199 return native_setPosition(this.nativeRef, point);
200 }
201 private native boolean native_setPosition(long _nativeRef, LocationPoint point);
202
203 @Override
204 public boolean setPositionAnimated(LocationPoint point, float duration, AnimationType type)
205 {
206 assert !this.destroyed.get() : "trying to use a destroyed object";
207 return native_setPositionAnimated(this.nativeRef, point, duration, type);
208 }
209 private native boolean native_setPositionAnimated(long _nativeRef, LocationPoint point, float duration, AnimationType type);
210
211 @Override
212 public boolean setModel(com.navigine.model.ModelProvider model)
213 {
214 assert !this.destroyed.get() : "trying to use a destroyed object";
215 return native_setModel(this.nativeRef, model);
216 }
217 private native boolean native_setModel(long _nativeRef, com.navigine.model.ModelProvider model);
218
219 @Override
220 public boolean setSize(float width, float height)
221 {
222 assert !this.destroyed.get() : "trying to use a destroyed object";
223 return native_setSize(this.nativeRef, width, height);
224 }
225 private native boolean native_setSize(long _nativeRef, float width, float height);
226
227 @Override
228 public boolean setCollisionEnabled(boolean enabled)
229 {
230 assert !this.destroyed.get() : "trying to use a destroyed object";
231 return native_setCollisionEnabled(this.nativeRef, enabled);
232 }
233 private native boolean native_setCollisionEnabled(long _nativeRef, boolean enabled);
234
235 @Override
236 public boolean setAngle(float angle)
237 {
238 assert !this.destroyed.get() : "trying to use a destroyed object";
239 return native_setAngle(this.nativeRef, angle);
240 }
241 private native boolean native_setAngle(long _nativeRef, float angle);
242
243 @Override
244 public boolean setAngleAnimated(float angle, float duration, AnimationType type)
245 {
246 assert !this.destroyed.get() : "trying to use a destroyed object";
247 return native_setAngleAnimated(this.nativeRef, angle, duration, type);
248 }
249 private native boolean native_setAngleAnimated(long _nativeRef, float angle, float duration, AnimationType type);
250
251 @Override
252 public boolean setBuffer(float width, float height)
253 {
254 assert !this.destroyed.get() : "trying to use a destroyed object";
255 return native_setBuffer(this.nativeRef, width, height);
256 }
257 private native boolean native_setBuffer(long _nativeRef, float width, float height);
258
259 @Override
260 public boolean setPriority(float priority)
261 {
262 assert !this.destroyed.get() : "trying to use a destroyed object";
263 return native_setPriority(this.nativeRef, priority);
264 }
265 private native boolean native_setPriority(long _nativeRef, float priority);
266
267 // MapObject methods
268
269 @Override
270 public int getId()
271 {
272 assert !this.destroyed.get() : "trying to use a destroyed object";
273 return native_getId(this.nativeRef);
274 }
275 private native int native_getId(long _nativeRef);
276
277 @Override
278 public MapObjectType getType()
279 {
280 assert !this.destroyed.get() : "trying to use a destroyed object";
281 return native_getType(this.nativeRef);
282 }
283 private native MapObjectType native_getType(long _nativeRef);
284
285 @Override
286 public byte[] getData()
287 {
288 assert !this.destroyed.get() : "trying to use a destroyed object";
289 return native_getData(this.nativeRef);
290 }
291 private native byte[] native_getData(long _nativeRef);
292
293 @Override
294 public boolean setVisible(boolean visible)
295 {
296 assert !this.destroyed.get() : "trying to use a destroyed object";
297 return native_setVisible(this.nativeRef, visible);
298 }
299 private native boolean native_setVisible(long _nativeRef, boolean visible);
300
301 @Override
302 public boolean setInteractive(boolean interactive)
303 {
304 assert !this.destroyed.get() : "trying to use a destroyed object";
305 return native_setInteractive(this.nativeRef, interactive);
306 }
307 private native boolean native_setInteractive(long _nativeRef, boolean interactive);
308
309 @Override
310 public void setData(byte[] data)
311 {
312 assert !this.destroyed.get() : "trying to use a destroyed object";
313 native_setData(this.nativeRef, data);
314 }
315 private native void native_setData(long _nativeRef, byte[] data);
316
317 @Override
318 public boolean setTitle(String title)
319 {
320 assert !this.destroyed.get() : "trying to use a destroyed object";
321 return native_setTitle(this.nativeRef, title);
322 }
323 private native boolean native_setTitle(long _nativeRef, String title);
324
325 @Override
326 public boolean setAlpha(float alpha)
327 {
328 assert !this.destroyed.get() : "trying to use a destroyed object";
329 return native_setAlpha(this.nativeRef, alpha);
330 }
331 private native boolean native_setAlpha(long _nativeRef, float alpha);
332 }
333}