diff --git a/.classpath b/.classpath index f5ee005b..70f98a61 100644 --- a/.classpath +++ b/.classpath @@ -6,27 +6,30 @@ - - - - - + - + - - + + + + + + + + + diff --git a/.gitignore b/.gitignore index 5fd665f9..80668db2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,10 +3,6 @@ bin/* build/ dist/ doc/ - -*.DS_STORE .DS_Store - data/splendor-big.png - src/de/fhpotsdam/unfolding/mapdisplay/GLGraphicsMapDisplayTransparentTest.java diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index b3e23777..df6a2919 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,2 +1,4 @@ eclipse.preferences.version=1 +encoding//examples/de/fhpotsdam/unfolding/examples/image/ImageOverlayApp.java=UTF-8 +encoding//src/de/fhpotsdam/unfolding/mapdisplay/AbstractMapDisplay.java=UTF-8 encoding//src/de/fhpotsdam/unfolding/utils/DebugDisplay.java=UTF-8 diff --git a/README.md b/README.md index 994f0ec4..d54357d6 100644 --- a/README.md +++ b/README.md @@ -22,11 +22,12 @@ such as OpenStreetMap or TileMill. ## Download -Get Unfolding from or directly from here: https://github.com/tillnagel/unfolding/downloads +Get Unfolding from or directly from here: http://unfoldingmaps.org/downloads ## Credit -Developed at Interaction Design Lab, FH Potsdam, and the HCI group, KU Leuven. +Developed at Interaction Design Lab, FH Potsdam, the HCI group, KU Leuven, and MIT Senseable City Labs. +See http://unfoldingmaps.org/contact.html for the full credits. ## License @@ -34,7 +35,7 @@ Developed at Interaction Design Lab, FH Potsdam, and the HCI group, KU Leuven. You may use Unfolding under the terms of the MIT License. See http://en.wikipedia.org/wiki/MIT_License for more information. -Copyright (C) 2013 Till Nagel, and contributors +Copyright (C) 2014 Till Nagel, and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/build.xml b/build.xml index 8ecdefb7..690c576e 100644 --- a/build.xml +++ b/build.xml @@ -9,7 +9,7 @@ /resources/unfolding_app_template/classpath /resources/unfolding_app_template/classpath_with_examples --> - + @@ -116,7 +116,7 @@ - + @@ -124,13 +124,17 @@ + + + @@ -150,7 +154,7 @@ - + @@ -158,9 +162,11 @@ + @@ -169,6 +175,7 @@ + @@ -192,8 +199,11 @@ + + + - + @@ -215,7 +225,7 @@ diff --git a/data/data/bike-tour2.gpx b/data/data/bike-tour2.gpx new file mode 100644 index 00000000..d3d1dba4 --- /dev/null +++ b/data/data/bike-tour2.gpx @@ -0,0 +1,441 @@ + + + + + + +41.0 +41.0 +41.0 +41.0 +40.7 +40.5 +40.2 +39.9 +39.6 +39.4 +39.1 +39.1 +39.1 +39.1 +39.1 +39.5 +40.0 +40.5 +40.9 +41.0 +41.1 +41.2 +41.0 +40.8 +40.6 +40.5 +39.8 +39.2 +38.5 +37.9 +37.6 +37.4 +37.1 +36.8 +36.5 +36.3 +36.0 +36.0 +36.0 +36.0 +36.0 +36.0 +36.0 +36.0 +36.2 +36.4 +36.5 +36.7 +36.9 +37.2 +37.5 +37.7 +38.0 +38.4 +38.6 +38.7 +38.8 +38.9 +39.0 +39.0 +38.9 +38.8 +38.7 +38.6 +38.5 +38.4 +38.3 +38.2 +38.1 +38.1 +38.2 +38.3 +38.4 +38.5 +38.5 +38.6 +38.7 +39.1 +39.3 +39.5 +39.5 +39.5 +39.5 +39.5 +39.5 +39.4 +39.2 +39.0 +38.5 +38.3 +38.0 +37.7 +37.5 +37.4 +37.3 +37.2 +37.3 +37.4 +37.5 +37.6 +37.8 +38.0 +38.2 +38.5 +38.7 +38.9 +39.1 +39.3 +39.5 +39.6 +39.8 +40.0 +40.2 +40.4 +40.5 +40.5 +40.5 +40.6 +40.7 +40.8 +40.9 +40.6 +40.4 +40.1 +39.8 +39.6 +39.5 +39.4 +39.2 +39.0 +39.0 +39.0 +39.3 +39.5 +39.8 +40.0 +40.1 +40.2 +40.3 +40.4 +40.5 +40.3 +40.1 +39.9 +39.7 +39.5 +39.5 +39.3 +39.1 +38.9 +38.7 +38.5 +38.6 +38.8 +39.0 +39.2 +39.4 +39.5 +39.8 +40.1 +40.4 +40.5 +40.7 +40.7 +40.5 +40.4 +40.2 +40.0 +39.8 +39.6 +39.5 +39.3 +39.2 +39.1 +39.1 +39.2 +39.3 +39.4 +39.5 +39.5 +39.5 +39.5 +39.5 +39.5 +39.5 +39.5 +39.4 +39.3 +39.2 +39.1 +39.0 +39.0 +39.1 +39.2 +39.2 +39.1 +39.1 +39.1 +39.1 +39.1 +39.1 +39.1 +39.1 +39.1 +39.1 +39.2 +39.4 +39.5 +39.4 +39.4 +39.4 +39.4 +39.4 +39.4 +39.3 +39.2 +39.1 +39.0 +38.9 +39.0 +39.0 +39.0 +39.0 +39.0 +39.0 +39.0 +39.0 +39.0 +39.0 +39.0 +39.0 +38.9 +38.8 +38.7 +38.6 +38.5 +38.5 +38.4 +38.4 +38.4 +38.4 +38.3 +38.4 +38.5 +38.5 +38.5 +38.5 +38.5 +38.5 +38.5 +38.5 +38.5 +38.6 +38.6 +38.5 +38.5 +38.5 +38.5 +38.7 +38.8 +38.9 +39.0 +39.0 +39.0 +39.0 +39.1 +39.1 +39.2 +39.3 +39.2 +39.1 +39.0 +39.0 +39.1 +39.2 +39.3 +39.4 +39.2 +38.9 +38.6 +38.4 +38.0 +37.6 +37.2 +36.7 +36.5 +36.2 +35.9 +36.0 +36.2 +36.4 +36.5 +36.8 +37.1 +37.6 +38.2 +38.5 +38.9 +39.3 +39.5 +39.7 +39.9 +40.3 +40.6 +41.0 +41.1 +41.2 +41.3 +41.4 +41.5 +41.6 +41.8 +42.0 +42.0 +42.1 +42.1 +42.1 +42.1 +42.1 +41.9 +41.7 +41.5 +41.4 +41.2 +41.0 +40.7 +40.5 +40.4 +40.2 +40.0 +40.0 +39.9 +39.8 +39.7 +39.6 +39.5 +39.5 +39.4 +39.3 +39.2 +39.1 +39.0 +39.0 +39.0 +39.0 +38.9 +38.8 +38.7 +38.5 +38.2 +37.9 +37.6 +37.4 +37.3 +37.2 +37.1 +37.1 +37.1 +37.1 +37.5 +37.5 +37.5 +37.5 +37.7 +37.8 +37.9 +38.0 +38.3 +38.5 +38.8 +38.9 +39.7 +40.5 +41.4 +41.9 +42.5 +43.3 +44.1 +44.7 +45.4 +45.9 +46.5 +46.6 +46.8 +47.0 +47.2 +47.4 +47.3 +47.0 +46.7 +46.5 +46.3 +46.0 +45.7 +45.5 +45.2 +44.9 +44.6 +44.2 +43.9 +43.6 +43.4 +43.1 +42.7 +42.4 +42.0 +41.6 +41.3 +40.8 +40.5 +40.3 +40.0 +39.7 +39.5 +39.4 +39.3 +39.4 +39.5 +39.5 +39.7 +39.9 +40.0 +40.1 +40.2 +40.4 +40.7 + + + diff --git a/data/test/Mask.glsl b/data/test/Mask.glsl deleted file mode 100644 index 25c31e7a..00000000 --- a/data/test/Mask.glsl +++ /dev/null @@ -1,13 +0,0 @@ -uniform sampler2D src_tex_unit0; -uniform sampler2D src_tex_unit1; - - -void main(void) { - vec4 src_color = texture2D(src_tex_unit0, gl_TexCoord[0].st).rgba; - vec4 mask_color = texture2D(src_tex_unit1, gl_TexCoord[1].st).rgba; - - gl_FragColor = mix(src_color, 0.0*mask_color, mask_color.r); - - //gl_FragColor = vec4(1.0, 0.0, 0.0, 0.0); - //gl_FragColor = vec4(src_color.r, src_color.g, src_color.b, mask_color.a); -} diff --git a/data/test/Mask.xml b/data/test/Mask.xml deleted file mode 100644 index fd6e6ce6..00000000 --- a/data/test/Mask.xml +++ /dev/null @@ -1,5 +0,0 @@ - - masks a source texture with a mask texture - Mask.glsl - - diff --git a/data/test/blur.glsl b/data/test/blur.glsl new file mode 100644 index 00000000..1b15094c --- /dev/null +++ b/data/test/blur.glsl @@ -0,0 +1,59 @@ +// Adapted from: +// http://callumhay.blogspot.com/2010/09/gaussian-blur-shader-glsl.html + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +#define PROCESSING_TEXTURE_SHADER + +uniform sampler2D texture; + +// The inverse of the texture dimensions along X and Y +uniform vec2 texOffset; + +varying vec4 vertColor; +varying vec4 vertTexCoord; + +uniform int blurSize; +uniform int horizontalPass; // 0 or 1 to indicate vertical or horizontal pass +uniform float sigma; // The sigma value for the gaussian function: higher value means more blur + // A good value for 9x9 is around 3 to 5 + // A good value for 7x7 is around 2.5 to 4 + // A good value for 5x5 is around 2 to 3.5 + // ... play around with this based on what you need :) + +const float pi = 3.14159265; + +void main() { + float numBlurPixelsPerSide = float(blurSize / 2); + + vec2 blurMultiplyVec = 0 < horizontalPass ? vec2(1.0, 0.0) : vec2(0.0, 1.0); + + // Incremental Gaussian Coefficent Calculation (See GPU Gems 3 pp. 877 - 889) + vec3 incrementalGaussian; + incrementalGaussian.x = 1.0 / (sqrt(2.0 * pi) * sigma); + incrementalGaussian.y = exp(-0.5 / (sigma * sigma)); + incrementalGaussian.z = incrementalGaussian.y * incrementalGaussian.y; + + vec4 avgValue = vec4(0.0, 0.0, 0.0, 0.0); + float coefficientSum = 0.0; + + // Take the central sample first... + avgValue += texture2D(texture, vertTexCoord.st) * incrementalGaussian.x; + coefficientSum += incrementalGaussian.x; + incrementalGaussian.xy *= incrementalGaussian.yz; + + // Go through the remaining 8 vertical samples (4 on each side of the center) + for (float i = 1.0; i <= numBlurPixelsPerSide; i++) { + avgValue += texture2D(texture, vertTexCoord.st - i * texOffset * + blurMultiplyVec) * incrementalGaussian.x; + avgValue += texture2D(texture, vertTexCoord.st + i * texOffset * + blurMultiplyVec) * incrementalGaussian.x; + coefficientSum += 2.0 * incrementalGaussian.x; + incrementalGaussian.xy *= incrementalGaussian.yz; + } + + gl_FragColor = avgValue / coefficientSum; +} \ No newline at end of file diff --git a/data/test/deform.glsl b/data/test/deform.glsl new file mode 100644 index 00000000..0c69cfdc --- /dev/null +++ b/data/test/deform.glsl @@ -0,0 +1,31 @@ +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +#define PROCESSING_TEXTURE_SHADER + +uniform sampler2D texture; + +uniform float time; +uniform vec2 resolution; +uniform vec2 mouse; + +void main(void) { + vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy; + vec2 m = -1.0 + 2.0 * mouse.xy / resolution.xy; + + float a1 = atan(p.y - m.y, p.x - m.x); + float r1 = sqrt(dot(p - m, p - m)); + float a2 = atan(p.y + m.y, p.x + m.x); + float r2 = sqrt(dot(p + m, p + m)); + + vec2 uv; + uv.x = 0.2 * time + (r1 - r2) * 0.25; + uv.y = sin(2.0 * (a1 - a2)); + + float w = r1 * r2 * 0.8; + vec3 col = texture2D(texture, 0.5 - 0.495 * uv).xyz; + + gl_FragColor = vec4(col / (0.1 + w), 1.0); +} \ No newline at end of file diff --git a/data/test/mask-circular.png b/data/test/mask-circular.png new file mode 100644 index 00000000..3e00b618 Binary files /dev/null and b/data/test/mask-circular.png differ diff --git a/data/test/mask.glsl b/data/test/mask.glsl new file mode 100644 index 00000000..591d342b --- /dev/null +++ b/data/test/mask.glsl @@ -0,0 +1,19 @@ +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +#define PROCESSING_TEXTURE_SHADER + +uniform sampler2D texture; +uniform sampler2D mask; + +uniform vec2 texOffset; +varying vec4 vertColor; +varying vec4 vertTexCoord; + +void main() { + vec4 texColor = texture2D(texture, vertTexCoord.st).rgba; + vec4 maskColor = texture2D(mask, vec2(vertTexCoord.s, vertTexCoord.t)).rgba; + gl_FragColor = mix(texColor, vec4(0, 0, 0, 0), 1.0 - maskColor.r); +} \ No newline at end of file diff --git a/examples-extern/de/fhpotsdam/unfolding/examples/animation/AnimationWithAniLibApp.java b/examples-extern/de/fhpotsdam/unfolding/examples/animation/AnimationWithAniLibApp.java index 98d55ae9..00a48792 100644 --- a/examples-extern/de/fhpotsdam/unfolding/examples/animation/AnimationWithAniLibApp.java +++ b/examples-extern/de/fhpotsdam/unfolding/examples/animation/AnimationWithAniLibApp.java @@ -4,7 +4,6 @@ import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.providers.Microsoft; -import de.fhpotsdam.unfolding.utils.MapUtils; import de.looksgood.ani.Ani; /** @@ -12,7 +11,7 @@ * smoothly. * * Demonstrates how to create own animations, instead of the built-in tweening functionality. In this example, the - * external Ani library is used. + * external Ani library is used. */ public class AnimationWithAniLibApp extends PApplet { @@ -25,11 +24,10 @@ public class AnimationWithAniLibApp extends PApplet { float targetZoom = currentZoom; public void setup() { - size(1200, 600); + size(1200, 600, P2D); map = new UnfoldingMap(this, new Microsoft.AerialProvider()); map.zoomAndPanTo(location, (int) currentZoom); - MapUtils.createDefaultEventDispatcher(this, map); Ani.init(this); } @@ -54,16 +52,15 @@ public void keyPressed() { if (key == 'Z') { targetZoom--; } + Ani.to(this, 4.5f, "currentZoom", targetZoom, Ani.ELASTIC_OUT); } - Ani.to(this, 1.5f, "currentZoom", targetZoom, Ani.EXPO_OUT); - } public void mouseReleased() { Location targetLocation = map.getLocation(mouseX, mouseY); - Ani.to(this, 1.5f, "lat", targetLocation.getLat(), Ani.EXPO_OUT); - Ani.to(this, 1.5f, "lon", targetLocation.getLon(), Ani.EXPO_OUT); + Ani.to(this, 1.5f, "lat", targetLocation.getLat(), Ani.ELASTIC_OUT); + Ani.to(this, 1.5f, "lon", targetLocation.getLon(), Ani.ELASTIC_OUT); } } diff --git a/examples-extern/de/fhpotsdam/unfolding/examples/data/temporal/AnimatedTemporalDotsApp.java b/examples-extern/de/fhpotsdam/unfolding/examples/data/temporal/AnimatedTemporalDotsApp.java index 36be741b..7a73ac6c 100644 --- a/examples-extern/de/fhpotsdam/unfolding/examples/data/temporal/AnimatedTemporalDotsApp.java +++ b/examples-extern/de/fhpotsdam/unfolding/examples/data/temporal/AnimatedTemporalDotsApp.java @@ -8,7 +8,6 @@ import processing.core.PApplet; import processing.core.PVector; -import codeanticode.glgraphics.GLConstants; import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.data.Feature; import de.fhpotsdam.unfolding.data.GeoRSSReader; @@ -36,7 +35,7 @@ public class AnimatedTemporalDotsApp extends PApplet { boolean animating = true; public void setup() { - size(900, 600, GLConstants.GLGRAPHICS); + size(900, 600, OPENGL); smooth(); map = new UnfoldingMap(this); @@ -101,7 +100,7 @@ public void drawGrowingEarthquakeDots(PVector pos, DateTime time) { int minutes = Minutes.minutesBetween(time, currentTime).getMinutes(); int maxMinutes = 12 * 60; float size = constrain(map(minutes, 0, maxMinutes, 0, 30), 0, 30); - + // But fades away the colors float alphaValue = constrain(map(minutes, 0, maxMinutes, 100, 0), 0, 100); float alphaStrokeValue = constrain(map(minutes, 0, maxMinutes, 255, 0), 0, 255); @@ -111,7 +110,7 @@ public void drawGrowingEarthquakeDots(PVector pos, DateTime time) { stroke(255, 0, 0, alphaStrokeValue); strokeWeight(1); ellipse(pos.x, pos.y, size, size); - + // Always draw the epicenter fill(255, 0, 0); ellipse(pos.x, pos.y, 4, 4); diff --git a/examples-extern/de/fhpotsdam/unfolding/examples/data/temporal/TemporalDotsApp.java b/examples-extern/de/fhpotsdam/unfolding/examples/data/temporal/TemporalDotsApp.java index 3cfa9dc4..b67c188e 100644 --- a/examples-extern/de/fhpotsdam/unfolding/examples/data/temporal/TemporalDotsApp.java +++ b/examples-extern/de/fhpotsdam/unfolding/examples/data/temporal/TemporalDotsApp.java @@ -3,11 +3,9 @@ import java.util.List; import org.joda.time.DateTime; -import org.joda.time.Hours; import processing.core.PApplet; import processing.core.PVector; -import codeanticode.glgraphics.GLConstants; import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.data.Feature; import de.fhpotsdam.unfolding.data.GeoRSSReader; @@ -32,7 +30,7 @@ public class TemporalDotsApp extends PApplet { DateTime currentTime; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); smooth(); map = new UnfoldingMap(this); @@ -52,7 +50,7 @@ public void setup() { public void draw() { background(0); map.draw(); - + for (Marker marker : markers) { DateTime markerTime = new DateTime(marker.getStringProperty("date")); // Check if earthquake has occurred before current time, i.e. visible @@ -61,24 +59,24 @@ public void draw() { drawEarthquakeMarker(pos); } } - + // Every 10 frames increase current time by 1h if (frameCount % 10 == 0) { currentTime = currentTime.plusHours(1); - + // Loop: If end is reached start at beginning again. if (currentTime.isAfter(endTime)) { currentTime = startTime.plus(0); } } - + noStroke(); fill(0, 200); rect(10, 10, 270, 20); fill(255); text("Time: " + currentTime, 13, 24); } - + public void drawEarthquakeMarker(PVector pos) { fill(255, 0, 0, 100); stroke(255, 0, 0, 200); diff --git a/examples-extern/de/fhpotsdam/unfolding/examples/geonames/GeoNamesBasicLookup.java b/examples-extern/de/fhpotsdam/unfolding/examples/geonames/GeoNamesBasicLookup.java index f44b3834..87747e56 100644 --- a/examples-extern/de/fhpotsdam/unfolding/examples/geonames/GeoNamesBasicLookup.java +++ b/examples-extern/de/fhpotsdam/unfolding/examples/geonames/GeoNamesBasicLookup.java @@ -1,14 +1,16 @@ package de.fhpotsdam.unfolding.examples.geonames; +import org.geonames.Toponym; +import org.geonames.ToponymSearchCriteria; +import org.geonames.ToponymSearchResult; +import org.geonames.WebService; + import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.MapUtils; import de.fhpotsdam.unfolding.utils.ScreenPosition; -import org.geonames.*; - public class GeoNamesBasicLookup extends PApplet { UnfoldingMap map; @@ -22,7 +24,7 @@ public class GeoNamesBasicLookup extends PApplet { public void setup() { - size(650, 440, GLConstants.GLGRAPHICS); + size(650, 440, OPENGL); // INIT UNFOLDING map = new UnfoldingMap(this); diff --git a/examples-extern/de/fhpotsdam/unfolding/examples/geonames/GeoNamesDynamicLookup.java b/examples-extern/de/fhpotsdam/unfolding/examples/geonames/GeoNamesDynamicLookup.java index 3b112319..3b82deaf 100644 --- a/examples-extern/de/fhpotsdam/unfolding/examples/geonames/GeoNamesDynamicLookup.java +++ b/examples-extern/de/fhpotsdam/unfolding/examples/geonames/GeoNamesDynamicLookup.java @@ -1,18 +1,19 @@ package de.fhpotsdam.unfolding.examples.geonames; +import org.geonames.Toponym; +import org.geonames.ToponymSearchCriteria; +import org.geonames.ToponymSearchResult; +import org.geonames.WebService; + import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; +import controlP5.ControlEvent; +import controlP5.ControlP5; +import controlP5.Textfield; import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.MapUtils; import de.fhpotsdam.unfolding.utils.ScreenPosition; -import org.geonames.*; - -import controlP5.ControlEvent; -import controlP5.ControlP5; -import controlP5.Textfield; - public class GeoNamesDynamicLookup extends PApplet { // UNFOLDING Variables @@ -33,7 +34,7 @@ public class GeoNamesDynamicLookup extends PApplet { public void setup() { - size(650, 440, GLConstants.GLGRAPHICS); + size(650, 440, OPENGL); // INIT UNFOLDING map = new UnfoldingMap(this); diff --git a/examples-extern/de/fhpotsdam/unfolding/examples/misc/PathSmoothingApp.java b/examples-extern/de/fhpotsdam/unfolding/examples/misc/PathSmoothingApp.java new file mode 100644 index 00000000..d97a4a4d --- /dev/null +++ b/examples-extern/de/fhpotsdam/unfolding/examples/misc/PathSmoothingApp.java @@ -0,0 +1,207 @@ +package de.fhpotsdam.unfolding.examples.misc; + +import java.util.ArrayList; +import java.util.List; + +import processing.core.PApplet; +import processing.core.PVector; +import controlP5.ControlEvent; +import controlP5.ControlP5; +import controlP5.Label; +import controlP5.Textlabel; +import de.fhpotsdam.unfolding.UnfoldingMap; +import de.fhpotsdam.unfolding.data.Feature; +import de.fhpotsdam.unfolding.data.GPXReader; +import de.fhpotsdam.unfolding.geo.Location; +import de.fhpotsdam.unfolding.providers.StamenMapProvider; +import de.fhpotsdam.unfolding.utils.GeneralizationUtils; +import de.fhpotsdam.unfolding.utils.GeoUtils; +import de.fhpotsdam.unfolding.utils.MapUtils; +import de.fhpotsdam.unfolding.utils.ScreenPosition; + +/** + * Smoothes the lines of a bike trail. The original, the simplified and the moving-averaged lines are shown. You can + * tweak the algorithms by interactive sliders. + */ +public class PathSmoothingApp extends PApplet { + + boolean showPoints = true; + + UnfoldingMap map; + List locations; + + float simplificationTolerance = 4; + int averageNumber = 5; + boolean showOriginal = true; + boolean showSimplified = true; + boolean showAveraged = true; + boolean showCombined = false; + + ControlP5 cp5; + Textlabel numOriginalTL; + Textlabel numSimplifiedTL; + Textlabel numAverageTL; + Textlabel numCombinedTL; + + public void setup() { + size(800, 600, P2D); + + // map = new UnfoldingMap(this, 0, 60, 800, 540, new MBTilesMapProvider("jdbc:sqlite:./berlin-dark.mbtiles")); + map = new UnfoldingMap(this, 0, 60, 800, 540, new StamenMapProvider.TonerLite()); + map.zoomAndPanTo(new Location(52.5f, 13.4f), 15); + map.setZoomRange(10, 17); + MapUtils.createDefaultEventDispatcher(this, map); + + // Create marker + List features = GPXReader.loadData(this, "data/bike-tour2.gpx"); + // List features = GPXReader.loadData(this, "data/bike-tour.gpx"); + + println("Loaded " + features.size() + " features"); + // MarkerFactory markerFactory = new MarkerFactory(); + // List markers = markerFactory.createMarkers(features); + // map.addMarkers(markers); + + // Center around bike path (by panning to center of all features) + locations = GeoUtils.getLocationsFromFeatures(features); + Location center = GeoUtils.getEuclideanCentroid(locations); + map.panTo(center); + + // UI + cp5 = new ControlP5(this); + cp5.addSlider("simplificationTolerance").setPosition(20, 25).setRange(0, 25).setCaptionLabel("Simplification"); + Label label = cp5.addSlider("averageNumber").setPosition(20, 40).setRange(1, 10).setCaptionLabel("Average") + .getCaptionLabel(); + + cp5.addTextlabel("original").setText("ORIGINAL").setPosition(144, 12).setFont(label.getFont()) + .setColorValue(color(255)); + cp5.addTextlabel("combined").setText("SIMPL+AVG").setPosition(131, 55).setFont(label.getFont()) + .setColorValue(color(255)); + + cp5.addToggle("showOriginal").setPosition(190, 10).setSize(10, 10).setLabelVisible(false); + cp5.addToggle("showSimplified").setPosition(190, 25).setSize(10, 10).setLabelVisible(false); + cp5.addToggle("showAveraged").setPosition(190, 40).setSize(10, 10).setLabelVisible(false); + cp5.addToggle("showCombined").setPosition(190, 55).setSize(10, 10).setLabelVisible(false); + + numOriginalTL = cp5.addTextlabel("numOriginal").setPosition(300, 12).setColorValue(color(200)); + numSimplifiedTL = cp5.addTextlabel("numSimplified").setPosition(300, 27).setColorValue(color(200)); + numAverageTL = cp5.addTextlabel("numAverage").setPosition(300, 42).setColorValue(color(200)); + numCombinedTL = cp5.addTextlabel("numCombined").setPosition(300, 57).setColorValue(color(200)); + } + + public void controlEvent(ControlEvent theEvent) { + if (theEvent.isFrom(cp5.getController("simplificationTolerance"))) { + simplificationTolerance = theEvent.getController().getValue(); + } + if (theEvent.isFrom(cp5.getController("averageNumber"))) { + averageNumber = Math.round(theEvent.getController().getValue()); + } + if (theEvent.isFrom(cp5.getController("showSimplified"))) { + showSimplified = (theEvent.getController().getValue() > 0); + } + if (theEvent.isFrom(cp5.getController("showAveraged"))) { + showAveraged = (theEvent.getController().getValue() > 0); + } + if (theEvent.isFrom(cp5.getController("showOriginal"))) { + showOriginal = (theEvent.getController().getValue() > 0); + } + if (theEvent.isFrom(cp5.getController("showCombined"))) { + showCombined = (theEvent.getController().getValue() > 0); + } + + } + + public void draw() { + map.draw(); + noStroke(); + fill(0, 150); + rect(0, 0, width, height); + + // Update list of points + List points = new ArrayList(); + for (Location location : locations) { + ScreenPosition pos = map.getScreenPosition(location); + points.add(pos); + } + + if (!points.isEmpty()) { + + if (showSimplified) { + // simplified + List simplifiedPoints = GeneralizationUtils.simplify(points, simplificationTolerance, true); + drawLine(simplifiedPoints, color(255, 0, 255, 160), color(255, 0, 255, 160), 5); + numSimplifiedTL.setText("(" + simplifiedPoints.size() + ")"); + } + + if (showAveraged) { + // moving average + List averagedPoints = GeneralizationUtils.computeMovingAverage(points, averageNumber); + drawLine(averagedPoints, color(0, 255, 255, 160), color(0, 255, 255, 160), 5); + numAverageTL.setText("(" + averagedPoints.size() + ")"); + } + + if (showCombined) { + List averagedPoints = GeneralizationUtils.computeMovingAverage(points, averageNumber); + List simplifiedAveragedPoints = GeneralizationUtils.simplify(averagedPoints, + simplificationTolerance, true); + drawLine(simplifiedAveragedPoints, color(255, 160), color(255, 160), 5); + numCombinedTL.setText("(" + simplifiedAveragedPoints.size() + ")"); + } + + if (showOriginal) { + // original on top + drawLine(points, color(255, 255, 0, 200), color(255, 255, 0, 200), 2); + numOriginalTL.setText("(" + points.size() + ")"); + } + } + + drawUIBackground(); + // Actual UI will be drawn in postDraw() by ControlP5 + } + + public void drawUIBackground() { + // UI background + noStroke(); + fill(0); + rect(0, 0, width, 70); + + stroke(255, 255, 0, 200); + strokeWeight(2); + line(205, 15, 280, 15); + + stroke(255, 0, 255, 160); + strokeWeight(5); + line(205, 30, 280, 30); + + stroke(0, 255, 255, 160); + strokeWeight(5); + line(205, 45, 280, 45); + + stroke(255, 255, 255, 240); + strokeWeight(5); + line(205, 60, 280, 60); + } + + public void drawLine(List points, int strokeColor, int color) { + drawLine(points, strokeColor, color, 2); + } + + public void drawLine(List points, int strokeColor, int color, int strokeWeight) { + stroke(strokeColor); + strokeWeight(strokeWeight); + noFill(); + beginShape(); + for (PVector p : points) { + vertex(p.x, p.y); + } + endShape(); + + if (showPoints) { + noStroke(); + fill(color); + for (PVector p : points) { + ellipse(p.x, p.y, strokeWeight, strokeWeight); + } + } + } + +} diff --git a/examples-processing/ChoroplethMapApp/ChoroplethMapApp.pde b/examples-processing/ChoroplethMapApp/ChoroplethMapApp.pde index 14d5ca8f..244721e1 100644 --- a/examples-processing/ChoroplethMapApp/ChoroplethMapApp.pde +++ b/examples-processing/ChoroplethMapApp/ChoroplethMapApp.pde @@ -7,12 +7,11 @@ * mapping. */ -import processing.opengl.*; -import codeanticode.glgraphics.*; import de.fhpotsdam.unfolding.*; import de.fhpotsdam.unfolding.data.*; import de.fhpotsdam.unfolding.marker.*; import de.fhpotsdam.unfolding.utils.*; +import java.util.List; UnfoldingMap map; @@ -20,7 +19,7 @@ HashMap dataEntriesMap; List countryMarkers; void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, P2D); smooth(); map = new UnfoldingMap(this, 50, 50, 700, 500); diff --git a/examples-processing/CircularMapSnapshotApp/CircularMapSnapshotApp.pde b/examples-processing/CircularMapSnapshotApp/CircularMapSnapshotApp.pde index 58ccd602..9d19bd38 100644 --- a/examples-processing/CircularMapSnapshotApp/CircularMapSnapshotApp.pde +++ b/examples-processing/CircularMapSnapshotApp/CircularMapSnapshotApp.pde @@ -7,19 +7,18 @@ * See MapSnapshot.java and CircularMapSnapshot.java for creating the actual snapshot and storage of metadata. */ -import processing.opengl.*; -import codeanticode.glgraphics.*; import de.fhpotsdam.unfolding.*; import de.fhpotsdam.unfolding.geo.*; import de.fhpotsdam.unfolding.utils.*; import de.fhpotsdam.unfolding.providers.*; +import java.util.List; UnfoldingMap map; List mapSnapshots = new ArrayList(); void setup() { - size(600, 400, GLConstants.GLGRAPHICS); + size(600, 400, P2D); map = new UnfoldingMap(this, 0, 0, 400, 400, new StamenMapProvider.WaterColor()); map.zoomAndPanTo(new Location(51.507222, -0.1275), 10); diff --git a/examples-processing/CircularMapSnapshotApp/MapSnapshot.java b/examples-processing/CircularMapSnapshotApp/MapSnapshot.java index e5ed69cc..62fd9405 100644 --- a/examples-processing/CircularMapSnapshotApp/MapSnapshot.java +++ b/examples-processing/CircularMapSnapshotApp/MapSnapshot.java @@ -1,7 +1,6 @@ import processing.core.PApplet; import processing.core.PGraphics; import processing.core.PImage; -import codeanticode.glgraphics.GLGraphicsOffScreen; import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; @@ -39,12 +38,7 @@ public void snapshot(UnfoldingMap map) { // Stores image data of the current map PGraphics pg = map.mapDisplay.getOuterPG(); - if (pg instanceof GLGraphicsOffScreen) { - thumbnail = new PImage((int) map.mapDisplay.getWidth(), (int) map.mapDisplay.getHeight()); - ((GLGraphicsOffScreen) pg).getTexture().getImage(thumbnail); - } else { - thumbnail = pg.get(); - } + thumbnail = pg.get(); } public void set(float x, float y, float width, float height) { diff --git a/examples-processing/DebugDisplayApp/DebugDisplayApp.pde b/examples-processing/DebugDisplayApp/DebugDisplayApp.pde index f822159c..a8b6e901 100644 --- a/examples-processing/DebugDisplayApp/DebugDisplayApp.pde +++ b/examples-processing/DebugDisplayApp/DebugDisplayApp.pde @@ -1,5 +1,3 @@ -import processing.opengl.*; -import codeanticode.glgraphics.*; import de.fhpotsdam.unfolding.*; import de.fhpotsdam.unfolding.geo.*; import de.fhpotsdam.unfolding.utils.*; @@ -12,7 +10,7 @@ UnfoldingMap map; DebugDisplay debugDisplay; void setup() { - size(1024, 768, GLConstants.GLGRAPHICS); + size(1024, 768, P2D); map = new UnfoldingMap(this, "myMap"); map.zoomAndPanTo(new Location(52.5f, 13.4f), 10); diff --git a/examples-processing/GeoJSONMarkerApp/GeoJSONMarkerApp.pde b/examples-processing/GeoJSONMarkerApp/GeoJSONMarkerApp.pde index 6cf63999..901bea43 100644 --- a/examples-processing/GeoJSONMarkerApp/GeoJSONMarkerApp.pde +++ b/examples-processing/GeoJSONMarkerApp/GeoJSONMarkerApp.pde @@ -11,14 +11,12 @@ import de.fhpotsdam.unfolding.marker.*; import de.fhpotsdam.unfolding.*; import de.fhpotsdam.unfolding.data.*; import de.fhpotsdam.unfolding.geo.*; - -import processing.opengl.*; -import codeanticode.glgraphics.*; +import java.util.List; UnfoldingMap map; void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, P2D); smooth(); map = new UnfoldingMap(this); diff --git a/examples-processing/GeoRSSMarkerApp/GeoRSSMarkerApp.pde b/examples-processing/GeoRSSMarkerApp/GeoRSSMarkerApp.pde index 75f17eaa..499c4cac 100644 --- a/examples-processing/GeoRSSMarkerApp/GeoRSSMarkerApp.pde +++ b/examples-processing/GeoRSSMarkerApp/GeoRSSMarkerApp.pde @@ -12,23 +12,21 @@ import de.fhpotsdam.unfolding.*; import de.fhpotsdam.unfolding.core.*; import de.fhpotsdam.unfolding.data.*; import de.fhpotsdam.unfolding.geo.*; +import java.util.List; -import processing.opengl.*; -import codeanticode.glgraphics.*; - -String earthquakesURL = "http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-M5.xml"; +String earthquakesURL = "http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_week.atom"; UnfoldingMap map; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, P2D); smooth(); map = new UnfoldingMap(this); map.zoomToLevel(2); MapUtils.createDefaultEventDispatcher(this, map); - List features = GeoRSSReader.loadData(this, earthquakesURL); + List features = GeoRSSReader.loadDataGeoRSS(this, earthquakesURL); List markers = MapUtils.createSimpleMarkers(features); map.addMarkers(markers); } diff --git a/examples-processing/GeoRSSStyledMarkerApp/GeoRSSStyledMarkerApp.pde b/examples-processing/GeoRSSStyledMarkerApp/GeoRSSStyledMarkerApp.pde index 31e39fcf..5e8b0679 100644 --- a/examples-processing/GeoRSSStyledMarkerApp/GeoRSSStyledMarkerApp.pde +++ b/examples-processing/GeoRSSStyledMarkerApp/GeoRSSStyledMarkerApp.pde @@ -10,24 +10,21 @@ import de.fhpotsdam.unfolding.ui.*; import de.fhpotsdam.unfolding.*; import de.fhpotsdam.unfolding.data.*; import de.fhpotsdam.unfolding.geo.*; +import java.util.List; -import processing.opengl.*; -import codeanticode.glgraphics.*; - - -String earthquakesURL = "http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-M5.xml"; +String earthquakesURL = "http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_week.atom"; UnfoldingMap map; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, P2D); smooth(); map = new UnfoldingMap(this); map.zoomToLevel(2); MapUtils.createDefaultEventDispatcher(this, map); - List features = GeoRSSReader.loadData(this, earthquakesURL); + List features = GeoRSSReader.loadDataGeoRSS(this, earthquakesURL); MarkerFactory markerFactory = new MarkerFactory(); markerFactory.setPointClass(EarthquakeMarker.class); List markers = markerFactory.createMarkers(features); diff --git a/examples-processing/LabeledMarkerApp/LabeledMarker.java b/examples-processing/LabeledMarkerApp/LabeledMarker.java index 318e526d..9f24425c 100644 --- a/examples-processing/LabeledMarkerApp/LabeledMarker.java +++ b/examples-processing/LabeledMarkerApp/LabeledMarker.java @@ -32,7 +32,7 @@ public void draw(PGraphics pg, float x, float y) { pg.pushStyle(); pg.pushMatrix(); if (selected) { - pg.translate(0, 0, 1); + pg.translate(0, 0); } pg.strokeWeight(strokeWeight); if (selected) { diff --git a/examples-processing/LabeledMarkerApp/LabeledMarkerApp.pde b/examples-processing/LabeledMarkerApp/LabeledMarkerApp.pde index 18d0b619..0b98f981 100644 --- a/examples-processing/LabeledMarkerApp/LabeledMarkerApp.pde +++ b/examples-processing/LabeledMarkerApp/LabeledMarkerApp.pde @@ -14,6 +14,9 @@ import de.fhpotsdam.unfolding.utils.*; import de.fhpotsdam.unfolding.marker.*; import de.fhpotsdam.unfolding.data.*; import de.fhpotsdam.unfolding.geo.*; +import java.util.List; + +String earthquakesURL = "http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_week.atom"; UnfoldingMap map; @@ -26,7 +29,7 @@ void setup() { MapUtils.createDefaultEventDispatcher(this, map); // Load from GeoRSS file - List features = GeoRSSReader.loadData(this, "http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-M5.xml"); + List features = GeoRSSReader.loadDataGeoRSS(this, earthquakesURL); // Create (visible) markers from (data) features MarkerFactory markerFactory = new MarkerFactory(); markerFactory.setPointClass(LabeledMarker.class); diff --git a/examples-processing/MBTilesApp/MBTilesApp.pde b/examples-processing/MBTilesApp/MBTilesApp.pde index cc80453e..7f979fec 100644 --- a/examples-processing/MBTilesApp/MBTilesApp.pde +++ b/examples-processing/MBTilesApp/MBTilesApp.pde @@ -9,8 +9,6 @@ * For testing purposes and to keep the file size small, this example supports only three zoom levels. */ -import processing.opengl.*; -import codeanticode.glgraphics.*; import de.fhpotsdam.unfolding.*; import de.fhpotsdam.unfolding.geo.*; import de.fhpotsdam.unfolding.utils.*; @@ -19,17 +17,16 @@ import de.fhpotsdam.unfolding.providers.*; UnfoldingMap map; void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, P2D); - String mbTilesConnectionString = "jdbc:sqlite:"; - mbTilesConnectionString += sketchPath("data/blank-1-3.mbtiles"); + String mbTilesString = sketchPath("data/blank-1-3.mbtiles"); - map = new UnfoldingMap(this, new MBTilesMapProvider(mbTilesConnectionString)); + map = new UnfoldingMap(this, new MBTilesMapProvider(mbTilesString)); MapUtils.createDefaultEventDispatcher(this, map); map.setZoomRange(1, 3); } void draw() { + background(240); map.draw(); } - diff --git a/examples-processing/MarkerSelectionApp/MarkerSelectionApp.pde b/examples-processing/MarkerSelectionApp/MarkerSelectionApp.pde index d0d5c7c7..a09dba96 100644 --- a/examples-processing/MarkerSelectionApp/MarkerSelectionApp.pde +++ b/examples-processing/MarkerSelectionApp/MarkerSelectionApp.pde @@ -1,8 +1,8 @@ /** * Loads country markers, and highlights a polygon when the user hovers over it. * - * This example starts in Southeast Asia to demonstrate hovering multi-marker polygons such as Indonesia, Phillipines, - * etc. + * This example starts in Southeast Asia to demonstrate hovering multi-marker polygons + * such as Indonesia, Phillipines, etc. */ import de.fhpotsdam.unfolding.*; @@ -10,23 +10,21 @@ import de.fhpotsdam.unfolding.data.*; import de.fhpotsdam.unfolding.geo.*; import de.fhpotsdam.unfolding.marker.*; import de.fhpotsdam.unfolding.utils.*; - -import processing.opengl.*; -import codeanticode.glgraphics.*; +import java.util.*; UnfoldingMap map; -List countryMarkers = new ArrayList(); +List countryMarkers = new ArrayList(); Location indonesiaLocation = new Location(-6.175, 106.82); void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, P2D); map = new UnfoldingMap(this); map.zoomAndPanTo(indonesiaLocation, 3); MapUtils.createDefaultEventDispatcher(this, map); - List countries = GeoJSONReader.loadData(this, "countries.geo.json"); - List countryMarkers = MapUtils.createSimpleMarkers(countries); + List countries = GeoJSONReader.loadData(this, "countries.geo.json"); + List countryMarkers = MapUtils.createSimpleMarkers(countries); map.addMarkers(countryMarkers); } @@ -48,4 +46,3 @@ void mouseMoved() { marker.setSelected(true); } } - diff --git a/examples-processing/MultiProviderMultiMapApp/MultiProviderMultiMapApp.pde b/examples-processing/MultiProviderMultiMapApp/MultiProviderMultiMapApp.pde index 5800b2db..fcf1b99b 100644 --- a/examples-processing/MultiProviderMultiMapApp/MultiProviderMultiMapApp.pde +++ b/examples-processing/MultiProviderMultiMapApp/MultiProviderMultiMapApp.pde @@ -2,8 +2,6 @@ * Shows two independent maps side by side, with own interactions and different providers. */ -import processing.opengl.*; -import codeanticode.glgraphics.*; import de.fhpotsdam.unfolding.*; import de.fhpotsdam.unfolding.utils.*; import de.fhpotsdam.unfolding.providers.*; @@ -13,7 +11,7 @@ UnfoldingMap map1; UnfoldingMap map2; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, P2D); map1 = new UnfoldingMap(this, "map1", 10, 10, 385, 580, true, false, new Microsoft.AerialProvider()); map2 = new UnfoldingMap(this, "map2", 405, 10, 385, 580, true, false, new OpenStreetMap.OSMGrayProvider()); diff --git a/examples-processing/OverviewAndDetailMapApp/OverviewAndDetailMapApp.pde b/examples-processing/OverviewAndDetailMapApp/OverviewAndDetailMapApp.pde index 7115d0df..f342b042 100644 --- a/examples-processing/OverviewAndDetailMapApp/OverviewAndDetailMapApp.pde +++ b/examples-processing/OverviewAndDetailMapApp/OverviewAndDetailMapApp.pde @@ -7,8 +7,6 @@ * */ -import processing.opengl.*; -import codeanticode.glgraphics.*; import de.fhpotsdam.unfolding.*; import de.fhpotsdam.unfolding.geo.*; import de.fhpotsdam.unfolding.utils.*; @@ -19,7 +17,7 @@ UnfoldingMap mapDetail; UnfoldingMap mapOverview; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, P2D); mapDetail = new UnfoldingMap(this, "detail", 10, 10, 585, 580); mapDetail.setTweening(true); diff --git a/examples-processing/PanAnimationMapApp/PanAnimationMapApp.pde b/examples-processing/PanAnimationMapApp/PanAnimationMapApp.pde index f1b8f722..b8816fef 100644 --- a/examples-processing/PanAnimationMapApp/PanAnimationMapApp.pde +++ b/examples-processing/PanAnimationMapApp/PanAnimationMapApp.pde @@ -3,8 +3,6 @@ * * Press SPACE to switch tweening off (and on again). */ -import processing.opengl.*; -import codeanticode.glgraphics.*; import de.fhpotsdam.unfolding.*; import de.fhpotsdam.unfolding.geo.*; import de.fhpotsdam.unfolding.utils.*; @@ -17,7 +15,7 @@ Location[] locations = new Location[] { int currentLocation = 0; void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, P2D); map = new UnfoldingMap(this); map.setTweening(true); diff --git a/examples-processing/SimpleConversionMapApp/SimpleConversionMapApp.pde b/examples-processing/SimpleConversionMapApp/SimpleConversionMapApp.pde index e76278bf..b6da4332 100644 --- a/examples-processing/SimpleConversionMapApp/SimpleConversionMapApp.pde +++ b/examples-processing/SimpleConversionMapApp/SimpleConversionMapApp.pde @@ -1,15 +1,13 @@ -import processing.opengl.*; -import codeanticode.glgraphics.*; import de.fhpotsdam.unfolding.*; import de.fhpotsdam.unfolding.geo.*; import de.fhpotsdam.unfolding.utils.*; -de.fhpotsdam.unfolding.Map map; +UnfoldingMap map; void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, P2D); - map = new de.fhpotsdam.unfolding.Map(this); + map = new UnfoldingMap(this); MapUtils.createDefaultEventDispatcher(this, map); } diff --git a/examples-processing/SimpleMapApp/SimpleMapApp.pde b/examples-processing/SimpleMapApp/SimpleMapApp.pde index 94ccf6bc..ea68d942 100644 --- a/examples-processing/SimpleMapApp/SimpleMapApp.pde +++ b/examples-processing/SimpleMapApp/SimpleMapApp.pde @@ -2,8 +2,6 @@ * An application with a basic interactive map. You can zoom and pan the map. */ -import processing.opengl.*; -import codeanticode.glgraphics.*; import de.fhpotsdam.unfolding.*; import de.fhpotsdam.unfolding.geo.*; import de.fhpotsdam.unfolding.utils.*; @@ -11,7 +9,7 @@ import de.fhpotsdam.unfolding.utils.*; UnfoldingMap map; void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, P2D); map = new UnfoldingMap(this); map.zoomAndPanTo(new Location(52.5f, 13.4f), 10); diff --git a/examples-processing/SimpleMarkerApp/SimpleMarkerApp.pde b/examples-processing/SimpleMarkerApp/SimpleMarkerApp.pde index 471a5115..22b99cdb 100644 --- a/examples-processing/SimpleMarkerApp/SimpleMarkerApp.pde +++ b/examples-processing/SimpleMarkerApp/SimpleMarkerApp.pde @@ -1,19 +1,17 @@ -import processing.opengl.*; -import codeanticode.glgraphics.*; import de.fhpotsdam.unfolding.*; import de.fhpotsdam.unfolding.geo.*; import de.fhpotsdam.unfolding.utils.*; -de.fhpotsdam.unfolding.Map map; +UnfoldingMap map; Location locationBerlin = new Location(52.5f, 13.4f); Location locationLondon = new Location(51.5f, 0f); public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, P2D); noStroke(); - map = new de.fhpotsdam.unfolding.Map(this); + map = new UnfoldingMap(this); map.setTweening(true); map.zoomToLevel(3); map.panTo(new Location(40f, 8f)); diff --git a/examples-processing/TransitLineMarkerApp/TransitLineMarkerApp.pde b/examples-processing/TransitLineMarkerApp/TransitLineMarkerApp.pde index cfa7b391..034ff9bd 100644 --- a/examples-processing/TransitLineMarkerApp/TransitLineMarkerApp.pde +++ b/examples-processing/TransitLineMarkerApp/TransitLineMarkerApp.pde @@ -4,21 +4,20 @@ * This example shows how to load data features and create markers manually in order to map specific properties; in this * case the colors according to the MBTA schema. */ -import processing.opengl.*; -import codeanticode.glgraphics.*; import de.fhpotsdam.unfolding.*; import de.fhpotsdam.unfolding.geo.*; import de.fhpotsdam.unfolding.utils.*; import de.fhpotsdam.unfolding.providers.*; import de.fhpotsdam.unfolding.data.*; import de.fhpotsdam.unfolding.marker.*; +import java.util.List; Location bostonLocation = new Location(42.357778f, -71.061667f); UnfoldingMap map; void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); smooth(); map = new UnfoldingMap(this, new StamenMapProvider.TonerBackground()); diff --git a/examples/HelloUnfoldingWorld.java b/examples/HelloUnfoldingWorld.java index e694ab7b..6b54082e 100644 --- a/examples/HelloUnfoldingWorld.java +++ b/examples/HelloUnfoldingWorld.java @@ -1,5 +1,5 @@ import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.providers.OpenStreetMap; @@ -15,7 +15,7 @@ public class HelloUnfoldingWorld extends PApplet { UnfoldingMap map; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this, new OpenStreetMap.OpenStreetMapProvider()); map.zoomAndPanTo(new Location(52.5f, 13.4f), 10); diff --git a/examples/de/fhpotsdam/unfolding/examples/SimpleMapApp.java b/examples/de/fhpotsdam/unfolding/examples/SimpleMapApp.java index 10532e40..b827f3db 100644 --- a/examples/de/fhpotsdam/unfolding/examples/SimpleMapApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/SimpleMapApp.java @@ -1,7 +1,6 @@ package de.fhpotsdam.unfolding.examples; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -14,14 +13,18 @@ public class SimpleMapApp extends PApplet { UnfoldingMap map; public void setup() { - size(1024, 768, GLConstants.GLGRAPHICS); + size(1024, 768, P2D); map = new UnfoldingMap(this); - map.zoomAndPanTo(new Location(52.5f, 13.4f), 10); + map.zoomAndPanTo(new Location(6.316667f, 5.6f), 6); MapUtils.createDefaultEventDispatcher(this, map); } public void draw() { map.draw(); } + + public static void main(String args[]) { + PApplet.main(new String[] { SimpleMapApp.class.getName() }); + } } diff --git a/examples/de/fhpotsdam/unfolding/examples/SimplePositionConversionMapApp.java b/examples/de/fhpotsdam/unfolding/examples/SimplePositionConversionMapApp.java index 8f95979b..be4eda84 100644 --- a/examples/de/fhpotsdam/unfolding/examples/SimplePositionConversionMapApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/SimplePositionConversionMapApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.examples.marker.SimpleMarkerManagerApp; import de.fhpotsdam.unfolding.geo.Location; @@ -19,7 +19,7 @@ public class SimplePositionConversionMapApp extends PApplet { UnfoldingMap map; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); MapUtils.createDefaultEventDispatcher(this, map); diff --git a/examples/de/fhpotsdam/unfolding/examples/animation/FadeTwoMapsApp.java b/examples/de/fhpotsdam/unfolding/examples/animation/FadeTwoMapsApp.java index 3585fdeb..4f0a28e9 100644 --- a/examples/de/fhpotsdam/unfolding/examples/animation/FadeTwoMapsApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/animation/FadeTwoMapsApp.java @@ -12,10 +12,10 @@ * Press key '1' to fade once, and press key '2' to start fading animation. */ public class FadeTwoMapsApp extends PApplet { - + UnfoldingMap map1; UnfoldingMap map2; - + // Create and set variable we need to fade between our two maps. boolean fadeOnce = false; boolean fadeAlways = false; @@ -23,20 +23,19 @@ public class FadeTwoMapsApp extends PApplet { int fadeDelta = 5; int fadeMin = 0; int fadeMax = 255; - - + public void setup() { - size(600, 400); + size(600, 400, OPENGL); // Set the position and size of our two maps. int mapXposition = 0; int mapYposition = 30; int mapWidth = width; - int mapHeight = height-mapYposition; + int mapHeight = height - mapYposition; // Set our location of the maps float lon = 52.5f; float lat = 13.4f; - + // Initialize two maps map1 = new UnfoldingMap(this, mapXposition, mapYposition, mapWidth, mapHeight); map1.zoomAndPanTo(new Location(lon, lat), 10); @@ -44,40 +43,39 @@ public void setup() { map2.zoomAndPanTo(new Location(lon, lat), 10); MapUtils.createDefaultEventDispatcher(this, map1, map2); } - - + public void draw() { background(0); - + // Calculate Fade Value - if(fadeAlways == true){ + if (fadeAlways == true) { fadeOnce = false; - if(fadeVal == 0 || fadeVal == 255) + if (fadeVal == 0 || fadeVal == 255) fadeDelta = -fadeDelta; - fadeVal+= fadeDelta; + fadeVal += fadeDelta; } - - if(fadeOnce == true){ - if(fadeVal == 0 || fadeVal == 255){ + + if (fadeOnce == true) { + if (fadeVal == 0 || fadeVal == 255) { fadeDelta = -fadeDelta; fadeOnce = false; } - fadeVal+= fadeDelta; + fadeVal += fadeDelta; } - + // Draw maps tint(255); map1.draw(); tint(255, fadeVal); map2.draw(); - + // Description at the Top fill(255); text("Press key '1' to fade once | Press key '2' to fade always", 10, 20); } - - public void keyPressed(){ - switch(key){ + + public void keyPressed() { + switch (key) { case '1': fadeAlways = false; fadeOnce = true; @@ -88,9 +86,8 @@ public void keyPressed(){ break; } } - - + public static void main(String[] args) { - PApplet.main(new String[] {"de.fhpotsdam.unfolding.examples.animation.FadeTwoMapsApp"}); + PApplet.main(new String[] { "de.fhpotsdam.unfolding.examples.animation.FadeTwoMapsApp" }); } } diff --git a/examples/de/fhpotsdam/unfolding/examples/animation/PanAnimationMapApp.java b/examples/de/fhpotsdam/unfolding/examples/animation/PanAnimationMapApp.java index 50e104fc..153dd1ec 100644 --- a/examples/de/fhpotsdam/unfolding/examples/animation/PanAnimationMapApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/animation/PanAnimationMapApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.animation; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.examples.interaction.NaviButtonMapApp; import de.fhpotsdam.unfolding.geo.Location; @@ -23,7 +23,7 @@ public class PanAnimationMapApp extends PApplet { int currentLocation = 0; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); map.setTweening(true); diff --git a/examples/de/fhpotsdam/unfolding/examples/data/GPXTrackApp.java b/examples/de/fhpotsdam/unfolding/examples/data/GPXTrackApp.java index 5f84a466..4fca134d 100644 --- a/examples/de/fhpotsdam/unfolding/examples/data/GPXTrackApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/data/GPXTrackApp.java @@ -3,16 +3,18 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.data.Feature; import de.fhpotsdam.unfolding.data.GPXReader; +import de.fhpotsdam.unfolding.examples.data.customreader.GPXSpeedTrackApp; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.marker.Marker; import de.fhpotsdam.unfolding.utils.MapUtils; /** - * Displays a track loaded from a GPX file containing a bike tour in Berlin. + * Displays a track loaded from a GPX file containing a bike tour in Berlin. + * + * See {@link GPXSpeedTrackApp} for custom GPX parsing and marker display. */ public class GPXTrackApp extends PApplet { @@ -21,7 +23,7 @@ public class GPXTrackApp extends PApplet { Location startLocation = new Location(52.49f, 13.44f); public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); MapUtils.createDefaultEventDispatcher(this, map); diff --git a/examples/de/fhpotsdam/unfolding/examples/data/GeoJSONMarkerApp.java b/examples/de/fhpotsdam/unfolding/examples/data/GeoJSONMarkerApp.java index 35fb9201..7cb7e702 100644 --- a/examples/de/fhpotsdam/unfolding/examples/data/GeoJSONMarkerApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/data/GeoJSONMarkerApp.java @@ -3,7 +3,7 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.data.Feature; import de.fhpotsdam.unfolding.data.GeoJSONReader; @@ -22,7 +22,7 @@ public class GeoJSONMarkerApp extends PApplet { UnfoldingMap map; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); smooth(); map = new UnfoldingMap(this, 50, 50, 700, 500); diff --git a/examples/de/fhpotsdam/unfolding/examples/data/GeoRSSMarkerApp.java b/examples/de/fhpotsdam/unfolding/examples/data/GeoRSSMarkerApp.java index 67bf9d8d..397ae862 100644 --- a/examples/de/fhpotsdam/unfolding/examples/data/GeoRSSMarkerApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/data/GeoRSSMarkerApp.java @@ -3,7 +3,6 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.data.Feature; import de.fhpotsdam.unfolding.data.GeoRSSReader; @@ -13,25 +12,25 @@ /** * Displays earthquake markers from an RSS feed for the last 7 days. * - * Reads from GeoRSS file, and uses default marker creation. + * Reads from GeoRSS file, and uses default marker creation. * * Features are points (positions of earthquakes). */ public class GeoRSSMarkerApp extends PApplet { - String earthquakesURL = "http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-M5.xml"; + String earthquakesURL = "http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_week.atom"; UnfoldingMap map; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); smooth(); map = new UnfoldingMap(this); map.zoomToLevel(2); MapUtils.createDefaultEventDispatcher(this, map); - List features = GeoRSSReader.loadData(this, earthquakesURL); + List features = GeoRSSReader.loadDataGeoRSS(this, earthquakesURL); List markers = MapUtils.createSimpleMarkers(features); map.addMarkers(markers); } diff --git a/examples/de/fhpotsdam/unfolding/examples/data/TransitLinesMarkerApp.java b/examples/de/fhpotsdam/unfolding/examples/data/TransitLinesMarkerApp.java index b8ffbb2e..cebe20e9 100644 --- a/examples/de/fhpotsdam/unfolding/examples/data/TransitLinesMarkerApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/data/TransitLinesMarkerApp.java @@ -4,7 +4,7 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.data.Feature; import de.fhpotsdam.unfolding.data.GeoJSONReader; @@ -28,7 +28,7 @@ public class TransitLinesMarkerApp extends PApplet { UnfoldingMap map; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, P2D); smooth(); map = new UnfoldingMap(this, new StamenMapProvider.TonerBackground()); diff --git a/examples/de/fhpotsdam/unfolding/examples/data/choropleth/ChoroplethMapApp.java b/examples/de/fhpotsdam/unfolding/examples/data/choropleth/ChoroplethMapApp.java index 62f17432..54cfc876 100644 --- a/examples/de/fhpotsdam/unfolding/examples/data/choropleth/ChoroplethMapApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/data/choropleth/ChoroplethMapApp.java @@ -4,7 +4,7 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.data.Feature; import de.fhpotsdam.unfolding.data.GeoJSONReader; @@ -27,7 +27,7 @@ public class ChoroplethMapApp extends PApplet { List countryMarkers; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); smooth(); map = new UnfoldingMap(this, 50, 50, 700, 500); diff --git a/examples/de/fhpotsdam/unfolding/examples/data/countrydata/CountryBubbleMapApp.java b/examples/de/fhpotsdam/unfolding/examples/data/countrydata/CountryBubbleMapApp.java index 89c16750..12f163b9 100644 --- a/examples/de/fhpotsdam/unfolding/examples/data/countrydata/CountryBubbleMapApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/data/countrydata/CountryBubbleMapApp.java @@ -4,7 +4,7 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.data.Feature; import de.fhpotsdam.unfolding.data.GeoJSONReader; @@ -29,7 +29,7 @@ public class CountryBubbleMapApp extends PApplet { List countryMarkers; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); smooth(); map = new UnfoldingMap(this); diff --git a/examples/de/fhpotsdam/unfolding/examples/data/customreader/ColoredLinesMarker.java b/examples/de/fhpotsdam/unfolding/examples/data/customreader/ColoredLinesMarker.java index 04ad5e17..a5b4d620 100644 --- a/examples/de/fhpotsdam/unfolding/examples/data/customreader/ColoredLinesMarker.java +++ b/examples/de/fhpotsdam/unfolding/examples/data/customreader/ColoredLinesMarker.java @@ -25,12 +25,13 @@ protected void draw(PGraphics pg, List mapPositions, HashMap speedList = (List) properties.get("speedList"); MapPosition oldPos = null; for (int i = 0; i < mapPositions.size(); i++) { MapPosition pos = mapPositions.get(i); - if (i > 0) { + if (i > 0) { // Draw a line pg.strokeWeight(4); // Map speed to color of line diff --git a/examples/de/fhpotsdam/unfolding/examples/data/customreader/GPXSpeedReader.java b/examples/de/fhpotsdam/unfolding/examples/data/customreader/GPXSpeedReader.java index 9ccd8ec3..8af4a9e2 100644 --- a/examples/de/fhpotsdam/unfolding/examples/data/customreader/GPXSpeedReader.java +++ b/examples/de/fhpotsdam/unfolding/examples/data/customreader/GPXSpeedReader.java @@ -6,7 +6,7 @@ import java.util.List; import processing.core.PApplet; -import processing.xml.XMLElement; +import processing.data.XML; import de.fhpotsdam.unfolding.data.Feature; import de.fhpotsdam.unfolding.data.Feature.FeatureType; import de.fhpotsdam.unfolding.data.GPXReader; @@ -33,7 +33,7 @@ public static List loadData(PApplet p, String gpxFilename) { List trackFeatures = new ArrayList(); // Load GPX file - XMLElement gpx = new XMLElement(p, gpxFilename); + XML gpx = p.loadXML(gpxFilename); Calendar prevTime = null; Location prevLocation = null; @@ -42,19 +42,19 @@ public static List loadData(PApplet p, String gpxFilename) { ShapeFeature trackFeature = new ShapeFeature(FeatureType.LINES); List speedList = new ArrayList(); - XMLElement[] itemXMLElements = gpx.getChildren("trk/trkseg/trkpt"); - for (int i = 0; i < itemXMLElements.length; i++) { + XML[] itemXML = gpx.getChildren("trk/trkseg/trkpt"); + for (int i = 0; i < itemXML.length; i++) { // Adds location for track point - float lat = itemXMLElements[i].getFloat("lat"); - float lon = itemXMLElements[i].getFloat("lon"); + float lat = itemXML[i].getFloat("lat"); + float lon = itemXML[i].getFloat("lon"); Location location = new Location(lat, lon); // Calculates speed for track point // Uses time span (h) and distance (km) to previous point to get km/h double speed = 0; try { - String timeStr = itemXMLElements[i].getChild("time").getContent(); + String timeStr = itemXML[i].getChild("time").getContent(); // Replace "Z" for Zulu/GMT time with parseable hour offset timeStr = timeStr.replaceAll("Z", "+0000"); Calendar time = StringUtils.parseIsoDateTime(timeStr); diff --git a/examples/de/fhpotsdam/unfolding/examples/data/customreader/GPXSpeedTrackApp.java b/examples/de/fhpotsdam/unfolding/examples/data/customreader/GPXSpeedTrackApp.java index b7142365..421913e4 100644 --- a/examples/de/fhpotsdam/unfolding/examples/data/customreader/GPXSpeedTrackApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/data/customreader/GPXSpeedTrackApp.java @@ -3,7 +3,7 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.data.Feature; import de.fhpotsdam.unfolding.data.MarkerFactory; @@ -24,7 +24,7 @@ public class GPXSpeedTrackApp extends PApplet { Location startLocation = new Location(52.49f, 13.44f); public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); MapUtils.createDefaultEventDispatcher(this, map); diff --git a/examples/de/fhpotsdam/unfolding/examples/data/styled/GeoRSSStyledMarkerApp.java b/examples/de/fhpotsdam/unfolding/examples/data/styled/GeoRSSStyledMarkerApp.java index e84513b9..32ec639b 100644 --- a/examples/de/fhpotsdam/unfolding/examples/data/styled/GeoRSSStyledMarkerApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/data/styled/GeoRSSStyledMarkerApp.java @@ -3,7 +3,6 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.data.Feature; import de.fhpotsdam.unfolding.data.GeoRSSReader; @@ -18,19 +17,19 @@ */ public class GeoRSSStyledMarkerApp extends PApplet { - String earthquakesURL = "http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-M5.xml"; + String earthquakesURL = "http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_week.atom"; UnfoldingMap map; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); smooth(); map = new UnfoldingMap(this); map.zoomToLevel(2); MapUtils.createDefaultEventDispatcher(this, map); - List features = GeoRSSReader.loadData(this, earthquakesURL); + List features = GeoRSSReader.loadDataGeoRSS(this, earthquakesURL); MarkerFactory markerFactory = new MarkerFactory(); markerFactory.setPointClass(EarthquakeMarker.class); List markers = markerFactory.createMarkers(features); diff --git a/examples/de/fhpotsdam/unfolding/examples/distance/GetDistanceApp.java b/examples/de/fhpotsdam/unfolding/examples/distance/GetDistanceApp.java index 13b1d08b..3068812a 100644 --- a/examples/de/fhpotsdam/unfolding/examples/distance/GetDistanceApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/distance/GetDistanceApp.java @@ -15,7 +15,7 @@ public class GetDistanceApp extends PApplet { UnfoldingMap map; public void setup() { - size(600, 600); + size(600, 600, OPENGL); map = new UnfoldingMap(this); map.zoomAndPanTo(new Location(52.5f, 13.4f), 10); diff --git a/examples/de/fhpotsdam/unfolding/examples/distance/GreatCircleConnectionApp.java b/examples/de/fhpotsdam/unfolding/examples/distance/GreatCircleConnectionApp.java index 006c1761..8b94f984 100644 --- a/examples/de/fhpotsdam/unfolding/examples/distance/GreatCircleConnectionApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/distance/GreatCircleConnectionApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.distance; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.GeoUtils; @@ -25,7 +25,7 @@ public class GreatCircleConnectionApp extends PApplet { Location targetLocation = moscowLocation; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); map.zoomTo(2); diff --git a/examples/de/fhpotsdam/unfolding/examples/events/AllTilesLoadedApp.java b/examples/de/fhpotsdam/unfolding/examples/events/AllTilesLoadedApp.java index 55f7698a..83135f67 100644 --- a/examples/de/fhpotsdam/unfolding/examples/events/AllTilesLoadedApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/events/AllTilesLoadedApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.events; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -17,7 +17,7 @@ public class AllTilesLoadedApp extends PApplet { UnfoldingMap map; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); MapUtils.createDefaultEventDispatcher(this, map); diff --git a/examples/de/fhpotsdam/unfolding/examples/events/ComplexMapEventApp.java b/examples/de/fhpotsdam/unfolding/examples/events/ComplexMapEventApp.java index f2b46180..8b02f76c 100644 --- a/examples/de/fhpotsdam/unfolding/examples/events/ComplexMapEventApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/events/ComplexMapEventApp.java @@ -6,7 +6,7 @@ import org.apache.log4j.Logger; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.events.EventDispatcher; import de.fhpotsdam.unfolding.events.MapEventListener; @@ -51,7 +51,7 @@ public class ComplexMapEventApp extends PApplet { DebugDisplay debugDisplay3; public void setup() { - size(1240, 420, GLConstants.GLGRAPHICS); + size(1240, 420, OPENGL); smooth(); // Creates non-default dispatcher to register own broadcasters and listeners. diff --git a/examples/de/fhpotsdam/unfolding/examples/events/InternalMapEventListenerApp.java b/examples/de/fhpotsdam/unfolding/examples/events/InternalMapEventListenerApp.java index b4882666..78c71e00 100644 --- a/examples/de/fhpotsdam/unfolding/examples/events/InternalMapEventListenerApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/events/InternalMapEventListenerApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.events; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.events.EventDispatcher; import de.fhpotsdam.unfolding.events.MapEvent; @@ -25,7 +25,7 @@ public class InternalMapEventListenerApp extends PApplet implements MapEventList Location oldLocation = new Location(0, 0); public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this, "myMap"); EventDispatcher eventDispatcher = MapUtils.createDefaultEventDispatcher(this, map); diff --git a/examples/de/fhpotsdam/unfolding/examples/events/MapChangedApp.java b/examples/de/fhpotsdam/unfolding/examples/events/MapChangedApp.java index 7c0c2a76..b0e88a3f 100644 --- a/examples/de/fhpotsdam/unfolding/examples/events/MapChangedApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/events/MapChangedApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.events; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.events.MapEvent; import de.fhpotsdam.unfolding.events.ZoomMapEvent; @@ -22,7 +22,7 @@ public class MapChangedApp extends PApplet { float rectSizeDiff; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); map.setTweening(true); diff --git a/examples/de/fhpotsdam/unfolding/examples/image/ImageOverlayApp.java b/examples/de/fhpotsdam/unfolding/examples/image/ImageOverlayApp.java index f814d89b..1765ac5e 100644 --- a/examples/de/fhpotsdam/unfolding/examples/image/ImageOverlayApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/image/ImageOverlayApp.java @@ -2,7 +2,7 @@ import processing.core.PApplet; import processing.core.PImage; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.providers.Microsoft; @@ -15,8 +15,8 @@ * are used to position and scale the image. (There is no tile mechanism for the overlay image). * * In this example, the image shows from where people take pictures of famous sights. The visualization is laid over a - * satellite map. Below, you can see how people photograph the Hans-Otto-Theater in Potsdam, Germany. - * See http://schwinki.de/splendor/ for more information. + * satellite map. Below, you can see how people photograph the Hans-Otto-Theater in Potsdam, Germany. See + * http://schwinki.de/splendor/ for more information. * */ public class ImageOverlayApp extends PApplet { @@ -28,16 +28,16 @@ public class ImageOverlayApp extends PApplet { PImage visImg; - // Kaiserbahnhof Potsdam, 52.394667¡, 13.013944¡ (west) - // Meierei, 52.421944¡, 13.069722¡ (north) - // Schloss Babelsberg, 52.407639¡, 13.093289¡ (east) - // Potsdam Hauptbahnhof, 52.391667¡, 13.066667¡ (south) + // Kaiserbahnhof Potsdam, 52.39466, 13.013944 (west) + // Meierei, 52.421944, 13.069722 (north) + // Schloss Babelsberg, 52.407639, 13.093289 (east) + // Potsdam Hauptbahnhof, 52.391667, 13.066667 (south) Location visNorthWest = new Location(52.421944, 13.013944); Location visSouthEast = new Location(52.391667, 13.093289); public void setup() { - size(1400, 800, GLConstants.GLGRAPHICS); + size(1400, 800, OPENGL); // Very low quality for file size reasons. Use original from http://schwinki.de/splendor/ visImg = loadImage("test/splendor-big.jpg"); diff --git a/examples/de/fhpotsdam/unfolding/examples/image/LargeMapImageSaveApp.java b/examples/de/fhpotsdam/unfolding/examples/image/LargeMapImageSaveApp.java index dc403c89..3a529e5d 100644 --- a/examples/de/fhpotsdam/unfolding/examples/image/LargeMapImageSaveApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/image/LargeMapImageSaveApp.java @@ -1,22 +1,13 @@ package de.fhpotsdam.unfolding.examples.image; import processing.core.PApplet; -import processing.core.PGraphics; -import processing.core.PImage; -import codeanticode.glgraphics.GLConstants; -import codeanticode.glgraphics.GLGraphicsOffScreen; import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; +import de.fhpotsdam.unfolding.utils.LargeMapImageUtils; import de.fhpotsdam.unfolding.utils.MapUtils; /** - * Creates large map images, stitched together from multiple tiles. Saves a single large image with a map around the - * given location at the given zoom level. Initializes map, makes screen-shot, pans automatically, and repeats until it - * is finished. - * - * To customize, set location, zoomLevel, and totalWidth and totalHeight. The latter two should be multiples of xStep - * and yStep. Please note the respective terms of service of the map provider. - * + * Uses LargeMapImageUtils to create a large map image, stitched together from multiple map screenshots. */ public class LargeMapImageSaveApp extends PApplet { @@ -25,89 +16,35 @@ public class LargeMapImageSaveApp extends PApplet { // Set to zoom level you want to grab. int zoomLevel = 9; - int xStep = 500; - int yStep = 500; - int totalWidth = xStep * 4; - int totalHeight = yStep * 4; - - int shotX = 0; - int shotY = 0; UnfoldingMap map; - PGraphics largeImage; - boolean tilesLoaded = false; + + LargeMapImageUtils lmiUtils; public void setup() { - size(xStep, yStep, GLConstants.GLGRAPHICS); + size(500, 500, OPENGL); map = new UnfoldingMap(this); map.zoomAndPanTo(location, zoomLevel); MapUtils.createDefaultEventDispatcher(this, map); println("Init large map image."); - largeImage = createGraphics(totalWidth, totalHeight, P2D); - - map.panBy(totalWidth / 2 - xStep / 2, totalHeight / 2 - yStep / 2); + lmiUtils = new LargeMapImageUtils(this, map); } public void draw() { map.draw(); - if (tilesLoaded) { - renderAndMakeSnapshot(shotX, shotY); - - shotX += xStep; - if (shotX >= totalWidth) { - shotX = 0; - shotY += yStep; - // Return back to the right, and go one down - map.panBy(totalWidth - xStep, -yStep); - } - else { - // Go left - map.panBy(-xStep, 0); - } - - if (shotY >= totalHeight) { - saveLargeImage(); - exit(); - } - - tilesLoaded = false; - } - } - - public void saveLargeImage() { - largeImage.save("largeMap.png"); - println("Saving large map image."); + lmiUtils.run(); } - public void renderAndMakeSnapshot(int shotX, int shotY) { - println("Making snapshot for " + shotX + ", " + shotY); - PImage currentImage = makeSnapshot(); - largeImage.image(currentImage, shotX, shotY); - } - - public void tilesLoaded() { - println("All tiles loaded."); - tilesLoaded = true; - } - - public PImage makeSnapshot() { - return makeSnapshot((int) map.mapDisplay.getWidth(), (int) map.mapDisplay.getHeight()); - } - - public PImage makeSnapshot(int width, int height) { - PImage thumbnail; - - PGraphics pg = map.mapDisplay.getInnerPG(); - if (pg instanceof GLGraphicsOffScreen) { - println("Creating new thumbnail"); - thumbnail = new PImage(width, height); - ((GLGraphicsOffScreen) pg).getTexture().getImage(thumbnail); - } else { - thumbnail = pg.get(); + public void keyPressed() { + if (key == 's') { + // Around current center and with current zoom level + lmiUtils.init(); + } + if (key == 'b') { + // Around set center and zoom level (pans there before screenshoting) + lmiUtils.init(location, zoomLevel); } - - return thumbnail; } } diff --git a/examples/de/fhpotsdam/unfolding/examples/image/SmallImageOverlayApp.java b/examples/de/fhpotsdam/unfolding/examples/image/SmallImageOverlayApp.java index 78a66145..62b2a3fe 100644 --- a/examples/de/fhpotsdam/unfolding/examples/image/SmallImageOverlayApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/image/SmallImageOverlayApp.java @@ -2,7 +2,7 @@ import processing.core.PApplet; import processing.core.PImage; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.providers.Microsoft; @@ -27,7 +27,7 @@ public class SmallImageOverlayApp extends PApplet { Location visSouthEast = new Location(52.391667, 13.066667); public void setup() { - size(1400, 800, GLConstants.GLGRAPHICS); + size(1400, 800, OPENGL); visImg = loadImage("test/splendor-cutout.png"); diff --git a/examples/de/fhpotsdam/unfolding/examples/interaction/ConstrainedBoxMapApp.java b/examples/de/fhpotsdam/unfolding/examples/interaction/ConstrainedBoxMapApp.java index 9668d229..f27070d8 100644 --- a/examples/de/fhpotsdam/unfolding/examples/interaction/ConstrainedBoxMapApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/interaction/ConstrainedBoxMapApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.interaction; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.events.MapEvent; import de.fhpotsdam.unfolding.geo.Location; @@ -21,7 +21,7 @@ public class ConstrainedBoxMapApp extends PApplet { Location boundBottomRight = new Location(52.0, 14.5); public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); map.zoomAndPanTo(new Location(52.5, 13.4f), 10); diff --git a/examples/de/fhpotsdam/unfolding/examples/interaction/ConstrainedMapApp.java b/examples/de/fhpotsdam/unfolding/examples/interaction/ConstrainedMapApp.java index cc8d9b78..f7dc7403 100644 --- a/examples/de/fhpotsdam/unfolding/examples/interaction/ConstrainedMapApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/interaction/ConstrainedMapApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.interaction; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -18,7 +18,7 @@ public class ConstrainedMapApp extends PApplet { float maxPanningDistance = 30; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); map.zoomAndPanTo(new Location(centerLocation), 12); diff --git a/examples/de/fhpotsdam/unfolding/examples/interaction/NaviButtonMapApp.java b/examples/de/fhpotsdam/unfolding/examples/interaction/NaviButtonMapApp.java index b1b9a0a3..e2ee2743 100644 --- a/examples/de/fhpotsdam/unfolding/examples/interaction/NaviButtonMapApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/interaction/NaviButtonMapApp.java @@ -2,7 +2,7 @@ import processing.core.PApplet; import processing.core.PFont; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -21,7 +21,7 @@ public class NaviButtonMapApp extends PApplet { PFont font; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); smooth(); font = createFont("sans-serif", 14); diff --git a/examples/de/fhpotsdam/unfolding/examples/interaction/NaviButtonMapEventsApp.java b/examples/de/fhpotsdam/unfolding/examples/interaction/NaviButtonMapEventsApp.java index 7d078b04..0589ecb9 100644 --- a/examples/de/fhpotsdam/unfolding/examples/interaction/NaviButtonMapEventsApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/interaction/NaviButtonMapEventsApp.java @@ -2,7 +2,7 @@ import processing.core.PApplet; import processing.core.PFont; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.events.EventDispatcher; import de.fhpotsdam.unfolding.events.PanMapEvent; @@ -30,7 +30,7 @@ public class NaviButtonMapEventsApp extends PApplet { EventDispatcher eventDispatcher; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); smooth(); font = createFont("sans-serif", 14); diff --git a/examples/de/fhpotsdam/unfolding/examples/interaction/UIOnMapApp.java b/examples/de/fhpotsdam/unfolding/examples/interaction/UIOnMapApp.java deleted file mode 100644 index a8a39181..00000000 --- a/examples/de/fhpotsdam/unfolding/examples/interaction/UIOnMapApp.java +++ /dev/null @@ -1,41 +0,0 @@ -package de.fhpotsdam.unfolding.examples.interaction; - -import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; -import de.fhpotsdam.unfolding.UnfoldingMap; -import de.fhpotsdam.unfolding.providers.Google; -import de.fhpotsdam.unfolding.utils.MapUtils; - -public class UIOnMapApp extends PApplet { - - UnfoldingMap map; - float uiX = 20, uiY = 20, uiWidth = 300, uiHeight = 60; - - public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); - - map = new UnfoldingMap(this, new Google.GoogleMapProvider()); - MapUtils.createDefaultEventDispatcher(this, map); - } - - public void draw() { - map.draw(); - - fill(0, 200); - rect(uiX, uiY, uiWidth, uiHeight); - } - - public void mouseDragged() { - if (isOverUI(mouseX, mouseY)) { - // react to UI buttons or whatnot - } - else { - map.panBy(mouseX - pmouseX, mouseY - pmouseY); - } - } - - public boolean isOverUI(float x, float y) { - return x > uiX && x < uiX + uiWidth && y > uiY && y < uiY + height; - } - -} diff --git a/examples/de/fhpotsdam/unfolding/examples/interaction/multitouch/MultitouchMapApp.java b/examples/de/fhpotsdam/unfolding/examples/interaction/multitouch/MultitouchMapApp.java index 2374b041..98072dbe 100644 --- a/examples/de/fhpotsdam/unfolding/examples/interaction/multitouch/MultitouchMapApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/interaction/multitouch/MultitouchMapApp.java @@ -3,7 +3,6 @@ import org.apache.log4j.Logger; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.events.EventDispatcher; import de.fhpotsdam.unfolding.interactions.TuioCursorHandler; @@ -30,9 +29,9 @@ public class MultitouchMapApp extends PApplet { public void setup() { if (FULLSCREEN) { - size(1920, 1080, GLConstants.GLGRAPHICS); + size(1920, 1080, OPENGL); } else { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); } // Init the map @@ -59,8 +58,8 @@ public void draw() { } public static void main(String[] args) { - String[] params = new String[] { "--present", "--bgcolor=#000000", "--hide-stop", "--exclusive", - "de.fhpotsdam.unfolding.examples.interaction.MultitouchMapApp" }; + String[] params = new String[] { "--present", "--bgcolor=#000000", "--hide-stop", + "de.fhpotsdam.unfolding.examples.interaction.multitouch.MultitouchMapApp" }; FULLSCREEN = true; PApplet.main(params); } diff --git a/examples/de/fhpotsdam/unfolding/examples/interaction/multitouch/MultitouchMapExternalTuioApp.java b/examples/de/fhpotsdam/unfolding/examples/interaction/multitouch/MultitouchMapExternalTuioApp.java index 89dadc88..c1fe9e49 100644 --- a/examples/de/fhpotsdam/unfolding/examples/interaction/multitouch/MultitouchMapExternalTuioApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/interaction/multitouch/MultitouchMapExternalTuioApp.java @@ -8,7 +8,7 @@ import TUIO.TuioListener; import TUIO.TuioObject; import TUIO.TuioTime; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.events.EventDispatcher; import de.fhpotsdam.unfolding.geo.Location; @@ -38,14 +38,14 @@ public class MultitouchMapExternalTuioApp extends PApplet implements TuioListene int buttonSize = 40; public static void main(String[] args) { - String[] params = new String[] { "--present", "--bgcolor=#000000", "--hide-stop", "--exclusive", - "de.fhpotsdam.unfolding.examples.interaction.MultitouchMapExternalTuioApp" }; + String[] params = new String[] { "--present", "--bgcolor=#000000", "--hide-stop", + "de.fhpotsdam.unfolding.examples.interaction.multitouch.MultitouchMapExternalTuioApp" }; PApplet.main(params); } public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); - //size(1920, 1080, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); + // size(1920, 1080, OPENGL); map = new UnfoldingMap(this); map.setTweening(false); diff --git a/examples/de/fhpotsdam/unfolding/examples/interaction/snapshot/CircularMapSnapshotApp.java b/examples/de/fhpotsdam/unfolding/examples/interaction/snapshot/CircularMapSnapshotApp.java index f4456abc..97659d29 100644 --- a/examples/de/fhpotsdam/unfolding/examples/interaction/snapshot/CircularMapSnapshotApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/interaction/snapshot/CircularMapSnapshotApp.java @@ -4,7 +4,7 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.providers.StamenMapProvider; @@ -25,7 +25,7 @@ public class CircularMapSnapshotApp extends PApplet { List mapSnapshots = new ArrayList(); public void setup() { - size(600, 400, GLConstants.GLGRAPHICS); + size(600, 400, OPENGL); map = new UnfoldingMap(this, 0, 0, 400, 400, new StamenMapProvider.WaterColor()); map.zoomAndPanTo(new Location(51.507222, -0.1275), 10); diff --git a/examples/de/fhpotsdam/unfolding/examples/interaction/snapshot/ComplexMapSnapshotApp.java b/examples/de/fhpotsdam/unfolding/examples/interaction/snapshot/ComplexMapSnapshotApp.java index 9cebb8f4..560ad05c 100644 --- a/examples/de/fhpotsdam/unfolding/examples/interaction/snapshot/ComplexMapSnapshotApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/interaction/snapshot/ComplexMapSnapshotApp.java @@ -4,7 +4,7 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.marker.SimplePointMarker; @@ -24,7 +24,7 @@ public class ComplexMapSnapshotApp extends PApplet { List mapSnapshots = new ArrayList(); public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); map.zoomAndPanTo(new Location(52.5f, 13.4f), 10); diff --git a/examples/de/fhpotsdam/unfolding/examples/interaction/snapshot/MapSnapshot.java b/examples/de/fhpotsdam/unfolding/examples/interaction/snapshot/MapSnapshot.java index d7360a03..1b3d3337 100644 --- a/examples/de/fhpotsdam/unfolding/examples/interaction/snapshot/MapSnapshot.java +++ b/examples/de/fhpotsdam/unfolding/examples/interaction/snapshot/MapSnapshot.java @@ -3,7 +3,6 @@ import processing.core.PApplet; import processing.core.PGraphics; import processing.core.PImage; -import codeanticode.glgraphics.GLGraphicsOffScreen; import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; @@ -41,12 +40,7 @@ public void snapshot(UnfoldingMap map) { // Stores image data of the current map PGraphics pg = map.mapDisplay.getOuterPG(); - if (pg instanceof GLGraphicsOffScreen) { - thumbnail = new PImage((int) map.mapDisplay.getWidth(), (int) map.mapDisplay.getHeight()); - ((GLGraphicsOffScreen) pg).getTexture().getImage(thumbnail); - } else { - thumbnail = pg.get(); - } + thumbnail = pg.get(); } public void set(float x, float y, float width, float height) { diff --git a/examples/de/fhpotsdam/unfolding/examples/interaction/snapshot/MapSnapshotApp.java b/examples/de/fhpotsdam/unfolding/examples/interaction/snapshot/MapSnapshotApp.java index f616a7d0..5b34eb21 100644 --- a/examples/de/fhpotsdam/unfolding/examples/interaction/snapshot/MapSnapshotApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/interaction/snapshot/MapSnapshotApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.interaction.snapshot; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -19,7 +19,7 @@ public class MapSnapshotApp extends PApplet { MapSnapshot mapSnapshot; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); map.zoomAndPanTo(new Location(52.5f, 13.4f), 10); diff --git a/examples/de/fhpotsdam/unfolding/examples/marker/MarkerSelectionApp.java b/examples/de/fhpotsdam/unfolding/examples/marker/MarkerSelectionApp.java index 16326ced..cba06f23 100644 --- a/examples/de/fhpotsdam/unfolding/examples/marker/MarkerSelectionApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/marker/MarkerSelectionApp.java @@ -4,7 +4,7 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.data.Feature; import de.fhpotsdam.unfolding.data.GeoJSONReader; @@ -25,13 +25,13 @@ public class MarkerSelectionApp extends PApplet { Location indonesiaLocation = new Location(-6.175, 106.82); public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); map.zoomAndPanTo(indonesiaLocation, 3); MapUtils.createDefaultEventDispatcher(this, map); - List countries = GeoJSONReader.loadData(this, "data/ountries.geo.json"); + List countries = GeoJSONReader.loadData(this, "data/countries.geo.json"); List countryMarkers = MapUtils.createSimpleMarkers(countries); map.addMarkers(countryMarkers); } diff --git a/examples/de/fhpotsdam/unfolding/examples/marker/SimpleMarkerManagerApp.java b/examples/de/fhpotsdam/unfolding/examples/marker/SimpleMarkerManagerApp.java index cd9f38cd..3ed02576 100644 --- a/examples/de/fhpotsdam/unfolding/examples/marker/SimpleMarkerManagerApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/marker/SimpleMarkerManagerApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.marker; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.marker.SimpleLinesMarker; @@ -22,7 +22,7 @@ public class SimpleMarkerManagerApp extends PApplet { UnfoldingMap map; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this, new Google.GoogleMapProvider()); diff --git a/examples/de/fhpotsdam/unfolding/examples/marker/SimpleNonMarkerApp.java b/examples/de/fhpotsdam/unfolding/examples/marker/SimpleNonMarkerApp.java index 09524c19..3562c2f2 100644 --- a/examples/de/fhpotsdam/unfolding/examples/marker/SimpleNonMarkerApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/marker/SimpleNonMarkerApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.marker; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -25,7 +25,7 @@ public class SimpleNonMarkerApp extends PApplet { Location locationLondon = new Location(51.5f, 0f); public void setup() { - size(400, 400, GLConstants.GLGRAPHICS); + size(400, 400, OPENGL); noStroke(); map = new UnfoldingMap(this); diff --git a/examples/de/fhpotsdam/unfolding/examples/marker/advanced/GetNearestMultiMarkerApp.java b/examples/de/fhpotsdam/unfolding/examples/marker/advanced/GetNearestMultiMarkerApp.java index ecd03d8a..e2f0398f 100644 --- a/examples/de/fhpotsdam/unfolding/examples/marker/advanced/GetNearestMultiMarkerApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/marker/advanced/GetNearestMultiMarkerApp.java @@ -4,7 +4,7 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.data.Feature; import de.fhpotsdam.unfolding.data.GeoJSONReader; @@ -27,7 +27,7 @@ public class GetNearestMultiMarkerApp extends PApplet { List countryMarkers = new ArrayList(); public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); map.zoomToLevel(2); diff --git a/examples/de/fhpotsdam/unfolding/examples/marker/advanced/ZoomDependentMarkerApp.java b/examples/de/fhpotsdam/unfolding/examples/marker/advanced/ZoomDependentMarkerApp.java index cd5d4f36..12398562 100644 --- a/examples/de/fhpotsdam/unfolding/examples/marker/advanced/ZoomDependentMarkerApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/marker/advanced/ZoomDependentMarkerApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.marker.advanced; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.marker.Marker; @@ -28,7 +28,7 @@ public class ZoomDependentMarkerApp extends PApplet { float oldZoomLevel = 0; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); map.zoomAndPanTo(new Location(41.50, -72.38), 5); diff --git a/examples/de/fhpotsdam/unfolding/examples/marker/advanced/centroid/CentroidMarkerApp.java b/examples/de/fhpotsdam/unfolding/examples/marker/advanced/centroid/CentroidMarkerApp.java index 9efba9cb..9ddbbb23 100644 --- a/examples/de/fhpotsdam/unfolding/examples/marker/advanced/centroid/CentroidMarkerApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/marker/advanced/centroid/CentroidMarkerApp.java @@ -3,7 +3,7 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.data.Feature; import de.fhpotsdam.unfolding.data.GeoJSONReader; @@ -22,7 +22,7 @@ public class CentroidMarkerApp extends PApplet { UnfoldingMap map; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this, 50, 50, 700, 500); map.zoomToLevel(2); diff --git a/examples/de/fhpotsdam/unfolding/examples/marker/connectionmarker/NeighborMarkersApp.java b/examples/de/fhpotsdam/unfolding/examples/marker/connectionmarker/NeighborMarkersApp.java index 041cb845..8af614c6 100644 --- a/examples/de/fhpotsdam/unfolding/examples/marker/connectionmarker/NeighborMarkersApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/marker/connectionmarker/NeighborMarkersApp.java @@ -4,7 +4,7 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.marker.Marker; @@ -22,7 +22,7 @@ public class NeighborMarkersApp extends PApplet { UnfoldingMap map; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); map.zoomToLevel(11); diff --git a/examples/de/fhpotsdam/unfolding/examples/marker/dynamic/DynamicMarkerApp.java b/examples/de/fhpotsdam/unfolding/examples/marker/dynamic/DynamicMarkerApp.java index bb6b329e..9cbe0ecf 100644 --- a/examples/de/fhpotsdam/unfolding/examples/marker/dynamic/DynamicMarkerApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/marker/dynamic/DynamicMarkerApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.marker.dynamic; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.marker.Marker; @@ -24,7 +24,7 @@ public class DynamicMarkerApp extends PApplet { SimplePointMarker berlinMarker; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); diff --git a/examples/de/fhpotsdam/unfolding/examples/marker/imagemarker/ImageMarkerApp.java b/examples/de/fhpotsdam/unfolding/examples/marker/imagemarker/ImageMarkerApp.java index cfaaae39..2f24bff3 100644 --- a/examples/de/fhpotsdam/unfolding/examples/marker/imagemarker/ImageMarkerApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/marker/imagemarker/ImageMarkerApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.marker.imagemarker; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -19,7 +19,7 @@ public class ImageMarkerApp extends PApplet { UnfoldingMap map; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); map.zoomAndPanTo(new Location(50.26f, 12.1f), 4); diff --git a/examples/de/fhpotsdam/unfolding/examples/marker/labelmarker/LabeledMarkerApp.java b/examples/de/fhpotsdam/unfolding/examples/marker/labelmarker/LabeledMarkerApp.java index 914166dc..dc96b5c9 100644 --- a/examples/de/fhpotsdam/unfolding/examples/marker/labelmarker/LabeledMarkerApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/marker/labelmarker/LabeledMarkerApp.java @@ -2,7 +2,7 @@ import processing.core.PApplet; import processing.core.PFont; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -21,7 +21,7 @@ public class LabeledMarkerApp extends PApplet { PFont font; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this, "map", 50, 50, 700, 500); map.zoomToLevel(3); diff --git a/examples/de/fhpotsdam/unfolding/examples/marker/labelmarker/ManualLabelMarkerApp.java b/examples/de/fhpotsdam/unfolding/examples/marker/labelmarker/ManualLabelMarkerApp.java index 7b845ffc..175b1a53 100644 --- a/examples/de/fhpotsdam/unfolding/examples/marker/labelmarker/ManualLabelMarkerApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/marker/labelmarker/ManualLabelMarkerApp.java @@ -5,7 +5,7 @@ import processing.core.PApplet; import processing.core.PFont; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.data.Feature; import de.fhpotsdam.unfolding.data.GeoRSSReader; @@ -24,7 +24,7 @@ public class ManualLabelMarkerApp extends PApplet { UnfoldingMap map; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this, "map", 50, 50, 700, 500); map.zoomToLevel(2); diff --git a/examples/de/fhpotsdam/unfolding/examples/marker/labelmarker/MultiLabeledMarkerApp.java b/examples/de/fhpotsdam/unfolding/examples/marker/labelmarker/MultiLabeledMarkerApp.java index 4d4d335b..4277f981 100644 --- a/examples/de/fhpotsdam/unfolding/examples/marker/labelmarker/MultiLabeledMarkerApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/marker/labelmarker/MultiLabeledMarkerApp.java @@ -3,7 +3,7 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.data.Feature; import de.fhpotsdam.unfolding.data.GeoRSSReader; @@ -27,7 +27,7 @@ public class MultiLabeledMarkerApp extends PApplet { UnfoldingMap map; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this, "map", 50, 50, 700, 500); map.zoomToLevel(2); diff --git a/examples/de/fhpotsdam/unfolding/examples/marker/multimaps/MultiLabeledMarkerOnMultiMapsApp.java b/examples/de/fhpotsdam/unfolding/examples/marker/multimaps/MultiLabeledMarkerOnMultiMapsApp.java index 477b0335..e30f25a9 100644 --- a/examples/de/fhpotsdam/unfolding/examples/marker/multimaps/MultiLabeledMarkerOnMultiMapsApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/marker/multimaps/MultiLabeledMarkerOnMultiMapsApp.java @@ -2,7 +2,7 @@ import java.util.List; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.data.Feature; import de.fhpotsdam.unfolding.data.GeoRSSReader; @@ -21,7 +21,7 @@ public class MultiLabeledMarkerOnMultiMapsApp extends ManualLabelMarkerApp { UnfoldingMap map2; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map1 = new UnfoldingMap(this, "map", 50, 50, 500, 500); map1.zoomToLevel(2); diff --git a/examples/de/fhpotsdam/unfolding/examples/marker/multimarker/CombineTestApp.java b/examples/de/fhpotsdam/unfolding/examples/marker/multimarker/CombineTestApp.java index 20dcbc2a..eb81fa00 100644 --- a/examples/de/fhpotsdam/unfolding/examples/marker/multimarker/CombineTestApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/marker/multimarker/CombineTestApp.java @@ -5,7 +5,7 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.data.Feature; import de.fhpotsdam.unfolding.data.GeoJSONReader; @@ -25,7 +25,7 @@ public class CombineTestApp extends PApplet { List specialIDs = new ArrayList(Arrays.asList(ids)); public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); diff --git a/examples/de/fhpotsdam/unfolding/examples/marker/multimarker/MultiMarkerApp.java b/examples/de/fhpotsdam/unfolding/examples/marker/multimarker/MultiMarkerApp.java index 832ae108..289180cd 100644 --- a/examples/de/fhpotsdam/unfolding/examples/marker/multimarker/MultiMarkerApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/marker/multimarker/MultiMarkerApp.java @@ -4,7 +4,7 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.marker.Marker; @@ -29,7 +29,7 @@ public class MultiMarkerApp extends PApplet { UnfoldingMap map; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this, "map"); map.zoomToLevel(4); diff --git a/examples/de/fhpotsdam/unfolding/examples/misc/DebugDisplayApp.java b/examples/de/fhpotsdam/unfolding/examples/misc/DebugDisplayApp.java index 8640914a..afd6e5bc 100644 --- a/examples/de/fhpotsdam/unfolding/examples/misc/DebugDisplayApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/misc/DebugDisplayApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.misc; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.DebugDisplay; @@ -16,7 +16,7 @@ public class DebugDisplayApp extends PApplet { DebugDisplay debugDisplay; public void setup() { - size(1024, 768, GLConstants.GLGRAPHICS); + size(1024, 768, P2D); map = new UnfoldingMap(this, "myMap"); map.zoomAndPanTo(new Location(52.5f, 13.4f), 10); diff --git a/examples/de/fhpotsdam/unfolding/examples/misc/MultiDebugDisplayApp.java b/examples/de/fhpotsdam/unfolding/examples/misc/MultiDebugDisplayApp.java index 1f2b2908..d0ad7956 100644 --- a/examples/de/fhpotsdam/unfolding/examples/misc/MultiDebugDisplayApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/misc/MultiDebugDisplayApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.misc; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.events.EventDispatcher; import de.fhpotsdam.unfolding.geo.Location; @@ -22,7 +22,7 @@ public class MultiDebugDisplayApp extends PApplet { DebugDisplay debugDisplay2; public void setup() { - size(1024, 768, GLConstants.GLGRAPHICS); + size(1024, 768, OPENGL); map1 = new UnfoldingMap(this, "map1", 0, 0, 512, height); map1.zoomAndPanTo(new Location(52.5f, 13.4f), 10); diff --git a/examples/de/fhpotsdam/unfolding/examples/misc/ResizableMapApp.java b/examples/de/fhpotsdam/unfolding/examples/misc/ResizableMapApp.java index e57dc152..42ea6a46 100644 --- a/examples/de/fhpotsdam/unfolding/examples/misc/ResizableMapApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/misc/ResizableMapApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.misc; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -18,9 +18,14 @@ public class ResizableMapApp extends PApplet { float oldWidth; float oldHeight; + + public static boolean isApplet = true; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + if (isApplet) { + println("This only works for Applications!"); + } + size(800, 600, OPENGL); frame.setResizable(true); map = new UnfoldingMap(this); @@ -48,6 +53,7 @@ public void draw() { } public static void main(String[] args) { + isApplet = false; PApplet.main(new String[] { "de.fhpotsdam.unfolding.examples.misc.ResizableMapApp" }); } } diff --git a/examples/de/fhpotsdam/unfolding/examples/misc/RotatableMapApp.java b/examples/de/fhpotsdam/unfolding/examples/misc/RotatableMapApp.java index 4e80675f..dec37cd6 100644 --- a/examples/de/fhpotsdam/unfolding/examples/misc/RotatableMapApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/misc/RotatableMapApp.java @@ -2,7 +2,7 @@ import processing.core.PApplet; import processing.core.PVector; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -26,7 +26,7 @@ public class RotatableMapApp extends PApplet { public void setup() { if (fullRotatable) { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); } else { size(800, 600); } diff --git a/examples/de/fhpotsdam/unfolding/examples/misc/SimpleBackgroundMapApp.java b/examples/de/fhpotsdam/unfolding/examples/misc/SimpleBackgroundMapApp.java index 6b397e97..d4c4fbd2 100644 --- a/examples/de/fhpotsdam/unfolding/examples/misc/SimpleBackgroundMapApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/misc/SimpleBackgroundMapApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.misc; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -16,7 +16,7 @@ public class SimpleBackgroundMapApp extends PApplet { UnfoldingMap map; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this, 50, 50, 700, 500); map.zoomAndPanTo(new Location(52.5f, 13.4f), 10); MapUtils.createDefaultEventDispatcher(this, map); diff --git a/examples/de/fhpotsdam/unfolding/examples/misc/SimpleNoMapApp.java b/examples/de/fhpotsdam/unfolding/examples/misc/SimpleNoMapApp.java index 5ec24264..f87d9236 100644 --- a/examples/de/fhpotsdam/unfolding/examples/misc/SimpleNoMapApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/misc/SimpleNoMapApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.misc; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.examples.marker.multimarker.MultiMarkerApp; import de.fhpotsdam.unfolding.geo.Location; @@ -16,7 +16,7 @@ public class SimpleNoMapApp extends PApplet { UnfoldingMap map; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); map.zoomAndPanTo(new Location(50f, 12f), 4); diff --git a/examples/de/fhpotsdam/unfolding/examples/multi/DayNightTransitionApp.java b/examples/de/fhpotsdam/unfolding/examples/multi/DayNightTransitionApp.java index d5e789f3..d2376f94 100644 --- a/examples/de/fhpotsdam/unfolding/examples/multi/DayNightTransitionApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/multi/DayNightTransitionApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.multi; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.providers.MBTilesMapProvider; @@ -21,7 +21,7 @@ public class DayNightTransitionApp extends PApplet { Integrator blendIntegrator = new Integrator(0); public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); mapDay = new UnfoldingMap(this); mapNight = new UnfoldingMap(this, new MBTilesMapProvider(JDBC_CONN_STRING_APPLET)); diff --git a/examples/de/fhpotsdam/unfolding/examples/multi/MapComparisonApp.java b/examples/de/fhpotsdam/unfolding/examples/multi/MapComparisonApp.java index 25b9014b..c2e6c916 100644 --- a/examples/de/fhpotsdam/unfolding/examples/multi/MapComparisonApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/multi/MapComparisonApp.java @@ -6,7 +6,7 @@ import org.apache.log4j.Logger; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.events.EventDispatcher; import de.fhpotsdam.unfolding.events.MapEventListener; @@ -45,7 +45,7 @@ public class MapComparisonApp extends PApplet { UnfoldingMap mapGoogleSmallSat; public void setup() { - size(1230, 700, GLConstants.GLGRAPHICS); + size(1230, 700, OPENGL); smooth(); eventDispatcher = new EventDispatcher(); diff --git a/examples/de/fhpotsdam/unfolding/examples/multi/MapErrorComparisonApp.java b/examples/de/fhpotsdam/unfolding/examples/multi/MapErrorComparisonApp.java index c8fc235b..b067a79f 100644 --- a/examples/de/fhpotsdam/unfolding/examples/multi/MapErrorComparisonApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/multi/MapErrorComparisonApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.multi; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.providers.Microsoft; @@ -23,7 +23,7 @@ public class MapErrorComparisonApp extends PApplet { float fadeValue = 100; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map1 = new UnfoldingMap(this, "map1", new Microsoft.AerialProvider()); map2 = new UnfoldingMap(this, "map2", new Microsoft.AerialProvider()); diff --git a/examples/de/fhpotsdam/unfolding/examples/multi/MultiProviderMultiMapApp.java b/examples/de/fhpotsdam/unfolding/examples/multi/MultiProviderMultiMapApp.java index 8bde3355..a130e1db 100644 --- a/examples/de/fhpotsdam/unfolding/examples/multi/MultiProviderMultiMapApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/multi/MultiProviderMultiMapApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.multi; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.providers.Microsoft; import de.fhpotsdam.unfolding.providers.OpenStreetMap; @@ -16,7 +16,7 @@ public class MultiProviderMultiMapApp extends PApplet { UnfoldingMap map2; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map1 = new UnfoldingMap(this, "map1", 10, 10, 385, 580, true, false, new Microsoft.AerialProvider()); map2 = new UnfoldingMap(this, "map2", 405, 10, 385, 580, true, false, new OpenStreetMap.OSMGrayProvider()); diff --git a/examples/de/fhpotsdam/unfolding/examples/multi/MultiProviderOverlayMapApp.java b/examples/de/fhpotsdam/unfolding/examples/multi/MultiProviderOverlayMapApp.java index d88919cc..f209af77 100644 --- a/examples/de/fhpotsdam/unfolding/examples/multi/MultiProviderOverlayMapApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/multi/MultiProviderOverlayMapApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.multi; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.providers.ImmoScout; @@ -17,7 +17,7 @@ public class MultiProviderOverlayMapApp extends PApplet { UnfoldingMap map2; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); Location berlinLocation = new Location(52.439046f, 13.447266f); map1 = new UnfoldingMap(this, "map1", new Microsoft.RoadProvider()); diff --git a/examples/de/fhpotsdam/unfolding/examples/multi/SimpleMultiMapApp.java b/examples/de/fhpotsdam/unfolding/examples/multi/SimpleMultiMapApp.java index f754efd5..8e9455e8 100644 --- a/examples/de/fhpotsdam/unfolding/examples/multi/SimpleMultiMapApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/multi/SimpleMultiMapApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.multi; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -16,7 +16,7 @@ public class SimpleMultiMapApp extends PApplet { UnfoldingMap map2; public void setup() { - size(620, 300, GLConstants.GLGRAPHICS); + size(620, 300, OPENGL); map1 = new UnfoldingMap(this, "map1", 0, 0, 305, 300); map2 = new UnfoldingMap(this, "map2", 315, 0, 305, 300); diff --git a/examples/de/fhpotsdam/unfolding/examples/multi/overlay/MovableMapOnStaticMapApp.java b/examples/de/fhpotsdam/unfolding/examples/multi/overlay/MovableMapOnStaticMapApp.java index da5de2e2..ff30d2fe 100644 --- a/examples/de/fhpotsdam/unfolding/examples/multi/overlay/MovableMapOnStaticMapApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/multi/overlay/MovableMapOnStaticMapApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.multi.overlay; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; @@ -18,7 +18,7 @@ public class MovableMapOnStaticMapApp extends PApplet { float mapZoomY = 100; public void setup() { - size(750, 600, GLConstants.GLGRAPHICS); + size(750, 600, OPENGL); mapStatic = new UnfoldingMap(this, "static", 0, 0, 750, 600); mapZoom = new UnfoldingMap(this, "zoom", 400, 300, 150, 150); diff --git a/examples/de/fhpotsdam/unfolding/examples/multi/overlay/SatelliteOverlayApp.java b/examples/de/fhpotsdam/unfolding/examples/multi/overlay/SatelliteOverlayApp.java index 47e3a273..3b1acc42 100644 --- a/examples/de/fhpotsdam/unfolding/examples/multi/overlay/SatelliteOverlayApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/multi/overlay/SatelliteOverlayApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.multi.overlay; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.providers.Microsoft; @@ -23,7 +23,7 @@ public class SatelliteOverlayApp extends PApplet { float mapZoomY = 100; public void setup() { - size(750, 600, GLConstants.GLGRAPHICS); + size(750, 600, OPENGL); mapOverview = new UnfoldingMap(this, "static", 0, 0, 750, 600); mapOverview.zoomToLevel(2); diff --git a/examples/de/fhpotsdam/unfolding/examples/overviewdetail/OverviewAndDetailFinderBoxMapApp.java b/examples/de/fhpotsdam/unfolding/examples/overviewdetail/OverviewAndDetailFinderBoxMapApp.java index 517b99da..80b04ee9 100644 --- a/examples/de/fhpotsdam/unfolding/examples/overviewdetail/OverviewAndDetailFinderBoxMapApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/overviewdetail/OverviewAndDetailFinderBoxMapApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.overviewdetail; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.events.EventDispatcher; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -22,7 +22,7 @@ public class OverviewAndDetailFinderBoxMapApp extends PApplet { UnfoldingMap mapOverviewStatic; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); // Detail map with default mouse and keyboard interactions mapDetail = new UnfoldingMap(this, "detail", 10, 10, 585, 580); diff --git a/examples/de/fhpotsdam/unfolding/examples/overviewdetail/OverviewAndDetailMapApp.java b/examples/de/fhpotsdam/unfolding/examples/overviewdetail/OverviewAndDetailMapApp.java index f0714b87..3fcf7dee 100644 --- a/examples/de/fhpotsdam/unfolding/examples/overviewdetail/OverviewAndDetailMapApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/overviewdetail/OverviewAndDetailMapApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.overviewdetail; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.events.EventDispatcher; import de.fhpotsdam.unfolding.interactions.MouseHandler; @@ -20,7 +20,7 @@ public class OverviewAndDetailMapApp extends PApplet { UnfoldingMap mapOverview; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); mapDetail = new UnfoldingMap(this, "detail", 10, 10, 585, 580); mapDetail.setTweening(true); diff --git a/examples/de/fhpotsdam/unfolding/examples/overviewdetail/OverviewAndDetailWithViewportApp.java b/examples/de/fhpotsdam/unfolding/examples/overviewdetail/OverviewAndDetailWithViewportApp.java index b5392ac7..e0d4936c 100644 --- a/examples/de/fhpotsdam/unfolding/examples/overviewdetail/OverviewAndDetailWithViewportApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/overviewdetail/OverviewAndDetailWithViewportApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.overviewdetail; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -26,7 +26,7 @@ public class OverviewAndDetailWithViewportApp extends PApplet { ViewportRect viewportRect; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); // Detail map with default mouse and keyboard interactions mapDetail = new UnfoldingMap(this, "detail", 10, 10, 585, 580); diff --git a/examples/de/fhpotsdam/unfolding/examples/overviewdetail/connection/ConvexHullConnectedMapOnStaticMap.java b/examples/de/fhpotsdam/unfolding/examples/overviewdetail/connection/ConvexHullConnectedMapOnStaticMap.java index 8ec089c2..ce7bb166 100644 --- a/examples/de/fhpotsdam/unfolding/examples/overviewdetail/connection/ConvexHullConnectedMapOnStaticMap.java +++ b/examples/de/fhpotsdam/unfolding/examples/overviewdetail/connection/ConvexHullConnectedMapOnStaticMap.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.overviewdetail.connection; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.utils.MapUtils; import de.fhpotsdam.unfolding.utils.ScreenPosition; @@ -24,7 +24,7 @@ public class ConvexHullConnectedMapOnStaticMap extends PApplet { OverviewPlusDetailConnection connection; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); mapOverview = new UnfoldingMap(this, "overview", 10, 10, 585, 580); mapOverview.zoomToLevel(1); diff --git a/examples/de/fhpotsdam/unfolding/examples/provider/MBTilesMapApp.java b/examples/de/fhpotsdam/unfolding/examples/provider/MBTilesMapApp.java index 59105ad5..1839c544 100644 --- a/examples/de/fhpotsdam/unfolding/examples/provider/MBTilesMapApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/provider/MBTilesMapApp.java @@ -1,7 +1,6 @@ package de.fhpotsdam.unfolding.examples.provider; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.providers.MBTilesMapProvider; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -14,17 +13,17 @@ public class MBTilesMapApp extends PApplet { // relative path varies depending on whether this was started as applet or application - public static final String JDBC_CONN_STRING_APPLICATION = "jdbc:sqlite:./bin/tiles/blankLight-1-3.mbtiles"; - public static final String JDBC_CONN_STRING_APPLET = "jdbc:sqlite:./tiles/blankLight-1-3.mbtiles"; + public static final String TILES_LOCATION_APPLICATION = "./bin/tiles/blankLight-1-3.mbtiles"; + public static final String TILES_LOCATION_APPLET = "./tiles/blankLight-1-3.mbtiles"; - public static String mbTilesConnectionString = JDBC_CONN_STRING_APPLET; + public static String mbTilesString = TILES_LOCATION_APPLET; UnfoldingMap map; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); - map = new UnfoldingMap(this, new MBTilesMapProvider(mbTilesConnectionString)); + map = new UnfoldingMap(this, new MBTilesMapProvider(mbTilesString)); MapUtils.createDefaultEventDispatcher(this, map); map.setZoomRange(1, 3); } @@ -35,7 +34,7 @@ public void draw() { } public static void main(String[] args) { - mbTilesConnectionString = JDBC_CONN_STRING_APPLICATION; + mbTilesString = TILES_LOCATION_APPLICATION; PApplet.main(new String[] { "de.fhpotsdam.unfolding.examples.provider.MBTilesMapApp" }); } } \ No newline at end of file diff --git a/examples/de/fhpotsdam/unfolding/examples/provider/SatelliteProviderMapApp.java b/examples/de/fhpotsdam/unfolding/examples/provider/SatelliteProviderMapApp.java index 6757b0be..720f2d90 100644 --- a/examples/de/fhpotsdam/unfolding/examples/provider/SatelliteProviderMapApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/provider/SatelliteProviderMapApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.provider; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.providers.Microsoft; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -14,7 +14,7 @@ public class SatelliteProviderMapApp extends PApplet { UnfoldingMap map; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this, new Microsoft.AerialProvider()); map.zoomToLevel(3); MapUtils.createDefaultEventDispatcher(this, map); @@ -26,6 +26,6 @@ public void draw() { } public static void main(String[] args) { - PApplet.main(new String[] { "de.fhpotsdam.unfolding.examples.SatelliteProviderMapApp" }); + PApplet.main(new String[] { "de.fhpotsdam.unfolding.examples.provider.SatelliteProviderMapApp" }); } } \ No newline at end of file diff --git a/examples/de/fhpotsdam/unfolding/examples/provider/dynamic/DynamicMapSwitch.java b/examples/de/fhpotsdam/unfolding/examples/provider/dynamic/DynamicMapSwitch.java index 97e3f0ee..a52967ee 100644 --- a/examples/de/fhpotsdam/unfolding/examples/provider/dynamic/DynamicMapSwitch.java +++ b/examples/de/fhpotsdam/unfolding/examples/provider/dynamic/DynamicMapSwitch.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.provider.dynamic; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.mapdisplay.MapDisplayFactory; import de.fhpotsdam.unfolding.providers.Google; @@ -27,7 +27,7 @@ public class DynamicMapSwitch extends PApplet { UnfoldingMap map3; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map1 = new UnfoldingMap(this, new Google.GoogleMapProvider()); map2 = new UnfoldingMap(this, new Microsoft.AerialProvider()); diff --git a/examples/de/fhpotsdam/unfolding/examples/provider/dynamic/DynamicProviderSwitch.java b/examples/de/fhpotsdam/unfolding/examples/provider/dynamic/DynamicProviderSwitch.java index bf1ec758..f2a7f737 100644 --- a/examples/de/fhpotsdam/unfolding/examples/provider/dynamic/DynamicProviderSwitch.java +++ b/examples/de/fhpotsdam/unfolding/examples/provider/dynamic/DynamicProviderSwitch.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.provider.dynamic; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.mapdisplay.MapDisplayFactory; import de.fhpotsdam.unfolding.providers.AbstractMapProvider; @@ -25,7 +25,7 @@ public class DynamicProviderSwitch extends PApplet { AbstractMapProvider provider3; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); provider1 = new Google.GoogleMapProvider(); provider2 = new Microsoft.AerialProvider(); diff --git a/examples/de/fhpotsdam/unfolding/examples/ui/BarScaleApp.java b/examples/de/fhpotsdam/unfolding/examples/ui/BarScaleApp.java index 1812f088..852ffc2c 100644 --- a/examples/de/fhpotsdam/unfolding/examples/ui/BarScaleApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/ui/BarScaleApp.java @@ -2,13 +2,11 @@ import processing.core.PApplet; import processing.core.PFont; -import codeanticode.glgraphics.GLConstants; import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.ui.BarScaleUI; import de.fhpotsdam.unfolding.utils.MapUtils; - /** * Simple map example with a styled bar scale (at the right top). */ @@ -19,16 +17,16 @@ public class BarScaleApp extends PApplet { BarScaleUI barScale; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); map.zoomAndPanTo(new Location(52.5f, 13.4f), 10); MapUtils.createDefaultEventDispatcher(this, map); - - //add a bar scale to your map + + // add a bar scale to your map barScale = new BarScaleUI(this, map, 700, 20); - //optionally style your bar scale + // optionally style your bar scale PFont myFont = createFont("Monospaced", 12); barScale.setStyle(color(60, 120), 6, -2, myFont); } @@ -36,6 +34,7 @@ public void setup() { public void draw() { background(0); map.draw(); + barScale.draw(); } diff --git a/examples/de/fhpotsdam/unfolding/examples/ui/CompassApp.java b/examples/de/fhpotsdam/unfolding/examples/ui/CompassApp.java index 690479e6..f9415960 100644 --- a/examples/de/fhpotsdam/unfolding/examples/ui/CompassApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/ui/CompassApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples.ui; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.ui.CompassUI; @@ -18,7 +18,7 @@ public class CompassApp extends PApplet { CompassUI compass; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); map.zoomAndPanTo(new Location(52.5f, 13.4f), 10); // MapUtils.createDefaultEventDispatcher(this, map); diff --git a/examples/de/fhpotsdam/unfolding/examples/ui/StyledCompassApp.java b/examples/de/fhpotsdam/unfolding/examples/ui/StyledCompassApp.java index 79eadf74..b8222a82 100644 --- a/examples/de/fhpotsdam/unfolding/examples/ui/StyledCompassApp.java +++ b/examples/de/fhpotsdam/unfolding/examples/ui/StyledCompassApp.java @@ -2,7 +2,7 @@ import processing.core.PApplet; import processing.core.PImage; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.ui.CompassUI; @@ -21,7 +21,7 @@ public class StyledCompassApp extends PApplet { PImage compassImg; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); map.zoomAndPanTo(new Location(52.5f, 13.4f), 10); diff --git a/examples/de/fhpotsdam/unfolding/examples/ui/ZoomSlider.java b/examples/de/fhpotsdam/unfolding/examples/ui/ZoomSlider.java new file mode 100644 index 00000000..76e53be4 --- /dev/null +++ b/examples/de/fhpotsdam/unfolding/examples/ui/ZoomSlider.java @@ -0,0 +1,69 @@ +package de.fhpotsdam.unfolding.examples.ui; + +import processing.core.PApplet; +import de.fhpotsdam.unfolding.UnfoldingMap; + +public class ZoomSlider { + + PApplet p; + UnfoldingMap map; + + float x = 50; + float y = 30; + float w = 100; + float h = 10; + + float sliderX; + float sliderW = 10; + boolean dragging = false; + + ZoomSlider(PApplet p, UnfoldingMap map, float x, float y) { + this.p = p; + this.map = map; + + this.x = x; + this.y = y; + sliderX = x; + } + + public void draw() { + p.fill(200); + p.stroke(180); + p.rect(x, y, w, h); + + p.fill(180); + p.rect(sliderX, y, sliderW, 10); + } + + public void setZoomLevel(int zoomLevel) { + sliderX = PApplet.map(zoomLevel, 1, 16, x, x + w); + } + + public boolean isDragging() { + return dragging; + } + + public boolean contains(float checkX, float checkY) { + return (checkX > x && checkX < x + w && checkY > y && checkY < y + h); + } + + public void startDrag(float dragX, float dragY) { + sliderX = PApplet.constrain(dragX - sliderW / 2, x, x + w - sliderW); + dragging = true; + } + + public void drag(float dragX, float dragY) { + sliderX = PApplet.constrain(dragX - sliderW / 2, x, x + w - sliderW); + updateMap(); + } + + public void endDrag() { + dragging = false; + updateMap(); + } + + protected void updateMap() { + int level = (int) PApplet.map(sliderX, x, x + w, 1, 16); + map.zoomToLevel(level); + } +} \ No newline at end of file diff --git a/examples/de/fhpotsdam/unfolding/examples/ui/ZoomSliderOnMapApp.java b/examples/de/fhpotsdam/unfolding/examples/ui/ZoomSliderOnMapApp.java new file mode 100644 index 00000000..3253b03b --- /dev/null +++ b/examples/de/fhpotsdam/unfolding/examples/ui/ZoomSliderOnMapApp.java @@ -0,0 +1,75 @@ +package de.fhpotsdam.unfolding.examples.ui; + +import processing.core.PApplet; +import de.fhpotsdam.unfolding.UnfoldingMap; +import de.fhpotsdam.unfolding.events.EventDispatcher; +import de.fhpotsdam.unfolding.events.MapEvent; +import de.fhpotsdam.unfolding.events.PanMapEvent; +import de.fhpotsdam.unfolding.events.ZoomMapEvent; +import de.fhpotsdam.unfolding.interactions.MouseHandler; + +/** + * Interactive map with slider atop. Uses work-around to mute MouseHandler when dragging slider. + */ +public class ZoomSliderOnMapApp extends PApplet { + + UnfoldingMap map; + ZoomSlider slider; + + EventDispatcher eventDispatcher; + + public void setup() { + size(800, 600); + + map = new UnfoldingMap(this); + + eventDispatcher = new EventDispatcher(); + MouseHandler mouseHandler = new MouseHandler(this, map); + eventDispatcher.addBroadcaster(mouseHandler); + listen(); + + slider = new ZoomSlider(this, map, 50, 30); + } + + public void listen() { + eventDispatcher.register(map, PanMapEvent.TYPE_PAN, map.getId()); + eventDispatcher.register(map, ZoomMapEvent.TYPE_ZOOM, map.getId()); + } + + public void mute() { + eventDispatcher.unregister(map, PanMapEvent.TYPE_PAN, map.getId()); + eventDispatcher.unregister(map, ZoomMapEvent.TYPE_ZOOM, map.getId()); + } + + public void draw() { + map.draw(); + + slider.draw(); + } + + public void mapChanged(MapEvent mapEvent) { + // Updates slider based on current map zoom + slider.setZoomLevel(map.getZoomLevel()); + } + + public void mousePressed() { + if (slider.contains(mouseX, mouseY)) { + slider.startDrag(mouseX, mouseY); + mute(); // mute mouse event handling + } + } + + public void mouseDragged() { + if (slider.isDragging()) { + slider.drag(mouseX, mouseY); + } + } + + public void mouseReleased() { + if (slider.isDragging()) { + slider.endDrag(); + listen(); // unmute mouse event handling + } + } + +} diff --git a/lib-extern/controlP5.jar b/lib-extern/controlP5.jar index a9ac2508..34c0b364 100644 Binary files a/lib-extern/controlP5.jar and b/lib-extern/controlP5.jar differ diff --git a/lib/core.jar b/lib/core.jar index feffba83..95ebae58 100644 Binary files a/lib/core.jar and b/lib/core.jar differ diff --git a/lib/glgraphics.jar b/lib/glgraphics.jar deleted file mode 100644 index f8b3dd8d..00000000 Binary files a/lib/glgraphics.jar and /dev/null differ diff --git a/lib/gluegen-rt-natives-linux-amd64.jar b/lib/gluegen-rt-natives-linux-amd64.jar new file mode 100644 index 00000000..989291b0 Binary files /dev/null and b/lib/gluegen-rt-natives-linux-amd64.jar differ diff --git a/lib/gluegen-rt-natives-linux-armv6hf.jar b/lib/gluegen-rt-natives-linux-armv6hf.jar new file mode 100644 index 00000000..0d998bd5 Binary files /dev/null and b/lib/gluegen-rt-natives-linux-armv6hf.jar differ diff --git a/lib/gluegen-rt-natives-linux-i586.jar b/lib/gluegen-rt-natives-linux-i586.jar new file mode 100644 index 00000000..713d0bec Binary files /dev/null and b/lib/gluegen-rt-natives-linux-i586.jar differ diff --git a/lib/gluegen-rt-natives-macosx-universal.jar b/lib/gluegen-rt-natives-macosx-universal.jar new file mode 100644 index 00000000..3ba5ac23 Binary files /dev/null and b/lib/gluegen-rt-natives-macosx-universal.jar differ diff --git a/lib/gluegen-rt-natives-windows-amd64.jar b/lib/gluegen-rt-natives-windows-amd64.jar new file mode 100644 index 00000000..1c82854c Binary files /dev/null and b/lib/gluegen-rt-natives-windows-amd64.jar differ diff --git a/lib/gluegen-rt-natives-windows-i586.jar b/lib/gluegen-rt-natives-windows-i586.jar new file mode 100644 index 00000000..989b32a6 Binary files /dev/null and b/lib/gluegen-rt-natives-windows-i586.jar differ diff --git a/lib/gluegen-rt.jar b/lib/gluegen-rt.jar index 7ac10a35..19773f8b 100644 Binary files a/lib/gluegen-rt.jar and b/lib/gluegen-rt.jar differ diff --git a/lib/jogl-all-natives-linux-amd64.jar b/lib/jogl-all-natives-linux-amd64.jar new file mode 100644 index 00000000..ec0cde0f Binary files /dev/null and b/lib/jogl-all-natives-linux-amd64.jar differ diff --git a/lib/jogl-all-natives-linux-armv6hf.jar b/lib/jogl-all-natives-linux-armv6hf.jar new file mode 100644 index 00000000..a92355c5 Binary files /dev/null and b/lib/jogl-all-natives-linux-armv6hf.jar differ diff --git a/lib/jogl-all-natives-linux-i586.jar b/lib/jogl-all-natives-linux-i586.jar new file mode 100644 index 00000000..25f8f73b Binary files /dev/null and b/lib/jogl-all-natives-linux-i586.jar differ diff --git a/lib/jogl-all-natives-macosx-universal.jar b/lib/jogl-all-natives-macosx-universal.jar new file mode 100644 index 00000000..9a388187 Binary files /dev/null and b/lib/jogl-all-natives-macosx-universal.jar differ diff --git a/lib/jogl-all-natives-windows-amd64.jar b/lib/jogl-all-natives-windows-amd64.jar new file mode 100644 index 00000000..0b7cbdfd Binary files /dev/null and b/lib/jogl-all-natives-windows-amd64.jar differ diff --git a/lib/jogl-all-natives-windows-i586.jar b/lib/jogl-all-natives-windows-i586.jar new file mode 100644 index 00000000..f40211f7 Binary files /dev/null and b/lib/jogl-all-natives-windows-i586.jar differ diff --git a/lib/jogl-all.jar b/lib/jogl-all.jar new file mode 100644 index 00000000..5ac5e55d Binary files /dev/null and b/lib/jogl-all.jar differ diff --git a/lib/jogl.jar b/lib/jogl.jar deleted file mode 100644 index 305e9987..00000000 Binary files a/lib/jogl.jar and /dev/null differ diff --git a/lib/opengl.jar b/lib/opengl.jar deleted file mode 100644 index 000d29e0..00000000 Binary files a/lib/opengl.jar and /dev/null differ diff --git a/libNative/linux32/libgluegen-rt.so b/libNative/linux32/libgluegen-rt.so deleted file mode 100644 index 14824304..00000000 Binary files a/libNative/linux32/libgluegen-rt.so and /dev/null differ diff --git a/libNative/linux32/libjogl.so b/libNative/linux32/libjogl.so deleted file mode 100644 index 51adbdb4..00000000 Binary files a/libNative/linux32/libjogl.so and /dev/null differ diff --git a/libNative/linux32/libjogl_awt.so b/libNative/linux32/libjogl_awt.so deleted file mode 100644 index 7ea13546..00000000 Binary files a/libNative/linux32/libjogl_awt.so and /dev/null differ diff --git a/libNative/linux32/libjogl_cg.so b/libNative/linux32/libjogl_cg.so deleted file mode 100644 index 95a0374c..00000000 Binary files a/libNative/linux32/libjogl_cg.so and /dev/null differ diff --git a/libNative/linux64/libgluegen-rt.so b/libNative/linux64/libgluegen-rt.so deleted file mode 100644 index e12c5111..00000000 Binary files a/libNative/linux64/libgluegen-rt.so and /dev/null differ diff --git a/libNative/linux64/libjogl.so b/libNative/linux64/libjogl.so deleted file mode 100644 index 45b0d63e..00000000 Binary files a/libNative/linux64/libjogl.so and /dev/null differ diff --git a/libNative/linux64/libjogl_awt.so b/libNative/linux64/libjogl_awt.so deleted file mode 100644 index ad1bc140..00000000 Binary files a/libNative/linux64/libjogl_awt.so and /dev/null differ diff --git a/libNative/linux64/libjogl_cg.so b/libNative/linux64/libjogl_cg.so deleted file mode 100644 index b90208bc..00000000 Binary files a/libNative/linux64/libjogl_cg.so and /dev/null differ diff --git a/libNative/macosx/libgluegen-rt.jnilib b/libNative/macosx/libgluegen-rt.jnilib deleted file mode 100644 index 19562801..00000000 Binary files a/libNative/macosx/libgluegen-rt.jnilib and /dev/null differ diff --git a/libNative/macosx/libjogl.jnilib b/libNative/macosx/libjogl.jnilib deleted file mode 100644 index eb8719aa..00000000 Binary files a/libNative/macosx/libjogl.jnilib and /dev/null differ diff --git a/libNative/macosx/libjogl_awt.jnilib b/libNative/macosx/libjogl_awt.jnilib deleted file mode 100644 index 2f16fbfb..00000000 Binary files a/libNative/macosx/libjogl_awt.jnilib and /dev/null differ diff --git a/libNative/macosx/libjogl_cg.jnilib b/libNative/macosx/libjogl_cg.jnilib deleted file mode 100644 index 56271210..00000000 Binary files a/libNative/macosx/libjogl_cg.jnilib and /dev/null differ diff --git a/libNative/windows32/gluegen-rt.dll b/libNative/windows32/gluegen-rt.dll deleted file mode 100644 index 281d389d..00000000 Binary files a/libNative/windows32/gluegen-rt.dll and /dev/null differ diff --git a/libNative/windows32/jogl.dll b/libNative/windows32/jogl.dll deleted file mode 100644 index ee7a6a59..00000000 Binary files a/libNative/windows32/jogl.dll and /dev/null differ diff --git a/libNative/windows32/jogl_awt.dll b/libNative/windows32/jogl_awt.dll deleted file mode 100644 index 2b47eee6..00000000 Binary files a/libNative/windows32/jogl_awt.dll and /dev/null differ diff --git a/libNative/windows32/jogl_cg.dll b/libNative/windows32/jogl_cg.dll deleted file mode 100644 index c64e2a2e..00000000 Binary files a/libNative/windows32/jogl_cg.dll and /dev/null differ diff --git a/libNative/windows64/gluegen-rt.dll b/libNative/windows64/gluegen-rt.dll deleted file mode 100644 index a7eb6f5b..00000000 Binary files a/libNative/windows64/gluegen-rt.dll and /dev/null differ diff --git a/libNative/windows64/jogl.dll b/libNative/windows64/jogl.dll deleted file mode 100644 index 990986f1..00000000 Binary files a/libNative/windows64/jogl.dll and /dev/null differ diff --git a/libNative/windows64/jogl_awt.dll b/libNative/windows64/jogl_awt.dll deleted file mode 100644 index d247b4a0..00000000 Binary files a/libNative/windows64/jogl_awt.dll and /dev/null differ diff --git a/libNative/windows64/jogl_cg.dll b/libNative/windows64/jogl_cg.dll deleted file mode 100644 index 9e2f371b..00000000 Binary files a/libNative/windows64/jogl_cg.dll and /dev/null differ diff --git a/examples-extern/de/fhpotsdam/unfolding/examples/threed/AnimatedParticle.java b/notworking/de/fhpotsdam/unfolding/examples/threed/AnimatedParticle.java similarity index 100% rename from examples-extern/de/fhpotsdam/unfolding/examples/threed/AnimatedParticle.java rename to notworking/de/fhpotsdam/unfolding/examples/threed/AnimatedParticle.java diff --git a/examples-extern/de/fhpotsdam/unfolding/examples/threed/ArcsBezierMap3DApp.java b/notworking/de/fhpotsdam/unfolding/examples/threed/ArcsBezierMap3DApp.java similarity index 100% rename from examples-extern/de/fhpotsdam/unfolding/examples/threed/ArcsBezierMap3DApp.java rename to notworking/de/fhpotsdam/unfolding/examples/threed/ArcsBezierMap3DApp.java diff --git a/examples-extern/de/fhpotsdam/unfolding/examples/threed/ArcsMap3DApp.java b/notworking/de/fhpotsdam/unfolding/examples/threed/ArcsMap3DApp.java similarity index 100% rename from examples-extern/de/fhpotsdam/unfolding/examples/threed/ArcsMap3DApp.java rename to notworking/de/fhpotsdam/unfolding/examples/threed/ArcsMap3DApp.java diff --git a/examples-extern/de/fhpotsdam/unfolding/examples/threed/ArcsWithAnimatedParticlesMap3DApp.java b/notworking/de/fhpotsdam/unfolding/examples/threed/ArcsWithAnimatedParticlesMap3DApp.java similarity index 100% rename from examples-extern/de/fhpotsdam/unfolding/examples/threed/ArcsWithAnimatedParticlesMap3DApp.java rename to notworking/de/fhpotsdam/unfolding/examples/threed/ArcsWithAnimatedParticlesMap3DApp.java diff --git a/examples-extern/de/fhpotsdam/unfolding/examples/threed/Map3DApp.java b/notworking/de/fhpotsdam/unfolding/examples/threed/Map3DApp.java similarity index 100% rename from examples-extern/de/fhpotsdam/unfolding/examples/threed/Map3DApp.java rename to notworking/de/fhpotsdam/unfolding/examples/threed/Map3DApp.java diff --git a/examples-extern/de/fhpotsdam/unfolding/examples/threed/SphereMarkersMap3DApp.java b/notworking/de/fhpotsdam/unfolding/examples/threed/SphereMarkersMap3DApp.java similarity index 98% rename from examples-extern/de/fhpotsdam/unfolding/examples/threed/SphereMarkersMap3DApp.java rename to notworking/de/fhpotsdam/unfolding/examples/threed/SphereMarkersMap3DApp.java index ab20cdc7..afb7b6b0 100644 --- a/examples-extern/de/fhpotsdam/unfolding/examples/threed/SphereMarkersMap3DApp.java +++ b/notworking/de/fhpotsdam/unfolding/examples/threed/SphereMarkersMap3DApp.java @@ -11,7 +11,7 @@ public class SphereMarkersMap3DApp extends Map3DApp { - String earthquakesURL = "http://earthquake.usgs.gov/earthquakes/feed/atom/4.5/week"; + String earthquakesURL = "http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_week.atom"; List features; boolean useColorCoding = false; diff --git a/examples-extern/de/fhpotsdam/unfolding/examples/threed/SphereModelMap3DApp.java b/notworking/de/fhpotsdam/unfolding/examples/threed/SphereModelMap3DApp.java similarity index 100% rename from examples-extern/de/fhpotsdam/unfolding/examples/threed/SphereModelMap3DApp.java rename to notworking/de/fhpotsdam/unfolding/examples/threed/SphereModelMap3DApp.java diff --git a/release-notes.txt b/release-notes.txt index e285bb3c..d2c52528 100644 --- a/release-notes.txt +++ b/release-notes.txt @@ -1,8 +1,32 @@ RELEASE NOTES +0.9.5 +----------------------------- + +Bug Fixes +- Fixed map transparency issues. + + +Features +- Moved core and examples to Processing 2 and its new Java2D/OpenGL renderer. +- + +Documentation +- Added more examples (Processing and Eclipse distributions) + + +Other +- Using Processing's new library installation mechanism + + + +0.9.4beta +----------------------------- +First version using Processing 2 -0.9.3 +0.9.3 +----------------------------- Bug Fixes - Fixed tweening (#5). Map now can animate between states, optionally. diff --git a/resources/ChangeLog.txt b/resources/ChangeLog.txt deleted file mode 100644 index a79d9e71..00000000 --- a/resources/ChangeLog.txt +++ /dev/null @@ -1,29 +0,0 @@ -2010-05-07 Andreas Schlegel - * version 0.3.2 - * build.xml: removing delete tag for bin folder, did cause issues with class referencing inside eclipse - -2010-05-01 Andreas Schlegel - * version 0.3.1 - * the option to create a tool with the library template has been excluded. to create tools for processing see http://code.google.com/p/processing-tool-template - * build.properties and build.xml files have been adjusted accordingly - * modified: src, examples - -2010-04-25 Andreas Schlegel - * version 0.2.1 - * build.xml: zip method adjusted, tested on osx 10.x and windows xp - * screencasts available for both library and tool, see wiki. - -2010-04-12 Andreas Schlegel - * version 0.2.0 - * the template now support both, processing libraries and tools - * added an install file for a library/tool distribution included in the .zip file. - * data: adding data folder, see README file for details - * lib: adding lib folder, see README file for details - * resources: excluding project related properties from build.xml, now located inside build.properties - * distribution: distributions are now archived with a version number - * bin: folder removed - * build.xml: ant build file has been mostly rewritten, now supports tool and library - * build.properties: adding properties file for build.xml. please read comments inside build.properties. - * changeLog: adding ChangeLog file - - \ No newline at end of file diff --git a/resources/build.properties b/resources/build.properties deleted file mode 100644 index 3792ccfc..00000000 --- a/resources/build.properties +++ /dev/null @@ -1,130 +0,0 @@ -# Todo (Till): -# - Clean project in Eclipse -# - Delete everything in build/ -# - Run 'clean' task in Ant - - - - -# Create libraries for the open source programming language -# and environment processing (http://www.processing.org) -# -# Customize the build properties to make the ant-build-process -# work for your environment. How? Please read the comments below. -# -# The default properties are set for OSX, for Windows-settings -# please refer to comments made under (1) and (2). - - - -# (1) -# Where is your processing sketchbook located? -# If you are not sure, check the sketchbook location in your -# processing application preferences. -# ${user.home} points the compiler to your home directory -# For windows the default path to your sketchbook would be -# ${user.home}/My Documents/Processing (make adjustments below). - -sketchbook.location=${user.home}/Coding/Processing-Code - - - -# (2) -# Where are the jar files located that are required for compiling -# your library such as e.g. core.jar? -# by default the local classpath location points to folder libs -# inside eclipse's workspace (by default found in your home directory). -# For Windows the default path would be ${user.home}/workspace/libs -# (make adjustments below) - -classpath.local.location=${user.home}/PhD/workspace/unfolding/lib - - - -# For OSX users. -# The following path will direct you into processing's -# application source code folder in case you put processing inside your -# Applications folder. Uncommenting the line below will overwrite the -# classpath.local.location from above. - -# classpath.local.location=/Applications/Processing.app/Contents/Resources/Java/ - - -# Add all jar files that are required for compiling your project -# to the local and project classpath, use a comma as delimiter. -# These jar files must be inside your classpath.local.location folder. - -classpath.local.include=core.jar,glgraphics.jar,opengl.jar,log4j-1.2.15.jar,jogl.jar - - -# Add processing's libraries folder to the classpath. -# If you don't need to include the libraries folder to your classpath, -# comment out the following line. - -classpath.libraries.location=${sketchbook.location}/libraries - - - -# (3) set the java version that should be used to compile your library. - -java.target.version=1.5 - - -# set the description of the ant build.xml file - -ant.description=processingLibs. ant build file. - - - -# (4) -# project details. -# Give your library a name. - -project.name=Unfolding - - -# use normal or fast as value for project.compile -# (fast will only compile the project into your sketchbook, -# using normal as property will compile the distribution including the -# javadoc-reference and all web-files - the compile process here -# takes longer) - -project.compile=normal - -# all files compiled with project.compile=normal are stored -# in folder distribution - - - -# (5) -# the following items are properties that will be used to -# make changes to the html document template. values of properties -# will be implemented ito the document automatically. - -# set the current version of your project. - -project.version=0.8.3 -project.copyright=Copyright 2012 -project.dependencies=OpenGL, GLGraphics, TUIO -project.keywords=map, geovisualization, marker, zoom+pan, interaction, geovis -author.name=Till Nagel -author.url=http://unfoldingmaps.org - -tested.platform=osx,windows -tested.processingversion=1.5 - -# recommendations for storing your source code online are: code.google or github. - -source.host=Google Code -source.url=http://code.google.com/p/unfolding/ -source.repository=http://code.google.com/p/unfolding/source/browse/ - - -# include javadoc references into your project's javadoc - -javadoc.java.href= -#http://java.sun.com/javase/6/docs/api/ -javadoc.processing.href= -#http://dev.processing.org/reference/everything/javadoc/ - - diff --git a/resources/build.xml b/resources/build.xml deleted file mode 100644 index 4a0e31a5..00000000 --- a/resources/build.xml +++ /dev/null @@ -1,371 +0,0 @@ - - - - - - - - - - - ${ant.description} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${line} - building a processing library, ${project.name} ${project.version} -${line} - src path ${project.src} - bin path ${project.bin} - classpath.local ${classpath.local.location} - sketchbook ${sketchbook.location} - java version ${java.target.version} - project lib ${project.lib} - classpath.local.location ${classpath.local.location} -${line} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -${line} -Name ${project.name} -Version ${project.version} -Compiled ${project.compile} -Sketchbook ${sketchbook.location} -${line} -done, finished. -${line} - - - - - diff --git a/resources/code/ExampleTaglet.class b/resources/code/ExampleTaglet.class deleted file mode 100644 index b17c64ed..00000000 Binary files a/resources/code/ExampleTaglet.class and /dev/null differ diff --git a/resources/code/ExampleTaglet.java b/resources/code/ExampleTaglet.java deleted file mode 100644 index 461ea082..00000000 --- a/resources/code/ExampleTaglet.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * -Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * -Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any - * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND - * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY - * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY - * DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR - * RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR - * ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE - * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, - * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER - * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF - * THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that Software is not designed, licensed or - * intended for use in the design, construction, operation or - * maintenance of any nuclear facility. - */ - -import com.sun.tools.doclets.Taglet; -import com.sun.javadoc.*; -import java.util.Map; -import java.io.*; -/** - * A sample Taglet representing @example. This tag can be used in any kind of - * {@link com.sun.javadoc.Doc}. It is not an inline tag. The text is displayed - * in yellow to remind the developer to perform a task. For - * example, "@example Hello" would be shown as: - *
- *
- * To Do: - *
Fix this! - *
- *
- * - * @author Jamie Ho - * @since 1.4 - */ - -public class ExampleTaglet implements Taglet { - - private static final String NAME = "example"; - private static final String HEADER = "example To Do:"; - - /** - * Return the name of this custom tag. - */ - public String getName() { - return NAME; - } - - /** - * Will return true since @example - * can be used in field documentation. - * @return true since @example - * can be used in field documentation and false - * otherwise. - */ - public boolean inField() { - return true; - } - - /** - * Will return true since @example - * can be used in constructor documentation. - * @return true since @example - * can be used in constructor documentation and false - * otherwise. - */ - public boolean inConstructor() { - return true; - } - - /** - * Will return true since @example - * can be used in method documentation. - * @return true since @example - * can be used in method documentation and false - * otherwise. - */ - public boolean inMethod() { - return true; - } - - /** - * Will return true since @example - * can be used in method documentation. - * @return true since @example - * can be used in overview documentation and false - * otherwise. - */ - public boolean inOverview() { - return true; - } - - /** - * Will return true since @example - * can be used in package documentation. - * @return true since @example - * can be used in package documentation and false - * otherwise. - */ - public boolean inPackage() { - return true; - } - - /** - * Will return true since @example - * can be used in type documentation (classes or interfaces). - * @return true since @example - * can be used in type documentation and false - * otherwise. - */ - public boolean inType() { - return true; - } - - /** - * Will return false since @example - * is not an inline tag. - * @return false since @example - * is not an inline tag. - */ - - public boolean isInlineTag() { - return false; - } - - /** - * Register this Taglet. - * @param tagletMap the map to register this tag to. - */ - public static void register(Map tagletMap) { - ExampleTaglet tag = new ExampleTaglet(); - Taglet t = (Taglet) tagletMap.get(tag.getName()); - if (t != null) { - tagletMap.remove(tag.getName()); - } - tagletMap.put(tag.getName(), tag); - } - - /** - * Given the Tag representation of this custom - * tag, return its string representation. - * @param tag the Tag representation of this custom tag. - */ - public String toString(Tag tag) { - return createHTML(readFile(tag.text())); - } - - - /** - * Given an array of Tags representing this custom - * tag, return its string representation. - * @param tags the array of Tags representing of this custom tag. - */ - public String toString(Tag[] tags) { - if (tags.length == 0) { - return null; - } - return createHTML(readFile(tags[0].text())); - } - - - - String createHTML(String theString) { - if(theString!=null) { - String dd = ""; - - return dd+"\n
" + - "
+Example
" + - "
"+theString+"
" + - "
"; - } - return ""; - } - - - /** - * check if the examples directory exists and return the example as given in the tag. - * @param theExample the name of the example - */ - String readFile(String theExample) { - String record = ""; - String myResult = ""; - int recCount = 0; - String myDir = "../examples"; - File file=new File(myDir); - if(file.exists()==false) { - myDir = "./examples"; - } - try { - FileReader fr = new FileReader(myDir+"/"+theExample+"/"+theExample+".pde"); - BufferedReader br = new BufferedReader(fr); - record = new String(); - while ((record = br.readLine()) != null) { - myResult += record+"\n"; - } - } catch (IOException e) { - System.out.println(e); - return null; - } - return myResult; - } -} - - diff --git a/resources/code/ant-contrib-1.0b3.jar b/resources/code/ant-contrib-1.0b3.jar deleted file mode 100644 index 06253766..00000000 Binary files a/resources/code/ant-contrib-1.0b3.jar and /dev/null differ diff --git a/resources/code/doc.sh b/resources/code/doc.sh deleted file mode 100644 index 1db9a92c..00000000 --- a/resources/code/doc.sh +++ /dev/null @@ -1,18 +0,0 @@ -# a shell script to create a java documentation -# for a processing library. -# -# make changes to the variables below so they -# fit the structure of your library - -# the package name of your library -package=template; - -# source folder location -src=../src; - -# the destination folder of your documentation -dest=../documentation; - - -# compile the java documentation -javadoc -d $dest -stylesheetfile ./stylesheet.css -sourcepath ${src} ${package} diff --git a/resources/install_instructions.txt b/resources/install_instructions.txt deleted file mode 100644 index a9253b24..00000000 --- a/resources/install_instructions.txt +++ /dev/null @@ -1,29 +0,0 @@ -How to install library ##name## - -Contributed libraries must be downloaded separately and placed within -the "libraries" folder of your Processing sketchbook. To find the Processing -sketchbook location on your computer, open the Preferences window from the -Processing application and look for the "Sketchbook location" item at the top. - -Copy the contributed library's folder into the "libraries" folder at this location. -You will need to create the "libraries" folder if this is your first contributed library. - -By default the following locations are used for your sketchbook folder. -For mac users the sketchbook folder is located inside ~/Documents/Processing. -for windows users the sketchbook folder is located inside folder 'My Documents'/Processing - -The folder structure for library ##name## should be as follows - -Processing - libraries - ##name## - examples - library - ##name##.jar - reference - src - - -After library ##name## has been successfully installed, restart processing. - - diff --git a/resources/library.properties b/resources/library.properties new file mode 100644 index 00000000..d3ea6180 --- /dev/null +++ b/resources/library.properties @@ -0,0 +1,43 @@ +# The name of your library as you want it formatted +name = Unfolding Maps + +# List of authors. Links can be provided using the syntax [author name](url) +authorList = [Till Nagel](http://tillnagel.com/) and others + +# A web page for your library, NOT a direct link to where to download it +url = http://www.unfoldingmaps.org/ + +# The category of your library, must be one (or many) of the following: +# "3D" "Animation" "Compilations" "Data" +# "Fabrication" "Geometry" "GUI" "Hardware" +# "I/O" "Language" "Math" "Simulation" +# "Sound" "Utilities" "Typography" "Video & Vision" +# +# If a value other than those listed is used, your library will listed as "Other." +category = Maps + +# A short sentence (or fragment) to summarize the library's function. This will be +# shown from inside the PDE when the library is being installed. Avoid repeating +# the name of your library here. Also, avoid saying anything redundant like +# mentioning that its a library. This should start with a capitalized letter, and +# end with a period. +sentence = Create interactive maps and geovisualizations. + +# Additional information suitable for the Processing website. The value of +# 'sentence' always will be prepended, so you should start by writing the +# second sentence here. If your library only works on certain operating systems, +# mention it here. +paragraph = + +# Links in the 'sentence' and 'paragraph' attributes can be inserted using the +# same syntax as for authors. That is, [here is a link to Processing](http://processing.org/) + + +# A version number that increments once with each release. This +# is used to compare different versions of the same library, and +# check if an update is available. You should think of it as a +# counter, counting the total number of releases you've had. +version = 95 # This must be parsable as an int + +# The version as the user will see it. If blank, the version attribute will be used here +prettyVersion = 0.9.5 # This is treated as a String \ No newline at end of file diff --git a/resources/singleAppJar-build.xml b/resources/singleAppJar-build.xml deleted file mode 100644 index 332fc40b..00000000 --- a/resources/singleAppJar-build.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/stylesheet.css b/resources/stylesheet.css deleted file mode 100644 index 54998c2b..00000000 --- a/resources/stylesheet.css +++ /dev/null @@ -1,310 +0,0 @@ -/* Javadoc style sheet */ -/* Define colors, fonts and other style attributes here to override the defaults */ -/* processingLibs style by andreas schlegel, sojamo */ - - -body { - margin : 0; - padding : 0; - padding-left : 10px; - padding-right : 8px; - background-color : #FFFFFF; - font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; - font-size : 100%; - font-size : 0.7em; - font-weight : normal; - line-height : normal; - margin-bottom:30px; -} - - - - -/* Headings */ -h1, h2, h3, h4, h5, th { - font-family :Arial, Helvetica, sans-serif; - font-size:1.2em; -} - - -p { - font-size : 1em; - width:80%; -} - -pre, code { - font-family : "Courier New", Courier, monospace; - font-size : 12px; - line-height : normal; -} - - - -table { - border:0; - margin-bottom:10px; - margin-top:10px; -} - - -tr, td { - border-top: 0px solid; - border-left: 0px solid; - padding-top:8px; - padding-bottom:8px; -} - - - -hr { - border:0; - height:1px; - padding:0; - margin:0; - margin-bottom:4px; - -} - - - -dd, th, td, font { - font-size:1.0em; - line-height:1.0em; -} - - - -dt { - margin-bottom:0px; -} - - - -dd { - margin-top:2px; - margin-bottom:4px; -} - - - -a { - text-decoration: underline; - font-weight: normal; -} - -a:hover, -a:active { - text-decoration: underline; - font-weight: normal; -} - -a:visited, -a:link:visited { - text-decoration: underline; - font-weight: normal; -} - - -img { - border: 0px solid #000000; -} - - - -/* Navigation bar fonts */ -.NavBarCell1 { - border:0; -} - -.NavBarCell1Rev { - border:0; -} - -.NavBarFont1 { - font-family: Arial, Helvetica, sans-serif; - font-size:1.1em; -} - - -.NavBarFont1 b { - font-weight:normal; -} - - - -.NavBarFont1:after, .NavBarFont1Rev:after { - font-weight:normal; - content: " \\"; -} - - -.NavBarFont1Rev { - font-family: Arial, Helvetica, sans-serif; - font-size:1.1em; -} - -.NavBarFont1Rev b { - font-family: Arial, Helvetica, sans-serif; - font-size:1.1em; - font-weight:normal; -} - -.NavBarCell2 { - font-family: Arial, Helvetica, sans-serif; -} - -.NavBarCell3 { - font-family: Arial, Helvetica, sans-serif; -} - - - -font.FrameItemFont { - font-family: Helvetica, Arial, sans-serif; - font-size:1.1em; - line-height:1.1em; -} - -font.FrameHeadingFont { - font-family: Helvetica, Arial, sans-serif; - line-height:32px; -} - -/* Font used in left-hand frame lists */ -.FrameTitleFont { - font-family: Helvetica, Arial, sans-serif -} - - -.toggleList { - padding:0; - margin:0; - margin-top:12px; -} - -.toggleList dt { - font-weight:bold; - font-size:12px; - font-family:arial,sans-serif; - padding:0px; - margin:10px 0px 10px 0px; -} - -.toggleList dt span { - font-family: monospace; - padding:0; - margin:0; -} - - -.toggleList dd { - margin:0; - padding:0; -} - -html.isjs .toggleList dd { - display: none; -} - -.toggleList pre { - padding: 4px 4px 4px 4px; -} - - - - - -/* COLORS */ - -pre, code { - color: #000000; -} - - -body { - color : #333333; - background-color :#FFFFFF; -} - - -h1, h2, h3, h4, h5, h6 { - color:#555; -} - -a, -.toggleList dt { - color: #1a7eb0; -} - -a:hover, -a:active { - color: #1a7eb0; -} - -a:visited, -a:link:visited { - color: #1a7eb0; -} - -td,tr { - border-color: #999999; -} - -hr { - color:#999999; - background:#999999; -} - - -.TableHeadingColor { - background: #dcdcdc; - color: #555; -} - - -.TableSubHeadingColor { - background: #EEEEFF -} - -.TableRowColor { - background: #FFFFFF -} - - -.NavBarCell1 { - background-color:#dcdcdc; - color:#000; -} - -.NavBarCell1 a { - color:#333; -} - - -.NavBarCell1Rev { - background-color:transparent; -} - -.NavBarFont1 { - color:#333; -} - - -.NavBarFont1Rev { - color:#fff; -} - -.NavBarCell2 { - background-color:#999; -} - -.NavBarCell2 a { - color:#fff; -} - - - -.NavBarCell3 { - background-color:#dcdcdc; -} - diff --git a/resources/unfolding_app_template/classpath b/resources/unfolding_app_template/classpath index caf9ba1d..fd7a9426 100644 --- a/resources/unfolding_app_template/classpath +++ b/resources/unfolding_app_template/classpath @@ -16,6 +16,6 @@ - + diff --git a/resources/unfolding_app_template/classpath_with_examples b/resources/unfolding_app_template/classpath_with_examples index 0c4d671d..2dd176d7 100644 --- a/resources/unfolding_app_template/classpath_with_examples +++ b/resources/unfolding_app_template/classpath_with_examples @@ -17,6 +17,6 @@ - + diff --git a/src/de/fhpotsdam/unfolding/Map.java b/src/de/fhpotsdam/unfolding/Map.java index 4ec33620..5f842cc8 100644 --- a/src/de/fhpotsdam/unfolding/Map.java +++ b/src/de/fhpotsdam/unfolding/Map.java @@ -8,31 +8,31 @@ public class Map extends UnfoldingMap { @Deprecated public Map(PApplet p) { - super(p, generateId(), 0, 0, p.width, p.height, true, false, null); + super(p, generateId(), 0, 0, p.width, p.height, true, false, null, null); } @Deprecated public Map(PApplet p, AbstractMapProvider provider) { - super(p, generateId(), 0, 0, p.width, p.height, true, false, provider); + super(p, generateId(), 0, 0, p.width, p.height, true, false, provider, null); } @Deprecated public Map(PApplet p, float x, float y, float width, float height) { - super(p, generateId(), x, y, width, height, true, false, null); + super(p, generateId(), x, y, width, height, true, false, null, null); } @Deprecated public Map(PApplet p, String id, float x, float y, float width, float height) { - super(p, id, x, y, width, height, true, false, null); + super(p, id, x, y, width, height, true, false, null, null); } @Deprecated public Map(PApplet p, String id, float x, float y, float width, float height, boolean useDistortion) { - super(p, id, x, y, width, height, true, useDistortion, null); + super(p, id, x, y, width, height, true, useDistortion, null, null); } @Deprecated public Map(PApplet p, float x, float y, float width, float height, AbstractMapProvider provider) { - super(p, generateId(), x, y, width, height, true, false, provider); + super(p, generateId(), x, y, width, height, true, false, provider, null); } } diff --git a/src/de/fhpotsdam/unfolding/UnfoldingMap.java b/src/de/fhpotsdam/unfolding/UnfoldingMap.java index 7c7667ca..dc01da1c 100644 --- a/src/de/fhpotsdam/unfolding/UnfoldingMap.java +++ b/src/de/fhpotsdam/unfolding/UnfoldingMap.java @@ -28,7 +28,9 @@ * Acts as facade for the map interactions, e.g. using innerScale for zooming, and outerRotate for rotating. */ public class UnfoldingMap implements MapEventListener { - + + public static final String GREETING_MESSAGE = "Unfolding Map v0.9.5"; + public static final float SCALE_DELTA_IN = 1.05f; public static final float SCALE_DELTA_OUT = 1 / 1.05f; @@ -96,7 +98,7 @@ public class UnfoldingMap implements MapEventListener { * The ID of this map. */ public UnfoldingMap(PApplet p, String id) { - this(p, id, 0, 0, p.width, p.height, true, false, null); + this(p, id, 0, 0, p.width, p.height, true, false, null, null); } /** @@ -106,7 +108,7 @@ public UnfoldingMap(PApplet p, String id) { * The main applet. */ public UnfoldingMap(PApplet p) { - this(p, generateId(), 0, 0, p.width, p.height, true, false, null); + this(p, generateId(), 0, 0, p.width, p.height, true, false, null, null); } /** @@ -118,7 +120,7 @@ public UnfoldingMap(PApplet p) { * The map tiles provider to use. */ public UnfoldingMap(PApplet p, AbstractMapProvider provider) { - this(p, generateId(), 0, 0, p.width, p.height, true, false, provider); + this(p, generateId(), 0, 0, p.width, p.height, true, false, provider, null); } /** @@ -132,7 +134,7 @@ public UnfoldingMap(PApplet p, AbstractMapProvider provider) { * The map tiles provider to use. */ public UnfoldingMap(PApplet p, String id, AbstractMapProvider provider) { - this(p, id, 0, 0, p.width, p.height, true, false, provider); + this(p, id, 0, 0, p.width, p.height, true, false, provider, null); } /** @@ -150,7 +152,11 @@ public UnfoldingMap(PApplet p, String id, AbstractMapProvider provider) { * The height of this map. */ public UnfoldingMap(PApplet p, float x, float y, float width, float height) { - this(p, generateId(), x, y, width, height, true, false, null); + this(p, generateId(), x, y, width, height, true, false, null, null); + } + + public UnfoldingMap(PApplet p, float x, float y, float width, float height, String renderer) { + this(p, generateId(), x, y, width, height, true, false, null, renderer); } /** @@ -170,11 +176,20 @@ public UnfoldingMap(PApplet p, float x, float y, float width, float height) { * The height of this map. */ public UnfoldingMap(PApplet p, String id, float x, float y, float width, float height) { - this(p, id, x, y, width, height, true, false, null); + this(p, id, x, y, width, height, true, false, null, null); + } + + public UnfoldingMap(PApplet p, String id, float x, float y, float width, float height, String renderer) { + this(p, id, x, y, width, height, true, false, null, renderer); } public UnfoldingMap(PApplet p, String id, float x, float y, float width, float height, boolean useDistortion) { - this(p, id, x, y, width, height, true, useDistortion, null); + this(p, id, x, y, width, height, true, useDistortion, null, null); + } + + public UnfoldingMap(PApplet p, String id, float x, float y, float width, float height, boolean useDistortion, + String renderer) { + this(p, id, x, y, width, height, true, useDistortion, null, renderer); } /** @@ -194,7 +209,17 @@ public UnfoldingMap(PApplet p, String id, float x, float y, float width, float h * The map tiles provider to use. */ public UnfoldingMap(PApplet p, float x, float y, float width, float height, AbstractMapProvider provider) { - this(p, generateId(), x, y, width, height, true, false, provider); + this(p, generateId(), x, y, width, height, true, false, provider, null); + } + + public UnfoldingMap(PApplet p, float x, float y, float width, float height, AbstractMapProvider provider, + String renderer) { + this(p, generateId(), x, y, width, height, true, false, provider, renderer); + } + + public UnfoldingMap(PApplet p, String id, float x, float y, float width, float height, boolean useMask, + boolean useDistortion, AbstractMapProvider provider) { + this(p, generateId(), x, y, width, height, true, false, provider, null); } /** @@ -220,17 +245,17 @@ public UnfoldingMap(PApplet p, float x, float y, float width, float height, Abst * The map tiles provider to use. */ public UnfoldingMap(PApplet p, String id, float x, float y, float width, float height, boolean useMask, - boolean useDistortion, AbstractMapProvider provider) { + boolean useDistortion, AbstractMapProvider provider, String renderer) { this.p = p; this.id = id; if (!greetingMessageDisplayed) { - PApplet.println("Unfolding Map v0.9.3"); + PApplet.println(GREETING_MESSAGE); greetingMessageDisplayed = true; } this.mapDisplay = MapDisplayFactory.getMapDisplay(p, id, x, y, width, height, useMask, useDistortion, provider, - this); + this, renderer); // panCenterZoomTo(PRIME_MERIDIAN_EQUATOR_LOCATION, DEFAULT_ZOOM_LEVEL); @@ -257,6 +282,15 @@ protected void prepareMapChangedMethod() { } } + /** + * Check whether all currently visible tiles have been loaded. + * + * @return True if all tiles have been loaded, false otherwise. + */ + public boolean allTilesLoaded() { + return mapDisplay.allTilesLoaded(); + } + protected static String generateId() { return UUID.randomUUID().toString(); } @@ -676,7 +710,9 @@ public void pan(ScreenPosition from, ScreenPosition to) { * Pans from one location to another one. * * @param fromLocation + * Origin location to pan from. * @param toLocation + * Destination location to pan to. */ public void pan(Location fromLocation, Location toLocation) { float[] xy1 = mapDisplay.getObjectFromLocation(fromLocation); @@ -688,23 +724,42 @@ public void pan(Location fromLocation, Location toLocation) { addInnerOffset(dx, dy); } + /** + * Pans by distance in screen coordinates. + * + * @param dx + * Horizontal distance in pixel. + * @param dy + * Vertical distance in pixel. + */ public void panBy(float dx, float dy) { - float[] dxy = mapDisplay.getObjectFromScreenPosition(dx, dy); - addInnerOffset(dxy[0], dxy[1]); + addInnerOffset(dx, dy); } + /** + * Pans one tile to the left. + */ public void panLeft() { addInnerOffset(PAN_DEFAULT_DELTA, 0); } + /** + * Pans one tile to the right. + */ public void panRight() { addInnerOffset(-PAN_DEFAULT_DELTA, 0); } + /** + * Pans one tile up. + */ public void panUp() { addInnerOffset(0, PAN_DEFAULT_DELTA); } + /** + * Pans one tile down. + */ public void panDown() { addInnerOffset(0, -PAN_DEFAULT_DELTA); } @@ -735,6 +790,19 @@ public void move(ScreenPosition screenPosition) { setOffset(screenPosition.x, screenPosition.y); } + /** + * Moves the map by the given screen coordinates. + * + * @param dx + * The x distance to move by. + * @param dy + * The y distance to move by. + * + */ + public void moveBy(float dx, float dy) { + addOffset(dx, dy); + } + // MarkerManagement ----------------------------------------------- /** @@ -875,7 +943,7 @@ public Marker getFirstHitMarker(float checkX, float checkY) { public List getHitMarkers(float checkX, float checkY) { return mapDisplay.getDefaultMarkerManager().getHitMarkers(checkX, checkY); } - + /** * @deprecated Use {@link #getHitMarkers(float, float)} instead. */ @@ -883,8 +951,6 @@ public List getHitMarker(float checkX, float checkY) { return getHitMarkers(checkX, checkY); } - - // Transformations ------------------------------------ protected void setOuterRotate(float angle) { @@ -1192,9 +1258,9 @@ public void setTweening(boolean tweening) { * Sets the background color of this map. * * @param bgColor - * The color in Processing notation. + * The color in the current colorMode. */ - public void setBackgroundColor(int bgColor) { + public void setBackgroundColor(Integer bgColor) { this.mapDisplay.setBackgroundColor(bgColor); } diff --git a/src/de/fhpotsdam/unfolding/data/GPXReader.java b/src/de/fhpotsdam/unfolding/data/GPXReader.java index a9dd00cb..04c76760 100644 --- a/src/de/fhpotsdam/unfolding/data/GPXReader.java +++ b/src/de/fhpotsdam/unfolding/data/GPXReader.java @@ -4,7 +4,7 @@ import java.util.List; import processing.core.PApplet; -import processing.xml.XMLElement; +import processing.data.XML; import de.fhpotsdam.unfolding.data.Feature.FeatureType; import de.fhpotsdam.unfolding.geo.Location; @@ -22,7 +22,7 @@ public static List loadData(PApplet p, String gpxFilename) { List trackFeatures = new ArrayList(); // Load GPX file - XMLElement gpx = new XMLElement(p, gpxFilename); + XML gpx = p.loadXML(gpxFilename); // TODO Handle multiple features in one GPX file @@ -30,9 +30,9 @@ public static List loadData(PApplet p, String gpxFilename) { ShapeFeature trackFeature = new ShapeFeature(FeatureType.LINES); List trackPointTimes = new ArrayList(); - XMLElement[] itemXMLElements = gpx.getChildren("trk/trkseg/trkpt"); - for (int i = 0; i < itemXMLElements.length; i++) { - XMLElement trackPoint = itemXMLElements[i]; + XML[] itemXML = gpx.getChildren("trk/trkseg/trkpt"); + for (int i = 0; i < itemXML.length; i++) { + XML trackPoint = itemXML[i]; // Adds location for track point float lat = trackPoint.getFloat("lat"); @@ -40,19 +40,19 @@ public static List loadData(PApplet p, String gpxFilename) { Location location = new Location(lat, lon); trackFeature.addLocation(location); - XMLElement trackPointTime = trackPoint.getChild("time"); + XML trackPointTime = trackPoint.getChild("time"); if (trackPointTime != null) { trackPointTimes.add(trackPointTime.getContent()); } } // Add name for whole track as property - XMLElement nameXMLElement = gpx.getChild("trk/name"); + XML nameXMLElement = gpx.getChild("trk/name"); if (nameXMLElement != null) { trackFeature.addProperty("name", nameXMLElement.getContent()); } // Add (single) time for whole track as property - XMLElement timeXMLElement = gpx.getChild("trk/time"); + XML timeXMLElement = gpx.getChild("trk/time"); if (timeXMLElement != null) { trackFeature.addProperty("time", timeXMLElement.getContent()); } diff --git a/src/de/fhpotsdam/unfolding/data/GeoRSSReader.java b/src/de/fhpotsdam/unfolding/data/GeoRSSReader.java index da163c60..e58e4121 100644 --- a/src/de/fhpotsdam/unfolding/data/GeoRSSReader.java +++ b/src/de/fhpotsdam/unfolding/data/GeoRSSReader.java @@ -4,7 +4,7 @@ import java.util.List; import processing.core.PApplet; -import processing.xml.XMLElement; +import processing.data.XML; import de.fhpotsdam.unfolding.geo.Location; /** @@ -14,16 +14,25 @@ */ public class GeoRSSReader extends GeoDataReader { + /** + * Loads features from RSS feed in W3C Geo format (geo:lat and geo:long) + * + * @param p + * The PApplet. + * @param fileName + * The name of the GeoRSS file (can be local or remote, i.e. a URI) + * @return A list of geo features. + */ public static List loadData(PApplet p, String fileName) { List features = new ArrayList(); - XMLElement rss = new XMLElement(p, fileName); + XML rss = p.loadXML(fileName); // Get all items - XMLElement[] itemXMLElements = rss.getChildren("channel/item"); - for (int i = 0; i < itemXMLElements.length; i++) { + XML[] itemXML = rss.getChildren("channel/item"); + for (int i = 0; i < itemXML.length; i++) { // Sets lat,lon as locations for each item - XMLElement latXML = itemXMLElements[i].getChild("geo:lat"); - XMLElement lonXML = itemXMLElements[i].getChild("geo:long"); + XML latXML = itemXML[i].getChild("geo:lat"); + XML lonXML = itemXML[i].getChild("geo:long"); if (latXML != null && latXML.getContent() != null) { float lat = Float.valueOf(latXML.getContent()); float lon = Float.valueOf(lonXML.getContent()); @@ -33,7 +42,7 @@ public static List loadData(PApplet p, String fileName) { features.add(pointFeature); // Sets title if existing - XMLElement titleXML = itemXMLElements[i].getChild("title"); + XML titleXML = itemXML[i].getChild("title"); if (titleXML != null && titleXML.getContent() != null) { pointFeature.putProperty("title", titleXML.getContent()); } @@ -43,15 +52,24 @@ public static List loadData(PApplet p, String fileName) { return features; } + /** + * Loads features from RSS feed in GeoRSS format (georss:point). + * + * @param p + * The PApplet. + * @param fileName + * The name of the GeoRSS file (can be local or remote, i.e. a URI) + * @return A list of geo features. + */ public static List loadDataGeoRSS(PApplet p, String fileName) { List features = new ArrayList(); - XMLElement rss = new XMLElement(p, fileName); + XML rss = p.loadXML(fileName); // Get all items - XMLElement[] itemXMLElements = rss.getChildren("entry"); - for (int i = 0; i < itemXMLElements.length; i++) { + XML[] itemXML = rss.getChildren("entry"); + for (int i = 0; i < itemXML.length; i++) { // Sets lat,lon as locations for each item - XMLElement pointXML = itemXMLElements[i].getChild("georss:point"); + XML pointXML = itemXML[i].getChild("georss:point"); if (pointXML != null && pointXML.getContent() != null) { String point = pointXML.getContent(); String[] latLon = point.split(" "); @@ -63,26 +81,32 @@ public static List loadDataGeoRSS(PApplet p, String fileName) { features.add(pointFeature); // Sets title if existing - XMLElement titleXML = itemXMLElements[i].getChild("title"); + XML titleXML = itemXML[i].getChild("title"); if (titleXML != null && titleXML.getContent() != null) { pointFeature.putProperty("title", titleXML.getContent()); } // Sets date if existing - XMLElement dateXML = itemXMLElements[i].getChild("dc:date"); + XML dateXML = itemXML[i].getChild("dc:date"); if (dateXML != null && dateXML.getContent() != null) { pointFeature.putProperty("date", dateXML.getContent()); } // Sets magnitude if existing - XMLElement[] catXMLElements = itemXMLElements[i].getChildren("category"); - for (int c = 0; c < catXMLElements.length; c++) { - String label = catXMLElements[c].getString("label"); + XML[] catXML = itemXML[i].getChildren("category"); + for (int c = 0; c < catXML.length; c++) { + String label = catXML[c].getString("label"); if ("Magnitude".equals(label)) { - pointFeature.putProperty("magnitude", catXMLElements[c].getFloat("term")); + Float magnitude = 0f; + String magnitudeString = catXML[c].getString("term"); + if (magnitudeString.contains("Magnitude")) { + magnitudeString = magnitudeString.replace("Magnitude", ""); + } + magnitude = Float.valueOf(magnitudeString); + pointFeature.putProperty("magnitude", magnitude); } } - // getChild("category[@label='Magnitude']"); // not supported by XMLELement + // getChild("category[@label='Magnitude']"); // not supported by XMLElement } } diff --git a/src/de/fhpotsdam/unfolding/interactions/KeyboardHandler.java b/src/de/fhpotsdam/unfolding/interactions/KeyboardHandler.java index f7f1fdad..31c1d766 100644 --- a/src/de/fhpotsdam/unfolding/interactions/KeyboardHandler.java +++ b/src/de/fhpotsdam/unfolding/interactions/KeyboardHandler.java @@ -1,11 +1,12 @@ package de.fhpotsdam.unfolding.interactions; -import java.awt.event.KeyEvent; import java.util.Arrays; import java.util.List; import processing.core.PApplet; import processing.core.PConstants; +import processing.event.KeyEvent; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.events.MapEventBroadcaster; import de.fhpotsdam.unfolding.events.PanMapEvent; @@ -39,7 +40,7 @@ public KeyboardHandler(PApplet p, UnfoldingMap... maps) { public KeyboardHandler(PApplet p, List maps) { super(maps); - p.registerKeyEvent(this); + p.registerMethod("keyEvent",this); } public void keyPressed(char key, int keyCode) { @@ -89,14 +90,14 @@ public void keyReleased(char key, int keyCode) { } public void keyEvent(KeyEvent keyEvent) { - char key = keyEvent.getKeyChar(); + char key = keyEvent.getKey(); int keyCode = keyEvent.getKeyCode(); - switch (keyEvent.getID()) { - case KeyEvent.KEY_PRESSED: + switch (keyEvent.getAction()) { + case KeyEvent.PRESS: keyPressed(key, keyCode); break; - case KeyEvent.KEY_RELEASED: + case KeyEvent.RELEASE: keyReleased(key, keyCode); break; } diff --git a/src/de/fhpotsdam/unfolding/interactions/MouseHandler.java b/src/de/fhpotsdam/unfolding/interactions/MouseHandler.java index c8bb6be1..ab675906 100644 --- a/src/de/fhpotsdam/unfolding/interactions/MouseHandler.java +++ b/src/de/fhpotsdam/unfolding/interactions/MouseHandler.java @@ -1,12 +1,11 @@ package de.fhpotsdam.unfolding.interactions; -import java.awt.event.InputEvent; -import java.awt.event.MouseEvent; import java.util.Arrays; import java.util.List; import processing.core.PApplet; import processing.core.PConstants; +import processing.event.MouseEvent; import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.events.MapEventBroadcaster; import de.fhpotsdam.unfolding.events.PanMapEvent; @@ -41,19 +40,13 @@ public MouseHandler(PApplet p, UnfoldingMap... maps) { public MouseHandler(PApplet p, List maps) { super(maps); - p.registerMouseEvent(this); - - p.addMouseWheelListener(new java.awt.event.MouseWheelListener() { - public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) { - mouseWheel(evt.getWheelRotation()); - } - }); + p.registerMethod("mouseEvent", this); } public void mouseClicked() { for (UnfoldingMap map : maps) { if (map.isHit(mouseX, mouseY)) { - if (mouseEvent.getClickCount() == 2) { + if (mouseButton == PConstants.LEFT && mouseEvent.getCount() == 2) { // Pan + Zoom (order is important) PanMapEvent panMapEvent = new PanMapEvent(this, map.getId()); @@ -95,17 +88,19 @@ public void mouseWheel(float delta) { public void mouseDragged() { for (UnfoldingMap map : maps) { if (map.isHit(mouseX, mouseY)) { - // log.debug("mouse: fire panTo for " + map.getId()); + if (mouseButton == PConstants.LEFT) { + // log.debug("mouse: fire panTo for " + map.getId()); - // Pan between two locations, so other listening maps can pan correctly + // Pan between two locations, so other listening maps can pan correctly - Location oldLocation = map.getLocation(pmouseX, pmouseY); - Location newLocation = map.getLocation(mouseX, mouseY); + Location oldLocation = map.getLocation(pmouseX, pmouseY); + Location newLocation = map.getLocation(mouseX, mouseY); - PanMapEvent panMapEvent = new PanMapEvent(this, map.getId(), PanMapEvent.PAN_BY); - panMapEvent.setFromLocation(oldLocation); - panMapEvent.setToLocation(newLocation); - eventDispatcher.fireMapEvent(panMapEvent); + PanMapEvent panMapEvent = new PanMapEvent(this, map.getId(), PanMapEvent.PAN_BY); + panMapEvent.setFromLocation(oldLocation); + panMapEvent.setToLocation(newLocation); + eventDispatcher.fireMapEvent(panMapEvent); + } } } } @@ -121,62 +116,46 @@ public void mouseMoved() { private int mouseX; private int mouseY; private int pmouseX, pmouseY; - private int dmouseX, dmouseY; private int emouseX, emouseY; private boolean firstMouse; private int mouseButton; - private boolean mousePressed; private MouseEvent mouseEvent; public void mouseEvent(MouseEvent event) { - int id = event.getID(); + int action = event.getAction(); mouseEvent = event; - if ((id == MouseEvent.MOUSE_DRAGGED) || (id == MouseEvent.MOUSE_MOVED)) { + if ((action == MouseEvent.DRAG) || (action == MouseEvent.MOVE)) { pmouseX = emouseX; pmouseY = emouseY; mouseX = event.getX(); mouseY = event.getY(); } - int modifiers = event.getModifiers(); - if ((modifiers & InputEvent.BUTTON1_MASK) != 0) { - mouseButton = PConstants.LEFT; - } else if ((modifiers & InputEvent.BUTTON2_MASK) != 0) { - mouseButton = PConstants.CENTER; - } else if ((modifiers & InputEvent.BUTTON3_MASK) != 0) { - mouseButton = PConstants.RIGHT; - } + mouseButton = event.getButton(); if (firstMouse) { pmouseX = mouseX; pmouseY = mouseY; - dmouseX = mouseX; - dmouseY = mouseY; firstMouse = false; } - switch (id) { - case MouseEvent.MOUSE_PRESSED: - mousePressed = true; - // mousePressed(); - break; - case MouseEvent.MOUSE_RELEASED: - mousePressed = false; - // mouseReleased(); - break; - case MouseEvent.MOUSE_CLICKED: + switch (action) { + case MouseEvent.CLICK: mouseClicked(); break; - case MouseEvent.MOUSE_DRAGGED: + case MouseEvent.DRAG: mouseDragged(); break; - case MouseEvent.MOUSE_MOVED: + case MouseEvent.MOVE: mouseMoved(); break; + case MouseEvent.WHEEL: + mouseWheel(event.getCount()); + break; } - if ((id == MouseEvent.MOUSE_DRAGGED) || (id == MouseEvent.MOUSE_MOVED)) { + if ((action == MouseEvent.DRAG) || (action == MouseEvent.MOVE)) { emouseX = mouseX; emouseY = mouseY; } diff --git a/src/de/fhpotsdam/unfolding/mapdisplay/AbstractMapDisplay.java b/src/de/fhpotsdam/unfolding/mapdisplay/AbstractMapDisplay.java index 36f78729..92f4a2a2 100644 --- a/src/de/fhpotsdam/unfolding/mapdisplay/AbstractMapDisplay.java +++ b/src/de/fhpotsdam/unfolding/mapdisplay/AbstractMapDisplay.java @@ -10,7 +10,6 @@ import processing.core.PGraphics; import processing.core.PVector; -import codeanticode.glgraphics.GLGraphicsOffScreen; import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.core.Coordinate; import de.fhpotsdam.unfolding.geo.Location; @@ -74,6 +73,9 @@ public abstract class AbstractMapDisplay implements TileLoaderListener { // public int max_images_to_keep = 1024; public int grid_padding = 1; // set to 0 for debugging purposes + /** Check whether all currently visible tiles have been loaded. */ + protected boolean allTilesLoaded = false; + protected AbstractMapProvider provider; protected Hashtable pending = new Hashtable(); protected Hashtable images = new Hashtable(); @@ -119,13 +121,19 @@ public void setMapProvider(AbstractMapProvider provider) { public abstract PGraphics getOuterPG(); - public GLGraphicsOffScreen getMask() { + public PGraphics getMask() { return null; } public abstract void draw(); - public abstract void setBackgroundColor(int color); + /** + * Sets background color of map. + * + * @param color + * Color for the background canvas. Can be semi-transparent. If null it is not used. + */ + public abstract void setBackgroundColor(Integer color); // MarkerManagement ----------------------------------------------- @@ -315,10 +323,22 @@ public void tileLoaded(Coordinate coord, Object image) { } if (pending.size() == 0 && queue.size() == 0) { + allTilesLoaded = true; tilesLoaded(); + } else { + allTilesLoaded = false; } } + /** + * Check whether all currently visible tiles have been loaded. + * + * @return True if all tiles have been loaded, false otherwise. + */ + public boolean allTilesLoaded() { + return allTilesLoaded; + } + /** * Will be called if all tiles have been loaded. Subclasses can implement this method to notify a method in the * client app. @@ -336,7 +356,7 @@ public void setCenter(Coordinate center) { public int compare(Coordinate c1, Coordinate c2) { if (c1.zoom == center.zoom) { if (c2.zoom == center.zoom) { - // only compare squared distances� saves cpu + // only compare squared distances, saves cpu float d1 = (float) Math.pow(c1.column - center.column, 2) + (float) Math.pow(c1.row - center.row, 2); float d2 = (float) Math.pow(c2.column - center.column, 2) diff --git a/src/de/fhpotsdam/unfolding/mapdisplay/DistortedGLGraphicsMapDisplay.java b/src/de/fhpotsdam/unfolding/mapdisplay/DistortedGLGraphicsMapDisplay.java index ced8a4c2..491a45ed 100644 --- a/src/de/fhpotsdam/unfolding/mapdisplay/DistortedGLGraphicsMapDisplay.java +++ b/src/de/fhpotsdam/unfolding/mapdisplay/DistortedGLGraphicsMapDisplay.java @@ -9,14 +9,14 @@ import de.fhpotsdam.unfolding.texture.LinearInterpolationDistorter; import de.fhpotsdam.unfolding.texture.TextureDistorter; -public class DistortedGLGraphicsMapDisplay extends GLGraphicsMapDisplay { +public class DistortedGLGraphicsMapDisplay extends OpenGLMapDisplay { public Distorter distorter; public TextureDistorter textureDistorter; public DistortedGLGraphicsMapDisplay(PApplet papplet, AbstractMapProvider provider, float offsetX, float offsetY, float width, float height) { - super(papplet, provider, offsetX, offsetY, width, height); + super(papplet, provider, null, offsetX, offsetY, width, height); distorter = new LinearInterpolationDistorter(width / 2, height / 2); textureDistorter = new TextureDistorter(papplet, width, height, 10); @@ -25,7 +25,7 @@ public DistortedGLGraphicsMapDisplay(PApplet papplet, AbstractMapProvider provid public DistortedGLGraphicsMapDisplay(PApplet papplet, AbstractMapProvider provider, float offsetX, float offsetY, float width, float height, Distorter distorter) { - super(papplet, provider, offsetX, offsetY, width, height); + super(papplet, provider, null, offsetX, offsetY, width, height); this.distorter = distorter; textureDistorter = new TextureDistorter(papplet, width, height, 10); @@ -35,7 +35,7 @@ public DistortedGLGraphicsMapDisplay(PApplet papplet, AbstractMapProvider provid protected void postDraw() { // Draws inner map (with inner marker) and outer marker offscreenCutoffPG.beginDraw(); - offscreenCutoffPG.image(offscreenPG.getTexture(), 0, 0); + offscreenCutoffPG.image(offscreenPG, 0, 0); for (MarkerManager mm : markerManagerList) { mm.draw(); } @@ -48,7 +48,7 @@ protected void postDraw() { canvasPG.translate(offsetX, offsetY); canvasPG.applyMatrix(matrix); - textureDistorter.draw(canvasPG, offscreenPG.getTexture()); + textureDistorter.draw(canvasPG, offscreenPG); //canvasPG.image(offscreenCutoffPG.getTexture(), 0, 0); canvasPG.popMatrix(); } diff --git a/src/de/fhpotsdam/unfolding/mapdisplay/GLGraphicsMapDisplay.java b/src/de/fhpotsdam/unfolding/mapdisplay/GLGraphicsMapDisplay.java deleted file mode 100644 index 674189d4..00000000 --- a/src/de/fhpotsdam/unfolding/mapdisplay/GLGraphicsMapDisplay.java +++ /dev/null @@ -1,65 +0,0 @@ -package de.fhpotsdam.unfolding.mapdisplay; - -import processing.core.PApplet; -import processing.core.PConstants; -import processing.core.PGraphics; -import codeanticode.glgraphics.GLGraphicsOffScreen; -import de.fhpotsdam.unfolding.marker.Marker; -import de.fhpotsdam.unfolding.marker.MarkerManager; -import de.fhpotsdam.unfolding.providers.AbstractMapProvider; - -public class GLGraphicsMapDisplay extends ProcessingMapDisplay implements PConstants { - - // Inner map (and inner marker) will be drawn on this. - protected GLGraphicsOffScreen offscreenPG; - // Outer marker will be drawn on this - protected GLGraphicsOffScreen offscreenCutoffPG; - - protected float opacity = 255; - - public GLGraphicsMapDisplay(PApplet papplet, AbstractMapProvider provider, float offsetX, float offsetY, - float width, float height) { - super(papplet, provider, offsetX, offsetY, width, height); - - offscreenPG = new GLGraphicsOffScreen(papplet, (int) width, (int) height, true); - offscreenCutoffPG = new GLGraphicsOffScreen(papplet, (int) width, (int) height, true); - } - - @Override - public void resize(float width, float height) { - super.resize(width, height); - offscreenPG = new GLGraphicsOffScreen(papplet, (int) width, (int) height); - offscreenCutoffPG = new GLGraphicsOffScreen(papplet, (int) width, (int) height); - } - - @Override - public PGraphics getInnerPG() { - return offscreenPG; - } - - @Override - public PGraphics getOuterPG() { - return offscreenCutoffPG; - } - - @Override - protected void postDraw() { - // Draws inner map (with inner marker) and outer marker - offscreenCutoffPG.beginDraw(); - offscreenCutoffPG.image(offscreenPG.getTexture(), 0, 0); - for (MarkerManager mm : markerManagerList) { - mm.draw(); - } - offscreenCutoffPG.endDraw(); - - // Transforms (outer) map pane, and draws inner map + marker onto canvas - // This cuts off marker at the border. - PGraphics canvasPG = papplet.g; - canvasPG.pushMatrix(); - canvasPG.translate(offsetX, offsetY); - canvasPG.applyMatrix(matrix); - canvasPG.image(offscreenCutoffPG.getTexture(), 0, 0); - canvasPG.popMatrix(); - } - -} diff --git a/src/de/fhpotsdam/unfolding/mapdisplay/ProcessingMapDisplay.java b/src/de/fhpotsdam/unfolding/mapdisplay/Java2DMapDisplay.java similarity index 93% rename from src/de/fhpotsdam/unfolding/mapdisplay/ProcessingMapDisplay.java rename to src/de/fhpotsdam/unfolding/mapdisplay/Java2DMapDisplay.java index 368f6986..6412f741 100644 --- a/src/de/fhpotsdam/unfolding/mapdisplay/ProcessingMapDisplay.java +++ b/src/de/fhpotsdam/unfolding/mapdisplay/Java2DMapDisplay.java @@ -22,10 +22,13 @@ import de.fhpotsdam.unfolding.tiles.TileLoader; import de.fhpotsdam.unfolding.utils.ScreenPosition; +/** + * The internal MapDisplay to handle the map display in Processing 2D (and used as super class for 3D) + */ @SuppressWarnings("unchecked") -public class ProcessingMapDisplay extends AbstractMapDisplay implements PConstants { +public class Java2DMapDisplay extends AbstractMapDisplay implements PConstants { - public static Logger log = Logger.getLogger(ProcessingMapDisplay.class); + public static Logger log = Logger.getLogger(Java2DMapDisplay.class); // Used for loadImage and float maths public PApplet papplet; @@ -37,7 +40,7 @@ public class ProcessingMapDisplay extends AbstractMapDisplay implements PConstan protected PMatrix3D matrix = new PMatrix3D(); // Background color - protected int bgColor = 0; + protected Integer bgColor = null; // To notify client app when all tiles have been loaded private static final String TILESLOADED_METHOD_NAME = "tilesLoaded"; @@ -46,15 +49,15 @@ public class ProcessingMapDisplay extends AbstractMapDisplay implements PConstan /** * Creates a new MapDisplay with full canvas size, and given provider */ - public ProcessingMapDisplay(PApplet papplet, AbstractMapProvider provider) { + public Java2DMapDisplay(PApplet papplet, AbstractMapProvider provider) { this(papplet, provider, 0, 0, papplet.width, papplet.height); } /** * Creates a new MapDisplay. */ - public ProcessingMapDisplay(PApplet papplet, AbstractMapProvider provider, float offsetX, float offsetY, - float width, float height) { + public Java2DMapDisplay(PApplet papplet, AbstractMapProvider provider, float offsetX, float offsetY, float width, + float height) { super(provider, width, height); this.papplet = papplet; @@ -339,17 +342,22 @@ public void draw() { PGraphics pg = getInnerPG(); pg.beginDraw(); - // Store and switch off smooth (OpenGL cannot handle it) - boolean smooth = papplet.g.smooth; - pg.noSmooth(); - // REVISIT For transparency, do not paint bg - // But needed to delete panning off the map (in order to not smudge) - pg.background(bgColor); + // Clears canvas (set to transparency, to not smudge previous map on panning) + pg.clear(); + if (bgColor != null) { + // Set background color if given (can also be transparent) + pg.background(bgColor); + } // translate and scale, from the middle pg.pushMatrix(); pg.translate((float) innerOffsetX, (float) innerOffsetY); - pg.applyMatrix(innerMatrix); + if (pg.is3D()) { + pg.applyMatrix(innerMatrix); + } else { + pg.applyMatrix(innerMatrix.m00, innerMatrix.m01, innerMatrix.m03, innerMatrix.m10, innerMatrix.m11, + innerMatrix.m13); + } Vector visibleKeys = getVisibleKeys(pg); @@ -390,14 +398,15 @@ public void draw() { postDraw(); cleanupImageBuffer(); - - // Restore smoothing, if needed - if (smooth) { - papplet.smooth(); - } } - public void setBackgroundColor(int color) { + /** + * Sets background color of map. + * + * @param color + * Color for the background canvas. Can be semi-transparent. If null it is not used. + */ + public void setBackgroundColor(Integer color) { this.bgColor = color; } diff --git a/src/de/fhpotsdam/unfolding/mapdisplay/MapDisplayFactory.java b/src/de/fhpotsdam/unfolding/mapdisplay/MapDisplayFactory.java index 14629083..2da10779 100644 --- a/src/de/fhpotsdam/unfolding/mapdisplay/MapDisplayFactory.java +++ b/src/de/fhpotsdam/unfolding/mapdisplay/MapDisplayFactory.java @@ -11,9 +11,7 @@ */ @SuppressWarnings("rawtypes") public class MapDisplayFactory { - public static final String OPEN_GL_CLASSNAME = "processing.opengl.PGraphicsOpenGL"; - public static final String GLGRAPHICS_CLASSNAME = "codeanticode.glgraphics.GLGraphics"; public static final boolean DEFAULT_USE_MASK = true; public static final boolean DEFAULT_USE_DISTORTION = false; @@ -22,12 +20,13 @@ public class MapDisplayFactory { public static final int OSM_STYLE_ID = 65678; // test: 69960; // original: 998 public static AbstractMapDisplay getMapDisplay(PApplet p, String id, float x, float y, float width, float height, - AbstractMapProvider provider, UnfoldingMap map) { - return getMapDisplay(p, id, x, y, width, height, DEFAULT_USE_MASK, DEFAULT_USE_DISTORTION, provider, map); + AbstractMapProvider provider, UnfoldingMap map, String renderer) { + return getMapDisplay(p, id, x, y, width, height, DEFAULT_USE_MASK, DEFAULT_USE_DISTORTION, provider, map, + renderer); } public static AbstractMapDisplay getMapDisplay(PApplet p, String id, float x, float y, float width, float height, - boolean useMask, boolean useDistortion, AbstractMapProvider provider, UnfoldingMap map) { + boolean useMask, boolean useDistortion, AbstractMapProvider provider, UnfoldingMap map, String renderer) { AbstractMapDisplay mapDisplay = null; @@ -35,45 +34,17 @@ public static AbstractMapDisplay getMapDisplay(PApplet p, String id, float x, fl provider = getDefaultProvider(); } - if (useMask) { - try { - Class glGraphicsClass = Class.forName(GLGRAPHICS_CLASSNAME); - if (glGraphicsClass.isInstance(p.g)) { - if (useDistortion) { - // log.debug("Using DistortedGLGraphicsMapDisplay for '" + id + "'"); - mapDisplay = new DistortedGLGraphicsMapDisplay(p, provider, x, y, width, height); - } else { - // log.debug("Using GLGraphicsMapDisplay for '" + id + "'"); - PApplet.println("Using GLGraphicsMapDisplay."); - // TODO @chris: Why always use MaskedGLGraphicsMD? - // mapDisplay = new MaskedGLGraphicsMapDisplay(p, provider, x, y, width, height); - mapDisplay = new GLGraphicsMapDisplay(p, provider, x, y, width, height); - } - } - } catch (ClassNotFoundException e) { - // GLGraphics not found, go for Processing default + try { + Class openGLClass = Class.forName(OPEN_GL_CLASSNAME); + if (openGLClass.isInstance(p.g)) { + mapDisplay = new OpenGLMapDisplay(p, provider, renderer, x, y, width, height); + PApplet.println("Using OpenGLMapDisplay with " + ((OpenGLMapDisplay) mapDisplay).getRenderer()); + } else { + mapDisplay = new Java2DMapDisplay(p, provider, x, y, width, height); + PApplet.println("No OpenGL/P2D set. Using Java2DMapDisplay."); } - - if (mapDisplay == null) { - try { - Class openGLClass = Class.forName(OPEN_GL_CLASSNAME); - if (openGLClass.isInstance(p.g)) { - // log.warn("No OpenGL mapDisplay available. Use GLGraphics or P3D. '" + id + "'"); - PApplet.println("No OpenGL mapDisplay available. Use GLGraphics or P2D."); - } - } catch (ClassNotFoundException e) { - // OpenGL not found, was for informational purposes anyway. - } - - // log.debug("Using MaskedPGraphicsMapDisplay for '" + id + "'"); - // log.warn("no rotation possible (without OpenGL)"); - PApplet.println("Using MaskedPGraphicsMapDisplay. No rotation possible (w/o GLGraphics)"); - mapDisplay = new MaskedPGraphicsMapDisplay(p, provider, x, y, width, height); - } - - } else { - PApplet.println("Using ProcessingMapDisplay"); - mapDisplay = new ProcessingMapDisplay(p, provider, x, y, width, height); + } catch (ClassNotFoundException e) { + mapDisplay = new Java2DMapDisplay(p, provider, x, y, width, height); } mapDisplay.createDefaultMarkerManager(map); diff --git a/src/de/fhpotsdam/unfolding/mapdisplay/MaskedGLGraphicsMapDisplay.java b/src/de/fhpotsdam/unfolding/mapdisplay/MaskedGLGraphicsMapDisplay.java deleted file mode 100644 index 6bc13ea8..00000000 --- a/src/de/fhpotsdam/unfolding/mapdisplay/MaskedGLGraphicsMapDisplay.java +++ /dev/null @@ -1,59 +0,0 @@ -package de.fhpotsdam.unfolding.mapdisplay; - -import processing.core.PApplet; -import processing.core.PConstants; -import processing.core.PGraphics; -import codeanticode.glgraphics.GLGraphicsOffScreen; -import codeanticode.glgraphics.GLTexture; -import codeanticode.glgraphics.GLTextureFilter; -import de.fhpotsdam.unfolding.marker.Marker; -import de.fhpotsdam.unfolding.marker.MarkerManager; -import de.fhpotsdam.unfolding.providers.AbstractMapProvider; - -// TODO: Unify with GLGRaphics and create as flag/property -public class MaskedGLGraphicsMapDisplay extends GLGraphicsMapDisplay implements PConstants { - - public GLGraphicsOffScreen mask; - private GLTextureFilter maskFilter; - private GLTexture maskedTex; - - public MaskedGLGraphicsMapDisplay(PApplet papplet, AbstractMapProvider provider, float offsetX, float offsetY, - float width, float height) { - super(papplet, provider, offsetX, offsetY, width, height); - - mask = new GLGraphicsOffScreen(papplet, (int) width, (int) height, true); - mask.smooth(); - maskedTex = new GLTexture(papplet, (int) width, (int) height); - maskFilter = new GLTextureFilter(papplet, "test/Mask.xml"); - } - - @Override - public void resize(float width, float height) { - super.resize(width, height); - mask = new GLGraphicsOffScreen(papplet, (int) width, (int) height); - } - - public GLGraphicsOffScreen getMask() { - return mask; - } - - protected void postDraw() { - PGraphics outerPG = getOuterPG(); - - outerPG.pushMatrix(); - outerPG.translate(offsetX, offsetY); - outerPG.applyMatrix(matrix); - - // maskFilter.setParameterValue("mask_factor", 0.0f); - maskFilter.apply(new GLTexture[] { offscreenPG.getTexture(), mask.getTexture() }, maskedTex); - - outerPG.image(maskedTex, 0, 0); - - for (MarkerManager mm : markerManagerList) { - mm.draw(); - } - - outerPG.popMatrix(); - } - -} diff --git a/src/de/fhpotsdam/unfolding/mapdisplay/MaskedPGraphicsMapDisplay.java b/src/de/fhpotsdam/unfolding/mapdisplay/MaskedPGraphicsMapDisplay.java deleted file mode 100644 index 6543a613..00000000 --- a/src/de/fhpotsdam/unfolding/mapdisplay/MaskedPGraphicsMapDisplay.java +++ /dev/null @@ -1,40 +0,0 @@ -package de.fhpotsdam.unfolding.mapdisplay; - -import processing.core.PApplet; -import processing.core.PConstants; -import processing.core.PGraphics; -import de.fhpotsdam.unfolding.marker.Marker; -import de.fhpotsdam.unfolding.marker.MarkerManager; -import de.fhpotsdam.unfolding.providers.AbstractMapProvider; - - -public class MaskedPGraphicsMapDisplay extends ProcessingMapDisplay implements PConstants { - - protected PGraphics pg; - - public MaskedPGraphicsMapDisplay(PApplet papplet, AbstractMapProvider provider, - float offsetX, float offsetY, float width, float height) { - super(papplet, provider, offsetX, offsetY, width, height); - - pg = papplet.createGraphics((int) width, (int) height, P3D); - } - - public PGraphics getInnerPG() { - return pg; - } - - protected void postDraw() { - papplet.pushMatrix(); - //applyMatrix is not available with this renderer. - //papplet.applyMatrix(matrix); - papplet.translate(offsetX, offsetY); - papplet.image(pg, 0, 0); - - for (MarkerManager mm : markerManagerList){ - mm.draw(); - } - - papplet.popMatrix(); - } - -} diff --git a/src/de/fhpotsdam/unfolding/mapdisplay/OpenGLMapDisplay.java b/src/de/fhpotsdam/unfolding/mapdisplay/OpenGLMapDisplay.java new file mode 100644 index 00000000..84ca3d28 --- /dev/null +++ b/src/de/fhpotsdam/unfolding/mapdisplay/OpenGLMapDisplay.java @@ -0,0 +1,132 @@ +package de.fhpotsdam.unfolding.mapdisplay; + +import processing.core.PApplet; +import processing.core.PConstants; +import processing.core.PGraphics; +import de.fhpotsdam.unfolding.mapdisplay.shaders.MapDisplayShader; +import de.fhpotsdam.unfolding.marker.Marker; +import de.fhpotsdam.unfolding.marker.MarkerManager; +import de.fhpotsdam.unfolding.providers.AbstractMapProvider; + +@SuppressWarnings("rawtypes") +public class OpenGLMapDisplay extends Java2DMapDisplay implements PConstants { + + protected String renderer; + // Inner map (and inner marker) will be drawn on this. + protected PGraphics offscreenPG; + // Outer marker will be drawn on this + protected PGraphics offscreenCutoffPG; + + protected float opacity = 255; + + protected MapDisplayShader mapDisplayShader = null; + + public OpenGLMapDisplay(PApplet papplet, AbstractMapProvider provider, String renderer, float offsetX, + float offsetY, float width, float height) { + super(papplet, provider, offsetX, offsetY, width, height); + + if (renderer == null || renderer.equals("")) { + try { + Class P2DClass = Class.forName(P2D); + Class P3DClass = Class.forName(P3D); + if (P2DClass.isInstance(papplet.g)) { + this.renderer = P2D; + } else if (P3DClass.isInstance(papplet.g)) { + this.renderer = P3D; + } else { + // REVISIT: Never reached as P3D and OPENGL are both PGraphics3D + this.renderer = OPENGL; + } + } catch (ClassNotFoundException e) { + this.renderer = OPENGL; + } + } else { + this.renderer = renderer; + } + + offscreenPG = papplet.createGraphics((int) width, (int) height, this.renderer); + offscreenPG.smooth(papplet.g.quality); + offscreenCutoffPG = papplet.createGraphics((int) width, (int) height, this.renderer); + offscreenCutoffPG.smooth(papplet.g.quality); + } + + public void setMapDisplayShader(MapDisplayShader shader) { + this.mapDisplayShader = shader; + } + + public MapDisplayShader getMapDisplayShader() { + return mapDisplayShader; + } + + public String getRenderer() { + return renderer; + } + + @Override + public void resize(float width, float height) { + super.resize(width, height); + + if (offscreenPG != null) { + offscreenPG.dispose(); + } + if (offscreenCutoffPG != null) { + offscreenCutoffPG.dispose(); + } + + offscreenPG = papplet.createGraphics((int) width, (int) height, renderer); + offscreenPG.smooth(papplet.g.quality); + offscreenCutoffPG = papplet.createGraphics((int) width, (int) height, renderer); + offscreenCutoffPG.smooth(papplet.g.quality); + + if (mapDisplayShader != null) { + mapDisplayShader.resize(width, height); + } + } + + @Override + public PGraphics getInnerPG() { + return offscreenPG; + } + + @Override + public PGraphics getOuterPG() { + return offscreenCutoffPG; + } + + @Override + protected void postDraw() { + // Draws inner map (with inner marker) and outer marker + offscreenCutoffPG.beginDraw(); + offscreenCutoffPG.clear(); + if (mapDisplayShader != null) { + // NB: Uses offscreenPG (and not offscreenCutofPG) to not get 'Shader must be COLOR type' error + mapDisplayShader.shadeWithoutMarkers(offscreenPG); + } + offscreenCutoffPG.image(offscreenPG, 0, 0); + for (MarkerManager mm : markerManagerList) { + mm.draw(); + } + offscreenCutoffPG.endDraw(); + + // Transforms (outer) map pane, and draws inner map + marker onto canvas + // This cuts off marker at the border. + PGraphics canvasPG = papplet.g; + canvasPG.pushMatrix(); + canvasPG.translate(offsetX, offsetY); + if (canvasPG.is3D()) { + canvasPG.applyMatrix(matrix); + } else { + canvasPG.applyMatrix(matrix.m00, matrix.m01, matrix.m03, matrix.m10, matrix.m11, matrix.m13); + } + if (mapDisplayShader != null) { + mapDisplayShader.shadeWithMarkers(canvasPG); + } + canvasPG.pushStyle(); + //canvasPG.blendMode(REPLACE); + canvasPG.image(offscreenCutoffPG, 0, 0); + //canvasPG.blendMode(BLEND); + canvasPG.popStyle(); + canvasPG.popMatrix(); + // canvasPG.resetShader(); + } +} diff --git a/src/de/fhpotsdam/unfolding/mapdisplay/shaders/BlurredMapDisplayShader.java b/src/de/fhpotsdam/unfolding/mapdisplay/shaders/BlurredMapDisplayShader.java new file mode 100644 index 00000000..c38cefb1 --- /dev/null +++ b/src/de/fhpotsdam/unfolding/mapdisplay/shaders/BlurredMapDisplayShader.java @@ -0,0 +1,39 @@ +package de.fhpotsdam.unfolding.mapdisplay.shaders; + +import processing.core.PApplet; +import processing.core.PGraphics; + +/** + * This shader blurs a map. + * + * Implements shade without markers, i.e. blurs only the map but not the markers. + * Uses two-pass, i.e. calls PGraphics.shader(blurShader) twice. + * + */ +public class BlurredMapDisplayShader extends MapDisplayShader { + + private static final int DEFAULT_BLUR_SIZE = 9; + private static final float DEFAULT_SIGMA = 5.0f; + + public BlurredMapDisplayShader(PApplet p, int blurSize, float sigma) { + super(p); + shader = p.loadShader("test/blur.glsl"); + shader.set("blurSize", blurSize); + shader.set("sigma", sigma); + } + + public BlurredMapDisplayShader(PApplet p) { + this(p, DEFAULT_BLUR_SIZE, DEFAULT_SIGMA); + } + + @Override + public void shadeWithoutMarkers(PGraphics mapDisplayCanvas) { + // Two-pass Gaussian blur, first vertical, then horizontal + + shader.set("horizontalPass", 0); + mapDisplayCanvas.shader(shader); + shader.set("horizontalPass", 1); + mapDisplayCanvas.shader(shader); + } + +} diff --git a/src/de/fhpotsdam/unfolding/mapdisplay/shaders/MapDisplayShader.java b/src/de/fhpotsdam/unfolding/mapdisplay/shaders/MapDisplayShader.java new file mode 100644 index 00000000..275bc65e --- /dev/null +++ b/src/de/fhpotsdam/unfolding/mapdisplay/shaders/MapDisplayShader.java @@ -0,0 +1,47 @@ +package de.fhpotsdam.unfolding.mapdisplay.shaders; + +import processing.core.PApplet; +import processing.core.PGraphics; +import processing.opengl.PShader; + +public class MapDisplayShader { + + protected PApplet p; + + protected PShader shader; + + public MapDisplayShader(PApplet p) { + this.p = p; + } + + public PShader getShader() { + return shader; + } + + /** + * Resizes the shader. Optional, only implement if needed. + * + * @param width + * The new width of the canvas. + * @param height + * The new height of the canvas. + */ + public void resize(float width, float height) { + + } + + /** + * Applies the shader to the map display canvas. + * + * @param innerCanvas + * The inner canvas. + */ + public void shadeWithoutMarkers(PGraphics innerCanvas) { + + } + + public void shadeWithMarkers(PGraphics innerCanvas) { + + } + +} diff --git a/src/de/fhpotsdam/unfolding/mapdisplay/shaders/MaskedMapDisplayShader.java b/src/de/fhpotsdam/unfolding/mapdisplay/shaders/MaskedMapDisplayShader.java new file mode 100644 index 00000000..721cc375 --- /dev/null +++ b/src/de/fhpotsdam/unfolding/mapdisplay/shaders/MaskedMapDisplayShader.java @@ -0,0 +1,74 @@ +package de.fhpotsdam.unfolding.mapdisplay.shaders; + +import processing.core.PApplet; +import processing.core.PGraphics; +import processing.core.PImage; + +/** + * This shader masks a map. The offscreen graphic canvas as mask + * + * + */ +public class MaskedMapDisplayShader extends MapDisplayShader { + + /** The mask canvas. */ + protected PGraphics mask; + + /** + * Creates a MaskedMapDisplayShader to draw the mask dynamically. Call {@link #getMask()} to get the mask canvas to + * draw on. + * + * @param p + * The PApplet. + * @param width + * The width of the mask. + * @param height + * The height of the mask. + */ + public MaskedMapDisplayShader(PApplet p, float width, float height) { + super(p); + mask = p.createGraphics((int) width, (int) height, PApplet.OPENGL); + mask.noSmooth(); + + shader = p.loadShader("test/mask.glsl"); + shader.set("mask", mask); + } + + /** + * Creates a MaskedMapDisplayShader with the given mask image. + * + * @param p + * The PApplet. + * @param width + * The width of the mask. + * @param height + * The height of the mask. + * @param maskImage + * An image to be used as mask. + */ + public MaskedMapDisplayShader(PApplet p, float width, float height, PImage maskImage) { + this(p, width, height); + mask.beginDraw(); + mask.image(maskImage, 0, 0); + mask.endDraw(); + } + + public void resize(float width, float height) { + mask.resize((int) width, (int) height); + } + + /** + * Returns the mask canvas to dynamically create or update the mask. + * + * @return The mask. + */ + public PGraphics getMask() { + return mask; + } + + @Override + public void shadeWithMarkers(PGraphics mapDisplayCanvas) { + mapDisplayCanvas.shader(getShader()); + } + +} diff --git a/src/de/fhpotsdam/unfolding/providers/MBTilesMapProvider.java b/src/de/fhpotsdam/unfolding/providers/MBTilesMapProvider.java index 3b7287d4..8bbe7b04 100644 --- a/src/de/fhpotsdam/unfolding/providers/MBTilesMapProvider.java +++ b/src/de/fhpotsdam/unfolding/providers/MBTilesMapProvider.java @@ -12,6 +12,7 @@ */ public class MBTilesMapProvider extends AbstractMapTileProvider { + private static final String JDBC_PREFIX = "jdbc:sqlite:"; protected String jdbcConnectionString; public MBTilesMapProvider() { @@ -21,6 +22,9 @@ public MBTilesMapProvider() { public MBTilesMapProvider(String jdbcConnectionString) { this(); + if (jdbcConnectionString != null && !jdbcConnectionString.startsWith(JDBC_PREFIX)) { + jdbcConnectionString = JDBC_PREFIX + jdbcConnectionString; + } this.jdbcConnectionString = jdbcConnectionString; } diff --git a/src/de/fhpotsdam/unfolding/texture/TextureDistorter.java b/src/de/fhpotsdam/unfolding/texture/TextureDistorter.java index 886165de..02707aac 100644 --- a/src/de/fhpotsdam/unfolding/texture/TextureDistorter.java +++ b/src/de/fhpotsdam/unfolding/texture/TextureDistorter.java @@ -5,10 +5,9 @@ import processing.core.PApplet; import processing.core.PConstants; import processing.core.PGraphics; +import processing.core.PImage; +import processing.core.PShape; import processing.core.PVector; -import codeanticode.glgraphics.GLGraphics; -import codeanticode.glgraphics.GLModel; -import codeanticode.glgraphics.GLTexture; public class TextureDistorter { @@ -17,7 +16,7 @@ public class TextureDistorter { public float lightX; public float lightY; - GLModel meshModel; + PShape meshModel; // Mesh parameters protected int meshWidth; @@ -47,7 +46,7 @@ public TextureDistorter(PApplet p, int meshWidth, int meshHeight, int meshStep) initGrids(); createMesh(distortedGrid); - meshModel = new GLModel(p, vertices.size(), PConstants.TRIANGLE_STRIP, GLModel.DYNAMIC); + meshModel = null; } public TextureDistorter(PApplet papplet, float width, float height, int meshStep) { @@ -60,9 +59,9 @@ public void setDistorter(Distorter distorter) { int frameCount = 0; - public void draw(PGraphics g, GLTexture texture) { + public void draw(PGraphics g, PImage texture) { frameCount++; - + // REVISIT // Distort by texture to extrude by pixel brightness distortGridByTexture(texture); @@ -72,45 +71,68 @@ public void draw(PGraphics g, GLTexture texture) { distortMesh(); // createMesh(distortedGrid); - - GLGraphics renderer = (GLGraphics) g; - // GLGraphicsOffScreen renderer = (GLGraphicsOffScreen) g; - renderer.beginGL(); - renderer.background(0); - meshModel.updateVertices(vertices); - meshModel.initTextures(1); - meshModel.setTexture(0, texture); - meshModel.updateTexCoords(0, texCoords); - meshModel.initNormals(); - meshModel.updateNormals(normals); + + if (meshModel == null) { + // create + meshModel = g.createShape(); + meshModel.beginShape(PConstants.TRIANGLE_STRIP); + meshModel.texture(texture); + for (int i = 0; i < vertices.size(); i++) { + PVector vert = vertices.get(i); + PVector tcoord = texCoords.get(i); + if (g.is3D()) { + PVector norm = normals.get(i); + meshModel.normal(norm.x, norm.y, norm.z); + meshModel.vertex(vert.x, vert.y, vert.z, tcoord.x, tcoord.y); + } else { + meshModel.vertex(vert.x, vert.y, tcoord.x, tcoord.y); + } + } + meshModel.endShape(); + } else { + // update using setter methods + meshModel.setTexture(texture); + for (int i = 0; i < vertices.size(); i++) { + PVector vert = vertices.get(i); + PVector tcoord = texCoords.get(i); + if (g.is3D()) { + PVector norm = normals.get(i); + meshModel.setNormal(i, norm.x, norm.y, norm.z); + meshModel.setVertex(i, vert.x, vert.y, vert.z); + } else { + meshModel.setVertex(i, vert.x, vert.y); + } + meshModel.setTextureUV(i, tcoord.x, tcoord.y); + } + } + + g.background(0); if (mouse3DRotate || osc3DRotate) { PApplet p = PAppletFactory.getInstance(); if (showLight) { // Simple 3D lighting - renderer.directionalLight(204, 204, 204, lightX, lightY, -1); + g.directionalLight(204, 204, 204, lightX, lightY, -1); } - renderer.translate(400, 300, 0); + g.translate(400, 300); if (mouse3DRotate) { float rotX = (p.mouseX / (float) p.width - 0.5f) * 2f * PApplet.PI; float rotZ = (p.mouseY / (float) p.height - 0.5f) * 2f * PApplet.PI; - renderer.rotateX(rotX); - renderer.rotateZ(rotZ); + g.rotateX(rotX); + g.rotateZ(rotZ); } else if (osc3DRotate) { - renderer.rotateX(rotX); - renderer.rotateY(rotY); - renderer.rotateZ(rotZ); + g.rotateX(rotX); + g.rotateY(rotY); + g.rotateZ(rotZ); } - renderer.translate(-400, -300, 0); + g.translate(-400, -300); } - renderer.model(meshModel); - - renderer.endGL(); + g.shape(meshModel); } public float rotX, rotY, rotZ; @@ -128,8 +150,8 @@ protected void initGrids() { } } - protected void distortGridByTexture(GLTexture texture) { - texture.updateTexture(); + protected void distortGridByTexture(PImage texture) { + texture.loadPixels(); for (int u = 0; u < uSteps; u++) { for (int v = 0; v < vSteps; v++) { int x = u * meshStep; diff --git a/src/de/fhpotsdam/unfolding/tiles/TileLoader.java b/src/de/fhpotsdam/unfolding/tiles/TileLoader.java index 00ba1160..9c473561 100644 --- a/src/de/fhpotsdam/unfolding/tiles/TileLoader.java +++ b/src/de/fhpotsdam/unfolding/tiles/TileLoader.java @@ -5,7 +5,7 @@ import processing.core.PImage; import de.fhpotsdam.unfolding.core.Coordinate; import de.fhpotsdam.unfolding.mapdisplay.AbstractMapDisplay; -import de.fhpotsdam.unfolding.mapdisplay.ProcessingMapDisplay; +import de.fhpotsdam.unfolding.mapdisplay.Java2DMapDisplay; import de.fhpotsdam.unfolding.providers.AbstractMapProvider; /** @@ -18,7 +18,7 @@ * * * Tile organization is handled in {@link AbstractMapDisplay} (caching) and - * {@link ProcessingMapDisplay} (rendering). + * {@link Java2DMapDisplay} (rendering). */ public class TileLoader implements Runnable { @@ -93,12 +93,13 @@ public void run() { protected PImage getTileFromUrl(String[] urls) { // Load image from URL (local file included) // NB: Use 'unknown' as content-type to let loadImage decide - PImage img = p.loadImage(urls[0], "unknown"); + //PImage img = p.loadImage(urls[0], "unknown"); + PImage img = p.loadImage(urls[0]); if (img != null) { // If array contains multiple URLs, load all images and blend them together for (int i = 1; i < urls.length; i++) { - PImage img2 = p.loadImage(urls[i], "unknown"); + PImage img2 = p.loadImage(urls[i]); if (img2 != null) { img.blend(img2, 0, 0, img.width, img.height, 0, 0, img.width, img.height, PApplet.BLEND); } diff --git a/src/de/fhpotsdam/unfolding/ui/MaskUI.java b/src/de/fhpotsdam/unfolding/ui/MaskUI.java deleted file mode 100644 index 1f169c6a..00000000 --- a/src/de/fhpotsdam/unfolding/ui/MaskUI.java +++ /dev/null @@ -1,43 +0,0 @@ -package de.fhpotsdam.unfolding.ui; - -import javax.media.opengl.GL; - -import processing.core.PApplet; -import processing.opengl.PGraphicsOpenGL; -import codeanticode.glgraphics.GLGraphicsOffScreen; -import codeanticode.glgraphics.GLTexture; -import de.fhpotsdam.unfolding.mapdisplay.AbstractMapDisplay; - -public class MaskUI { - - private PApplet p; - private AbstractMapDisplay mapDisplay; - private GL gl; - private PGraphicsOpenGL pgl; - - public GLGraphicsOffScreen c; - public GLTexture maskTex; - - public MaskUI(PApplet p) { - this.p = p; - this.mapDisplay = mapDisplay; - this.c = new GLGraphicsOffScreen(p, p.width, p.height); - this.maskTex = new GLTexture(p, p.width, p.height); - - this.pgl = (PGraphicsOpenGL) p.g; - this.gl = pgl.gl; - } - - - public void draw() { - maskTex = c.getTexture(); - gl.glBlendFunc(gl.GL_DST_COLOR, gl.GL_ZERO); - p.image(maskTex, 0, 0, p.width, p.height); - gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA); - } - - public void setTexture(GLTexture tex){ - maskTex=tex; - } - -} diff --git a/src/de/fhpotsdam/unfolding/utils/GeoUtils.java b/src/de/fhpotsdam/unfolding/utils/GeoUtils.java index 9e575614..93003eb1 100644 --- a/src/de/fhpotsdam/unfolding/utils/GeoUtils.java +++ b/src/de/fhpotsdam/unfolding/utils/GeoUtils.java @@ -5,6 +5,7 @@ import java.util.List; import processing.core.PVector; +import de.fhpotsdam.unfolding.core.Coordinate; import de.fhpotsdam.unfolding.data.Feature; import de.fhpotsdam.unfolding.data.MultiFeature; import de.fhpotsdam.unfolding.data.PointFeature; @@ -223,9 +224,10 @@ protected static float getArea(List vertices) { protected static float getArea(Feature feature) { return getArea(GeoUtils.getLocations(feature)); } - + /** * Calculates the area of a shape marker. + * * @param marker * The marker containing location vertices. * @return The area. @@ -233,7 +235,7 @@ protected static float getArea(Feature feature) { protected static float getArea(Marker marker) { return getArea(GeoUtils.getLocations(marker)); } - + /** * Gets the overall geometric center of all features. * @@ -308,7 +310,7 @@ public static Feature getLargestFeature(MultiFeature multiFeature) { } return largestFeature; } - + public static Marker getLargestMarker(MultiMarker multiMarker) { float largestArea = 0; Marker largestMarker = null; @@ -412,4 +414,25 @@ public static List getLocations(Marker marker) { return locations; } + public static String getQuadKey(Coordinate coord) { + return getQuadKey((int) coord.column, (int) coord.row, (int) coord.zoom); + } + + public static String getQuadKey(int x, int y, int z) { + String quadKey = ""; + for (int i = z; i > 0; i--) { + int digit = 0; + int mask = 1 << (i - 1); + if ((x & mask) != 0) { + digit++; + } + if ((y & mask) != 0) { + digit++; + digit++; + } + quadKey += Integer.toString(digit); + } + return quadKey; + } + } diff --git a/src/de/fhpotsdam/unfolding/utils/LargeMapImageUtils.java b/src/de/fhpotsdam/unfolding/utils/LargeMapImageUtils.java new file mode 100644 index 00000000..dddfebb8 --- /dev/null +++ b/src/de/fhpotsdam/unfolding/utils/LargeMapImageUtils.java @@ -0,0 +1,204 @@ +package de.fhpotsdam.unfolding.utils; + +import processing.core.PApplet; +import processing.core.PGraphics; +import processing.core.PImage; +import de.fhpotsdam.unfolding.UnfoldingMap; +import de.fhpotsdam.unfolding.geo.Location; + +/** + * Utility class to save large map images. Can be used to create high resolution screenshots for print. Everything + * currently visible on the map (tiles and markers) will be in the image. + * + * This process happens on-screen, thus the map can not be used while this tool is running. It will automatically pan to + * different areas of the map, stitch them together, and save them in one single image. + * + * To customize, set location, zoomLevel, and totalWidth and totalHeight. The latter two should be multiples of xStep + * and yStep. You can also set file name, or file prefix and file suffix of the large image to be saved. + * + * Please note the respective terms of service of the map provider! + * + */ +public class LargeMapImageUtils { + + protected PApplet p; + + protected int xStep = 500; + protected int yStep = 500; + protected int totalWidth = xStep * 2; + protected int totalHeight = yStep * 2; + + int shotX = 0; + int shotY = 0; + + UnfoldingMap map; + PGraphics largeImage; + boolean running = false; + + String imageFilePrefix = "largeMap-"; + String imageFileSuffix = ".png"; + int imageFileNumber = 0; + String imageFileName = null; + + /** + * Creates a new LargeMapImageUtils which stores a large image double the size of the canvas. + * + * @param p + * The PApplet + * @param map + * The map to take screenshots from. + */ + public LargeMapImageUtils(PApplet p, UnfoldingMap map) { + this(p, map, 2); + } + + public LargeMapImageUtils(PApplet p, UnfoldingMap map, int stitchNumber) { + this(p, map, p.width, p.height, p.width * stitchNumber, p.height * stitchNumber); + } + + public LargeMapImageUtils(PApplet p, UnfoldingMap map, Location location, int zoomLevel) { + this(p, map, location, zoomLevel, 2); + } + + public LargeMapImageUtils(PApplet p, UnfoldingMap map, Location location, int zoomLevel, int stitchNumber) { + this(p, map, location, zoomLevel, p.width, p.height, p.width * stitchNumber, p.height * stitchNumber); + } + + public LargeMapImageUtils(PApplet p, UnfoldingMap map, Location location, int zoomLevel, int xStep, int yStep, + int totalWidth, + int totalHeight) { + this(p, map, xStep, yStep, totalWidth, totalHeight); + init(location, zoomLevel); + } + + public LargeMapImageUtils(PApplet p, UnfoldingMap map, int xStep, int yStep, int totalWidth, int totalHeight) { + this.p = p; + this.map = map; + + this.xStep = xStep; + this.yStep = yStep; + this.totalWidth = totalWidth; + this.totalHeight = totalHeight; + + largeImage = p.createGraphics(totalWidth, totalHeight, PApplet.P2D); + } + + /** + * Initializes a new large map image around the current map center. Pans to the upper left corner, and start the + * recording process. + */ + public void init() { + running = true; + shotX = 0; + shotY = 0; + PApplet.println("Init. running=" + running); + + // Set map to start position + map.panBy(totalWidth / 2 - xStep / 2, totalHeight / 2 - yStep / 2); + } + + /** + * Initializes a new large map image around the location. Pans to the upper left corner, and start the recording + * process. + * + * @param location + * The location to center around. + * @param zoomLevel + * The zoom level to use. + */ + public void init(Location location, int zoomLevel) { + map.zoomAndPanTo(location, zoomLevel); + init(); + } + + /** + * Runs the recording process. It will automatically pan to different areas of the map, stitch them together, and + * save them in one single image, at the end. + */ + public void run() { + if (map.allTilesLoaded() && running) { + renderAndMakeSnapshot(shotX, shotY); + + shotX += xStep; + if (shotX >= totalWidth) { + shotX = 0; + shotY += yStep; + // Return back to the right, and go one down + map.panBy(totalWidth - xStep, -yStep); + } + else { + // Go left + map.panBy(-xStep, 0); + } + + if (shotY >= totalHeight) { + saveLargeImage(); + } + } + } + + /** + * Internal method to save the actual large stitched-together image in one file. + */ + protected void saveLargeImage() { + String fn = imageFileName; + if (imageFileName == null) { + fn = imageFilePrefix + imageFileNumber++ + imageFileSuffix; + } + PApplet.println("Saving large map image: " + fn); + largeImage.save(fn); + + running = false; + } + + /** + * Internal method to get the current map canvas (incl markers) and stores it in an buffer image. + * + * @param shotX + * Current x position of the large image to store the current screenshot to. + * @param shotY + * Current y position of the large image to store the current screenshot to. + */ + protected void renderAndMakeSnapshot(int shotX, int shotY) { + PApplet.println("Making snapshot for " + shotX + ", " + shotY); + PImage currentImage = makeSnapshot(); + largeImage.beginDraw(); + largeImage.image(currentImage, shotX, shotY); + largeImage.endDraw(); + } + + public PImage makeSnapshot() { + return map.mapDisplay.getOuterPG(); + } + + /** + * Sets the prefix of the final large image file. Actual file name will be prefix + number + suffix. + * + * @param imageFilePrefix + * A image file prefix (supported by Processing, i.e. '.tif', '.png', '.jpg'). + */ + public void setImageFilePrefix(String imageFilePrefix) { + this.imageFilePrefix = imageFilePrefix; + } + + /** + * Sets the suffix of the final large image file. Actual file name will be prefix + number + suffix. + * + * @param imageFileSuffix + * A image file suffix, e.g. 'largeImage-'. + */ + public void setImageFileSuffix(String imageFileSuffix) { + this.imageFileSuffix = imageFileSuffix; + } + + /** + * The full name of the final large image. If set, the LargeMapImageUtils won't automatically include a number. + * + * @param imageFileName + * A file name. + */ + public void setImageFileName(String imageFileName) { + this.imageFileName = imageFileName; + } + +} diff --git a/test/de/fhpotsdam/RetinaTestApp.java b/test/de/fhpotsdam/RetinaTestApp.java new file mode 100644 index 00000000..b1074e00 --- /dev/null +++ b/test/de/fhpotsdam/RetinaTestApp.java @@ -0,0 +1,37 @@ +package de.fhpotsdam; + +import processing.core.PApplet; + +public class RetinaTestApp extends PApplet { + + public void setup() { + // default: Java2D, low fps, low quality + //size(1920, 1080); + //size(1440, 900); + + // Retina2D, high fps, high quality + size(1920, 1080, "processing.core.PGraphicsRetina2D"); + + // P2D (OpenGL), high fps, lowest quality + //size(1920, 1080, P2D); + + // OpenGL, same as P2D + //size(1920, 1080, OPENGL); + + smooth(); + frameRate(60); + } + + public void draw() { + background(40); + noStroke(); + ellipse(random(width), random(height), 30, 30); + ellipse(mouseX, mouseY, 30, 30); + + fill(255); + text("fps: " + frameRate, 10, 10); + + println(width + ", "+ height); + } + +} diff --git a/test/de/fhpotsdam/matrix/GridFingerTest.java b/test/de/fhpotsdam/matrix/GridFingerTest.java index 4d7713ff..1728de43 100644 --- a/test/de/fhpotsdam/matrix/GridFingerTest.java +++ b/test/de/fhpotsdam/matrix/GridFingerTest.java @@ -8,7 +8,7 @@ import TUIO.TuioListener; import TUIO.TuioObject; import TUIO.TuioTime; -import codeanticode.glgraphics.GLConstants; + /** * Fully working test app to freely transform an object (Grid). Rotate, Scale (and implicit @@ -34,7 +34,7 @@ public class GridFingerTest extends PApplet implements TuioListener { // } public void setup() { - size(1024, 768, GLConstants.GLGRAPHICS); + size(1024, 768, OPENGL); smooth(); grid = new Grid(this, 100, 100, 300, 300); diff --git a/test/de/fhpotsdam/matrix/GridTest.java b/test/de/fhpotsdam/matrix/GridTest.java index 4086aee6..bd58c250 100644 --- a/test/de/fhpotsdam/matrix/GridTest.java +++ b/test/de/fhpotsdam/matrix/GridTest.java @@ -1,14 +1,14 @@ package de.fhpotsdam.matrix; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + public class GridTest extends PApplet { Grid grid; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); smooth(); grid = new Grid(this, 50, 50, 300, 200); diff --git a/test/de/fhpotsdam/matrix/RotationTest.java b/test/de/fhpotsdam/matrix/RotationTest.java index 6ebd6d5f..7e856410 100644 --- a/test/de/fhpotsdam/matrix/RotationTest.java +++ b/test/de/fhpotsdam/matrix/RotationTest.java @@ -2,7 +2,7 @@ import processing.core.PApplet; import processing.core.PMatrix3D; -import codeanticode.glgraphics.GLConstants; + public class RotationTest extends PApplet { @@ -16,7 +16,7 @@ public class RotationTest extends PApplet { float zoom; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); smooth(); offsetX = 50; diff --git a/test/de/fhpotsdam/unfolding/PrecisePositionsApp.java b/test/de/fhpotsdam/unfolding/PrecisePositionsApp.java index c9f420bf..423403fd 100644 --- a/test/de/fhpotsdam/unfolding/PrecisePositionsApp.java +++ b/test/de/fhpotsdam/unfolding/PrecisePositionsApp.java @@ -2,7 +2,7 @@ import processing.core.PApplet; import processing.core.PVector; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.core.Coordinate; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.geo.Transformation; @@ -28,7 +28,7 @@ public class PrecisePositionsApp extends PApplet { @Override public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this, new Microsoft.AerialProvider()); map.zoomAndPanTo(SINGAPORE_LOCATION, 14); diff --git a/test/de/fhpotsdam/unfolding/SimpleMapP2DApp.java b/test/de/fhpotsdam/unfolding/SimpleMapP2DApp.java new file mode 100644 index 00000000..07fef5e7 --- /dev/null +++ b/test/de/fhpotsdam/unfolding/SimpleMapP2DApp.java @@ -0,0 +1,29 @@ +package de.fhpotsdam.unfolding; + +import processing.core.PApplet; + +import de.fhpotsdam.unfolding.UnfoldingMap; +import de.fhpotsdam.unfolding.geo.Location; +import de.fhpotsdam.unfolding.utils.MapUtils; + +/** + * An application with a basic interactive map. You can zoom and pan the map. + */ +public class SimpleMapP2DApp extends PApplet { + + UnfoldingMap map; + + public void setup() { + size(1024, 768, P2D); + + println(g); + + map = new UnfoldingMap(this); + map.zoomAndPanTo(new Location(52.5f, 13.4f), 10); + MapUtils.createDefaultEventDispatcher(this, map); + } + + public void draw() { + map.draw(); + } +} diff --git a/test/de/fhpotsdam/unfolding/TransparentThingsOnOpenGLMapApp.java b/test/de/fhpotsdam/unfolding/TransparentThingsOnOpenGLMapApp.java new file mode 100644 index 00000000..f3dabb04 --- /dev/null +++ b/test/de/fhpotsdam/unfolding/TransparentThingsOnOpenGLMapApp.java @@ -0,0 +1,35 @@ +package de.fhpotsdam.unfolding; + +import processing.core.PApplet; + +public class TransparentThingsOnOpenGLMapApp extends PApplet { + + UnfoldingMap map; + + public void setup() { + size(600, 600, OPENGL); + map = new UnfoldingMap(this); + } + + public void draw() { + background(0); + map.draw(); + + fill(255, 0, 0, 50); + ellipse(width / 2, height / 2, 200, 200); + } + + public void test() { + // PGraphics pg = createGraphics((int) width, (int) height); + // pg.beginDraw(); + // pg.background(0); + // pg.endDraw(); + // + // pushStyle(); + // blendMode(REPLACE); + // image(pg, 0, 0); + // popStyle(); + // //blendMode(BLEND); + } + +} diff --git a/test/de/fhpotsdam/unfolding/ZoomRangeTweenMap.java b/test/de/fhpotsdam/unfolding/ZoomRangeTweenMap.java index 77e5cdec..55b51c8c 100644 --- a/test/de/fhpotsdam/unfolding/ZoomRangeTweenMap.java +++ b/test/de/fhpotsdam/unfolding/ZoomRangeTweenMap.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -22,7 +22,7 @@ public class ZoomRangeTweenMap extends PApplet { int maxZoomLevel = 11; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); map.zoomAndPanTo(new Location(52.5f, 13.4f), 10); diff --git a/test/de/fhpotsdam/unfolding/data/manual/CenteredTrackApp.java b/test/de/fhpotsdam/unfolding/data/manual/CenteredTrackApp.java index 1f96f78f..16706bbb 100644 --- a/test/de/fhpotsdam/unfolding/data/manual/CenteredTrackApp.java +++ b/test/de/fhpotsdam/unfolding/data/manual/CenteredTrackApp.java @@ -4,7 +4,7 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -32,7 +32,7 @@ public class CenteredTrackApp extends PApplet { int trailNumber = 10; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); MapUtils.createDefaultEventDispatcher(this, map); diff --git a/test/de/fhpotsdam/unfolding/data/manual/GPXUtils.java b/test/de/fhpotsdam/unfolding/data/manual/GPXUtils.java index 7d58afcb..087d2328 100644 --- a/test/de/fhpotsdam/unfolding/data/manual/GPXUtils.java +++ b/test/de/fhpotsdam/unfolding/data/manual/GPXUtils.java @@ -6,7 +6,7 @@ import java.util.List; import processing.core.PApplet; -import processing.xml.XMLElement; +import processing.data.XML; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.GeoUtils; import de.fhpotsdam.utils.StringUtils; @@ -22,20 +22,20 @@ public static List loadGPXTrack(PApplet p, String gpxFilename) { Location prevLocation = null; // Load GPX file - XMLElement gpx = new XMLElement(p, gpxFilename); + XML gpx = p.loadXML(gpxFilename); // Get all track points - XMLElement[] itemXMLElements = gpx.getChildren("trk/trkseg/trkpt"); - for (int i = 0; i < itemXMLElements.length; i++) { + XML[] itemXML = gpx.getChildren("trk/trkseg/trkpt"); + for (int i = 0; i < itemXML.length; i++) { // Creates location for track point - float lat = itemXMLElements[i].getFloat("lat"); - float lon = itemXMLElements[i].getFloat("lon"); + float lat = itemXML[i].getFloat("lat"); + float lon = itemXML[i].getFloat("lon"); Location location = new Location(lat, lon); // Calculates speed for track point // Uses time span (h) and distance (km) to previous point to get km/h double speed = 0; try { - String timeStr = itemXMLElements[i].getChild("time").getContent(); + String timeStr = itemXML[i].getChild("time").getContent(); // Replace "Z" for Zulu/GMT time with parseable hour offset timeStr = timeStr.replaceAll("Z", "+0000"); Calendar time = StringUtils.parseIsoDateTime(timeStr); diff --git a/test/de/fhpotsdam/unfolding/data/manual/ManualGPXTrackApp.java b/test/de/fhpotsdam/unfolding/data/manual/ManualGPXTrackApp.java index decafa41..6829c3f9 100644 --- a/test/de/fhpotsdam/unfolding/data/manual/ManualGPXTrackApp.java +++ b/test/de/fhpotsdam/unfolding/data/manual/ManualGPXTrackApp.java @@ -4,7 +4,7 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -24,7 +24,7 @@ public class ManualGPXTrackApp extends PApplet { List trackPoints = new ArrayList(); public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); MapUtils.createDefaultEventDispatcher(this, map); diff --git a/test/de/fhpotsdam/unfolding/data/manual/ManualGeoRSSApp.java b/test/de/fhpotsdam/unfolding/data/manual/ManualGeoRSSApp.java index 981cbd36..2835c6fc 100644 --- a/test/de/fhpotsdam/unfolding/data/manual/ManualGeoRSSApp.java +++ b/test/de/fhpotsdam/unfolding/data/manual/ManualGeoRSSApp.java @@ -4,8 +4,7 @@ import java.util.List; import processing.core.PApplet; -import processing.xml.XMLElement; -import codeanticode.glgraphics.GLConstants; +import processing.data.XML; import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -29,7 +28,7 @@ public class ManualGeoRSSApp extends PApplet { List rssGeoLocations = new ArrayList(); public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); smooth(); map = new UnfoldingMap(this, 50, 50, 700, 500); @@ -42,17 +41,19 @@ public void setup() { public void loadRSSGeoLocations() { // Load RSS feed String url = "http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-M5.xml"; - XMLElement rss = new XMLElement(this, url); + XML rss = loadXML(url); // Get all items - XMLElement[] itemXMLElements = rss.getChildren("channel/item"); - for (int i = 0; i < itemXMLElements.length; i++) { + XML[] itemXML = rss.getChildren("channel/item"); + for (int i = 0; i < itemXML.length; i++) { // Adds lat,lon as locations for each item - XMLElement latXML = itemXMLElements[i].getChild("geo:lat"); - XMLElement lonXML = itemXMLElements[i].getChild("geo:long"); - float lat = Float.valueOf(latXML.getContent()); - float lon = Float.valueOf(lonXML.getContent()); + XML latXML = itemXML[i].getChild("geo:lat"); + XML lonXML = itemXML[i].getChild("geo:long"); + if (latXML != null && latXML.getContent() != null) { + float lat = Float.valueOf(latXML.getContent()); + float lon = Float.valueOf(lonXML.getContent()); - rssGeoLocations.add(new Location(lat, lon)); + rssGeoLocations.add(new Location(lat, lon)); + } } } diff --git a/test/de/fhpotsdam/unfolding/examples/SimpleAnimatedMapApp.java b/test/de/fhpotsdam/unfolding/examples/SimpleAnimatedMapApp.java index b035d744..c6ee18e8 100644 --- a/test/de/fhpotsdam/unfolding/examples/SimpleAnimatedMapApp.java +++ b/test/de/fhpotsdam/unfolding/examples/SimpleAnimatedMapApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.examples; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.GeoUtils; @@ -36,7 +36,7 @@ public class SimpleAnimatedMapApp extends PApplet { float animationSpeed = 0.05f; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); MapUtils.createDefaultEventDispatcher(this, map); diff --git a/test/de/fhpotsdam/unfolding/examples/fun/FlippedMapDisplay.java b/test/de/fhpotsdam/unfolding/examples/fun/FlippedMapDisplay.java deleted file mode 100644 index 30a6655f..00000000 --- a/test/de/fhpotsdam/unfolding/examples/fun/FlippedMapDisplay.java +++ /dev/null @@ -1,39 +0,0 @@ -package de.fhpotsdam.unfolding.examples.fun; - -import processing.core.PApplet; -import processing.core.PGraphics; -import codeanticode.glgraphics.GLGraphicsOffScreen; -import codeanticode.glgraphics.GLTexture; -import de.fhpotsdam.unfolding.mapdisplay.GLGraphicsMapDisplay; -import de.fhpotsdam.unfolding.marker.Marker; -import de.fhpotsdam.unfolding.marker.MarkerManager; -import de.fhpotsdam.unfolding.providers.AbstractMapProvider; - -public class FlippedMapDisplay extends GLGraphicsMapDisplay { - - public FlippedMapDisplay(PApplet papplet, AbstractMapProvider provider, float offsetX, float offsetY, float width, - float height) { - super(papplet, provider, offsetX, offsetY, width, height); - } - - protected void postDraw() { - PGraphics outerPG = getOuterPG(); - - outerPG.pushMatrix(); - outerPG.translate(offsetX, offsetY); - outerPG.applyMatrix(matrix); - - // Flip test - GLTexture map = ((GLGraphicsOffScreen) getInnerPG()).getTexture(); - outerPG.scale(-1, 1); - outerPG.translate(-width, 0); - outerPG.image(map, 0, 0); - - for (MarkerManager mm : markerManagerList) { - mm.draw(); - } - - outerPG.popMatrix(); - } - -} diff --git a/test/de/fhpotsdam/unfolding/examples/fun/GenerativeGraphicMap.java b/test/de/fhpotsdam/unfolding/examples/fun/GenerativeGraphicMap.java index ffbce0c0..ffb50283 100644 --- a/test/de/fhpotsdam/unfolding/examples/fun/GenerativeGraphicMap.java +++ b/test/de/fhpotsdam/unfolding/examples/fun/GenerativeGraphicMap.java @@ -2,7 +2,7 @@ import processing.core.PApplet; import processing.core.PGraphics; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.providers.Microsoft; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -16,7 +16,7 @@ public class GenerativeGraphicMap extends PApplet { PGraphics pg; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this, new Microsoft.AerialProvider()); MapUtils.createDefaultEventDispatcher(this, map); diff --git a/test/de/fhpotsdam/unfolding/examples/fun/MovingCirclesMap.java b/test/de/fhpotsdam/unfolding/examples/fun/MovingCirclesMap.java index d0212a0b..f542d6e3 100644 --- a/test/de/fhpotsdam/unfolding/examples/fun/MovingCirclesMap.java +++ b/test/de/fhpotsdam/unfolding/examples/fun/MovingCirclesMap.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.events.MapEvent; import de.fhpotsdam.unfolding.providers.Microsoft; @@ -23,7 +23,7 @@ public class MovingCirclesMap extends PApplet { boolean reInit = false; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map1 = new UnfoldingMap(this, "map1", 0, 0, 800, 600, true, false, new Microsoft.AerialProvider()); MapUtils.createDefaultEventDispatcher(this, map1); diff --git a/test/de/fhpotsdam/unfolding/examples/fun/RorschachMap.java b/test/de/fhpotsdam/unfolding/examples/fun/RorschachMap.java deleted file mode 100644 index 2cc6b453..00000000 --- a/test/de/fhpotsdam/unfolding/examples/fun/RorschachMap.java +++ /dev/null @@ -1,46 +0,0 @@ -package de.fhpotsdam.unfolding.examples.fun; - -import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; -import de.fhpotsdam.unfolding.UnfoldingMap; -import de.fhpotsdam.unfolding.events.EventDispatcher; -import de.fhpotsdam.unfolding.providers.Microsoft; -import de.fhpotsdam.unfolding.utils.MapUtils; - -public class RorschachMap extends PApplet { - - UnfoldingMap map1; - UnfoldingMap map2; - UnfoldingMap map3; - UnfoldingMap map4; - - public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); - - map1 = new UnfoldingMap(this, "map1", 0, 0, 400, 300, true, false, new Microsoft.AerialProvider()); - map1.mapDisplay = new FlippedMapDisplay(this, new Microsoft.AerialProvider(), 0, 0, 400, 300); - map2 = new UnfoldingMap(this, "map2", 400, 0, 400, 300, true, false, new Microsoft.AerialProvider()); - map3 = new UnfoldingMap(this, "map3", 0, 300, 400, 300, true, false, new Microsoft.AerialProvider()); - map4 = new UnfoldingMap(this, "map4", 400, 300, 400, 300, true, false, new Microsoft.AerialProvider()); - EventDispatcher eventDispatcher = MapUtils.createDefaultEventDispatcher(this, map1, map2, map3, map4); - - //map1.rotate(PI); - - // All maps listen to all pan interactions. (Note: Maps do not register to themselves, - // again. This has been done in default EventDispatcher, above.) - eventDispatcher.register(map1, "pan", map2.getId(), map3.getId(), map4.getId()); - eventDispatcher.register(map2, "pan", map1.getId(), map3.getId(), map4.getId()); - eventDispatcher.register(map3, "pan", map1.getId(), map2.getId(), map4.getId()); - eventDispatcher.register(map4, "pan", map1.getId(), map2.getId(), map3.getId()); - } - - public void draw() { - background(0); - - map1.draw(); - map2.draw(); - map3.draw(); - map4.draw(); - } - -} diff --git a/test/de/fhpotsdam/unfolding/examples/image/MapImageOverlayApp.java b/test/de/fhpotsdam/unfolding/examples/image/MapImageOverlayApp.java new file mode 100644 index 00000000..b071d093 --- /dev/null +++ b/test/de/fhpotsdam/unfolding/examples/image/MapImageOverlayApp.java @@ -0,0 +1,48 @@ +package de.fhpotsdam.unfolding.examples.image; + +import processing.core.PApplet; +import processing.core.PImage; +import de.fhpotsdam.unfolding.UnfoldingMap; +import de.fhpotsdam.unfolding.geo.Location; +import de.fhpotsdam.unfolding.providers.Microsoft; +import de.fhpotsdam.unfolding.utils.MapUtils; +import de.fhpotsdam.unfolding.utils.ScreenPosition; + +/** + * Shows a static image laid over an interactive background map. + * + * See {@link ImageOverlayApp} for more information. + */ +public class MapImageOverlayApp extends PApplet { + + UnfoldingMap map; + Location center = new Location(52.396, 13.058); + + PImage visImg; + Location visNorthWest = new Location(52.687, 13.06); + Location visSouthEast = new Location(52.328, 13.78); + + public void setup() { + size(1400, 800, OPENGL); + + visImg = loadImage("http://upload.wikimedia.org/wikipedia/commons/thumb/5/56/Occupied_Berlin.svg/2000px-Occupied_Berlin.svg.png"); + + map = new UnfoldingMap(this, "Satellite Map", new Microsoft.AerialProvider()); + map.zoomAndPanTo(center, 14); + MapUtils.createDefaultEventDispatcher(this, map); + } + + public void draw() { + tint(255); + map.draw(); + + ScreenPosition topRight = map.getScreenPosition(visNorthWest); + ScreenPosition bottomLeft = map.getScreenPosition(visSouthEast); + + float width = bottomLeft.x - topRight.x; + float height = bottomLeft.y - topRight.y; + + tint(255, 110); + image(visImg, topRight.x, topRight.y, width, height); + } +} diff --git a/test/de/fhpotsdam/unfolding/examples/mask/DynamicMaskApp.java b/test/de/fhpotsdam/unfolding/examples/mask/DynamicMaskApp.java new file mode 100644 index 00000000..7bdcfab5 --- /dev/null +++ b/test/de/fhpotsdam/unfolding/examples/mask/DynamicMaskApp.java @@ -0,0 +1,67 @@ +package de.fhpotsdam.unfolding.examples.mask; + +import processing.core.PApplet; +import processing.core.PGraphics; +import de.fhpotsdam.unfolding.UnfoldingMap; +import de.fhpotsdam.unfolding.mapdisplay.OpenGLMapDisplay; +import de.fhpotsdam.unfolding.mapdisplay.shaders.MaskedMapDisplayShader; +import de.fhpotsdam.unfolding.utils.MapUtils; + +/** + * This example shows the use of an gray-scale mask applied to the map. + */ +public class DynamicMaskApp extends PApplet { + + UnfoldingMap map; + + PGraphics mask; + MaskedMapDisplayShader mapDisplayShader; + + public void setup() { + size(830, 420, OPENGL); + map = new UnfoldingMap(this, "map1", 10, 10, 400, 400, true, false, null); + MapUtils.createDefaultEventDispatcher(this, map); + + mapDisplayShader = new MaskedMapDisplayShader(this, 400, 400); + ((OpenGLMapDisplay) map.mapDisplay).setMapDisplayShader(mapDisplayShader); + + mask = mapDisplayShader.getMask(); + mask.beginDraw(); + mask.background(0); + mask.endDraw(); + } + + public void draw() { + background(0); + + updateMask(); + map.draw(); + + // shows the mask next to the map + image(mask, 420, 10); + } + + public void keyPressed() { + resetMask(); + } + + // draw the grayscale mask on an mask object + // 255 = invisible + // 0 = visible + public void updateMask() { + mask.beginDraw(); + if (mouseX != 0 && mouseY != 0) { + mask.noStroke(); + mask.fill(255, 127); + mask.ellipse(mouseX, mouseY, 50, 50); + } + mask.endDraw(); + } + + public void resetMask() { + mask.beginDraw(); + mask.clear(); + mask.endDraw(); + } + +} \ No newline at end of file diff --git a/test/de/fhpotsdam/unfolding/examples/mask/MaskedMarkerAndMapApp.java b/test/de/fhpotsdam/unfolding/examples/mask/MaskedMarkerAndMapApp.java new file mode 100644 index 00000000..998131f1 --- /dev/null +++ b/test/de/fhpotsdam/unfolding/examples/mask/MaskedMarkerAndMapApp.java @@ -0,0 +1,64 @@ +package de.fhpotsdam.unfolding.examples.mask; + +import java.util.List; + +import processing.core.PApplet; +import processing.core.PImage; +import de.fhpotsdam.unfolding.UnfoldingMap; +import de.fhpotsdam.unfolding.data.Feature; +import de.fhpotsdam.unfolding.data.GeoRSSReader; +import de.fhpotsdam.unfolding.mapdisplay.OpenGLMapDisplay; +import de.fhpotsdam.unfolding.mapdisplay.shaders.BlurredMapDisplayShader; +import de.fhpotsdam.unfolding.mapdisplay.shaders.MapDisplayShader; +import de.fhpotsdam.unfolding.mapdisplay.shaders.MaskedMapDisplayShader; +import de.fhpotsdam.unfolding.marker.Marker; +import de.fhpotsdam.unfolding.utils.MapUtils; + +/** + * Shows two different MapDisplayShader, one shading map and marker (mask), one only map (blur). + * + * Whether the shader also affects marker depends on the implementation in the Shader class. + * + * Switch shader by setting the useShaderWithMarker. + * + */ +public class MaskedMarkerAndMapApp extends PApplet { + + boolean useShaderWithMarker = true; + + String earthquakesURL = "http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_week.atom"; + + UnfoldingMap map; + + MapDisplayShader shader; + + public void setup() { + size(600, 600, OPENGL); + map = new UnfoldingMap(this, 100, 100, 400, 400); + MapUtils.createDefaultEventDispatcher(this, map); + + List features = GeoRSSReader.loadDataGeoRSS(this, earthquakesURL); + List markers = MapUtils.createSimpleMarkers(features); + for (Marker m : markers) { + m.setColor(color(255, 0, 0)); + } + map.addMarkers(markers); + + if (useShaderWithMarker) { + // Mask shader also shades markers + PImage maskImage = loadImage("test/mask-circular.png"); + shader = new MaskedMapDisplayShader(this, 400, 400, maskImage); + } else { + // Blur shader does not shade marker + shader = new BlurredMapDisplayShader(this); + } + + ((OpenGLMapDisplay) map.mapDisplay).setMapDisplayShader(shader); + } + + public void draw() { + background(0); + map.draw(); + } + +} \ No newline at end of file diff --git a/test/de/fhpotsdam/unfolding/examples/mask/SimpleBlurApp.java b/test/de/fhpotsdam/unfolding/examples/mask/SimpleBlurApp.java new file mode 100644 index 00000000..6fe3f618 --- /dev/null +++ b/test/de/fhpotsdam/unfolding/examples/mask/SimpleBlurApp.java @@ -0,0 +1,32 @@ +package de.fhpotsdam.unfolding.examples.mask; + +import processing.core.PApplet; +import de.fhpotsdam.unfolding.UnfoldingMap; +import de.fhpotsdam.unfolding.mapdisplay.OpenGLMapDisplay; +import de.fhpotsdam.unfolding.mapdisplay.shaders.BlurredMapDisplayShader; +import de.fhpotsdam.unfolding.utils.MapUtils; + +/** + * Map is shown inside a fuzzy circle. Uses an gray-scale image as map mask. + */ +public class SimpleBlurApp extends PApplet { + + UnfoldingMap map; + + BlurredMapDisplayShader mapDisplayShader; + + public void setup() { + size(800, 600, OPENGL); + map = new UnfoldingMap(this, 100, 100, 600, 400); + MapUtils.createDefaultEventDispatcher(this, map); + + mapDisplayShader = new BlurredMapDisplayShader(this); + ((OpenGLMapDisplay) map.mapDisplay).setMapDisplayShader(mapDisplayShader); + } + + public void draw() { + background(0); + map.draw(); + } + +} \ No newline at end of file diff --git a/test/de/fhpotsdam/unfolding/examples/mask/SimpleImageMaskApp.java b/test/de/fhpotsdam/unfolding/examples/mask/SimpleImageMaskApp.java new file mode 100644 index 00000000..3d63fdf5 --- /dev/null +++ b/test/de/fhpotsdam/unfolding/examples/mask/SimpleImageMaskApp.java @@ -0,0 +1,34 @@ +package de.fhpotsdam.unfolding.examples.mask; + +import processing.core.PApplet; +import processing.core.PImage; +import de.fhpotsdam.unfolding.UnfoldingMap; +import de.fhpotsdam.unfolding.mapdisplay.OpenGLMapDisplay; +import de.fhpotsdam.unfolding.mapdisplay.shaders.MaskedMapDisplayShader; +import de.fhpotsdam.unfolding.utils.MapUtils; + +/** + * Map is shown inside a fuzzy circle. Uses an gray-scale image as map mask. + */ +public class SimpleImageMaskApp extends PApplet { + + UnfoldingMap map; + + MaskedMapDisplayShader mapDisplayShader; + + public void setup() { + size(400, 400, OPENGL); + map = new UnfoldingMap(this); + MapUtils.createDefaultEventDispatcher(this, map); + + PImage maskImage = loadImage("test/mask-circular.png"); + mapDisplayShader = new MaskedMapDisplayShader(this, 400, 400, maskImage); + ((OpenGLMapDisplay) map.mapDisplay).setMapDisplayShader(mapDisplayShader); + } + + public void draw() { + background(0); + map.draw(); + } + +} \ No newline at end of file diff --git a/test/de/fhpotsdam/unfolding/examples/mask/SimpleMaskApp.java b/test/de/fhpotsdam/unfolding/examples/mask/SimpleMaskApp.java deleted file mode 100644 index 73f14823..00000000 --- a/test/de/fhpotsdam/unfolding/examples/mask/SimpleMaskApp.java +++ /dev/null @@ -1,54 +0,0 @@ -package de.fhpotsdam.unfolding.examples.mask; - -import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; -import codeanticode.glgraphics.GLGraphicsOffScreen; -import de.fhpotsdam.unfolding.UnfoldingMap; -import de.fhpotsdam.unfolding.utils.MapUtils; - -/** - * This example shows the use of an gray-scale mask applied to the map. - */ -public class SimpleMaskApp extends PApplet { - - UnfoldingMap map; - - GLGraphicsOffScreen mask; - - public void setup() { - size(830, 420, GLConstants.GLGRAPHICS); - map = new UnfoldingMap(this, "map1", 10, 10, 400, 400, true, false, null); - MapUtils.createDefaultEventDispatcher(this, map); - - mask = map.mapDisplay.getMask(); - } - - public void draw() { - background(0); - - updateMask(); - map.draw(); - - // shows the mask next to the map - image(mask.getTexture(), 420, 10); - } - - // draw the grayscale mask on an mask object - // 255 = invisible - // 0 = visible - public void updateMask() { - mask.beginDraw(); - mask.background(255); - mask.noStroke(); - mask.fill(100); - mask.ellipse(mouseX, mouseY, 122, 122); - mask.fill(0); - mask.ellipse(mouseX, mouseY, 100, 100); - mask.endDraw(); - } - - public static void main(String[] args) { - PApplet.main(new String[] { "de.fhpotsdam.unfolding.examples.ui.SimpleMaskApp" }); - } - -} \ No newline at end of file diff --git a/test/de/fhpotsdam/unfolding/examples/mask/SimpleMaskAppGl.java b/test/de/fhpotsdam/unfolding/examples/mask/SimpleMaskAppGl.java deleted file mode 100644 index 1b730fa0..00000000 --- a/test/de/fhpotsdam/unfolding/examples/mask/SimpleMaskAppGl.java +++ /dev/null @@ -1,57 +0,0 @@ -package de.fhpotsdam.unfolding.examples.mask; - -import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; -import de.fhpotsdam.unfolding.UnfoldingMap; -import de.fhpotsdam.unfolding.geo.Location; -import de.fhpotsdam.unfolding.ui.MaskUI; -import de.fhpotsdam.unfolding.utils.MapUtils; - -public class SimpleMaskAppGl extends PApplet { - - UnfoldingMap map; - MaskUI mask; - - public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); - map = new UnfoldingMap(this); - map.zoomAndPanTo(new Location(52.5f, 13.4f), 10); - mask = new MaskUI(this); - - MapUtils.createDefaultEventDispatcher(this, map); - } - - public void draw() { - // update the mask - updateMask(); - //background(0, 255, 0); - map.draw(); - - mask.draw(); - - } - - public void updateMask() { - mask.c.beginDraw(); - //mask.c.background(0); - mask.c.noStroke(); - mask.c.fill(255); - mask.c.ellipse(mouseX, mouseY, 100, 100); - mask.c.endDraw(); - - // put the canvas into the texture - // mask.setTexture(canvas.getTexture()); - } - - public void keyPressed() { - if (key == '+') - map.zoomIn(); - if (key == '-') - map.zoomOut(); - } - - public static void main(String[] args) { - PApplet.main(new String[] { "de.fhpotsdam.unfolding.examples.mask.SimpleMaskAppGl" }); - } - -} \ No newline at end of file diff --git a/test/de/fhpotsdam/unfolding/examples/mask/custom/DeformApp.java b/test/de/fhpotsdam/unfolding/examples/mask/custom/DeformApp.java new file mode 100644 index 00000000..5b397fe4 --- /dev/null +++ b/test/de/fhpotsdam/unfolding/examples/mask/custom/DeformApp.java @@ -0,0 +1,34 @@ +package de.fhpotsdam.unfolding.examples.mask.custom; + +import processing.core.PApplet; +import de.fhpotsdam.unfolding.UnfoldingMap; +import de.fhpotsdam.unfolding.mapdisplay.OpenGLMapDisplay; +import de.fhpotsdam.unfolding.utils.MapUtils; + +/** + * Map is shown inside a fuzzy circle. Uses an gray-scale image as map mask. + */ +public class DeformApp extends PApplet { + + UnfoldingMap map; + + DeformMapDisplayShader mapDisplayShader; + + public void setup() { + size(800, 600, OPENGL); + map = new UnfoldingMap(this); + MapUtils.createDefaultEventDispatcher(this, map); + + mapDisplayShader = new DeformMapDisplayShader(this, width, height); + ((OpenGLMapDisplay) map.mapDisplay).setMapDisplayShader(mapDisplayShader); + } + + public void draw() { + background(0); + + mapDisplayShader.setPos(mouseX, mouseY); + + map.draw(); + } + +} \ No newline at end of file diff --git a/test/de/fhpotsdam/unfolding/examples/mask/custom/DeformMapDisplayShader.java b/test/de/fhpotsdam/unfolding/examples/mask/custom/DeformMapDisplayShader.java new file mode 100644 index 00000000..34ae463a --- /dev/null +++ b/test/de/fhpotsdam/unfolding/examples/mask/custom/DeformMapDisplayShader.java @@ -0,0 +1,34 @@ +package de.fhpotsdam.unfolding.examples.mask.custom; + +import de.fhpotsdam.unfolding.mapdisplay.shaders.MapDisplayShader; +import processing.core.PApplet; +import processing.core.PGraphics; + +/** + * This shader deforms a map. + */ +public class DeformMapDisplayShader extends MapDisplayShader { + + float posX; + float posY; + + public DeformMapDisplayShader(PApplet p, float width, float height) { + super(p); + shader = p.loadShader("test/deform.glsl"); + shader.set("resolution", width, height); + } + + @Override + public void shadeWithMarkers(PGraphics mapDisplayCanvas) { + shader.set("time", (float) (p.millis() / 1000.0)); + shader.set("mouse", posX, posY); + mapDisplayCanvas.textureWrap(PApplet.REPEAT); + mapDisplayCanvas.shader(shader); + } + + public void setPos(float posX, float posY) { + this.posX = posX; + this.posY = posY; + } + +} diff --git a/test/de/fhpotsdam/unfolding/interaction/ManualMapInteractionsTestApp.java b/test/de/fhpotsdam/unfolding/interaction/ManualMapInteractionsTestApp.java index d9ddd5d2..6c508a6a 100644 --- a/test/de/fhpotsdam/unfolding/interaction/ManualMapInteractionsTestApp.java +++ b/test/de/fhpotsdam/unfolding/interaction/ManualMapInteractionsTestApp.java @@ -4,7 +4,7 @@ import processing.core.PApplet; import processing.core.PVector; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.DebugDisplay; @@ -29,7 +29,7 @@ public class ManualMapInteractionsTestApp extends PApplet { Location berlinLocation = new Location(52.439046f, 13.447266f); public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this, "map1", 50, 50, 700, 500); map.setTweening(false); diff --git a/test/de/fhpotsdam/unfolding/interaction/PanConstrainedMapSelfApp.java b/test/de/fhpotsdam/unfolding/interaction/PanConstrainedMapSelfApp.java index 79ee675e..226a0027 100644 --- a/test/de/fhpotsdam/unfolding/interaction/PanConstrainedMapSelfApp.java +++ b/test/de/fhpotsdam/unfolding/interaction/PanConstrainedMapSelfApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.interaction; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.GeoUtils; @@ -14,7 +14,7 @@ public class PanConstrainedMapSelfApp extends PApplet { Location centerLocation = new Location(1.359f, 103.816f); public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this); map.zoomAndPanTo(new Location(centerLocation), 12); diff --git a/test/de/fhpotsdam/unfolding/interaction/PanToCenterBugApp.java b/test/de/fhpotsdam/unfolding/interaction/PanToCenterBugApp.java index 5f651c39..64562e6c 100644 --- a/test/de/fhpotsdam/unfolding/interaction/PanToCenterBugApp.java +++ b/test/de/fhpotsdam/unfolding/interaction/PanToCenterBugApp.java @@ -3,7 +3,7 @@ import org.apache.log4j.Logger; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.events.EventDispatcher; import de.fhpotsdam.unfolding.geo.Location; @@ -35,7 +35,7 @@ public class PanToCenterBugApp extends PApplet { public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); smooth(); textFont(loadFont("Miso-Light-12.vlw")); diff --git a/test/de/fhpotsdam/unfolding/marker/compare/ExtendedMarkerApp.java b/test/de/fhpotsdam/unfolding/marker/compare/ExtendedMarkerApp.java index 68b28632..9170349f 100644 --- a/test/de/fhpotsdam/unfolding/marker/compare/ExtendedMarkerApp.java +++ b/test/de/fhpotsdam/unfolding/marker/compare/ExtendedMarkerApp.java @@ -4,7 +4,7 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.marker.Marker; @@ -39,7 +39,7 @@ public class ExtendedMarkerApp extends PApplet { OuterLabelMarker outerLabelMarker; public void setup() { - size(1280, 768, GLConstants.GLGRAPHICS); + size(1280, 768, OPENGL); mapsWithInner = createMaps(50, 20, 170, 170, 10, 10); mapsWithOuter = createMaps(650, 20, 170, 170, 10, 10); diff --git a/test/de/fhpotsdam/unfolding/marker/gllines/GLLinesMarker.java b/test/de/fhpotsdam/unfolding/marker/gllines/GLLinesMarker.java deleted file mode 100644 index f99216c2..00000000 --- a/test/de/fhpotsdam/unfolding/marker/gllines/GLLinesMarker.java +++ /dev/null @@ -1,57 +0,0 @@ -package de.fhpotsdam.unfolding.marker.gllines; - -import java.nio.FloatBuffer; -import java.util.List; - -import javax.media.opengl.GL; - -import processing.core.PGraphics; -import codeanticode.glgraphics.GLGraphicsOffScreen; - -import com.sun.opengl.util.BufferUtil; - -import de.fhpotsdam.unfolding.marker.AbstractShapeMarker; -import de.fhpotsdam.unfolding.utils.MapPosition; - -public class GLLinesMarker extends AbstractShapeMarker { - - @Override - public void draw(PGraphics pg, List mapPositions) { - GL gl = ((GLGraphicsOffScreen) pg).beginGL(); - int n = mapPositions.size(); - - // REVISIT reuse buffers and update if loations.size() changes - FloatBuffer vertices = BufferUtil.newFloatBuffer(n * 2 * 2); - FloatBuffer colors = BufferUtil.newFloatBuffer(n * 3 * 2); - - MapPosition last = mapPositions.get(0); - for (int i = 1; i < mapPositions.size(); ++i) { - MapPosition op = mapPositions.get(i); - vertices.put(last.x); - vertices.put(last.y); - vertices.put(op.x); - vertices.put(op.y); - last = op; - for (int j = 0; j < 6; ++j) { - colors.put(0); - } - } - - gl.glEnableClientState(GL.GL_VERTEX_ARRAY); - vertices.rewind(); - gl.glVertexPointer(2, GL.GL_FLOAT, 0, vertices); - - gl.glEnableClientState(GL.GL_COLOR_ARRAY); - colors.rewind(); - gl.glColorPointer(3, GL.GL_FLOAT, 0, colors); - - gl.glDrawArrays(GL.GL_LINES, 0, n * 2); - ((GLGraphicsOffScreen) pg).endGL(); - } - - @Override - protected boolean isInside(float checkX, float checkY, float x, float y) { - return false; - } - -} diff --git a/test/de/fhpotsdam/unfolding/marker/gllines/GLLinesMarkerApp.java b/test/de/fhpotsdam/unfolding/marker/gllines/GLLinesMarkerApp.java deleted file mode 100644 index 2450c5db..00000000 --- a/test/de/fhpotsdam/unfolding/marker/gllines/GLLinesMarkerApp.java +++ /dev/null @@ -1,35 +0,0 @@ -package de.fhpotsdam.unfolding.marker.gllines; - -import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; -import de.fhpotsdam.unfolding.UnfoldingMap; -import de.fhpotsdam.unfolding.geo.Location; -import de.fhpotsdam.unfolding.utils.MapUtils; - -@SuppressWarnings("serial") -public class GLLinesMarkerApp extends PApplet { - - UnfoldingMap map; - - //TODO @fx-lange use dataset - - public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); - - map = new UnfoldingMap(this, 0, 0, 800, 500); - map.zoomToLevel(3); - map.panTo(new Location(40f, 8f)); - MapUtils.createDefaultEventDispatcher(this, map); - - GLLinesMarker linesMarker = new GLLinesMarker(); - linesMarker.addLocations(new Location(52.5f, 13.4f+0.5f)); - linesMarker.addLocations(new Location(51.5f, 0.0f)); - linesMarker.addLocations(new Location(48.f, 5f)); - - map.addMarkers(linesMarker); - } - - public void draw(){ - map.draw(); - } -} diff --git a/test/de/fhpotsdam/unfolding/masks/DynamicMaskedGLGraphicsApp.java b/test/de/fhpotsdam/unfolding/masks/DynamicMaskedGLGraphicsApp.java deleted file mode 100644 index cbd6f845..00000000 --- a/test/de/fhpotsdam/unfolding/masks/DynamicMaskedGLGraphicsApp.java +++ /dev/null @@ -1,81 +0,0 @@ -package de.fhpotsdam.unfolding.masks; - -import processing.core.PApplet; -import processing.core.PGraphics; -import codeanticode.glgraphics.GLConstants; -import codeanticode.glgraphics.GLGraphicsOffScreen; -import codeanticode.glgraphics.GLTexture; -import codeanticode.glgraphics.GLTextureFilter; - -public class DynamicMaskedGLGraphicsApp extends PApplet { - - GLTexture maskedTex; - - GLGraphicsOffScreen buf; - - public void setup() { - size(768, 256, GLConstants.GLGRAPHICS); - - GLTexture imgTex = new GLTexture(this, "test/beach.jpg"); - // GLTexture imgMask = new GLTexture(this, "test/mask.png"); - GLTexture imgMask = new GLTexture(this, 256, 256); - - PGraphics pg = createGraphics(256, 256, P2D); - pg.beginDraw(); - pg.noStroke(); - pg.background(0); - pg.fill(255, 100); - pg.ellipse(100, 100, 100, 100); - pg.fill(0, 100); - pg.ellipse(200, 150, 100, 100); - pg.endDraw(); - - buf = new GLGraphicsOffScreen(this, width, height, true, 4); - buf.beginDraw(); - buf.noStroke(); - buf.background(0); - buf.fill(255, 100); - buf.ellipse(100, 100, 100, 100); - buf.fill(0, 100); - buf.ellipse(200, 150, 100, 100); - buf.endDraw(); - - imgMask.loadPixels(); - // imgMask.updateTexture(); - //buf.loadPixels(); - // imgMask.copy(buf.getTexture(), 0, 0, 256, 256, 0, 0, 256, 256); - int k = 0; - for (int j = 0; j < 256; j++) - for (int i = 0; i < 256; i++) { - imgMask.pixels[k] = pg.pixels[k]; - // if (j < 100) - // imgMask.pixels[k] = color(255, 50); - // else - // imgMask.pixels[k] = color(255, 100); - k++; - } - // imgMask.loadTexture(); - imgMask.updatePixels(); - - //image(buf.getTexture(), 0, 0); - image(pg, 0, 0); - image(imgMask, 256, 0); - - maskedTex = new GLTexture(this, 256, 256); - - GLTextureFilter maskFilter = new GLTextureFilter(this, "test/Mask.xml"); - - maskFilter.setParameterValue("mask_factor", 0.0f); - maskFilter.apply(new GLTexture[] { imgTex, imgMask }, maskedTex); - - image(maskedTex, 512, 0); - } - - public void draw() { - // background(20, 255, 30); - // image(maskedTex, 0, 0); - - // image(buf.getTexture(), 0, 0, width, height); - } - -} diff --git a/test/de/fhpotsdam/unfolding/masks/MaskedGLGraphicsApp.java b/test/de/fhpotsdam/unfolding/masks/MaskedGLGraphicsApp.java deleted file mode 100644 index ea1cec99..00000000 --- a/test/de/fhpotsdam/unfolding/masks/MaskedGLGraphicsApp.java +++ /dev/null @@ -1,61 +0,0 @@ -package de.fhpotsdam.unfolding.masks; - -import processing.core.PApplet; -import processing.core.PGraphics; -import codeanticode.glgraphics.GLConstants; -import codeanticode.glgraphics.GLGraphicsOffScreen; -import codeanticode.glgraphics.GLTexture; -import codeanticode.glgraphics.GLTextureFilter; - -public class MaskedGLGraphicsApp extends PApplet { - - GLTexture maskedTex; - - GLGraphicsOffScreen buf; - - public void setup() { - size(256, 256, GLConstants.GLGRAPHICS); - - GLTexture imgTex = new GLTexture(this, "test/beach.jpg"); - // GLTexture imgMask = new GLTexture(this, "test/mask.png"); - GLTexture imgMask = new GLTexture(this, 256, 256); - - PGraphics pg = createGraphics(256, 256, P2D); - pg.beginDraw(); - pg.fill(255, 200); - pg.ellipse(100, 100, 100, 100); - pg.endDraw(); - - - imgMask.loadPixels(); - imgMask.copy(pg, 0, 0, 256, 256, 0, 0, 256, 256); -// int k = 0; -// for (int j = 0; j < 256; j++) -// for (int i = 0; i < 256; i++) { -// if (j < 100) -// imgMask.pixels[k] = color(255, 30); -// else -// imgMask.pixels[k] = color(255, 100); -// k++; -// } - imgMask.loadTexture(); - - image(imgMask, 0, 0); - - - maskedTex = new GLTexture(this, 256, 256); - - GLTextureFilter maskFilter = new GLTextureFilter(this, "Mask.xml"); - - maskFilter.setParameterValue("mask_factor", 0.0f); - maskFilter.apply(new GLTexture[] { imgTex, imgMask }, maskedTex); - - image(maskedTex, 0, 0); - } - - public void draw() { - //background(20, 255, 30); - //image(maskedTex, 0, 0); - } - -} diff --git a/test/de/fhpotsdam/unfolding/masks/MaskedImageApp.java b/test/de/fhpotsdam/unfolding/masks/MaskedImageApp.java index 9e0a39b0..704d56da 100644 --- a/test/de/fhpotsdam/unfolding/masks/MaskedImageApp.java +++ b/test/de/fhpotsdam/unfolding/masks/MaskedImageApp.java @@ -17,7 +17,7 @@ public class MaskedImageApp extends PApplet { float vx, vy = random(1, 2); public void setup() { - size(800, 600); + size(800, 600, P2D); img = loadImage("test/test800x600.png"); diff --git a/test/de/fhpotsdam/unfolding/masks/MaskedMapApp.java b/test/de/fhpotsdam/unfolding/masks/MaskedMapApp.java deleted file mode 100644 index d4a73f5c..00000000 --- a/test/de/fhpotsdam/unfolding/masks/MaskedMapApp.java +++ /dev/null @@ -1,26 +0,0 @@ -package de.fhpotsdam.unfolding.masks; - -import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; -import de.fhpotsdam.unfolding.UnfoldingMap; -import de.fhpotsdam.unfolding.utils.MapUtils; - -public class MaskedMapApp extends PApplet { - - UnfoldingMap map; - - public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); - - map = new UnfoldingMap(this); - MapUtils.createDefaultEventDispatcher(this, map); - map.zoomToLevel(2); - } - - public void draw() { - background(0); - - map.draw(); - } - -} diff --git a/test/de/fhpotsdam/unfolding/misc/WrapAroundMapApp.java b/test/de/fhpotsdam/unfolding/misc/WrapAroundMapApp.java new file mode 100644 index 00000000..36a4d96d --- /dev/null +++ b/test/de/fhpotsdam/unfolding/misc/WrapAroundMapApp.java @@ -0,0 +1,68 @@ +package de.fhpotsdam.unfolding.misc; + +import processing.core.PApplet; +import de.fhpotsdam.unfolding.UnfoldingMap; +import de.fhpotsdam.unfolding.events.EventDispatcher; +import de.fhpotsdam.unfolding.geo.Location; +import de.fhpotsdam.unfolding.utils.MapUtils; +import de.fhpotsdam.unfolding.utils.ScreenPosition; + +public class WrapAroundMapApp extends PApplet { + + UnfoldingMap map; + + UnfoldingMap leftMap; + UnfoldingMap rightMap; + + public void setup() { + size(800, 600, P2D); + + map = new UnfoldingMap(this); + map.zoomToLevel(2); + EventDispatcher eventDispatcher = MapUtils.createDefaultEventDispatcher(this, map); + + leftMap = createWrappedMap(map, eventDispatcher, true); + rightMap = createWrappedMap(map, eventDispatcher, false); + } + + public UnfoldingMap createWrappedMap(UnfoldingMap mainMap, EventDispatcher eventDispatcher, boolean left) { + UnfoldingMap wrappedMap = new UnfoldingMap(this); + wrappedMap.zoomToLevel(mainMap.getZoomLevel()); + eventDispatcher.register(wrappedMap, "zoom", mainMap.getId()); + return wrappedMap; + } + + public void draw() { + background(0, 255, 0); + + updateMap(map, leftMap, true); + updateMap(map, rightMap, false); + + map.draw(); + leftMap.draw(); + rightMap.draw(); + } + + public void updateMap(UnfoldingMap mainMap, UnfoldingMap nextMap, boolean left) { + float degree = (left) ? -180 : 180; + + // Move next map + ScreenPosition pos = mainMap.getScreenPosition(new Location(0, degree)); + nextMap.move(pos.x, 0); + if (left) { + nextMap.moveBy(-800, 0); + } + + // Pan next map + nextMap.panTo(new Location(0, 0)); + ScreenPosition map1RightPos = mainMap.getScreenPosition(new Location(0, degree)); + Location map1RightLocation = nextMap.getLocation(map1RightPos); + float lonDiff = (-map1RightLocation.getLon()) - degree; + nextMap.panTo(new Location(-map1RightLocation.getLat(), lonDiff)); + + // Ensure next map is always over main map (push 1px) + float fixLastPixel = (left) ? 1 : -1; + nextMap.panBy(fixLastPixel, 0); + } + +} diff --git a/test/de/fhpotsdam/unfolding/multi/MultiProviderMultiMapApp.java b/test/de/fhpotsdam/unfolding/multi/MultiProviderMultiMapApp.java index d2287be9..633d64d3 100644 --- a/test/de/fhpotsdam/unfolding/multi/MultiProviderMultiMapApp.java +++ b/test/de/fhpotsdam/unfolding/multi/MultiProviderMultiMapApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.multi; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.mapdisplay.MapDisplayFactory; import de.fhpotsdam.unfolding.providers.Microsoft; @@ -17,7 +17,7 @@ public class MultiProviderMultiMapApp extends PApplet { UnfoldingMap map2; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); map1 = new UnfoldingMap(this, "map1", 10, 10, 385, 580, true, false, new Microsoft.AerialProvider()); map2 = new UnfoldingMap(this, "map2", 405, 10, 385, 580, true, false, new OpenStreetMap.CloudmadeProvider( diff --git a/test/de/fhpotsdam/unfolding/overviewdetail/KiteConnectedMapOnStaticMap.java b/test/de/fhpotsdam/unfolding/overviewdetail/KiteConnectedMapOnStaticMap.java index 6a4864a8..0997c509 100644 --- a/test/de/fhpotsdam/unfolding/overviewdetail/KiteConnectedMapOnStaticMap.java +++ b/test/de/fhpotsdam/unfolding/overviewdetail/KiteConnectedMapOnStaticMap.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.overviewdetail; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.examples.overviewdetail.connection.OverviewPlusDetailConnection; import de.fhpotsdam.unfolding.geo.Location; @@ -22,7 +22,7 @@ public class KiteConnectedMapOnStaticMap extends PApplet { OverviewPlusDetailConnection kiteConnection; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); mapStatic = new UnfoldingMap(this, "static", 0, 0, 800, 600); // MapUtils.createDefaultEventDispatcher(this, mapStatic); diff --git a/test/de/fhpotsdam/unfolding/overviewdetail/KiteConnectionApp.java b/test/de/fhpotsdam/unfolding/overviewdetail/KiteConnectionApp.java index 3e0ba60e..d3698563 100644 --- a/test/de/fhpotsdam/unfolding/overviewdetail/KiteConnectionApp.java +++ b/test/de/fhpotsdam/unfolding/overviewdetail/KiteConnectionApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.overviewdetail; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.examples.overviewdetail.connection.OverviewPlusDetailConnection; public class KiteConnectionApp extends PApplet { @@ -9,7 +9,7 @@ public class KiteConnectionApp extends PApplet { OverviewPlusDetailConnection connection; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); connection = new KiteConnection(this); } diff --git a/test/de/fhpotsdam/unfolding/performance/GeoJSONMarkerApp.java b/test/de/fhpotsdam/unfolding/performance/GeoJSONMarkerApp.java new file mode 100644 index 00000000..160724b8 --- /dev/null +++ b/test/de/fhpotsdam/unfolding/performance/GeoJSONMarkerApp.java @@ -0,0 +1,122 @@ +package de.fhpotsdam.unfolding.performance; + +import java.util.List; + +import processing.core.PApplet; +import processing.core.PShape; +import de.fhpotsdam.unfolding.UnfoldingMap; +import de.fhpotsdam.unfolding.data.Feature; +import de.fhpotsdam.unfolding.data.Feature.FeatureType; +import de.fhpotsdam.unfolding.data.GeoJSONReader; +import de.fhpotsdam.unfolding.data.ShapeFeature; +import de.fhpotsdam.unfolding.events.MapEvent; +import de.fhpotsdam.unfolding.geo.Location; +import de.fhpotsdam.unfolding.utils.MapUtils; +import de.fhpotsdam.unfolding.utils.ScreenPosition; + +/** + * Displays countries of the world as simple polygons. + * + * Reads from a GeoJSON file, and uses default marker creation. Features are polygons. + * + * Press SPACE to toggle visibility of the polygons. + */ +public class GeoJSONMarkerApp extends PApplet { + + UnfoldingMap map; + + List countries; + PShape shapeGroup; + + public void setup() { + size(800, 600, OPENGL); + smooth(); + + map = new UnfoldingMap(this, 50, 50, 700, 500); + map.zoomToLevel(2); + MapUtils.createDefaultEventDispatcher(this, map); + + countries = GeoJSONReader.loadData(this, "data/countries.geo.json"); + shapeGroup = createShapeGroup(countries); + } + + public void draw() { + background(160); + map.draw(); + + shape(shapeGroup); + + fill(255); + rect(5, 5, 180, 20); + fill(0); + text("fps: " + nfs(frameRate, 0, 2), 10, 20); + } + + public PShape createShapeGroup(List features) { + shapeGroup = createShape(PShape.GROUP); + + for (int i = 0; i < features.size(); i++) { + Feature feature = features.get(i); + if (feature.getType().equals(FeatureType.POLYGON)) { + ShapeFeature shapeFeature = (ShapeFeature) feature; + + updateShape("c" + i, shapeFeature, false); + } + } + return shapeGroup; + } + + public void updateShape(String shapeName, ShapeFeature shapeFeature, boolean update) { + if (!update) { + // Create shape + PShape shape = createShape(); + shape.beginShape(); + shape.stroke(30); + //shape.fill(255, 0, 0, 4); + shape.fill(color(255, 0, 0), 100); + updateShapeVertices(shape, shapeFeature, false); + shape.endShape(); + + // Add shape AND add to name list to retrieve later + shapeGroup.addChild(shape); + shapeGroup.addName(shapeName, shape); + } + else { + // Get shape via name list (and not via index) + PShape shape = shapeGroup.getChild(shapeName); + // PShape shape = shapeGroup.getChild(i); + + updateShapeVertices(shape, shapeFeature, true); + } + } + + public void updateShapeVertices(PShape shape, ShapeFeature shapeFeature, boolean update) { + List locations = shapeFeature.getLocations(); + int v = 0; + for (Location location : locations) { + ScreenPosition pos = map.getScreenPosition(location); + if (update) { + shape.setVertex(v++, pos.x, pos.y); + } + else { + shape.vertex(pos.x, pos.y); + } + } + } + + public void mapChanged(MapEvent mapEvent) { + updateFeatures(countries); + } + + public void updateFeatures(List features) { + for (int i = 0; i < features.size(); i++) { + Feature feature = features.get(i); + if (feature.getType().equals(FeatureType.POLYGON)) { + ShapeFeature shapeFeature = (ShapeFeature) feature; + + updateShape("c" + i, shapeFeature, true); + } + } + + } +} diff --git a/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp1.java b/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp1.java index 24610b96..749fc5e4 100644 --- a/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp1.java +++ b/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp1.java @@ -5,7 +5,7 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.MapUtils; @@ -28,7 +28,7 @@ public class MillionDotsMapApp1 extends PApplet { boolean useMouseRect = false; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); smooth(); map = new UnfoldingMap(this); diff --git a/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp2.java b/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp2.java index 2c70c801..bba98d46 100644 --- a/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp2.java +++ b/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp2.java @@ -5,7 +5,7 @@ import java.util.List; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.events.MapEvent; import de.fhpotsdam.unfolding.geo.Location; @@ -28,7 +28,7 @@ public class MillionDotsMapApp2 extends PApplet { Location brLoc; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); smooth(); dots = createRandomDots(50000); diff --git a/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp3.java b/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp3.java index 803fe0a8..3035bba6 100644 --- a/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp3.java +++ b/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp3.java @@ -6,7 +6,7 @@ import processing.core.PApplet; import processing.core.PVector; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.events.MapEvent; import de.fhpotsdam.unfolding.geo.Location; @@ -31,7 +31,7 @@ public class MillionDotsMapApp3 extends PApplet { Location brLoc; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); smooth(); dots = createRandomDots(100000); diff --git a/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp4Timer.java b/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp4Timer.java index b835e10f..dad84079 100644 --- a/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp4Timer.java +++ b/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp4Timer.java @@ -6,7 +6,7 @@ import processing.core.PApplet; import processing.core.PVector; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.events.MapEvent; import de.fhpotsdam.unfolding.geo.Location; @@ -42,7 +42,7 @@ public class MillionDotsMapApp4Timer extends PApplet { Location brLoc; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); smooth(); dots = createRandomDots(10000); diff --git a/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp5Timer2.java b/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp5Timer2.java index 7581f05c..1fe78e9b 100644 --- a/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp5Timer2.java +++ b/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp5Timer2.java @@ -6,7 +6,6 @@ import processing.core.PApplet; import processing.core.PVector; -import codeanticode.glgraphics.GLConstants; import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.events.MapEvent; import de.fhpotsdam.unfolding.geo.Location; @@ -17,6 +16,9 @@ * * (c) 2012 Till Nagel, unfoldingmaps.org * + * + * SEE unfolding-dots-performance-results.txt!! + * * Used for various performance tests. *
    *
  • pure drawing (fps for 10k, 100k, 1000k.)
  • @@ -43,7 +45,7 @@ public class MillionDotsMapApp5Timer2 extends PApplet { Location brLoc; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); smooth(); dots = createRandomDots(20000); diff --git a/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp6GLModel.java b/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp6GLModel.java index c2cfda3b..95d42c44 100644 --- a/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp6GLModel.java +++ b/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp6GLModel.java @@ -1,140 +1,142 @@ -package de.fhpotsdam.unfolding.performance; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import processing.core.PApplet; -import processing.core.PVector; -import codeanticode.glgraphics.GLConstants; -import codeanticode.glgraphics.GLGraphics; -import codeanticode.glgraphics.GLModel; -import de.fhpotsdam.unfolding.UnfoldingMap; -import de.fhpotsdam.unfolding.events.MapEvent; -import de.fhpotsdam.unfolding.geo.Location; -import de.fhpotsdam.unfolding.utils.MapUtils; - -/** - * Displays a million markers on the map. - * - * (c) 2012 Till Nagel, unfoldingmaps.org - * - * Used for various performance tests. - *
      - *
    • pure drawing (fps for 10k, 100k, 1000k.)
    • - *
    • pure drawing markers (ditto)
    • - *
    • filter cut-off on map border
    • - *
    • filtering only on map change
    • - *
    • calculating ScreenPosition only on map change
    • - *
    • Different visual representations (e.g. rect vs ellipse
    • - *
    • Use GLModel (see ltavis)
    • - *
    • ...
    • - *
    - * - * Outcomes - rect is faster than ellipse (20k. rect: 24fps, ellipse: 7fps) - * - */ -public class MillionDotsMapApp6GLModel extends PApplet { - - int dotNumber = 20000; - - UnfoldingMap map; - // Original dots (loc + time) - List dots = new ArrayList(); - - // Visible points - List visibleDotVertices = new ArrayList(); - // GLGraphics model containing vertices - GLModel model; - - Location tlLoc; - Location brLoc; - - public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); - smooth(); - - dots = createRandomDots(dotNumber); - - map = new UnfoldingMap(this); - map.zoomToLevel(3); - MapUtils.createDefaultEventDispatcher(this, map); - - mapChanged(null); - model = new GLModel(this, dotNumber * 4, GLModel.QUADS, GLModel.STATIC); - } - - public void draw() { - background(0); - map.draw(); - - fill(0, 180); - noStroke(); - - synchronized (visibleDotVertices) { - updateModelVertices(); - drawModel(); - } - - fill(255); - rect(5, 5, 180, 20); - fill(0); - text("fps: " + nfs(frameRate, 0, 2) + " (" + visibleDotVertices.size() + " dots)", 10, 20); - } - - public void drawModel() { - GLGraphics renderer = (GLGraphics) g; - renderer.beginGL(); - //renderer.model(model); - // Using render(int, int, GLEffect) method, due to bug (see https://forum.processing.org/topic/getting-extra-vertices-when-building-a-mesh-with-glmodel#25080000001046326) - int verticesPerSegment = 4; - int numVertices = visibleDotVertices.size() * verticesPerSegment; - model.render(0, numVertices, null); - renderer.endGL(); - } - - public void updateModelVertices() { - model.beginUpdateVertices(); - int verticesPerSegment = 4; - int numVertices = visibleDotVertices.size() * verticesPerSegment; - synchronized (visibleDotVertices) { - for (int i = 0; i < numVertices; i += verticesPerSegment) { - PVector pos = visibleDotVertices.get(i / verticesPerSegment); - model.updateVertex(i, pos.x, pos.y); - model.updateVertex(i + 1, pos.x - 4, pos.y); - model.updateVertex(i + 2, pos.x - 4, pos.y - 4); - model.updateVertex(i + 3, pos.x, pos.y - 4); - } - } - model.endUpdateVertices(); - } - - public void mapChanged(MapEvent mapEvent) { - // Check map area only once after user interaction. - // Additionally, instead of calculating the screen position each frame, store it in new list. - brLoc = map.getBottomRightBorder(); - tlLoc = map.getTopLeftBorder(); - synchronized (visibleDotVertices) { - visibleDotVertices.clear(); - for (Dot dot : dots) { - if (dot.location.getLat() > brLoc.getLat() && dot.location.getLat() < tlLoc.getLat() - && dot.location.getLon() > tlLoc.getLon() && dot.location.getLon() < brLoc.getLon()) { - PVector pos = map.getScreenPosition(dot.location); - visibleDotVertices.add(pos); - } - } - - - //model = new GLModel(this, visibleDotVertices.size() * 4, GLModel.QUADS, GLModel.STATIC); - } - } - - private List createRandomDots(int dotNumbers) { - List dots = new ArrayList(); - for (int i = 0; i < dotNumbers; i++) { - Dot dot = new Dot(new Location(random(-85, 85), random(-180, 180)), new Date()); - dots.add(dot); - } - return dots; - } -} +//package de.fhpotsdam.unfolding.performance; +// +//import java.util.ArrayList; +//import java.util.Date; +//import java.util.List; +// +//import processing.core.PApplet; +//import processing.core.PVector; +// +// +// +//import de.fhpotsdam.unfolding.UnfoldingMap; +//import de.fhpotsdam.unfolding.events.MapEvent; +//import de.fhpotsdam.unfolding.geo.Location; +//import de.fhpotsdam.unfolding.utils.MapUtils; +// +///** +// * Displays a million markers on the map. +// * +// * (c) 2012 Till Nagel, unfoldingmaps.org +// * +// * SEE unfolding-dots-performance-results.txt!! +// * +// * Used for various performance tests. +// *
      +// *
    • pure drawing (fps for 10k, 100k, 1000k.)
    • +// *
    • pure drawing markers (ditto)
    • +// *
    • filter cut-off on map border
    • +// *
    • filtering only on map change
    • +// *
    • calculating ScreenPosition only on map change
    • +// *
    • Different visual representations (e.g. rect vs ellipse
    • +// *
    • Use GLModel (see ltavis)
    • +// *
    • ...
    • +// *
    +// * +// * Outcomes - rect is faster than ellipse (20k. rect: 24fps, ellipse: 7fps) +// * +// */ +//public class MillionDotsMapApp6GLModel extends PApplet { +// +// int dotNumber = 20000; +// +// UnfoldingMap map; +// // Original dots (loc + time) +// List dots = new ArrayList(); +// +// // Visible points +// List visibleDotVertices = new ArrayList(); +// // GLGraphics model containing vertices +// GLModel model; +// +// Location tlLoc; +// Location brLoc; +// +// public void setup() { +// size(800, 600, OPENGL); +// smooth(); +// +// dots = createRandomDots(dotNumber); +// +// map = new UnfoldingMap(this); +// map.zoomToLevel(3); +// MapUtils.createDefaultEventDispatcher(this, map); +// +// mapChanged(null); +// model = new GLModel(this, dotNumber * 4, GLModel.QUADS, GLModel.STATIC); +// } +// +// public void draw() { +// background(0); +// map.draw(); +// +// fill(0, 180); +// noStroke(); +// +// synchronized (visibleDotVertices) { +// updateModelVertices(); +// drawModel(); +// } +// +// fill(255); +// rect(5, 5, 180, 20); +// fill(0); +// text("fps: " + nfs(frameRate, 0, 2) + " (" + visibleDotVertices.size() + " dots)", 10, 20); +// } +// +// public void drawModel() { +// GLGraphics renderer = (GLGraphics) g; +// renderer.beginGL(); +// //renderer.model(model); +// // Using render(int, int, GLEffect) method, due to bug (see https://forum.processing.org/topic/getting-extra-vertices-when-building-a-mesh-with-glmodel#25080000001046326) +// int verticesPerSegment = 4; +// int numVertices = visibleDotVertices.size() * verticesPerSegment; +// model.render(0, numVertices, null); +// renderer.endGL(); +// } +// +// public void updateModelVertices() { +// model.beginUpdateVertices(); +// int verticesPerSegment = 4; +// int numVertices = visibleDotVertices.size() * verticesPerSegment; +// synchronized (visibleDotVertices) { +// for (int i = 0; i < numVertices; i += verticesPerSegment) { +// PVector pos = visibleDotVertices.get(i / verticesPerSegment); +// model.updateVertex(i, pos.x, pos.y); +// model.updateVertex(i + 1, pos.x - 4, pos.y); +// model.updateVertex(i + 2, pos.x - 4, pos.y - 4); +// model.updateVertex(i + 3, pos.x, pos.y - 4); +// } +// } +// model.endUpdateVertices(); +// } +// +// public void mapChanged(MapEvent mapEvent) { +// // Check map area only once after user interaction. +// // Additionally, instead of calculating the screen position each frame, store it in new list. +// brLoc = map.getBottomRightBorder(); +// tlLoc = map.getTopLeftBorder(); +// synchronized (visibleDotVertices) { +// visibleDotVertices.clear(); +// for (Dot dot : dots) { +// if (dot.location.getLat() > brLoc.getLat() && dot.location.getLat() < tlLoc.getLat() +// && dot.location.getLon() > tlLoc.getLon() && dot.location.getLon() < brLoc.getLon()) { +// PVector pos = map.getScreenPosition(dot.location); +// visibleDotVertices.add(pos); +// } +// } +// +// +// //model = new GLModel(this, visibleDotVertices.size() * 4, GLModel.QUADS, GLModel.STATIC); +// } +// } +// +// private List createRandomDots(int dotNumbers) { +// List dots = new ArrayList(); +// for (int i = 0; i < dotNumbers; i++) { +// Dot dot = new Dot(new Location(random(-85, 85), random(-180, 180)), new Date()); +// dots.add(dot); +// } +// return dots; +// } +//} diff --git a/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp6GLModelMoving.java b/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp6GLModelMoving.java index 3a744a1e..bbe0dac9 100644 --- a/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp6GLModelMoving.java +++ b/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp6GLModelMoving.java @@ -1,166 +1,166 @@ -package de.fhpotsdam.unfolding.performance; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import processing.core.PApplet; -import processing.core.PVector; -import codeanticode.glgraphics.GLConstants; -import codeanticode.glgraphics.GLGraphics; -import codeanticode.glgraphics.GLModel; -import codeanticode.glgraphics.GLTexture; -import de.fhpotsdam.unfolding.UnfoldingMap; -import de.fhpotsdam.unfolding.events.MapEvent; -import de.fhpotsdam.unfolding.geo.Location; -import de.fhpotsdam.unfolding.utils.MapUtils; - -/** - - * - */ -public class MillionDotsMapApp6GLModelMoving extends PApplet { - - int dotNumber = 20000; - - UnfoldingMap map; - // Original dots (loc + time) - List dots = new ArrayList(); - - // Visible points - List visibleDotVertices = new ArrayList(); - // GLGraphics model containing vertices - GLModel model; - - GLTexture tex; - - Location tlLoc; - Location brLoc; - - public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); - smooth(); - - dots = createRandomDots(dotNumber); - - map = new UnfoldingMap(this); - map.zoomToLevel(3); - MapUtils.createDefaultEventDispatcher(this, map); - - initAllDots(); - model = new GLModel(this, dotNumber * 4, GLModel.QUADS, GLModel.STATIC); - - model.initTextures(1); - tex = new GLTexture(this, "sprite-pink.png"); - model.setTexture(0, tex); - - println("visibleDotVertices.size():" + visibleDotVertices.size()); - updateTexture(); - } - - public void draw() { - background(0); - map.draw(); - - fill(0, 180); - noStroke(); - - timeChanged(); - - synchronized (visibleDotVertices) { - updateModelVertices(); - drawModel(); - } - - fill(255); - rect(5, 5, 180, 20); - fill(0); - text("fps: " + nfs(frameRate, 0, 2) + " (" + visibleDotVertices.size() + " dots)", 10, 20); - } - - public void drawModel() { - GLGraphics renderer = (GLGraphics) g; - renderer.beginGL(); - - - // Do not draw full model, as only visible dots (i.e. their vertices) should be shown - // renderer.model(model); - - // Using render(int, int, GLEffect) method, due to bug (see - // https://forum.processing.org/topic/getting-extra-vertices-when-building-a-mesh-with-glmodel#25080000001046326) - int verticesPerSegment = 4; - int numVertices = visibleDotVertices.size() * verticesPerSegment; - model.render(0, numVertices, null); - renderer.endGL(); - } - - public void updateTexture() { - model.beginUpdateTexCoords(0); - int verticesPerSegment = 4; - int numVertices = visibleDotVertices.size() * verticesPerSegment; - for (int i = 0; i < numVertices; i += verticesPerSegment) { - model.updateTexCoord(i, 0, 0); - model.updateTexCoord(i + 1, 1, 0); - model.updateTexCoord(i + 2, 1, 1); - model.updateTexCoord(i + 3, 0, 1); - } - model.endUpdateTexCoords(); - } - - public void updateModelVertices() { - model.beginUpdateVertices(); - int verticesPerSegment = 4; - int numVertices = visibleDotVertices.size() * verticesPerSegment; - synchronized (visibleDotVertices) { - for (int i = 0; i < numVertices; i += verticesPerSegment) { - PVector pos = visibleDotVertices.get(i / verticesPerSegment); - model.updateVertex(i, pos.x, pos.y); - model.updateVertex(i + 1, pos.x - 4, pos.y); - model.updateVertex(i + 2, pos.x - 4, pos.y - 4); - model.updateVertex(i + 3, pos.x, pos.y - 4); - } - } - model.endUpdateVertices(); - } - - public void timeChanged() { - mapChanged(null); - } - - public void mapChanged(MapEvent mapEvent) { - // Check map area only once after user interaction. - // Additionally, instead of calculating the screen position each frame, store it in new list. - brLoc = map.getBottomRightBorder(); - tlLoc = map.getTopLeftBorder(); - synchronized (visibleDotVertices) { - visibleDotVertices.clear(); - for (Dot dot : dots) { - Location location = new Location(dot.location.getLat() + random(-1, 1), dot.location.getLon() - + random(-1, 1)); - if (location.getLat() > brLoc.getLat() && location.getLat() < tlLoc.getLat() - && location.getLon() > tlLoc.getLon() && location.getLon() < brLoc.getLon()) { - PVector pos = map.getScreenPosition(location); - visibleDotVertices.add(pos); - } - } - - // model = new GLModel(this, visibleDotVertices.size() * 4, GLModel.QUADS, GLModel.STATIC); - } - } - - public void initAllDots() { - for (Dot dot : dots) { - PVector pos = map.getScreenPosition(dot.location); - visibleDotVertices.add(pos); - } - } - - private List createRandomDots(int dotNumbers) { - List dots = new ArrayList(); - for (int i = 0; i < dotNumbers; i++) { - Dot dot = new Dot(new Location(random(-85, 85), random(-180, 180)), new Date()); - dots.add(dot); - } - return dots; - } -} +//package de.fhpotsdam.unfolding.performance; +// +//import java.util.ArrayList; +//import java.util.Date; +//import java.util.List; +// +//import processing.core.PApplet; +//import processing.core.PVector; +// +// +// +// +//import de.fhpotsdam.unfolding.UnfoldingMap; +//import de.fhpotsdam.unfolding.events.MapEvent; +//import de.fhpotsdam.unfolding.geo.Location; +//import de.fhpotsdam.unfolding.utils.MapUtils; +// +///** +// +// * +// */ +//public class MillionDotsMapApp6GLModelMoving extends PApplet { +// +// int dotNumber = 20000; +// +// UnfoldingMap map; +// // Original dots (loc + time) +// List dots = new ArrayList(); +// +// // Visible points +// List visibleDotVertices = new ArrayList(); +// // GLGraphics model containing vertices +// GLModel model; +// +// GLTexture tex; +// +// Location tlLoc; +// Location brLoc; +// +// public void setup() { +// size(800, 600, OPENGL); +// smooth(); +// +// dots = createRandomDots(dotNumber); +// +// map = new UnfoldingMap(this); +// map.zoomToLevel(3); +// MapUtils.createDefaultEventDispatcher(this, map); +// +// initAllDots(); +// model = new GLModel(this, dotNumber * 4, GLModel.QUADS, GLModel.STATIC); +// +// model.initTextures(1); +// tex = new GLTexture(this, "sprite-pink.png"); +// model.setTexture(0, tex); +// +// println("visibleDotVertices.size():" + visibleDotVertices.size()); +// updateTexture(); +// } +// +// public void draw() { +// background(0); +// map.draw(); +// +// fill(0, 180); +// noStroke(); +// +// timeChanged(); +// +// synchronized (visibleDotVertices) { +// updateModelVertices(); +// drawModel(); +// } +// +// fill(255); +// rect(5, 5, 180, 20); +// fill(0); +// text("fps: " + nfs(frameRate, 0, 2) + " (" + visibleDotVertices.size() + " dots)", 10, 20); +// } +// +// public void drawModel() { +// GLGraphics renderer = (GLGraphics) g; +// renderer.beginGL(); +// +// +// // Do not draw full model, as only visible dots (i.e. their vertices) should be shown +// // renderer.model(model); +// +// // Using render(int, int, GLEffect) method, due to bug (see +// // https://forum.processing.org/topic/getting-extra-vertices-when-building-a-mesh-with-glmodel#25080000001046326) +// int verticesPerSegment = 4; +// int numVertices = visibleDotVertices.size() * verticesPerSegment; +// model.render(0, numVertices, null); +// renderer.endGL(); +// } +// +// public void updateTexture() { +// model.beginUpdateTexCoords(0); +// int verticesPerSegment = 4; +// int numVertices = visibleDotVertices.size() * verticesPerSegment; +// for (int i = 0; i < numVertices; i += verticesPerSegment) { +// model.updateTexCoord(i, 0, 0); +// model.updateTexCoord(i + 1, 1, 0); +// model.updateTexCoord(i + 2, 1, 1); +// model.updateTexCoord(i + 3, 0, 1); +// } +// model.endUpdateTexCoords(); +// } +// +// public void updateModelVertices() { +// model.beginUpdateVertices(); +// int verticesPerSegment = 4; +// int numVertices = visibleDotVertices.size() * verticesPerSegment; +// synchronized (visibleDotVertices) { +// for (int i = 0; i < numVertices; i += verticesPerSegment) { +// PVector pos = visibleDotVertices.get(i / verticesPerSegment); +// model.updateVertex(i, pos.x, pos.y); +// model.updateVertex(i + 1, pos.x - 4, pos.y); +// model.updateVertex(i + 2, pos.x - 4, pos.y - 4); +// model.updateVertex(i + 3, pos.x, pos.y - 4); +// } +// } +// model.endUpdateVertices(); +// } +// +// public void timeChanged() { +// mapChanged(null); +// } +// +// public void mapChanged(MapEvent mapEvent) { +// // Check map area only once after user interaction. +// // Additionally, instead of calculating the screen position each frame, store it in new list. +// brLoc = map.getBottomRightBorder(); +// tlLoc = map.getTopLeftBorder(); +// synchronized (visibleDotVertices) { +// visibleDotVertices.clear(); +// for (Dot dot : dots) { +// Location location = new Location(dot.location.getLat() + random(-1, 1), dot.location.getLon() +// + random(-1, 1)); +// if (location.getLat() > brLoc.getLat() && location.getLat() < tlLoc.getLat() +// && location.getLon() > tlLoc.getLon() && location.getLon() < brLoc.getLon()) { +// PVector pos = map.getScreenPosition(location); +// visibleDotVertices.add(pos); +// } +// } +// +// // model = new GLModel(this, visibleDotVertices.size() * 4, GLModel.QUADS, GLModel.STATIC); +// } +// } +// +// public void initAllDots() { +// for (Dot dot : dots) { +// PVector pos = map.getScreenPosition(dot.location); +// visibleDotVertices.add(pos); +// } +// } +// +// private List createRandomDots(int dotNumbers) { +// List dots = new ArrayList(); +// for (int i = 0; i < dotNumbers; i++) { +// Dot dot = new Dot(new Location(random(-85, 85), random(-180, 180)), new Date()); +// dots.add(dot); +// } +// return dots; +// } +//} diff --git a/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp7GLModel2.java b/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp7GLModel2.java index cbf5e987..88e71d60 100644 --- a/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp7GLModel2.java +++ b/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp7GLModel2.java @@ -1,153 +1,153 @@ -package de.fhpotsdam.unfolding.performance; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import processing.core.PApplet; -import processing.core.PVector; -import codeanticode.glgraphics.GLConstants; -import codeanticode.glgraphics.GLGraphics; -import codeanticode.glgraphics.GLModel; -import de.fhpotsdam.unfolding.UnfoldingMap; -import de.fhpotsdam.unfolding.events.MapEvent; -import de.fhpotsdam.unfolding.geo.Location; -import de.fhpotsdam.unfolding.utils.MapUtils; - -/** - * Displays a million markers on the map. - * - * (c) 2012 Till Nagel, unfoldingmaps.org - * - * Used for various performance tests. - *
      - *
    • pure drawing (fps for 10k, 100k, 1000k.)
    • - *
    • pure drawing markers (ditto)
    • - *
    • filter cut-off on map border
    • - *
    • filtering only on map change
    • - *
    • calculating ScreenPosition only on map change
    • - *
    • Different visual representations (e.g. rect vs ellipse
    • - *
    • Use GLModel (see ltavis)
    • - *
    • ...
    • - *
    - * - * Outcomes - rect is faster than ellipse (20k. rect: 24fps, ellipse: 7fps) - * - */ -public class MillionDotsMapApp7GLModel2 extends PApplet { - - int dotNumber = 500000; - - UnfoldingMap map; - // Original dots (loc + time) - List dots = new ArrayList(); - - // Visible points - List visibleDotVertices = new ArrayList(); - // GLGraphics model containing vertices - GLModel model; - // Indicates whether model was updated and should be drawn next frame (to circumvent error on updating outside - // draw()) - boolean updateModelOnNextDraw = false; - - Location tlLoc; - Location brLoc; - - public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); - smooth(); - - dots = createRandomDots(dotNumber); - - map = new UnfoldingMap(this); - map.zoomToLevel(3); - MapUtils.createDefaultEventDispatcher(this, map); - - model = new GLModel(this, dotNumber * 4, GLModel.QUADS, GLModel.STATIC); - mapChanged(null); - } - - public void draw() { - background(0); - map.draw(); - - synchronized (visibleDotVertices) { - if (updateModelOnNextDraw) { - updateModelVertices(); - updateModelOnNextDraw = false; - } - drawModel(); - } - - - fill(255); - rect(5, 5, 180, 20); - fill(0); - text("fps: " + nfs(frameRate, 0, 2) + " (" + visibleDotVertices.size() + " dots)", 10, 20); - } - - public void drawModel() { - GLGraphics renderer = (GLGraphics) g; - renderer.beginGL(); - - model.setTint(0, 100); - - // renderer.model(model); - // Using render(int, int, GLEffect) method, due to bug (see - // https://forum.processing.org/topic/getting-extra-vertices-when-building-a-mesh-with-glmodel#25080000001046326) - int verticesPerSegment = 4; - int numVertices = visibleDotVertices.size() * verticesPerSegment; - model.render(0, numVertices, null); - renderer.endGL(); - } - - public void updateModelVertices() { - int verticesPerSegment = 4; - int numVertices = visibleDotVertices.size() * verticesPerSegment; - - if (model.getSize() != numVertices) { - // If number of visible dots has changed, create new model with new number of vertices. - model = new GLModel(this, visibleDotVertices.size() * 4, GLModel.QUADS, GLModel.STATIC); - } - - model.beginUpdateVertices(); - synchronized (visibleDotVertices) { - for (int i = 0; i < numVertices; i += verticesPerSegment) { - PVector pos = visibleDotVertices.get(i / verticesPerSegment); - model.updateVertex(i, pos.x + 4, pos.y + 4); - model.updateVertex(i + 1, pos.x - 4, pos.y + 4); - model.updateVertex(i + 2, pos.x - 4, pos.y - 4); - model.updateVertex(i + 3, pos.x + 4, pos.y - 4); - } - } - model.endUpdateVertices(); - } - - public void mapChanged(MapEvent mapEvent) { - // Check map area only once after user interaction. - // Additionally, instead of calculating the screen position each frame, store it in new list. - brLoc = map.getBottomRightBorder(); - tlLoc = map.getTopLeftBorder(); - synchronized (visibleDotVertices) { - visibleDotVertices.clear(); - for (Dot dot : dots) { - if (dot.location.getLat() > brLoc.getLat() && dot.location.getLat() < tlLoc.getLat() - && dot.location.getLon() > tlLoc.getLon() && dot.location.getLon() < brLoc.getLon()) { - PVector pos = map.getScreenPosition(dot.location); - visibleDotVertices.add(pos); - } - } - } - - updateModelOnNextDraw = true; - } - - private List createRandomDots(int dotNumbers) { - List dots = new ArrayList(); - for (int i = 0; i < dotNumbers; i++) { - Dot dot = new Dot(new Location(random(-85, 85), random(-180, 180)), new Date()); - dots.add(dot); - } - return dots; - } -} +//package de.fhpotsdam.unfolding.performance; +// +//import java.util.ArrayList; +//import java.util.Date; +//import java.util.List; +// +//import processing.core.PApplet; +//import processing.core.PVector; +// +// +// +//import de.fhpotsdam.unfolding.UnfoldingMap; +//import de.fhpotsdam.unfolding.events.MapEvent; +//import de.fhpotsdam.unfolding.geo.Location; +//import de.fhpotsdam.unfolding.utils.MapUtils; +// +///** +// * Displays a million markers on the map. +// * +// * (c) 2012 Till Nagel, unfoldingmaps.org +// * +// * Used for various performance tests. +// *
      +// *
    • pure drawing (fps for 10k, 100k, 1000k.)
    • +// *
    • pure drawing markers (ditto)
    • +// *
    • filter cut-off on map border
    • +// *
    • filtering only on map change
    • +// *
    • calculating ScreenPosition only on map change
    • +// *
    • Different visual representations (e.g. rect vs ellipse
    • +// *
    • Use GLModel (see ltavis)
    • +// *
    • ...
    • +// *
    +// * +// * Outcomes - rect is faster than ellipse (20k. rect: 24fps, ellipse: 7fps) +// * +// */ +//public class MillionDotsMapApp7GLModel2 extends PApplet { +// +// int dotNumber = 500000; +// +// UnfoldingMap map; +// // Original dots (loc + time) +// List dots = new ArrayList(); +// +// // Visible points +// List visibleDotVertices = new ArrayList(); +// // GLGraphics model containing vertices +// GLModel model; +// // Indicates whether model was updated and should be drawn next frame (to circumvent error on updating outside +// // draw()) +// boolean updateModelOnNextDraw = false; +// +// Location tlLoc; +// Location brLoc; +// +// public void setup() { +// size(800, 600, OPENGL); +// smooth(); +// +// dots = createRandomDots(dotNumber); +// +// map = new UnfoldingMap(this); +// map.zoomToLevel(3); +// MapUtils.createDefaultEventDispatcher(this, map); +// +// model = new GLModel(this, dotNumber * 4, GLModel.QUADS, GLModel.STATIC); +// mapChanged(null); +// } +// +// public void draw() { +// background(0); +// map.draw(); +// +// synchronized (visibleDotVertices) { +// if (updateModelOnNextDraw) { +// updateModelVertices(); +// updateModelOnNextDraw = false; +// } +// drawModel(); +// } +// +// +// fill(255); +// rect(5, 5, 180, 20); +// fill(0); +// text("fps: " + nfs(frameRate, 0, 2) + " (" + visibleDotVertices.size() + " dots)", 10, 20); +// } +// +// public void drawModel() { +// GLGraphics renderer = (GLGraphics) g; +// renderer.beginGL(); +// +// model.setTint(0, 100); +// +// // renderer.model(model); +// // Using render(int, int, GLEffect) method, due to bug (see +// // https://forum.processing.org/topic/getting-extra-vertices-when-building-a-mesh-with-glmodel#25080000001046326) +// int verticesPerSegment = 4; +// int numVertices = visibleDotVertices.size() * verticesPerSegment; +// model.render(0, numVertices, null); +// renderer.endGL(); +// } +// +// public void updateModelVertices() { +// int verticesPerSegment = 4; +// int numVertices = visibleDotVertices.size() * verticesPerSegment; +// +// if (model.getSize() != numVertices) { +// // If number of visible dots has changed, create new model with new number of vertices. +// model = new GLModel(this, visibleDotVertices.size() * 4, GLModel.QUADS, GLModel.STATIC); +// } +// +// model.beginUpdateVertices(); +// synchronized (visibleDotVertices) { +// for (int i = 0; i < numVertices; i += verticesPerSegment) { +// PVector pos = visibleDotVertices.get(i / verticesPerSegment); +// model.updateVertex(i, pos.x + 4, pos.y + 4); +// model.updateVertex(i + 1, pos.x - 4, pos.y + 4); +// model.updateVertex(i + 2, pos.x - 4, pos.y - 4); +// model.updateVertex(i + 3, pos.x + 4, pos.y - 4); +// } +// } +// model.endUpdateVertices(); +// } +// +// public void mapChanged(MapEvent mapEvent) { +// // Check map area only once after user interaction. +// // Additionally, instead of calculating the screen position each frame, store it in new list. +// brLoc = map.getBottomRightBorder(); +// tlLoc = map.getTopLeftBorder(); +// synchronized (visibleDotVertices) { +// visibleDotVertices.clear(); +// for (Dot dot : dots) { +// if (dot.location.getLat() > brLoc.getLat() && dot.location.getLat() < tlLoc.getLat() +// && dot.location.getLon() > tlLoc.getLon() && dot.location.getLon() < brLoc.getLon()) { +// PVector pos = map.getScreenPosition(dot.location); +// visibleDotVertices.add(pos); +// } +// } +// } +// +// updateModelOnNextDraw = true; +// } +// +// private List createRandomDots(int dotNumbers) { +// List dots = new ArrayList(); +// for (int i = 0; i < dotNumbers; i++) { +// Dot dot = new Dot(new Location(random(-85, 85), random(-180, 180)), new Date()); +// dots.add(dot); +// } +// return dots; +// } +//} diff --git a/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp8PShape.java b/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp8PShape.java new file mode 100644 index 00000000..6e0ee3c0 --- /dev/null +++ b/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp8PShape.java @@ -0,0 +1,94 @@ +package de.fhpotsdam.unfolding.performance; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import processing.core.PApplet; +import processing.core.PShape; +import processing.core.PVector; +import de.fhpotsdam.unfolding.UnfoldingMap; +import de.fhpotsdam.unfolding.events.MapEvent; +import de.fhpotsdam.unfolding.geo.Location; +import de.fhpotsdam.unfolding.utils.MapUtils; + +public class MillionDotsMapApp8PShape extends PApplet { + + int dotNumber = 1000; + + UnfoldingMap map; + // Original dots (loc + time) + List dots = new ArrayList(); + + List shapes = new ArrayList(); + + public void setup() { + size(800, 600, P2D); + // smooth(); + + dots = createRandomDots(dotNumber); + + map = new UnfoldingMap(this); + map.zoomToLevel(3); + MapUtils.createDefaultEventDispatcher(this, map); + + shapes = createShapes(); + + } + + public List createShapes() { + List shapes = new ArrayList(); + for (int i = 0; i < 100; i++) { + PShape shape = createShape(); + shape.beginShape(QUAD); + shape.noStroke(); + shape.fill(255, 0, 0, 100); + PVector pos = new PVector(); + shape.vertex(pos.x, pos.y); + shape.vertex(pos.x + 4, pos.y); + shape.vertex(pos.x + 4, pos.y + 4); + shape.vertex(pos.x, pos.y + 4); + shape.endShape(); + shapes.add(shape); + } + return shapes; + } + + public void draw() { + background(0); + map.draw(); + + for (PShape shape : shapes) { + shape(shape); + } + + fill(255); + rect(5, 5, 180, 20); + fill(0); + text("fps: " + nfs(frameRate, 0, 2) + " (n" + " dots)", 10, 20); + } + + public void mapChanged(MapEvent mapEvent) { + // Check map area only once after user interaction. + + int i = 0; + for (PShape shape : shapes) { + PVector pos = map.getScreenPosition(dots.get(i).location); + shape.setVertex(0, pos.x, pos.y); + shape.setVertex(1, pos.x - 4, pos.y); + shape.setVertex(2, pos.x - 4, pos.y - 4); + shape.setVertex(3, pos.x, pos.y - 4); + //shape.translate(random(-1, 1), random(-1,1)); + i++; + } + } + + private List createRandomDots(int dotNumbers) { + List dots = new ArrayList(); + for (int i = 0; i < dotNumbers; i++) { + Dot dot = new Dot(new Location(random(-85, 85), random(-180, 180)), new Date()); + dots.add(dot); + } + return dots; + } +} diff --git a/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp9PShapeGroup.java b/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp9PShapeGroup.java new file mode 100644 index 00000000..5e8964d3 --- /dev/null +++ b/test/de/fhpotsdam/unfolding/performance/MillionDotsMapApp9PShapeGroup.java @@ -0,0 +1,90 @@ +package de.fhpotsdam.unfolding.performance; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import processing.core.PApplet; +import processing.core.PShape; +import processing.core.PVector; +import de.fhpotsdam.unfolding.UnfoldingMap; +import de.fhpotsdam.unfolding.events.MapEvent; +import de.fhpotsdam.unfolding.geo.Location; +import de.fhpotsdam.unfolding.utils.MapUtils; + +public class MillionDotsMapApp9PShapeGroup extends PApplet { + + int dotNumber = 2000; + + UnfoldingMap map; + // Original dots (loc + time) + List dots = new ArrayList(); + + PShape shapeGroup; + + public void setup() { + size(800, 600, P2D); + // smooth(); + + dots = createRandomDots(dotNumber); + + map = new UnfoldingMap(this); + map.zoomToLevel(3); + MapUtils.createDefaultEventDispatcher(this, map); + + shapeGroup = createShapeGroup(); + mapChanged(null); + } + + public PShape createShapeGroup() { + shapeGroup = createShape(PShape.GROUP); + for (int i = 0; i < dotNumber; i++) { + PShape shape = createShape(); + shape.beginShape(QUAD); + shape.noStroke(); + shape.fill(255, 0, 0, 100); + PVector pos = new PVector(); + shape.vertex(pos.x, pos.y); + shape.vertex(pos.x + 4, pos.y); + shape.vertex(pos.x + 4, pos.y + 4); + shape.vertex(pos.x, pos.y + 4); + shape.endShape(); + shapeGroup.addChild(shape); + } + return shapeGroup; + } + + public void draw() { + background(0); + map.draw(); + + shape(shapeGroup); + + fill(255); + rect(5, 5, 180, 20); + fill(0); + text("fps: " + nfs(frameRate, 0, 2) + " (" + dotNumber + " dots)", 10, 20); + } + + public void mapChanged(MapEvent mapEvent) { + // Check map area only once after user interaction. + + for (int i = 0; i < shapeGroup.getChildCount(); i++) { + PShape shape = shapeGroup.getChild(i); + PVector pos = map.getScreenPosition(dots.get(i).location); + shape.setVertex(0, pos.x, pos.y); + shape.setVertex(1, pos.x - 4, pos.y); + shape.setVertex(2, pos.x - 4, pos.y - 4); + shape.setVertex(3, pos.x, pos.y - 4); + } + } + + private List createRandomDots(int dotNumbers) { + List dots = new ArrayList(); + for (int i = 0; i < dotNumbers; i++) { + Dot dot = new Dot(new Location(random(-85, 85), random(-180, 180)), new Date()); + dots.add(dot); + } + return dots; + } +} diff --git a/test/de/fhpotsdam/unfolding/performance/unfolding-dots-performance-results.txt b/test/de/fhpotsdam/unfolding/performance/unfolding-dots-performance-results.txt index ac481663..d21ca4b1 100644 --- a/test/de/fhpotsdam/unfolding/performance/unfolding-dots-performance-results.txt +++ b/test/de/fhpotsdam/unfolding/performance/unfolding-dots-performance-results.txt @@ -20,6 +20,8 @@ ALGORITHMS 5) Filter and getPos on timer. getPos on interaction. 6) GLModel. Filter on interaction, getPos each frame. 7) GLModel. Filter and getPos on interaction. +8) PShape. Using P2's shape mechanism. +9) PShapeGroup. Using single group with many shapes. DRAWING @@ -50,7 +52,8 @@ algorithm with numberOfDots in fps 7) 60 60 60 60 60 i 60 50 40 25 25 im 45 - +9) 60 60 60 60 + i ANALYSIS - Not much difference between 1) and 2), but large difference between 2) and 3). diff --git a/test/de/fhpotsdam/unfolding/rendering/RenderMarkerTestApp.java b/test/de/fhpotsdam/unfolding/rendering/RenderMarkerTestApp.java index 25123f78..fd4c741d 100644 --- a/test/de/fhpotsdam/unfolding/rendering/RenderMarkerTestApp.java +++ b/test/de/fhpotsdam/unfolding/rendering/RenderMarkerTestApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.rendering; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.marker.SimplePointMarker; @@ -16,7 +16,7 @@ public class RenderMarkerTestApp extends PApplet { SimplePointMarker berlinMarker; public void setup() { - size(800, 600, GLConstants.GLGRAPHICS); + size(800, 600, OPENGL); //size(800, 600); smooth(); diff --git a/test/de/fhpotsdam/unfolding/tweening/TweeningTestApp.java b/test/de/fhpotsdam/unfolding/tweening/TweeningTestApp.java index 5d3a0f34..66c7dabb 100644 --- a/test/de/fhpotsdam/unfolding/tweening/TweeningTestApp.java +++ b/test/de/fhpotsdam/unfolding/tweening/TweeningTestApp.java @@ -1,7 +1,7 @@ package de.fhpotsdam.unfolding.tweening; import processing.core.PApplet; -import codeanticode.glgraphics.GLConstants; + import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.geo.Location; import de.fhpotsdam.unfolding.utils.DebugDisplay; @@ -17,7 +17,7 @@ public class TweeningTestApp extends PApplet { DebugDisplay debugDisplay; public void setup() { - size(1024, 768, GLConstants.GLGRAPHICS); + size(1024, 768, OPENGL); map = new UnfoldingMap(this); map.setTweening(true); diff --git a/test/de/fhpotsdam/unfolding/utils/GeneralizationFeatureTestApp.java b/test/de/fhpotsdam/unfolding/utils/GeneralizationFeatureTestApp.java index 5d294937..bb21155f 100644 --- a/test/de/fhpotsdam/unfolding/utils/GeneralizationFeatureTestApp.java +++ b/test/de/fhpotsdam/unfolding/utils/GeneralizationFeatureTestApp.java @@ -5,7 +5,6 @@ import processing.core.PApplet; import processing.core.PVector; -import codeanticode.glgraphics.GLGraphics; import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.data.Feature; import de.fhpotsdam.unfolding.data.GeoJSONReader; @@ -25,7 +24,7 @@ public class GeneralizationFeatureTestApp extends PApplet { float tolerance = 1; public void setup() { - size(800, 600, GLGraphics.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this, new StamenMapProvider.Toner()); MapUtils.createDefaultEventDispatcher(this, map); diff --git a/test/de/fhpotsdam/unfolding/utils/GeneralizationPolyMarkerTestApp.java b/test/de/fhpotsdam/unfolding/utils/GeneralizationPolyMarkerTestApp.java index ca9c7ec9..f052c89d 100644 --- a/test/de/fhpotsdam/unfolding/utils/GeneralizationPolyMarkerTestApp.java +++ b/test/de/fhpotsdam/unfolding/utils/GeneralizationPolyMarkerTestApp.java @@ -5,7 +5,6 @@ import processing.core.PApplet; import processing.core.PVector; -import codeanticode.glgraphics.GLGraphics; import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.data.Feature; import de.fhpotsdam.unfolding.data.GeoJSONReader; @@ -26,7 +25,7 @@ public class GeneralizationPolyMarkerTestApp extends PApplet { float tolerance = 1; public void setup() { - size(800, 600, GLGraphics.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this, new StamenMapProvider.Toner()); MapUtils.createDefaultEventDispatcher(this, map); diff --git a/test/de/fhpotsdam/unfolding/utils/GeneralizationTestApp.java b/test/de/fhpotsdam/unfolding/utils/GeneralizationTestApp.java index e1f5486b..8e3e755c 100644 --- a/test/de/fhpotsdam/unfolding/utils/GeneralizationTestApp.java +++ b/test/de/fhpotsdam/unfolding/utils/GeneralizationTestApp.java @@ -5,7 +5,7 @@ import processing.core.PApplet; import processing.core.PVector; -import codeanticode.glgraphics.GLGraphics; + import de.fhpotsdam.unfolding.UnfoldingMap; /** @@ -24,7 +24,7 @@ public class GeneralizationTestApp extends PApplet { float tolerance = 10; public void setup() { - size(800, 600, GLGraphics.GLGRAPHICS); + size(800, 600, OPENGL); // map = new UnfoldingMap(this); diff --git a/test/de/fhpotsdam/unfolding/utils/GeneralizationTestOnMapApp.java b/test/de/fhpotsdam/unfolding/utils/GeneralizationTestOnMapApp.java index 600deaf9..d764af07 100644 --- a/test/de/fhpotsdam/unfolding/utils/GeneralizationTestOnMapApp.java +++ b/test/de/fhpotsdam/unfolding/utils/GeneralizationTestOnMapApp.java @@ -5,7 +5,6 @@ import processing.core.PApplet; import processing.core.PVector; -import codeanticode.glgraphics.GLGraphics; import de.fhpotsdam.unfolding.UnfoldingMap; import de.fhpotsdam.unfolding.events.EventDispatcher; import de.fhpotsdam.unfolding.events.PanMapEvent; @@ -32,7 +31,7 @@ public class GeneralizationTestOnMapApp extends PApplet { float tolerance = 4; public void setup() { - size(800, 600, GLGraphics.GLGRAPHICS); + size(800, 600, OPENGL); map = new UnfoldingMap(this, new StamenMapProvider.Toner()); // MapUtils.createDefaultEventDispatcher(this, map); diff --git a/test/de/fhpotsdam/unfolding/utils/QuadKeyTestApp.java b/test/de/fhpotsdam/unfolding/utils/QuadKeyTestApp.java new file mode 100644 index 00000000..3bb13aae --- /dev/null +++ b/test/de/fhpotsdam/unfolding/utils/QuadKeyTestApp.java @@ -0,0 +1,35 @@ +package de.fhpotsdam.unfolding.utils; + +import processing.core.PApplet; +import de.fhpotsdam.unfolding.UnfoldingMap; +import de.fhpotsdam.unfolding.core.Coordinate; +import de.fhpotsdam.unfolding.geo.Location; + +public class QuadKeyTestApp extends PApplet { + + UnfoldingMap map; + + public void setup() { + size(800, 600); + + map = new UnfoldingMap(this); + Location location = new Location(52.52, 13.38); + + Coordinate coord = map.mapDisplay.getMapProvider().locationCoordinate(location).zoomTo(14); + String quadKey = GeoUtils.getQuadKey(coord); + println("QuadKey: " + quadKey + " for location: " + location); + + String hereAPIUriString = "http://traffic.cit.api.here.com/traffic/6.1/flow.json?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg&quadkey="; + hereAPIUriString += quadKey; + + String[] result = loadStrings(hereAPIUriString); + for (String r : result) { + println(r); + } + } + + public void draw() { + // map.draw(); + } + +} diff --git a/todo.txt b/todo.txt index 81d84714..c022f5b4 100644 --- a/todo.txt +++ b/todo.txt @@ -1,6 +1,65 @@ -- Clean up /test + + +1.0 beta Release (for Processing 2) +-------------------------- + +- Re-enable sketches for P2D + + + +UPDATES to 2.0 + +- REVISIT ProcessingMapDisplay smooth switching (commented) +- REVISIT MapUtils event dispatcher registration +- REVISIT MapDisplayFactory (Instantiation via Class Lookup) + +- CHANGED GLGraphics to OpenGL + +x CHANGED to Processing events (from awt) +x MouseWheel not working yet (https://github.com/processing/processing/issues/1461) + + + +MATRIX / TEXTURE / SHADER + +- How to deform / distort a map in a way the location to screen conversion still works + (e.g. Fisheye, 3D spikes) + + +x Mask +x Implement blur shader + +- Send to Andres Colubri & ask for feedback + +- 3D: 2.5D / Pseudo +- Distortion grids + + +OTHER +- Transparent (real transparency for map tiles) + - see offscreenCutoffPG.bg(0) + + + +EXAMPLES + +- Update examples-processing to P2 + + +MISC + + +- frameRate seems to be not correct? + On FullHD/Fullscreen sketches it still shows 60fps but seems to be lagging. +- File encoding (all UTF-8) + + +0.9.3 Release +-------------------------- + +x Clean up /test x Move test apps from /examples to /test - - Select fewer example per section (1 best practice!) + x Select fewer example per section (1 best practice!) x Add javadocs to examples x Convert more examples from /examples to /examples-processing x Clean up data folder @@ -17,14 +76,14 @@ x Add tweening (from KUL student fork) x Merge develop into master -- Publish distributions as 0.9.3 - - Update ant script: build.xml +x Publish distributions as 0.9.3 + x Update ant script: build.xml - Unfolding App Template - How to handle examples-extern? (/examples-extern, /lib-extern, .classpath) - Test on Linux and Mac - - Processing - - Test w/ 1.5 - - Put zip files to Amazon Cloud + x Processing + x Test w/ 1.5 + x Put zip files to Amazon Cloud UPDATED Processing examples