PageRenderTime 46ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/jmathplot/src/org/math/plot/PlotPanel.java

http://jmathplot.googlecode.com/
Java | 678 lines | 463 code | 94 blank | 121 comment | 102 complexity | af38a7ab69bd02ea292078595bfd5ead MD5 | raw file
  1. package org.math.plot;
  2. import java.awt.BorderLayout;
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.Image;
  7. import java.awt.image.BufferedImage;
  8. import java.awt.image.RenderedImage;
  9. import java.io.File;
  10. import java.io.IOException;
  11. import java.util.LinkedList;
  12. import javax.imageio.ImageIO;
  13. import javax.swing.ImageIcon;
  14. import javax.swing.JFrame;
  15. import javax.swing.JPanel;
  16. import org.math.io.files.ASCIIFile;
  17. import org.math.plot.canvas.PlotCanvas;
  18. import org.math.plot.components.LegendPanel;
  19. import org.math.plot.components.PlotToolBar;
  20. import org.math.plot.plotObjects.Axis;
  21. import org.math.plot.plotObjects.Plotable;
  22. import org.math.plot.plots.Plot;
  23. import org.math.plot.utils.Array;
  24. /**
  25. * BSD License
  26. *
  27. * @author Yann RICHET
  28. */
  29. public abstract class PlotPanel extends JPanel {
  30. private static final long serialVersionUID = 1L;
  31. public PlotToolBar plotToolBar;
  32. public PlotCanvas plotCanvas;
  33. public LegendPanel plotLegend;
  34. public final static String EAST = BorderLayout.EAST;
  35. public final static String SOUTH = BorderLayout.SOUTH;
  36. public final static String NORTH = BorderLayout.NORTH;
  37. public final static String WEST = BorderLayout.WEST;
  38. public final static String INVISIBLE = "INVISIBLE";
  39. public final static String SCATTER = "SCATTER";
  40. public final static String LINE = "LINE";
  41. public final static String BAR = "BAR";
  42. public final static String HISTOGRAM = "HISTOGRAM";
  43. public final static String BOX = "BOX";
  44. public final static String STAIRCASE = "STAIRCASE";
  45. public final static String GRID = "GRID";
  46. public final static Color[] COLORLIST = {Color.BLUE, Color.RED, Color.GREEN, Color.YELLOW, Color.ORANGE, Color.PINK, Color.CYAN, Color.MAGENTA};
  47. private Font font = new Font("Arial", Font.PLAIN, 10);
  48. public PlotPanel(PlotCanvas _canvas, String legendOrientation) {
  49. plotCanvas = _canvas;
  50. setBackground(Color.WHITE);
  51. setLayout(new BorderLayout());
  52. addPlotToolBar(NORTH);
  53. addLegend(legendOrientation);
  54. add(plotCanvas, BorderLayout.CENTER);
  55. }
  56. public PlotPanel(PlotCanvas _canvas) {
  57. this(_canvas, INVISIBLE);
  58. }
  59. /**
  60. * Defines where the legend of the plot should be added to the plot
  61. * panel.
  62. *
  63. * @param location Location where should be put the legend (String).
  64. * location can have the following values (case insensitive): EAST,
  65. * SOUTH, WEST, NORTH, INVISIBLE (legend will be hidden in this case).
  66. * Any other value will be ignored and an error message will be sent to
  67. * the error output.
  68. */
  69. public void addLegend(String location) {
  70. if (location.equalsIgnoreCase(EAST)) {
  71. plotLegend = new LegendPanel(this, LegendPanel.VERTICAL);
  72. add(plotLegend, EAST);
  73. } else if (location.equalsIgnoreCase(SOUTH)) {
  74. plotLegend = new LegendPanel(this, LegendPanel.HORIZONTAL);
  75. add(plotLegend, SOUTH);
  76. } else if (location.equalsIgnoreCase(WEST)) {
  77. plotLegend = new LegendPanel(this, LegendPanel.VERTICAL);
  78. add(plotLegend, WEST);
  79. } else if (location.equalsIgnoreCase(NORTH)) {
  80. plotLegend = new LegendPanel(this, LegendPanel.HORIZONTAL);
  81. add(plotLegend, NORTH);
  82. } else if (location.equalsIgnoreCase(INVISIBLE)) {
  83. plotLegend = new LegendPanel(this, LegendPanel.INVISIBLE);
  84. // add(legends, BorderLayout.NORTH);
  85. } else {
  86. System.err.println("Orientation " + location + " is unknonw.");
  87. }
  88. }
  89. /**
  90. * Removes the current legend from the plot panel.
  91. */
  92. public void removeLegend() {
  93. remove(plotLegend);
  94. }
  95. /**
  96. * Moves the legend to the specified location.
  97. *
  98. * @param location Location where should be put the legend (String).
  99. * location can have the following values (case insensitive): EAST,
  100. * SOUTH, WEST, NORTH, INVISIBLE (legend will be hidden in this case).
  101. * Any other value will be ignored and an error message will be sent to
  102. * the error output.
  103. */
  104. public void setLegendOrientation(String location) {
  105. removeLegend();
  106. addLegend(location);
  107. }
  108. /**
  109. * Adds a new plot toolbar to the specified location. The previous toolbar
  110. * is deleted.
  111. * @param location Location where should be put the toolbar (String).
  112. * location can have the following values (case insensitive): EAST,
  113. * SOUTH, WEST, NORTH.
  114. * Any other value will be ignored and an error message will be sent to
  115. * the error output.
  116. */
  117. public void addPlotToolBar(String location) {
  118. if (location.equalsIgnoreCase(EAST)) {
  119. removePlotToolBar();
  120. plotToolBar = new PlotToolBar(this);
  121. plotToolBar.setFloatable(false);
  122. add(plotToolBar, EAST);
  123. } else if (location.equalsIgnoreCase(SOUTH)) {
  124. removePlotToolBar();
  125. plotToolBar = new PlotToolBar(this);
  126. plotToolBar.setFloatable(false);
  127. add(plotToolBar, SOUTH);
  128. } else if (location.equalsIgnoreCase(WEST)) {
  129. removePlotToolBar();
  130. plotToolBar = new PlotToolBar(this);
  131. plotToolBar.setFloatable(false);
  132. add(plotToolBar, WEST);
  133. } else if (location.equalsIgnoreCase(NORTH)) {
  134. removePlotToolBar();
  135. plotToolBar = new PlotToolBar(this);
  136. plotToolBar.setFloatable(false);
  137. add(plotToolBar, NORTH);
  138. } else {
  139. System.err.println("Location " + location + " is unknonw.");
  140. }
  141. }
  142. /**
  143. * Removes the plot toolbar from the panel.
  144. */
  145. public void removePlotToolBar() {
  146. if (plotToolBar == null) {
  147. return;
  148. }
  149. remove(plotToolBar);
  150. }
  151. /**
  152. * Moves the plot toolbar to the specified location.
  153. * @param location Location where should be put the toolbar (String).
  154. * location can have the following values (case insensitive): EAST,
  155. * SOUTH, WEST, NORTH.
  156. * Any other value will be ignored and an error message will be sent to
  157. * the error output.
  158. */
  159. public void setPlotToolBarOrientation(String location) {
  160. addPlotToolBar(location);
  161. }
  162. // ///////////////////////////////////////////
  163. // ////// set actions ////////////////////////
  164. // ///////////////////////////////////////////
  165. public void setActionMode(int am) {
  166. plotCanvas.setActionMode(am);
  167. }
  168. public void setNoteCoords(boolean b) {
  169. plotCanvas.setNoteCoords(b);
  170. }
  171. public void setEditable(boolean b) {
  172. plotCanvas.setEditable(b);
  173. }
  174. public boolean getEditable() {
  175. return plotCanvas.getEditable();
  176. }
  177. public void setNotable(boolean b) {
  178. plotCanvas.setNotable(b);
  179. }
  180. public boolean getNotable() {
  181. return plotCanvas.getNotable();
  182. }
  183. // ///////////////////////////////////////////
  184. // ////// set/get elements ///////////////////
  185. // ///////////////////////////////////////////
  186. public LinkedList<Plot> getPlots() {
  187. return plotCanvas.getPlots();
  188. }
  189. public Plot getPlot(int i) {
  190. return plotCanvas.getPlot(i);
  191. }
  192. public int getPlotIndex(Plot p) {
  193. return plotCanvas.getPlotIndex(p);
  194. }
  195. public LinkedList<Plotable> getPlotables() {
  196. return plotCanvas.getPlotables();
  197. }
  198. public Plotable getPlotable(int i) {
  199. return plotCanvas.getPlotable(i);
  200. }
  201. /**
  202. * Return the axis specified in parameter.
  203. * @param i Axis number. 0 for X, 1 for Y, 2 for Z.
  204. * @return The axis which number is given in parameter.
  205. */
  206. public Axis getAxis(int i) {
  207. return plotCanvas.getGrid().getAxis(i);
  208. }
  209. /**
  210. * Returns the scaling for all of the axis of the plot.
  211. * @return An array of String
  212. *
  213. */
  214. public String[] getAxisScales() {
  215. return plotCanvas.getAxisScales();
  216. }
  217. // TODO axes labels are rested after addPlot... correct this.
  218. /**
  219. * Sets the name of the axis, in this order: X, Y and Z.
  220. * @param labels One to three strings containing the name of each axis.
  221. */
  222. public void setAxisLabels(String... labels) {
  223. plotCanvas.setAxisLabels(labels);
  224. }
  225. /**
  226. * Sets the name of the axis specified in parameter.
  227. * @param axe Axis number. 0 for X, 1 for Y, 2 for Z.
  228. * @param label Name to be given.
  229. */
  230. public void setAxisLabel(int axe, String label) {
  231. plotCanvas.setAxisLabel(axe, label);
  232. }
  233. /**
  234. * Sets the scale of the axes, linear or logarithm, in this order: X,Y,Z.
  235. * @param scales Strings containing the scaling, LOG or LIN (case insensitive) for the axes.
  236. */
  237. public void setAxisScales(String... scales) {
  238. plotCanvas.setAxisScales(scales);
  239. }
  240. /**
  241. * Sets the scaling of the specified axis.
  242. * @param axe Axis number. 0 for X, 1 for Y, 2 for Z.
  243. * @param scale String specifying the scaling. LIN or LOG, case insensitive.
  244. */
  245. public void setAxisScale(int axe, String scale) {
  246. plotCanvas.setAxiScale(axe, scale);
  247. }
  248. /**
  249. * Sets the boundaries for each axis.
  250. * @param min Array of at most 3 doubles specifying the min bound of each axis, in this order: X,Y,Z.
  251. * @param max Array of at most 3 doubles specifying the max bound of each axis, in this order: X,Y,Z.
  252. */
  253. public void setFixedBounds(double[] min, double[] max) {
  254. plotCanvas.setFixedBounds(min, max);
  255. }
  256. /**
  257. * Sets the boundaries for the specified axis.
  258. * @param axe Axis number to modify. 0 for X, 1 for Y, 2 for Z.
  259. * @param min Min bound of the axis.
  260. * @param max Max bound of the axis.
  261. */
  262. public void setFixedBounds(int axe, double min, double max) {
  263. plotCanvas.setFixedBounds(axe, min, max);
  264. }
  265. /**
  266. * Modify bounds of the axes so as to include the point given in parameter.
  267. * @param into Coords of the point to include in bounds.
  268. */
  269. public void includeInBounds(double... into) {
  270. plotCanvas.includeInBounds(into);
  271. }
  272. /**
  273. * Modify axes boundaries so as to include all the points of a given plot.
  274. * @param plot Plot to include.
  275. */
  276. public void includeInBounds(Plot plot) {
  277. plotCanvas.includeInBounds(plot);
  278. }
  279. /**
  280. * Set bounds automatically.
  281. */
  282. public void setAutoBounds() {
  283. plotCanvas.setAutoBounds();
  284. }
  285. /**
  286. * Set bounds automatically for one axis.
  287. * @param axe Number of the axis to modify. 0 for X, 1 for Y, 2 for Z.
  288. */
  289. public void setAutoBounds(int axe) {
  290. plotCanvas.setAutoBounds(axe);
  291. }
  292. public double[][] mapData(Object[][] stringdata) {
  293. return plotCanvas.mapData(stringdata);
  294. }
  295. public void resetMapData() {
  296. plotCanvas.resetMapData();
  297. }
  298. // ///////////////////////////////////////////
  299. // ////// add/remove elements ////////////////
  300. // ///////////////////////////////////////////
  301. public void addLabel(String text, Color c, double... where) {
  302. plotCanvas.addLabel(text, c, where);
  303. }
  304. public void addBaseLabel(String text, Color c, double... where) {
  305. plotCanvas.addBaseLabel(text, c, where);
  306. }
  307. public void addPlotable(Plotable p) {
  308. plotCanvas.addPlotable(p);
  309. }
  310. public void removePlotable(Plotable p) {
  311. plotCanvas.removePlotable(p);
  312. }
  313. public void removePlotable(int i) {
  314. plotCanvas.removePlotable(i);
  315. }
  316. public void removeAllPlotables() {
  317. plotCanvas.removeAllPlotables();
  318. }
  319. public int addPlot(Plot newPlot) {
  320. return plotCanvas.addPlot(newPlot);
  321. }
  322. protected Color getNewColor() {
  323. return COLORLIST[plotCanvas.plots.size() % COLORLIST.length];
  324. }
  325. public int addPlot(String type, String name, double[]... v) {
  326. return addPlot(type, name, getNewColor(), v);
  327. }
  328. public abstract int addPlot(String type, String name, Color c, double[]... v);
  329. public void setPlot(int I, Plot p) {
  330. plotCanvas.setPlot(I, p);
  331. }
  332. public void changePlotData(int I, double[]... XY) {
  333. plotCanvas.changePlotData(I, XY);
  334. }
  335. public void changePlotName(int I, String name) {
  336. plotCanvas.changePlotName(I, name);
  337. }
  338. public void changePlotColor(int I, Color c) {
  339. plotCanvas.changePlotColor(I, c);
  340. }
  341. public void removePlot(int I) {
  342. plotCanvas.removePlot(I);
  343. }
  344. public void removePlot(Plot p) {
  345. plotCanvas.removePlot(p);
  346. }
  347. public void removeAllPlots() {
  348. plotCanvas.removeAllPlots();
  349. }
  350. public void addVectortoPlot(int numPlot, double[][] v) {
  351. plotCanvas.addVectortoPlot(numPlot, v);
  352. }
  353. public void addQuantiletoPlot(int numPlot, int numAxe, double rate, boolean symetric, double[] q) {
  354. plotCanvas.addQuantiletoPlot(numPlot, numAxe, rate, symetric, q);
  355. }
  356. public void addQuantiletoPlot(int numPlot, int numAxe, double rate, boolean symetric, double q) {
  357. plotCanvas.addQuantiletoPlot(numPlot, numAxe, rate, symetric, q);
  358. }
  359. public void addQuantilestoPlot(int numPlot, int numAxe, double[][] q) {
  360. plotCanvas.addQuantilestoPlot(numPlot, numAxe, q);
  361. }
  362. public void addQuantilestoPlot(int numPlot, int numAxe, double[] q) {
  363. plotCanvas.addQuantilestoPlot(numPlot, numAxe, q);
  364. }
  365. public void addGaussQuantilestoPlot(int numPlot, int numAxe, double[] s) {
  366. plotCanvas.addGaussQuantilestoPlot(numPlot, numAxe, s);
  367. }
  368. public void addGaussQuantilestoPlot(int numPlot, int numAxe, double s) {
  369. plotCanvas.addGaussQuantilestoPlot(numPlot, numAxe, s);
  370. }
  371. public void toGraphicFile(File file) throws IOException {
  372. // otherwise toolbar appears
  373. plotToolBar.setVisible(false);
  374. Image image = createImage(getWidth(), getHeight());
  375. paint(image.getGraphics());
  376. image = new ImageIcon(image).getImage();
  377. BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB);
  378. Graphics g = bufferedImage.createGraphics();
  379. g.drawImage(image, 0, 0, Color.WHITE, null);
  380. g.dispose();
  381. // make it reappear
  382. plotToolBar.setVisible(true);
  383. try {
  384. ImageIO.write((RenderedImage) bufferedImage, "PNG", file);
  385. } catch (IllegalArgumentException ex) {
  386. }
  387. }
  388. public static void main(String[] args) {
  389. String man = "Usage: jplot.<sh|bat> <-2D|-3D> [-l <INVISIBLE|NORTH|SOUTH|EAST|WEST>] [options] <ASCII file (n rows, m columns)> [[options] other ASCII file]\n" + "[-l <INVISIBLE|NORTH|SOUTH|EAST|WEST>] giving the legend position\n" + "[options] are:\n" + " -t <SCATTER|LINE|BAR|HISTOGRAM2D(<integer h>)|HISTOGRAM3D(<integer h>,<integer k>)|GRID3D|CLOUD2D(<integer h>,<integer k>)|CLOUD3D(<integer h>,<integer k>,<integer l>)> type of the plot\n" + " SCATTER|LINE|BAR: each line of the ASCII file contains coordinates of one point.\n" + " HISTOGRAM2D(<integer h>): ASCII file contains the 1D sample (i.e. m=1) to split in h slices.\n" + " HISTOGRAM3D(<integer h>,<integer k>): ASCII file contains the 2D sample (i.e. m=2) to split in h*k slices (h slices on X axis and k slices on Y axis).\n" + " GRID3D: ASCII file is a matrix, first row gives n X grid values, first column gives m Y grid values, other values are Z values.\n" + " CLOUD2D(<integer h>,<integer k>): ASCII file contains the 2D sample (i.e. m=2) to split in h*k slices (h slices on X axis and k slices on Y axis), density of cloud corresponds to frequency of X-Y slice in given 2D sample.\n" + " CLOUD3D(<integer h>,<integer k>,<integer l>): ASCII file contains the 3D sample (i.e. m=3) to split in h*k*l slices (h slices on X axis, k slices on Y axis, l slices on Y axis), density of cloud corresponds to frequency of X-Y-Z slice in given 3D sample.\n" + " -n name name of the plot\n" + " -v <ASCII file (n,3|2)> vector data to add to the plot\n" + " -q<X|Y|Z>(<float Q>) <ASCII file (n,1)> Q-quantile to add to the plot on <X|Y|Z> axis. Each line of the given ASCII file contains the value of quantile for probvability Q.\n" + " -qP<X|Y|Z> <ASCII file (n,p)> p-quantiles density to add to the plot on <X|Y|Z> axis. Each line of the given ASCII file contains p values.\n" + " -qN<X|Y|Z> <ASCII file (n,1)> Gaussian density to add to the plot on <X|Y|Z> axis. Each line of the given ASCII file contains a standard deviation.";
  390. if (args.length == 0) {
  391. double[][] data = new double[20][];
  392. for (int i = 0; i < data.length; i++) {
  393. data[i] = new double[]{Math.random(), Math.random(), Math.random()};
  394. }
  395. ASCIIFile.writeDoubleArray(new File("tmp.dat"), data);
  396. args = new String[]{"-3D", "-l", "SOUTH", "-t", "SCATTER", "tmp.dat"};
  397. System.out.println(man);
  398. System.out.println("\nExample: jplot.<sh|bat> " + Array.cat(args));
  399. }
  400. PlotPanel p = null;
  401. if (args[0].equals("-2D")) {
  402. p = new Plot2DPanel();
  403. } else if (args[0].equals("-3D")) {
  404. p = new Plot3DPanel();
  405. } else {
  406. System.out.println(man);
  407. }
  408. try {
  409. String leg = "INVISIBLE";
  410. String type = SCATTER;
  411. String name = "";
  412. double[][] v = null;
  413. double[] qX = null;
  414. double[] qY = null;
  415. double[] qZ = null;
  416. double qXp = 0;
  417. double qYp = 0;
  418. double qZp = 0;
  419. double[][] qPX = null;
  420. double[][] qPY = null;
  421. double[][] qPZ = null;
  422. double[] qNX = null;
  423. double[] qNY = null;
  424. double[] qNZ = null;
  425. for (int i = 1; i < args.length; i++) {
  426. //System.out.println("<" + args[i] + ">");
  427. if (args[i].equals("-l")) {
  428. leg = args[i + 1];
  429. i++;
  430. } else if (args[i].equals("-t")) {
  431. type = args[i + 1];
  432. i++;
  433. } else if (args[i].equals("-n")) {
  434. name = args[i + 1];
  435. i++;
  436. } else if (args[i].equals("-v")) {
  437. v = ASCIIFile.readDoubleArray(new File(args[i + 1]));
  438. i++;
  439. } else if (args[i].startsWith("-qX(")) {
  440. qX = ASCIIFile.readDouble1DArray(new File(args[i + 1]));
  441. qXp = Double.parseDouble(args[i].substring(4, args[i].length() - 1));
  442. i++;
  443. } else if (args[i].startsWith("-qY(")) {
  444. qY = ASCIIFile.readDouble1DArray(new File(args[i + 1]));
  445. qYp = Double.parseDouble(args[i].substring(4, args[i].length() - 1));
  446. i++;
  447. } else if (args[i].startsWith("-qZ(")) {
  448. qZ = ASCIIFile.readDouble1DArray(new File(args[i + 1]));
  449. qZp = Double.parseDouble(args[i].substring(4, args[i].length() - 1));
  450. i++;
  451. } else if (args[i].equals("-qPX")) {
  452. qPX = ASCIIFile.readDoubleArray(new File(args[i + 1]));
  453. i++;
  454. } else if (args[i].equals("-qPY")) {
  455. qPY = ASCIIFile.readDoubleArray(new File(args[i + 1]));
  456. i++;
  457. } else if (args[i].equals("-qPZ")) {
  458. qPZ = ASCIIFile.readDoubleArray(new File(args[i + 1]));
  459. i++;
  460. } else if (args[i].equals("-qNX")) {
  461. qNX = ASCIIFile.readDouble1DArray(new File(args[i + 1]));
  462. i++;
  463. } else if (args[i].equals("-qNY")) {
  464. qNY = ASCIIFile.readDouble1DArray(new File(args[i + 1]));
  465. i++;
  466. } else if (args[i].equals("-qNZ")) {
  467. qNZ = ASCIIFile.readDouble1DArray(new File(args[i + 1]));
  468. i++;
  469. } else {
  470. File input_file = new File(args[i]);
  471. int n = 0;
  472. if (input_file.exists()) {
  473. if (name.length() == 0) {
  474. name = input_file.getName();
  475. }
  476. if (p instanceof Plot2DPanel) {
  477. Plot2DPanel p2d = (Plot2DPanel) p;
  478. if (type.equals("SCATTER")) {
  479. n = p2d.addScatterPlot(name, ASCIIFile.readDoubleArray(input_file));
  480. } else if (type.equals("LINE")) {
  481. n = p2d.addLinePlot(name, ASCIIFile.readDoubleArray(input_file));
  482. } else if (type.equals("BAR")) {
  483. n = p2d.addBarPlot(name, ASCIIFile.readDoubleArray(input_file));
  484. } else if (type.startsWith("HISTOGRAM2D(")) {
  485. n = p2d.addHistogramPlot(name, ASCIIFile.readDouble1DArray(input_file), Integer.parseInt(type.substring(12, type.length() - 1)));
  486. } else if (type.startsWith("CLOUD2D(")) {
  487. n = p2d.addCloudPlot(name, ASCIIFile.readDoubleArray(input_file), Integer.parseInt(type.substring(8, type.indexOf(","))),
  488. Integer.parseInt(type.substring(type.indexOf(",") + 1, type.length() - 1)));
  489. } else {
  490. p2d.addPlot(type, name, ASCIIFile.readDoubleArray(input_file));
  491. }
  492. } else {
  493. Plot3DPanel p3d = (Plot3DPanel) p;
  494. if (type.equals("SCATTER")) {
  495. n = p3d.addScatterPlot(name, ASCIIFile.readDoubleArray(input_file));
  496. } else if (type.equals("LINE")) {
  497. n = p3d.addLinePlot(name, ASCIIFile.readDoubleArray(input_file));
  498. } else if (type.equals("BAR")) {
  499. n = p3d.addBarPlot(name, ASCIIFile.readDoubleArray(input_file));
  500. } else if (type.startsWith("HISTOGRAM3D(")) {
  501. n = p3d.addHistogramPlot(name, ASCIIFile.readDoubleArray(input_file), Integer.parseInt(type.substring(12, type.indexOf(","))),
  502. Integer.parseInt(type.substring(type.indexOf(",") + 1, type.length() - 1)));
  503. } else if (type.equals("GRID3D")) {
  504. n = p3d.addGridPlot(name, ASCIIFile.readDoubleArray(input_file));
  505. } else if (type.startsWith("CLOUD3D(")) {
  506. n = p3d.addCloudPlot(name, ASCIIFile.readDoubleArray(input_file), Integer.parseInt(type.substring(8, type.indexOf(","))),
  507. Integer.parseInt(type.substring(type.indexOf(",") + 1, type.indexOf(",", type.indexOf(",") + 1))), Integer.parseInt(type.substring(type.indexOf(",", type.indexOf(",") + 1) + 1, type.length() - 1)));
  508. } else {
  509. p3d.addPlot(type, name, ASCIIFile.readDoubleArray(input_file));
  510. }
  511. }
  512. if (v != null) {
  513. p.addVectortoPlot(n, v);
  514. }
  515. if (qX != null) {
  516. p.addQuantiletoPlot(n, 0, qXp, false, qX);
  517. }
  518. if (qY != null) {
  519. p.addQuantiletoPlot(n, 1, qYp, false, qY);
  520. }
  521. if (qZ != null) {
  522. p.addQuantiletoPlot(n, 2, qZp, false, qZ);
  523. }
  524. if (qPX != null) {
  525. p.addQuantilestoPlot(n, 0, qPX);
  526. }
  527. if (qPY != null) {
  528. p.addQuantilestoPlot(n, 1, qPY);
  529. }
  530. if (qPZ != null) {
  531. p.addQuantilestoPlot(n, 2, qPZ);
  532. }
  533. if (qNX != null) {
  534. p.addGaussQuantilestoPlot(n, 0, qNX);
  535. }
  536. if (qNY != null) {
  537. p.addGaussQuantilestoPlot(n, 1, qNY);
  538. }
  539. if (qNZ != null) {
  540. p.addGaussQuantilestoPlot(n, 2, qNZ);
  541. }
  542. type = "SCATTER";
  543. leg = "SOUTH";
  544. name = "";
  545. qX = null;
  546. qY = null;
  547. qZ = null;
  548. qXp = 0;
  549. qYp = 0;
  550. qZp = 0;
  551. v = null;
  552. qPX = null;
  553. qPY = null;
  554. qPZ = null;
  555. qNX = null;
  556. qNY = null;
  557. qNZ = null;
  558. } else {
  559. System.out.println("File " + args[i] + " unknown.");
  560. System.out.println(man);
  561. }
  562. }
  563. }
  564. p.setLegendOrientation(leg);
  565. FrameView f = new FrameView(p);
  566. f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  567. } catch (Exception e) {
  568. e.printStackTrace();
  569. System.err.println("\n" + man);
  570. }
  571. }
  572. /**
  573. * @return the font
  574. */
  575. public Font getFont() {
  576. return font;
  577. }
  578. /**
  579. * @param font the font to set
  580. */
  581. public void setFont(Font font) {
  582. this.font = font;
  583. }
  584. }