1 #include "CallRenderer.hxx"
2 /* Generated by GIWS (version 2.0.0) with command:
3 giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/renderer.giws.xml
7 Copyright 2007-2008 INRIA
8 Copyright 2008-2011 DIGITEO
9 Copyright 2011-2012 Scilab Enterprises
11 Author : Sylvestre Ledru & others
13 This is generated code.
15 This software is a computer program whose purpose is to hide the complexity
16 of accessing Java objects/methods from C++ code.
18 This software is governed by the CeCILL-B license under French law and
19 abiding by the rules of distribution of free software. You can use,
20 modify and/ or redistribute the software under the terms of the CeCILL-B
21 license as circulated by CEA, CNRS and INRIA at the following URL
22 "http://www.cecill.info".
24 As a counterpart to the access to the source code and rights to copy,
25 modify and redistribute granted by the license, users are provided only
26 with a limited warranty and the software's author, the holder of the
27 economic rights, and the successive licensors have only limited
30 In this respect, the user's attention is drawn to the risks associated
31 with loading, using, modifying and/or developing or reproducing the
32 software by the user in light of its specific status of free software,
33 that may mean that it is complicated to manipulate, and that also
34 therefore means that it is reserved for developers and experienced
35 professionals having in-depth computer knowledge. Users are therefore
36 encouraged to load and test the software's suitability as regards their
37 requirements in conditions enabling the security of their systems and/or
38 data to be ensured and, more generally, to use and operate it in the
39 same conditions as regards security.
41 The fact that you are presently reading this means that you have had
42 knowledge of the CeCILL-B license and that you accept its terms.
45 namespace org_scilab_modules_renderer {
47 // Static declarations (if any)
49 // Returns the current env
51 JNIEnv * CallRenderer::getCurrentEnv() {
52 JNIEnv * curEnv = NULL;
53 jint res=this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
55 throw GiwsException::JniException(getCurrentEnv());
61 CallRenderer::~CallRenderer() {
62 JNIEnv * curEnv = NULL;
63 this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
65 curEnv->DeleteGlobalRef(this->instance);
66 curEnv->DeleteGlobalRef(this->instanceClass);
69 CallRenderer::CallRenderer(JavaVM * jvm_) {
70 jmethodID constructObject = NULL ;
71 jobject localInstance ;
74 const std::string construct="<init>";
75 const std::string param="()V";
78 JNIEnv * curEnv = getCurrentEnv();
80 localClass = curEnv->FindClass( this->className().c_str() ) ;
81 if (localClass == NULL) {
82 throw GiwsException::JniClassNotFoundException(curEnv, this->className());
85 this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
87 /* localClass is not needed anymore */
88 curEnv->DeleteLocalRef(localClass);
90 if (this->instanceClass == NULL) {
91 throw GiwsException::JniObjectCreationException(curEnv, this->className());
95 constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ;
96 if(constructObject == NULL){
97 throw GiwsException::JniObjectCreationException(curEnv, this->className());
100 localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ;
101 if(localInstance == NULL){
102 throw GiwsException::JniObjectCreationException(curEnv, this->className());
105 this->instance = curEnv->NewGlobalRef(localInstance) ;
106 if(this->instance == NULL){
107 throw GiwsException::JniObjectCreationException(curEnv, this->className());
109 /* localInstance not needed anymore */
110 curEnv->DeleteLocalRef(localInstance);
112 /* Methods ID set to NULL */
113 voidstartInteractiveZoomjstringjava_lang_StringID=NULL;
114 voidupdateTextBoundsjstringjava_lang_StringID=NULL;
115 voidupdateSubwinScalejstringjava_lang_StringID=NULL;
116 jdoubleArray_get2dViewCoordinatesjstringjava_lang_StringjdoubleArray_doubledoubleID=NULL;
117 jdoubleArray_getPixelFrom2dViewCoordinatesjstringjava_lang_StringjdoubleArray_doubledoubleID=NULL;
118 jdoubleArray_get2dViewFromPixelCoordinatesjstringjava_lang_StringjdoubleArray_doubledoubleID=NULL;
119 jdoubleArray_getViewingAreajstringjava_lang_StringID=NULL;
124 CallRenderer::CallRenderer(JavaVM * jvm_, jobject JObj) {
127 JNIEnv * curEnv = getCurrentEnv();
129 jclass localClass = curEnv->GetObjectClass(JObj);
130 this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
131 curEnv->DeleteLocalRef(localClass);
133 if (this->instanceClass == NULL) {
134 throw GiwsException::JniObjectCreationException(curEnv, this->className());
137 this->instance = curEnv->NewGlobalRef(JObj) ;
138 if(this->instance == NULL){
139 throw GiwsException::JniObjectCreationException(curEnv, this->className());
141 /* Methods ID set to NULL */
142 voidstartInteractiveZoomjstringjava_lang_StringID=NULL;
143 voidupdateTextBoundsjstringjava_lang_StringID=NULL;
144 voidupdateSubwinScalejstringjava_lang_StringID=NULL;
145 jdoubleArray_get2dViewCoordinatesjstringjava_lang_StringjdoubleArray_doubledoubleID=NULL;
146 jdoubleArray_getPixelFrom2dViewCoordinatesjstringjava_lang_StringjdoubleArray_doubledoubleID=NULL;
147 jdoubleArray_get2dViewFromPixelCoordinatesjstringjava_lang_StringjdoubleArray_doubledoubleID=NULL;
148 jdoubleArray_getViewingAreajstringjava_lang_StringID=NULL;
155 void CallRenderer::synchronize() {
156 if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK) {
157 throw GiwsException::JniMonitorException(getCurrentEnv(), "CallRenderer");
161 void CallRenderer::endSynchronize() {
162 if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK) {
163 throw GiwsException::JniMonitorException(getCurrentEnv(), "CallRenderer");
168 void CallRenderer::startInteractiveZoom (JavaVM * jvm_, char const* id){
170 JNIEnv * curEnv = NULL;
171 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
172 jclass cls = curEnv->FindClass( className().c_str() );
174 jmethodID voidstartInteractiveZoomjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "startInteractiveZoom", "(Ljava/lang/String;)V" ) ;
175 if (voidstartInteractiveZoomjstringjava_lang_StringID == NULL) {
176 throw GiwsException::JniMethodNotFoundException(curEnv, "startInteractiveZoom");
179 jstring id_ = curEnv->NewStringUTF( id );
180 if (id != NULL && id_ == NULL)
182 throw GiwsException::JniBadAllocException(curEnv);
186 curEnv->CallStaticVoidMethod(cls, voidstartInteractiveZoomjstringjava_lang_StringID ,id_);
187 curEnv->DeleteLocalRef(id_);
188 curEnv->DeleteLocalRef(cls);
189 if (curEnv->ExceptionCheck()) {
190 throw GiwsException::JniCallMethodException(curEnv);
194 void CallRenderer::updateTextBounds (JavaVM * jvm_, char const* id){
196 JNIEnv * curEnv = NULL;
197 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
198 jclass cls = curEnv->FindClass( className().c_str() );
200 jmethodID voidupdateTextBoundsjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "updateTextBounds", "(Ljava/lang/String;)V" ) ;
201 if (voidupdateTextBoundsjstringjava_lang_StringID == NULL) {
202 throw GiwsException::JniMethodNotFoundException(curEnv, "updateTextBounds");
205 jstring id_ = curEnv->NewStringUTF( id );
206 if (id != NULL && id_ == NULL)
208 throw GiwsException::JniBadAllocException(curEnv);
212 curEnv->CallStaticVoidMethod(cls, voidupdateTextBoundsjstringjava_lang_StringID ,id_);
213 curEnv->DeleteLocalRef(id_);
214 curEnv->DeleteLocalRef(cls);
215 if (curEnv->ExceptionCheck()) {
216 throw GiwsException::JniCallMethodException(curEnv);
220 void CallRenderer::updateSubwinScale (JavaVM * jvm_, char const* id){
222 JNIEnv * curEnv = NULL;
223 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
224 jclass cls = curEnv->FindClass( className().c_str() );
226 jmethodID voidupdateSubwinScalejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "updateSubwinScale", "(Ljava/lang/String;)V" ) ;
227 if (voidupdateSubwinScalejstringjava_lang_StringID == NULL) {
228 throw GiwsException::JniMethodNotFoundException(curEnv, "updateSubwinScale");
231 jstring id_ = curEnv->NewStringUTF( id );
232 if (id != NULL && id_ == NULL)
234 throw GiwsException::JniBadAllocException(curEnv);
238 curEnv->CallStaticVoidMethod(cls, voidupdateSubwinScalejstringjava_lang_StringID ,id_);
239 curEnv->DeleteLocalRef(id_);
240 curEnv->DeleteLocalRef(cls);
241 if (curEnv->ExceptionCheck()) {
242 throw GiwsException::JniCallMethodException(curEnv);
246 double* CallRenderer::get2dViewCoordinates (JavaVM * jvm_, char const* id, double const* coords, int coordsSize){
248 JNIEnv * curEnv = NULL;
249 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
250 jclass cls = curEnv->FindClass( className().c_str() );
252 jmethodID jdoubleArray_get2dViewCoordinatesjstringjava_lang_StringjdoubleArray_doubledoubleID = curEnv->GetStaticMethodID(cls, "get2dViewCoordinates", "(Ljava/lang/String;[D)[D" ) ;
253 if (jdoubleArray_get2dViewCoordinatesjstringjava_lang_StringjdoubleArray_doubledoubleID == NULL) {
254 throw GiwsException::JniMethodNotFoundException(curEnv, "get2dViewCoordinates");
257 jstring id_ = curEnv->NewStringUTF( id );
258 if (id != NULL && id_ == NULL)
260 throw GiwsException::JniBadAllocException(curEnv);
264 jdoubleArray coords_ = curEnv->NewDoubleArray( coordsSize ) ;
268 // check that allocation succeed
269 throw GiwsException::JniBadAllocException(curEnv);
272 curEnv->SetDoubleArrayRegion( coords_, 0, coordsSize, (jdouble*)(coords) ) ;
275 jdoubleArray res = static_cast<jdoubleArray>( curEnv->CallStaticObjectMethod(cls, jdoubleArray_get2dViewCoordinatesjstringjava_lang_StringjdoubleArray_doubledoubleID ,id_, coords_));
276 if (res == NULL) { return NULL; }
277 if (curEnv->ExceptionCheck()) {
278 throw GiwsException::JniCallMethodException(curEnv);
280 lenRow = curEnv->GetArrayLength(res);
281 jboolean isCopy = JNI_FALSE;
283 /* GetPrimitiveArrayCritical is faster than getXXXArrayElements */
284 jdouble *resultsArray = static_cast<jdouble *>(curEnv->GetPrimitiveArrayCritical(res, &isCopy));
285 double* myArray= new double[ lenRow];
287 for (jsize i = 0; i < lenRow; i++){
288 myArray[i]=resultsArray[i];
290 curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
292 curEnv->DeleteLocalRef(res);
293 curEnv->DeleteLocalRef(id_);
294 curEnv->DeleteLocalRef(coords_);
295 curEnv->DeleteLocalRef(cls);
296 if (curEnv->ExceptionCheck()) {
298 throw GiwsException::JniCallMethodException(curEnv);
304 double* CallRenderer::getPixelFrom2dViewCoordinates (JavaVM * jvm_, char const* id, double const* coords, int coordsSize){
306 JNIEnv * curEnv = NULL;
307 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
308 jclass cls = curEnv->FindClass( className().c_str() );
310 jmethodID jdoubleArray_getPixelFrom2dViewCoordinatesjstringjava_lang_StringjdoubleArray_doubledoubleID = curEnv->GetStaticMethodID(cls, "getPixelFrom2dViewCoordinates", "(Ljava/lang/String;[D)[D" ) ;
311 if (jdoubleArray_getPixelFrom2dViewCoordinatesjstringjava_lang_StringjdoubleArray_doubledoubleID == NULL) {
312 throw GiwsException::JniMethodNotFoundException(curEnv, "getPixelFrom2dViewCoordinates");
315 jstring id_ = curEnv->NewStringUTF( id );
316 if (id != NULL && id_ == NULL)
318 throw GiwsException::JniBadAllocException(curEnv);
322 jdoubleArray coords_ = curEnv->NewDoubleArray( coordsSize ) ;
326 // check that allocation succeed
327 throw GiwsException::JniBadAllocException(curEnv);
330 curEnv->SetDoubleArrayRegion( coords_, 0, coordsSize, (jdouble*)(coords) ) ;
333 jdoubleArray res = static_cast<jdoubleArray>( curEnv->CallStaticObjectMethod(cls, jdoubleArray_getPixelFrom2dViewCoordinatesjstringjava_lang_StringjdoubleArray_doubledoubleID ,id_, coords_));
334 if (res == NULL) { return NULL; }
335 if (curEnv->ExceptionCheck()) {
336 throw GiwsException::JniCallMethodException(curEnv);
338 lenRow = curEnv->GetArrayLength(res);
339 jboolean isCopy = JNI_FALSE;
341 /* GetPrimitiveArrayCritical is faster than getXXXArrayElements */
342 jdouble *resultsArray = static_cast<jdouble *>(curEnv->GetPrimitiveArrayCritical(res, &isCopy));
343 double* myArray= new double[ lenRow];
345 for (jsize i = 0; i < lenRow; i++){
346 myArray[i]=resultsArray[i];
348 curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
350 curEnv->DeleteLocalRef(res);
351 curEnv->DeleteLocalRef(id_);
352 curEnv->DeleteLocalRef(coords_);
353 curEnv->DeleteLocalRef(cls);
354 if (curEnv->ExceptionCheck()) {
356 throw GiwsException::JniCallMethodException(curEnv);
362 double* CallRenderer::get2dViewFromPixelCoordinates (JavaVM * jvm_, char const* id, double const* coords, int coordsSize){
364 JNIEnv * curEnv = NULL;
365 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
366 jclass cls = curEnv->FindClass( className().c_str() );
368 jmethodID jdoubleArray_get2dViewFromPixelCoordinatesjstringjava_lang_StringjdoubleArray_doubledoubleID = curEnv->GetStaticMethodID(cls, "get2dViewFromPixelCoordinates", "(Ljava/lang/String;[D)[D" ) ;
369 if (jdoubleArray_get2dViewFromPixelCoordinatesjstringjava_lang_StringjdoubleArray_doubledoubleID == NULL) {
370 throw GiwsException::JniMethodNotFoundException(curEnv, "get2dViewFromPixelCoordinates");
373 jstring id_ = curEnv->NewStringUTF( id );
374 if (id != NULL && id_ == NULL)
376 throw GiwsException::JniBadAllocException(curEnv);
380 jdoubleArray coords_ = curEnv->NewDoubleArray( coordsSize ) ;
384 // check that allocation succeed
385 throw GiwsException::JniBadAllocException(curEnv);
388 curEnv->SetDoubleArrayRegion( coords_, 0, coordsSize, (jdouble*)(coords) ) ;
391 jdoubleArray res = static_cast<jdoubleArray>( curEnv->CallStaticObjectMethod(cls, jdoubleArray_get2dViewFromPixelCoordinatesjstringjava_lang_StringjdoubleArray_doubledoubleID ,id_, coords_));
392 if (res == NULL) { return NULL; }
393 if (curEnv->ExceptionCheck()) {
394 throw GiwsException::JniCallMethodException(curEnv);
396 lenRow = curEnv->GetArrayLength(res);
397 jboolean isCopy = JNI_FALSE;
399 /* GetPrimitiveArrayCritical is faster than getXXXArrayElements */
400 jdouble *resultsArray = static_cast<jdouble *>(curEnv->GetPrimitiveArrayCritical(res, &isCopy));
401 double* myArray= new double[ lenRow];
403 for (jsize i = 0; i < lenRow; i++){
404 myArray[i]=resultsArray[i];
406 curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
408 curEnv->DeleteLocalRef(res);
409 curEnv->DeleteLocalRef(id_);
410 curEnv->DeleteLocalRef(coords_);
411 curEnv->DeleteLocalRef(cls);
412 if (curEnv->ExceptionCheck()) {
414 throw GiwsException::JniCallMethodException(curEnv);
420 double* CallRenderer::getViewingArea (JavaVM * jvm_, char const* id){
422 JNIEnv * curEnv = NULL;
423 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
424 jclass cls = curEnv->FindClass( className().c_str() );
426 jmethodID jdoubleArray_getViewingAreajstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "getViewingArea", "(Ljava/lang/String;)[D" ) ;
427 if (jdoubleArray_getViewingAreajstringjava_lang_StringID == NULL) {
428 throw GiwsException::JniMethodNotFoundException(curEnv, "getViewingArea");
431 jstring id_ = curEnv->NewStringUTF( id );
432 if (id != NULL && id_ == NULL)
434 throw GiwsException::JniBadAllocException(curEnv);
438 jdoubleArray res = static_cast<jdoubleArray>( curEnv->CallStaticObjectMethod(cls, jdoubleArray_getViewingAreajstringjava_lang_StringID ,id_));
439 if (res == NULL) { return NULL; }
440 if (curEnv->ExceptionCheck()) {
441 throw GiwsException::JniCallMethodException(curEnv);
443 lenRow = curEnv->GetArrayLength(res);
444 jboolean isCopy = JNI_FALSE;
446 /* GetPrimitiveArrayCritical is faster than getXXXArrayElements */
447 jdouble *resultsArray = static_cast<jdouble *>(curEnv->GetPrimitiveArrayCritical(res, &isCopy));
448 double* myArray= new double[ lenRow];
450 for (jsize i = 0; i < lenRow; i++){
451 myArray[i]=resultsArray[i];
453 curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
455 curEnv->DeleteLocalRef(res);
456 curEnv->DeleteLocalRef(id_);
457 curEnv->DeleteLocalRef(cls);
458 if (curEnv->ExceptionCheck()) {
460 throw GiwsException::JniCallMethodException(curEnv);