?? plotarray.java~2~
字號:
package java2d;
public class plotArray implements Runnable {
Thread thread;
static float pts[];
static float lastdata;
int LT = 500;
int ptNum;
String inputtime;
public plotArray() {
pts = new float[LT];
lastdata = 0;
}
public int getptNum() {
return ptNum;
}
public void inputdata() {
if (Java2Demo.datapool != null) {
lastdata = Java2Demo.datapool.getdataF("Z3", "high_frequency_table");
inputtime = Java2Demo.datapool.getdataT("high_frequency_table").
substring(11, 19);
//disptime=samptime.substring(11,19);
if (pts == null) {
//pts=new int[graphW];
pts = new float[LT];
ptNum = 0;
} else if (pts.length != LT) {
float tmp[] = null;
if (ptNum < LT) {
tmp = new float[ptNum];
System.arraycopy(pts, 0, tmp, 0, tmp.length);
} else {
tmp = new float[LT];
System.arraycopy(pts, pts.length - tmp.length, tmp, 0,
tmp.length);
ptNum = tmp.length - 2;
}
pts = new float[LT];
System.arraycopy(tmp, 0, pts, 0, tmp.length);
} else {
pts[ptNum] = lastdata;
if (ptNum + 1 == pts.length) {
//throw out the oldest data
for (int j = 1; j < ptNum; j++) {
pts[j - 1] = pts[j];
}
--ptNum;
} else {
ptNum++;
}
}
}
}
public void run() {
Thread me = Thread.currentThread();
while (thread == me) {
System.out.println("plotArray is running");
inputdata();
try {
Thread.sleep(500);
} catch (InterruptedException e) {
return;
}
}
thread = null;
}
public void start() {
if (thread == null) {
thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.setName("plotArray");
thread.start();
}
}
public synchronized void stop() {
if (thread != null) {
thread.interrupt();
}
thread = null;
notifyAll();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -