7fd59977 |
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_Background.h> |
22 | #include <Aspect_Background.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 <Quantity_Color.hxx> |
30 | |
31 | |
32 | extern "C" { |
33 | |
34 | |
35 | JNIEXPORT void JNICALL Java_SampleHLRJni_Aspect_1Background_Aspect_1Background_1Create_11 (JNIEnv *env, jobject theobj) |
36 | { |
37 | |
38 | jcas_Locking alock(env); |
39 | { |
40 | try { |
41 | Aspect_Background* theret = new Aspect_Background(); |
42 | jcas_SetHandle(env,theobj,theret); |
43 | |
44 | } |
45 | catch (Standard_Failure) { |
46 | Standard_SStream Err; |
47 | Err << Standard_Failure::Caught(); |
48 | Err << (char) 0; |
49 | jcas_ThrowException(env,Err.str().c_str()); |
50 | } |
51 | } |
52 | alock.Release(); |
53 | |
54 | } |
55 | |
56 | |
57 | |
58 | JNIEXPORT void JNICALL Java_SampleHLRJni_Aspect_1Background_Aspect_1Background_1Create_12 (JNIEnv *env, jobject theobj, jobject AColor) |
59 | { |
60 | |
61 | jcas_Locking alock(env); |
62 | { |
63 | try { |
64 | Quantity_Color* the_AColor = (Quantity_Color*) jcas_GetHandle(env,AColor); |
65 | if ( the_AColor == NULL ) { |
66 | |
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"); |
73 | |
74 | } // end if |
75 | Aspect_Background* theret = new Aspect_Background(*the_AColor); |
76 | jcas_SetHandle(env,theobj,theret); |
77 | |
78 | } |
79 | catch (Standard_Failure) { |
80 | Standard_SStream Err; |
81 | Err << Standard_Failure::Caught(); |
82 | Err << (char) 0; |
83 | jcas_ThrowException(env,Err.str().c_str()); |
84 | } |
85 | } |
86 | alock.Release(); |
87 | |
88 | } |
89 | |
90 | |
91 | |
92 | JNIEXPORT void JNICALL Java_SampleHLRJni_Aspect_1Background_SetColor (JNIEnv *env, jobject theobj, jobject AColor) |
93 | { |
94 | |
95 | jcas_Locking alock(env); |
96 | { |
97 | try { |
98 | Quantity_Color* the_AColor = (Quantity_Color*) jcas_GetHandle(env,AColor); |
99 | if ( the_AColor == NULL ) { |
100 | |
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"); |
107 | |
108 | } // end if |
109 | Aspect_Background* the_this = (Aspect_Background*) jcas_GetHandle(env,theobj); |
110 | the_this->SetColor(*the_AColor); |
111 | |
112 | } |
113 | catch (Standard_Failure) { |
114 | Standard_SStream Err; |
115 | Err << Standard_Failure::Caught(); |
116 | Err << (char) 0; |
117 | jcas_ThrowException(env,Err.str().c_str()); |
118 | } |
119 | } |
120 | alock.Release(); |
121 | |
122 | } |
123 | |
124 | |
125 | |
126 | JNIEXPORT jobject JNICALL Java_SampleHLRJni_Aspect_1Background_Color (JNIEnv *env, jobject theobj) |
127 | { |
128 | jobject thejret; |
129 | |
130 | jcas_Locking alock(env); |
131 | { |
132 | try { |
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); |
136 | |
137 | } |
138 | catch (Standard_Failure) { |
139 | Standard_SStream Err; |
140 | Err << Standard_Failure::Caught(); |
141 | Err << (char) 0; |
142 | jcas_ThrowException(env,Err.str().c_str()); |
143 | } |
144 | } |
145 | alock.Release(); |
146 | return thejret; |
147 | } |
148 | |
149 | |
150 | |
151 | JNIEXPORT void JNICALL Java_SampleHLRJni_Aspect_1Background_FinalizeValue(JNIEnv *, jclass, jlong theid) |
152 | { |
153 | if (theid) { |
154 | Aspect_Background* theobj = (Aspect_Background*) theid; |
155 | delete theobj; |
156 | } |
157 | } |
158 | |
159 | |
160 | } |