Skip to content
This repository
Browse code

LegendArea

  • Loading branch information...
commit 91f8f03e9b47715c6a6a2ad074e4aead1f8fbdf1 1 parent 05d80ff
pjimen5 authored October 31, 2011
16  GraphView.pde
@@ -100,5 +100,21 @@ class GraphView extends View {
100 100
       }
101 101
       barx += barw;
102 102
     }
  103
+    fill(backgroundColor);
  104
+    stroke(textColor);
  105
+    rect (0,h+5,w,90);
  106
+    fill(textColor);
  107
+    textAlign(LEFT,TOP);
  108
+    float[] activeModeLegend =  data.getLegendLabels(activeMode);
  109
+    if (activeModeLegend != null){
  110
+      text("[1] < " + nfc(activeModeLegend[0],2),10,h+15);
  111
+
  112
+      for (int i = 1; i <  activeModeLegend.length;i++) {
  113
+        int y_delta = (i % 5) * 15;
  114
+        int x_delta = (i / 5) * 300;
  115
+        text("["+(i+1) + "] >= " + nfc(activeModeLegend[i-1],2) + " and < " + nfc(activeModeLegend[i-1],2), 10 + x_delta ,h + 15 + y_delta);
  116
+      }
  117
+      text("["+(activeModeLegend.length+1)+"] > " + nfc(activeModeLegend[activeModeLegend.length-1],2), 10 + ((activeModeLegend.length / 5) * 300),h + 15 + ((activeModeLegend.length % 5) * 15));
  118
+    }
103 119
   }
104 120
 }
12  Sighting.pde
@@ -273,6 +273,7 @@ interface DataSource {
273 273
   List<Bucket> sightingCountsByAirportDistance();
274 274
   List<Bucket> sightingCountsByWeatherStDistance();
275 275
   List<Bucket> sightingCountsByMilitaryBaseDistance();  
  276
+  float[] getLegendLabels(String activeMode);
276 277
 }
277 278
 
278 279
 class Bucket {
@@ -528,7 +529,14 @@ class SQLiteDataSource implements DataSource {
528 529
   float[] airportsDistanceBreaks = {7.794978,12.22485,16.34988,21.02355,26.27319,32.03328,38.54012,45.20428,54.43778,64.34605,76.22255,91.7209,113.2127,152.5769};
529 530
   float[] weatherStDistanceBreaks = {3.417465,5.244248,6.937217,8.564252,10.51355,12.41377,14.63627,16.98696,19.75864,23.02078,26.70035,31.42313,38.6634,50.20286};
530 531
   float[] militaryBaseDistanceBreaks = {12.07392,20.41422,27.86664,36.02675,44.57247,54.70817,67.01115,80.2194,95.13276,111.2619,133.6569,158.7418,192.5056,247.0147};
531  
-                
  532
+           
  533
+  float[] getLegendLabels(String activeMode){
  534
+   if (activeMode.equals("Airport distance")) return airportsDistanceBreaks;
  535
+   else if (activeMode.equals("Military Base dist")) return militaryBaseDistanceBreaks;
  536
+   else if (activeMode.equals("Weather St. dist.")) return weatherStDistanceBreaks;
  537
+   
  538
+   return null;
  539
+  }    
532 540
   List<Bucket> sightingCountsByAirportDistance()
533 541
   {
534 542
     String caseQuery = "when distance < "+airportsDistanceBreaks[0]+" then 1 ";
@@ -574,7 +582,7 @@ class SQLiteDataSource implements DataSource {
574 582
   List<Bucket> sightingCountsByCategoryQuery(String query, String categoryName)
575 583
   {
576 584
     List<Bucket> buckets = new ArrayList();
577  
-    println(query);
  585
+
578 586
     db.query(query);
579 587
     
580 588
     String prev_cat = "NOPE!";
8  cs424p3.pde
@@ -187,6 +187,14 @@ void listClicked(ListBox lb, int index, Object item)
187 187
 {
188 188
   if (lb == graphModeList) {
189 189
     graphView.setActiveMode((String)item);
  190
+    String _item = (String)item;
  191
+    if (!_item.equals("Year") && !_item.equals("Season")  && !_item.equals("Month") && !_item.equals("Time of day")){
  192
+        graphContainer.graphAnimator.target(graphContainer.h-100);
  193
+    }
  194
+    else{
  195
+       graphContainer.graphAnimator.target(graphContainer.h-5);
  196
+    }
  197
+    
190 198
   }
191 199
 }
192 200
 
9  graphContainer.pde
@@ -8,6 +8,8 @@ class GraphContainer extends View {
8 8
   String title;
9 9
   Map<SightingType, Checkbox> typeCheckboxGraph;
10 10
   
  11
+  Animator graphAnimator;
  12
+  
11 13
   GraphContainer(float x_, float y_, float w_, float h_)
12 14
   {
13 15
     super(x_, y_, w_, h_);
@@ -32,7 +34,9 @@ class GraphContainer extends View {
32 34
       subviews.add(cb);
33 35
       typeCheckboxGraph.put(st,cb);
34 36
       i++;
35  
-    } 
  37
+    }
  38
+   
  39
+    graphAnimator = new Animator(graphView.h);  
36 40
   }
37 41
   
38 42
   void updateValuesGraph(){
@@ -71,7 +75,8 @@ class GraphContainer extends View {
71 75
     line(CHECKBOX_X,CHECKBOX_Y,CHECKBOX_X,CHECKBOX_H + CHECKBOX_Y);
72 76
     line(CHECKBOX_X,CHECKBOX_H + CHECKBOX_Y,CHECKBOX_X+CHECKBOX_W,CHECKBOX_H + CHECKBOX_Y);
73 77
     line(CHECKBOX_X+CHECKBOX_W,CHECKBOX_Y,CHECKBOX_X+CHECKBOX_W,CHECKBOX_H + CHECKBOX_Y);
74  
-        
  78
+     
  79
+     graphView.h = graphAnimator.value;      
75 80
   }
76 81
   
77 82
 }

0 notes on commit 91f8f03

Please sign in to comment.
Something went wrong with that request. Please try again.