-
Notifications
You must be signed in to change notification settings - Fork 0
/
Atom.pde
69 lines (65 loc) · 2.26 KB
/
Atom.pde
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
/**
* @author jakemingolla
* @since 1.0
*
* Point of atomicity within the Force Directed Graph scene.
* An Atom is the smallest {@link Node} object that is
* still {@link Renderable} and can interact with {@link
* Force} objects.
*
* @see Node
* @see Force
* @see Renderable
*/
public class Atom extends Node implements Renderable, Gravitational {
/* Double precision radius of the atom. In relation
* to the Node object, this corresponds to each of the
* x, y, and z fields.
*/
private Double radius;
/**
* @author jakemingolla
*
* Default constructor for an instance of an Atom object. Defaults
* can be controlled by the {@link Constants} fields.
*
* @param id The id of the Atom.
* @param weight The weight of the Atom.
* @param x The x position of the Atom.
* @param y The y position of the Atom.
* @param z The z position of the Atom.
*/
Atom(String id, Double weight,
Double x, Double y, Double z) {
super(id,
weight,
x,
y,
z,
Constants.DEFAULT_ATOM_RADIUS,
Constants.DEFAULT_ATOM_RADIUS,
Constants.DEFAULT_ATOM_RADIUS,
Constants.DEFAULT_ATOM_R,
Constants.DEFAULT_ATOM_B,
Constants.DEFAULT_ATOM_G,
Constants.DEFAULT_ATOM_A);
radius = Constants.DEFAULT_ATOM_RADIUS;
}
/**
* @author jakemingolla
*
* Overriden render method that renders an Atom into the scene as a sphere
* with the default RGBA values.
*
* @see Renderable
*/
@Override
public void render() {
pushMatrix();
translate(x.floatValue(), y.floatValue(), z.floatValue());
noStroke();
fill(r.floatValue(), g.floatValue(), b.floatValue(), a.floatValue());
sphere(radius.floatValue());
popMatrix();
}
}