コード例 #1
0
ファイル: jpal.cpp プロジェクト: Pana/pal
/*
 * Class:     ch_heigvd_jpal_JPal
 * Method:    jpal_removeLayer
 * Signature: (Ljava/lang/String;)V;
 */
JNIEXPORT void JNICALL Java_ch_heigvd_jpal_JPal_removeLayer
(JNIEnv * env, jobject obj, jstring lyrName) {

    jclass cls = env->GetObjectClass (obj);
    jfieldID fid = env->GetFieldID (cls, "pal_adr", "J");
    Pal *pal = (Pal*) env->GetLongField (obj, fid);

    const char *name = env->GetStringUTFChars (lyrName, NULL);

    pal->removeLayer (pal->getLayer (name));
}
コード例 #2
0
ファイル: jpal.cpp プロジェクト: Pana/pal
JNIEXPORT jobject JNICALL Java_ch_heigvd_jpal_JPal_getLayer
(JNIEnv *env, jobject obj, jstring layerName) {

    jclass cls = env->GetObjectClass (obj);
    jfieldID fid = env->GetFieldID (cls, "pal_adr", "J");
    Pal *pal = (Pal*) env->GetLongField (obj, fid);

    const char *name = env->GetStringUTFChars (layerName, NULL);

    Layer * layer = pal->getLayer (name);

    // Create a JPalLayer and put jpallayer_adr to (long)layer*
    jclass jpalLayer = env->FindClass ("ch/heigvd/jpal/JPalLayer");
    jmethodID jpalLayerInit = env->GetMethodID (jpalLayer, "<init>", "()V");
    jfieldID jpalLayerAdr = env->GetFieldID (jpalLayer, "pal_layer_adr", "J");

    jobject jpalLayerObj = env->NewObject (jpalLayer, jpalLayerInit);

    std::cout << "JNI_WRAP: layer adr: " << layer << std::endl;

    env->SetLongField (jpalLayerObj, jpalLayerAdr, (long) layer);

    return jpalLayerObj;
}