Loading...
Searching...
No Matches
PolygonMapObject.java
Go to the documentation of this file.
1package com.navigine.idl.java;
2
3import java.util.concurrent.atomic.AtomicBoolean;
4
18public abstract class PolygonMapObject extends MapObject {
26 public abstract boolean setPolygon(LocationPolygon polygon);
27
38 public abstract boolean setColor(float red, float green, float blue, float alpha);
39
40 private static final class CppProxy extends PolygonMapObject
41 {
42 private final long nativeRef;
43 private final AtomicBoolean destroyed = new AtomicBoolean(false);
44
45 private CppProxy(long nativeRef)
46 {
47 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
48 this.nativeRef = nativeRef;
49 }
50
51 private native void nativeDestroy(long nativeRef);
52 public void _djinni_private_destroy()
53 {
54 boolean destroyed = this.destroyed.getAndSet(true);
55 if (!destroyed) nativeDestroy(this.nativeRef);
56 }
57 protected void finalize() throws java.lang.Throwable
58 {
59 _djinni_private_destroy();
60 super.finalize();
61 }
62
63 // PolygonMapObject methods
64
65 @Override
66 public boolean setPolygon(LocationPolygon polygon)
67 {
68 assert !this.destroyed.get() : "trying to use a destroyed object";
69 return native_setPolygon(this.nativeRef, polygon);
70 }
71 private native boolean native_setPolygon(long _nativeRef, LocationPolygon polygon);
72
73 @Override
74 public boolean setColor(float red, float green, float blue, float alpha)
75 {
76 assert !this.destroyed.get() : "trying to use a destroyed object";
77 return native_setColor(this.nativeRef, red, green, blue, alpha);
78 }
79 private native boolean native_setColor(long _nativeRef, float red, float green, float blue, float alpha);
80
81 // MapObject methods
82
83 @Override
84 public int getId()
85 {
86 assert !this.destroyed.get() : "trying to use a destroyed object";
87 return native_getId(this.nativeRef);
88 }
89 private native int native_getId(long _nativeRef);
90
91 @Override
92 public MapObjectType getType()
93 {
94 assert !this.destroyed.get() : "trying to use a destroyed object";
95 return native_getType(this.nativeRef);
96 }
97 private native MapObjectType native_getType(long _nativeRef);
98
99 @Override
100 public byte[] getData()
101 {
102 assert !this.destroyed.get() : "trying to use a destroyed object";
103 return native_getData(this.nativeRef);
104 }
105 private native byte[] native_getData(long _nativeRef);
106
107 @Override
108 public boolean setVisible(boolean visible)
109 {
110 assert !this.destroyed.get() : "trying to use a destroyed object";
111 return native_setVisible(this.nativeRef, visible);
112 }
113 private native boolean native_setVisible(long _nativeRef, boolean visible);
114
115 @Override
116 public boolean setInteractive(boolean interactive)
117 {
118 assert !this.destroyed.get() : "trying to use a destroyed object";
119 return native_setInteractive(this.nativeRef, interactive);
120 }
121 private native boolean native_setInteractive(long _nativeRef, boolean interactive);
122
123 @Override
124 public boolean setStyle(String style)
125 {
126 assert !this.destroyed.get() : "trying to use a destroyed object";
127 return native_setStyle(this.nativeRef, style);
128 }
129 private native boolean native_setStyle(long _nativeRef, String style);
130
131 @Override
132 public void setData(byte[] data)
133 {
134 assert !this.destroyed.get() : "trying to use a destroyed object";
135 native_setData(this.nativeRef, data);
136 }
137 private native void native_setData(long _nativeRef, byte[] data);
138
139 @Override
140 public boolean setTitle(String title)
141 {
142 assert !this.destroyed.get() : "trying to use a destroyed object";
143 return native_setTitle(this.nativeRef, title);
144 }
145 private native boolean native_setTitle(long _nativeRef, String title);
146 }
147}