Permalink
Browse files

SighingsDetailsViewUpdates

  • Loading branch information...
1 parent d4325f8 commit 95ab44d69f398cf36c89feaca059282c93ae396d @pjimen5 pjimen5 committed Oct 23, 2011
Showing with 178 additions and 29 deletions.
  1. +6 −8 MapView.pde
  2. +82 −0 ScrollList.pde
  3. +1 −1 SettingsView.pde
  4. +25 −11 SightingDetailsView.pde
  5. +48 −0 VScroll.pde
  6. +16 −9 cs424p3.pde
View
@@ -8,7 +8,7 @@ class MapView extends View {
InteractiveMap mmap;
float zoomValue = 4;
float minZoom = 4;
- float maxZoom = 12;
+ float maxZoom = 15;
int minPointSize= 5;
int maxPointSize = 45;
int minIconSize= 8;
@@ -225,9 +225,6 @@ class MapView extends View {
clickedPlace = place;
}
}
- else if (clickedPlace == place){
- clickedPlace = null;
- }
}
}
@@ -246,6 +243,7 @@ class MapView extends View {
Point2f p = mmap.locationPoint(((Place)(newSighting.location)).loc);
if (dist(mouseX,mouseY,p.x,p.y) < map(zoomValue,minZoom,maxZoom,minPointSize/2,maxPointSize/2)){
textSize(normalFontSize);
+ textAlign(LEFT);
strokeWeight(1);
stroke(((SightingType)newSighting.type).colr);
String textToPrint = dateFormat.format(newSighting.localTime);
@@ -263,12 +261,12 @@ class MapView extends View {
textSize(smallFontSize);
text("Click on it to see details",x_+5,y_+h_-10);
if (mousePressed){
- clickedSighting = newSighting;
+ clickedSighting = newSighting;
}
}
- else if (clickedSighting == newSighting){
- clickedSighting = null;
- }
+ // else if (clickedSighting == newSighting){
+ // clickedSighting = null;
+ // }
}
}
}
View
@@ -0,0 +1,82 @@
+int vSpaceBtwLabels = 5;
+color scrollListColor = #2D2A36;
+color activeScrollListColor = 0;
+color textActiveColor = #FFFF00;
+
+
+class ScrollList extends View {
+ ArrayList labels;
+ int firstIndex = 0;
+ int selectedIndex = 1;
+ int selectedItem = 1;
+ VScroll scroll;
+
+ ScrollList(float x_, float y_, float w_, float h_)
+ {
+ super(x_, y_, w_ , h_);
+ labels=new ArrayList();
+
+ scroll = new VScroll(w-12,0,12,h);
+ this.subviews.add(scroll);
+ scroll.linesXSpace = int(w/(textAscent() + textDescent()+ vSpaceBtwLabels));
+ }
+
+ void add(String _label){
+ labels.add(_label);
+ scroll.linesCount = labels.size();
+ }
+
+ void removeAll(){
+ labels.clear();
+ scroll.linesCount = 0;
+ selectedIndex = 1;
+ scroll.currentLine = 0;
+ }
+
+ void drawContent()
+ {
+ textAlign(LEFT,TOP);
+ textFont(font,normalFontSize);
+ stroke(textColor);
+ fill(scrollListColor);
+ rect(0,0,w,h);
+ textFont(font,normalFontSize);
+ float spaceBtwLabels = textAscent() + textDescent()+ vSpaceBtwLabels;
+ firstIndex = scroll.currentLine;
+ int _value = selectedItem + firstIndex;
+ selectedIndex = (labels.size() >= _value)?constrain(_value,1,labels.size()):constrain(firstIndex,1,labels.size());
+ println("FirstIndex = " + firstIndex);
+ for (int i = 0; i < h/spaceBtwLabels; i++) {
+ float y = spaceBtwLabels*i;
+ if (labels.size()>i+firstIndex){
+ if ((selectedIndex-1)==i+firstIndex){
+ fill(activeScrollListColor);
+ rect(0,y,w-12,textAscent() + textDescent()+ vSpaceBtwLabels);
+ fill(textActiveColor);
+ }
+ else{
+ fill(textColor);
+ }
+ String _str = (String)labels.get(firstIndex+i);
+ // String textToPrint = (textWidth(_str)) > (w-5))?(_str.substring(0,(w-5)/textWidth(" ")-5))+"..":_str;
+ text(_str, x , y+ vSpaceBtwLabels);
+ }
+ }
+ }
+
+ boolean contentPressed(float lx, float ly)
+ {
+ textFont(font,normalFontSize);
+ selectedItem = round(ly / (textAscent() + textDescent()+ vSpaceBtwLabels));
+
+ return true;
+ }
+
+ boolean contentDragged(float lx, float ly)
+ {
+ textFont(font,normalFontSize);
+ selectedItem = round(ly / (textAscent() + textDescent()+ vSpaceBtwLabels));
+ return true;
+ }
+}
+
View
@@ -77,7 +77,7 @@ class SettingsView extends View {
title = "MAP " + ((yearSlider.minIndex()!=yearSlider.maxIndex())?("From: "+yearLabelsToPrint[yearSlider.minIndex()] + " To: " + yearLabelsToPrint[yearSlider.maxIndex()]):("Year: "+yearLabelsToPrint[yearSlider.minIndex()]));
title = title + ((monthCheckbox.value)?((monthSlider.minIndex()!=monthSlider.maxIndex())?(" - " + monthLabelsToPrint[monthSlider.minIndex()] + " to " + monthLabelsToPrint[monthSlider.maxIndex()]):(" - " + monthLabelsToPrint[monthSlider.minIndex()])):(""));
title = title + ((timeCheckbox.value)?((timeSlider.minIndex()!=timeSlider.maxIndex())?(" - " + timeLabels[timeSlider.minIndex()] + ":00 to " + timeLabels[timeSlider.maxIndex()] +":00"):(" - " + timeLabels[timeSlider.minIndex()])+":00"):(""));
- text(title,(width-textWidth(title))/2,h-20);
+ text(title,(w-textWidth(title))/2,h-20);
}
boolean contentPressed(float lx, float ly)
@@ -1,25 +1,39 @@
class SightingDetailsView extends View {
- float heightView ;
boolean showView = false;
- Sighting[] _sighting;
+ List<Sighting> sightings;
Place place;
-
+ ScrollList sightingSList;
+
SightingDetailsView(float x_, float y_, float w_, float h_)
{
super(x_, y_, w_, h_);
+
+ sightingSList = new ScrollList(5,5,200,180);
+ this.subviews.add(sightingSList);
+
+ }
+ void setSightings(List<Sighting> _sightings){
+ sightings = _sightings;
+ sightingSList.removeAll();
+ for (int i = 0;i<sightings.size();i++){
+ sightingSList.add(shortDateFormat.format(sightings.get(i).localTime));
+ }
}
- void drawContent()
- {
- if (showView){
- fill(viewBackgroundColor,220);
- stroke(viewBackgroundColor,220);
- rect(0,0, w, h);
- text(place.name,5,5);
+ void drawContent()
+ {
+ fill(viewBackgroundColor,220);
+ stroke(viewBackgroundColor,220);
+ rect(0,0, w, h);
+ if (place!=null){
+ fill(boldTextColor);
+ text(place.name + " (Total # of Sightings = " + place.sightingCount + ")",(w+230-textWidth(place.name + " (Total # of Sightings = " + place.sightingCount + ")"))/2,5);
+ Sighting newSighting = sightings.get(sightingSList.selectedIndex-1);
+ fill(textColor);
+ text(newSighting.description,230,25, w - 260,80);
}
-
}
}
View
@@ -0,0 +1,48 @@
+
+color vScrollColor = 255;
+color buttonsvScrollColor = 255;
+
+class VScroll extends View {
+ int currentLine;
+ int linesCount;
+ int linesXSpace;
+
+ VScroll(float x_, float y_, float w_, float h_)
+ {
+ super(x_, y_, w_, h_);
+ linesCount = currentLine = 1;
+ }
+
+ void drawContent()
+ {
+ if (linesCount > linesXSpace){
+ noFill();
+ stroke(vScrollColor);
+ line(0, 0,0,h);
+ fill(vScrollColor);
+ float _y = map(currentLine*linesXSpace,0,linesCount,0,linesXSpace);
+ float _h = map(linesXSpace,linesXSpace,linesCount,5,h);
+ rect(0,_y, w, _h);
+ }
+ }
+
+ boolean contentPressed(float lx, float ly)
+ {
+ if (linesCount > linesXSpace){
+
+ currentLine = int(map(ly,0,h,0,linesCount)) +1;
+
+ }
+ return true;
+ }
+
+ boolean contentDragged(float lx, float ly)
+ {
+ if (linesCount > linesXSpace){
+ currentLine = int(map(ly,0,h,0,linesCount))+1 ;
+
+ }
+ return true;
+ }
+}
+
View
@@ -5,15 +5,18 @@ PFont font;
HBar hbar;
HBar hbar2;
Animator settingsAnimator;
+Animator detailsAnimator;
PApplet papplet;
MapView mapv;
SettingsView settingsView;
SightingDetailsView sightingDetailsView;
DateFormat dateFormat= new SimpleDateFormat("EEEE MMMM dd, yyyy HH:mm");
+DateFormat shortDateFormat= new SimpleDateFormat("MM/dd/yyyy HH:mm");
color backgroundColor = 0;
color textColor = 255;
+color boldTextColor = #FFFF00;
color viewBackgroundColor = #2D2A36;
color airportAreaColor = #FFA500;
color infoBoxBackground = #000000;
@@ -74,10 +77,11 @@ void setup()
settingsView = new SettingsView(0,-100,width,125);
rootView.subviews.add(settingsView);
- sightingDetailsView = new SightingDetailsView(0,height-150,width,150);
+ sightingDetailsView = new SightingDetailsView(0,height,width,200);
rootView.subviews.add(sightingDetailsView);
settingsAnimator = new Animator(settingsView.y);
+ detailsAnimator = new Animator(sightingDetailsView.y);
// I want to add true multitouch support, but let's have this as a stopgap for now
addMouseWheelListener(new java.awt.event.MouseWheelListener() {
@@ -93,13 +97,8 @@ void draw()
Animator.updateAll();
settingsView.y = settingsAnimator.value;
-
- sightingDetailsView.place = mapv.clickedPlace;
- if (sightingDetailsView.place==null)
- sightingDetailsView.showView = false;
- else
- sightingDetailsView.showView = true;
-
+ sightingDetailsView.y = detailsAnimator.value;
+
rootView.draw();
}
@@ -116,8 +115,16 @@ void mouseDragged()
void mouseClicked()
{
showAirports = settingsView.showAirport.value;
-
+
+ //if (sightingDetailsView.place==null)
+ // detailsAnimator.target(height);
+ //else {
+ if (sightingDetailsView.place!=mapv.clickedPlace){
+ sightingDetailsView.place = mapv.clickedPlace;
+ sightingDetailsView.setSightings(sightingsForCity(mapv.clickedPlace));
+ detailsAnimator.target(height-200);
+ }
rootView.mouseClicked(mouseX, mouseY);
}

0 comments on commit 95ab44d

Please sign in to comment.