2 // Copyright (C) 1991 - 2000 by
3 // Matra Datavision SA. All rights reserved.
5 // Copyright (C) 2001 - 2004 by
6 // Open CASCADE SA. All rights reserved.
8 // This file is part of the Open CASCADE Technology software.
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.
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
21 #include <SampleHLRJni_Aspect_ColorMap.h>
22 #include <Aspect_ColorMap.hxx>
25 #include <Standard_ErrorHandler.hxx>
26 #include <Standard_Failure.hxx>
27 #include <Standard_SStream.hxx>
29 #include <Aspect_TypeOfColorMap.hxx>
30 #include <Standard_Integer.hxx>
31 #include <Aspect_ColorMapEntry.hxx>
32 #include <Quantity_Color.hxx>
38 JNIEXPORT jshort JNICALL Java_SampleHLRJni_Aspect_1ColorMap_Type (JNIEnv *env, jobject theobj)
42 jcas_Locking alock(env);
45 Handle(Aspect_ColorMap) the_this = *((Handle(Aspect_ColorMap)*) jcas_GetHandle(env,theobj));
46 thejret = the_this->Type();
49 catch (Standard_Failure) {
51 Err << Standard_Failure::Caught();
53 jcas_ThrowException(env,Err.str().c_str());
62 JNIEXPORT jint JNICALL Java_SampleHLRJni_Aspect_1ColorMap_Size (JNIEnv *env, jobject theobj)
66 jcas_Locking alock(env);
69 Handle(Aspect_ColorMap) the_this = *((Handle(Aspect_ColorMap)*) jcas_GetHandle(env,theobj));
70 thejret = the_this->Size();
73 catch (Standard_Failure) {
75 Err << Standard_Failure::Caught();
77 jcas_ThrowException(env,Err.str().c_str());
86 JNIEXPORT jint JNICALL Java_SampleHLRJni_Aspect_1ColorMap_Index (JNIEnv *env, jobject theobj, jint aColormapIndex)
90 jcas_Locking alock(env);
93 Handle(Aspect_ColorMap) the_this = *((Handle(Aspect_ColorMap)*) jcas_GetHandle(env,theobj));
94 thejret = the_this->Index((Standard_Integer) aColormapIndex);
97 catch (Standard_Failure) {
99 Err << Standard_Failure::Caught();
101 jcas_ThrowException(env,Err.str().c_str());
110 JNIEXPORT void JNICALL Java_SampleHLRJni_Aspect_1ColorMap_Dump (JNIEnv *env, jobject theobj)
113 jcas_Locking alock(env);
116 Handle(Aspect_ColorMap) the_this = *((Handle(Aspect_ColorMap)*) jcas_GetHandle(env,theobj));
120 catch (Standard_Failure) {
121 Standard_SStream Err;
122 Err << Standard_Failure::Caught();
124 jcas_ThrowException(env,Err.str().c_str());
133 JNIEXPORT jobject JNICALL Java_SampleHLRJni_Aspect_1ColorMap_Entry (JNIEnv *env, jobject theobj, jint AColorMapIndex)
137 jcas_Locking alock(env);
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);
145 catch (Standard_Failure) {
146 Standard_SStream Err;
147 Err << Standard_Failure::Caught();
149 jcas_ThrowException(env,Err.str().c_str());
158 JNIEXPORT jint JNICALL Java_SampleHLRJni_Aspect_1ColorMap_FindColorMapIndex (JNIEnv *env, jobject theobj, jint AColorMapEntryIndex)
162 jcas_Locking alock(env);
165 Handle(Aspect_ColorMap) the_this = *((Handle(Aspect_ColorMap)*) jcas_GetHandle(env,theobj));
166 thejret = the_this->FindColorMapIndex((Standard_Integer) AColorMapEntryIndex);
169 catch (Standard_Failure) {
170 Standard_SStream Err;
171 Err << Standard_Failure::Caught();
173 jcas_ThrowException(env,Err.str().c_str());
182 JNIEXPORT jobject JNICALL Java_SampleHLRJni_Aspect_1ColorMap_FindEntry (JNIEnv *env, jobject theobj, jint AColorMapEntryIndex)
186 jcas_Locking alock(env);
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);
194 catch (Standard_Failure) {
195 Standard_SStream Err;
196 Err << Standard_Failure::Caught();
198 jcas_ThrowException(env,Err.str().c_str());
207 JNIEXPORT jint JNICALL Java_SampleHLRJni_Aspect_1ColorMap_NearestColorMapIndex (JNIEnv *env, jobject theobj, jobject aColor)
211 jcas_Locking alock(env);
214 Quantity_Color* the_aColor = (Quantity_Color*) jcas_GetHandle(env,aColor);
215 if ( the_aColor == NULL ) {
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");
225 Handle(Aspect_ColorMap) the_this = *((Handle(Aspect_ColorMap)*) jcas_GetHandle(env,theobj));
226 thejret = the_this->NearestColorMapIndex(*the_aColor);
229 catch (Standard_Failure) {
230 Standard_SStream Err;
231 Err << Standard_Failure::Caught();
233 jcas_ThrowException(env,Err.str().c_str());
242 JNIEXPORT jobject JNICALL Java_SampleHLRJni_Aspect_1ColorMap_NearestEntry (JNIEnv *env, jobject theobj, jobject aColor)
246 jcas_Locking alock(env);
249 Quantity_Color* the_aColor = (Quantity_Color*) jcas_GetHandle(env,aColor);
250 if ( the_aColor == NULL ) {
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");
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);
265 catch (Standard_Failure) {
266 Standard_SStream Err;
267 Err << Standard_Failure::Caught();
269 jcas_ThrowException(env,Err.str().c_str());
278 JNIEXPORT jint JNICALL Java_SampleHLRJni_Aspect_1ColorMap_AddEntry (JNIEnv *env, jobject theobj, jobject aColor)
282 jcas_Locking alock(env);
285 Quantity_Color* the_aColor = (Quantity_Color*) jcas_GetHandle(env,aColor);
286 if ( the_aColor == NULL ) {
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");
296 Handle(Aspect_ColorMap) the_this = *((Handle(Aspect_ColorMap)*) jcas_GetHandle(env,theobj));
297 thejret = the_this->AddEntry(*the_aColor);
300 catch (Standard_Failure) {
301 Standard_SStream Err;
302 Err << Standard_Failure::Caught();
304 jcas_ThrowException(env,Err.str().c_str());