Loading...
Searching...
No Matches
MapObject.java
Go to the documentation of this file.
1package com.navigine.idl.java;
2
3import java.util.concurrent.atomic.AtomicBoolean;
4
21public abstract class MapObject {
36 public abstract int getId();
37
52 public abstract MapObjectType getType();
53
68 public abstract byte[] getData();
69
85 public abstract boolean setVisible(boolean visible);
86
102 public abstract boolean setInteractive(boolean interactive);
103
118 public abstract void setData(byte[] data);
119
135 public abstract boolean setTitle(String title);
136
152 public abstract boolean setAlpha(float alpha);
153
154 private static final class CppProxy extends MapObject
155 {
156 private final long nativeRef;
157 private final AtomicBoolean destroyed = new AtomicBoolean(false);
158
159 private CppProxy(long nativeRef)
160 {
161 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
162 this.nativeRef = nativeRef;
163 }
164
165 private native void nativeDestroy(long nativeRef);
166 public void _djinni_private_destroy()
167 {
168 boolean destroyed = this.destroyed.getAndSet(true);
169 if (!destroyed) nativeDestroy(this.nativeRef);
170 }
171 protected void finalize() throws java.lang.Throwable
172 {
173 _djinni_private_destroy();
174 super.finalize();
175 }
176
177 // MapObject methods
178
179 @Override
180 public int getId()
181 {
182 assert !this.destroyed.get() : "trying to use a destroyed object";
183 return native_getId(this.nativeRef);
184 }
185 private native int native_getId(long _nativeRef);
186
187 @Override
188 public MapObjectType getType()
189 {
190 assert !this.destroyed.get() : "trying to use a destroyed object";
191 return native_getType(this.nativeRef);
192 }
193 private native MapObjectType native_getType(long _nativeRef);
194
195 @Override
196 public byte[] getData()
197 {
198 assert !this.destroyed.get() : "trying to use a destroyed object";
199 return native_getData(this.nativeRef);
200 }
201 private native byte[] native_getData(long _nativeRef);
202
203 @Override
204 public boolean setVisible(boolean visible)
205 {
206 assert !this.destroyed.get() : "trying to use a destroyed object";
207 return native_setVisible(this.nativeRef, visible);
208 }
209 private native boolean native_setVisible(long _nativeRef, boolean visible);
210
211 @Override
212 public boolean setInteractive(boolean interactive)
213 {
214 assert !this.destroyed.get() : "trying to use a destroyed object";
215 return native_setInteractive(this.nativeRef, interactive);
216 }
217 private native boolean native_setInteractive(long _nativeRef, boolean interactive);
218
219 @Override
220 public void setData(byte[] data)
221 {
222 assert !this.destroyed.get() : "trying to use a destroyed object";
223 native_setData(this.nativeRef, data);
224 }
225 private native void native_setData(long _nativeRef, byte[] data);
226
227 @Override
228 public boolean setTitle(String title)
229 {
230 assert !this.destroyed.get() : "trying to use a destroyed object";
231 return native_setTitle(this.nativeRef, title);
232 }
233 private native boolean native_setTitle(long _nativeRef, String title);
234
235 @Override
236 public boolean setAlpha(float alpha)
237 {
238 assert !this.destroyed.get() : "trying to use a destroyed object";
239 return native_setAlpha(this.nativeRef, alpha);
240 }
241 private native boolean native_setAlpha(long _nativeRef, float alpha);
242 }
243}