Integration of OCCT 6.5.0 from SVN
[occt.git] / samples / java / drv / SampleHLRJni / SampleHLRJni_Aspect_ColorRampColorMap_java.cxx
CommitLineData
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_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
35extern "C" {
36
37
38JNIEXPORT void JNICALL Java_SampleHLRJni_Aspect_1ColorRampColorMap_Aspect_1ColorRampColorMap_1Create_11 (JNIEnv *env, jobject theobj, jint basepixel, jint dimension, jobject color)
39{
40
41jcas_Locking alock(env);
42{
43try {
44Quantity_Color* the_color = (Quantity_Color*) jcas_GetHandle(env,color);
45if ( 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
55Handle(Aspect_ColorRampColorMap)* theret = new Handle(Aspect_ColorRampColorMap);
56*theret = new Aspect_ColorRampColorMap((Standard_Integer) basepixel,(Standard_Integer) dimension,*the_color);
57jcas_SetHandle(env,theobj,theret);
58
59}
60catch (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}
67alock.Release();
68
69}
70
71
72
73JNIEXPORT void JNICALL Java_SampleHLRJni_Aspect_1ColorRampColorMap_Aspect_1ColorRampColorMap_1Create_12 (JNIEnv *env, jobject theobj, jint basepixel, jint dimension, jshort colorName)
74{
75
76jcas_Locking alock(env);
77{
78try {
79Handle(Aspect_ColorRampColorMap)* theret = new Handle(Aspect_ColorRampColorMap);
80*theret = new Aspect_ColorRampColorMap((Standard_Integer) basepixel,(Standard_Integer) dimension,(Quantity_NameOfColor) colorName);
81jcas_SetHandle(env,theobj,theret);
82
83}
84catch (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}
91alock.Release();
92
93}
94
95
96
97JNIEXPORT void JNICALL Java_SampleHLRJni_Aspect_1ColorRampColorMap_ColorRampDefinition (JNIEnv *env, jobject theobj, jobject basepixel, jobject dimension, jobject color)
98{
99
100jcas_Locking alock(env);
101{
102try {
103Standard_Integer the_basepixel = jcas_GetInteger(env,basepixel);
104Standard_Integer the_dimension = jcas_GetInteger(env,dimension);
105Quantity_Color* the_color = (Quantity_Color*) jcas_GetHandle(env,color);
106if ( 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
116Handle(Aspect_ColorRampColorMap) the_this = *((Handle(Aspect_ColorRampColorMap)*) jcas_GetHandle(env,theobj));
117the_this->ColorRampDefinition(the_basepixel,the_dimension,*the_color);
118jcas_SetInteger(env,basepixel,the_basepixel);
119jcas_SetInteger(env,dimension,the_dimension);
120
121}
122catch (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}
129alock.Release();
130
131}
132
133
134
135JNIEXPORT jint JNICALL Java_SampleHLRJni_Aspect_1ColorRampColorMap_FindColorMapIndex (JNIEnv *env, jobject theobj, jint ColorMapEntryIndex)
136{
137jint thejret;
138
139jcas_Locking alock(env);
140{
141try {
142Handle(Aspect_ColorRampColorMap) the_this = *((Handle(Aspect_ColorRampColorMap)*) jcas_GetHandle(env,theobj));
143 thejret = the_this->FindColorMapIndex((Standard_Integer) ColorMapEntryIndex);
144
145}
146catch (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}
153alock.Release();
154return thejret;
155}
156
157
158
159JNIEXPORT jobject JNICALL Java_SampleHLRJni_Aspect_1ColorRampColorMap_FindEntry (JNIEnv *env, jobject theobj, jint AColorMapEntryIndex)
160{
161jobject thejret;
162
163jcas_Locking alock(env);
164{
165try {
166Handle(Aspect_ColorRampColorMap) the_this = *((Handle(Aspect_ColorRampColorMap)*) jcas_GetHandle(env,theobj));
167const Aspect_ColorMapEntry& theret = the_this->FindEntry((Standard_Integer) AColorMapEntryIndex);
168thejret = jcas_CreateObject(env,"CASCADESamplesJni/Aspect_ColorMapEntry",&theret,0);
169
170}
171catch (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}
178alock.Release();
179return thejret;
180}
181
182
183
184JNIEXPORT jint JNICALL Java_SampleHLRJni_Aspect_1ColorRampColorMap_NearestColorMapIndex (JNIEnv *env, jobject theobj, jobject aColor)
185{
186jint thejret;
187
188jcas_Locking alock(env);
189{
190try {
191Quantity_Color* the_aColor = (Quantity_Color*) jcas_GetHandle(env,aColor);
192if ( 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
202Handle(Aspect_ColorRampColorMap) the_this = *((Handle(Aspect_ColorRampColorMap)*) jcas_GetHandle(env,theobj));
203 thejret = the_this->NearestColorMapIndex(*the_aColor);
204
205}
206catch (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}
213alock.Release();
214return thejret;
215}
216
217
218
219JNIEXPORT jobject JNICALL Java_SampleHLRJni_Aspect_1ColorRampColorMap_NearestEntry (JNIEnv *env, jobject theobj, jobject aColor)
220{
221jobject thejret;
222
223jcas_Locking alock(env);
224{
225try {
226Quantity_Color* the_aColor = (Quantity_Color*) jcas_GetHandle(env,aColor);
227if ( 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
237Handle(Aspect_ColorRampColorMap) the_this = *((Handle(Aspect_ColorRampColorMap)*) jcas_GetHandle(env,theobj));
238const Aspect_ColorMapEntry& theret = the_this->NearestEntry(*the_aColor);
239thejret = jcas_CreateObject(env,"CASCADESamplesJni/Aspect_ColorMapEntry",&theret,0);
240
241}
242catch (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}
249alock.Release();
250return thejret;
251}
252
253
254
255JNIEXPORT jint JNICALL Java_SampleHLRJni_Aspect_1ColorRampColorMap_AddEntry (JNIEnv *env, jobject theobj, jobject aColor)
256{
257jint thejret;
258
259jcas_Locking alock(env);
260{
261try {
262Quantity_Color* the_aColor = (Quantity_Color*) jcas_GetHandle(env,aColor);
263if ( 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
273Handle(Aspect_ColorRampColorMap) the_this = *((Handle(Aspect_ColorRampColorMap)*) jcas_GetHandle(env,theobj));
274 thejret = the_this->AddEntry(*the_aColor);
275
276}
277catch (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}
284alock.Release();
285return thejret;
286}
287
288
289}