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
19public abstract class MapObject {
26 public abstract int getId();
27
34 public abstract MapObjectType getType();
35
42 public abstract byte[] getData();
43
51 public abstract boolean setVisible(boolean visible);
52
60 public abstract boolean setInteractive(boolean interactive);
61
69 public abstract void setData(byte[] data);
70
78 public abstract boolean setTitle(String title);
79
87 public abstract boolean setAlpha(float alpha);
88
89 private static final class CppProxy extends MapObject
90 {
91 private final long nativeRef;
92 private final AtomicBoolean destroyed = new AtomicBoolean(false);
93
94 private CppProxy(long nativeRef)
95 {
96 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
97 this.nativeRef = nativeRef;
98 }
99
100 private native void nativeDestroy(long nativeRef);
101 public void _djinni_private_destroy()
102 {
103 boolean destroyed = this.destroyed.getAndSet(true);
104 if (!destroyed) nativeDestroy(this.nativeRef);
105 }
106 protected void finalize() throws java.lang.Throwable
107 {
108 _djinni_private_destroy();
109 super.finalize();
110 }
111
112 // MapObject methods
113
114 @Override
115 public int getId()
116 {
117 assert !this.destroyed.get() : "trying to use a destroyed object";
118 return native_getId(this.nativeRef);
119 }
120 private native int native_getId(long _nativeRef);
121
122 @Override
123 public MapObjectType getType()
124 {
125 assert !this.destroyed.get() : "trying to use a destroyed object";
126 return native_getType(this.nativeRef);
127 }
128 private native MapObjectType native_getType(long _nativeRef);
129
130 @Override
131 public byte[] getData()
132 {
133 assert !this.destroyed.get() : "trying to use a destroyed object";
134 return native_getData(this.nativeRef);
135 }
136 private native byte[] native_getData(long _nativeRef);
137
138 @Override
139 public boolean setVisible(boolean visible)
140 {
141 assert !this.destroyed.get() : "trying to use a destroyed object";
142 return native_setVisible(this.nativeRef, visible);
143 }
144 private native boolean native_setVisible(long _nativeRef, boolean visible);
145
146 @Override
147 public boolean setInteractive(boolean interactive)
148 {
149 assert !this.destroyed.get() : "trying to use a destroyed object";
150 return native_setInteractive(this.nativeRef, interactive);
151 }
152 private native boolean native_setInteractive(long _nativeRef, boolean interactive);
153
154 @Override
155 public void setData(byte[] data)
156 {
157 assert !this.destroyed.get() : "trying to use a destroyed object";
158 native_setData(this.nativeRef, data);
159 }
160 private native void native_setData(long _nativeRef, byte[] data);
161
162 @Override
163 public boolean setTitle(String title)
164 {
165 assert !this.destroyed.get() : "trying to use a destroyed object";
166 return native_setTitle(this.nativeRef, title);
167 }
168 private native boolean native_setTitle(long _nativeRef, String title);
169
170 @Override
171 public boolean setAlpha(float alpha)
172 {
173 assert !this.destroyed.get() : "trying to use a destroyed object";
174 return native_setAlpha(this.nativeRef, alpha);
175 }
176 private native boolean native_setAlpha(long _nativeRef, float alpha);
177 }
178}