Images from Mathematica to Java
•
Java
I tried to get a picture from Mathematica
So my question:
How to convert these graphics to Java???
Here is my sample code:
ml = MathLinkFactory.createKernelLink("-linkmode launch -linkname 'F:\\APPS\\Wolfram Research\\Mathematica\\7.0\\mathkernel.exe'"); ml.addPacketListener(new MyPacketListener()); ml.discardAnswer(); PacketListener stdoutPrinter = new PacketPrinter(System.out); ml.addPacketListener(stdoutPrinter); // In stringList there is all the INPUT for Mathematica for (int i = 0; stringList.size() > i; i++) { System.out.println("Input" + "[" + i + "]" + stringList.get(i)); ml.evaluate(stringList.get(i)); ml.discardAnswer(); } ml.close(); class MyPacketListener implements PacketListener { public boolean packetArrived(PacketArrivedEvent evt) throws MathLinkException { if (evt.getPktType() == MathLink.TEXTPKT) { KernelLink ml = (KernelLink) evt.getSource(); System.out.println(ml.getString()); } return true; }
The output is:
<<CIP`ExperimentalData` <<CIP`MLR` dataSet = CIP`ExperimentalData`GetQSPRDataSet02[]; CIP`Graphics`ShowDataSetInfo[{"IoPairs","InputComponents","OutputComponents"},dataSet]; Number of IO pairs = 2169 Number of input components = 130 Number of output components = 1 mlrInfo = CIP`MLR`FitMlr[dataSet]; mlrInfoInInputForm = InputForm[mlrInfo]; pointSize = 0.025; CIP`MLR`ShowMlrSingleRegression[{"ModelVsDataPlot","CorrelationCoefficient"},dataSet,mlrInfo,GraphicsOptionPointSize -> pointSize]; (*-Graphics-*) (* Out 1 : Correlation coefficient = 0.999373 *) pointSize = 0.01; CIP`MLR`ShowMlrSingleRegression[{"AbsoluteSortedResidualsPlot","AbsoluteResidualsStatistics","RMSE"},GraphicsOptionPointSize -> pointSize]; (*-Graphics- DeFinition of 'Residual (absolute)': Data - Model -1 Out 1 : Residual (absolute): Mean/Median/Maximum Value = 1.4 / 9.84 × 10 / 1 > 1.79 × 10 Root mean squared error (RMSE) = 2.063 *)
How do I get these - Graphics -?
Thank you for your help!
Solution
The J / link user guide has a good code example for sending graphics from Mathematica to Java:
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码