📄 gaacanvas.java
字号:
import java.awt.*;
import java.applet.*;
class GaaCanvas extends Canvas
{
GaaProblem problem;
GaaPopulation pop;
GaaFunction function;
Graphics Gra;
Color color;
boolean first;
boolean reset;
public GaaCanvas(GaaProblem pr, GaaPopulation pl, GaaFunction fn) {
super();
pop = pl;
problem = pr;
function = fn;
setBackground(Color.white);
setForeground(Color.black);
color = Color.red;
first = true;
reset = false;
}
public void clear() {
reset = true;
repaint();
}
public void paint(Graphics g) {
int i;
if (reset) {
g.setColor(Color.white);
g.fillRect(0,0,size().width,size().height);
reset = false;
return;
}
function.draw(g,pop.chroms[0],size());
}
public void update(Graphics g) {
if (function.drawMode == 1) {
g.setColor(getBackground());
g.fillRect(0,0,size().width,size().height);
g.setColor(getForeground());
}
paint(g);
}
Graphics getGra() {
return this.getGraphics();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -