001: /*
002: * Created on Nov 3, 2004
003: *
004: */
005: package test;
006:
007: import java.util.Stack;
008: import java.util.Vector;
009:
010: import test.org.jmatlab.graphics.plot.PlplotInit;
011: import test.plplot.core.PLStream;
012:
013: /**
014: * @author Ali
015: *
016: */
017: public abstract class AbstractPLPlot extends Thread {
018:
019: protected PLStream pls;
020: protected static int strm = 0;
021: protected static Vector input = new Vector();
022: protected static String xlabel = "";
023: protected static String ylabel = "";
024: protected static String zlabel = "";
025: protected static String tlabel = "";
026: protected static boolean grid = false;
027: protected double[] axis = new double[4];
028: protected static Stack lastThread = new Stack();
029:
030: static {
031: PlplotInit.init();
032: }
033:
034: public AbstractPLPlot() {
035: pls = new PLStream();
036: strm = pls.getstrm();
037: }
038:
039: protected PLStream getPLStream() {
040: return pls;
041: }
042:
043: public void run() {
044: pls.sdev("win3");
045: pls.init();
046: exec();
047: pls.lab(xlabel, ylabel, tlabel);
048: pls.end();
049: }
050:
051: abstract protected void exec();
052:
053: protected static double min(double[] x) {
054: double rtn = x[0];
055: for (int i = 0; i < x.length; i++) {
056: if (x[i] < rtn) {
057: rtn = x[i];
058: }
059: }
060: return rtn;
061: }
062:
063: protected static double max(double[] x) {
064: double rtn = x[0];
065: for (int i = 0; i < x.length; i++) {
066: if (x[i] > rtn) {
067: rtn = x[i];
068: }
069: }
070: return rtn;
071: }
072:
073: protected static double absmax(double[] x) {
074: double rtn = Math.abs(x[0]);
075: for (int i = 0; i < x.length; i++) {
076: double temp = Math.abs(x[i]);
077: if (temp > rtn) {
078: rtn = temp;
079: }
080: }
081: return rtn;
082: }
083:
084: protected static double min(double[][] x) {
085: double rtn = x[0][0];
086: int rows = x.length;
087: int cols = x[0].length;
088: for (int i = 0; i < rows; i++) {
089: for (int j = 0; j < cols; j++) {
090: if (x[i][j] < rtn) {
091: rtn = x[i][j];
092: }
093: }
094: }
095: return rtn;
096: }
097:
098: protected static double max(double[][] x) {
099: double rtn = x[0][0];
100: int rows = x.length;
101: int cols = x[0].length;
102: for (int i = 0; i < rows; i++) {
103: for (int j = 0; j < cols; j++) {
104: if (x[i][j] > rtn) {
105: rtn = x[i][j];
106: }
107: }
108: }
109: return rtn;
110: }
111:
112: protected static double[] domainVector(int n) {
113: double[] rtn = new double[n];
114: for (int i = 0; i < n; i++) {
115: rtn[i] = i + 1;
116: }
117: return rtn;
118: }
119:
120: protected static void reset() {
121: xlabel = "";
122: ylabel = "";
123: zlabel = "";
124: }
125:
126: }
|