}
public void executeRCode(int status, String loadingFile, String rCall) {
JavaFilterData.getInstance().loadData();
RCaller caller = new RCaller();
RCode code = new RCode();
Controller.getInstance().initializeBasic(caller, code);
if (status == 2 || status == 3 || status == 4) {
code.addRCode(InitialRCode.returnInstance().returnAllInitialCode());
}
// code.addRCode(rCodeToBeExecuted.toString());
if (status == 1) {
code.addRCode(rCodeToBeExecuted.toString());
String rCodeFix = "dataset<-data.frame(lapply(dataset2, as.character), stringsAsFactors=FALSE)";
code.addRCode(rCodeFix);
}
if (status == 2) {
// code.addRCode(InitialRCode.returnInstance().returnAllInitialCode());
code.addRCode(loadingFile + "\n");
code.addRCode("\n" + rCall);
String rCodeFix = "result2<-data.frame(lapply(result, as.character), stringsAsFactors=FALSE)";
code.addRCode(rCodeFix);
}
File plotFile = null;
ImageIcon plotImage = null;
if (status == 4) {
code.addRCode(loadingFile + "\n");
try {
plotFile = code.startPlot();
} catch (IOException ex) {
System.out.println("Cannot create plot");
Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, null, ex);
}
code.addRCode("\n" + rCall);
}
if (status == 3) {
code.addRCode(rCall + "\n");
}
caller.setRCode(code);
System.out.println("Kod koji ce da se izvrsi: \n" + code.toString());
System.out.println("-----------------------------------------------------------------------------------");
if (status == 1) {
//we will parse csv from java
//caller.runAndReturnResult("dataset");
DataFrameFromCSV df = new DataFrameFromCSV();
df.createDataFrameAndFillItWithData(new File(selectedFile));
Controller.getInstance().updateDataFrame(df);
caller.runOnly();
}
if (status == 2) {
caller.runOnly();
//caller.runAndReturnResult("result2");
}
if (status == 3) {
caller.runAndReturnResult("result");
DataFrame df = new StringDataFrame();
File xmlDocument = caller.getParser().getXMLFile();
df.createDataFrameAndFillItWithData(xmlDocument);
solarLong = (String) df.getMatrix()[0][0];
}
if (status == 4) {
caller.runOnly();
plotImage = code.getPlot(plotFile);
// code.showPlot(plotFile);
graph = plotFile;
}
if (status != 4 && status != 3 && status != 2 && status != 1) {