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 <CASCADESamplesJni_Quantity_Color.h>
22 #include <Quantity_Color.hxx>
25 #include <Standard_ErrorHandler.hxx>
26 #include <Standard_Failure.hxx>
27 #include <Standard_SStream.hxx>
29 #include <Quantity_NameOfColor.hxx>
30 #include <Standard_Real.hxx>
31 #include <Quantity_TypeOfColor.hxx>
32 #include <Standard_Boolean.hxx>
33 #include <Standard_CString.hxx>
39 JNIEXPORT void JNICALL Java_CASCADESamplesJni_Quantity_1Color_Quantity_1Color_1Create_11 (JNIEnv *env, jobject theobj)
42 jcas_Locking alock(env);
45 Quantity_Color* theret = new Quantity_Color();
46 jcas_SetHandle(env,theobj,theret);
49 catch (Standard_Failure) {
51 Err << Standard_Failure::Caught();
53 jcas_ThrowException(env,Err.str().c_str());
62 JNIEXPORT void JNICALL Java_CASCADESamplesJni_Quantity_1Color_Quantity_1Color_1Create_12 (JNIEnv *env, jobject theobj, jshort AName)
65 jcas_Locking alock(env);
68 Quantity_Color* theret = new Quantity_Color((Quantity_NameOfColor) AName);
69 jcas_SetHandle(env,theobj,theret);
72 catch (Standard_Failure) {
74 Err << Standard_Failure::Caught();
76 jcas_ThrowException(env,Err.str().c_str());
85 JNIEXPORT void JNICALL Java_CASCADESamplesJni_Quantity_1Color_Quantity_1Color_1Create_13 (JNIEnv *env, jobject theobj, jdouble R1, jdouble R2, jdouble R3, jshort AType)
88 jcas_Locking alock(env);
91 Quantity_Color* theret = new Quantity_Color((Quantity_Parameter) R1,(Quantity_Parameter) R2,(Quantity_Parameter) R3,(Quantity_TypeOfColor) AType);
92 jcas_SetHandle(env,theobj,theret);
95 catch (Standard_Failure) {
97 Err << Standard_Failure::Caught();
99 jcas_ThrowException(env,Err.str().c_str());
108 JNIEXPORT jobject JNICALL Java_CASCADESamplesJni_Quantity_1Color_Assign (JNIEnv *env, jobject theobj, jobject Other)
112 jcas_Locking alock(env);
115 Quantity_Color* the_Other = (Quantity_Color*) jcas_GetHandle(env,Other);
116 if ( the_Other == NULL ) {
118 // The following assumes availability of the default constructor (what may not
119 // always be the case). Therefore explicit exception is thrown if the null
120 // object has been passed.
121 // the_Other = new Quantity_Color ();
122 // jcas_SetHandle ( env, Other, the_Other );
123 jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value");
126 Quantity_Color* the_this = (Quantity_Color*) jcas_GetHandle(env,theobj);
127 const Quantity_Color& theret = the_this->Assign(*the_Other);
128 thejret = jcas_CreateObject(env,"CASCADESamplesJni/Quantity_Color",&theret,0);
131 catch (Standard_Failure) {
132 Standard_SStream Err;
133 Err << Standard_Failure::Caught();
135 jcas_ThrowException(env,Err.str().c_str());
144 JNIEXPORT void JNICALL Java_CASCADESamplesJni_Quantity_1Color_ChangeContrast (JNIEnv *env, jobject theobj, jdouble ADelta)
147 jcas_Locking alock(env);
150 Quantity_Color* the_this = (Quantity_Color*) jcas_GetHandle(env,theobj);
151 the_this->ChangeContrast((Quantity_Rate) ADelta);
154 catch (Standard_Failure) {
155 Standard_SStream Err;
156 Err << Standard_Failure::Caught();
158 jcas_ThrowException(env,Err.str().c_str());
167 JNIEXPORT void JNICALL Java_CASCADESamplesJni_Quantity_1Color_ChangeIntensity (JNIEnv *env, jobject theobj, jdouble ADelta)
170 jcas_Locking alock(env);
173 Quantity_Color* the_this = (Quantity_Color*) jcas_GetHandle(env,theobj);
174 the_this->ChangeIntensity((Quantity_Rate) ADelta);
177 catch (Standard_Failure) {
178 Standard_SStream Err;
179 Err << Standard_Failure::Caught();
181 jcas_ThrowException(env,Err.str().c_str());
190 JNIEXPORT void JNICALL Java_CASCADESamplesJni_Quantity_1Color_Quantity_1Color_1SetValues_11 (JNIEnv *env, jobject theobj, jshort AName)
193 jcas_Locking alock(env);
196 Quantity_Color* the_this = (Quantity_Color*) jcas_GetHandle(env,theobj);
197 the_this->SetValues((Quantity_NameOfColor) AName);
200 catch (Standard_Failure) {
201 Standard_SStream Err;
202 Err << Standard_Failure::Caught();
204 jcas_ThrowException(env,Err.str().c_str());
213 JNIEXPORT void JNICALL Java_CASCADESamplesJni_Quantity_1Color_Quantity_1Color_1SetValues_12 (JNIEnv *env, jobject theobj, jdouble R1, jdouble R2, jdouble R3, jshort AType)
216 jcas_Locking alock(env);
219 Quantity_Color* the_this = (Quantity_Color*) jcas_GetHandle(env,theobj);
220 the_this->SetValues((Quantity_Parameter) R1,(Quantity_Parameter) R2,(Quantity_Parameter) R3,(Quantity_TypeOfColor) AType);
223 catch (Standard_Failure) {
224 Standard_SStream Err;
225 Err << Standard_Failure::Caught();
227 jcas_ThrowException(env,Err.str().c_str());
236 JNIEXPORT void JNICALL Java_CASCADESamplesJni_Quantity_1Color_Delta (JNIEnv *env, jobject theobj, jobject AColor, jobject DC, jobject DI)
239 jcas_Locking alock(env);
242 Quantity_Color* the_AColor = (Quantity_Color*) jcas_GetHandle(env,AColor);
243 if ( the_AColor == NULL ) {
245 // The following assumes availability of the default constructor (what may not
246 // always be the case). Therefore explicit exception is thrown if the null
247 // object has been passed.
248 // the_AColor = new Quantity_Color ();
249 // jcas_SetHandle ( env, AColor, the_AColor );
250 jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value");
253 Standard_Real the_DC = jcas_GetReal(env,DC);
254 Standard_Real the_DI = jcas_GetReal(env,DI);
255 Quantity_Color* the_this = (Quantity_Color*) jcas_GetHandle(env,theobj);
256 the_this->Delta(*the_AColor,the_DC,the_DI);
257 jcas_SetReal(env,DC,the_DC);
258 jcas_SetReal(env,DI,the_DI);
261 catch (Standard_Failure) {
262 Standard_SStream Err;
263 Err << Standard_Failure::Caught();
265 jcas_ThrowException(env,Err.str().c_str());
274 JNIEXPORT jdouble JNICALL Java_CASCADESamplesJni_Quantity_1Color_Distance (JNIEnv *env, jobject theobj, jobject AColor)
278 jcas_Locking alock(env);
281 Quantity_Color* the_AColor = (Quantity_Color*) jcas_GetHandle(env,AColor);
282 if ( the_AColor == NULL ) {
284 // The following assumes availability of the default constructor (what may not
285 // always be the case). Therefore explicit exception is thrown if the null
286 // object has been passed.
287 // the_AColor = new Quantity_Color ();
288 // jcas_SetHandle ( env, AColor, the_AColor );
289 jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value");
292 Quantity_Color* the_this = (Quantity_Color*) jcas_GetHandle(env,theobj);
293 thejret = the_this->Distance(*the_AColor);
296 catch (Standard_Failure) {
297 Standard_SStream Err;
298 Err << Standard_Failure::Caught();
300 jcas_ThrowException(env,Err.str().c_str());
309 JNIEXPORT jdouble JNICALL Java_CASCADESamplesJni_Quantity_1Color_SquareDistance (JNIEnv *env, jobject theobj, jobject AColor)
313 jcas_Locking alock(env);
316 Quantity_Color* the_AColor = (Quantity_Color*) jcas_GetHandle(env,AColor);
317 if ( the_AColor == NULL ) {
319 // The following assumes availability of the default constructor (what may not
320 // always be the case). Therefore explicit exception is thrown if the null
321 // object has been passed.
322 // the_AColor = new Quantity_Color ();
323 // jcas_SetHandle ( env, AColor, the_AColor );
324 jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value");
327 Quantity_Color* the_this = (Quantity_Color*) jcas_GetHandle(env,theobj);
328 thejret = the_this->SquareDistance(*the_AColor);
331 catch (Standard_Failure) {
332 Standard_SStream Err;
333 Err << Standard_Failure::Caught();
335 jcas_ThrowException(env,Err.str().c_str());
344 JNIEXPORT jdouble JNICALL Java_CASCADESamplesJni_Quantity_1Color_Blue (JNIEnv *env, jobject theobj)
348 jcas_Locking alock(env);
351 Quantity_Color* the_this = (Quantity_Color*) jcas_GetHandle(env,theobj);
352 thejret = the_this->Blue();
355 catch (Standard_Failure) {
356 Standard_SStream Err;
357 Err << Standard_Failure::Caught();
359 jcas_ThrowException(env,Err.str().c_str());
368 JNIEXPORT jdouble JNICALL Java_CASCADESamplesJni_Quantity_1Color_Green (JNIEnv *env, jobject theobj)
372 jcas_Locking alock(env);
375 Quantity_Color* the_this = (Quantity_Color*) jcas_GetHandle(env,theobj);
376 thejret = the_this->Green();
379 catch (Standard_Failure) {
380 Standard_SStream Err;
381 Err << Standard_Failure::Caught();
383 jcas_ThrowException(env,Err.str().c_str());
392 JNIEXPORT jdouble JNICALL Java_CASCADESamplesJni_Quantity_1Color_Hue (JNIEnv *env, jobject theobj)
396 jcas_Locking alock(env);
399 Quantity_Color* the_this = (Quantity_Color*) jcas_GetHandle(env,theobj);
400 thejret = the_this->Hue();
403 catch (Standard_Failure) {
404 Standard_SStream Err;
405 Err << Standard_Failure::Caught();
407 jcas_ThrowException(env,Err.str().c_str());
416 JNIEXPORT jboolean JNICALL Java_CASCADESamplesJni_Quantity_1Color_IsDifferent (JNIEnv *env, jobject theobj, jobject Other)
420 jcas_Locking alock(env);
423 Quantity_Color* the_Other = (Quantity_Color*) jcas_GetHandle(env,Other);
424 if ( the_Other == NULL ) {
426 // The following assumes availability of the default constructor (what may not
427 // always be the case). Therefore explicit exception is thrown if the null
428 // object has been passed.
429 // the_Other = new Quantity_Color ();
430 // jcas_SetHandle ( env, Other, the_Other );
431 jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value");
434 Quantity_Color* the_this = (Quantity_Color*) jcas_GetHandle(env,theobj);
435 thejret = the_this->IsDifferent(*the_Other);
438 catch (Standard_Failure) {
439 Standard_SStream Err;
440 Err << Standard_Failure::Caught();
442 jcas_ThrowException(env,Err.str().c_str());
451 JNIEXPORT jboolean JNICALL Java_CASCADESamplesJni_Quantity_1Color_IsEqual (JNIEnv *env, jobject theobj, jobject Other)
455 jcas_Locking alock(env);
458 Quantity_Color* the_Other = (Quantity_Color*) jcas_GetHandle(env,Other);
459 if ( the_Other == NULL ) {
461 // The following assumes availability of the default constructor (what may not
462 // always be the case). Therefore explicit exception is thrown if the null
463 // object has been passed.
464 // the_Other = new Quantity_Color ();
465 // jcas_SetHandle ( env, Other, the_Other );
466 jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value");
469 Quantity_Color* the_this = (Quantity_Color*) jcas_GetHandle(env,theobj);
470 thejret = the_this->IsEqual(*the_Other);
473 catch (Standard_Failure) {
474 Standard_SStream Err;
475 Err << Standard_Failure::Caught();
477 jcas_ThrowException(env,Err.str().c_str());
486 JNIEXPORT jdouble JNICALL Java_CASCADESamplesJni_Quantity_1Color_Light (JNIEnv *env, jobject theobj)
490 jcas_Locking alock(env);
493 Quantity_Color* the_this = (Quantity_Color*) jcas_GetHandle(env,theobj);
494 thejret = the_this->Light();
497 catch (Standard_Failure) {
498 Standard_SStream Err;
499 Err << Standard_Failure::Caught();
501 jcas_ThrowException(env,Err.str().c_str());
510 JNIEXPORT jshort JNICALL Java_CASCADESamplesJni_Quantity_1Color_Quantity_1Color_1Name_11 (JNIEnv *env, jobject theobj)
514 jcas_Locking alock(env);
517 Quantity_Color* the_this = (Quantity_Color*) jcas_GetHandle(env,theobj);
518 thejret = the_this->Name();
521 catch (Standard_Failure) {
522 Standard_SStream Err;
523 Err << Standard_Failure::Caught();
525 jcas_ThrowException(env,Err.str().c_str());
534 JNIEXPORT jdouble JNICALL Java_CASCADESamplesJni_Quantity_1Color_Red (JNIEnv *env, jobject theobj)
538 jcas_Locking alock(env);
541 Quantity_Color* the_this = (Quantity_Color*) jcas_GetHandle(env,theobj);
542 thejret = the_this->Red();
545 catch (Standard_Failure) {
546 Standard_SStream Err;
547 Err << Standard_Failure::Caught();
549 jcas_ThrowException(env,Err.str().c_str());
558 JNIEXPORT jdouble JNICALL Java_CASCADESamplesJni_Quantity_1Color_Saturation (JNIEnv *env, jobject theobj)
562 jcas_Locking alock(env);
565 Quantity_Color* the_this = (Quantity_Color*) jcas_GetHandle(env,theobj);
566 thejret = the_this->Saturation();
569 catch (Standard_Failure) {
570 Standard_SStream Err;
571 Err << Standard_Failure::Caught();
573 jcas_ThrowException(env,Err.str().c_str());
582 JNIEXPORT void JNICALL Java_CASCADESamplesJni_Quantity_1Color_Values (JNIEnv *env, jobject theobj, jobject R1, jobject R2, jobject R3, jshort AType)
585 jcas_Locking alock(env);
588 Standard_Real the_R1 = jcas_GetReal(env,R1);
589 Standard_Real the_R2 = jcas_GetReal(env,R2);
590 Standard_Real the_R3 = jcas_GetReal(env,R3);
591 Quantity_Color* the_this = (Quantity_Color*) jcas_GetHandle(env,theobj);
592 the_this->Values(the_R1,the_R2,the_R3,(Quantity_TypeOfColor) AType);
593 jcas_SetReal(env,R1,the_R1);
594 jcas_SetReal(env,R2,the_R2);
595 jcas_SetReal(env,R3,the_R3);
598 catch (Standard_Failure) {
599 Standard_SStream Err;
600 Err << Standard_Failure::Caught();
602 jcas_ThrowException(env,Err.str().c_str());
611 JNIEXPORT void JNICALL Java_CASCADESamplesJni_Quantity_1Color_SetEpsilon (JNIEnv *env, jclass, jdouble AnEpsilon)
614 jcas_Locking alock(env);
617 Quantity_Color::SetEpsilon((Quantity_Parameter) AnEpsilon);
620 catch (Standard_Failure) {
621 Standard_SStream Err;
622 Err << Standard_Failure::Caught();
624 jcas_ThrowException(env,Err.str().c_str());
633 JNIEXPORT jdouble JNICALL Java_CASCADESamplesJni_Quantity_1Color_Epsilon (JNIEnv *env, jclass)
637 jcas_Locking alock(env);
640 thejret = Quantity_Color::Epsilon();
643 catch (Standard_Failure) {
644 Standard_SStream Err;
645 Err << Standard_Failure::Caught();
647 jcas_ThrowException(env,Err.str().c_str());
656 JNIEXPORT jshort JNICALL Java_CASCADESamplesJni_Quantity_1Color_Quantity_1Color_1Name_12 (JNIEnv *env, jclass, jdouble R, jdouble G, jdouble B)
660 jcas_Locking alock(env);
663 thejret = Quantity_Color::Name((Quantity_Parameter) R,(Quantity_Parameter) G,(Quantity_Parameter) B);
666 catch (Standard_Failure) {
667 Standard_SStream Err;
668 Err << Standard_Failure::Caught();
670 jcas_ThrowException(env,Err.str().c_str());
679 JNIEXPORT jobject JNICALL Java_CASCADESamplesJni_Quantity_1Color_StringName (JNIEnv *env, jclass, jshort AColor)
683 jcas_Locking alock(env);
686 Standard_CString sret = Quantity_Color::StringName((Quantity_NameOfColor) AColor);
687 jclass CLSret = env->FindClass("jcas/Standard_CString");
688 thejret = env->AllocObject(CLSret);
689 jcas_SetCStringValue(env,thejret,sret);
692 catch (Standard_Failure) {
693 Standard_SStream Err;
694 Err << Standard_Failure::Caught();
696 jcas_ThrowException(env,Err.str().c_str());
705 JNIEXPORT void JNICALL Java_CASCADESamplesJni_Quantity_1Color_HlsRgb (JNIEnv *env, jclass, jdouble H, jdouble L, jdouble S, jobject R, jobject G, jobject B)
708 jcas_Locking alock(env);
711 Standard_Real the_R = jcas_GetReal(env,R);
712 Standard_Real the_G = jcas_GetReal(env,G);
713 Standard_Real the_B = jcas_GetReal(env,B);
714 Quantity_Color::HlsRgb((Quantity_Parameter) H,(Quantity_Parameter) L,(Quantity_Parameter) S,the_R,the_G,the_B);
715 jcas_SetReal(env,R,the_R);
716 jcas_SetReal(env,G,the_G);
717 jcas_SetReal(env,B,the_B);
720 catch (Standard_Failure) {
721 Standard_SStream Err;
722 Err << Standard_Failure::Caught();
724 jcas_ThrowException(env,Err.str().c_str());
733 JNIEXPORT void JNICALL Java_CASCADESamplesJni_Quantity_1Color_RgbHls (JNIEnv *env, jclass, jdouble R, jdouble G, jdouble B, jobject H, jobject L, jobject S)
736 jcas_Locking alock(env);
739 Standard_Real the_H = jcas_GetReal(env,H);
740 Standard_Real the_L = jcas_GetReal(env,L);
741 Standard_Real the_S = jcas_GetReal(env,S);
742 Quantity_Color::RgbHls((Quantity_Parameter) R,(Quantity_Parameter) G,(Quantity_Parameter) B,the_H,the_L,the_S);
743 jcas_SetReal(env,H,the_H);
744 jcas_SetReal(env,L,the_L);
745 jcas_SetReal(env,S,the_S);
748 catch (Standard_Failure) {
749 Standard_SStream Err;
750 Err << Standard_Failure::Caught();
752 jcas_ThrowException(env,Err.str().c_str());
761 JNIEXPORT void JNICALL Java_CASCADESamplesJni_Quantity_1Color_Test (JNIEnv *env, jclass)
764 jcas_Locking alock(env);
767 Quantity_Color::Test();
770 catch (Standard_Failure) {
771 Standard_SStream Err;
772 Err << Standard_Failure::Caught();
774 jcas_ThrowException(env,Err.str().c_str());
783 JNIEXPORT void JNICALL Java_CASCADESamplesJni_Quantity_1Color_FinalizeValue(JNIEnv *, jclass, jlong theid)
786 Quantity_Color* theobj = (Quantity_Color*) theid;