Skip to content

Commit

Permalink
Updated lots of examples to use settings() and updated them to
Browse files Browse the repository at this point in the history
Applications (instead of Applets)
  • Loading branch information
tillnagel committed Oct 27, 2015
1 parent 2782168 commit c07dc9d
Show file tree
Hide file tree
Showing 61 changed files with 509 additions and 251 deletions.
2 changes: 1 addition & 1 deletion examples-processing/SimpleMapApp/SimpleMapApp.pde
Expand Up @@ -12,7 +12,7 @@ void setup() {
size(800, 600, P2D);

map = new UnfoldingMap(this);
map.zoomAndPanTo(new Location(52.5f, 13.4f), 10);
map.zoomAndPanTo(10, new Location(52.5f, 13.4f));
MapUtils.createDefaultEventDispatcher(this, map);
}

Expand Down
5 changes: 4 additions & 1 deletion examples/de/fhpotsdam/unfolding/examples/SimpleMapApp.java
Expand Up @@ -12,15 +12,18 @@ public class SimpleMapApp extends PApplet {

UnfoldingMap map;

public void setup() {
public void settings() {
size(800, 600, P2D);
}

public void setup() {
map = new UnfoldingMap(this);
map.zoomAndPanTo(10, new Location(52.5f, 13.4f));
MapUtils.createDefaultEventDispatcher(this, map);
}

public void draw() {
background(240);
map.draw();
}

Expand Down
@@ -1,7 +1,6 @@
package de.fhpotsdam.unfolding.examples;

import processing.core.PApplet;

import de.fhpotsdam.unfolding.UnfoldingMap;
import de.fhpotsdam.unfolding.examples.marker.SimpleMarkerManagerApp;
import de.fhpotsdam.unfolding.geo.Location;
Expand All @@ -17,15 +16,18 @@
public class SimplePositionConversionMapApp extends PApplet {

UnfoldingMap map;


public void settings() {
size(800, 600, P2D);
}

public void setup() {
size(800, 600, OPENGL);

map = new UnfoldingMap(this);
MapUtils.createDefaultEventDispatcher(this, map);
}

public void draw() {
background(240);
map.draw();

fill(215, 0, 0, 100);
Expand All @@ -43,6 +45,6 @@ public void draw() {
}

public static void main(String[] args) {
PApplet.main(new String[] { "de.fhpotsdam.unfolding.examples.SimplePositionConversionMapApp" });
PApplet.main(new String[] { SimplePositionConversionMapApp.class.getName() });
}
}
Expand Up @@ -24,9 +24,11 @@ public class FadeTwoMapsApp extends PApplet {
int fadeMin = 0;
int fadeMax = 255;

public void settings() {
size(600, 400, P2D);
}

public void setup() {
size(600, 400, OPENGL);

// Set the position and size of our two maps.
int mapXposition = 0;
int mapYposition = 30;
Expand All @@ -38,9 +40,9 @@ public void setup() {

// Initialize two maps
map1 = new UnfoldingMap(this, mapXposition, mapYposition, mapWidth, mapHeight);
map1.zoomAndPanTo(new Location(lon, lat), 10);
map1.zoomAndPanTo(10, new Location(lon, lat));
map2 = new UnfoldingMap(this, mapXposition, mapYposition, mapWidth, mapHeight, new Microsoft.AerialProvider());
map2.zoomAndPanTo(new Location(lon, lat), 10);
map2.zoomAndPanTo(10, new Location(lon, lat));
MapUtils.createDefaultEventDispatcher(this, map1, map2);
}

Expand Down
@@ -1,7 +1,6 @@
package de.fhpotsdam.unfolding.examples.animation;

import processing.core.PApplet;

import de.fhpotsdam.unfolding.UnfoldingMap;
import de.fhpotsdam.unfolding.examples.interaction.NaviButtonMapApp;
import de.fhpotsdam.unfolding.geo.Location;
Expand All @@ -22,12 +21,14 @@ public class PanAnimationMapApp extends PApplet {
new Location(51.34, 12.37) };
int currentLocation = 0;

public void setup() {
size(800, 600, OPENGL);
public void settings() {
size(800, 600, P2D);
}

public void setup() {
map = new UnfoldingMap(this);
map.setTweening(true);
map.zoomAndPanTo(locations[currentLocation], 8);
map.zoomAndPanTo(8, locations[currentLocation]);

MapUtils.createDefaultEventDispatcher(this, map);
}
Expand Down
10 changes: 6 additions & 4 deletions examples/de/fhpotsdam/unfolding/examples/data/GPXTrackApp.java
Expand Up @@ -22,12 +22,14 @@ public class GPXTrackApp extends PApplet {

Location startLocation = new Location(52.49f, 13.44f);

public void setup() {
size(800, 600, OPENGL);
public void settings() {
size(800, 600, P2D);
}

public void setup() {
map = new UnfoldingMap(this);
MapUtils.createDefaultEventDispatcher(this, map);
map.zoomAndPanTo(startLocation, 13);
map.zoomAndPanTo(13, startLocation);

List<Feature> features = GPXReader.loadData(this, "data/bike-tour.gpx");
List<Marker> markers = MapUtils.createSimpleMarkers(features);
Expand All @@ -39,6 +41,6 @@ public void draw() {
}

public static void main(String[] args) {
PApplet.main(new String[] { "de.fhpotsdam.unfolding.examples.data.GPXTrackApp" });
PApplet.main(new String[] { GPXTrackApp.class.getName() });
}
}
Expand Up @@ -3,7 +3,6 @@
import java.util.List;

import processing.core.PApplet;

import de.fhpotsdam.unfolding.UnfoldingMap;
import de.fhpotsdam.unfolding.data.Feature;
import de.fhpotsdam.unfolding.data.GeoJSONReader;
Expand All @@ -21,10 +20,16 @@ public class GeoJSONMarkerApp extends PApplet {

UnfoldingMap map;

public void setup() {
size(800, 600, OPENGL);
public void settings() {
size(800, 600, P2D);
smooth();
}

public static void main(String args[]) {
PApplet.main(new String[] { GeoJSONMarkerApp.class.getName() });
}

public void setup() {
map = new UnfoldingMap(this, 50, 50, 700, 500);
map.zoomToLevel(2);
MapUtils.createDefaultEventDispatcher(this, map);
Expand Down
Expand Up @@ -22,10 +22,16 @@ public class GeoRSSMarkerApp extends PApplet {

UnfoldingMap map;

public void setup() {
size(800, 600, OPENGL);
public void settings() {
size(800, 600, P2D);
smooth();
}

public static void main(String args[]) {
PApplet.main(new String[] { GeoRSSMarkerApp.class.getName() });
}

public void setup() {
map = new UnfoldingMap(this);
map.zoomToLevel(2);
MapUtils.createDefaultEventDispatcher(this, map);
Expand Down
Expand Up @@ -4,7 +4,6 @@
import java.util.List;

import processing.core.PApplet;

import de.fhpotsdam.unfolding.UnfoldingMap;
import de.fhpotsdam.unfolding.data.Feature;
import de.fhpotsdam.unfolding.data.GeoJSONReader;
Expand All @@ -27,10 +26,16 @@ public class TransitLinesMarkerApp extends PApplet {

UnfoldingMap map;

public void setup() {
public void settings() {
size(800, 600, P2D);
smooth();
}

public static void main(String args[]) {
PApplet.main(new String[] { TransitLinesMarkerApp.class.getName() });
}

public void setup() {
map = new UnfoldingMap(this, new StamenMapProvider.TonerBackground());
map.zoomToLevel(11);
map.panTo(bostonLocation);
Expand Down
Expand Up @@ -4,7 +4,6 @@
import java.util.List;

import processing.core.PApplet;

import de.fhpotsdam.unfolding.UnfoldingMap;
import de.fhpotsdam.unfolding.data.Feature;
import de.fhpotsdam.unfolding.data.GeoJSONReader;
Expand All @@ -26,10 +25,15 @@ public class ChoroplethMapApp extends PApplet {
HashMap<String, DataEntry> dataEntriesMap;
List<Marker> countryMarkers;

public void setup() {
size(800, 600, OPENGL);
smooth();
public void settings() {
size(800, 600, P2D);
}

public static void main(String args[]) {
PApplet.main(new String[] { ChoroplethMapApp.class.getName() });
}

public void setup() {
map = new UnfoldingMap(this, 50, 50, 700, 500);
map.zoomToLevel(2);
map.setBackgroundColor(240);
Expand Down
Expand Up @@ -4,7 +4,6 @@
import java.util.List;

import processing.core.PApplet;

import de.fhpotsdam.unfolding.UnfoldingMap;
import de.fhpotsdam.unfolding.data.Feature;
import de.fhpotsdam.unfolding.data.GeoJSONReader;
Expand All @@ -28,10 +27,15 @@ public class CountryBubbleMapApp extends PApplet {
HashMap<String, DataEntry> dataEntriesMap;
List<Marker> countryMarkers;

public void setup() {
size(800, 600, OPENGL);
smooth();
public void settings() {
size(800, 600, P2D);
}

public static void main(String args[]) {
PApplet.main(new String[] { CountryBubbleMapApp.class.getName() });
}

public void setup() {
map = new UnfoldingMap(this);
map.zoomToLevel(2);
map.setBackgroundColor(240);
Expand All @@ -53,7 +57,7 @@ public void setup() {

String countryId = country.getId();
DataEntry dataEntry = dataEntriesMap.get(countryId);
if (dataEntry != null) {
if (dataEntry != null && dataEntry.value > 0) {
// Map to correct size (linearly to area)
float radius = PApplet.sqrt(dataEntry.value / PApplet.PI);
// Constrain radius to 100px (20000 is for China's population of 1.3billion)
Expand Down
Expand Up @@ -22,13 +22,15 @@ public class GPXSpeedTrackApp extends PApplet {
UnfoldingMap map;

Location startLocation = new Location(52.49f, 13.44f);


public void settings() {
size(800, 600, P2D);
}

public void setup() {
size(800, 600, OPENGL);

map = new UnfoldingMap(this);
MapUtils.createDefaultEventDispatcher(this, map);
map.zoomAndPanTo(startLocation, 14);
map.zoomAndPanTo(14, startLocation);

List<Feature> features = GPXSpeedReader.loadData(this, "data/bike-tour.gpx");
MarkerFactory markerFactory = new MarkerFactory();
Expand All @@ -42,6 +44,6 @@ public void draw() {
}

public static void main(String[] args) {
PApplet.main(new String[] { "de.fhpotsdam.unfolding.examples.data.GPXTrackApp" });
PApplet.main(new String[] { GPXSpeedTrackApp.class.getName() });
}
}
Expand Up @@ -21,10 +21,15 @@ public class GeoRSSStyledMarkerApp extends PApplet {

UnfoldingMap map;

public void setup() {
size(800, 600, OPENGL);
smooth();
public void settings() {
size(800, 600, P2D);
}

public static void main(String args[]) {
PApplet.main(new String[] { GeoRSSStyledMarkerApp.class.getName() });
}

public void setup() {
map = new UnfoldingMap(this);
map.zoomToLevel(2);
MapUtils.createDefaultEventDispatcher(this, map);
Expand All @@ -37,6 +42,7 @@ public void setup() {
}

public void draw() {
background(240);
map.draw();
}

Expand Down
Expand Up @@ -21,9 +21,17 @@ public class ColoredSelectedVectorTilesApp extends PApplet {

VectorTilesUtils vectorTilesUtils;

public void setup() {
size(800, 600, OPENGL);
String filteredType = "museum";

public void settings() {
size(800, 600, P2D);
}

public static void main(String args[]) {
PApplet.main(new String[] { ColoredSelectedVectorTilesApp.class.getName() });
}

public void setup() {
map = new UnfoldingMap(this, "myMap");
map.zoomAndPanTo(16, new Location(52.501, 13.395));
MapUtils.createDefaultEventDispatcher(this, map);
Expand All @@ -32,7 +40,7 @@ public void setup() {

vectorTilesUtils = new VectorTilesUtils(this, map);

loadAndAddColoredMarkers(width / 2, height / 2, "museum");
loadAndAddColoredMarkers(width / 2, height / 2, filteredType);
}

public void draw() {
Expand All @@ -41,14 +49,14 @@ public void draw() {
}

public void mouseClicked() {
loadAndAddColoredMarkers(mouseX, mouseY, "museum");
loadAndAddColoredMarkers(mouseX, mouseY, filteredType);
}

public void loadAndAddColoredMarkers(int x, int y, String kindName) {
public void loadAndAddColoredMarkers(int x, int y, String filteredType) {
List<Marker> markers = vectorTilesUtils.loadMarkersForScreenPos("buildings", x, y);
for (Marker marker : markers) {
String kind = marker.getStringProperty("kind");
if (kindName.equals(kind)) {
if (filteredType.equals(kind)) {
marker.setColor(color(0, 255, 0, 200));
}
}
Expand Down

0 comments on commit c07dc9d

Please sign in to comment.