added the plot of circles to to the radar
[tech-radar.git] / src / models / radar.js
1 tr.models.Radar = function() {
2 var self, quadrants;
3
4 quadrants = { I: null, II: null, III: null, IV: null };
5 self = {};
6
7 self.setFirstQuadrant = function (quadrant) {
8 quadrants.I = quadrant;
9 };
10
11 self.setSecondQuadrant = function (quadrant) {
12 quadrants.II = quadrant;
13 };
14
15 self.setThirdQuadrant = function (quadrant) {
16 quadrants.III = quadrant;
17 };
18
19 self.setFourthQuadrant = function (quadrant) {
20 quadrants.IV = quadrant;
21 };
22
23 function allQuadrants() {
24 var all = [];
25
26 for (var p in quadrants) {
27 if (quadrants.hasOwnProperty(p) && quadrants[p] != null) {
28 all.push(quadrants[p]);
29 }
30 }
31
32 return all;
33 }
34
35 function allBlips() {
36 return allQuadrants().reduce(function (blips, quadrant) {
37 return blips.concat(quadrant.blips());
38 }, []);
39 }
40
41 self.cycles = function () {
42 var cycleHash, cycleArray;
43
44 cycleArray = [];
45 cycleHash = {};
46
47 allBlips().forEach(function (blip) {
48 cycleHash[blip.cycle().name()] = blip.cycle();
49 });
50
51 for (var p in cycleHash) {
52 if (cycleHash.hasOwnProperty(p)) {
53 cycleArray.push(cycleHash[p]);
54 }
55 }
56
57 return cycleArray.slice(0);
58 };
59
60 self.quadrants = function () {
61 return quadrants;
62 };
63
64 return self;
65 };