Le Mon, 28 Jun 2010 10:13:07 +0200 (CEST), jcouteau@users.nuiton.org a écrit :
} + + /** + * @param filename + * @param x + * @param y + * @param type + * @param main + * @param sub + * @param xlab + * @param ylab + * @param asp + */ + public void plot(String filename, String x, String y, String type, + String main, String sub, String xlab, String ylab, + String asp) throws RException { + + eval("jpeg(\"" + filename + ".jpg\")"); + + String Rinstruction = "plot("; + + if ((x != null) && (!x.isEmpty())) { + Rinstruction += x; + } else { + throw new IllegalArgumentException("x argument must be filled"); + } + + if ((y != null) && (!y.isEmpty())) { + Rinstruction += ",y=" + y; + } + + if (type != null) { + Rinstruction += ",type=\"" + type + "\""; + } + + if (main != null) { + Rinstruction += ",main=\"" + main + "\""; + } + + if (sub != null) { + Rinstruction += ",sub=\"" + sub + "\""; + } + + if (xlab != null) { + Rinstruction += ",xlab=\"" + xlab + "\""; + } + + if (ylab != null) { + Rinstruction += ",ylab=\"" + ylab + "\""; + } + + if (asp != null) { + Rinstruction += ",asp=" + asp + "\""; + } + + Rinstruction += ")"; + + eval(Rinstruction); + eval("dev.off()"); + + } }
Non, on évite d'écrire ce genre de code avec des concatenation de string a fouason . Il faut utiliser un StringBuilder. -- Tony Chemit -------------------- tél: +33 (0) 2 40 50 29 28 email: chemit@codelutin.com http://www.codelutin.com