Integration of OCCT 6.5.0 from SVN
[occt.git] / samples / java / drv / SampleHLRJni / SampleHLRJni_Aspect_ColorMap_java.cxx
1 //
2 //                     Copyright (C) 1991 - 2000 by  
3 //                      Matra Datavision SA.  All rights reserved.
4 //  
5 //                     Copyright (C) 2001 - 2004 by
6 //                     Open CASCADE SA.  All rights reserved.
7 // 
8 // This file is part of the Open CASCADE Technology software.
9 //
10 // This software may be distributed and/or modified under the terms and
11 // conditions of the Open CASCADE Public License as defined by Open CASCADE SA
12 // and appearing in the file LICENSE included in the packaging of this file.
13 //  
14 // This software is distributed on an "AS IS" basis, without warranty of any
15 // kind, and Open CASCADE SA hereby disclaims all such warranties,
16 // including without limitation, any warranties of merchantability, fitness
17 // for a particular purpose or non-infringement. Please see the License for
18 // the specific terms and conditions governing rights and limitations under the
19 // License.
20
21 #include <SampleHLRJni_Aspect_ColorMap.h>
22 #include <Aspect_ColorMap.hxx>
23 #include <jcas.hxx>
24 #include <stdlib.h>
25 #include <Standard_ErrorHandler.hxx>
26 #include <Standard_Failure.hxx>
27 #include <Standard_SStream.hxx>
28
29 #include <Aspect_TypeOfColorMap.hxx>
30 #include <Standard_Integer.hxx>
31 #include <Aspect_ColorMapEntry.hxx>
32 #include <Quantity_Color.hxx>
33
34
35 extern "C" {
36
37
38 JNIEXPORT jshort JNICALL Java_SampleHLRJni_Aspect_1ColorMap_Type (JNIEnv *env, jobject theobj)
39 {
40 jshort thejret;
41
42 jcas_Locking alock(env);
43 {
44 try {
45 Handle(Aspect_ColorMap) the_this = *((Handle(Aspect_ColorMap)*) jcas_GetHandle(env,theobj));
46  thejret = the_this->Type();
47
48 }
49 catch (Standard_Failure) {
50   Standard_SStream Err;
51   Err <<   Standard_Failure::Caught(); 
52   Err << (char) 0;
53   jcas_ThrowException(env,Err.str().c_str());
54 }
55 }
56 alock.Release();
57 return thejret;
58 }
59
60
61
62 JNIEXPORT jint JNICALL Java_SampleHLRJni_Aspect_1ColorMap_Size (JNIEnv *env, jobject theobj)
63 {
64 jint thejret;
65
66 jcas_Locking alock(env);
67 {
68 try {
69 Handle(Aspect_ColorMap) the_this = *((Handle(Aspect_ColorMap)*) jcas_GetHandle(env,theobj));
70  thejret = the_this->Size();
71
72 }
73 catch (Standard_Failure) {
74   Standard_SStream Err;
75   Err <<   Standard_Failure::Caught(); 
76   Err << (char) 0;
77   jcas_ThrowException(env,Err.str().c_str());
78 }
79 }
80 alock.Release();
81 return thejret;
82 }
83
84
85
86 JNIEXPORT jint JNICALL Java_SampleHLRJni_Aspect_1ColorMap_Index (JNIEnv *env, jobject theobj, jint aColormapIndex)
87 {
88 jint thejret;
89
90 jcas_Locking alock(env);
91 {
92 try {
93 Handle(Aspect_ColorMap) the_this = *((Handle(Aspect_ColorMap)*) jcas_GetHandle(env,theobj));
94  thejret = the_this->Index((Standard_Integer) aColormapIndex);
95
96 }
97 catch (Standard_Failure) {
98   Standard_SStream Err;
99   Err <<   Standard_Failure::Caught(); 
100   Err << (char) 0;
101   jcas_ThrowException(env,Err.str().c_str());
102 }
103 }
104 alock.Release();
105 return thejret;
106 }
107
108
109
110 JNIEXPORT void JNICALL Java_SampleHLRJni_Aspect_1ColorMap_Dump (JNIEnv *env, jobject theobj)
111 {
112
113 jcas_Locking alock(env);
114 {
115 try {
116 Handle(Aspect_ColorMap) the_this = *((Handle(Aspect_ColorMap)*) jcas_GetHandle(env,theobj));
117 the_this->Dump();
118
119 }
120 catch (Standard_Failure) {
121   Standard_SStream Err;
122   Err <<   Standard_Failure::Caught(); 
123   Err << (char) 0;
124   jcas_ThrowException(env,Err.str().c_str());
125 }
126 }
127 alock.Release();
128
129 }
130
131
132
133 JNIEXPORT jobject JNICALL Java_SampleHLRJni_Aspect_1ColorMap_Entry (JNIEnv *env, jobject theobj, jint AColorMapIndex)
134 {
135 jobject thejret;
136
137 jcas_Locking alock(env);
138 {
139 try {
140 Handle(Aspect_ColorMap) the_this = *((Handle(Aspect_ColorMap)*) jcas_GetHandle(env,theobj));
141 const Aspect_ColorMapEntry& theret = the_this->Entry((Standard_Integer) AColorMapIndex);
142 thejret = jcas_CreateObject(env,"CASCADESamplesJni/Aspect_ColorMapEntry",&theret,0);
143
144 }
145 catch (Standard_Failure) {
146   Standard_SStream Err;
147   Err <<   Standard_Failure::Caught(); 
148   Err << (char) 0;
149   jcas_ThrowException(env,Err.str().c_str());
150 }
151 }
152 alock.Release();
153 return thejret;
154 }
155
156
157
158 JNIEXPORT jint JNICALL Java_SampleHLRJni_Aspect_1ColorMap_FindColorMapIndex (JNIEnv *env, jobject theobj, jint AColorMapEntryIndex)
159 {
160 jint thejret;
161
162 jcas_Locking alock(env);
163 {
164 try {
165 Handle(Aspect_ColorMap) the_this = *((Handle(Aspect_ColorMap)*) jcas_GetHandle(env,theobj));
166  thejret = the_this->FindColorMapIndex((Standard_Integer) AColorMapEntryIndex);
167
168 }
169 catch (Standard_Failure) {
170   Standard_SStream Err;
171   Err <<   Standard_Failure::Caught(); 
172   Err << (char) 0;
173   jcas_ThrowException(env,Err.str().c_str());
174 }
175 }
176 alock.Release();
177 return thejret;
178 }
179
180
181
182 JNIEXPORT jobject JNICALL Java_SampleHLRJni_Aspect_1ColorMap_FindEntry (JNIEnv *env, jobject theobj, jint AColorMapEntryIndex)
183 {
184 jobject thejret;
185
186 jcas_Locking alock(env);
187 {
188 try {
189 Handle(Aspect_ColorMap) the_this = *((Handle(Aspect_ColorMap)*) jcas_GetHandle(env,theobj));
190 const Aspect_ColorMapEntry& theret = the_this->FindEntry((Standard_Integer) AColorMapEntryIndex);
191 thejret = jcas_CreateObject(env,"CASCADESamplesJni/Aspect_ColorMapEntry",&theret,0);
192
193 }
194 catch (Standard_Failure) {
195   Standard_SStream Err;
196   Err <<   Standard_Failure::Caught(); 
197   Err << (char) 0;
198   jcas_ThrowException(env,Err.str().c_str());
199 }
200 }
201 alock.Release();
202 return thejret;
203 }
204
205
206
207 JNIEXPORT jint JNICALL Java_SampleHLRJni_Aspect_1ColorMap_NearestColorMapIndex (JNIEnv *env, jobject theobj, jobject aColor)
208 {
209 jint thejret;
210
211 jcas_Locking alock(env);
212 {
213 try {
214 Quantity_Color* the_aColor = (Quantity_Color*) jcas_GetHandle(env,aColor);
215 if ( the_aColor == NULL ) {
216
217  // The following assumes availability of the default constructor (what may not
218  // always be the case). Therefore explicit exception is thrown if the null
219  // object has been passed.
220  // the_aColor = new Quantity_Color ();
221  // jcas_SetHandle ( env, aColor, the_aColor );
222  jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value");
223
224 }  // end if
225 Handle(Aspect_ColorMap) the_this = *((Handle(Aspect_ColorMap)*) jcas_GetHandle(env,theobj));
226  thejret = the_this->NearestColorMapIndex(*the_aColor);
227
228 }
229 catch (Standard_Failure) {
230   Standard_SStream Err;
231   Err <<   Standard_Failure::Caught(); 
232   Err << (char) 0;
233   jcas_ThrowException(env,Err.str().c_str());
234 }
235 }
236 alock.Release();
237 return thejret;
238 }
239
240
241
242 JNIEXPORT jobject JNICALL Java_SampleHLRJni_Aspect_1ColorMap_NearestEntry (JNIEnv *env, jobject theobj, jobject aColor)
243 {
244 jobject thejret;
245
246 jcas_Locking alock(env);
247 {
248 try {
249 Quantity_Color* the_aColor = (Quantity_Color*) jcas_GetHandle(env,aColor);
250 if ( the_aColor == NULL ) {
251
252  // The following assumes availability of the default constructor (what may not
253  // always be the case). Therefore explicit exception is thrown if the null
254  // object has been passed.
255  // the_aColor = new Quantity_Color ();
256  // jcas_SetHandle ( env, aColor, the_aColor );
257  jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value");
258
259 }  // end if
260 Handle(Aspect_ColorMap) the_this = *((Handle(Aspect_ColorMap)*) jcas_GetHandle(env,theobj));
261 const Aspect_ColorMapEntry& theret = the_this->NearestEntry(*the_aColor);
262 thejret = jcas_CreateObject(env,"CASCADESamplesJni/Aspect_ColorMapEntry",&theret,0);
263
264 }
265 catch (Standard_Failure) {
266   Standard_SStream Err;
267   Err <<   Standard_Failure::Caught(); 
268   Err << (char) 0;
269   jcas_ThrowException(env,Err.str().c_str());
270 }
271 }
272 alock.Release();
273 return thejret;
274 }
275
276
277
278 JNIEXPORT jint JNICALL Java_SampleHLRJni_Aspect_1ColorMap_AddEntry (JNIEnv *env, jobject theobj, jobject aColor)
279 {
280 jint thejret;
281
282 jcas_Locking alock(env);
283 {
284 try {
285 Quantity_Color* the_aColor = (Quantity_Color*) jcas_GetHandle(env,aColor);
286 if ( the_aColor == NULL ) {
287
288  // The following assumes availability of the default constructor (what may not
289  // always be the case). Therefore explicit exception is thrown if the null
290  // object has been passed.
291  // the_aColor = new Quantity_Color ();
292  // jcas_SetHandle ( env, aColor, the_aColor );
293  jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value");
294
295 }  // end if
296 Handle(Aspect_ColorMap) the_this = *((Handle(Aspect_ColorMap)*) jcas_GetHandle(env,theobj));
297  thejret = the_this->AddEntry(*the_aColor);
298
299 }
300 catch (Standard_Failure) {
301   Standard_SStream Err;
302   Err <<   Standard_Failure::Caught(); 
303   Err << (char) 0;
304   jcas_ThrowException(env,Err.str().c_str());
305 }
306 }
307 alock.Release();
308 return thejret;
309 }
310
311
312 }