split vtm-web into library and vtm-web-app

This commit is contained in:
Hannes Janetzek 2014-03-21 21:42:10 +01:00
parent 1bbf77df0c
commit 4e4d4270db
22 changed files with 296 additions and 71 deletions

View File

@ -8,6 +8,7 @@ include ':vtm-gdx'
include ':vtm-desktop'
include ':vtm-android-gdx'
include ':vtm-web'
include ':vtm-web-app'
include ':vtm-ios'
include ':vtm-jeo'
include ':vtm-jeo-desktop'

4
vtm-web-app/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
war/
assets/
gwt-unitCache/
build/

98
vtm-web-app/build.gradle Normal file
View File

@ -0,0 +1,98 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url 'https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/' }
}
dependencies {
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.3'
}
}
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
apply plugin: 'war'
apply plugin: 'jetty'
apply plugin: 'gwt'
apply plugin: 'eclipse'
sourceSets {
//main.java.srcDirs = ['src', 'src/org/oscim/gdx/emu']
main.java.srcDirs = ['src']
}
dependencies {
providedCompile project(':vtm-web')
providedCompile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
providedCompile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
providedCompile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
providedCompile 'ru.finam:slf4j-gwt:1.2.1'
providedCompile 'org.slf4j:slf4j-api:1.7.5'
}
// explicit dependencies for org.gradle.configureondemand=true
evaluationDependsOn(':vtm')
evaluationDependsOn(':vtm-themes')
evaluationDependsOn(':vtm-gdx')
evaluationDependsOn(':vtm-web')
gwt {
gwtVersion='2.6.0'
modules 'org.oscim.web.VtmWebApp'
superDev {
noPrecompile=true
}
compiler {
enableClosureCompiler = false; // activates -XenableClosureCompiler
disableClassMetadata = true; // activates -XdisableClassMetadata
disableCastChecking = true; // activates -XdisableCastChecking
}
src += files(sourceSets.main.java.srcDirs)
src += files(project(':vtm').sourceSets.main.allJava.srcDirs)
src += files(project(':vtm-themes').sourceSets.main.allJava.srcDirs)
src += files(project(':vtm-themes').sourceSets.main.resources.srcDirs)
src += files(project(':vtm-gdx').sourceSets.main.allJava.srcDirs)
src += files(project(':vtm-web').sourceSets.main.allJava.srcDirs)
}
// Run jetty with draft compiled war
task jettyDraftWar(type: JettyRunWar) {
dependsOn draftWar
dependsOn.remove('war')
webApp=draftWar.archivePath
}
task copyThemeAssets(type: Copy) {
from "$rootDir/vtm-themes/resources/assets"
into "assets"
include '**/*'
}
task copyVtmAssets(type: Copy) {
from "$rootDir/vtm/resources/assets"
into "assets"
include '**/*'
}
tasks.withType(JavaCompile) { compileTask ->
compileTask.dependsOn copyThemeAssets
compileTask.dependsOn copyVtmAssets
}
// Configuring Eclipse classpath
eclipse.classpath {
defaultOutputDir = file('war/WEB-INF/classes')
//file {
// whenMerged { classpath ->
// classpath.entries.findAll { entry ->
// entry.path == 'src' }*.excludes = ['main','org/oscim/gdx/emu/']
// }
//}
}

View File

@ -137,11 +137,9 @@
</head>
<body oncontextmenu="return false;">
<script type="text/javascript" src="js/_tessellate.js"></script>
<script type="text/javascript" src="js/tessellate.js"></script>
<script type="text/javascript"
src="org.oscim.gdx.GwtDefinition/org.oscim.gdx.GwtDefinition.nocache.js"></script>
- <script type="text/javascript" src="VtmWebApp/js/_tessellate.js"></script>
<script type="text/javascript" src="VtmWebApp/js/tessellate.js"></script>
<script type="text/javascript" src="VtmWebApp/VtmWebApp.nocache.js"></script>
<div id="credits">
<a href="https://github.com/hjanetzek/vtm">Source</a>

View File

@ -1,27 +1,24 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<module>
<entry-point class="org.oscim.gdx.client.GwtLauncher" />
<inherits name="com.google.gwt.xml.XML" />
<inherits name="ru.finam.slf4jgwt.logging.gwt.Logging"/>
<module rename-to="VtmWebApp">
<entry-point class="org.oscim.web.client.GwtLauncher" />
<inherits name="org.oscim.gdx.VtmWeb" />
<set-property name='gwt.logging.enabled' value='TRUE' />
<set-property name='gwt.logging.consoleHandler' value='ENABLED' />
<set-property name='gwt.logging.firebugHandler' value='DISABLED' />
<set-property name='gwt.logging.popupHandler' value='DISABLED' />
<set-property name="gwt.logging.logLevel" value="FINE"/>
<inherits name="GdxMap" />
<inherits name="com.badlogic.gdx.backends.gdx_backends_gwt" />
<inherits name="com.google.gwt.user.theme.chrome.Chrome" />
<!-- super dev mode -->
<add-linker name="xsiframe"/>
<!-- <add-linker name="xsiframe"/>
<set-configuration-property name='xsiframe.failIfScriptTag' value='FALSE'/>
<set-configuration-property name="devModeRedirectEnabled" value="true"/>
-->
<!-- <super-source path="emu" /> -->
<super-source path="emu" />
<set-configuration-property name="gdx.assetpath" value="./assets" />
<set-configuration-property name="gdx.assetpath" value="assets" />
<!-- for gradle build, commend out for eclipse build/devmode -->
<set-configuration-property name="gdx.assetoutputpath" value="build/gwt/draftOut" />

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.oscim.gdx.client;
package org.oscim.web.client;
import java.util.HashMap;
@ -23,8 +23,11 @@ import org.oscim.backend.GL20;
import org.oscim.backend.GLAdapter;
import org.oscim.core.MapPosition;
import org.oscim.core.MercatorProjection;
import org.oscim.gdx.GdxAssets;
import org.oscim.gdx.GdxMap;
import org.oscim.gdx.client.GwtGdxGraphics;
import org.oscim.layers.tile.bitmap.BitmapTileLayer;
import org.oscim.layers.tile.vector.BuildingLayer;
import org.oscim.layers.tile.vector.VectorTileLayer;
import org.oscim.layers.tile.vector.labeling.LabelLayer;
import org.oscim.renderer.MapRenderer;
@ -56,11 +59,13 @@ class GwtGdxMap extends GdxMap {
// <- circle/stroke test 800ms firefox, 80ms chromium..
// TODO use texture atlas to avoid drawing text-textures
if (GwtApplication.agentInfo().isLinux() && GwtApplication.agentInfo().isFirefox())
GwtCanvasAdapter.NO_STROKE_TEXT = true;
GwtGdxGraphics.NO_STROKE_TEXT = true;
CanvasAdapter.g = GwtCanvasAdapter.INSTANCE;
GwtGdxGraphics.init();
GdxAssets.init("");
CanvasAdapter.textScale = 0.7f;
GLAdapter.g = (GL20) Gdx.graphics.getGL20();
GLAdapter.init((GL20) Gdx.graphics.getGL20());
GLAdapter.GDX_WEBGL_QUIRKS = true;
MapRenderer.setBackgroundColor(0xffffff);
//Gdx.app.setLogLevel(Application.LOG_DEBUG);
@ -173,6 +178,9 @@ class GwtGdxMap extends GdxMap {
if (l != null) {
if (!params.containsKey("nolabel"))
mMap.layers().add(new LabelLayer(mMap, l));
if (!params.containsKey("nobuildings"))
mMap.layers().add(new BuildingLayer(mMap, l));
}
mSearchBox = new SearchBox(mMap);

View File

@ -14,15 +14,12 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.oscim.gdx.client;
package org.oscim.web.client;
// -draftCompile -localWorkers 2
import org.oscim.core.Tile;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
import com.badlogic.gdx.backends.gwt.GwtGraphics;
import com.badlogic.gdx.backends.gwt.preloader.Preloader.PreloaderCallback;
import com.badlogic.gdx.backends.gwt.preloader.Preloader.PreloaderState;
import com.google.gwt.dom.client.Style.Unit;
@ -35,8 +32,8 @@ public class GwtLauncher extends GwtApplication {
@Override
public GwtApplicationConfiguration getConfig() {
GwtApplicationConfiguration cfg =
new GwtApplicationConfiguration(GwtGraphics.getWindowWidthJSNI(),
GwtGraphics.getWindowHeightJSNI());
new GwtApplicationConfiguration(getWindowWidthJSNI(),
getWindowHeightJSNI());
DockLayoutPanel p = new DockLayoutPanel(Unit.EM);
p.setHeight("100%");
@ -64,10 +61,10 @@ public class GwtLauncher extends GwtApplication {
@Override
public ApplicationListener getApplicationListener() {
if (GwtGraphics.getDevicePixelRatioJSNI() > 1)
Tile.SIZE = 400;
else
Tile.SIZE = 360;
// if (GwtGraphics.getDevicePixelRatioJSNI() > 1)
// Tile.SIZE = 400;
// else
// Tile.SIZE = 360;
return new GwtGdxMap();
}
@ -86,4 +83,13 @@ public class GwtLauncher extends GwtApplication {
}
};
}
public static native int getWindowWidthJSNI() /*-{
return $wnd.innerWidth;
}-*/;
public static native int getWindowHeightJSNI() /*-{
return $wnd.innerHeight;
}-*/;
}

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.oscim.gdx.client;
package org.oscim.web.client;
import com.google.gwt.core.client.JavaScriptObject;

View File

@ -14,18 +14,18 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.oscim.gdx.client;
package org.oscim.web.client;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.oscim.core.BoundingBox;
import org.oscim.core.GeometryBuffer;
import org.oscim.core.MapPosition;
import org.oscim.layers.PathLayer;
import org.oscim.map.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.core.client.JavaScriptObject;

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.oscim.gdx.client;
package org.oscim.web.client;
import org.oscim.core.GeometryBuffer;

View File

@ -13,9 +13,10 @@ repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
apply plugin: 'war'
apply plugin: 'jetty'
apply plugin: 'gwt'
//apply plugin: 'war'
//apply plugin: 'jetty'
apply plugin: 'java'
apply plugin: 'gwt-base'
apply plugin: 'eclipse'
sourceSets {
@ -23,12 +24,12 @@ sourceSets {
}
dependencies {
providedCompile project(':vtm-gdx')
providedCompile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
providedCompile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
providedCompile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
providedCompile 'ru.finam:slf4j-gwt:1.2.1'
providedCompile 'org.slf4j:slf4j-api:1.7.5'
compile project(':vtm-gdx')
compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
compile 'ru.finam:slf4j-gwt:1.2.1'
compile 'org.slf4j:slf4j-api:1.7.5'
}
// explicit dependencies for org.gradle.configureondemand=true
@ -38,7 +39,7 @@ evaluationDependsOn(':vtm-gdx')
gwt {
gwtVersion='2.6.0'
modules 'org.oscim.gdx.GwtDefinition'
modules 'org.oscim.gdx.VtmWeb'
superDev {
noPrecompile=true
@ -57,28 +58,28 @@ gwt {
}
// Run jetty with draft compiled war
task jettyDraftWar(type: JettyRunWar) {
dependsOn draftWar
dependsOn.remove('war')
webApp=draftWar.archivePath
}
//task jettyDraftWar(type: JettyRunWar) {
// dependsOn draftWar
// dependsOn.remove('war')
// webApp=draftWar.archivePath
//}
task copyThemeAssets(type: Copy) {
from "$rootDir/vtm-themes/resources/assets"
into "assets"
include '**/*'
}
//task copyThemeAssets(type: Copy) {
// from "$rootDir/vtm-themes/resources/assets"
// into "assets"
// include '**/*'
//}
task copyVtmAssets(type: Copy) {
from "$rootDir/vtm/resources/assets"
into "assets"
include '**/*'
}
//task copyVtmAssets(type: Copy) {
// from "$rootDir/vtm/resources/assets"
// into "assets"
// include '**/*'
//}
tasks.withType(JavaCompile) { compileTask ->
compileTask.dependsOn copyThemeAssets
compileTask.dependsOn copyVtmAssets
}
//tasks.withType(JavaCompile) { compileTask ->
// compileTask.dependsOn copyThemeAssets
// compileTask.dependsOn copyVtmAssets
//}
// Configuring Eclipse classpath
eclipse.classpath {

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd">
<module rename-to='com.badlogic.gdx.backends.gwt'>
<inherits name='com.google.gwt.user.User' />
<!-- Inherit edited chrome theme ("gwt"-prefixed classes only) for a little bit of default styling in the text input dialogs -->
<inherits name='com.badlogic.gdx.backends.gwt.theme.chrome.Chrome'/>
<inherits name="com.google.gwt.http.HTTP"/>
<inherits name="com.badlogic.gdx" />
<inherits name="com.google.gwt.webgl.WebGL" />
<inherits name="com.badlogic.gwtref.GwtReflect"/>
<!-- <script src="soundmanager2-setup.js"/>
<script src="soundmanager2-jsmin.js"/> -->
<!-- <public path="gwt/resources"/> -->
<super-source path="gwt/emu" />
<source path="gwt">
<exclude name="**/emu/**" />
<exclude name="**/theme/**" />
<exclude name="**/PreloaderBundleGenerator.java"/>
<exclude name="**/FileWrapper.java"/>
<exclude name="**/emu/**" />
</source>
<define-configuration-property name="gdx.assetpath" is-multi-valued="false"/>
<define-configuration-property name="gdx.assetfilterclass" is-multi-valued="false"/>
<define-configuration-property name="gdx.assetoutputpath" is-multi-valued="false"/>
<generate-with class="com.badlogic.gdx.backends.gwt.preloader.PreloaderBundleGenerator">
<when-type-assignable class="com.badlogic.gdx.backends.gwt.preloader.PreloaderBundle"/>
</generate-with>
</module>

View File

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<module>
<!-- <entry-point class="org.oscim.gdx.client.GwtLauncher" /> -->
<inherits name="com.google.gwt.xml.XML" />
<inherits name="ru.finam.slf4jgwt.logging.gwt.Logging" />
<!-- <set-property name='gwt.logging.enabled' value='TRUE' />
<set-property name='gwt.logging.consoleHandler' value='ENABLED' />
<set-property name='gwt.logging.firebugHandler' value='DISABLED' />
<set-property name='gwt.logging.popupHandler' value='DISABLED' />
<set-property name="gwt.logging.logLevel" value="FINE"/>
-->
<inherits name="VtmGdx" />
<!-- <inherits name="com.badlogic.gdx.backends.gdx_backends_gwt" /> -->
<inherits name="com.badlogic.gdx.backends.Gdx" />
<inherits name="com.google.gwt.user.theme.chrome.Chrome" />
<!-- <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.scenes.scene2d" />
<extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.math" />
<extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g2d.TextureRegion" />
<extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g2d.BitmapFont" />
<extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g2d.NinePatch" />
<extend-configuration-property name="gdx.reflect.include"
value="com.badlogic.gdx.graphics.g3d.materials.MaterialAttribute" />
<extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.Color" />
<extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.Texture" />
<extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.utils.Array" />
<extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.utils.ObjectMap" />
<extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.utils.OrderedMap" />
<extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.utils.Disposable" />
<extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.VertexAttribute" />
<extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.model" />
-->
<clear-configuration-property name="gdx.reflect.include" />
<extend-configuration-property name="gdx.reflect.include" value="java.util.List" />
<extend-configuration-property name="gdx.reflect.include" value="java.util.ArrayList" />
<extend-configuration-property name="gdx.reflect.include" value="java.util.Map" />
<extend-configuration-property name="gdx.reflect.include" value="java.util.HashMap" />
<extend-configuration-property name="gdx.reflect.include" value="java.lang.String" />
<extend-configuration-property name="gdx.reflect.include" value="java.lang.Boolean" />
<extend-configuration-property name="gdx.reflect.include" value="java.lang.Byte" />
<extend-configuration-property name="gdx.reflect.include" value="java.lang.Short" />
<extend-configuration-property name="gdx.reflect.include" value="java.lang.Character" />
<extend-configuration-property name="gdx.reflect.include" value="java.lang.Integer" />
<extend-configuration-property name="gdx.reflect.include" value="java.lang.Float" />
<extend-configuration-property name="gdx.reflect.include" value="java.lang.Double" />
<extend-configuration-property name="gdx.reflect.include" value="java.lang.CharSequence" />
<extend-configuration-property name="gdx.reflect.include" value="java.lang.Enum" />
<extend-configuration-property name="gdx.reflect.include" value="java.lang.Object" />
<!-- super dev mode -->
<!--
<add-linker name="xsiframe"/>
<set-configuration-property name='xsiframe.failIfScriptTag' value='FALSE'/>
<set-configuration-property name="devModeRedirectEnabled" value="true"/>
-->
<!-- does not work with super dev mode, include directly in page -->
<!--
<script src="_tessellate.js"/>
<script src="tessellate.js"/>
-->
<public path="resources" />
<super-source path="emu" />
<!-- <set-configuration-property name="gdx.assetpath" value="./assets" /> -->
<!-- for gradle build, commend out for eclipse build/devmode -->
<!-- <set-configuration-property name="gdx.assetoutputpath" value="build/gwt/draftOut" /> -->
<!-- <set-property name="user.agent" value="safari"/> -->
</module>

View File

@ -47,7 +47,7 @@ public class GwtCanvas implements org.oscim.backend.canvas.Canvas {
GwtPaint p = (GwtPaint) paint;
if (p.stroke && GwtCanvasAdapter.NO_STROKE_TEXT)
if (p.stroke && GwtGdxGraphics.NO_STROKE_TEXT)
return;
Context2d ctx = bitmap.pixmap.getContext();

View File

@ -26,11 +26,11 @@ import com.google.gwt.canvas.client.Canvas;
import com.google.gwt.canvas.dom.client.Context2d;
import com.google.gwt.canvas.dom.client.TextMetrics;
public class GwtCanvasAdapter extends CanvasAdapter {
public class GwtGdxGraphics extends CanvasAdapter {
public static boolean NO_STROKE_TEXT = false;
public static final GwtCanvasAdapter INSTANCE = new GwtCanvasAdapter();
public static final GwtGdxGraphics INSTANCE = new GwtGdxGraphics();
static final Context2d ctx;
static {
@ -40,7 +40,7 @@ public class GwtCanvasAdapter extends CanvasAdapter {
ctx = canvas.getContext2d();
}
static synchronized float getTextWidth(String text, String font) {
public static synchronized float getTextWidth(String text, String font) {
ctx.setFont(font);
TextMetrics tm = ctx.measureText(text);
return (float) tm.getWidth();
@ -72,4 +72,8 @@ public class GwtCanvasAdapter extends CanvasAdapter {
return new GwtCanvas();
}
public static void init() {
g = INSTANCE;
}
}

View File

@ -107,7 +107,7 @@ public class GwtPaint implements Paint {
@Override
public float measureText(String text) {
return GwtCanvasAdapter.getTextWidth(text, font);
return GwtGdxGraphics.getTextWidth(text, font);
}
// FIXME all estimates. no idea how to properly measure canvas text..