-
Notifications
You must be signed in to change notification settings - Fork 0
/
GraphicPanelCPM.java
88 lines (78 loc) · 2.7 KB
/
GraphicPanelCPM.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import javax.swing.*;
import java.awt.*;
import java.awt.Color;
import java.awt.Graphics;
class GraphicPanelCPM extends JPanel{
private static final long serialVersionUID = 1L;//REVISAR
int dimension_;
int steps_;
CPMLatticeMio tumor_;
boolean verdad;
Object l;
public GraphicPanelCPM(int newXMax, int newYMax, int newMcs, int newMcSubsteps, int newSigmaMax,double newInitialMatrixDensity,
/*CPMcalculations*/
double jEcm, double jLightCells,double jDarkCells, double jOtherCells, double lambdaArea,
double targetAreaFactorLight, double targetAreaFactorDark, int darkCellDecrease, double temperature,
int ratioDarkToLightCells )
{
super(new BorderLayout());
tumor_ = new CPMLatticeMio(newXMax,newYMax,newMcs,newMcSubsteps,newSigmaMax,newInitialMatrixDensity,
jEcm, jLightCells,jDarkCells, jOtherCells, lambdaArea,targetAreaFactorLight,
targetAreaFactorDark, darkCellDecrease, temperature, ratioDarkToLightCells);
tumor_.initializeLattice();
verdad = true;
}
public void parar(){
verdad=false;
int[] areas = tumor_.getArea();
System.out.println("------------------------------------------FIN--------------------------------------------");
for(int i = 0 ; i<areas.length ; ++i)
System.out.println("Area"+ i +"= "+areas[i]);
}
public void dibujar()
{
int[] areas = tumor_.getArea();
System.out.println("------------------------------------------INICIO--------------------------------------------");
for(int i = 0 ; i<areas.length ; ++i)
System.out.println("Area"+i+"= "+areas[i]);
verdad = true;
Thread updateThread = new Thread(){
public void run(){
while(verdad){
repaint();
/*try{
Thread.sleep(10);
}catch(InterruptedException e){}*/
tumor_.computeCPM();
}
}
};
updateThread.start();
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
for(int y=1; y<tumor_.getYMax();++y)
{
for(int x=1; x<tumor_.getXMax(); ++x)
{
switch(tumor_.sigma[x][y])
{
case 0: g.setColor(Color.white);
break;
case 1: g.setColor(Color.red);
break;
case 2: g.setColor(Color.blue);
break;
case 3: g.setColor(Color.green);
break;
case 4: g.setColor(Color.black);
break;
default:
break;
}
g.fillRect(x,y,1,1);
}
}
}
}