Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 297 lines (243 sloc) 8.643 kB
24fbd23 @camillol only draw places in area that needs to be drawn
authored
1 import org.khelekore.prtree.*;
2
6e95208 @camillol initial commit with base project and utils
authored
3 View rootView;
4
7d0b99c @pjimen5 SettingsView+Icons
pjimen5 authored
5 PFont font;
339171a @pjimen5 InformationBoxByState
pjimen5 authored
6 PFont font2;
7a7d1c8 @pjimen5 someUpdates-GraphContainer
pjimen5 authored
7
59ed714 @camillol test wit hbars and animator
authored
8 HBar hbar;
9 HBar hbar2;
8dfec76 @pjimen5 Animation-SettingsView
pjimen5 authored
10 Animator settingsAnimator;
95ab44d @pjimen5 SighingsDetailsViewUpdates
pjimen5 authored
11 Animator detailsAnimator;
59ed714 @camillol test wit hbars and animator
authored
12
3675745 @camillol added MapView
authored
13 PApplet papplet;
14 MapView mapv;
7a7d1c8 @pjimen5 someUpdates-GraphContainer
pjimen5 authored
15 GraphContainer graphContainer;
8fc81fe @camillol added graph view
authored
16 GraphView graphView;
a55c5d8 @camillol toggle graph
authored
17 Button graphButton;
e677d17 @camillol graph mode selector
authored
18 ListBox graphModeList;
a55c5d8 @camillol toggle graph
authored
19 boolean graphOn;
7d0b99c @pjimen5 SettingsView+Icons
pjimen5 authored
20 SettingsView settingsView;
e9fc876 @pjimen5 AddedDetailViewForSightings
pjimen5 authored
21 SightingDetailsView sightingDetailsView;
f5d2c73 @pjimen5 FewUpdatesIntheInterface
pjimen5 authored
22
b77cea0 @pjimen5 CallUpdateCitiesWhenSettingsChange
pjimen5 authored
23 DateFormat dateTimeFormat= new SimpleDateFormat("EEEE, MMMM dd, yyyy HH:mm");
24 DateFormat dateFormat= new SimpleDateFormat("EEEE, MMMM dd, yyyy");
95ab44d @pjimen5 SighingsDetailsViewUpdates
pjimen5 authored
25 DateFormat shortDateFormat= new SimpleDateFormat("MM/dd/yyyy HH:mm");
dc00403 @camillol much faster filtering of sightings
authored
26 DateFormat dbDateFormat= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
7d0b99c @pjimen5 SettingsView+Icons
pjimen5 authored
27
28 color backgroundColor = 0;
29 color textColor = 255;
95ab44d @pjimen5 SighingsDetailsViewUpdates
pjimen5 authored
30 color boldTextColor = #FFFF00;
5925b0c @pjimen5 PopulationDensity&Legend
pjimen5 authored
31 color titleTextColor = 0;
7d0b99c @pjimen5 SettingsView+Icons
pjimen5 authored
32 color viewBackgroundColor = #2D2A36;
33 color airportAreaColor = #FFA500;
d8ca394 @pjimen5 DrawingMilitaryBases
pjimen5 authored
34 color militaryBaseColor = #CC0000;
1b99571 @pjimen5 DrawingWeatherStations
pjimen5 authored
35 color weatherStationColor = #FFFF00;
d46044f @pjimen5 UFOInfoBox+LimitMapZoom
pjimen5 authored
36 color infoBoxBackground = #000000;
0882c8e @pjimen5 ColorsFixedOnApp
pjimen5 authored
37 //color[] UFOColors = {#FFFF00,#00FF00,#00FFFF,#FF8000,#800FFF,#FF0000,};
38 color[] UFOColors = {#0000FF,#FF6600,#00FFFF,#FF0000,#FFFF00,#00FF00,#800FFF};
7d0b99c @pjimen5 SettingsView+Icons
pjimen5 authored
39
40 int normalFontSize = 13;
a4a5056 @pjimen5 ChangeFont
pjimen5 authored
41 int smallFontSize = 10 ;
2e33fd5 @pjimen5 animationWithTimer
pjimen5 authored
42 int largeFontSize = 15;
dc00403 @camillol much faster filtering of sightings
authored
43
7d0b99c @pjimen5 SettingsView+Icons
pjimen5 authored
44 String[] monthLabelsToPrint = {"January","February","March","April","May","June","July","August","September","October","November","December"};
45 String[] monthLabels = {"01","02","03","04","05","06","07","08","09","10","11","12"};
46 String[] yearLabels = {"'00","'01","'02","'03","'04","'05","'06","'07","'08","'09","'10","'11"};
47 String[] yearLabelsToPrint = {"2000","2001","2002","2003","2004","2005","2006","2007","2008","2009","2010","2011"};
48 String[] timeLabels = {"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23"};
f051126 @pjimen5 DrawingSightings+SizeIconsAccordingZoom
pjimen5 authored
49 String[] UFOTypeLabels = {"UFOType 1","UFOType 2","UFOType 3","UFOType 4","UFOType 5","UFOType 6","UFOType 7"};
d46044f @pjimen5 UFOInfoBox+LimitMapZoom
pjimen5 authored
50 String[] UFOImages = {"blue.png","green.png","star.png","orange.png","purple.png","red.png","yellow.png"};
7d0b99c @pjimen5 SettingsView+Icons
pjimen5 authored
51
0882c8e @pjimen5 ColorsFixedOnApp
pjimen5 authored
52
7d0b99c @pjimen5 SettingsView+Icons
pjimen5 authored
53 PImage airplaneImage;
d8ca394 @pjimen5 DrawingMilitaryBases
pjimen5 authored
54 PImage militaryBaseImage;
1b99571 @pjimen5 DrawingWeatherStations
pjimen5 authored
55 PImage weatherStationImage;
3675745 @camillol added MapView
authored
56
460d688 @camillol added WebDataSource for applet, all that's missing is the actual web …
authored
57 Map<Integer,SightingType> sightingTypeMap = new LinkedHashMap<Integer, SightingType>();
58 Map<Integer,State> stateMap = new HashMap<Integer,State>();
59 Map<Integer,Place> cityMap = new HashMap<Integer,Place>();
60 Map<Integer,Place> airportMap = new HashMap<Integer,Place>();
61 Map<Integer,Place> militaryBaseMap = new HashMap<Integer,Place>();
62 Map<Integer,Place> weatherStationMap = new HashMap<Integer,Place>();
706cecd @pjimen5 Map+Tree updates
pjimen5 authored
63 PRTree<Place> cityTree;
64 PRTree<Place> airportTree;
65 PRTree<Place> militaryBaseTree;
66 PRTree<Place> weatherStationTree;
2b08cce @pjimen5 TypeOfUFO-ContainerGraphView
pjimen5 authored
67
68 Map<SightingType, Checkbox> typeCheckboxMap;
f719530 @camillol sighting types in database
authored
69
e9fc876 @pjimen5 AddedDetailViewForSightings
pjimen5 authored
70 Sighting clickedSighting;
d46044f @pjimen5 UFOInfoBox+LimitMapZoom
pjimen5 authored
71 Boolean showAirports=false;
d8ca394 @pjimen5 DrawingMilitaryBases
pjimen5 authored
72 Boolean showMilitaryBases = false;
1b99571 @pjimen5 DrawingWeatherStations
pjimen5 authored
73 Boolean showWeatherStation = false;
05d80ff @camillol initialize checkboxes with correct values
authored
74 Boolean showByStates = true;
b77cea0 @pjimen5 CallUpdateCitiesWhenSettingsChange
pjimen5 authored
75 Boolean btwMonths = false;
76 Boolean btwTime = false;
10e05a6 @pjimen5 lastupdates
pjimen5 authored
77 String byType = "";
b77cea0 @pjimen5 CallUpdateCitiesWhenSettingsChange
pjimen5 authored
78 Boolean isDragging = false;
d46044f @pjimen5 UFOInfoBox+LimitMapZoom
pjimen5 authored
79
8196f9c @pjimen5 PlayButton+SightingAnimation
pjimen5 authored
80
dc00403 @camillol much faster filtering of sightings
authored
81 SightingsFilter activeFilter;
82
2202254 @camillol isolated DB access layer
authored
83 DataSource data;
0c3a8e7 @camillol fast play
authored
84 boolean playing = false;
85 Player player;
a675529 @camillol simplified data loading
authored
86
6e95208 @camillol initial commit with base project and utils
authored
87 void setup()
88 {
13b3f4e Worked on script
Eugene authored
89 size(1000, 700); // OPENGL seems to be slower than the default
24fbd23 @camillol only draw places in area that needs to be drawn
authored
90 // setupG2D();
6e95208 @camillol initial commit with base project and utils
authored
91
3675745 @camillol added MapView
authored
92 papplet = this;
93
6e95208 @camillol initial commit with base project and utils
authored
94 smooth();
3532db6 @pjimen5 fewChanges
pjimen5 authored
95
a675529 @camillol simplified data loading
authored
96 /* load data */
2c14f07 @camillol web service client
authored
97 if (sketchPath == null) // applet
4152f49 @camillol fixed access to new web service
authored
98 data = new WebDataSource("http://young-mountain-2805.heroku.com/"); //dataPath("jsontest")
2c14f07 @camillol web service client
authored
99 else // application
100 data = new SQLiteDataSource();
65386f6 @camillol solved SQLite slowness problem
authored
101
2202254 @camillol isolated DB access layer
authored
102 data.loadSightingTypes();
c36fe9b @camillol try drawing all types
authored
103 activeFilter = new SightingsFilter();
e5384ed @camillol clustering by state
authored
104 data.loadStates();
2202254 @camillol isolated DB access layer
authored
105 data.loadCities();
106 data.loadAirports();
107 data.loadMilitaryBases();
108 data.loadWeatherStations();
109 data.reloadCitySightingCounts();
8cb1727 @pjimen5 HighlightedPlaces-NearAirport-MilitaryBase-WeatherStation
pjimen5 authored
110 data.loadCityDistances();
e5384ed @camillol clustering by state
authored
111 updateStateSightingCounts();
1102fa4 @camillol created dummy data provider
authored
112
e677d17 @camillol graph mode selector
authored
113 buildPlaceTree();
114
a675529 @camillol simplified data loading
authored
115 /* setup UI */
6e95208 @camillol initial commit with base project and utils
authored
116 rootView = new View(0, 0, width, height);
5925b0c @pjimen5 PopulationDensity&Legend
pjimen5 authored
117 font = loadFont("Helvetica-20.vlw");
339171a @pjimen5 InformationBoxByState
pjimen5 authored
118 font2 = loadFont("Courier-20.vlw");
7d0b99c @pjimen5 SettingsView+Icons
pjimen5 authored
119
120 airplaneImage = loadImage("plane.png");
b477acd @pjimen5 IconsUpdates
pjimen5 authored
121 militaryBaseImage = loadImage("militars.png");
122 weatherStationImage = loadImage("irkickflash2.png");
a4f7136 @camillol added example view HBar
authored
123
7d0b99c @pjimen5 SettingsView+Icons
pjimen5 authored
124 mapv = new MapView(0,0,width,height);
3675745 @camillol added MapView
authored
125 rootView.subviews.add(mapv);
7d0b99c @pjimen5 SettingsView+Icons
pjimen5 authored
126
7a7d1c8 @pjimen5 someUpdates-GraphContainer
pjimen5 authored
127 settingsView = new SettingsView(0,-80,width,125);
7d0b99c @pjimen5 SettingsView+Icons
pjimen5 authored
128 rootView.subviews.add(settingsView);
e9fc876 @pjimen5 AddedDetailViewForSightings
pjimen5 authored
129
95ab44d @pjimen5 SighingsDetailsViewUpdates
pjimen5 authored
130 sightingDetailsView = new SightingDetailsView(0,height,width,200);
e9fc876 @pjimen5 AddedDetailViewForSightings
pjimen5 authored
131 rootView.subviews.add(sightingDetailsView);
7d0b99c @pjimen5 SettingsView+Icons
pjimen5 authored
132
8dfec76 @pjimen5 Animation-SettingsView
pjimen5 authored
133 settingsAnimator = new Animator(settingsView.y);
95ab44d @pjimen5 SighingsDetailsViewUpdates
pjimen5 authored
134 detailsAnimator = new Animator(sightingDetailsView.y);
ff69b0a @camillol added mouse wheel support to map
authored
135
136 // I want to add true multitouch support, but let's have this as a stopgap for now
137 addMouseWheelListener(new java.awt.event.MouseWheelListener() {
138 public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) {
139 rootView.mouseWheel(mouseX, mouseY, evt.getWheelRotation());
140 }
141 });
8fc81fe @camillol added graph view
authored
142
7a7d1c8 @pjimen5 someUpdates-GraphContainer
pjimen5 authored
143 graphContainer = new GraphContainer(0, 20, width, height-20);
a55c5d8 @camillol toggle graph
authored
144
7a7d1c8 @pjimen5 someUpdates-GraphContainer
pjimen5 authored
145 graphButton = new Button(0, 0, width, 20, "Click here to show the Graphs");
a55c5d8 @camillol toggle graph
authored
146 rootView.subviews.add(graphButton);
147 graphOn = false;
148 }
149
150 void buttonClicked(Button button)
151 {
152 if (button == graphButton) {
153 graphOn = !graphOn;
7a7d1c8 @pjimen5 someUpdates-GraphContainer
pjimen5 authored
154 if (graphOn){
155 rootView.subviews.add(graphContainer);
156 button.label = "Click here to show the Map";
2b08cce @pjimen5 TypeOfUFO-ContainerGraphView
pjimen5 authored
157 graphContainer.updateValuesGraph();
7a7d1c8 @pjimen5 someUpdates-GraphContainer
pjimen5 authored
158
159 }
160 else{
161 rootView.subviews.remove(graphContainer);
162 button.label = "Click here to show the Graphs";
163 }
a55c5d8 @camillol toggle graph
authored
164 }
6e95208 @camillol initial commit with base project and utils
authored
165 }
166
87f6f27 @camillol select types for graph
authored
167 void buttonClicked(Checkbox button)
168 {
2b08cce @pjimen5 TypeOfUFO-ContainerGraphView
pjimen5 authored
169 if (graphOn)
170 graphContainer.updateValuesMap();
171
172 for (Entry<SightingType, Checkbox> entry : typeCheckboxMap.entrySet()) {
87f6f27 @camillol select types for graph
authored
173 entry.getKey().setActive(entry.getValue().value);
174 }
175 btwTime = settingsView.timeCheckbox.value;
176 btwMonths = settingsView.monthCheckbox.value;
177
178 updateFilter();
2e33fd5 @pjimen5 animationWithTimer
pjimen5 authored
179
05d80ff @camillol initialize checkboxes with correct values
authored
180 if (showAirports != settingsView.showAirportCB.value || showMilitaryBases != settingsView.showMilitaryBasesCB.value
181 || showWeatherStation != settingsView.showWeatherStationCB.value || showByStates != settingsView.showByStatesCB.value){
182 showAirports = settingsView.showAirportCB.value;
183 showMilitaryBases = settingsView.showMilitaryBasesCB.value;
184 showWeatherStation = settingsView.showWeatherStationCB.value;
185 showByStates = settingsView.showByStatesCB.value;
2e33fd5 @pjimen5 animationWithTimer
pjimen5 authored
186 mapv.rebuildOverlay();
187 }
8cb1727 @pjimen5 HighlightedPlaces-NearAirport-MilitaryBase-WeatherStation
pjimen5 authored
188
189 if (showByStates)
190 detailsAnimator.target(height);
87f6f27 @camillol select types for graph
authored
191 }
192
e677d17 @camillol graph mode selector
authored
193 void listClicked(ListBox lb, int index, Object item)
194 {
195 if (lb == graphModeList) {
e88e4fb @camillol graph by hour
authored
196 graphView.setActiveMode((String)item);
91f8f03 @pjimen5 LegendArea
pjimen5 authored
197 String _item = (String)item;
198 if (!_item.equals("Year") && !_item.equals("Season") && !_item.equals("Month") && !_item.equals("Time of day")){
5925b0c @pjimen5 PopulationDensity&Legend
pjimen5 authored
199 graphContainer.graphAnimator.target(graphContainer.h-120);
91f8f03 @pjimen5 LegendArea
pjimen5 authored
200 }
201 else{
202 graphContainer.graphAnimator.target(graphContainer.h-5);
203 }
204
e677d17 @camillol graph mode selector
authored
205 }
206 }
207
0c3a8e7 @camillol fast play
authored
208 void startPlaying()
209 {
210 playing = true;
211 player = new Player();
b6baeb6 @camillol play controls with progress bar
authored
212 settingsView.playBarAnimator.target(100);
213 }
214
215 void stopPlaying()
216 {
217 playing = false;
218 player = null;
219 settingsView.playBarAnimator.target(0);
0c3a8e7 @camillol fast play
authored
220 }
221
6e95208 @camillol initial commit with base project and utils
authored
222 void draw()
223 {
7d0b99c @pjimen5 SettingsView+Icons
pjimen5 authored
224 background(backgroundColor);
6e95208 @camillol initial commit with base project and utils
authored
225 Animator.updateAll();
226
8dfec76 @pjimen5 Animation-SettingsView
pjimen5 authored
227 settingsView.y = settingsAnimator.value;
95ab44d @pjimen5 SighingsDetailsViewUpdates
pjimen5 authored
228 sightingDetailsView.y = detailsAnimator.value;
b6baeb6 @camillol play controls with progress bar
authored
229 settingsView.playBar.w = settingsView.playBarAnimator.value;
0c3a8e7 @camillol fast play
authored
230
231 rootView.draw();
6e95208 @camillol initial commit with base project and utils
authored
232 }
233
234 void mousePressed()
235 {
236 rootView.mousePressed(mouseX, mouseY);
237 }
238
239 void mouseDragged()
240 {
b77cea0 @pjimen5 CallUpdateCitiesWhenSettingsChange
pjimen5 authored
241 isDragging = true;
6e95208 @camillol initial commit with base project and utils
authored
242 rootView.mouseDragged(mouseX, mouseY);
243 }
244
245 void mouseClicked()
87f6f27 @camillol select types for graph
authored
246 {
6e95208 @camillol initial commit with base project and utils
authored
247 rootView.mouseClicked(mouseX, mouseY);
248 }
249
f062acc @camillol fixed filtering by type
authored
250 /* returns true if filter changed */
251 boolean updateFilter()
dc00403 @camillol much faster filtering of sightings
authored
252 {
253 SightingsFilter newFilter = new SightingsFilter();
0c3a8e7 @camillol fast play
authored
254 newFilter.viewMinYear = 2000 + settingsView.yearSlider.minIndex();
255 newFilter.viewMaxYear = 2000 + settingsView.yearSlider.maxIndex();
dc00403 @camillol much faster filtering of sightings
authored
256 if (btwMonths) {
257 newFilter.viewMinMonth = 1 + settingsView.monthSlider.minIndex();
258 newFilter.viewMaxMonth = 1 + settingsView.monthSlider.maxIndex();
259 }
260 if (btwTime) {
f9b1483 @pjimen5 UpdateTimeFilter
pjimen5 authored
261 newFilter.viewMinHour = settingsView.timeSlider.minIndex();
262 newFilter.viewMaxHour = settingsView.timeSlider.maxIndex();
dc00403 @camillol much faster filtering of sightings
authored
263 }
87f6f27 @camillol select types for graph
authored
264
c36fe9b @camillol try drawing all types
authored
265 Set<SightingType> activeTypes = new HashSet<SightingType>();
87f6f27 @camillol select types for graph
authored
266 for (SightingType type : sightingTypeMap.values()) {
267 if (type.active) activeTypes.add(type);
268 }
269 newFilter.activeTypes = activeTypes;
dc00403 @camillol much faster filtering of sightings
authored
270
271 if (!newFilter.equals(activeFilter)) {
c36fe9b @camillol try drawing all types
authored
272 println(activeFilter + " -> " + newFilter);
f062acc @camillol fixed filtering by type
authored
273 boolean reload = !newFilter.equalsIgnoringTypes(activeFilter);
dc00403 @camillol much faster filtering of sightings
authored
274 activeFilter = newFilter;
f062acc @camillol fixed filtering by type
authored
275 if (reload) {
276 data.reloadCitySightingCounts();
277 updateStateSightingCounts();
278 } else {
279 println("recomputing totals");
280 updateCitySightingTotals();
281 updateStateSightingTotals();
282 }
dc00403 @camillol much faster filtering of sightings
authored
283 mapv.rebuildOverlay();
284 detailsAnimator.target(height);
f062acc @camillol fixed filtering by type
authored
285 return true;
dc00403 @camillol much faster filtering of sightings
authored
286 }
f062acc @camillol fixed filtering by type
authored
287 else return false;
dc00403 @camillol much faster filtering of sightings
authored
288 }
289
b77cea0 @pjimen5 CallUpdateCitiesWhenSettingsChange
pjimen5 authored
290 void mouseReleased(){
dc00403 @camillol much faster filtering of sightings
authored
291 if (isDragging) {
292 updateFilter();
b77cea0 @pjimen5 CallUpdateCitiesWhenSettingsChange
pjimen5 authored
293 }
294 isDragging = false;
295 }
296
Something went wrong with that request. Please try again.