Permalink
Browse files

LegendArea

  • Loading branch information...
1 parent 05d80ff commit 91f8f03e9b47715c6a6a2ad074e4aead1f8fbdf1 @pjimen5 pjimen5 committed Oct 31, 2011
Showing with 41 additions and 4 deletions.
  1. +16 −0 GraphView.pde
  2. +10 −2 Sighting.pde
  3. +8 −0 cs424p3.pde
  4. +7 −2 graphContainer.pde
View
@@ -100,5 +100,21 @@ class GraphView extends View {
}
barx += barw;
}
+ fill(backgroundColor);
+ stroke(textColor);
+ rect (0,h+5,w,90);
+ fill(textColor);
+ textAlign(LEFT,TOP);
+ float[] activeModeLegend = data.getLegendLabels(activeMode);
+ if (activeModeLegend != null){
+ text("[1] < " + nfc(activeModeLegend[0],2),10,h+15);
+
+ for (int i = 1; i < activeModeLegend.length;i++) {
+ int y_delta = (i % 5) * 15;
+ int x_delta = (i / 5) * 300;
+ text("["+(i+1) + "] >= " + nfc(activeModeLegend[i-1],2) + " and < " + nfc(activeModeLegend[i-1],2), 10 + x_delta ,h + 15 + y_delta);
+ }
+ text("["+(activeModeLegend.length+1)+"] > " + nfc(activeModeLegend[activeModeLegend.length-1],2), 10 + ((activeModeLegend.length / 5) * 300),h + 15 + ((activeModeLegend.length % 5) * 15));
+ }
}
}
View
@@ -273,6 +273,7 @@ interface DataSource {
List<Bucket> sightingCountsByAirportDistance();
List<Bucket> sightingCountsByWeatherStDistance();
List<Bucket> sightingCountsByMilitaryBaseDistance();
+ float[] getLegendLabels(String activeMode);
}
class Bucket {
@@ -528,7 +529,14 @@ class SQLiteDataSource implements DataSource {
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};
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};
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};
-
+
+ float[] getLegendLabels(String activeMode){
+ if (activeMode.equals("Airport distance")) return airportsDistanceBreaks;
+ else if (activeMode.equals("Military Base dist")) return militaryBaseDistanceBreaks;
+ else if (activeMode.equals("Weather St. dist.")) return weatherStDistanceBreaks;
+
+ return null;
+ }
List<Bucket> sightingCountsByAirportDistance()
{
String caseQuery = "when distance < "+airportsDistanceBreaks[0]+" then 1 ";
@@ -574,7 +582,7 @@ class SQLiteDataSource implements DataSource {
List<Bucket> sightingCountsByCategoryQuery(String query, String categoryName)
{
List<Bucket> buckets = new ArrayList();
- println(query);
+
db.query(query);
String prev_cat = "NOPE!";
View
@@ -187,6 +187,14 @@ void listClicked(ListBox lb, int index, Object item)
{
if (lb == graphModeList) {
graphView.setActiveMode((String)item);
+ String _item = (String)item;
+ if (!_item.equals("Year") && !_item.equals("Season") && !_item.equals("Month") && !_item.equals("Time of day")){
+ graphContainer.graphAnimator.target(graphContainer.h-100);
+ }
+ else{
+ graphContainer.graphAnimator.target(graphContainer.h-5);
+ }
+
}
}
View
@@ -8,6 +8,8 @@ class GraphContainer extends View {
String title;
Map<SightingType, Checkbox> typeCheckboxGraph;
+ Animator graphAnimator;
+
GraphContainer(float x_, float y_, float w_, float h_)
{
super(x_, y_, w_, h_);
@@ -32,7 +34,9 @@ class GraphContainer extends View {
subviews.add(cb);
typeCheckboxGraph.put(st,cb);
i++;
- }
+ }
+
+ graphAnimator = new Animator(graphView.h);
}
void updateValuesGraph(){
@@ -71,7 +75,8 @@ class GraphContainer extends View {
line(CHECKBOX_X,CHECKBOX_Y,CHECKBOX_X,CHECKBOX_H + CHECKBOX_Y);
line(CHECKBOX_X,CHECKBOX_H + CHECKBOX_Y,CHECKBOX_X+CHECKBOX_W,CHECKBOX_H + CHECKBOX_Y);
line(CHECKBOX_X+CHECKBOX_W,CHECKBOX_Y,CHECKBOX_X+CHECKBOX_W,CHECKBOX_H + CHECKBOX_Y);
-
+
+ graphView.h = graphAnimator.value;
}
}

0 comments on commit 91f8f03

Please sign in to comment.