0001: /*
0002: * Created on May 22, 2004
0003: *
0004: */
0005: package test;
0006:
0007: import java.text.NumberFormat;
0008: import java.util.ArrayList;
0009: import java.util.Iterator;
0010: import java.util.List;
0011: import org.jmatlab.linalg.IMatrix;
0012:
0013: import test.plplot.core.plplotjavac;
0014:
0015: /**
0016: * @author Ali
0017: *
0018: */
0019: public class Plotxy extends Thread {
0020:
0021: private IMatrix m;
0022: private IMatrix n;
0023: private IMatrix p;
0024: private String s;
0025: private int type;
0026: private boolean logxy = false;
0027: private boolean logx = false;
0028: private boolean logy = false;
0029: private boolean grid = false;
0030: private int graph = 0;
0031:
0032: private String title = "";
0033: private String xlabel = "";
0034: private String ylabel = "";
0035: private String zlabel = "";
0036:
0037: public void setGrid(boolean grid) {
0038: this .grid = grid;
0039: }
0040:
0041: public void setType(int type) {
0042: this .type = type;
0043: }
0044:
0045: public void setLogx(boolean logx) {
0046: this .logx = logx;
0047: }
0048:
0049: public void setLogxy(boolean logxy) {
0050: this .logxy = logxy;
0051: }
0052:
0053: public void setLogy(boolean logy) {
0054: this .logy = logy;
0055: }
0056:
0057: public void setTitle(String title) {
0058: this .title = title;
0059: }
0060:
0061: public void setXlabel(String xlabel) {
0062: this .xlabel = xlabel;
0063: }
0064:
0065: public void setYlabel(String ylabel) {
0066: this .ylabel = ylabel;
0067: }
0068:
0069: private Plotxy(IMatrix m) {
0070: this .m = m;
0071: type = 1;
0072: }
0073:
0074: private Plotxy(IMatrix m, String s) {
0075: this .m = m;
0076: this .s = s;
0077: type = 1;
0078: }
0079:
0080: private Plotxy(IMatrix m, IMatrix n) {
0081: this .m = m;
0082: this .n = n;
0083: type = 2;
0084: }
0085:
0086: private Plotxy(IMatrix m, IMatrix n, IMatrix p) {
0087: this .m = m;
0088: this .n = n;
0089: this .p = p;
0090: type = 3;
0091: }
0092:
0093: private Plotxy(IMatrix m, IMatrix n, String s) {
0094: this .m = m;
0095: this .n = n;
0096: this .s = s;
0097: this .type = 2;
0098: }
0099:
0100: public void run() {
0101: if (type == 1) {
0102: if (s == null) {
0103: plot(m);
0104: } else {
0105: plot(m, s);
0106: }
0107: } else if (type == 2)
0108: if (s == null) {
0109: plot(m, n);
0110: } else {
0111: plot(m, n, s);
0112: }
0113: else if (type == 3)
0114: plot(m, n, p);
0115: ;
0116: }
0117:
0118: public void plot(IMatrix x, IMatrix y, IMatrix z) {
0119: if (graph == 4) {
0120: plotMesh(m.getRealRow(1), n.getRealRow(1), p
0121: .getRealMatrix());
0122: }
0123: if (graph == 5) {
0124: plot3(m.getRealRow(1), n.getRealRow(1), p.getRealRow(1));
0125: }
0126: }
0127:
0128: public void plot(IMatrix x) {
0129: int rows = x.getRows();
0130: int cols = x.getCols();
0131: boolean isAllReal = x.isAllReal();
0132: boolean isAnyComplex = x.isAnyComplex();
0133: if (rows == 1 && isAllReal) {
0134: double[] v = x.getRealRow(1);
0135: if (graph == 0) {
0136: plotVector(v);
0137: } else if (graph == 1) {
0138: plotBar(v);
0139: } else if (graph == 2) {
0140: plotHist(v);
0141: } else if (graph == 5) {
0142: plot3(v);
0143: }
0144:
0145: } else if (cols == 1 && isAllReal) {
0146: double[] v = x.getRealCol(1);
0147: if (graph == 0) {
0148: plotVector(v);
0149: } else if (graph == 1) {
0150: plotBar(v);
0151: } else if (graph == 2) {
0152: plotHist(v);
0153: }
0154: } else if (rows == 1 && isAnyComplex) {
0155: double[] m = x.getRealRow(1);
0156: double[] n = x.getImagRow(1);
0157: plotVector(m, n);
0158: } else if (cols == 1 && isAnyComplex) {
0159: double[] m = x.getRealCol(1);
0160: double[] n = x.getImagCol(1);
0161: plotVector(m, n);
0162: } else {
0163: if (graph == 4) {
0164: plotMesh(m.getRealMatrix());
0165: } else {
0166: List colList = new ArrayList();
0167: for (int i = 1; i <= cols; i++) {
0168: colList.add(x.getRealCol(i));
0169: }
0170: plotMatrix(colList);
0171: }
0172: }
0173: }
0174:
0175: public static void PLOT(IMatrix x) {
0176: Plotxy p = new Plotxy(x);
0177: p.start();
0178: }
0179:
0180: public static void PLOT(IMatrix x, Boolean grid) {
0181: Plotxy p = new Plotxy(x);
0182: p.setGrid(grid.booleanValue());
0183: p.start();
0184: }
0185:
0186: public static void PLOT(IMatrix x, String title, String xlabel,
0187: String ylabel) {
0188: Plotxy p = new Plotxy(x);
0189: p.setTitle(title);
0190: p.setXlabel(xlabel);
0191: p.setYlabel(ylabel);
0192: p.start();
0193: }
0194:
0195: public static void PLOT(IMatrix x, String title, String xlabel,
0196: String ylabel, Boolean grid) {
0197: Plotxy p = new Plotxy(x);
0198: p.setTitle(title);
0199: p.setXlabel(xlabel);
0200: p.setYlabel(ylabel);
0201: p.setGrid(grid.booleanValue());
0202: p.start();
0203: }
0204:
0205: public static void PLOT(IMatrix x, String s) {
0206: Plotxy p = new Plotxy(x, s);
0207: p.start();
0208: }
0209:
0210: public static void PLOT(IMatrix x, String s, Boolean grid) {
0211: Plotxy p = new Plotxy(x, s);
0212: p.setGrid(grid.booleanValue());
0213: p.start();
0214: }
0215:
0216: public static void PLOT(IMatrix x, String s, String title,
0217: String xlabel, String ylabel) {
0218: Plotxy p = new Plotxy(x, s);
0219: p.setTitle(title);
0220: p.setXlabel(xlabel);
0221: p.setYlabel(ylabel);
0222: p.start();
0223: }
0224:
0225: public static void PLOT(IMatrix x, String s, String title,
0226: String xlabel, String ylabel, Boolean grid) {
0227: Plotxy p = new Plotxy(x, s);
0228: p.setTitle(title);
0229: p.setXlabel(xlabel);
0230: p.setYlabel(ylabel);
0231: p.setGrid(grid.booleanValue());
0232: p.start();
0233: }
0234:
0235: public static void PLOT(IMatrix x, IMatrix y) {
0236: Plotxy p = new Plotxy(x, y);
0237: p.start();
0238: }
0239:
0240: public static void PLOT(IMatrix x, IMatrix y, Boolean grid) {
0241: Plotxy p = new Plotxy(x, y);
0242: p.setGrid(grid.booleanValue());
0243: p.start();
0244: }
0245:
0246: public static void PLOT(IMatrix x, IMatrix y, String title,
0247: String xlabel, String ylabel) {
0248: Plotxy p = new Plotxy(x, y);
0249: p.setTitle(title);
0250: p.setXlabel(xlabel);
0251: p.setYlabel(ylabel);
0252: p.start();
0253: }
0254:
0255: public static void PLOT(IMatrix x, IMatrix y, String title,
0256: String xlabel, String ylabel, Boolean grid) {
0257: Plotxy p = new Plotxy(x, y);
0258: p.setTitle(title);
0259: p.setXlabel(xlabel);
0260: p.setYlabel(ylabel);
0261: p.setGrid(grid.booleanValue());
0262: p.start();
0263: }
0264:
0265: public static void PLOT(IMatrix x, IMatrix y, String s) {
0266: Plotxy p = new Plotxy(x, y, s);
0267: p.start();
0268: }
0269:
0270: public static void PLOT(IMatrix x, IMatrix y, String s, Boolean grid) {
0271: Plotxy p = new Plotxy(x, y, s);
0272: p.setGrid(grid.booleanValue());
0273: p.start();
0274: }
0275:
0276: public static void PLOT(IMatrix x, IMatrix y, String s,
0277: String title, String xlabel, String ylabel) {
0278: Plotxy p = new Plotxy(x, y, s);
0279: p.setTitle(title);
0280: p.setXlabel(xlabel);
0281: p.setYlabel(ylabel);
0282: p.start();
0283: }
0284:
0285: public static void PLOT(IMatrix x, IMatrix y, String s,
0286: String title, String xlabel, String ylabel, Boolean grid) {
0287: Plotxy p = new Plotxy(x, y, s);
0288: p.setTitle(title);
0289: p.setXlabel(xlabel);
0290: p.setYlabel(ylabel);
0291: p.setGrid(grid.booleanValue());
0292: p.start();
0293: }
0294:
0295: public static void LOGLOG(IMatrix x) {
0296: Plotxy p = new Plotxy(x);
0297: p.setLogxy(true);
0298: p.start();
0299: }
0300:
0301: public static void LOGLOG(IMatrix x, Boolean grid) {
0302: Plotxy p = new Plotxy(x);
0303: p.setGrid(grid.booleanValue());
0304: p.setLogxy(true);
0305: p.start();
0306: }
0307:
0308: public static void LOGLOG(IMatrix x, String title, String xlabel,
0309: String ylabel) {
0310: Plotxy p = new Plotxy(x);
0311: p.setTitle(title);
0312: p.setXlabel(xlabel);
0313: p.setYlabel(ylabel);
0314: p.setLogxy(true);
0315: p.start();
0316: }
0317:
0318: public static void LOGLOG(IMatrix x, String title, String xlabel,
0319: String ylabel, Boolean grid) {
0320: Plotxy p = new Plotxy(x);
0321: p.setTitle(title);
0322: p.setXlabel(xlabel);
0323: p.setYlabel(ylabel);
0324: p.setGrid(grid.booleanValue());
0325: p.setLogxy(true);
0326: p.start();
0327: }
0328:
0329: public static void LOGLOG(IMatrix x, String s) {
0330: Plotxy p = new Plotxy(x, s);
0331: p.setLogxy(true);
0332: p.start();
0333: }
0334:
0335: public static void LOGLOG(IMatrix x, String s, Boolean grid) {
0336: Plotxy p = new Plotxy(x, s);
0337: p.setGrid(grid.booleanValue());
0338: p.setLogxy(true);
0339: p.start();
0340: }
0341:
0342: public static void LOGLOG(IMatrix x, String s, String title,
0343: String xlabel, String ylabel) {
0344: Plotxy p = new Plotxy(x, s);
0345: p.setTitle(title);
0346: p.setXlabel(xlabel);
0347: p.setYlabel(ylabel);
0348: p.setLogxy(true);
0349: p.start();
0350: }
0351:
0352: public static void LOGLOG(IMatrix x, String s, String title,
0353: String xlabel, String ylabel, Boolean grid) {
0354: Plotxy p = new Plotxy(x, s);
0355: p.setTitle(title);
0356: p.setXlabel(xlabel);
0357: p.setYlabel(ylabel);
0358: p.setGrid(grid.booleanValue());
0359: p.setLogxy(true);
0360: p.start();
0361: }
0362:
0363: public static void LOGLOG(IMatrix x, IMatrix y) {
0364: Plotxy p = new Plotxy(x, y);
0365: p.setLogxy(true);
0366: p.start();
0367: }
0368:
0369: public static void LOGLOG(IMatrix x, IMatrix y, Boolean grid) {
0370: Plotxy p = new Plotxy(x, y);
0371: p.setGrid(grid.booleanValue());
0372: p.setLogxy(true);
0373: p.start();
0374: }
0375:
0376: public static void LOGLOG(IMatrix x, IMatrix y, String title,
0377: String xlabel, String ylabel) {
0378: Plotxy p = new Plotxy(x, y);
0379: p.setTitle(title);
0380: p.setXlabel(xlabel);
0381: p.setYlabel(ylabel);
0382: p.setLogxy(true);
0383: p.start();
0384: }
0385:
0386: public static void LOGLOG(IMatrix x, IMatrix y, String title,
0387: String xlabel, String ylabel, Boolean grid) {
0388: Plotxy p = new Plotxy(x, y);
0389: p.setTitle(title);
0390: p.setXlabel(xlabel);
0391: p.setYlabel(ylabel);
0392: p.setGrid(grid.booleanValue());
0393: p.setLogxy(true);
0394: p.start();
0395: }
0396:
0397: public static void LOGLOG(IMatrix x, IMatrix y, String s) {
0398: Plotxy p = new Plotxy(x, y, s);
0399: p.setLogxy(true);
0400: p.start();
0401: }
0402:
0403: public static void LOGLOG(IMatrix x, IMatrix y, String s,
0404: Boolean grid) {
0405: Plotxy p = new Plotxy(x, y, s);
0406: p.setGrid(grid.booleanValue());
0407: p.setLogxy(true);
0408: p.start();
0409: }
0410:
0411: public static void LOGLOG(IMatrix x, IMatrix y, String s,
0412: String title, String xlabel, String ylabel) {
0413: Plotxy p = new Plotxy(x, y, s);
0414: p.setTitle(title);
0415: p.setXlabel(xlabel);
0416: p.setYlabel(ylabel);
0417: p.setLogxy(true);
0418: p.start();
0419: }
0420:
0421: public static void LOGLOG(IMatrix x, IMatrix y, String s,
0422: String title, String xlabel, String ylabel, Boolean grid) {
0423: Plotxy p = new Plotxy(x, y, s);
0424: p.setTitle(title);
0425: p.setXlabel(xlabel);
0426: p.setYlabel(ylabel);
0427: p.setGrid(grid.booleanValue());
0428: p.setLogxy(true);
0429: p.start();
0430: }
0431:
0432: public static void SEMILOGX(IMatrix x) {
0433: Plotxy p = new Plotxy(x);
0434: p.setLogx(true);
0435: p.start();
0436: }
0437:
0438: public static void SEMILOGX(IMatrix x, Boolean grid) {
0439: Plotxy p = new Plotxy(x);
0440: p.setGrid(grid.booleanValue());
0441: p.setLogx(true);
0442: p.start();
0443: }
0444:
0445: public static void SEMILOGX(IMatrix x, String title, String xlabel,
0446: String ylabel) {
0447: Plotxy p = new Plotxy(x);
0448: p.setTitle(title);
0449: p.setXlabel(xlabel);
0450: p.setYlabel(ylabel);
0451: p.setLogx(true);
0452: p.start();
0453: }
0454:
0455: public static void SEMILOGX(IMatrix x, String title, String xlabel,
0456: String ylabel, Boolean grid) {
0457: Plotxy p = new Plotxy(x);
0458: p.setTitle(title);
0459: p.setXlabel(xlabel);
0460: p.setYlabel(ylabel);
0461: p.setGrid(grid.booleanValue());
0462: p.setLogx(true);
0463: p.start();
0464: }
0465:
0466: public static void SEMILOGX(IMatrix x, String s) {
0467: Plotxy p = new Plotxy(x, s);
0468: p.setLogx(true);
0469: p.start();
0470: }
0471:
0472: public static void SEMILOGX(IMatrix x, String s, Boolean grid) {
0473: Plotxy p = new Plotxy(x, s);
0474: p.setGrid(grid.booleanValue());
0475: p.setLogx(true);
0476: p.start();
0477: }
0478:
0479: public static void SEMILOGX(IMatrix x, String s, String title,
0480: String xlabel, String ylabel) {
0481: Plotxy p = new Plotxy(x, s);
0482: p.setTitle(title);
0483: p.setXlabel(xlabel);
0484: p.setYlabel(ylabel);
0485: p.setLogx(true);
0486: p.start();
0487: }
0488:
0489: public static void SEMILOGX(IMatrix x, String s, String title,
0490: String xlabel, String ylabel, Boolean grid) {
0491: Plotxy p = new Plotxy(x, s);
0492: p.setTitle(title);
0493: p.setXlabel(xlabel);
0494: p.setYlabel(ylabel);
0495: p.setGrid(grid.booleanValue());
0496: p.setLogx(true);
0497: p.start();
0498: }
0499:
0500: public static void SEMILOGX(IMatrix x, IMatrix y) {
0501: Plotxy p = new Plotxy(x, y);
0502: p.setLogx(true);
0503: p.start();
0504: }
0505:
0506: public static void SEMILOGX(IMatrix x, IMatrix y, Boolean grid) {
0507: Plotxy p = new Plotxy(x, y);
0508: p.setGrid(grid.booleanValue());
0509: p.setLogx(true);
0510: p.start();
0511: }
0512:
0513: public static void SEMILOGX(IMatrix x, IMatrix y, String title,
0514: String xlabel, String ylabel) {
0515: Plotxy p = new Plotxy(x, y);
0516: p.setTitle(title);
0517: p.setXlabel(xlabel);
0518: p.setYlabel(ylabel);
0519: p.setLogx(true);
0520: p.start();
0521: }
0522:
0523: public static void SEMILOGX(IMatrix x, IMatrix y, String title,
0524: String xlabel, String ylabel, Boolean grid) {
0525: Plotxy p = new Plotxy(x, y);
0526: p.setTitle(title);
0527: p.setXlabel(xlabel);
0528: p.setYlabel(ylabel);
0529: p.setGrid(grid.booleanValue());
0530: p.setLogx(true);
0531: p.start();
0532: }
0533:
0534: public static void SEMILOGX(IMatrix x, IMatrix y, String s) {
0535: Plotxy p = new Plotxy(x, y, s);
0536: p.setLogx(true);
0537: p.start();
0538: }
0539:
0540: public static void SEMILOGX(IMatrix x, IMatrix y, String s,
0541: Boolean grid) {
0542: Plotxy p = new Plotxy(x, y, s);
0543: p.setGrid(grid.booleanValue());
0544: p.setLogx(true);
0545: p.start();
0546: }
0547:
0548: public static void SEMILOGX(IMatrix x, IMatrix y, String s,
0549: String title, String xlabel, String ylabel) {
0550: Plotxy p = new Plotxy(x, y, s);
0551: p.setTitle(title);
0552: p.setXlabel(xlabel);
0553: p.setYlabel(ylabel);
0554: p.setLogx(true);
0555: p.start();
0556: }
0557:
0558: public static void SEMILOGX(IMatrix x, IMatrix y, String s,
0559: String title, String xlabel, String ylabel, Boolean grid) {
0560: Plotxy p = new Plotxy(x, y, s);
0561: p.setTitle(title);
0562: p.setXlabel(xlabel);
0563: p.setYlabel(ylabel);
0564: p.setGrid(grid.booleanValue());
0565: p.setLogx(true);
0566: p.start();
0567: }
0568:
0569: public static void SEMILOGY(IMatrix x) {
0570: Plotxy p = new Plotxy(x);
0571: p.setLogy(true);
0572: p.start();
0573: }
0574:
0575: public static void SEMILOGY(IMatrix x, Boolean grid) {
0576: Plotxy p = new Plotxy(x);
0577: p.setGrid(grid.booleanValue());
0578: p.setLogy(true);
0579: p.start();
0580: }
0581:
0582: public static void SEMILOGY(IMatrix x, String title, String xlabel,
0583: String ylabel) {
0584: Plotxy p = new Plotxy(x);
0585: p.setTitle(title);
0586: p.setXlabel(xlabel);
0587: p.setYlabel(ylabel);
0588: p.setLogy(true);
0589: p.start();
0590: }
0591:
0592: public static void SEMILOGY(IMatrix x, String title, String xlabel,
0593: String ylabel, Boolean grid) {
0594: Plotxy p = new Plotxy(x);
0595: p.setTitle(title);
0596: p.setXlabel(xlabel);
0597: p.setYlabel(ylabel);
0598: p.setGrid(grid.booleanValue());
0599: p.setLogy(true);
0600: p.start();
0601: }
0602:
0603: public static void SEMILOGY(IMatrix x, String s) {
0604: Plotxy p = new Plotxy(x, s);
0605: p.setLogy(true);
0606: p.start();
0607: }
0608:
0609: public static void SEMILOGY(IMatrix x, String s, Boolean grid) {
0610: Plotxy p = new Plotxy(x, s);
0611: p.setGrid(grid.booleanValue());
0612: p.setLogy(true);
0613: p.start();
0614: }
0615:
0616: public static void SEMILOGY(IMatrix x, String s, String title,
0617: String xlabel, String ylabel) {
0618: Plotxy p = new Plotxy(x, s);
0619: p.setTitle(title);
0620: p.setXlabel(xlabel);
0621: p.setYlabel(ylabel);
0622: p.setLogy(true);
0623: p.start();
0624: }
0625:
0626: public static void SEMILOGY(IMatrix x, String s, String title,
0627: String xlabel, String ylabel, Boolean grid) {
0628: Plotxy p = new Plotxy(x, s);
0629: p.setTitle(title);
0630: p.setXlabel(xlabel);
0631: p.setYlabel(ylabel);
0632: p.setGrid(grid.booleanValue());
0633: p.setLogy(true);
0634: p.start();
0635: }
0636:
0637: public static void SEMILOGY(IMatrix x, IMatrix y) {
0638: Plotxy p = new Plotxy(x, y);
0639: p.setLogy(true);
0640: p.start();
0641: }
0642:
0643: public static void SEMILOGY(IMatrix x, IMatrix y, Boolean grid) {
0644: Plotxy p = new Plotxy(x, y);
0645: p.setGrid(grid.booleanValue());
0646: p.setLogy(true);
0647: p.start();
0648: }
0649:
0650: public static void SEMILOGY(IMatrix x, IMatrix y, String title,
0651: String xlabel, String ylabel) {
0652: Plotxy p = new Plotxy(x, y);
0653: p.setTitle(title);
0654: p.setXlabel(xlabel);
0655: p.setYlabel(ylabel);
0656: p.setLogy(true);
0657: p.start();
0658: }
0659:
0660: public static void SEMILOGY(IMatrix x, IMatrix y, String title,
0661: String xlabel, String ylabel, Boolean grid) {
0662: Plotxy p = new Plotxy(x, y);
0663: p.setTitle(title);
0664: p.setXlabel(xlabel);
0665: p.setYlabel(ylabel);
0666: p.setGrid(grid.booleanValue());
0667: p.setLogy(true);
0668: p.start();
0669: }
0670:
0671: public static void SEMILOGY(IMatrix x, IMatrix y, String s) {
0672: Plotxy p = new Plotxy(x, y, s);
0673: p.setLogy(true);
0674: p.start();
0675: }
0676:
0677: public static void SEMILOGY(IMatrix x, IMatrix y, String s,
0678: Boolean grid) {
0679: Plotxy p = new Plotxy(x, y, s);
0680: p.setGrid(grid.booleanValue());
0681: p.setLogy(true);
0682: p.start();
0683: }
0684:
0685: public static void SEMILOGY(IMatrix x, IMatrix y, String s,
0686: String title, String xlabel, String ylabel) {
0687: Plotxy p = new Plotxy(x, y, s);
0688: p.setTitle(title);
0689: p.setXlabel(xlabel);
0690: p.setYlabel(ylabel);
0691: p.setLogy(true);
0692: p.start();
0693: }
0694:
0695: public static void SEMILOGY(IMatrix x, IMatrix y, String s,
0696: String title, String xlabel, String ylabel, Boolean grid) {
0697: Plotxy p = new Plotxy(x, y, s);
0698: p.setTitle(title);
0699: p.setXlabel(xlabel);
0700: p.setYlabel(ylabel);
0701: p.setGrid(grid.booleanValue());
0702: p.setLogy(true);
0703: p.start();
0704: }
0705:
0706: public static void BAR(IMatrix x) {
0707: Plotxy p = new Plotxy(x);
0708: p.setGraph(1);
0709: p.start();
0710: }
0711:
0712: public static void BAR(IMatrix x, String title, String xlabel,
0713: String ylabel) {
0714: Plotxy p = new Plotxy(x);
0715: p.setGraph(1);
0716: p.setTitle(title);
0717: p.setXlabel(xlabel);
0718: p.setYlabel(ylabel);
0719: p.start();
0720: }
0721:
0722: public static void HIST(IMatrix x) {
0723: Plotxy p = new Plotxy(x);
0724: p.setGraph(2);
0725: p.start();
0726: }
0727:
0728: public static void HIST(IMatrix x, String title, String xlabel,
0729: String ylabel) {
0730: Plotxy p = new Plotxy(x);
0731: p.setGraph(2);
0732: p.setTitle(title);
0733: p.setXlabel(xlabel);
0734: p.setYlabel(ylabel);
0735: p.start();
0736: }
0737:
0738: public static void POLAR(IMatrix x, IMatrix y) {
0739: Plotxy p = new Plotxy(x, y);
0740: p.type = 2;
0741: p.setGraph(3);
0742: p.start();
0743: }
0744:
0745: public static void POLAR(IMatrix x, IMatrix y, String title,
0746: String xlabel, String ylabel) {
0747: Plotxy p = new Plotxy(x, y);
0748: p.type = 2;
0749: p.setGraph(3);
0750: p.setTitle(title);
0751: p.setXlabel(xlabel);
0752: p.setYlabel(ylabel);
0753: p.start();
0754: }
0755:
0756: public static void MESH(IMatrix x, IMatrix y, IMatrix z) {
0757: Plotxy p = new Plotxy(x, y, z);
0758: p.type = 3;
0759: p.setGraph(4);
0760: p.start();
0761: }
0762:
0763: public static void MESH(IMatrix x, IMatrix y, IMatrix z,
0764: String title, String xlabel, String ylabel, String zlabel) {
0765: Plotxy p = new Plotxy(x, y, z);
0766: p.type = 3;
0767: p.setGraph(4);
0768: p.setTitle(title);
0769: p.setXlabel(xlabel);
0770: p.setYlabel(ylabel);
0771: p.setZlabel(zlabel);
0772: p.start();
0773: }
0774:
0775: public static void MESH(IMatrix x) {
0776: Plotxy p = new Plotxy(x);
0777: p.type = 1;
0778: p.setGraph(4);
0779: p.start();
0780: }
0781:
0782: public static void MESH(IMatrix x, String title, String xlabel,
0783: String ylabel, String zlabel) {
0784: Plotxy p = new Plotxy(x);
0785: p.type = 1;
0786: p.setGraph(4);
0787: p.setTitle(title);
0788: p.setXlabel(xlabel);
0789: p.setYlabel(ylabel);
0790: p.setZlabel(zlabel);
0791: p.start();
0792: }
0793:
0794: public static void PLOT3(IMatrix x, IMatrix y, IMatrix z,
0795: String title, String xlabel, String ylabel, String zlabel) {
0796: Plotxy p = new Plotxy(x, y, z);
0797: p.type = 3;
0798: p.setGraph(5);
0799: p.setTitle(title);
0800: p.setXlabel(xlabel);
0801: p.setYlabel(ylabel);
0802: p.setZlabel(zlabel);
0803: p.start();
0804: }
0805:
0806: public static void PLOT3(IMatrix x, IMatrix y, IMatrix z) {
0807: Plotxy p = new Plotxy(x, y, z);
0808: p.type = 3;
0809: p.setGraph(5);
0810: p.start();
0811: }
0812:
0813: public static void PLOT3(IMatrix x, String title, String xlabel,
0814: String ylabel, String zlabel) {
0815: Plotxy p = new Plotxy(x);
0816: p.type = 1;
0817: p.setGraph(5);
0818: p.setTitle(title);
0819: p.setXlabel(xlabel);
0820: p.setYlabel(ylabel);
0821: p.setZlabel(zlabel);
0822: p.start();
0823: }
0824:
0825: public static void PLOT3(IMatrix x) {
0826: Plotxy p = new Plotxy(x);
0827: p.type = 1;
0828: p.setGraph(5);
0829: p.start();
0830: }
0831:
0832: public void plot(IMatrix x, IMatrix y) {
0833: double[] m = null;
0834: double[] n = null;
0835: if (x.getCols() == 1) {
0836: m = x.getRealCol(1);
0837: } else {
0838: m = x.getRealRow(1);
0839: }
0840: if (y.getCols() == 1) {
0841: n = y.getRealCol(1);
0842: } else {
0843: n = y.getRealRow(1);
0844: }
0845: if (graph == 3) {
0846: plotPolar(m, n);
0847: } else {
0848: plotVector(m, n);
0849: }
0850: }
0851:
0852: public void plot(IMatrix x, String s) {
0853: int rows = x.getRows();
0854: int cols = x.getCols();
0855: boolean isAllReal = x.isAllReal();
0856: boolean isAnyComplex = x.isAnyComplex();
0857: if (rows == 1 && isAllReal) {
0858: double[] v = x.getRealRow(1);
0859: plotVector(v, s);
0860: } else if (cols == 1 && isAllReal) {
0861: double[] v = x.getRealCol(1);
0862: plotVector(v, s);
0863: } else if (rows == 1 && isAnyComplex) {
0864: double[] m = x.getRealRow(1);
0865: double[] n = x.getImagRow(1);
0866: plotVector(m, n, s);
0867: } else if (cols == 1 && isAnyComplex) {
0868: double[] m = x.getRealCol(1);
0869: double[] n = x.getImagCol(1);
0870: plotVector(m, n, s);
0871: } else {
0872: List colList = new ArrayList();
0873: for (int i = 1; i <= cols; i++) {
0874: colList.add(x.getRealCol(i));
0875: }
0876: plotMatrix(colList, s);
0877: }
0878: }
0879:
0880: public void plot(IMatrix x, IMatrix y, String s) {
0881: double[] m = null;
0882: double[] n = null;
0883: if (x.getCols() == 1) {
0884: m = x.getRealCol(1);
0885: } else {
0886: m = x.getRealRow(1);
0887: }
0888: if (y.getCols() == 1) {
0889: n = y.getRealCol(1);
0890: } else {
0891: n = y.getRealRow(1);
0892: }
0893: plotVector(m, n, s);
0894: }
0895:
0896: private static double min(double[] x) {
0897: double rtn = x[0];
0898: for (int i = 0; i < x.length; i++) {
0899: if (x[i] < rtn) {
0900: rtn = x[i];
0901: }
0902: }
0903: return rtn;
0904: }
0905:
0906: private static double max(double[] x) {
0907: double rtn = x[0];
0908: for (int i = 0; i < x.length; i++) {
0909: if (x[i] > rtn) {
0910: rtn = x[i];
0911: }
0912: }
0913: return rtn;
0914: }
0915:
0916: private static double absmax(double[] x) {
0917: double rtn = Math.abs(x[0]);
0918: for (int i = 0; i < x.length; i++) {
0919: double temp = Math.abs(x[i]);
0920: if (temp > rtn) {
0921: rtn = temp;
0922: }
0923: }
0924: return rtn;
0925: }
0926:
0927: private static double min(double[][] x) {
0928: double rtn = x[0][0];
0929: int rows = x.length;
0930: int cols = x[0].length;
0931: for (int i = 0; i < rows; i++) {
0932: for (int j = 0; j < cols; j++) {
0933: if (x[i][j] < rtn) {
0934: rtn = x[i][j];
0935: }
0936: }
0937: }
0938: return rtn;
0939: }
0940:
0941: private static double max(double[][] x) {
0942: double rtn = x[0][0];
0943: int rows = x.length;
0944: int cols = x[0].length;
0945: for (int i = 0; i < rows; i++) {
0946: for (int j = 0; j < cols; j++) {
0947: if (x[i][j] > rtn) {
0948: rtn = x[i][j];
0949: }
0950: }
0951: }
0952: return rtn;
0953: }
0954:
0955: public static double[] domainVector(int n) {
0956: double[] rtn = new double[n];
0957: for (int i = 0; i < n; i++) {
0958: rtn[i] = i + 1;
0959: }
0960: return rtn;
0961: }
0962:
0963: private static double[] log10(double[] x) {
0964: int size = x.length;
0965: double[] rtn = new double[size];
0966: for (int i = 0; i < size; i++) {
0967: rtn[i] = Math.log(x[i]) / Math.log(10);
0968: }
0969: return rtn;
0970: }
0971:
0972: private void plotVector(double[] m) {
0973: int n = m.length;
0974: double xmin = 1;
0975: double xmax = n;
0976: double ymin = min(m);
0977: double ymax = max(m);
0978: double x[] = domainVector(n);
0979: plplotjavac.plsdev("win3");
0980: plplotjavac.plinit();
0981: int axis = 0;
0982: if (grid) {
0983: axis = 2;
0984: }
0985: if (logxy) {
0986: if (grid) {
0987: axis = 33;
0988: } else {
0989: axis = 30;
0990: }
0991: }
0992: if (logx) {
0993: if (grid) {
0994: axis = 13;
0995: } else {
0996: axis = 10;
0997: }
0998: }
0999: if (logy) {
1000: if (grid) {
1001: axis = 23;
1002: } else {
1003: axis = 20;
1004: }
1005: }
1006: if (logx) {
1007: xmin = (Math.log(xmin) / Math.log(10));
1008: xmax = (Math.log(xmax) / Math.log(10));
1009: x = log10(x);
1010: }
1011: if (logy) {
1012: ymin = (Math.log(ymin) / Math.log(10));
1013: ymax = (Math.log(ymax) / Math.log(10));
1014: m = log10(m);
1015: }
1016: if (logxy) {
1017: xmin = (Math.log(xmin) / Math.log(10));
1018: xmax = (Math.log(xmax) / Math.log(10));
1019: ymin = (Math.log(ymin) / Math.log(10));
1020: ymax = (Math.log(ymax) / Math.log(10));
1021: x = log10(x);
1022: m = log10(m);
1023: }
1024: plplotjavac.plcol0(1);
1025: plplotjavac.plenv(xmin, xmax, ymin, ymax, 0, axis);
1026: plplotjavac.plcol0(2);
1027: plplotjavac.plline(x, m);
1028: plplotjavac.plcol0(3);
1029: plplotjavac.pllab(xlabel, ylabel, title);
1030: plplotjavac.plend1();
1031: }
1032:
1033: private void plotMatrix(List l) {
1034: // PlplotInit.init();
1035: plplotjavac.plsdev("win3");
1036: plplotjavac.plinit();
1037: double[] temp = (double[]) l.get(0);
1038: int n = temp.length;
1039: double xmin = 1;
1040: double xmax = n;
1041: double x[] = domainVector(n);
1042: Iterator iter = l.iterator();
1043: double ymin = Double.MAX_VALUE;
1044: double ymax = Double.MIN_VALUE;
1045: while (iter.hasNext()) {
1046: double[] m = (double[]) iter.next();
1047: double min = min(m);
1048: if (min < ymin) {
1049: ymin = min;
1050: }
1051: double max = max(m);
1052: if (max > ymax) {
1053: ymax = max;
1054: }
1055: }
1056: int axis = 0;
1057: if (grid) {
1058: axis = 2;
1059: }
1060: if (logxy) {
1061: if (grid) {
1062: axis = 33;
1063: } else {
1064: axis = 30;
1065: }
1066: }
1067: if (logx) {
1068: if (grid) {
1069: axis = 13;
1070: } else {
1071: axis = 10;
1072: }
1073: }
1074: if (logy) {
1075: if (grid) {
1076: axis = 23;
1077: } else {
1078: axis = 20;
1079: }
1080: }
1081: if (logx) {
1082: xmin = (Math.log(xmin) / Math.log(10));
1083: xmax = (Math.log(xmax) / Math.log(10));
1084: }
1085: if (logy) {
1086: ymin = (Math.log(ymin) / Math.log(10));
1087: ymax = (Math.log(ymax) / Math.log(10));
1088: }
1089: if (logxy) {
1090: xmin = (Math.log(xmin) / Math.log(10));
1091: xmax = (Math.log(xmax) / Math.log(10));
1092: ymin = (Math.log(ymin) / Math.log(10));
1093: ymax = (Math.log(ymax) / Math.log(10));
1094: }
1095: plplotjavac.plenv(xmin, xmax, ymin, ymax, 0, axis);
1096: iter = l.iterator();
1097: int color = 1;
1098: while (iter.hasNext()) {
1099: double[] m = (double[]) iter.next();
1100: plplotjavac.plcol0(color++);
1101: if (logx)
1102: x = log10(x);
1103: if (logy)
1104: m = log10(m);
1105: if (logxy) {
1106: x = log10(x);
1107: m = log10(m);
1108: }
1109: plplotjavac.plline(x, m);
1110: }
1111: plplotjavac.pllab(xlabel, ylabel, title);
1112: plplotjavac.plend1();
1113: }
1114:
1115: private void plotMatrix(List l, String s) {
1116: // PlplotInit.init();
1117: plplotjavac.plsdev("win3");
1118: plplotjavac.plinit();
1119: double[] temp = (double[]) l.get(0);
1120: int n = temp.length;
1121: double xmin = 1;
1122: double xmax = n;
1123: double x[] = domainVector(n);
1124: Iterator iter = l.iterator();
1125: double ymin = Double.MAX_VALUE;
1126: double ymax = Double.MIN_VALUE;
1127: while (iter.hasNext()) {
1128: double[] m = (double[]) iter.next();
1129: double min = min(m);
1130: if (min < ymin) {
1131: ymin = min;
1132: }
1133: double max = max(m);
1134: if (max > ymax) {
1135: ymax = max;
1136: }
1137: }
1138: int axis = 0;
1139: if (grid) {
1140: axis = 2;
1141: }
1142: if (logxy) {
1143: if (grid) {
1144: axis = 33;
1145: } else {
1146: axis = 30;
1147: }
1148: }
1149: if (logx) {
1150: if (grid) {
1151: axis = 13;
1152: } else {
1153: axis = 10;
1154: }
1155: }
1156: if (logy) {
1157: if (grid) {
1158: axis = 23;
1159: } else {
1160: axis = 20;
1161: }
1162: }
1163: if (logx) {
1164: xmin = (Math.log(xmin) / Math.log(10));
1165: xmax = (Math.log(xmax) / Math.log(10));
1166: }
1167: if (logy) {
1168: ymin = (Math.log(ymin) / Math.log(10));
1169: ymax = (Math.log(ymax) / Math.log(10));
1170: }
1171: if (logxy) {
1172: xmin = (Math.log(xmin) / Math.log(10));
1173: xmax = (Math.log(xmax) / Math.log(10));
1174: ymin = (Math.log(ymin) / Math.log(10));
1175: ymax = (Math.log(ymax) / Math.log(10));
1176: }
1177: plplotjavac.plenv(xmin, xmax, ymin, ymax, 0, axis);
1178: iter = l.iterator();
1179: int color = 1;
1180: while (iter.hasNext()) {
1181: double[] m = (double[]) iter.next();
1182: plplotjavac.plcol0(color++);
1183: if (logx)
1184: x = log10(x);
1185: if (logy)
1186: m = log10(m);
1187: if (logxy) {
1188: x = log10(x);
1189: m = log10(m);
1190: }
1191: plplotjavac.plpoin(x, m, s.charAt(0));
1192: }
1193: plplotjavac.pllab(xlabel, ylabel, title);
1194: plplotjavac.plend1();
1195: }
1196:
1197: private void plotVector(double[] m, double[] n) {
1198: double xmin = min(m);
1199: double xmax = max(m);
1200: double ymin = min(n);
1201: double ymax = max(n);
1202: plplotjavac.plsdev("win3");
1203: try {
1204: plplotjavac.plinit();
1205: } catch (Exception e) {
1206: System.out.println("Error initializing.");
1207: }
1208: int axis = 0;
1209: if (grid) {
1210: axis = 2;
1211: }
1212: if (logxy) {
1213: if (grid) {
1214: axis = 33;
1215: } else {
1216: axis = 30;
1217: }
1218: }
1219: if (logx) {
1220: if (grid) {
1221: axis = 13;
1222: } else {
1223: axis = 10;
1224: }
1225: m = log10(m);
1226: }
1227: if (logy) {
1228: if (grid) {
1229: axis = 23;
1230: } else {
1231: axis = 20;
1232: }
1233: n = log10(n);
1234: }
1235: if (logx) {
1236: xmin = (Math.log(xmin) / Math.log(10));
1237: xmax = (Math.log(xmax) / Math.log(10));
1238: m = log10(m);
1239: }
1240: if (logy) {
1241: ymin = (Math.log(ymin) / Math.log(10));
1242: ymax = (Math.log(ymax) / Math.log(10));
1243: n = log10(n);
1244: }
1245: if (logxy) {
1246: xmin = (Math.log(xmin) / Math.log(10));
1247: xmax = (Math.log(xmax) / Math.log(10));
1248: ymin = (Math.log(ymin) / Math.log(10));
1249: ymax = (Math.log(ymax) / Math.log(10));
1250: m = log10(m);
1251: n = log10(n);
1252: }
1253: plplotjavac.plenv(xmin, xmax, ymin, ymax, 0, axis);
1254: plplotjavac.plline(m, n);
1255: plplotjavac.pllab(xlabel, ylabel, title);
1256: plplotjavac.plend1();
1257: }
1258:
1259: private void plotVector(double[] m, String s) {
1260: int n = m.length;
1261: double xmin = 1;
1262: double xmax = n;
1263: double ymin = min(m);
1264: double ymax = max(m);
1265: double x[] = domainVector(n);
1266: // PlplotInit.init();
1267: plplotjavac.plsdev("win3");
1268: plplotjavac.plinit();
1269: int axis = 0;
1270: if (grid) {
1271: axis = 2;
1272: }
1273: if (logxy) {
1274: if (grid) {
1275: axis = 33;
1276: } else {
1277: axis = 30;
1278: }
1279: }
1280: if (logx) {
1281: if (grid) {
1282: axis = 13;
1283: } else {
1284: axis = 10;
1285: }
1286: }
1287: if (logy) {
1288: if (grid) {
1289: axis = 23;
1290: } else {
1291: axis = 20;
1292: }
1293: }
1294: if (logx) {
1295: xmin = (Math.log(xmin) / Math.log(10));
1296: xmax = (Math.log(xmax) / Math.log(10));
1297: x = log10(x);
1298: }
1299: if (logy) {
1300: ymin = (Math.log(ymin) / Math.log(10));
1301: ymax = (Math.log(ymax) / Math.log(10));
1302: m = log10(m);
1303: }
1304: if (logxy) {
1305: xmin = (Math.log(xmin) / Math.log(10));
1306: xmax = (Math.log(xmax) / Math.log(10));
1307: ymin = (Math.log(ymin) / Math.log(10));
1308: ymax = (Math.log(ymax) / Math.log(10));
1309: x = log10(x);
1310: m = log10(m);
1311: }
1312: plplotjavac.plenv(xmin, xmax, ymin, ymax, 0, axis);
1313: plplotjavac.plpoin(x, m, (int) s.charAt(0));
1314: plplotjavac.pllab(xlabel, ylabel, title);
1315: plplotjavac.plend1();
1316: }
1317:
1318: private void plotVector(double[] m, double[] n, String s) {
1319: double xmin = min(m);
1320: double xmax = max(m);
1321: double ymin = min(n);
1322: double ymax = max(n);
1323: // PlplotInit.init();
1324: plplotjavac.plsdev("win3");
1325: plplotjavac.plinit();
1326: int axis = 0;
1327: if (grid) {
1328: axis = 2;
1329: }
1330: if (logxy) {
1331: if (grid) {
1332: axis = 33;
1333: } else {
1334: axis = 30;
1335: }
1336: }
1337: if (logx) {
1338: if (grid) {
1339: axis = 13;
1340: } else {
1341: axis = 10;
1342: }
1343: }
1344: if (logy) {
1345: if (grid) {
1346: axis = 23;
1347: } else {
1348: axis = 20;
1349: }
1350: }
1351: if (logx) {
1352: xmin = (Math.log(xmin) / Math.log(10));
1353: xmax = (Math.log(xmax) / Math.log(10));
1354: m = log10(m);
1355: }
1356: if (logy) {
1357: ymin = (Math.log(ymin) / Math.log(10));
1358: ymax = (Math.log(ymax) / Math.log(10));
1359: n = log10(n);
1360: }
1361: if (logxy) {
1362: xmin = (Math.log(xmin) / Math.log(10));
1363: xmax = (Math.log(xmax) / Math.log(10));
1364: ymin = (Math.log(ymin) / Math.log(10));
1365: ymax = (Math.log(ymax) / Math.log(10));
1366: m = log10(m);
1367: n = log10(n);
1368: }
1369: plplotjavac.plenv(xmin, xmax, ymin, ymax, 0, axis);
1370: plplotjavac.plpoin(m, n, (int) s.charAt(0));
1371: plplotjavac.pllab(xlabel, ylabel, title);
1372: plplotjavac.plend1();
1373: }
1374:
1375: private void plotBar(double[] m) {
1376: int n = m.length;
1377: double xmin = 1;
1378: double xmax = n;
1379: double ymin = min(m);
1380: double ymax = max(m);
1381: double x[] = domainVector(n);
1382: // PlplotInit.init();
1383: plplotjavac.plsdev("win3");
1384: plplotjavac.plinit();
1385: plplotjavac.pladv(0);
1386: plplotjavac.plvsta();
1387: plplotjavac.plenv(xmin, xmax, ymin, ymax, 0, 0);
1388: plplotjavac.plwind(xmin, xmax, ymin, ymax);
1389: plplotjavac.plbox("bc", 1.0, 0, "bcnv", 10.0, 0);
1390: for (int i = 0; i < n; i++) {
1391: plplotjavac.plcol0(i + 1);
1392: plplotjavac.plpsty(0);
1393: plfbox(i, m[i]);
1394: // plplotjavac.plmtex("b", 1.0, ((i + 1) * .1 - .05), 0.5, ""+(i+1));
1395: }
1396: plplotjavac.pllab(xlabel, ylabel, title);
1397: plplotjavac.plend1();
1398: }
1399:
1400: private void plfbox(double x0, double y0) {
1401: double[] x = new double[4];
1402: double[] y = new double[4];
1403:
1404: x[0] = x0;
1405: y[0] = 0.;
1406: x[1] = x0;
1407: y[1] = y0;
1408: x[2] = x0 + 1.;
1409: y[2] = y0;
1410: x[3] = x0 + 1.;
1411: y[3] = 0.;
1412: plplotjavac.plfill(x, y);
1413: plplotjavac.plcol0(1);
1414: plplotjavac.pllsty(1);
1415: plplotjavac.plline(x, y);
1416: }
1417:
1418: private void plotHist(double[] m) {
1419: int n = m.length;
1420: double xmin = 1;
1421: double xmax = n;
1422: double ymin = min(m);
1423: double ymax = max(m);
1424: double x[] = domainVector(n);
1425: // PlplotInit.init();
1426: plplotjavac.plsdev("win3");
1427: plplotjavac.plinit();
1428: plplotjavac.plcol0(1);
1429: plplotjavac.plhist(m, ymin, ymax, 10, 0);
1430: plplotjavac.pllab(xlabel, ylabel, title);
1431: plplotjavac.plend1();
1432: }
1433:
1434: private void plotMesh(double[][] z) {
1435: int m = z.length;
1436: int n = z[0].length;
1437: double[] x = domainVector(m);
1438: double[] y = domainVector(n);
1439: plotMesh(x, y, z);
1440: }
1441:
1442: private void plotMesh(double[] x, double[] y, double[][] z) {
1443: int levels = 10;
1444: double zmin = min(z);
1445: double zmax = max(z);
1446: double xmin = min(x);
1447: double xmax = max(x);
1448: double ymin = min(y);
1449: double ymax = max(y);
1450: double xbase = (xmax - xmin) / 2.0;
1451: double ybase = (ymax - ymin) / 2.0;
1452: double height = zmax - zmin;
1453: double step = (height) / (levels + 1);
1454: double clevel[] = new double[levels];
1455: for (int i = 0; i < levels; i++)
1456: clevel[i] = zmin + step + step * i;
1457: double alt[] = { 33.0, 17.0 };
1458: double az[] = { 24.0, 115.0 };
1459: int opt[] = { 3, 3 };
1460:
1461: int len = z.length;
1462: int width = z[0].length;
1463: // PlplotInit.init();
1464: plplotjavac.plsdev("win3");
1465: plplotjavac.plinit();
1466:
1467: cmap1_init();
1468: plplotjavac.pladv(0);
1469: plplotjavac.plcol0(1);
1470:
1471: plplotjavac.plvpor(0.0, 1.0, 0.0, 0.9);
1472: plplotjavac.plwind(-2.5, 2.5, -2.5, 4.0);
1473: plplotjavac.plw3d(2.0, 4.0, 3.0, xmin, xmax, ymin, ymax, zmin,
1474: zmax, alt[0], az[0]);
1475: plplotjavac.plbox3("bnstu", xlabel, 0.0, 0, "bnstu", ylabel,
1476: 0.0, 0, "bcdmnstuv", zlabel, 0.0, 4);
1477:
1478: plplotjavac.plcol0(2);
1479: plplotjavac.plmesh(x, y, z, opt[0]);
1480: plplotjavac.plcol0(3);
1481: plplotjavac.plmtex("t", 1.0, 0.5, 0.5, title);
1482:
1483: plplotjavac.plend1();
1484: }
1485:
1486: public void plot3(double[] x, double[] y, double[] z) {
1487: double alt[] = { 33.0, 17.0 };
1488: double az[] = { 24.0, 115.0 };
1489: double zmin = min(z);
1490: double zmax = max(z);
1491: double xmin = min(x);
1492: double xmax = max(x);
1493: double ymin = min(y);
1494: double ymax = max(y);
1495: // PlplotInit.init();
1496: plplotjavac.plsdev("win3");
1497: plplotjavac.plinit();
1498:
1499: plplotjavac.pladv(0);
1500: plplotjavac.plvpor(0.0, 1.0, 0.0, 0.9);
1501: plplotjavac.plwind(-2.5, 2.5, -2.5, 4.0);
1502: plplotjavac.plcol0(1);
1503: plplotjavac.plw3d(2.0, 4.0, 3.0, xmin, xmax, ymin, ymax, zmin,
1504: zmax, alt[0], az[0]);
1505: plplotjavac.plbox3("bnstu", xlabel, 0.0, 0, "bnstu", ylabel,
1506: 0.0, 0, "bcdmnstuv", zlabel, 0.0, 4);
1507: plplotjavac.plcol0(2);
1508: plplotjavac.plline3(x, y, z);
1509: plplotjavac.plcol0(3);
1510: plplotjavac.plmtex("t", 1.0, 0.5, 0.5, title);
1511:
1512: plplotjavac.plend1();
1513: }
1514:
1515: public void plot3(double[] z) {
1516: int n = z.length;
1517: double[] x = domainVector(n);
1518: double[] y = domainVector(n);
1519: plot3(x, y, z);
1520: }
1521:
1522: private void plotPolar(double[] m, double[] n) {
1523: int len = m.length;
1524: double dtr, theta, dx, dy, r;
1525: NumberFormat nf = NumberFormat.getNumberInstance();
1526: double[] x0 = new double[361];
1527: double[] y0 = new double[361];
1528: double[] x = new double[361];
1529: double[] y = new double[361];
1530: double[] mx = new double[len];
1531: double[] my = new double[len];
1532:
1533: dtr = Math.PI / 180.0;
1534: double dev = absmax(n);
1535: for (int i = 0; i < m.length; i++) {
1536: mx[i] = n[i] * Math.cos(m[i]) / dev;
1537: my[i] = n[i] * Math.sin(m[i]) / dev;
1538: }
1539: for (int i = 0; i <= 360; i++) {
1540: x0[i] = Math.cos(dtr * i);
1541: y0[i] = Math.sin(dtr * i);
1542: }
1543:
1544: // PlplotInit.init();
1545: plplotjavac.plsdev("win3");
1546: plplotjavac.plinit();
1547:
1548: plplotjavac.plenv(-1.3, 1.3, -1.3, 1.3, 1, -2);
1549: for (int i = 1; i <= 10; i++) {
1550: for (int j = 0; j <= 360; j++) {
1551: x[j] = 0.1 * i * x0[j];
1552: y[j] = 0.1 * i * y0[j];
1553: }
1554:
1555: plplotjavac.plline(x, y);
1556: }
1557:
1558: plplotjavac.plcol0(2);
1559: for (int i = 0; i <= 11; i++) {
1560: theta = 30.0 * i;
1561: dx = Math.cos(dtr * theta);
1562: dy = Math.sin(dtr * theta);
1563:
1564: // Draw radial spokes for polar grid.
1565:
1566: plplotjavac.pljoin(0.0, 0.0, dx, dy);
1567: String text = nf.format(theta);
1568:
1569: // Write labels for angle.
1570:
1571: //Slightly off zero to avoid floating point logic flips at 90 and 270 deg.
1572: if (dx >= -0.00001)
1573: plplotjavac.plptex(dx, dy, dx, dy, -0.15, text);
1574: else
1575: plplotjavac.plptex(dx, dy, -dx, -dy, 1.15, text);
1576: }
1577:
1578: // Draw the graph.
1579:
1580: plplotjavac.plcol0(3);
1581: plplotjavac.plline(mx, my);
1582: plplotjavac.pllab(xlabel, ylabel, title);
1583:
1584: plplotjavac.plend1();
1585: }
1586:
1587: void cmap1_init() {
1588: double[] i = new double[2];
1589: double[] h = new double[2];
1590: double[] l = new double[2];
1591: double[] s = new double[2];
1592: int[] rev = new int[2];
1593:
1594: i[0] = 0.0; // left boundary
1595: i[1] = 1.0; // right boundary
1596:
1597: h[0] = 240; /* blue -> green -> yellow -> */
1598: h[1] = 0; /* -> red */
1599:
1600: l[0] = 0.6;
1601: l[1] = 0.6;
1602:
1603: s[0] = 0.8;
1604: s[1] = 0.8;
1605:
1606: rev[0] = 0; // interpolate on front side of colour wheel.
1607: rev[1] = 0; // interpolate on front side of colour wheel.
1608:
1609: plplotjavac.plscmap1n(256);
1610: plplotjavac.plscmap1l(0, i, h, l, s, rev);
1611: }
1612:
1613: // private void plotCompass(double[] x, double[] y) {
1614: // double xmin = min(x);
1615: // double xmax = max(x);
1616: // double ymin = min(y);
1617: // double ymax = max(y);
1618: // PlplotInit.init();
1619: // plplotjavac.plenv(xmin, xmax, ymin, ymax, 0, 0);
1620: // plplotjavac.pllab(xlabel, ylabel, title);
1621: // plplotjavac.plcol0(2);
1622: // plplotjavac.plv``;
1623: // plplotjavac.plcol0(1);
1624: // plplotjavac.plend1();
1625: //
1626: // }
1627:
1628: /**
1629: * @param graph The graph to set.
1630: */
1631: public void setGraph(int graph) {
1632: this .graph = graph;
1633: }
1634:
1635: /**
1636: * @return Returns the zlabel.
1637: */
1638: public String getZlabel() {
1639: return zlabel;
1640: }
1641:
1642: /**
1643: * @param zlabel The zlabel to set.
1644: */
1645: public void setZlabel(String zlabel) {
1646: this.zlabel = zlabel;
1647: }
1648: }
|