1 #include "Builder.hxx"
2 /* Generated by GIWS (version 2.0.2) with command:
3 giws --disable-return-size-array --output-dir src\jni --throws-exception-on-error --description-file src\jni\builder.giws.xml
4 */
5 /*
6
7 This is generated code.
8
9 This software is a computer program whose purpose is to hide the complexity
10 of accessing Java objects/methods from C++ code.
11
12 Copyright (C) 2012 - 2016 - Scilab Enterprises
13
14 This file is hereby licensed under the terms of the GNU GPL v2.0,
15 pursuant to article 5.3.4 of the CeCILL v.2.1.
16 This file was originally licensed under the terms of the CeCILL v2.1,
17 and continues to be available under such terms.
18 For more information, see the COPYING file which you should have received
19 along with this program.
20 */
21
22 namespace org_scilab_modules_graphic_objects_builder {
23
24 // Static declarations (if any)
25
26 // Returns the current env
27
getCurrentEnv()28 JNIEnv * Builder::getCurrentEnv() {
29 JNIEnv * curEnv = NULL;
30 jint res=this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
31 if (res != JNI_OK) {
32 throw GiwsException::JniException(getCurrentEnv());
33 }
34 return curEnv;
35 }
36 // Destructor
37
~Builder()38 Builder::~Builder() {
39 JNIEnv * curEnv = NULL;
40 this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
41 curEnv->DeleteGlobalRef(this->instance);
42 curEnv->DeleteGlobalRef(this->instanceClass);
43 curEnv->DeleteGlobalRef(this->stringArrayClass);}
44 // Constructors
Builder(JavaVM * jvm_)45 Builder::Builder(JavaVM * jvm_) {
46 jmethodID constructObject = NULL ;
47 jobject localInstance ;
48 jclass localClass ;
49
50 const std::string construct="<init>";
51 const std::string param="()V";
52 jvm=jvm_;
53
54 JNIEnv * curEnv = getCurrentEnv();
55
56 localClass = curEnv->FindClass( this->className().c_str() ) ;
57 if (localClass == NULL) {
58 throw GiwsException::JniClassNotFoundException(curEnv, this->className());
59 }
60
61 this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
62
63 /* localClass is not needed anymore */
64 curEnv->DeleteLocalRef(localClass);
65
66 if (this->instanceClass == NULL) {
67 throw GiwsException::JniObjectCreationException(curEnv, this->className());
68 }
69
70
71 constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ;
72 if(constructObject == NULL){
73 throw GiwsException::JniObjectCreationException(curEnv, this->className());
74 }
75
76 localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ;
77 if(localInstance == NULL){
78 throw GiwsException::JniObjectCreationException(curEnv, this->className());
79 }
80
81 this->instance = curEnv->NewGlobalRef(localInstance) ;
82 if(this->instance == NULL){
83 throw GiwsException::JniObjectCreationException(curEnv, this->className());
84 }
85 /* localInstance not needed anymore */
86 curEnv->DeleteLocalRef(localInstance);
87
88 /* Methods ID set to NULL */
89 jintcreateRectjintintjdoubledoublejdoubledoublejdoubledoublejdoubledoublejintintjintintjintintjintintID=NULL;
90 jintcloneGraphicContextjintintjintintID=NULL;
91 jintcloneFontContextjintintjintintID=NULL;
92 jintcreateHiddenLabeljintintID=NULL;
93 jbooleanisAxesRedrawingjintintID=NULL;
94 jintcreateLabeljintintjintintID=NULL;
95 jintcreateNewFigureWithAxesID=NULL;
96 jintcreateFigurejbooleanbooleanjintintjintintjbooleanbooleanjbooleanbooleanID=NULL;
97 voidcloneMenusjintintjintintID=NULL;
98 jintcloneAxesModeljintintID=NULL;
99 jintcreateSubWinjintintID=NULL;
100 jintcreateTextjintintjobjectArray_java_lang_Stringjava_lang_StringjintintjintintjdoubledoublejdoubledoublejbooleanbooleanjdoubleArray_doubledoublejintintjintintjbooleanbooleanjintintjbooleanbooleanjbooleanbooleanjbooleanbooleanjbooleanbooleanjintintID=NULL;
101 jintcreateArcjintintjdoubledoublejdoubledoublejdoubledoublejdoubledoublejdoubledoublejdoubledoublejintintjbooleanbooleanjintintjbooleanbooleanjbooleanbooleanjbooleanbooleanID=NULL;
102 jintcreateAxisjintintjintintjintintjdoubleArray_doubledoublejdoubleArray_doubledoublejintintjstringjava_lang_StringjintintjintintjintintjbooleanbooleanID=NULL;
103 jintcreateCompoundjintintjintArray_intintID=NULL;
104 jintcreateCompoundSeqjintintjintintID=NULL;
105 jintcreateFecjintintjdoubleArray_doubledoublejintArray_intintjintArray_intintjbooleanbooleanID=NULL;
106 jintcreateGrayplotjintintjintintjdoubleArray_doubledoublejintintjintintID=NULL;
107 jintcreatePolylinejintintjbooleanbooleanjintintjintintjbooleanbooleanjintArray_intintjintintjbooleanbooleanjintintjbooleanbooleanjintintjbooleanbooleanjbooleanbooleanjbooleanbooleanjbooleanbooleanjbooleanbooleanID=NULL;
108 jintcreateLegendjintintjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintID=NULL;
109 jintcreateSegsjintintjdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejbooleanbooleanjintArray_intintjdoubledoubleID=NULL;
110 jintcreateChampjintintjdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubledoublejbooleanbooleanID=NULL;
111 jintcreateSurfacejintintjintintjintintjintintID=NULL;
112 voidinitSubWinTo3djintintjstringjava_lang_StringjbooleanbooleanjintArray_intintjdoubledoublejdoubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoubleID=NULL;
113 jintcreateLightjintintjintintjbooleanbooleanjdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoubleID=NULL;
114
115
116 }
117
Builder(JavaVM * jvm_,jobject JObj)118 Builder::Builder(JavaVM * jvm_, jobject JObj) {
119 jvm=jvm_;
120
121 JNIEnv * curEnv = getCurrentEnv();
122
123 jclass localClass = curEnv->GetObjectClass(JObj);
124 this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
125 curEnv->DeleteLocalRef(localClass);
126
127 if (this->instanceClass == NULL) {
128 throw GiwsException::JniObjectCreationException(curEnv, this->className());
129 }
130
131 this->instance = curEnv->NewGlobalRef(JObj) ;
132 if(this->instance == NULL){
133 throw GiwsException::JniObjectCreationException(curEnv, this->className());
134 }
135 /* Methods ID set to NULL */
136 jintcreateRectjintintjdoubledoublejdoubledoublejdoubledoublejdoubledoublejintintjintintjintintjintintID=NULL;
137 jintcloneGraphicContextjintintjintintID=NULL;
138 jintcloneFontContextjintintjintintID=NULL;
139 jintcreateHiddenLabeljintintID=NULL;
140 jbooleanisAxesRedrawingjintintID=NULL;
141 jintcreateLabeljintintjintintID=NULL;
142 jintcreateNewFigureWithAxesID=NULL;
143 jintcreateFigurejbooleanbooleanjintintjintintjbooleanbooleanjbooleanbooleanID=NULL;
144 voidcloneMenusjintintjintintID=NULL;
145 jintcloneAxesModeljintintID=NULL;
146 jintcreateSubWinjintintID=NULL;
147 jintcreateTextjintintjobjectArray_java_lang_Stringjava_lang_StringjintintjintintjdoubledoublejdoubledoublejbooleanbooleanjdoubleArray_doubledoublejintintjintintjbooleanbooleanjintintjbooleanbooleanjbooleanbooleanjbooleanbooleanjbooleanbooleanjintintID=NULL;
148 jintcreateArcjintintjdoubledoublejdoubledoublejdoubledoublejdoubledoublejdoubledoublejdoubledoublejintintjbooleanbooleanjintintjbooleanbooleanjbooleanbooleanjbooleanbooleanID=NULL;
149 jintcreateAxisjintintjintintjintintjdoubleArray_doubledoublejdoubleArray_doubledoublejintintjstringjava_lang_StringjintintjintintjintintjbooleanbooleanID=NULL;
150 jintcreateCompoundjintintjintArray_intintID=NULL;
151 jintcreateCompoundSeqjintintjintintID=NULL;
152 jintcreateFecjintintjdoubleArray_doubledoublejintArray_intintjintArray_intintjbooleanbooleanID=NULL;
153 jintcreateGrayplotjintintjintintjdoubleArray_doubledoublejintintjintintID=NULL;
154 jintcreatePolylinejintintjbooleanbooleanjintintjintintjbooleanbooleanjintArray_intintjintintjbooleanbooleanjintintjbooleanbooleanjintintjbooleanbooleanjbooleanbooleanjbooleanbooleanjbooleanbooleanjbooleanbooleanID=NULL;
155 jintcreateLegendjintintjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintID=NULL;
156 jintcreateSegsjintintjdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejbooleanbooleanjintArray_intintjdoubledoubleID=NULL;
157 jintcreateChampjintintjdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubledoublejbooleanbooleanID=NULL;
158 jintcreateSurfacejintintjintintjintintjintintID=NULL;
159 voidinitSubWinTo3djintintjstringjava_lang_StringjbooleanbooleanjintArray_intintjdoubledoublejdoubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoubleID=NULL;
160 jintcreateLightjintintjintintjbooleanbooleanjdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoubleID=NULL;
161
162
163 }
164
165 // Generic methods
166
synchronize()167 void Builder::synchronize() {
168 if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK) {
169 throw GiwsException::JniMonitorException(getCurrentEnv(), "Builder");
170 }
171 }
172
endSynchronize()173 void Builder::endSynchronize() {
174 if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK) {
175 throw GiwsException::JniMonitorException(getCurrentEnv(), "Builder");
176 }
177 }
178 // Method(s)
179
createRect(JavaVM * jvm_,int pparentsubwinUID,double x,double y,double height,double width,int foreground,int background,int isfilled,int isline)180 int Builder::createRect (JavaVM * jvm_, int pparentsubwinUID, double x, double y, double height, double width, int foreground, int background, int isfilled, int isline){
181
182 JNIEnv * curEnv = NULL;
183 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
184 jclass cls = initClass(curEnv);
185 if ( cls == NULL) {
186 throw GiwsException::JniCallMethodException(curEnv);
187 }
188
189 static jmethodID jintcreateRectjintintjdoubledoublejdoubledoublejdoubledoublejdoubledoublejintintjintintjintintjintintID = curEnv->GetStaticMethodID(cls, "createRect", "(IDDDDIIII)I" ) ;
190 if (jintcreateRectjintintjdoubledoublejdoubledoublejdoubledoublejdoubledoublejintintjintintjintintjintintID == NULL) {
191 throw GiwsException::JniMethodNotFoundException(curEnv, "createRect");
192 }
193
194 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcreateRectjintintjdoubledoublejdoubledoublejdoubledoublejdoubledoublejintintjintintjintintjintintID ,pparentsubwinUID, x, y, height, width, foreground, background, isfilled, isline));
195 if (curEnv->ExceptionCheck()) {
196 throw GiwsException::JniCallMethodException(curEnv);
197 }
198 return res;
199
200 }
201
cloneGraphicContext(JavaVM * jvm_,int sourceIdentifier,int destIdentifier)202 int Builder::cloneGraphicContext (JavaVM * jvm_, int sourceIdentifier, int destIdentifier){
203
204 JNIEnv * curEnv = NULL;
205 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
206 jclass cls = initClass(curEnv);
207 if ( cls == NULL) {
208 throw GiwsException::JniCallMethodException(curEnv);
209 }
210
211 static jmethodID jintcloneGraphicContextjintintjintintID = curEnv->GetStaticMethodID(cls, "cloneGraphicContext", "(II)I" ) ;
212 if (jintcloneGraphicContextjintintjintintID == NULL) {
213 throw GiwsException::JniMethodNotFoundException(curEnv, "cloneGraphicContext");
214 }
215
216 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcloneGraphicContextjintintjintintID ,sourceIdentifier, destIdentifier));
217 if (curEnv->ExceptionCheck()) {
218 throw GiwsException::JniCallMethodException(curEnv);
219 }
220 return res;
221
222 }
223
cloneFontContext(JavaVM * jvm_,int sourceIdentifier,int destIdentifier)224 int Builder::cloneFontContext (JavaVM * jvm_, int sourceIdentifier, int destIdentifier){
225
226 JNIEnv * curEnv = NULL;
227 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
228 jclass cls = initClass(curEnv);
229 if ( cls == NULL) {
230 throw GiwsException::JniCallMethodException(curEnv);
231 }
232
233 static jmethodID jintcloneFontContextjintintjintintID = curEnv->GetStaticMethodID(cls, "cloneFontContext", "(II)I" ) ;
234 if (jintcloneFontContextjintintjintintID == NULL) {
235 throw GiwsException::JniMethodNotFoundException(curEnv, "cloneFontContext");
236 }
237
238 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcloneFontContextjintintjintintID ,sourceIdentifier, destIdentifier));
239 if (curEnv->ExceptionCheck()) {
240 throw GiwsException::JniCallMethodException(curEnv);
241 }
242 return res;
243
244 }
245
createHiddenLabel(JavaVM * jvm_,int parent)246 int Builder::createHiddenLabel (JavaVM * jvm_, int parent){
247
248 JNIEnv * curEnv = NULL;
249 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
250 jclass cls = initClass(curEnv);
251 if ( cls == NULL) {
252 throw GiwsException::JniCallMethodException(curEnv);
253 }
254
255 static jmethodID jintcreateHiddenLabeljintintID = curEnv->GetStaticMethodID(cls, "createHiddenLabel", "(I)I" ) ;
256 if (jintcreateHiddenLabeljintintID == NULL) {
257 throw GiwsException::JniMethodNotFoundException(curEnv, "createHiddenLabel");
258 }
259
260 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcreateHiddenLabeljintintID ,parent));
261 if (curEnv->ExceptionCheck()) {
262 throw GiwsException::JniCallMethodException(curEnv);
263 }
264 return res;
265
266 }
267
isAxesRedrawing(JavaVM * jvm_,int subWin)268 bool Builder::isAxesRedrawing (JavaVM * jvm_, int subWin){
269
270 JNIEnv * curEnv = NULL;
271 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
272 jclass cls = initClass(curEnv);
273 if ( cls == NULL) {
274 throw GiwsException::JniCallMethodException(curEnv);
275 }
276
277 static jmethodID jbooleanisAxesRedrawingjintintID = curEnv->GetStaticMethodID(cls, "isAxesRedrawing", "(I)Z" ) ;
278 if (jbooleanisAxesRedrawingjintintID == NULL) {
279 throw GiwsException::JniMethodNotFoundException(curEnv, "isAxesRedrawing");
280 }
281
282 jboolean res = static_cast<jboolean>( curEnv->CallStaticBooleanMethod(cls, jbooleanisAxesRedrawingjintintID ,subWin));
283 if (curEnv->ExceptionCheck()) {
284 throw GiwsException::JniCallMethodException(curEnv);
285 }
286 return (res == JNI_TRUE);
287
288 }
289
createLabel(JavaVM * jvm_,int parent,int type)290 int Builder::createLabel (JavaVM * jvm_, int parent, int type){
291
292 JNIEnv * curEnv = NULL;
293 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
294 jclass cls = initClass(curEnv);
295 if ( cls == NULL) {
296 throw GiwsException::JniCallMethodException(curEnv);
297 }
298
299 static jmethodID jintcreateLabeljintintjintintID = curEnv->GetStaticMethodID(cls, "createLabel", "(II)I" ) ;
300 if (jintcreateLabeljintintjintintID == NULL) {
301 throw GiwsException::JniMethodNotFoundException(curEnv, "createLabel");
302 }
303
304 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcreateLabeljintintjintintID ,parent, type));
305 if (curEnv->ExceptionCheck()) {
306 throw GiwsException::JniCallMethodException(curEnv);
307 }
308 return res;
309
310 }
311
createNewFigureWithAxes(JavaVM * jvm_)312 int Builder::createNewFigureWithAxes (JavaVM * jvm_){
313
314 JNIEnv * curEnv = NULL;
315 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
316 jclass cls = initClass(curEnv);
317 if ( cls == NULL) {
318 throw GiwsException::JniCallMethodException(curEnv);
319 }
320
321 static jmethodID jintcreateNewFigureWithAxesID = curEnv->GetStaticMethodID(cls, "createNewFigureWithAxes", "()I" ) ;
322 if (jintcreateNewFigureWithAxesID == NULL) {
323 throw GiwsException::JniMethodNotFoundException(curEnv, "createNewFigureWithAxes");
324 }
325
326 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcreateNewFigureWithAxesID ));
327 if (curEnv->ExceptionCheck()) {
328 throw GiwsException::JniCallMethodException(curEnv);
329 }
330 return res;
331
332 }
333
createFigure(JavaVM * jvm_,bool dockable,int menubarType,int toolbarType,bool defaultAxes,bool visible)334 int Builder::createFigure (JavaVM * jvm_, bool dockable, int menubarType, int toolbarType, bool defaultAxes, bool visible){
335
336 JNIEnv * curEnv = NULL;
337 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
338 jclass cls = initClass(curEnv);
339 if ( cls == NULL) {
340 throw GiwsException::JniCallMethodException(curEnv);
341 }
342
343 static jmethodID jintcreateFigurejbooleanbooleanjintintjintintjbooleanbooleanjbooleanbooleanID = curEnv->GetStaticMethodID(cls, "createFigure", "(ZIIZZ)I" ) ;
344 if (jintcreateFigurejbooleanbooleanjintintjintintjbooleanbooleanjbooleanbooleanID == NULL) {
345 throw GiwsException::JniMethodNotFoundException(curEnv, "createFigure");
346 }
347
348 jboolean dockable_ = (static_cast<bool>(dockable) ? JNI_TRUE : JNI_FALSE);
349
350 jboolean defaultAxes_ = (static_cast<bool>(defaultAxes) ? JNI_TRUE : JNI_FALSE);
351
352 jboolean visible_ = (static_cast<bool>(visible) ? JNI_TRUE : JNI_FALSE);
353
354 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcreateFigurejbooleanbooleanjintintjintintjbooleanbooleanjbooleanbooleanID ,dockable_, menubarType, toolbarType, defaultAxes_, visible_));
355 if (curEnv->ExceptionCheck()) {
356 throw GiwsException::JniCallMethodException(curEnv);
357 }
358 return res;
359
360 }
361
cloneMenus(JavaVM * jvm_,int model,int newParent)362 void Builder::cloneMenus (JavaVM * jvm_, int model, int newParent){
363
364 JNIEnv * curEnv = NULL;
365 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
366 jclass cls = initClass(curEnv);
367 if ( cls == NULL) {
368 throw GiwsException::JniCallMethodException(curEnv);
369 }
370
371 static jmethodID voidcloneMenusjintintjintintID = curEnv->GetStaticMethodID(cls, "cloneMenus", "(II)V" ) ;
372 if (voidcloneMenusjintintjintintID == NULL) {
373 throw GiwsException::JniMethodNotFoundException(curEnv, "cloneMenus");
374 }
375
376 curEnv->CallStaticVoidMethod(cls, voidcloneMenusjintintjintintID ,model, newParent);
377 if (curEnv->ExceptionCheck()) {
378 throw GiwsException::JniCallMethodException(curEnv);
379 }
380 }
381
cloneAxesModel(JavaVM * jvm_,int parent)382 int Builder::cloneAxesModel (JavaVM * jvm_, int parent){
383
384 JNIEnv * curEnv = NULL;
385 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
386 jclass cls = initClass(curEnv);
387 if ( cls == NULL) {
388 throw GiwsException::JniCallMethodException(curEnv);
389 }
390
391 static jmethodID jintcloneAxesModeljintintID = curEnv->GetStaticMethodID(cls, "cloneAxesModel", "(I)I" ) ;
392 if (jintcloneAxesModeljintintID == NULL) {
393 throw GiwsException::JniMethodNotFoundException(curEnv, "cloneAxesModel");
394 }
395
396 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcloneAxesModeljintintID ,parent));
397 if (curEnv->ExceptionCheck()) {
398 throw GiwsException::JniCallMethodException(curEnv);
399 }
400 return res;
401
402 }
403
createSubWin(JavaVM * jvm_,int parent)404 int Builder::createSubWin (JavaVM * jvm_, int parent){
405
406 JNIEnv * curEnv = NULL;
407 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
408 jclass cls = initClass(curEnv);
409 if ( cls == NULL) {
410 throw GiwsException::JniCallMethodException(curEnv);
411 }
412
413 static jmethodID jintcreateSubWinjintintID = curEnv->GetStaticMethodID(cls, "createSubWin", "(I)I" ) ;
414 if (jintcreateSubWinjintintID == NULL) {
415 throw GiwsException::JniMethodNotFoundException(curEnv, "createSubWin");
416 }
417
418 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcreateSubWinjintintID ,parent));
419 if (curEnv->ExceptionCheck()) {
420 throw GiwsException::JniCallMethodException(curEnv);
421 }
422 return res;
423
424 }
425
createText(JavaVM * jvm_,int parent,char const * const * text,int textSize,int rows,int cols,double x,double y,bool autoSize,double const * userSize,int userSizeSize,int centerPos,int foreground,bool isForeground,int background,bool isBackground,bool boxed,bool line,bool filled,int align)426 int Builder::createText (JavaVM * jvm_, int parent, char const* const* text, int textSize, int rows, int cols, double x, double y, bool autoSize, double const* userSize, int userSizeSize, int centerPos, int foreground, bool isForeground, int background, bool isBackground, bool boxed, bool line, bool filled, int align){
427
428 JNIEnv * curEnv = NULL;
429 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
430 jclass cls = initClass(curEnv);
431 if ( cls == NULL) {
432 throw GiwsException::JniCallMethodException(curEnv);
433 }
434
435 static jmethodID jintcreateTextjintintjobjectArray_java_lang_Stringjava_lang_StringjintintjintintjdoubledoublejdoubledoublejbooleanbooleanjdoubleArray_doubledoublejintintjintintjbooleanbooleanjintintjbooleanbooleanjbooleanbooleanjbooleanbooleanjbooleanbooleanjintintID = curEnv->GetStaticMethodID(cls, "createText", "(I[Ljava/lang/String;IIDDZ[DIIZIZZZZI)I" ) ;
436 if (jintcreateTextjintintjobjectArray_java_lang_Stringjava_lang_StringjintintjintintjdoubledoublejdoubledoublejbooleanbooleanjdoubleArray_doubledoublejintintjintintjbooleanbooleanjintintjbooleanbooleanjbooleanbooleanjbooleanbooleanjbooleanbooleanjintintID == NULL) {
437 throw GiwsException::JniMethodNotFoundException(curEnv, "createText");
438 }
439 jclass stringArrayClass = curEnv->FindClass("java/lang/String");
440
441 // create java array of strings.
442 jobjectArray text_ = curEnv->NewObjectArray( textSize, stringArrayClass, NULL);
443 if (text_ == NULL)
444 {
445 throw GiwsException::JniBadAllocException(curEnv);
446 }
447
448 // convert each char * to java strings and fill the java array.
449 for ( int i = 0; i < textSize; i++)
450 {
451 jstring TempString = curEnv->NewStringUTF( text[i] );
452 if (TempString == NULL)
453 {
454 throw GiwsException::JniBadAllocException(curEnv);
455 }
456
457 curEnv->SetObjectArrayElement( text_, i, TempString);
458
459 // avoid keeping reference on too many strings
460 curEnv->DeleteLocalRef(TempString);
461 }
462 jboolean autoSize_ = (static_cast<bool>(autoSize) ? JNI_TRUE : JNI_FALSE);
463
464 jdoubleArray userSize_ = curEnv->NewDoubleArray( userSizeSize ) ;
465
466 if (userSize_ == NULL)
467 {
468 // check that allocation succeed
469 throw GiwsException::JniBadAllocException(curEnv);
470 }
471
472 curEnv->SetDoubleArrayRegion( userSize_, 0, userSizeSize, (jdouble*)(userSize) ) ;
473
474
475 jboolean isForeground_ = (static_cast<bool>(isForeground) ? JNI_TRUE : JNI_FALSE);
476
477 jboolean isBackground_ = (static_cast<bool>(isBackground) ? JNI_TRUE : JNI_FALSE);
478
479 jboolean boxed_ = (static_cast<bool>(boxed) ? JNI_TRUE : JNI_FALSE);
480
481 jboolean line_ = (static_cast<bool>(line) ? JNI_TRUE : JNI_FALSE);
482
483 jboolean filled_ = (static_cast<bool>(filled) ? JNI_TRUE : JNI_FALSE);
484
485 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcreateTextjintintjobjectArray_java_lang_Stringjava_lang_StringjintintjintintjdoubledoublejdoubledoublejbooleanbooleanjdoubleArray_doubledoublejintintjintintjbooleanbooleanjintintjbooleanbooleanjbooleanbooleanjbooleanbooleanjbooleanbooleanjintintID ,parent, text_, rows, cols, x, y, autoSize_, userSize_, centerPos, foreground, isForeground_, background, isBackground_, boxed_, line_, filled_, align));
486 curEnv->DeleteLocalRef(stringArrayClass);
487 curEnv->DeleteLocalRef(text_);
488 curEnv->DeleteLocalRef(userSize_);
489 if (curEnv->ExceptionCheck()) {
490 throw GiwsException::JniCallMethodException(curEnv);
491 }
492 return res;
493
494 }
495
createArc(JavaVM * jvm_,int parent,double x,double y,double h,double w,double start,double end,int foreground,bool isForeground,int background,bool isBackground,bool filled,bool line)496 int Builder::createArc (JavaVM * jvm_, int parent, double x, double y, double h, double w, double start, double end, int foreground, bool isForeground, int background, bool isBackground, bool filled, bool line){
497
498 JNIEnv * curEnv = NULL;
499 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
500 jclass cls = initClass(curEnv);
501 if ( cls == NULL) {
502 throw GiwsException::JniCallMethodException(curEnv);
503 }
504
505 static jmethodID jintcreateArcjintintjdoubledoublejdoubledoublejdoubledoublejdoubledoublejdoubledoublejdoubledoublejintintjbooleanbooleanjintintjbooleanbooleanjbooleanbooleanjbooleanbooleanID = curEnv->GetStaticMethodID(cls, "createArc", "(IDDDDDDIZIZZZ)I" ) ;
506 if (jintcreateArcjintintjdoubledoublejdoubledoublejdoubledoublejdoubledoublejdoubledoublejdoubledoublejintintjbooleanbooleanjintintjbooleanbooleanjbooleanbooleanjbooleanbooleanID == NULL) {
507 throw GiwsException::JniMethodNotFoundException(curEnv, "createArc");
508 }
509
510 jboolean isForeground_ = (static_cast<bool>(isForeground) ? JNI_TRUE : JNI_FALSE);
511
512 jboolean isBackground_ = (static_cast<bool>(isBackground) ? JNI_TRUE : JNI_FALSE);
513
514 jboolean filled_ = (static_cast<bool>(filled) ? JNI_TRUE : JNI_FALSE);
515
516 jboolean line_ = (static_cast<bool>(line) ? JNI_TRUE : JNI_FALSE);
517
518 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcreateArcjintintjdoubledoublejdoubledoublejdoubledoublejdoubledoublejdoubledoublejdoubledoublejintintjbooleanbooleanjintintjbooleanbooleanjbooleanbooleanjbooleanbooleanID ,parent, x, y, h, w, start, end, foreground, isForeground_, background, isBackground_, filled_, line_));
519 if (curEnv->ExceptionCheck()) {
520 throw GiwsException::JniCallMethodException(curEnv);
521 }
522 return res;
523
524 }
525
createAxis(JavaVM * jvm_,int parent,int dir,int tics,double const * vx,int vxSize,double const * vy,int vySize,int subint,char const * format,int fontSize,int textColor,int ticsColor,bool seg)526 int Builder::createAxis (JavaVM * jvm_, int parent, int dir, int tics, double const* vx, int vxSize, double const* vy, int vySize, int subint, char const* format, int fontSize, int textColor, int ticsColor, bool seg){
527
528 JNIEnv * curEnv = NULL;
529 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
530 jclass cls = initClass(curEnv);
531 if ( cls == NULL) {
532 throw GiwsException::JniCallMethodException(curEnv);
533 }
534
535 static jmethodID jintcreateAxisjintintjintintjintintjdoubleArray_doubledoublejdoubleArray_doubledoublejintintjstringjava_lang_StringjintintjintintjintintjbooleanbooleanID = curEnv->GetStaticMethodID(cls, "createAxis", "(III[D[DILjava/lang/String;IIIZ)I" ) ;
536 if (jintcreateAxisjintintjintintjintintjdoubleArray_doubledoublejdoubleArray_doubledoublejintintjstringjava_lang_StringjintintjintintjintintjbooleanbooleanID == NULL) {
537 throw GiwsException::JniMethodNotFoundException(curEnv, "createAxis");
538 }
539
540 jdoubleArray vx_ = curEnv->NewDoubleArray( vxSize ) ;
541
542 if (vx_ == NULL)
543 {
544 // check that allocation succeed
545 throw GiwsException::JniBadAllocException(curEnv);
546 }
547
548 curEnv->SetDoubleArrayRegion( vx_, 0, vxSize, (jdouble*)(vx) ) ;
549
550
551 jdoubleArray vy_ = curEnv->NewDoubleArray( vySize ) ;
552
553 if (vy_ == NULL)
554 {
555 // check that allocation succeed
556 throw GiwsException::JniBadAllocException(curEnv);
557 }
558
559 curEnv->SetDoubleArrayRegion( vy_, 0, vySize, (jdouble*)(vy) ) ;
560
561
562 jstring format_ = curEnv->NewStringUTF( format );
563 if (format != NULL && format_ == NULL)
564 {
565 throw GiwsException::JniBadAllocException(curEnv);
566 }
567
568
569 jboolean seg_ = (static_cast<bool>(seg) ? JNI_TRUE : JNI_FALSE);
570
571 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcreateAxisjintintjintintjintintjdoubleArray_doubledoublejdoubleArray_doubledoublejintintjstringjava_lang_StringjintintjintintjintintjbooleanbooleanID ,parent, dir, tics, vx_, vy_, subint, format_, fontSize, textColor, ticsColor, seg_));
572 curEnv->DeleteLocalRef(vx_);
573 curEnv->DeleteLocalRef(vy_);
574 curEnv->DeleteLocalRef(format_);
575 if (curEnv->ExceptionCheck()) {
576 throw GiwsException::JniCallMethodException(curEnv);
577 }
578 return res;
579
580 }
581
createCompound(JavaVM * jvm_,int parent,int const * children,int childrenSize)582 int Builder::createCompound (JavaVM * jvm_, int parent, int const* children, int childrenSize){
583
584 JNIEnv * curEnv = NULL;
585 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
586 jclass cls = initClass(curEnv);
587 if ( cls == NULL) {
588 throw GiwsException::JniCallMethodException(curEnv);
589 }
590
591 static jmethodID jintcreateCompoundjintintjintArray_intintID = curEnv->GetStaticMethodID(cls, "createCompound", "(I[I)I" ) ;
592 if (jintcreateCompoundjintintjintArray_intintID == NULL) {
593 throw GiwsException::JniMethodNotFoundException(curEnv, "createCompound");
594 }
595
596 jintArray children_ = curEnv->NewIntArray( childrenSize ) ;
597
598 if (children_ == NULL)
599 {
600 // check that allocation succeed
601 throw GiwsException::JniBadAllocException(curEnv);
602 }
603
604 curEnv->SetIntArrayRegion( children_, 0, childrenSize, (jint*)(children) ) ;
605
606
607 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcreateCompoundjintintjintArray_intintID ,parent, children_));
608 curEnv->DeleteLocalRef(children_);
609 if (curEnv->ExceptionCheck()) {
610 throw GiwsException::JniCallMethodException(curEnv);
611 }
612 return res;
613
614 }
615
createCompoundSeq(JavaVM * jvm_,int parent,int childrenCount)616 int Builder::createCompoundSeq (JavaVM * jvm_, int parent, int childrenCount){
617
618 JNIEnv * curEnv = NULL;
619 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
620 jclass cls = initClass(curEnv);
621 if ( cls == NULL) {
622 throw GiwsException::JniCallMethodException(curEnv);
623 }
624
625 static jmethodID jintcreateCompoundSeqjintintjintintID = curEnv->GetStaticMethodID(cls, "createCompoundSeq", "(II)I" ) ;
626 if (jintcreateCompoundSeqjintintjintintID == NULL) {
627 throw GiwsException::JniMethodNotFoundException(curEnv, "createCompoundSeq");
628 }
629
630 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcreateCompoundSeqjintintjintintID ,parent, childrenCount));
631 if (curEnv->ExceptionCheck()) {
632 throw GiwsException::JniCallMethodException(curEnv);
633 }
634 return res;
635
636 }
637
createFec(JavaVM * jvm_,int parent,double const * zminmax,int zminmaxSize,int const * colminmax,int colminmaxSize,int const * colout,int coloutSize,bool with_mesh)638 int Builder::createFec (JavaVM * jvm_, int parent, double const* zminmax, int zminmaxSize, int const* colminmax, int colminmaxSize, int const* colout, int coloutSize, bool with_mesh){
639
640 JNIEnv * curEnv = NULL;
641 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
642 jclass cls = initClass(curEnv);
643 if ( cls == NULL) {
644 throw GiwsException::JniCallMethodException(curEnv);
645 }
646
647 static jmethodID jintcreateFecjintintjdoubleArray_doubledoublejintArray_intintjintArray_intintjbooleanbooleanID = curEnv->GetStaticMethodID(cls, "createFec", "(I[D[I[IZ)I" ) ;
648 if (jintcreateFecjintintjdoubleArray_doubledoublejintArray_intintjintArray_intintjbooleanbooleanID == NULL) {
649 throw GiwsException::JniMethodNotFoundException(curEnv, "createFec");
650 }
651
652 jdoubleArray zminmax_ = curEnv->NewDoubleArray( zminmaxSize ) ;
653
654 if (zminmax_ == NULL)
655 {
656 // check that allocation succeed
657 throw GiwsException::JniBadAllocException(curEnv);
658 }
659
660 curEnv->SetDoubleArrayRegion( zminmax_, 0, zminmaxSize, (jdouble*)(zminmax) ) ;
661
662
663 jintArray colminmax_ = curEnv->NewIntArray( colminmaxSize ) ;
664
665 if (colminmax_ == NULL)
666 {
667 // check that allocation succeed
668 throw GiwsException::JniBadAllocException(curEnv);
669 }
670
671 curEnv->SetIntArrayRegion( colminmax_, 0, colminmaxSize, (jint*)(colminmax) ) ;
672
673
674 jintArray colout_ = curEnv->NewIntArray( coloutSize ) ;
675
676 if (colout_ == NULL)
677 {
678 // check that allocation succeed
679 throw GiwsException::JniBadAllocException(curEnv);
680 }
681
682 curEnv->SetIntArrayRegion( colout_, 0, coloutSize, (jint*)(colout) ) ;
683
684
685 jboolean with_mesh_ = (static_cast<bool>(with_mesh) ? JNI_TRUE : JNI_FALSE);
686
687 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcreateFecjintintjdoubleArray_doubledoublejintArray_intintjintArray_intintjbooleanbooleanID ,parent, zminmax_, colminmax_, colout_, with_mesh_));
688 curEnv->DeleteLocalRef(zminmax_);
689 curEnv->DeleteLocalRef(colminmax_);
690 curEnv->DeleteLocalRef(colout_);
691 if (curEnv->ExceptionCheck()) {
692 throw GiwsException::JniCallMethodException(curEnv);
693 }
694 return res;
695
696 }
697
createGrayplot(JavaVM * jvm_,int parent,int type,double const * pvecx,int pvecxSize,int n1,int n2)698 int Builder::createGrayplot (JavaVM * jvm_, int parent, int type, double const* pvecx, int pvecxSize, int n1, int n2){
699
700 JNIEnv * curEnv = NULL;
701 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
702 jclass cls = initClass(curEnv);
703 if ( cls == NULL) {
704 throw GiwsException::JniCallMethodException(curEnv);
705 }
706
707 static jmethodID jintcreateGrayplotjintintjintintjdoubleArray_doubledoublejintintjintintID = curEnv->GetStaticMethodID(cls, "createGrayplot", "(II[DII)I" ) ;
708 if (jintcreateGrayplotjintintjintintjdoubleArray_doubledoublejintintjintintID == NULL) {
709 throw GiwsException::JniMethodNotFoundException(curEnv, "createGrayplot");
710 }
711
712 jdoubleArray pvecx_ = curEnv->NewDoubleArray( pvecxSize ) ;
713
714 if (pvecx_ == NULL)
715 {
716 // check that allocation succeed
717 throw GiwsException::JniBadAllocException(curEnv);
718 }
719
720 curEnv->SetDoubleArrayRegion( pvecx_, 0, pvecxSize, (jdouble*)(pvecx) ) ;
721
722
723 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcreateGrayplotjintintjintintjdoubleArray_doubledoublejintintjintintID ,parent, type, pvecx_, n1, n2));
724 curEnv->DeleteLocalRef(pvecx_);
725 if (curEnv->ExceptionCheck()) {
726 throw GiwsException::JniCallMethodException(curEnv);
727 }
728 return res;
729
730 }
731
createPolyline(JavaVM * jvm_,int parent,bool closed,int plot,int foreground,bool isForeground,int const * background,int backgroundSize,int mark_style,bool isMarkStyle,int mark_foreground,bool isMarkForeground,int mark_background,bool isMarkBackground,bool isline,bool isfilled,bool ismark,bool isinterp)732 int Builder::createPolyline (JavaVM * jvm_, int parent, bool closed, int plot, int foreground, bool isForeground, int const* background, int backgroundSize, int mark_style, bool isMarkStyle, int mark_foreground, bool isMarkForeground, int mark_background, bool isMarkBackground, bool isline, bool isfilled, bool ismark, bool isinterp){
733
734 JNIEnv * curEnv = NULL;
735 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
736 jclass cls = initClass(curEnv);
737 if ( cls == NULL) {
738 throw GiwsException::JniCallMethodException(curEnv);
739 }
740
741 static jmethodID jintcreatePolylinejintintjbooleanbooleanjintintjintintjbooleanbooleanjintArray_intintjintintjbooleanbooleanjintintjbooleanbooleanjintintjbooleanbooleanjbooleanbooleanjbooleanbooleanjbooleanbooleanjbooleanbooleanID = curEnv->GetStaticMethodID(cls, "createPolyline", "(IZIIZ[IIZIZIZZZZZ)I" ) ;
742 if (jintcreatePolylinejintintjbooleanbooleanjintintjintintjbooleanbooleanjintArray_intintjintintjbooleanbooleanjintintjbooleanbooleanjintintjbooleanbooleanjbooleanbooleanjbooleanbooleanjbooleanbooleanjbooleanbooleanID == NULL) {
743 throw GiwsException::JniMethodNotFoundException(curEnv, "createPolyline");
744 }
745
746 jboolean closed_ = (static_cast<bool>(closed) ? JNI_TRUE : JNI_FALSE);
747
748 jboolean isForeground_ = (static_cast<bool>(isForeground) ? JNI_TRUE : JNI_FALSE);
749
750 jintArray background_ = curEnv->NewIntArray( backgroundSize ) ;
751
752 if (background_ == NULL)
753 {
754 // check that allocation succeed
755 throw GiwsException::JniBadAllocException(curEnv);
756 }
757
758 curEnv->SetIntArrayRegion( background_, 0, backgroundSize, (jint*)(background) ) ;
759
760
761 jboolean isMarkStyle_ = (static_cast<bool>(isMarkStyle) ? JNI_TRUE : JNI_FALSE);
762
763 jboolean isMarkForeground_ = (static_cast<bool>(isMarkForeground) ? JNI_TRUE : JNI_FALSE);
764
765 jboolean isMarkBackground_ = (static_cast<bool>(isMarkBackground) ? JNI_TRUE : JNI_FALSE);
766
767 jboolean isline_ = (static_cast<bool>(isline) ? JNI_TRUE : JNI_FALSE);
768
769 jboolean isfilled_ = (static_cast<bool>(isfilled) ? JNI_TRUE : JNI_FALSE);
770
771 jboolean ismark_ = (static_cast<bool>(ismark) ? JNI_TRUE : JNI_FALSE);
772
773 jboolean isinterp_ = (static_cast<bool>(isinterp) ? JNI_TRUE : JNI_FALSE);
774
775 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcreatePolylinejintintjbooleanbooleanjintintjintintjbooleanbooleanjintArray_intintjintintjbooleanbooleanjintintjbooleanbooleanjintintjbooleanbooleanjbooleanbooleanjbooleanbooleanjbooleanbooleanjbooleanbooleanID ,parent, closed_, plot, foreground, isForeground_, background_, mark_style, isMarkStyle_, mark_foreground, isMarkForeground_, mark_background, isMarkBackground_, isline_, isfilled_, ismark_, isinterp_));
776 curEnv->DeleteLocalRef(background_);
777 if (curEnv->ExceptionCheck()) {
778 throw GiwsException::JniCallMethodException(curEnv);
779 }
780 return res;
781
782 }
783
createLegend(JavaVM * jvm_,int parent,char const * const * text,int textSize,int const * handles,int handlesSize)784 int Builder::createLegend (JavaVM * jvm_, int parent, char const* const* text, int textSize, int const* handles, int handlesSize){
785
786 JNIEnv * curEnv = NULL;
787 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
788 jclass cls = initClass(curEnv);
789 if ( cls == NULL) {
790 throw GiwsException::JniCallMethodException(curEnv);
791 }
792
793 static jmethodID jintcreateLegendjintintjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintID = curEnv->GetStaticMethodID(cls, "createLegend", "(I[Ljava/lang/String;[I)I" ) ;
794 if (jintcreateLegendjintintjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintID == NULL) {
795 throw GiwsException::JniMethodNotFoundException(curEnv, "createLegend");
796 }
797 jclass stringArrayClass = curEnv->FindClass("java/lang/String");
798
799 // create java array of strings.
800 jobjectArray text_ = curEnv->NewObjectArray( textSize, stringArrayClass, NULL);
801 if (text_ == NULL)
802 {
803 throw GiwsException::JniBadAllocException(curEnv);
804 }
805
806 // convert each char * to java strings and fill the java array.
807 for ( int i = 0; i < textSize; i++)
808 {
809 jstring TempString = curEnv->NewStringUTF( text[i] );
810 if (TempString == NULL)
811 {
812 throw GiwsException::JniBadAllocException(curEnv);
813 }
814
815 curEnv->SetObjectArrayElement( text_, i, TempString);
816
817 // avoid keeping reference on too many strings
818 curEnv->DeleteLocalRef(TempString);
819 }
820 jintArray handles_ = curEnv->NewIntArray( handlesSize ) ;
821
822 if (handles_ == NULL)
823 {
824 // check that allocation succeed
825 throw GiwsException::JniBadAllocException(curEnv);
826 }
827
828 curEnv->SetIntArrayRegion( handles_, 0, handlesSize, (jint*)(handles) ) ;
829
830
831 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcreateLegendjintintjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintID ,parent, text_, handles_));
832 curEnv->DeleteLocalRef(stringArrayClass);
833 curEnv->DeleteLocalRef(text_);
834 curEnv->DeleteLocalRef(handles_);
835 if (curEnv->ExceptionCheck()) {
836 throw GiwsException::JniCallMethodException(curEnv);
837 }
838 return res;
839
840 }
841
createSegs(JavaVM * jvm_,int parent,double const * vx,int vxSize,double const * vy,int vySize,double const * vz,int vzSize,bool isVZ,int const * style,int styleSize,double arsize)842 int Builder::createSegs (JavaVM * jvm_, int parent, double const* vx, int vxSize, double const* vy, int vySize, double const* vz, int vzSize, bool isVZ, int const* style, int styleSize, double arsize){
843
844 JNIEnv * curEnv = NULL;
845 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
846 jclass cls = initClass(curEnv);
847 if ( cls == NULL) {
848 throw GiwsException::JniCallMethodException(curEnv);
849 }
850
851 static jmethodID jintcreateSegsjintintjdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejbooleanbooleanjintArray_intintjdoubledoubleID = curEnv->GetStaticMethodID(cls, "createSegs", "(I[D[D[DZ[ID)I" ) ;
852 if (jintcreateSegsjintintjdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejbooleanbooleanjintArray_intintjdoubledoubleID == NULL) {
853 throw GiwsException::JniMethodNotFoundException(curEnv, "createSegs");
854 }
855
856 jdoubleArray vx_ = curEnv->NewDoubleArray( vxSize ) ;
857
858 if (vx_ == NULL)
859 {
860 // check that allocation succeed
861 throw GiwsException::JniBadAllocException(curEnv);
862 }
863
864 curEnv->SetDoubleArrayRegion( vx_, 0, vxSize, (jdouble*)(vx) ) ;
865
866
867 jdoubleArray vy_ = curEnv->NewDoubleArray( vySize ) ;
868
869 if (vy_ == NULL)
870 {
871 // check that allocation succeed
872 throw GiwsException::JniBadAllocException(curEnv);
873 }
874
875 curEnv->SetDoubleArrayRegion( vy_, 0, vySize, (jdouble*)(vy) ) ;
876
877
878 jdoubleArray vz_ = curEnv->NewDoubleArray( vzSize ) ;
879
880 if (vz_ == NULL)
881 {
882 // check that allocation succeed
883 throw GiwsException::JniBadAllocException(curEnv);
884 }
885
886 curEnv->SetDoubleArrayRegion( vz_, 0, vzSize, (jdouble*)(vz) ) ;
887
888
889 jboolean isVZ_ = (static_cast<bool>(isVZ) ? JNI_TRUE : JNI_FALSE);
890
891 jintArray style_ = curEnv->NewIntArray( styleSize ) ;
892
893 if (style_ == NULL)
894 {
895 // check that allocation succeed
896 throw GiwsException::JniBadAllocException(curEnv);
897 }
898
899 curEnv->SetIntArrayRegion( style_, 0, styleSize, (jint*)(style) ) ;
900
901
902 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcreateSegsjintintjdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejbooleanbooleanjintArray_intintjdoubledoubleID ,parent, vx_, vy_, vz_, isVZ_, style_, arsize));
903 curEnv->DeleteLocalRef(vx_);
904 curEnv->DeleteLocalRef(vy_);
905 curEnv->DeleteLocalRef(vz_);
906 curEnv->DeleteLocalRef(style_);
907 if (curEnv->ExceptionCheck()) {
908 throw GiwsException::JniCallMethodException(curEnv);
909 }
910 return res;
911
912 }
913
createChamp(JavaVM * jvm_,int parent,double const * vx,int vxSize,double const * vy,int vySize,double const * vfx,int vfxSize,double const * vfy,int vfySize,double arsize,bool typeofchamp)914 int Builder::createChamp (JavaVM * jvm_, int parent, double const* vx, int vxSize, double const* vy, int vySize, double const* vfx, int vfxSize, double const* vfy, int vfySize, double arsize, bool typeofchamp){
915
916 JNIEnv * curEnv = NULL;
917 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
918 jclass cls = initClass(curEnv);
919 if ( cls == NULL) {
920 throw GiwsException::JniCallMethodException(curEnv);
921 }
922
923 static jmethodID jintcreateChampjintintjdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubledoublejbooleanbooleanID = curEnv->GetStaticMethodID(cls, "createChamp", "(I[D[D[D[DDZ)I" ) ;
924 if (jintcreateChampjintintjdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubledoublejbooleanbooleanID == NULL) {
925 throw GiwsException::JniMethodNotFoundException(curEnv, "createChamp");
926 }
927
928 jdoubleArray vx_ = curEnv->NewDoubleArray( vxSize ) ;
929
930 if (vx_ == NULL)
931 {
932 // check that allocation succeed
933 throw GiwsException::JniBadAllocException(curEnv);
934 }
935
936 curEnv->SetDoubleArrayRegion( vx_, 0, vxSize, (jdouble*)(vx) ) ;
937
938
939 jdoubleArray vy_ = curEnv->NewDoubleArray( vySize ) ;
940
941 if (vy_ == NULL)
942 {
943 // check that allocation succeed
944 throw GiwsException::JniBadAllocException(curEnv);
945 }
946
947 curEnv->SetDoubleArrayRegion( vy_, 0, vySize, (jdouble*)(vy) ) ;
948
949
950 jdoubleArray vfx_ = curEnv->NewDoubleArray( vfxSize ) ;
951
952 if (vfx_ == NULL)
953 {
954 // check that allocation succeed
955 throw GiwsException::JniBadAllocException(curEnv);
956 }
957
958 curEnv->SetDoubleArrayRegion( vfx_, 0, vfxSize, (jdouble*)(vfx) ) ;
959
960
961 jdoubleArray vfy_ = curEnv->NewDoubleArray( vfySize ) ;
962
963 if (vfy_ == NULL)
964 {
965 // check that allocation succeed
966 throw GiwsException::JniBadAllocException(curEnv);
967 }
968
969 curEnv->SetDoubleArrayRegion( vfy_, 0, vfySize, (jdouble*)(vfy) ) ;
970
971
972 jboolean typeofchamp_ = (static_cast<bool>(typeofchamp) ? JNI_TRUE : JNI_FALSE);
973
974 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcreateChampjintintjdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubledoublejbooleanbooleanID ,parent, vx_, vy_, vfx_, vfy_, arsize, typeofchamp_));
975 curEnv->DeleteLocalRef(vx_);
976 curEnv->DeleteLocalRef(vy_);
977 curEnv->DeleteLocalRef(vfx_);
978 curEnv->DeleteLocalRef(vfy_);
979 if (curEnv->ExceptionCheck()) {
980 throw GiwsException::JniCallMethodException(curEnv);
981 }
982 return res;
983
984 }
985
createSurface(JavaVM * jvm_,int parent,int typeof3d,int colorFlag,int colorMode)986 int Builder::createSurface (JavaVM * jvm_, int parent, int typeof3d, int colorFlag, int colorMode){
987
988 JNIEnv * curEnv = NULL;
989 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
990 jclass cls = initClass(curEnv);
991 if ( cls == NULL) {
992 throw GiwsException::JniCallMethodException(curEnv);
993 }
994
995 static jmethodID jintcreateSurfacejintintjintintjintintjintintID = curEnv->GetStaticMethodID(cls, "createSurface", "(IIII)I" ) ;
996 if (jintcreateSurfacejintintjintintjintintjintintID == NULL) {
997 throw GiwsException::JniMethodNotFoundException(curEnv, "createSurface");
998 }
999
1000 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcreateSurfacejintintjintintjintintjintintID ,parent, typeof3d, colorFlag, colorMode));
1001 if (curEnv->ExceptionCheck()) {
1002 throw GiwsException::JniCallMethodException(curEnv);
1003 }
1004 return res;
1005
1006 }
1007
initSubWinTo3d(JavaVM * jvm_,int parent,char const * legend,bool isLegend,int const * flag,int flagSize,double alpha,double theta,double const * ebox,int eboxSize,double const * x,int xSize,double const * y,int ySize,double const * z,int zSize)1008 void Builder::initSubWinTo3d (JavaVM * jvm_, int parent, char const* legend, bool isLegend, int const* flag, int flagSize, double alpha, double theta, double const* ebox, int eboxSize, double const* x, int xSize, double const* y, int ySize, double const* z, int zSize){
1009
1010 JNIEnv * curEnv = NULL;
1011 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1012 jclass cls = initClass(curEnv);
1013 if ( cls == NULL) {
1014 throw GiwsException::JniCallMethodException(curEnv);
1015 }
1016
1017 static jmethodID voidinitSubWinTo3djintintjstringjava_lang_StringjbooleanbooleanjintArray_intintjdoubledoublejdoubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoubleID = curEnv->GetStaticMethodID(cls, "initSubWinTo3d", "(ILjava/lang/String;Z[IDD[D[D[D[D)V" ) ;
1018 if (voidinitSubWinTo3djintintjstringjava_lang_StringjbooleanbooleanjintArray_intintjdoubledoublejdoubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoubleID == NULL) {
1019 throw GiwsException::JniMethodNotFoundException(curEnv, "initSubWinTo3d");
1020 }
1021
1022 jstring legend_ = curEnv->NewStringUTF( legend );
1023 if (legend != NULL && legend_ == NULL)
1024 {
1025 throw GiwsException::JniBadAllocException(curEnv);
1026 }
1027
1028
1029 jboolean isLegend_ = (static_cast<bool>(isLegend) ? JNI_TRUE : JNI_FALSE);
1030
1031 jintArray flag_ = curEnv->NewIntArray( flagSize ) ;
1032
1033 if (flag_ == NULL)
1034 {
1035 // check that allocation succeed
1036 throw GiwsException::JniBadAllocException(curEnv);
1037 }
1038
1039 curEnv->SetIntArrayRegion( flag_, 0, flagSize, (jint*)(flag) ) ;
1040
1041
1042 jdoubleArray ebox_ = curEnv->NewDoubleArray( eboxSize ) ;
1043
1044 if (ebox_ == NULL)
1045 {
1046 // check that allocation succeed
1047 throw GiwsException::JniBadAllocException(curEnv);
1048 }
1049
1050 curEnv->SetDoubleArrayRegion( ebox_, 0, eboxSize, (jdouble*)(ebox) ) ;
1051
1052
1053 jdoubleArray x_ = curEnv->NewDoubleArray( xSize ) ;
1054
1055 if (x_ == NULL)
1056 {
1057 // check that allocation succeed
1058 throw GiwsException::JniBadAllocException(curEnv);
1059 }
1060
1061 curEnv->SetDoubleArrayRegion( x_, 0, xSize, (jdouble*)(x) ) ;
1062
1063
1064 jdoubleArray y_ = curEnv->NewDoubleArray( ySize ) ;
1065
1066 if (y_ == NULL)
1067 {
1068 // check that allocation succeed
1069 throw GiwsException::JniBadAllocException(curEnv);
1070 }
1071
1072 curEnv->SetDoubleArrayRegion( y_, 0, ySize, (jdouble*)(y) ) ;
1073
1074
1075 jdoubleArray z_ = curEnv->NewDoubleArray( zSize ) ;
1076
1077 if (z_ == NULL)
1078 {
1079 // check that allocation succeed
1080 throw GiwsException::JniBadAllocException(curEnv);
1081 }
1082
1083 curEnv->SetDoubleArrayRegion( z_, 0, zSize, (jdouble*)(z) ) ;
1084
1085
1086 curEnv->CallStaticVoidMethod(cls, voidinitSubWinTo3djintintjstringjava_lang_StringjbooleanbooleanjintArray_intintjdoubledoublejdoubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoubleID ,parent, legend_, isLegend_, flag_, alpha, theta, ebox_, x_, y_, z_);
1087 curEnv->DeleteLocalRef(legend_);
1088 curEnv->DeleteLocalRef(flag_);
1089 curEnv->DeleteLocalRef(ebox_);
1090 curEnv->DeleteLocalRef(x_);
1091 curEnv->DeleteLocalRef(y_);
1092 curEnv->DeleteLocalRef(z_);
1093 if (curEnv->ExceptionCheck()) {
1094 throw GiwsException::JniCallMethodException(curEnv);
1095 }
1096 }
1097
createLight(JavaVM * jvm_,int parent,int type,bool visible,double const * pos,int posSize,double const * dir,int dirSize,double const * ambient,int ambientSize,double const * diffuse,int diffuseSize,double const * specular,int specularSize)1098 int Builder::createLight (JavaVM * jvm_, int parent, int type, bool visible, double const* pos, int posSize, double const* dir, int dirSize, double const* ambient, int ambientSize, double const* diffuse, int diffuseSize, double const* specular, int specularSize){
1099
1100 JNIEnv * curEnv = NULL;
1101 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1102 jclass cls = initClass(curEnv);
1103 if ( cls == NULL) {
1104 throw GiwsException::JniCallMethodException(curEnv);
1105 }
1106
1107 static jmethodID jintcreateLightjintintjintintjbooleanbooleanjdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoubleID = curEnv->GetStaticMethodID(cls, "createLight", "(IIZ[D[D[D[D[D)I" ) ;
1108 if (jintcreateLightjintintjintintjbooleanbooleanjdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoubleID == NULL) {
1109 throw GiwsException::JniMethodNotFoundException(curEnv, "createLight");
1110 }
1111
1112 jboolean visible_ = (static_cast<bool>(visible) ? JNI_TRUE : JNI_FALSE);
1113
1114 jdoubleArray pos_ = curEnv->NewDoubleArray( posSize ) ;
1115
1116 if (pos_ == NULL)
1117 {
1118 // check that allocation succeed
1119 throw GiwsException::JniBadAllocException(curEnv);
1120 }
1121
1122 curEnv->SetDoubleArrayRegion( pos_, 0, posSize, (jdouble*)(pos) ) ;
1123
1124
1125 jdoubleArray dir_ = curEnv->NewDoubleArray( dirSize ) ;
1126
1127 if (dir_ == NULL)
1128 {
1129 // check that allocation succeed
1130 throw GiwsException::JniBadAllocException(curEnv);
1131 }
1132
1133 curEnv->SetDoubleArrayRegion( dir_, 0, dirSize, (jdouble*)(dir) ) ;
1134
1135
1136 jdoubleArray ambient_ = curEnv->NewDoubleArray( ambientSize ) ;
1137
1138 if (ambient_ == NULL)
1139 {
1140 // check that allocation succeed
1141 throw GiwsException::JniBadAllocException(curEnv);
1142 }
1143
1144 curEnv->SetDoubleArrayRegion( ambient_, 0, ambientSize, (jdouble*)(ambient) ) ;
1145
1146
1147 jdoubleArray diffuse_ = curEnv->NewDoubleArray( diffuseSize ) ;
1148
1149 if (diffuse_ == NULL)
1150 {
1151 // check that allocation succeed
1152 throw GiwsException::JniBadAllocException(curEnv);
1153 }
1154
1155 curEnv->SetDoubleArrayRegion( diffuse_, 0, diffuseSize, (jdouble*)(diffuse) ) ;
1156
1157
1158 jdoubleArray specular_ = curEnv->NewDoubleArray( specularSize ) ;
1159
1160 if (specular_ == NULL)
1161 {
1162 // check that allocation succeed
1163 throw GiwsException::JniBadAllocException(curEnv);
1164 }
1165
1166 curEnv->SetDoubleArrayRegion( specular_, 0, specularSize, (jdouble*)(specular) ) ;
1167
1168
1169 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintcreateLightjintintjintintjbooleanbooleanjdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoubleID ,parent, type, visible_, pos_, dir_, ambient_, diffuse_, specular_));
1170 curEnv->DeleteLocalRef(pos_);
1171 curEnv->DeleteLocalRef(dir_);
1172 curEnv->DeleteLocalRef(ambient_);
1173 curEnv->DeleteLocalRef(diffuse_);
1174 curEnv->DeleteLocalRef(specular_);
1175 if (curEnv->ExceptionCheck()) {
1176 throw GiwsException::JniCallMethodException(curEnv);
1177 }
1178 return res;
1179
1180 }
1181
1182 }
1183