📄 datagenerator.java
字号:
public class DataGenerator implements Runnable {
int imageWidth, imageHeight, color;
DataPacket p;
DataBuffer inputBuffer;
DataGenerator(int imageWidth, int imageHeight, DataBuffer inputBuffer) {
this.imageWidth = imageWidth;
this.imageHeight = imageHeight;
this.inputBuffer = inputBuffer;
}
public void run() {
while (true) {
color = 7; //the highest no. of colors
p = new DataPacket((int) (imageWidth * Math.random()),
(int) (imageHeight * Math.random()), color);
//chooses a pair of random coordinate swith in the image area
inputBuffer.put(p); //put this packet to inputBuffer
try {
Thread.sleep(5);
} catch (InterruptedException e) {
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -