Skip to content

Commit

Permalink
someUpdates-GraphContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
pjimen5 committed Oct 31, 2011
1 parent d11196e commit 7a7d1c8
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 27 deletions.
13 changes: 8 additions & 5 deletions GraphView.pde
Expand Up @@ -11,10 +11,13 @@ class Button extends View {

void drawContent()
{
fill(viewBackgroundColor);
noStroke();
rect(0,0,w,h);
fill(255);
textAlign(LEFT, TOP);
text(label,0,0);

textAlign(CENTER, CENTER);
fill(textColor);
text(label,w/2,h/2);
}

boolean contentClicked(float lx, float ly)
Expand All @@ -32,7 +35,7 @@ class GraphView extends View {
List<Bucket> buckets;
int maxTotal;

List<String> modes = Arrays.asList("Year","Month", "Time of day", "Airport dist.", "Pop. density", "Season");
List<String> modes = Arrays.asList("Year","Month", "Time of day", "Airport distance", "Military Base dist.", "Weather St. dist.","Population density", "Season");
String activeMode = "Year";

GraphView(float x_, float y_, float w_, float h_)
Expand Down Expand Up @@ -72,7 +75,7 @@ class GraphView extends View {

void drawContent()
{
fill(0,0,0,128);
fill(backgroundColor);
rect(0,0,w,h);

float barw = w / buckets.size();
Expand Down
5 changes: 3 additions & 2 deletions PlayButton.pde
Expand Up @@ -15,10 +15,11 @@ class PlayButton extends View {
stroke(0);
rect(0, 0, w, h);
fill((transitionValue==0)?textColor:boldTextColor);
textAlign(CENTER,CENTER);
if (!value)
text ("Play",30,5);
text ("Play",w/2,h/2);
else
text ("Playing...",10,5);
text ("Playing...",w/2,h/2);
}

boolean contentPressed(float lx, float ly)
Expand Down
14 changes: 7 additions & 7 deletions SettingsView.pde
@@ -1,3 +1,7 @@
int CHECKBOX_X = 450;
int CHECKBOX_Y = 10;
int CHECKBOX_W = 300;

class SettingsView extends View {
HSlider yearSlider;
HSlider monthSlider;
Expand All @@ -8,11 +12,7 @@ class SettingsView extends View {
Checkbox showMilitaryBases;
Checkbox showWeatherStation;
PlayButton play;

int CHECKBOX_X = 450;
int CHECKBOX_Y = 10;
int CHECKBOX_W = 300;


boolean showView;
float heightView ;
String title;
Expand Down Expand Up @@ -59,7 +59,7 @@ class SettingsView extends View {
showWeatherStation = new Checkbox(780,50,12,12,"Show weather stations",weatherStationImage,-1);
this.subviews.add(showWeatherStation);

play = new PlayButton(w-105,h-20,100,20);
play = new PlayButton(w-100,h-20,90,20);
this.subviews.add(play);

showView = false;
Expand Down Expand Up @@ -105,7 +105,7 @@ class SettingsView extends View {
boolean contentPressed(float lx, float ly)
{
if(lx > 0 && lx < textWidth("Show Settings")+10 && ly>h-25 && ly < h){
settingsAnimator.target((showView)?(-heightView+25):0);
settingsAnimator.target((showView)?(-heightView+45):20);
showView = !showView;
}
return true;
Expand Down
38 changes: 25 additions & 13 deletions cs424p3.pde
Expand Up @@ -3,15 +3,15 @@ import org.khelekore.prtree.*;
View rootView;

PFont font;

HBar hbar;
HBar hbar2;
Animator settingsAnimator;
Animator detailsAnimator;

PApplet papplet;
MapView mapv;
View graphContainer;
GraphContainer graphContainer;
GraphView graphView;
Button graphButton;
ListBox graphModeList;
Expand Down Expand Up @@ -117,7 +117,7 @@ void setup()
mapv = new MapView(0,0,width,height);
rootView.subviews.add(mapv);

settingsView = new SettingsView(0,-100,width,125);
settingsView = new SettingsView(0,-80,width,125);
rootView.subviews.add(settingsView);

sightingDetailsView = new SightingDetailsView(0,height,width,200);
Expand All @@ -133,24 +133,36 @@ void setup()
}
});

graphContainer = new View(10, 100, width-20, height-120);
graphView = new GraphView(0, 0, graphContainer.w - 120, graphContainer.h);
graphContainer.subviews.add(graphView);
graphModeList = new ListBox(graphContainer.w - 120, 0, 120, 120, graphView.modesDataSource());
graphContainer.subviews.add(graphModeList);
graphContainer = new GraphContainer(0, 20, width, height-20);

graphButton = new Button(width-80, 0, 80, 20, "Graph");
graphButton = new Button(0, 0, width, 20, "Click here to show the Graphs");
rootView.subviews.add(graphButton);
graphOn = false;

}

void buttonClicked(Button button)
{
if (button == graphButton) {
graphOn = !graphOn;
if (graphOn) rootView.subviews.add(graphContainer);
else rootView.subviews.remove(graphContainer);
if (graphOn){
rootView.subviews.add(graphContainer);
button.label = "Click here to show the Map";
graphContainer.addCheckboxes();

}
else{
rootView.subviews.remove(graphContainer);
button.label = "Click here to show the Graphs";
graphContainer.removeCheckboxes();
int i = 0;
for (Entry<SightingType, Checkbox> entry : settingsView.typeCheckboxMap.entrySet()) {
int x_delta = (i / 4) * 160;
int y_delta = (i % 4) * 20;
entry.getValue().x = CHECKBOX_X + x_delta + 10;
entry.getValue().y = CHECKBOX_Y + y_delta + 9;
i++;
}
}
}
}

Expand Down Expand Up @@ -196,7 +208,7 @@ void draw()
sightingDetailsView.y = detailsAnimator.value;

rootView.draw();
// println(seconds);

if (settingsView.play.value){
if (!startedPlaying){
startedPlaying = true;
Expand Down
65 changes: 65 additions & 0 deletions graphContainer.pde
@@ -0,0 +1,65 @@
class GraphContainer extends View {

float CHECKBOX_X ;
float CHECKBOX_Y ;
float CHECKBOX_W ;
float CHECKBOX_H ;

String title;

GraphContainer(float x_, float y_, float w_, float h_)
{
super(x_, y_, w_, h_);
textFont(font,normalFontSize);

graphView = new GraphView(0, 0, w - 160, h-5);
this.subviews.add(graphView);

graphModeList = new ListBox(w - 160, 25, 160, 160, graphView.modesDataSource());
this.subviews.add(graphModeList);

CHECKBOX_X = w - 160;
CHECKBOX_Y = 220;
CHECKBOX_W = 160;
CHECKBOX_H = 150;
}

void addCheckboxes(){
int i = 0;
for (Entry<SightingType, Checkbox> entry : settingsView.typeCheckboxMap.entrySet()) {
int y_delta = (i % 7) * 20;
entry.getValue().x = CHECKBOX_X + 10;
entry.getValue().y = CHECKBOX_Y + y_delta + 9;
subviews.add(entry.getValue());
i++;
}

}

void removeCheckboxes(){
for (Entry<SightingType, Checkbox> entry : settingsView.typeCheckboxMap.entrySet()) {
subviews.remove(entry.getValue());
}
}

void drawContent()
{
textSize(normalFontSize);
fill(viewBackgroundColor);
stroke(viewBackgroundColor);
rect(0,0, w, h);
fill(textColor);
textAlign(LEFT,TOP);
title = " Type of UFO ";
text(title,CHECKBOX_X,CHECKBOX_Y - 5);
stroke(textColor);

line(CHECKBOX_X + textWidth(title)+5,CHECKBOX_Y,CHECKBOX_X+CHECKBOX_W,CHECKBOX_Y);
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);

}

}

0 comments on commit 7a7d1c8

Please sign in to comment.