Changeset 1727


Ignore:
Timestamp:
May 20, 2010 2:13:17 PM (14 years ago)
Author:
braffert
Message:

Last fix for building java bindings. Also added license info and more comments.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/app-fermi/java/Fermi.java

    r1722 r1727  
     1/*
     2 * EXAMPLE: Fermi-Dirac function in Java.
     3 *
     4 * This simple example shows how to use Rappture within a simulator
     5 * written in Java.
     6 * ======================================================================
     7 * AUTHOR:  Ben Rafferty, Purdue University
     8 * Copyright (c) 2010  Purdue Research Foundation
     9 *
     10 * See the file "license.terms" for information on usage and
     11 * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
     12 * ======================================================================
     13 */
    114
    215class Fermi{
     
    417  public static void main(String args[]){
    518
     19    // create a rappture library from the file path
    620    rappture.Library driver = new rappture.Library(args[0]);
    721
     22    // read the input values and convert to correct units
    823    String Tstr = driver.get("input.number(temperature).current");
    924    double T = Double.valueOf(rappture.Units.convert(Tstr, "K", false));
    10    
    1125    String Efstr = driver.get("input.number(Ef).current");
    1226    double Ef = Double.valueOf(rappture.Units.convert(Efstr, "eV", false));
    1327
     28    // Set the energy range and step size
    1429    double kT = 8.61734E-5 * T;
    1530    double Emin = Ef - 10*kT;
    1631    double Emax = Ef + 10*kT;
    17 
    1832    double E = Emin;
    1933    double dE = 0.005*(Emax-Emin);
    2034
    21     double f;
    22     String line;
    23 
     35    // Add relevant information to the output curve
    2436    driver.put("output.curve(f12).about.label", "Fermi-Dirac Factor");
    2537    driver.put("output.curve(f12).xaxis.label", "Fermi-Dirac Factor");
     
    2739    driver.put("output.curve(f12).yaxis.units", "eV");
    2840
     41    // Calculate the Fermi-Dirac function over the energy range
     42    // Add the results to the output curve
     43    double f;
     44    String line;
    2945    while (E < Emax){
    3046      f = 1.0/(1.0 + Math.exp((E - Ef)/kT));
     
    3551    }
    3652
     53    // Finalize the results and inform rappture that the simulation has ended
    3754    driver.result();
    3855  }
  • trunk/examples/app-fermi/java/Makefile.in

    r1722 r1727  
    3636
    3737clean:
    38         $(RM)Fermi.class
     38        $(RM) Fermi.class
    3939
    4040distclean: clean
  • trunk/lang/java/Library.java

    r1722 r1727  
     1/*
     2 * ======================================================================
     3 *  AUTHOR:  Ben Rafferty, Purdue University
     4 *  Copyright (c) 2010  Purdue Research Foundation
     5 *
     6 *  See the file "license.terms" for information on usage and
     7 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
     8 * ======================================================================
     9 */
     10
     11/*
     12 * This file defines a Java class that implemements the rappture XML library.
     13 * The class methods call the corresponding native code through c++ glue code
     14 * located in jRpLibrary.cc.
     15 */
     16
    117package rappture;
    218
     
    1127  }
    1228
    13   // Pseudo-Destructor---------------------------------------------------------
     29  // Pseudo-Destructor.  Called when the object is garbage collected.----------
    1430  protected void finalize() throws Throwable {
    1531    try {
     
    5874  private native String jRpGetString(long libPtr, String path);
    5975
    60   private native void jRpPut(long libPtr, String path, String value, boolean append);
     76  private native void jRpPut(long libPtr, String path,
     77                             String value, boolean append);
    6178
    6279  private native void jRpResult(long libPtr, int exitStatus); 
    6380
    6481  // Private Attributes--------------------------------------------------------
    65   private long libPtr;  //pointer to c rpLibrary
     82  private long libPtr;  //pointer to c++ RpLibrary
    6683
    6784}
    6885
    69 
    70 
  • trunk/lang/java/Makefile.in

    r1724 r1727  
    3939RM              = rm -f
    4040
    41 INCLUDES = $(JAVA_INCLUDES) -I $(includedir) -I .
    42 LIBS = -L $(LIB_SEARCH_DIRS) -lrappture
     41INCLUDES = $(JAVA_INCLUDES) -I $(srcdir)/../../src/core -I .
     42LIBS = -L ../../src/core -lrappture
    4343
    44 CXX_O_SWITCHES = -fpic -c $(INCLUDES) $(LIBS)
     44CXX_O_SWITCHES = -fpic -c $(INCLUDES)
    4545
    46 CXX_SO_SWITCHES = --shared $(LIBS)
     46CXX_SO_SWITCHES = --shared $(INCLUDES) $(LIBS)
    4747
    4848OBJS    = \
  • trunk/lang/java/Units.java

    r1722 r1727  
     1/*
     2 * ======================================================================
     3 *  AUTHOR:  Ben Rafferty, Purdue University
     4 *  Copyright (c) 2010  Purdue Research Foundation
     5 *
     6 *  See the file "license.terms" for information on usage and
     7 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
     8 * ======================================================================
     9 */
     10
     11/*
     12 * This file defines a java class that implemements the rappture units module.
     13 * The class methods call the corresponding native code through c++ glue code
     14 * located in jRpUnits.cc.
     15 */
     16
     17
    118package rappture;
    219
  • trunk/lang/java/Utils.java

    r1722 r1727  
     1/*
     2 * ======================================================================
     3 *  AUTHOR:  Ben Rafferty, Purdue University
     4 *  Copyright (c) 2010  Purdue Research Foundation
     5 *
     6 *  See the file "license.terms" for information on usage and
     7 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
     8 * ======================================================================
     9 */
     10
     11/*
     12 * This file defines a java class that implemements the rappture utils module.
     13 * The class methods call the corresponding native code through c++ glue code
     14 * located in jRpUtils.cc.
     15 */
     16
    117package rappture;
    218
  • trunk/lang/java/jRpLibrary.cc

    r1722 r1727  
     1/*
     2 * ======================================================================
     3 *  AUTHOR:  Ben Rafferty, Purdue University
     4 *  Copyright (c) 2010  Purdue Research Foundation
     5 *
     6 *  See the file "license.terms" for information on usage and
     7 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
     8 * ======================================================================
     9 */
     10
     11/*
     12 * This file defines the native functions which are called by the java Library
     13 * class methods, and in turn call the corresponding rappture RpLibrary methods.
     14 */
     15
    116#include "jRpLibrary.h"
    217#include "rappture.h"
    318
    4 // constructor
     19/*
     20 * Constructor.  Returns the address of the newly created RpLibrary object to
     21 * java as a long int.
     22 */
    523JNIEXPORT jlong JNICALL Java_rappture_Library_jRpLibrary
    624  (JNIEnv *env, jobject obj, jstring javaPath){
     
    1129}
    1230
    13 // Pseudo-destructor
     31/*
     32 * Pseudo-destructor.  This function is called by the java Library class's
     33 * finalizer.
     34 */
    1435JNIEXPORT void JNICALL Java_rappture_Library_jRpDeleteLibrary
    1536  (JNIEnv *env, jobject obj, jlong libPtr){
  • trunk/lang/java/jRpUnits.cc

    r1722 r1727  
     1/*
     2 * ======================================================================
     3 *  AUTHOR:  Ben Rafferty, Purdue University
     4 *  Copyright (c) 2010  Purdue Research Foundation
     5 *
     6 *  See the file "license.terms" for information on usage and
     7 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
     8 * ======================================================================
     9 */
     10
     11/*
     12 * This file defines the native functions which are called by the java Units
     13 * class methods, and in turn call the corresponding rappture RpUnits methods.
     14 */
     15
    116#include "jRpUnits.h"
    217#include "rappture.h"
    318
     19// convert
    420JNIEXPORT jstring JNICALL Java_rappture_Units_jRpUnitsConvert
    521  (JNIEnv *env, jclass cls, jstring javaFromVal, jstring javaTo, jboolean units){
  • trunk/lang/java/jRpUtils.cc

    r1722 r1727  
     1/*
     2 * ======================================================================
     3 *  AUTHOR:  Ben Rafferty, Purdue University
     4 *  Copyright (c) 2010  Purdue Research Foundation
     5 *
     6 *  See the file "license.terms" for information on usage and
     7 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
     8 * ======================================================================
     9 */
     10
     11/*
     12 * This file defines the native functions which are called by the java Utils
     13 * class methods, and in turn call the corresponding rappture RpUtils methods.
     14 */
     15
    116#include "jRpUtils.h"
    217#include "rappture.h"
    318
     19// progress
    420JNIEXPORT void JNICALL Java_rappture_Utils_jRpUtilsProgress
    521  (JNIEnv *env, jclass cls, jint percent, jstring javaText){
    6   const char* nativeText = env->GetStringUTFChars(javaText, 0);
     22          const char* nativeText = env->GetStringUTFChars(javaText, 0);
    723  Rappture::Utils::progress(percent, nativeText);
    824  env->ReleaseStringUTFChars(javaText, nativeText);
Note: See TracChangeset for help on using the changeset viewer.