-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParticle.java
More file actions
150 lines (121 loc) · 2.88 KB
/
Particle.java
File metadata and controls
150 lines (121 loc) · 2.88 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package com.masim.utils;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.util.Random;
/**
* @see DispersionEngine
* @author sabri ghazi
*
*/
public class Particle {
private double x;
private double y;
private double dx;
private double dy;
private double size;
private double life;
private double dlife=0.8;
private PollutantType pollutantType;
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
public double getDx() {
return dx;
}
public void setDx(double dx) {
this.dx = dx;
}
public double getDy() {
return dy;
}
public void setDy(double dy) {
this.dy = dy;
}
public double getSize() {
return size;
}
public void setSize(double size) {
this.size = size;
}
public double getLife() {
return life;
}
public void setLife(double life) {
this.life = life;
}
public double getDlife() {
return dlife;
}
public void setDlife(double dlife) {
this.dlife = dlife;
}
public PollutantType getPollutantType() {
return pollutantType;
}
public void setPollutantType(PollutantType pollutantType) {
this.pollutantType = pollutantType;
}
public boolean update(){
x += dx;
y += dy;
life=life-(DispersionEngine.currentWS);
if((x>DispersionEngine.nWidth)||(y>DispersionEngine.nHeight))
return true;
if((life <= 0))
return true;
else return false;
}
public void render(Graphics g){
Graphics2D g2d = (Graphics2D) g.create();
g2d.setColor(getColor(pollutantType));
g2d.fill(new Ellipse2D.Double(x-(size/2), y-(size/2), size, size));
g2d.dispose();
}
/**
* Which color is used for the pollutant.
* @param PollutantType
* @return Color
*/
private Color getColor(PollutantType p) {
if(p== PollutantType.PM10)
return Color.RED.darker();
else if(p==PollutantType.SOx)
return Color.YELLOW.darker();
else if (p==PollutantType.NOx)
return Color.GREEN.darker();
else if(p==PollutantType.O3)
return Color.MAGENTA.darker();
else if(p==PollutantType.COx)
return Color.blue.darker();
return Color.black;
}
public Particle(double x,
double y,
double dx,
double dy,
double size,
double life,
Color c,
double pdlife,
PollutantType pt){
this.x = x;
this.y = y;
this.dx = dx;
this.dy = dy;
this.size = size;
this.life = life;
this.dlife=pdlife;
this.pollutantType=pt;
}
}