|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.utils.REnvironment
public class REnvironment
This is an environment class for R and Rserve that helps you to handle all things in a more gentle way.
RUtils
Constructor Summary | |
---|---|
REnvironment()
This constructor creates a connection to an R instance on the "localhost" with empty login and password. |
|
REnvironment(String server,
int port,
String user,
String passwd)
Creates a new REnvironment with initial size 10 using the given
port. |
|
REnvironment(String server,
int port,
String user,
String passwd,
int initSize)
Creates a new REnvironment using the given port. |
|
REnvironment(String server,
String user,
String passwd)
Creates a new REnvironment with initial size 10 using the default
port. |
|
REnvironment(String server,
String user,
String passwd,
int initSize)
Creates a new REnvironment using the default port. |
Method Summary | |
---|---|
void |
close()
Closes the REnvironment and removes all files from the server. |
boolean |
copyFileFromServer(String serverFileName,
String clientFileName,
boolean overwriteExistingFile)
Copies a file from the server to the local machine. |
boolean |
copyFileToServer(String clientFileName,
String serverFileName,
boolean overwriteExistingFile)
Copies a file from the local machine to the server. |
REXP |
createMatrix(String matrixName,
double[][] matrix)
Creates a matrix of double s. |
REXP |
createMatrix(String matrixName,
int[][] matrix)
Creates a matrix of int s. |
REXP |
createVector(String vectorName,
double[] vector)
Creates a vector of double s. |
REXP |
createVector(String vectorName,
int[] vector)
Creates a vector of int s. |
REXP |
createVector(String vectorName,
long[] vector)
Creates a vector of long s. |
REXP |
createVector(String vectorName,
String[] vector)
Creates a vector of String s. |
void |
deleteAllFilesAtTheServer()
Deletes all files that have been copied to the server or created on the server. |
REXP |
eval(CharSequence cmd)
Evaluates the String as R commands. |
protected void |
finalize()
|
String |
getVersionInformation()
Returns information about the version of R that is used. |
void |
installScript(String clientFileName,
String serverFileName,
boolean overwriteExistingFile)
Installs a script on the server. |
BufferedImage |
plot(CharSequence pltcmd)
Creates a buffered image from a given plot command. |
BufferedImage |
plot(CharSequence pltcmd,
double width,
double height)
Creates a buffered image with given dimension from a given plot command. |
void |
plot(CharSequence pltcmd,
double width,
double height,
String formatName,
OutputStream out)
This method creates an image with given dimension from a given plot command and pipes it to the output stream. |
boolean |
plotToPDF(CharSequence pltcmd,
double width,
double height,
String fileName,
boolean overwriteExistingFile)
Creates a pdf file with given dimension from a given plot command. |
boolean |
plotToPDF(CharSequence pltcmd,
String fileName,
boolean overwriteExistingFile)
Creates a pdf file from a given plot command. |
boolean |
plotToTexFile(CharSequence pltcmd,
double width,
double height,
String fileName,
boolean overwriteExistingFile)
Creates a tex file with given dimension from a given plot command. |
boolean |
plotToTexFile(CharSequence pltcmd,
String fileName,
boolean overwriteExistingFile)
Creates a tex file from a given plot command. |
static JFrame |
showImage(String title,
BufferedImage img)
Enables you to show an image. |
static JFrame |
showImage(String title,
BufferedImage img,
int defaultCloseOperation)
Enables you to show an image. |
void |
voidEval(CharSequence cmd)
Evaluates the String as R commands. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public REnvironment() throws Exception
Exception
- if something went wrongREnvironment(String, String, String)
public REnvironment(String server, String user, String passwd, int initSize) throws Exception
REnvironment
using the default port.
server
- the name of the serveruser
- the loginpasswd
- the password for the logininitSize
- the initial number of slots for files on the server (has to be
at least 1)
Exception
- if something went wrongpublic REnvironment(String server, String user, String passwd) throws Exception
REnvironment
with initial size 10 using the default
port.
server
- the name of the serveruser
- the loginpasswd
- the password for the login
Exception
- if something went wrongREnvironment(String, String, String, int)
public REnvironment(String server, int port, String user, String passwd, int initSize) throws Exception
REnvironment
using the given port.
server
- the name of the serverport
- the portuser
- the loginpasswd
- the password for the logininitSize
- the initial number of slots for files on the server (has to be
at least 1)
Exception
- if something went wrongpublic REnvironment(String server, int port, String user, String passwd) throws Exception
REnvironment
with initial size 10 using the given
port.
server
- the name of the serverport
- the portuser
- the loginpasswd
- the password for the login
Exception
- if something went wrongREnvironment(String, String, String, int)
Method Detail |
---|
public boolean copyFileFromServer(String serverFileName, String clientFileName, boolean overwriteExistingFile) throws Exception
serverFileName
- name of the file on the serverclientFileName
- name of the file on the client (local machine)overwriteExistingFile
- whether to overwrite the file, if already existing on the
client
true
if the file is copied successfully
Exception
- if something went wrongpublic boolean copyFileToServer(String clientFileName, String serverFileName, boolean overwriteExistingFile) throws Exception
serverFileName
- name of the file on the serverclientFileName
- name of the file on the client (local machine)overwriteExistingFile
- whether to overwrite the file, if already existing on the
server
true
if the file is copied successfully
Exception
- if something went wrongpublic void close() throws Exception
REnvironment
and removes all files from the server.
Exception
- if something went wrongpublic REXP createMatrix(String matrixName, int[][] matrix) throws RserveException, IllegalArgumentException
int
s.
matrixName
- the name of the matrixmatrix
- the matrix of int
s
RserveException
- if something with Rserve went wrong
IllegalArgumentException
- if matrix[i].length != matrix[j].length
public REXP createMatrix(String matrixName, double[][] matrix) throws RserveException, IllegalArgumentException
double
s.
matrixName
- the name of the matrixmatrix
- the matrix of double
s
RserveException
- if something with Rserve went wrong
IllegalArgumentException
- if matrix[i].length != matrix[j].length
public REXP createVector(String vectorName, String[] vector) throws RserveException
String
s.
vectorName
- the name of the vectorvector
- the vector of String
s
RserveException
- if something with Rserve went wrongpublic REXP createVector(String vectorName, int[] vector) throws RserveException
int
s.
vectorName
- the name of the vectorvector
- the vector of int
s
RserveException
- if something with Rserve went wrongpublic REXP createVector(String vectorName, long[] vector) throws RserveException
long
s.
vectorName
- the name of the vectorvector
- the vector of long
s
RserveException
- if something with Rserve went wrongpublic REXP createVector(String vectorName, double[] vector) throws RserveException
double
s.
vectorName
- the name of the vectorvector
- the vector of double
s
RserveException
- if something with Rserve went wrongpublic void deleteAllFilesAtTheServer() throws Exception
Exception
- if something went wrongpublic REXP eval(CharSequence cmd) throws Exception
String
as R commands.
cmd
- the String
to be evaluated
Exception
- if something went wrongpublic String getVersionInformation() throws Exception
Exception
- if something went wrongpublic void installScript(String clientFileName, String serverFileName, boolean overwriteExistingFile) throws Exception
clientFileName
- the name of the scriptfile on the clientserverFileName
- the name of the scriptfile on the serveroverwriteExistingFile
- if true
the method is enabled to overwrite an
existing file
Exception
- if something went wrongpublic BufferedImage plot(CharSequence pltcmd) throws Exception
pltcmd
- the plot command
Exception
- if something went wrongplot(CharSequence, double, double)
,
showImage(String, BufferedImage)
,
ImageIO.write(java.awt.image.RenderedImage, String, File)
public BufferedImage plot(CharSequence pltcmd, double width, double height) throws Exception
pltcmd
- the plot commandwidth
- the width of the image (in pixel)height
- the height of the image (in pixel)
Exception
- if something went wrongshowImage(String, BufferedImage)
,
ImageIO.write(java.awt.image.RenderedImage, java.lang.String,
java.io.File)
public void plot(CharSequence pltcmd, double width, double height, String formatName, OutputStream out) throws IOException, Exception
pltcmd
- the plotting commandwidth
- the width of the imageheight
- the height of the imageformatName
- the name of the image format used for writing the image (see ImageIO
)out
- the OutputStream
used for writing the image
IOException
- see ImageIO.write(java.awt.image.RenderedImage, String, OutputStream)
Exception
- see plot(CharSequence, double, double)
ImageIO.write(java.awt.image.RenderedImage, String, OutputStream)
public boolean plotToPDF(CharSequence pltcmd, String fileName, boolean overwriteExistingFile) throws Exception
pltcmd
- the plot commandfileName
- the name of the pdf fileoverwriteExistingFile
- if true
the method is enabled to overwrite an
existing file
true
if the plot is done
Exception
- if something went wrongpublic boolean plotToPDF(CharSequence pltcmd, double width, double height, String fileName, boolean overwriteExistingFile) throws Exception
pltcmd
- the plot commandwidth
- the width of the imageheight
- the height of the imagefileName
- the name of the pdf fileoverwriteExistingFile
- if true
the method is enabled to overwrite an
existing file
true
if the plot is done
Exception
- if something went wrongpublic boolean plotToTexFile(CharSequence pltcmd, String fileName, boolean overwriteExistingFile) throws Exception
pltcmd
- the plot commandfileName
- the name of the tex fileoverwriteExistingFile
- if true
the method is enabled to overwrite an
existing file
true
if the plot is done
Exception
- if something went wrongpublic boolean plotToTexFile(CharSequence pltcmd, double width, double height, String fileName, boolean overwriteExistingFile) throws Exception
pltcmd
- the plot commandwidth
- the width of the imageheight
- the height of the imagefileName
- the name of the tex fileoverwriteExistingFile
- if true
the method is enabled to overwrite an
existing file
true
if the plot is done
Exception
- if something went wrongpublic void voidEval(CharSequence cmd) throws Exception
String
as R commands.
cmd
- the String
to be evaluated
Exception
- if something went wrongprotected void finalize() throws Throwable
finalize
in class Object
Throwable
public static JFrame showImage(String title, BufferedImage img) throws InterruptedException
title
- the title of the frameimg
- the image
InterruptedException
- if the process is interruptedshowImage(String, BufferedImage, int)
public static JFrame showImage(String title, BufferedImage img, int defaultCloseOperation) throws InterruptedException
title
- the title of the frameimg
- the imagedefaultCloseOperation
- the variable used to control the window-closing operation
InterruptedException
- if the process is interruptedWindowConstants
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |