Skip to content

Commit 66c7a0a

Browse files
committed
Completed issue #1179
1 parent dc78f74 commit 66c7a0a

File tree

2 files changed

+65
-61
lines changed

2 files changed

+65
-61
lines changed

lib/JRI.jar

-43.7 KB
Binary file not shown.

src/dr/geo/contouring/ContourWithR.java

+65-61
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727

2828
package dr.geo.contouring;
2929

30-
import org.rosuda.JRI.REXP;
31-
import org.rosuda.JRI.RVector;
32-
import org.rosuda.JRI.Rengine;
30+
//import org.rosuda.JRI.REXP;
31+
//import org.rosuda.JRI.RVector;
32+
//import org.rosuda.JRI.Rengine;
3333

3434
/**
3535
* @author Marc Suchard
@@ -42,26 +42,28 @@ public ContourWithR(final double[] xValues, final double[] yValues) {
4242
}
4343

4444
public ContourWithR(final double[] xValues, final double[] yValues, int N) {
45-
this.xValues = xValues;
46-
this.yValues = yValues;
47-
this.N = N;
45+
throw new UnsupportedOperationException("R jnilib no longer supported");
46+
// this.xValues = xValues;
47+
// this.yValues = yValues;
48+
// this.N = N;
4849
}
4950

5051
private final double[] xValues;
5152
private final double[] yValues;
5253

5354
public ContourPath[] getContourPaths(double hpdValue) {
54-
makeContour(xValues, yValues, hpdValue, N);
55-
if (contourList == null)
56-
return null;
57-
58-
ContourPath[] contourPaths = new ContourPath[getNumberContours()];
59-
60-
for(int i=0; i<getNumberContours(); i++) {
61-
double[][] cont = getContour(i);
62-
contourPaths[i] = new ContourPath(null,1,cont[0],cont[1]);
63-
}
64-
return contourPaths;
55+
throw new UnsupportedOperationException("R jnilib no longer supported");
56+
// makeContour(xValues, yValues, hpdValue, N);
57+
// if (contourList == null)
58+
// return null;
59+
//
60+
// ContourPath[] contourPaths = new ContourPath[getNumberContours()];
61+
//
62+
// for(int i=0; i<getNumberContours(); i++) {
63+
// double[][] cont = getContour(i);
64+
// contourPaths[i] = new ContourPath(null,1,cont[0],cont[1]);
65+
// }
66+
// return contourPaths;
6567
}
6668

6769

@@ -70,43 +72,45 @@ public void makeContour(double[] xValues, double[] yValues, double hpd) {
7072
}
7173

7274
public void makeContour(double[] xValues, double[] yValues, double hpd, int N) {
73-
74-
75-
REXP x = rEngine.eval("makeContour(" +
76-
makeRString(xValues) + "," +
77-
makeRString(yValues) + "," +
78-
hpd + "," +
79-
N + ")");
80-
contourList = x.asVector();
75+
throw new UnsupportedOperationException("R jnilib no longer supported");
76+
77+
// REXP x = rEngine.eval("makeContour(" +
78+
// makeRString(xValues) + "," +
79+
// makeRString(yValues) + "," +
80+
// hpd + "," +
81+
// N + ")");
82+
// contourList = x.asVector();
8183
}
8284

8385
public int getNumberContours() {
84-
if (contourList != null)
85-
return contourList.size();
86-
return 0;
86+
throw new UnsupportedOperationException("R jnilib no longer supported");
87+
// if (contourList != null)
88+
// return contourList.size();
89+
// return 0;
8790
}
8891

8992

9093

9194

9295
public double[][] getContour(int whichContour) {
93-
94-
if (contourList != null) {
95-
double[][] result = new double[2][];
96-
RVector oneContour = contourList.at(whichContour).asVector();
97-
result[0] = oneContour.at(1).asDoubleArray();
98-
result[1] = oneContour.at(2).asDoubleArray();
99-
return result;
100-
}
101-
return null;
96+
throw new UnsupportedOperationException("R jnilib no longer supported");
97+
98+
// if (contourList != null) {
99+
// double[][] result = new double[2][];
100+
// RVector oneContour = contourList.at(whichContour).asVector();
101+
// result[0] = oneContour.at(1).asDoubleArray();
102+
// result[1] = oneContour.at(2).asDoubleArray();
103+
// return result;
104+
// }
105+
// return null;
102106
}
103107

104108

105-
private static Rengine rEngine = null;
109+
// private static Rengine rEngine = null;
106110
private int N;
107111

108112

109-
private RVector contourList = null;
113+
// private RVector contourList = null;
110114

111115
private static final String[] rArgs = {"--no-save", "--max-vsize=1G"};
112116

@@ -137,27 +141,27 @@ private String makeRString(double[] values) {
137141

138142
static public boolean processWithR = false;
139143

140-
static {
141-
try {
142-
System.loadLibrary("jri");
143-
processWithR = true;
144-
System.err.println("JRI loaded. Will process using R contouring.");
145-
146-
// if (!Rengine.versionCheck()) {
147-
// throw new RuntimeException("JRI library version mismatch");
144+
// static {
145+
// try {
146+
// System.loadLibrary("jri");
147+
// processWithR = true;
148+
// System.err.println("JRI loaded. Will process using R contouring.");
149+
//
150+
//// if (!Rengine.versionCheck()) {
151+
//// throw new RuntimeException("JRI library version mismatch");
152+
//// }
153+
//
154+
// rEngine = new Rengine(rArgs, false, null);
155+
//
156+
// if (!rEngine.waitForR()) {
157+
// throw new RuntimeException("Cannot load R");
148158
// }
149-
150-
rEngine = new Rengine(rArgs, false, null);
151-
152-
if (!rEngine.waitForR()) {
153-
throw new RuntimeException("Cannot load R");
154-
}
155-
156-
for (String command : rBootCommands) {
157-
rEngine.eval(command);
158-
}
159-
} catch (UnsatisfiedLinkError e) {
160-
System.err.println("JRI not available. Will process using Java contouring.");
161-
}
162-
}
159+
//
160+
// for (String command : rBootCommands) {
161+
// rEngine.eval(command);
162+
// }
163+
// } catch (UnsatisfiedLinkError e) {
164+
// System.err.println("JRI not available. Will process using Java contouring.");
165+
// }
166+
// }
163167
}

0 commit comments

Comments
 (0)