Adjusting testing cases for current state of OCCT
[occt.git] / samples / java / drv / SampleHLRJni / SampleHLRJni_Aspect_ColorRampColorMap_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_ColorRampColorMap.h>
22 #include <Aspect_ColorRampColorMap.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 <Standard_Integer.hxx>
30 #include <Quantity_Color.hxx>
31 #include <Quantity_NameOfColor.hxx>
32 #include <Aspect_ColorMapEntry.hxx>
33
34
35 extern "C" {
36
37
38 JNIEXPORT void JNICALL Java_SampleHLRJni_Aspect_1ColorRampColorMap_Aspect_1ColorRampColorMap_1Create_11 (JNIEnv *env, jobject theobj, jint basepixel, jint dimension, jobject color)
39 {
40
41 jcas_Locking alock(env);
42 {
43 try {
44 Quantity_Color* the_color = (Quantity_Color*) jcas_GetHandle(env,color);
45 if ( the_color == NULL ) {
46
47  // The following assumes availability of the default constructor (what may not
48  // always be the case). Therefore explicit exception is thrown if the null
49  // object has been passed.
50  // the_color = new Quantity_Color ();
51  // jcas_SetHandle ( env, color, the_color );
52  jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value");
53
54 }  // end if
55 Handle(Aspect_ColorRampColorMap)* theret = new Handle(Aspect_ColorRampColorMap);
56 *theret = new Aspect_ColorRampColorMap((Standard_Integer) basepixel,(Standard_Integer) dimension,*the_color);
57 jcas_SetHandle(env,theobj,theret);
58
59 }
60 catch (Standard_Failure) {
61   Standard_SStream Err;
62   Err <<   Standard_Failure::Caught(); 
63   Err << (char) 0;
64   jcas_ThrowException(env,Err.str().c_str());
65 }
66 }
67 alock.Release();
68
69 }
70
71
72
73 JNIEXPORT void JNICALL Java_SampleHLRJni_Aspect_1ColorRampColorMap_Aspect_1ColorRampColorMap_1Create_12 (JNIEnv *env, jobject theobj, jint basepixel, jint dimension, jshort colorName)
74 {
75
76 jcas_Locking alock(env);
77 {
78 try {
79 Handle(Aspect_ColorRampColorMap)* theret = new Handle(Aspect_ColorRampColorMap);
80 *theret = new Aspect_ColorRampColorMap((Standard_Integer) basepixel,(Standard_Integer) dimension,(Quantity_NameOfColor) colorName);
81 jcas_SetHandle(env,theobj,theret);
82
83 }
84 catch (Standard_Failure) {
85   Standard_SStream Err;
86   Err <<   Standard_Failure::Caught(); 
87   Err << (char) 0;
88   jcas_ThrowException(env,Err.str().c_str());
89 }
90 }
91 alock.Release();
92
93 }
94
95
96
97 JNIEXPORT void JNICALL Java_SampleHLRJni_Aspect_1ColorRampColorMap_ColorRampDefinition (JNIEnv *env, jobject theobj, jobject basepixel, jobject dimension, jobject color)
98 {
99
100 jcas_Locking alock(env);
101 {
102 try {
103 Standard_Integer the_basepixel = jcas_GetInteger(env,basepixel);
104 Standard_Integer the_dimension = jcas_GetInteger(env,dimension);
105 Quantity_Color* the_color = (Quantity_Color*) jcas_GetHandle(env,color);
106 if ( the_color == NULL ) {
107
108  // The following assumes availability of the default constructor (what may not
109  // always be the case). Therefore explicit exception is thrown if the null
110  // object has been passed.
111  // the_color = new Quantity_Color ();
112  // jcas_SetHandle ( env, color, the_color );
113  jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value");
114
115 }  // end if
116 Handle(Aspect_ColorRampColorMap) the_this = *((Handle(Aspect_ColorRampColorMap)*) jcas_GetHandle(env,theobj));
117 the_this->ColorRampDefinition(the_basepixel,the_dimension,*the_color);
118 jcas_SetInteger(env,basepixel,the_basepixel);
119 jcas_SetInteger(env,dimension,the_dimension);
120
121 }
122 catch (Standard_Failure) {
123   Standard_SStream Err;
124   Err <<   Standard_Failure::Caught(); 
125   Err << (char) 0;
126   jcas_ThrowException(env,Err.str().c_str());
127 }
128 }
129 alock.Release();
130
131 }
132
133
134
135 JNIEXPORT jint JNICALL Java_SampleHLRJni_Aspect_1ColorRampColorMap_FindColorMapIndex (JNIEnv *env, jobject theobj, jint ColorMapEntryIndex)
136 {
137 jint thejret;
138
139 jcas_Locking alock(env);
140 {
141 try {
142 Handle(Aspect_ColorRampColorMap) the_this = *((Handle(Aspect_ColorRampColorMap)*) jcas_GetHandle(env,theobj));
143  thejret = the_this->FindColorMapIndex((Standard_Integer) ColorMapEntryIndex);
144
145 }
146 catch (Standard_Failure) {
147   Standard_SStream Err;
148   Err <<   Standard_Failure::Caught(); 
149   Err << (char) 0;
150   jcas_ThrowException(env,Err.str().c_str());
151 }
152 }
153 alock.Release();
154 return thejret;
155 }
156
157
158
159 JNIEXPORT jobject JNICALL Java_SampleHLRJni_Aspect_1ColorRampColorMap_FindEntry (JNIEnv *env, jobject theobj, jint AColorMapEntryIndex)
160 {
161 jobject thejret;
162
163 jcas_Locking alock(env);
164 {
165 try {
166 Handle(Aspect_ColorRampColorMap) the_this = *((Handle(Aspect_ColorRampColorMap)*) jcas_GetHandle(env,theobj));
167 const Aspect_ColorMapEntry& theret = the_this->FindEntry((Standard_Integer) AColorMapEntryIndex);
168 thejret = jcas_CreateObject(env,"CASCADESamplesJni/Aspect_ColorMapEntry",&theret,0);
169
170 }
171 catch (Standard_Failure) {
172   Standard_SStream Err;
173   Err <<   Standard_Failure::Caught(); 
174   Err << (char) 0;
175   jcas_ThrowException(env,Err.str().c_str());
176 }
177 }
178 alock.Release();
179 return thejret;
180 }
181
182
183
184 JNIEXPORT jint JNICALL Java_SampleHLRJni_Aspect_1ColorRampColorMap_NearestColorMapIndex (JNIEnv *env, jobject theobj, jobject aColor)
185 {
186 jint thejret;
187
188 jcas_Locking alock(env);
189 {
190 try {
191 Quantity_Color* the_aColor = (Quantity_Color*) jcas_GetHandle(env,aColor);
192 if ( the_aColor == NULL ) {
193
194  // The following assumes availability of the default constructor (what may not
195  // always be the case). Therefore explicit exception is thrown if the null
196  // object has been passed.
197  // the_aColor = new Quantity_Color ();
198  // jcas_SetHandle ( env, aColor, the_aColor );
199  jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value");
200
201 }  // end if
202 Handle(Aspect_ColorRampColorMap) the_this = *((Handle(Aspect_ColorRampColorMap)*) jcas_GetHandle(env,theobj));
203  thejret = the_this->NearestColorMapIndex(*the_aColor);
204
205 }
206 catch (Standard_Failure) {
207   Standard_SStream Err;
208   Err <<   Standard_Failure::Caught(); 
209   Err << (char) 0;
210   jcas_ThrowException(env,Err.str().c_str());
211 }
212 }
213 alock.Release();
214 return thejret;
215 }
216
217
218
219 JNIEXPORT jobject JNICALL Java_SampleHLRJni_Aspect_1ColorRampColorMap_NearestEntry (JNIEnv *env, jobject theobj, jobject aColor)
220 {
221 jobject thejret;
222
223 jcas_Locking alock(env);
224 {
225 try {
226 Quantity_Color* the_aColor = (Quantity_Color*) jcas_GetHandle(env,aColor);
227 if ( the_aColor == NULL ) {
228
229  // The following assumes availability of the default constructor (what may not
230  // always be the case). Therefore explicit exception is thrown if the null
231  // object has been passed.
232  // the_aColor = new Quantity_Color ();
233  // jcas_SetHandle ( env, aColor, the_aColor );
234  jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value");
235
236 }  // end if
237 Handle(Aspect_ColorRampColorMap) the_this = *((Handle(Aspect_ColorRampColorMap)*) jcas_GetHandle(env,theobj));
238 const Aspect_ColorMapEntry& theret = the_this->NearestEntry(*the_aColor);
239 thejret = jcas_CreateObject(env,"CASCADESamplesJni/Aspect_ColorMapEntry",&theret,0);
240
241 }
242 catch (Standard_Failure) {
243   Standard_SStream Err;
244   Err <<   Standard_Failure::Caught(); 
245   Err << (char) 0;
246   jcas_ThrowException(env,Err.str().c_str());
247 }
248 }
249 alock.Release();
250 return thejret;
251 }
252
253
254
255 JNIEXPORT jint JNICALL Java_SampleHLRJni_Aspect_1ColorRampColorMap_AddEntry (JNIEnv *env, jobject theobj, jobject aColor)
256 {
257 jint thejret;
258
259 jcas_Locking alock(env);
260 {
261 try {
262 Quantity_Color* the_aColor = (Quantity_Color*) jcas_GetHandle(env,aColor);
263 if ( the_aColor == NULL ) {
264
265  // The following assumes availability of the default constructor (what may not
266  // always be the case). Therefore explicit exception is thrown if the null
267  // object has been passed.
268  // the_aColor = new Quantity_Color ();
269  // jcas_SetHandle ( env, aColor, the_aColor );
270  jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value");
271
272 }  // end if
273 Handle(Aspect_ColorRampColorMap) the_this = *((Handle(Aspect_ColorRampColorMap)*) jcas_GetHandle(env,theobj));
274  thejret = the_this->AddEntry(*the_aColor);
275
276 }
277 catch (Standard_Failure) {
278   Standard_SStream Err;
279   Err <<   Standard_Failure::Caught(); 
280   Err << (char) 0;
281   jcas_ThrowException(env,Err.str().c_str());
282 }
283 }
284 alock.Release();
285 return thejret;
286 }
287
288
289 }