Skip to content

Commit

Permalink
Version 2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
hako committed Mar 14, 2015
1 parent f40d5b9 commit 57a08ad
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 41 deletions.
Binary file removed RCaller/.RData
Binary file not shown.
2 changes: 1 addition & 1 deletion RCaller/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>rcaller</groupId>
<artifactId>RCaller</artifactId>
<version>2.4-SNAPSHOT</version>
<version>2.5</version>
<packaging>jar</packaging>

<name>RCaller</name>
Expand Down
80 changes: 43 additions & 37 deletions RCaller/src/main/java/rcaller/Globals.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/*
*
RCaller, A solution for calling R from Java
Copyright (C) 2010-2014 Mehmet Hakan Satman
RCaller, A solution for calling R from Java
Copyright (C) 2010-2014 Mehmet Hakan Satman
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* Mehmet Hakan Satman - [email protected]
Expand All @@ -23,36 +23,42 @@
* Please visit the blog page with rcaller label:
* http://stdioe.blogspot.com.tr/search/label/rcaller
*/

package rcaller;

import graphics.DefaultTheme;
import graphics.GraphicsTheme;

public class Globals {

public static String cranRepos = "http://cran.r-project.org";
public static String RScript_Windows = "C:\\Program Files\\R\\R-3.0.2\\bin\\Rscript.exe";
public static String RScript_Linux = "/usr/bin/Rscript";
public static String Rscript_current;
public static String R_Windows = "C:\\Program Files\\R\\R-3.0.2\\bin\\R.exe";
public static String R_Linux = "/usr/bin/R";
public static String R_current;

public static GraphicsTheme theme = new DefaultTheme();

public final static String version = "RCaller 2.0";
public final static String about = "Author: Mehmet Hakan Satman - [email protected]";
public final static String licence = "LGPL v3.0";


public static void detect_current_rscript() {
if (System.getProperty("os.name").contains("Windows")) {
Rscript_current = RScript_Windows;
R_current = R_Windows;
} else {
Rscript_current = RScript_Linux;
R_current = R_Linux;
}
}
public static String cranRepos = "http://cran.r-project.org";
public static String RScript_Windows = "C:\\Program Files\\R\\R-3.0.2\\bin\\Rscript.exe";
public static String RScript_Linux = "/usr/bin/Rscript";
public static String Rscript_current;
public static String R_Windows = "C:\\Program Files\\R\\R-3.0.2\\bin\\R.exe";
public static String R_Linux = "/usr/bin/R";
public static String R_current;

public static GraphicsTheme theme = new DefaultTheme();

public final static String version = "RCaller 2.0";
public final static String about = "Author: Mehmet Hakan Satman - [email protected]";
public final static String licence = "LGPL v3.0";

public static void detect_current_rscript() {
if (System.getProperty("os.name").contains("Windows")) {
Rscript_current = RScript_Windows;
R_current = R_Windows;
} else {
Rscript_current = RScript_Linux;
R_current = R_Linux;
}
}

public static boolean isWindows() {
if (System.getProperty("os.name").contains("Windows")) {
return (true);
} else {
return (false);
}
}
}
5 changes: 4 additions & 1 deletion RCaller/src/main/java/rcaller/RCaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,12 @@ public void StopRCallerOnline() {
try {
process.getOutputStream().write("q(\"no\")\n".getBytes());
process.getOutputStream().flush();
process.getOutputStream().close();
} catch (Exception e) {
}
process.destroy();
if(Globals.isWindows()){
process.destroy();
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion RCaller/src/test/java/rcaller/GridCapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public class GridCapTest {
public void GridCapTest(){
RCaller caller = new RCaller();
RCode code = new RCode();
caller.setRscriptExecutable("C:\\Program Files\\R\\R-3.0.2\\bin\\Rscript.exe");
Globals.detect_current_rscript();
caller.setRscriptExecutable(Globals.Rscript_current);
code.R_require("grid");
code.addRCode("dev.new(width=.5, height=.5)");
code.addRCode("grid.rect()");
Expand Down
2 changes: 2 additions & 0 deletions RCaller/src/test/java/rcaller/RunOnlineTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public void testMatrixOnline() {
double mad = rcaller.getParser().getAsDoubleArray("result")[0];
System.out.println("mad: " + mad);

System.out.println("Deleting temp files:");
rcaller.deleteTempFiles();
System.out.println("Stopping RCaller online");
rcaller.StopRCallerOnline();
}

Expand Down
2 changes: 1 addition & 1 deletion RCaller/src/test/java/rcaller/matrix/RealMatrixTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static void MyAfterClass() {

public RealMatrixTest() {
Globals.detect_current_rscript();
pathToR = Globals.R_Windows;
pathToR = Globals.R_current;
if (rm == null) {
rm = new RealMatrix(pathToR, "MyMatrix");
}
Expand Down

0 comments on commit 57a08ad

Please sign in to comment.