Saturday, 15 August 2015

java - What does AWT.GetDrawingSurface do? -



java - What does AWT.GetDrawingSurface do? -

i'm on project need utilize vtk java , javafx. , give vtk right canvas can draw, wondering function getdrawingsurface() in code below. awt jawt object described in jawt.h jawt library.

it's in order rewrite java class give c++ right canvas.

class="lang-cpp prettyprint-override">extern "c" jniexport jint jnicall java_vtk_vtkpanel_rendercreate(jnienv *env, jobject canvas, jobject id0) { #if defined(win32_jawt_lock_hack) int hash; wjlh_hash_func(env, canvas, hash); wjlh_lock_map[hash] = 0; #endif jawt awt; jawt_drawingsurface* ds; jawt_drawingsurfaceinfo* dsi; jint lock; // render window pointer vtkrenderwindow *temp0; temp0 = (vtkrenderwindow *)(vtkjavagetpointerfromobject(env,id0)); /* awt */ awt.version = jawt_version_1_3; if (jawt_getawt(env, &awt) == jni_false) { #ifndef vtk_java_debug printf("awt not found\n"); #endif homecoming 1; } /* drawing surface */ ds = awt.getdrawingsurface(env, canvas); if (ds == null) { #ifndef vtk_java_debug printf("null drawing surface\n"); #endif homecoming 1; } /* lock drawing surface */ lock = ds->lock(ds); if((lock & jawt_lock_error) != 0) { #ifndef vtk_java_debug printf("error locking surface\n"); #endif awt.freedrawingsurface(ds); homecoming 1; } /* drawing surface info */ dsi = ds->getdrawingsurfaceinfo(ds); if (dsi == null) { printf("error getting surface info\n"); ds->unlock(ds); awt.freedrawingsurface(ds); homecoming 1; } // here win32 drawing code #if defined(_win32) || defined(win32) temp0->finalize(); jawt_win32drawingsurfaceinfo* dsi_win; dsi_win = (jawt_win32drawingsurfaceinfo*)dsi->platforminfo; temp0->setwindowid((void *)dsi_win->hwnd); temp0->setdisplayid((void *)dsi_win->hdc); // set parent id avoid border sizes beingness added temp0->setparentid((void *)dsi_win->hdc); // utilize mac code #elif defined(__apple__) jawt_macosxdrawingsurfaceinfo* dsi_mac; dsi_mac = (jawt_macosxdrawingsurfaceinfo*)dsi->platforminfo; temp0->setwindowid(dsi_mac->cocoaviewref); // otherwise utilize x11 code #else jawt_x11drawingsurfaceinfo* dsi_x11; dsi_x11 = (jawt_x11drawingsurfaceinfo*)dsi->platforminfo; temp0->setdisplayid((void *)dsi_x11->display); temp0->setwindowid((void *)dsi_x11->drawable); temp0->setparentid((void *)dsi_x11->display); #endif /* free drawing surface info */ ds->freedrawingsurfaceinfo(dsi); /* unlock drawing surface */ ds->unlock(ds); /* free drawing surface */ awt.freedrawingsurface(ds); #if defined(win32_jawt_lock_hack) if (wjlh_init_check == 0) { wjlh_init_check = 1; } wjlh_lock_map[hash] = 1; #endif homecoming 0; }

well, figured out myself returning info on window manager utilize on system.

it uses getpeer function of java right info , give c code. not possible give want draw because javadoc tells computer specific , not rewritten.

hopefully, lastly vtk version (6.1.0) gives new alternative have vtk in javafx using vtkjoglpanelcomponent. it's supposed lightweight guess because other option, vtkjoglcanvascomponent not working @ all.

java c++ jni vtk jawt

No comments:

Post a Comment