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_Background.h>
22 #include <Aspect_Background.hxx>
25 #include <Standard_ErrorHandler.hxx>
26 #include <Standard_Failure.hxx>
27 #include <Standard_SStream.hxx>
29 #include <Quantity_Color.hxx>
35 JNIEXPORT void JNICALL Java_SampleHLRJni_Aspect_1Background_Aspect_1Background_1Create_11 (JNIEnv *env, jobject theobj)
38 jcas_Locking alock(env);
41 Aspect_Background* theret = new Aspect_Background();
42 jcas_SetHandle(env,theobj,theret);
45 catch (Standard_Failure) {
47 Err << Standard_Failure::Caught();
49 jcas_ThrowException(env,Err.str().c_str());
58 JNIEXPORT void JNICALL Java_SampleHLRJni_Aspect_1Background_Aspect_1Background_1Create_12 (JNIEnv *env, jobject theobj, jobject AColor)
61 jcas_Locking alock(env);
64 Quantity_Color* the_AColor = (Quantity_Color*) jcas_GetHandle(env,AColor);
65 if ( the_AColor == NULL ) {
67 // The following assumes availability of the default constructor (what may not
68 // always be the case). Therefore explicit exception is thrown if the null
69 // object has been passed.
70 // the_AColor = new Quantity_Color ();
71 // jcas_SetHandle ( env, AColor, the_AColor );
72 jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value");
75 Aspect_Background* theret = new Aspect_Background(*the_AColor);
76 jcas_SetHandle(env,theobj,theret);
79 catch (Standard_Failure) {
81 Err << Standard_Failure::Caught();
83 jcas_ThrowException(env,Err.str().c_str());
92 JNIEXPORT void JNICALL Java_SampleHLRJni_Aspect_1Background_SetColor (JNIEnv *env, jobject theobj, jobject AColor)
95 jcas_Locking alock(env);
98 Quantity_Color* the_AColor = (Quantity_Color*) jcas_GetHandle(env,AColor);
99 if ( the_AColor == NULL ) {
101 // The following assumes availability of the default constructor (what may not
102 // always be the case). Therefore explicit exception is thrown if the null
103 // object has been passed.
104 // the_AColor = new Quantity_Color ();
105 // jcas_SetHandle ( env, AColor, the_AColor );
106 jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value");
109 Aspect_Background* the_this = (Aspect_Background*) jcas_GetHandle(env,theobj);
110 the_this->SetColor(*the_AColor);
113 catch (Standard_Failure) {
114 Standard_SStream Err;
115 Err << Standard_Failure::Caught();
117 jcas_ThrowException(env,Err.str().c_str());
126 JNIEXPORT jobject JNICALL Java_SampleHLRJni_Aspect_1Background_Color (JNIEnv *env, jobject theobj)
130 jcas_Locking alock(env);
133 Aspect_Background* the_this = (Aspect_Background*) jcas_GetHandle(env,theobj);
134 Quantity_Color* theret = new Quantity_Color(the_this->Color());
135 thejret = jcas_CreateObject(env,"CASCADESamplesJni/Quantity_Color",theret);
138 catch (Standard_Failure) {
139 Standard_SStream Err;
140 Err << Standard_Failure::Caught();
142 jcas_ThrowException(env,Err.str().c_str());
151 JNIEXPORT void JNICALL Java_SampleHLRJni_Aspect_1Background_FinalizeValue(JNIEnv *, jclass, jlong theid)
154 Aspect_Background* theobj = (Aspect_Background*) theid;