sampleTerrainMostDetailed(TerrainProvider terrainProvider,
+ Cartographic[] positions);
+
+ // TODO: Example
+
/**
- * A callback that will be called with a ModelGraphics instance and should
- * return the URI to use in the KML. Required if a model exists in the entity
- * collection.
+ * Destroys an object. Each of the object's functions, including functions in
+ * its prototype, is replaced with a function that throws a DeveloperError,
+ * except for the object's isDestroyed function, which is set to a function that
+ * returns true. The object's properties are removed with delete.
+ *
+ * This function is used by objects that hold native resources, e.g., WebGL
+ * resources, which need to be
+ *
+ * explicitly released. Client code calls an object's destroy function, which
+ * then releases the native resource and calls destroyObject to put itself in a
+ * destroyed state.
+ *
+ * @param object The object to destroy.
*/
- @JsProperty
- public ModelCallback modelCallback;
+ @JsMethod(namespace = "Cesium", name = "destroyObject")
+ public static native void destroyObject(Object object);
+
+ // TODO: Example
+
/**
- * The time value to use to get properties that are not time varying in KML.
+ * Destroys an object. Each of the object's functions, including functions in
+ * its prototype, is replaced with a function that throws a DeveloperError,
+ * except for the object's isDestroyed function, which is set to a function that
+ * returns true. The object's properties are removed with delete.
+ *
+ * This function is used by objects that hold native resources, e.g., WebGL
+ * resources, which need to be
+ *
+ * explicitly released. Client code calls an object's destroy function, which
+ * then releases the native resource and calls destroyObject to put itself in a
+ * destroyed state.
+ *
+ * @param object The object to destroy.
+ * @param message The message to include in the exception that is thrown if a
+ * destroyed object's function is called.
*/
- @JsProperty
- public JulianDate time;
+ @JsMethod(namespace = "Cesium", name = "destroyObject")
+ public static native void destroyObject(Object object, String message);
+
/**
- * The interval that will be sampled if an entity doesn't have an availability.
+ * Creates a {@link CesiumTerrainProvider} instance for the
+ * Cesium World
+ * Terrain.
+ *
+ * @return {@link CesiumTerrainProvider} instance for the
+ * Cesium World
+ * Terrain.
*/
- @JsProperty
- public TimeInterval defaultAvailability;
+ @JsMethod(namespace = "Cesium", name = "createWorldTerrain")
+ public static native CesiumTerrainProvider createWorldTerrain();
+
/**
- * The number of seconds to sample properties that are varying in KML. Default:
- * 60
+ * Creates a {@link CesiumTerrainProvider} instance for the
+ * Cesium World
+ * Terrain.
+ *
+ * @param options {@link CreateWorldTerrainOptions} object.
+ * @return {@link CesiumTerrainProvider} instance for the
+ * Cesium World
+ * Terrain.
*/
- @JsProperty
- public int sampleDuration;
+ @JsMethod(namespace = "Cesium", name = "createWorldTerrain")
+ public static native CesiumTerrainProvider createWorldTerrain(CreateWorldTerrainOptions options);
+
/**
- * If true KML and external files will be compressed into a kmz file. Default:
- * false
+ * Exports an EntityCollection as a KML document. Only Point, Billboard, Model,
+ * Path, Polygon, Polyline geometries will be exported. Note that there is not a
+ * 1 to 1 mapping of Entity properties to KML Feature properties. For example,
+ * entity properties that are time dynamic but cannot be dynamic in KML are
+ * exported with their values at options.time or the beginning of the
+ * EntityCollection's time interval if not specified. For time-dynamic
+ * properties that are supported in KML, we use the samples if it is a
+ * {@link org.cesiumjs.cs.datasources.properties.SampledProperty} otherwise we
+ * sample the value using the options.sampleDuration. Point, Billboard, Model
+ * and Path geometries with time-dynamic positions will be exported as gx:Track
+ * Features. Not all Materials are representable in KML, so for more advanced
+ * Materials just the primary color is used. Canvas objects are exported as PNG
+ * images.
+ *
+ * @param options object with properties
+ * @return A promise that resolved to an object containing the KML string and a
+ * dictionary of external file blobs, or a kmz file as a blob if
+ * options.kmz is true.
*/
- @JsProperty
- public boolean kmz;
+ @JsMethod(namespace = "Cesium", name = "exportKml")
+ public static native Promise exportKml(ExportKmlOptions options);
- @JsConstructor
- private ExportKmlOptions() {
- }
+ /**
+ * Creates a Material that combines multiple layers of color/gradient bands and maps them to terrain heights.
+ * The shader does a binary search over all the heights to find out which colors are above and below a given height,
+ * and interpolates between them for the final color. This material supports hundreds of entries relatively cheaply.
+ *
+ * @param options {@link ElevationBandMaterialOptions} with the following properties
+ * @return A new Material instance.
+ */
+ @JsMethod(namespace = "Cesium", name = "createElevationBandMaterial")
+ public static native Material createElevationBandMaterial(ElevationBandMaterialOptions options);
- @JsOverlay
- public static ExportKmlOptions create(EntityCollection entities) {
- ExportKmlOptions options = new ExportKmlOptions();
- options.entities = entities;
- return options;
+ @JsFunction
+ public interface Function {
+ Object function(Object... args);
}
- /**
- * Since KML does not support glTF models, this callback is required to specify
- * what URL to use for the model in the KML document. It can also be used to add
- * additional files to the externalFiles object, which is the list of files
- * embedded in the exported KMZ, or otherwise returned with the KML string when
- * exporting.
- */
@JsFunction
- public interface ModelCallback {
- /**
- * Since KML does not support glTF models, this callback is required to specify
- * what URL to use for the model in the KML document. It can also be used to add
- * additional files to the externalFiles object, which is the list of files
- * embedded in the exported KMZ, or otherwise returned with the KML string when
- * exporting.
- *
- * @param model The ModelGraphics instance for an Entity.
- * @param time The time that any properties should use to get the
- * value.
- * @param externalFiles An object that maps a filename to a Blob or a Promise
- * that resolves to a Blob.
- * @return The URL to use for the href in the KML document.
- */
- String Callback(ModelGraphics model, org.cesiumjs.cs.core.JulianDate time, JsObject externalFiles);
+ public interface RequestAnimationFrameCallback {
+ /**
+ * A function that will be called when the next frame should be drawn.
+ *
+ * @param timestamp A timestamp for the frame, in milliseconds.
+ */
+ @SuppressWarnings("unusable-by-js")
+ void Callback(Number timestamp);
+ }
+
+ @JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
+ public static class CreateWorldTerrainOptions {
+ /**
+ * Flag that indicates if the client should request additional lighting
+ * information from the server if available. Default: false
+ */
+ @JsProperty
+ public boolean requestVertexNormals;
+ /**
+ * Flag that indicates if the client should request per tile water masks from
+ * the server if available. Default: false
+ */
+ @JsProperty
+ public boolean requestWaterMask;
+
+ @JsConstructor
+ public CreateWorldTerrainOptions() {
+ }
+
+ /**
+ * Create instance for {@link Cesium#createWorldTerrain()}.
+ *
+ * @param requestVertexNormals Flag that indicates if the client should request
+ * additional lighting information from the server
+ * if available.
+ * @return instance for {@link Cesium#createWorldTerrain()}.
+ */
+ @JsOverlay
+ public static CreateWorldTerrainOptions create(boolean requestVertexNormals) {
+ CreateWorldTerrainOptions options = new CreateWorldTerrainOptions();
+ options.requestVertexNormals = requestVertexNormals;
+ return options;
+ }
+
+ /**
+ * Create instance for {@link Cesium#createWorldTerrain()}.
+ *
+ * @param requestVertexNormals Flag that indicates if the client should request
+ * additional lighting information from the server
+ * if available.
+ * @param requestWaterMask Flag that indicates if the client should request
+ * per tile water masks from the server if
+ * available.
+ * @return instance for {@link Cesium#createWorldTerrain()}.
+ */
+ @JsOverlay
+ public static CreateWorldTerrainOptions create(boolean requestVertexNormals, boolean requestWaterMask) {
+ CreateWorldTerrainOptions options = new CreateWorldTerrainOptions();
+ options.requestVertexNormals = requestVertexNormals;
+ options.requestWaterMask = requestWaterMask;
+ return options;
+ }
}
- }
- /**
- * Options for {@link Cesium#createElevationBandMaterial(ElevationBandMaterialOptions)}.
- */
- @JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
- public static class ElevationBandMaterialOptions {
/**
- * The scene where the visualization is taking place.
+ * Options for {@link Cesium#exportKml(ExportKmlOptions)}
*/
- @JsProperty
- public Scene scene;
+ @JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
+ public static class ExportKmlOptions {
+ /**
+ * The EntityCollection to export as KML.
+ */
+ @JsProperty
+ public EntityCollection entities;
+ /**
+ * The ellipsoid for the output file. Default: {@link Ellipsoid#WGS84()}
+ */
+ @JsProperty
+ public Ellipsoid ellipsoid;
+ /**
+ * A callback that will be called with a ModelGraphics instance and should
+ * return the URI to use in the KML. Required if a model exists in the entity
+ * collection.
+ */
+ @JsProperty
+ public ModelCallback modelCallback;
+ /**
+ * The time value to use to get properties that are not time varying in KML.
+ */
+ @JsProperty
+ public JulianDate time;
+ /**
+ * The interval that will be sampled if an entity doesn't have an availability.
+ */
+ @JsProperty
+ public TimeInterval defaultAvailability;
+ /**
+ * The number of seconds to sample properties that are varying in KML. Default:
+ * 60
+ */
+ @JsProperty
+ public int sampleDuration;
+ /**
+ * If true KML and external files will be compressed into a kmz file. Default:
+ * false
+ */
+ @JsProperty
+ public boolean kmz;
+
+ @JsConstructor
+ private ExportKmlOptions() {
+ }
+
+ @JsOverlay
+ public static ExportKmlOptions create(EntityCollection entities) {
+ ExportKmlOptions options = new ExportKmlOptions();
+ options.entities = entities;
+ return options;
+ }
+
+ /**
+ * Since KML does not support glTF models, this callback is required to specify
+ * what URL to use for the model in the KML document. It can also be used to add
+ * additional files to the externalFiles object, which is the list of files
+ * embedded in the exported KMZ, or otherwise returned with the KML string when
+ * exporting.
+ */
+ @JsFunction
+ public interface ModelCallback {
+ /**
+ * Since KML does not support glTF models, this callback is required to specify
+ * what URL to use for the model in the KML document. It can also be used to add
+ * additional files to the externalFiles object, which is the list of files
+ * embedded in the exported KMZ, or otherwise returned with the KML string when
+ * exporting.
+ *
+ * @param model The ModelGraphics instance for an Entity.
+ * @param time The time that any properties should use to get the
+ * value.
+ * @param externalFiles An object that maps a filename to a Blob or a Promise
+ * that resolves to a Blob.
+ * @return The URL to use for the href in the KML document.
+ */
+ String Callback(ModelGraphics model, org.cesiumjs.cs.core.JulianDate time, JsObject externalFiles);
+ }
+ }
+
/**
- * A list of bands ordered from lowest to highest precedence.
+ * Options for {@link Cesium#createElevationBandMaterial(ElevationBandMaterialOptions)}.
*/
- @JsProperty
- public ElevationBandMaterialBand[] layers;
-
- @JsConstructor
- protected ElevationBandMaterialOptions() {}
-
- @JsOverlay
- public static ElevationBandMaterialOptions create(Scene scene, ElevationBandMaterialBand[] layers) {
- ElevationBandMaterialOptions options = new ElevationBandMaterialOptions();
- options.scene = scene;
- options.layers = layers;
- return options;
+ @JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
+ public static class ElevationBandMaterialOptions {
+ /**
+ * The scene where the visualization is taking place.
+ */
+ @JsProperty
+ public Scene scene;
+ /**
+ * A list of bands ordered from lowest to highest precedence.
+ */
+ @JsProperty
+ public ElevationBandMaterialBand[] layers;
+
+ @JsConstructor
+ protected ElevationBandMaterialOptions() {
+ }
+
+ @JsOverlay
+ public static ElevationBandMaterialOptions create(Scene scene, ElevationBandMaterialBand[] layers) {
+ ElevationBandMaterialOptions options = new ElevationBandMaterialOptions();
+ options.scene = scene;
+ options.layers = layers;
+ return options;
+ }
}
- }
}
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/CesiumEntryPoint.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/CesiumEntryPoint.java
index b1eccaa97ad9eb32fc36b30e3ad97f4b658493a6..ee4ee3573472cda30a7b9e89ce6bc7a8dff01376 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/CesiumEntryPoint.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/CesiumEntryPoint.java
@@ -23,16 +23,16 @@ import com.google.gwt.core.client.GWT;
* @author Serge Silaev aka iSergio
*/
public class CesiumEntryPoint implements EntryPoint {
- @Override
- public void onModuleLoad() {
- Cesium.fixSmartGWT();
- GWT.log("Cesium GTW module loaded");
- if (!Cesium.isInitialized()) {
- String message = "The Core of Cesium (Cesium.js) JavaScript libraryes not loaded.\n"
- + "If you inherit Cesium from NoScript gwt.xml, \nyou need include ');\n" + "}\n";
- }
-
- private String getScriptLoadJS(Set scriptsToLoad, String pageRelativeModulePath) {
- String result = "if (!window." + LOADED_SCRIPTS + ") window." + LOADED_SCRIPTS + " = {};\n";
- for (ScriptReference script : scriptsToLoad) {
- String src = script.getSrc();
- if (!src.startsWith("cs/")) {
- continue;
- }
- result += "if (!" + LOADED_SCRIPTS + "['" + src + "']) {\n " + LOADED_SCRIPTS + "['" + src + "'] = true;\n "
- + "document.write('');\n}\n";
- System.out.println(src);
+ private static final String SCRIPT_LOADER = "loadCesiumScripts.js";
+ private static final String LOADED_SCRIPTS = "__gwt_cesiumScriptsLoaded";
+ private static final String PAGE_RELATIVE_MODULE_PATH = "cesiumScriptInjector.pageRelativeModulePath";
+
+ private static String getPageRelativeModulePath(LinkerContext context) {
+ String moduleName = context.getModuleName();
+
+ List pathBindings = null;
+ for (ConfigurationProperty property : context.getConfigurationProperties()) {
+ if (PAGE_RELATIVE_MODULE_PATH.equals(property.getName())) {
+ pathBindings = property.getValues();
+ }
+ }
+ if (pathBindings == null)
+ return moduleName;
+
+ for (String binding : pathBindings) {
+ String[] parts = binding.split("=");
+ if (parts.length == 2 && moduleName.equals(parts[0])) {
+ System.out
+ .println(" Setting page-relative module path for module '" + moduleName + "' using gwt.xml config");
+ return parts[1];
+ }
+ }
+
+ return moduleName;
}
- return result;
- }
- private static String getPageRelativeModulePath(LinkerContext context) {
- String moduleName = context.getModuleName();
-
- List pathBindings = null;
- for (ConfigurationProperty property : context.getConfigurationProperties()) {
- if (PAGE_RELATIVE_MODULE_PATH.equals(property.getName())) {
- pathBindings = property.getValues();
- }
+ private boolean forceScriptLoad(TreeLogger logger, String moduleName, Float gwtVersion) {
+ try {
+ ModuleDef module;
+ Method getModuleDef;
+
+ if (gwtVersion < 2.6f) {
+ getModuleDef = ModuleDefLoader.class.getDeclaredMethod("loadFromClassPath",
+ TreeLogger.class, String.class);
+ module = (ModuleDef) getModuleDef.invoke(null, logger, moduleName);
+ } else if (gwtVersion < 2.8f) {
+ Class compilerContextClass = Class.forName("com.google.gwt.dev.CompilerContext");
+ Object context = compilerContextClass.getDeclaredConstructor().newInstance();
+
+ getModuleDef = ModuleDefLoader.class.getDeclaredMethod("loadFromClassPath",
+ TreeLogger.class, compilerContextClass, String.class);
+ module = (ModuleDef) getModuleDef.invoke(null, logger, compilerContextClass.cast(context), moduleName);
+ } else {
+ getModuleDef = ModuleDefLoader.class.getDeclaredMethod("loadFromClassPath",
+ TreeLogger.class, String.class, boolean.class);
+ module = (ModuleDef) getModuleDef.invoke(null, logger, moduleName, false);
+ }
+
+ if (module != null)
+ return CrossSiteIframeLinker.class.equals(module.getActivePrimaryLinker());
+ logger.log(TreeLogger.WARN, "Can't find module reference - not injecting scripts.");
+
+ } catch (Throwable t) {
+ logger.log(TreeLogger.ERROR, "Encountered an exception while trying to resolve the ModuleDef for " + moduleName,
+ t);
+ }
+ return false;
}
- if (pathBindings == null)
- return moduleName;
-
- for (String binding : pathBindings) {
- String[] parts = binding.split("=");
- if (parts.length == 2 && moduleName.equals(parts[0])) {
- System.out
- .println(" Setting page-relative module path for module '" + moduleName + "' using gwt.xml config");
- return parts[1];
- }
+
+ private String getScriptLoaderJS(String pageRelativeModulePath) {
+ return "if (!/loaded|complete/.test(document.readyState)) {\n" + " document.write('');\n" + "}\n";
}
- return moduleName;
- }
+ private String getScriptLoadJS(Set scriptsToLoad, String pageRelativeModulePath) {
+ String result = "if (!window." + LOADED_SCRIPTS + ") window." + LOADED_SCRIPTS + " = {};\n";
+ for (ScriptReference script : scriptsToLoad) {
+ String src = script.getSrc();
+ if (!src.startsWith("cs/")) {
+ continue;
+ }
+ result += "if (!" + LOADED_SCRIPTS + "['" + src + "']) {\n " + LOADED_SCRIPTS + "['" + src + "'] = true;\n "
+ + "document.write('');\n}\n";
+ System.out.println(src);
+ }
+ return result;
+ }
- @Override
- public String getDescription() {
- return "CesiumScriptInjector";
- }
+ @Override
+ public String getDescription() {
+ return "CesiumScriptInjector";
+ }
- protected SyntheticArtifact emitString(TreeLogger logger, String what, String partialPath, LinkerContext context)
- throws UnableToCompleteException {
- if (context.isOutputCompact()) {
- what = what.replaceAll("\n\\s*", "");
+ protected SyntheticArtifact emitString(TreeLogger logger, String what, String partialPath, LinkerContext context)
+ throws UnableToCompleteException {
+ if (context.isOutputCompact()) {
+ what = what.replaceAll("\n\\s*", "");
+ }
+ return super.emitString(logger, what, partialPath);
}
- return super.emitString(logger, what, partialPath);
- }
- @Override
- public ArtifactSet link(TreeLogger logger, LinkerContext context, ArtifactSet artifacts, boolean permutation)
- throws UnableToCompleteException {
- Float gwtVersion = Float.parseFloat(About.getGwtVersionNum().replaceFirst("([0-9]+\\.[0-9]+).*", "$1"));
- String moduleName = context.getModuleName();
+ @Override
+ public ArtifactSet link(TreeLogger logger, LinkerContext context, ArtifactSet artifacts, boolean permutation)
+ throws UnableToCompleteException {
+ Float gwtVersion = Float.parseFloat(About.getGwtVersionNum().replaceFirst("([0-9]+\\.[0-9]+).*", "$1"));
+ String moduleName = context.getModuleName();
- if (permutation) {
- return artifacts;
- }
+ if (permutation) {
+ return artifacts;
+ }
- Artifact scriptLoader = emitString(logger, "", SCRIPT_LOADER);
- ArtifactSet result = new ArtifactSet(artifacts);
- result.add(scriptLoader);
+ Artifact scriptLoader = emitString(logger, "", SCRIPT_LOADER);
+ ArtifactSet result = new ArtifactSet(artifacts);
+ result.add(scriptLoader);
- if (gwtVersion < 2.5f || !forceScriptLoad(logger, moduleName, gwtVersion)) {
- return result;
- }
+ if (gwtVersion < 2.5f || !forceScriptLoad(logger, moduleName, gwtVersion)) {
+ return result;
+ }
- Set scripts = result.find(ScriptReference.class);
- if (scripts.size() == 0) {
- return result;
- }
+ Set scripts = result.find(ScriptReference.class);
+ if (scripts.size() == 0) {
+ return result;
+ }
- Set emittedArtifacts = artifacts.find(EmittedArtifact.class);
- for (EmittedArtifact emittedArtifact : emittedArtifacts) {
- String partialPath = emittedArtifact.getPartialPath();
- if (!partialPath.endsWith(moduleName + ".nocache.js"))
- continue;
+ Set emittedArtifacts = artifacts.find(EmittedArtifact.class);
+ for (EmittedArtifact emittedArtifact : emittedArtifacts) {
+ String partialPath = emittedArtifact.getPartialPath();
+ if (!partialPath.endsWith(moduleName + ".nocache.js"))
+ continue;
- System.out.println(" Invoking Linker CesiumScriptInjector");
+ System.out.println(" Invoking Linker CesiumScriptInjector");
- String pageRelativeModulePath = getPageRelativeModulePath(context);
+ String pageRelativeModulePath = getPageRelativeModulePath(context);
- System.out.println(" Creating " + SCRIPT_LOADER + " to manually load the following script tags:");
+ System.out.println(" Creating " + SCRIPT_LOADER + " to manually load the following script tags:");
- result.remove(emittedArtifact);
- String nocacheJS = CesiumLinkerUtils.getContents(emittedArtifact, logger);
- nocacheJS += getScriptLoaderJS(pageRelativeModulePath);
- result.add(emitString(logger, nocacheJS, partialPath, context));
+ result.remove(emittedArtifact);
+ String nocacheJS = CesiumLinkerUtils.getContents(emittedArtifact, logger);
+ nocacheJS += getScriptLoaderJS(pageRelativeModulePath);
+ result.add(emitString(logger, nocacheJS, partialPath, context));
- result.remove(scriptLoader);
- String loadTags = getScriptLoadJS(scripts, pageRelativeModulePath);
- result.add(emitString(logger, loadTags, SCRIPT_LOADER, context));
+ result.remove(scriptLoader);
+ String loadTags = getScriptLoadJS(scripts, pageRelativeModulePath);
+ result.add(emitString(logger, loadTags, SCRIPT_LOADER, context));
- break;
- }
+ break;
+ }
- return result;
- }
+ return result;
+ }
}
diff --git a/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/Cesium.gwt.xml b/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/Cesium.gwt.xml
index 19151f7c513103c948332099bdf66c2914d98844..4c6bff72b27fbec66b428a7a8afec8fdc6403404 100644
--- a/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/Cesium.gwt.xml
+++ b/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/Cesium.gwt.xml
@@ -20,6 +20,6 @@
-
-
+
+
\ No newline at end of file
diff --git a/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/CesiumClientBundle.gwt.xml b/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/CesiumClientBundle.gwt.xml
index 8c6d4dc79c516e670839ee91024a3dc1775f044d..790919ae71737e24b24aa53f06de473deb56810a 100644
--- a/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/CesiumClientBundle.gwt.xml
+++ b/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/CesiumClientBundle.gwt.xml
@@ -16,11 +16,11 @@
-
-
-
+
+
+
-
+
diff --git a/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/CesiumNoScript.gwt.xml b/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/CesiumNoScript.gwt.xml
index 2c8cb3f6fbcec3f250d59d60bda8a317ff2b9f64..97513e81d141ff6dd28d94a39b24a1230b778779 100644
--- a/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/CesiumNoScript.gwt.xml
+++ b/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/CesiumNoScript.gwt.xml
@@ -20,16 +20,16 @@
-
-
+
+
-
+
-
-
+
+
diff --git a/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/CesiumScript.gwt.xml b/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/CesiumScript.gwt.xml
index d31ef129490b65ade5d16455afc737fad8a0ef9a..33ba9a795aa7ed497449d88e93e0cd10b0a95eec 100644
--- a/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/CesiumScript.gwt.xml
+++ b/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/CesiumScript.gwt.xml
@@ -19,9 +19,9 @@
-
-
-
+
+
+
diff --git a/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/CesiumUnminified.gwt.xml b/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/CesiumUnminified.gwt.xml
index 05fb0fc361e5e8cccb3de52b165e1ddf0e08d9bb..3c27c4ffc029d8cfe49706f9b59cde9876f5433d 100644
--- a/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/CesiumUnminified.gwt.xml
+++ b/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/CesiumUnminified.gwt.xml
@@ -21,6 +21,6 @@
-
-
+
+
\ No newline at end of file
diff --git a/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/CesiumUnminifiedScript.gwt.xml b/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/CesiumUnminifiedScript.gwt.xml
index 756e8fc92d876bdb57313bbbc4065c8508a674d5..8dc052b51f750d9edfef1160c10826569e0ba248 100644
--- a/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/CesiumUnminifiedScript.gwt.xml
+++ b/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/CesiumUnminifiedScript.gwt.xml
@@ -19,9 +19,9 @@
-
-
-
+
+
+
diff --git a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/BaseTestCase.java b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/BaseTestCase.java
index c3b6b50201fa44b827e0d8c571914756c119df3a..5545266cb5efc3a0b6229a8c0da2cc318b5e4a3f 100644
--- a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/BaseTestCase.java
+++ b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/BaseTestCase.java
@@ -22,44 +22,45 @@ import com.google.gwt.junit.client.GWTTestCase;
/**
* Base abstract test.
+ *
* @author Serge Silaev aka iSergio
*/
public abstract class BaseTestCase extends GWTTestCase {
- private static boolean loaded = false;
+ private static boolean loaded = false;
- @Override
- public String getModuleName() {
- return "org.cesiumjs.CesiumTest";
- }
+ @Override
+ public String getModuleName() {
+ return "org.cesiumjs.CesiumTest";
+ }
- protected void beginTest(final Test test) {
- if (loaded) {
- test.execute();
- } else {
- ScriptInjector.fromString(
- "Number.parseFloat = Number.parseFloat || function(v) {return window.parseFloat(v);};"
- + "Number.parseInt = Number.parseInt || function(v) {return window.parseInt(v);};")
- .setWindow(ScriptInjector.TOP_WINDOW).inject();
- ScriptInjector.fromUrl("cs/CesiumUnminified/Cesium.js").setWindow(ScriptInjector.TOP_WINDOW)
- .setCallback(new Callback() {
+ protected void beginTest(final Test test) {
+ if (loaded) {
+ test.execute();
+ } else {
+ ScriptInjector.fromString(
+ "Number.parseFloat = Number.parseFloat || function(v) {return window.parseFloat(v);};"
+ + "Number.parseInt = Number.parseInt || function(v) {return window.parseInt(v);};")
+ .setWindow(ScriptInjector.TOP_WINDOW).inject();
+ ScriptInjector.fromUrl("cs/CesiumUnminified/Cesium.js").setWindow(ScriptInjector.TOP_WINDOW)
+ .setCallback(new Callback() {
- @Override
- public void onFailure(Exception reason) {
- assertNotNull(reason);
- fail("Injection failed: " + reason.toString());
- }
+ @Override
+ public void onFailure(Exception reason) {
+ assertNotNull(reason);
+ fail("Injection failed: " + reason.toString());
+ }
- @Override
- public void onSuccess(Void result) {
- loaded = true;
- test.execute();
- }
+ @Override
+ public void onSuccess(Void result) {
+ loaded = true;
+ test.execute();
+ }
- }).inject();
+ }).inject();
+ }
}
- }
- public interface Test {
- void execute();
- }
+ public interface Test {
+ void execute();
+ }
}
diff --git a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/CesiumTest.java b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/CesiumTest.java
index abba590ffceb3afac201c4d1b4097e0410780799..97949807df96cd368b63291bb125d2321bcfff9e 100644
--- a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/CesiumTest.java
+++ b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/CesiumTest.java
@@ -17,52 +17,42 @@
package org.cesiumjs.cs;
import org.cesiumjs.cs.core.providers.CesiumTerrainProvider;
-import org.cesiumjs.cs.promise.Fulfill;
/**
* @author Serge Silaev aka iSergio
*/
public class CesiumTest extends BaseTestCase {
- public void testCreateWorldTerrain() {
- delayTestFinish(10_000);
+ public void testCreateWorldTerrain() {
+ delayTestFinish(10_000);
- super.beginTest(new Test() {
- @Override
- public void execute() {
- CesiumTerrainProvider terrainProvider = Cesium.createWorldTerrain();
- assertNotNull(terrainProvider);
- assertEquals(false, terrainProvider.requestVertexNormals);
- assertEquals(false, terrainProvider.requestWaterMask);
- finishTest();
- }
- });
- }
+ super.beginTest(() -> {
+ CesiumTerrainProvider terrainProvider = Cesium.createWorldTerrain();
+ assertNotNull(terrainProvider);
+ assertEquals(false, terrainProvider.requestVertexNormals);
+ assertEquals(false, terrainProvider.requestWaterMask);
+ finishTest();
+ });
+ }
- public void testCreateWorldTerrain1() {
- delayTestFinish(10_000);
+ public void testCreateWorldTerrain1() {
+ delayTestFinish(10_000);
- super.beginTest(new Test() {
- @Override
- public void execute() {
- final Cesium.CreateWorldTerrainOptions options = new Cesium.CreateWorldTerrainOptions();
- options.requestVertexNormals = true;
- options.requestWaterMask = true;
- final CesiumTerrainProvider terrainProvider = Cesium.createWorldTerrain(options);
- assertNotNull(terrainProvider);
- assertEquals(options.requestVertexNormals, terrainProvider.requestVertexNormals);
- assertEquals(options.requestWaterMask, terrainProvider.requestWaterMask);
- terrainProvider.readyPromise().then(new Fulfill() {
- @Override
- public void onFulfilled(Boolean ready) {
- if (ready) {
- assertEquals(options.requestVertexNormals, terrainProvider.hasVertexNormals);
- assertEquals(options.requestWaterMask, terrainProvider.hasWaterMask);
- finishTest();
- }
- }
+ super.beginTest(() -> {
+ final Cesium.CreateWorldTerrainOptions options = new Cesium.CreateWorldTerrainOptions();
+ options.requestVertexNormals = true;
+ options.requestWaterMask = true;
+ final CesiumTerrainProvider terrainProvider = Cesium.createWorldTerrain(options);
+ assertNotNull(terrainProvider);
+ assertEquals(options.requestVertexNormals, terrainProvider.requestVertexNormals);
+ assertEquals(options.requestWaterMask, terrainProvider.requestWaterMask);
+ terrainProvider.readyPromise().then(ready -> {
+ if (ready) {
+ assertEquals(options.requestVertexNormals, terrainProvider.hasVertexNormals);
+ assertEquals(options.requestWaterMask, terrainProvider.hasWaterMask);
+ finishTest();
+ }
+ });
});
- }
- });
- }
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/CesiumTestSuite.java b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/CesiumTestSuite.java
index ff784487e04b24d14540795b3bce232f2a1735ed..dcff7cc0d90cedacb3e67b0a0df755d0922d0be4 100644
--- a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/CesiumTestSuite.java
+++ b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/CesiumTestSuite.java
@@ -17,49 +17,39 @@
package org.cesiumjs.cs;
import com.google.gwt.junit.tools.GWTTestSuite;
-
-import org.cesiumjs.cs.collections.ClippingPlaneCollectionTest;
-import org.cesiumjs.cs.collections.LabelCollectionTest;
-import org.cesiumjs.cs.core.Cartesian2Test;
-import org.cesiumjs.cs.core.ColorTest;
-import org.cesiumjs.cs.core.IonResourceTest;
-import org.cesiumjs.cs.core.geometry.CoplanarPolygonGeometryTest;
-import org.cesiumjs.cs.core.geometry.GroundPolylineGeometryTest;
-import org.cesiumjs.cs.scene.Cesium3DTilesetTest;
-import org.cesiumjs.cs.scene.LabelTest;
-
import junit.framework.TestSuite;
+import org.cesiumjs.cs.collections.DataSourceCollectionTest;
/**
* @author Serge Silaev aka iSergio
*/
public class CesiumTestSuite extends GWTTestSuite {
- public static TestSuite suite() {
- TestSuite suite = new TestSuite("GWTTestSuite for Cesium Wrapper");
-
- // Cesium
- suite.addTestSuite(CesiumTest.class);
-
- // Core
- suite.addTestSuite(ColorTest.class);
- suite.addTestSuite(Cartesian2Test.class);
- suite.addTestSuite(GroundPolylineGeometryTest.class);
- suite.addTestSuite(LabelCollectionTest.class);
- suite.addTestSuite(IonResourceTest.class);
- suite.addTestSuite(CoplanarPolygonGeometryTest.class);
-
- // Scene
- suite.addTestSuite(LabelTest.class);
- suite.addTestSuite(ClippingPlaneCollectionTest.class);
- // suite.addTestSuite(DataSourceCollectionTest.class);
- suite.addTestSuite(Cesium3DTilesetTest.class);
-
- // Widgets
- // Not understand how test widgets, in this moment strange error
- // com.google.gwt.core.shared.SerializableThrowable: (InternalError) :
- // TypeError: Cannot convert a Symbol value to a string
- // suite.addTestSuite(ViewerPanelTest.class);
-
- return suite;
- }
+ public static TestSuite suite() {
+ TestSuite suite = new TestSuite("GWTTestSuite for Cesium Wrapper");
+
+ // Cesium
+// suite.addTestSuite(CesiumTest.class);
+//
+// // Core
+// suite.addTestSuite(ColorTest.class);
+// suite.addTestSuite(Cartesian2Test.class);
+// suite.addTestSuite(GroundPolylineGeometryTest.class);
+// suite.addTestSuite(LabelCollectionTest.class);
+// suite.addTestSuite(IonResourceTest.class);
+// suite.addTestSuite(CoplanarPolygonGeometryTest.class);
+//
+// // Scene
+// suite.addTestSuite(LabelTest.class);
+// suite.addTestSuite(ClippingPlaneCollectionTest.class);
+ suite.addTestSuite(DataSourceCollectionTest.class);
+// suite.addTestSuite(Cesium3DTilesetTest.class);
+
+ // Widgets
+ // Not understand how test widgets, in this moment strange error
+ // com.google.gwt.core.shared.SerializableThrowable: (InternalError) :
+ // TypeError: Cannot convert a Symbol value to a string
+ // suite.addTestSuite(ViewerPanelTest.class);
+
+ return suite;
+ }
}
diff --git a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/collections/ClippingPlaneCollectionTest.java b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/collections/ClippingPlaneCollectionTest.java
index 1b248c7e3b54d9ff235fce8d5cb62c337c281732..6096ab997088b32c4e09c2f539685286b77ebaa8 100644
--- a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/collections/ClippingPlaneCollectionTest.java
+++ b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/collections/ClippingPlaneCollectionTest.java
@@ -23,16 +23,13 @@ import org.cesiumjs.cs.BaseTestCase;
*/
public class ClippingPlaneCollectionTest extends BaseTestCase {
- public void testIsSupported() {
- delayTestFinish(10_000);
+ public void testIsSupported() {
+ delayTestFinish(10_000);
- super.beginTest(new Test() {
- @Override
- public void execute() {
- // not supported only under IE
- assertTrue(true);
- finishTest();
- }
- });
- }
+ super.beginTest(() -> {
+ // not supported only under IE
+ assertTrue(true);
+ finishTest();
+ });
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/collections/DataSourceCollectionTest.java b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/collections/DataSourceCollectionTest.java
index 6d477cbb7ffaa39eb2a97c4cbf42d2ee1f9ca7d0..c96709b68fc815ea288df3c33f65999ab06f5b78 100644
--- a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/collections/DataSourceCollectionTest.java
+++ b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/collections/DataSourceCollectionTest.java
@@ -17,43 +17,22 @@
package org.cesiumjs.cs.collections;
import com.google.gwt.core.client.GWT;
-
+import junit.framework.TestCase;
import org.cesiumjs.cs.BaseTestCase;
-import org.cesiumjs.cs.Cesium;
-import org.cesiumjs.cs.datasources.DataSource;
import org.cesiumjs.cs.datasources.GeoJsonDataSource;
-import org.cesiumjs.cs.promise.Fulfill;
-import org.cesiumjs.cs.promise.Reject;
/**
* @author Serge Silaev aka iSergio
*/
public class DataSourceCollectionTest extends BaseTestCase {
- private DataSourceCollection collection;
- private DataSource geojsonDS;
- private DataSource topojsonDS;
-
- public void testLower() {
- delayTestFinish(10_000);
- super.beginTest(new Test() {
- @Override
- public void execute() {
- GeoJsonDataSource.load(GWT.getModuleBaseURL() + "SampleData/simplestyles.geojson")
- .then(new Fulfill() {
- @Override
- public void onFulfilled(GeoJsonDataSource dataSource) {
- assertNotNull(dataSource);
- finishTest();
- }
- }, new Reject() {
- @Override
- public void onRejected(String value) {
- Cesium.log("onRejected: " + value);
- finishTest();
- }
- });
- }
- });
- }
+ public void test() {
+ delayTestFinish(10_000);
+ super.beginTest(() -> GeoJsonDataSource.load(GWT.getModuleBaseURL() + "SampleData/ne_10m_us_states.topojson")
+ .then(dataSource -> {
+ assertNotNull(dataSource);
+ finishTest();
+ }, TestCase::fail)
+ );
+ }
}
diff --git a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/collections/LabelCollectionTest.java b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/collections/LabelCollectionTest.java
index 899b4a9eb3986e156036e2ff4fdd6eeacb2f6598..d69ac3f9a2b923b3e31132ed00debcc8f425f0f1 100644
--- a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/collections/LabelCollectionTest.java
+++ b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/collections/LabelCollectionTest.java
@@ -24,84 +24,78 @@ import org.cesiumjs.cs.scene.options.LabelOptions;
* @author Serge Silaev aka iSergio
*/
public class LabelCollectionTest extends BaseTestCase {
- private static final String VALUE = "LABEL";
-
- public void testAdd() {
- delayTestFinish(10_000);
-
- super.beginTest(new Test() {
- @Override
- public void execute() {
- LabelCollection collection = new LabelCollection();
-
- LabelOptions options = new LabelOptions();
- options.text = "ASDDQWEQWEDASDAFQEQWE";
- collection.add(options);
-
- options = new LabelOptions();
- options.text = VALUE;
- Label label = collection.add(options);
-
- options = new LabelOptions();
- options.text = "ASDDQWEQWEDASDAFQEQWE";
- collection.add(options);
-
- assertNotNull(label);
- assertEquals(VALUE, label.text);
- finishTest();
- }
- });
- }
-
- public void testContains() {
- delayTestFinish(10_000);
-
- super.beginTest(new Test() {
- @Override
- public void execute() {
- LabelCollection collection = new LabelCollection();
-
- LabelOptions options = new LabelOptions();
- options.text = "ASDDQWEQWEDASDAFQEQWE";
- collection.add(options);
-
- options = new LabelOptions();
- options.text = VALUE;
- Label label = collection.add(options);
-
- options = new LabelOptions();
- options.text = "ASDDQWEQWEDASDAFQEQWE";
- collection.add(options);
-
- assertTrue(collection.contains(label));
- finishTest();
- }
- });
- }
-
- public void testGet() {
- delayTestFinish(10_000);
-
- super.beginTest(new Test() {
- @Override
- public void execute() {
- LabelCollection collection = new LabelCollection();
-
- LabelOptions options = new LabelOptions();
- options.text = "ASDDQWEQWEDASDAFQEQWE";
- collection.add(options);
-
- options = new LabelOptions();
- options.text = VALUE;
- Label label = collection.add(options);
-
- options = new LabelOptions();
- options.text = "ASDDQWEQWEDASDAFQEQWE";
- collection.add(options);
-
- assertEquals(label, collection.get(1));
- finishTest();
- }
- });
- }
+ private static final String VALUE = "LABEL";
+
+ public void testAdd() {
+ delayTestFinish(10_000);
+
+ super.beginTest(() -> {
+ LabelCollection collection = new LabelCollection();
+
+ LabelOptions options = new LabelOptions();
+ options.text = "ASDDQWEQWEDASDAFQEQWE";
+ collection.add(options);
+
+ options = new LabelOptions();
+ options.text = VALUE;
+ Label label = collection.add(options);
+
+ options = new LabelOptions();
+ options.text = "ASDDQWEQWEDASDAFQEQWE";
+ collection.add(options);
+
+ assertNotNull(label);
+ assertEquals(VALUE, label.text);
+ finishTest();
+ });
+ }
+
+ public void testContains() {
+ delayTestFinish(10_000);
+
+ super.beginTest(() -> {
+ LabelCollection collection = new LabelCollection();
+
+ LabelOptions options = new LabelOptions();
+ options.text = "ASDDQWEQWEDASDAFQEQWE";
+ collection.add(options);
+
+ options = new LabelOptions();
+ options.text = VALUE;
+ Label label = collection.add(options);
+
+ options = new LabelOptions();
+ options.text = "ASDDQWEQWEDASDAFQEQWE";
+ collection.add(options);
+
+ assertTrue(collection.contains(label));
+ finishTest();
+ });
+ }
+
+ public void testGet() {
+ delayTestFinish(10_000);
+
+ super.beginTest(new Test() {
+ @Override
+ public void execute() {
+ LabelCollection collection = new LabelCollection();
+
+ LabelOptions options = new LabelOptions();
+ options.text = "ASDDQWEQWEDASDAFQEQWE";
+ collection.add(options);
+
+ options = new LabelOptions();
+ options.text = VALUE;
+ Label label = collection.add(options);
+
+ options = new LabelOptions();
+ options.text = "ASDDQWEQWEDASDAFQEQWE";
+ collection.add(options);
+
+ assertEquals(label, collection.get(1));
+ finishTest();
+ }
+ });
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/Cartesian2Test.java b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/Cartesian2Test.java
index caf003b47fb3f80a1ee7c46da7e0975888cdebec..cb8f3b7999f70c296279c84138544b6b195c5dd4 100644
--- a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/Cartesian2Test.java
+++ b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/Cartesian2Test.java
@@ -16,29 +16,26 @@
package org.cesiumjs.cs.core;
+import org.cesiumjs.cs.BaseTestCase;
+
import java.util.logging.LogManager;
import java.util.logging.Logger;
-import org.cesiumjs.cs.BaseTestCase;
-
/**
* @author Serge Silaev aka iSergio
*/
public class Cartesian2Test extends BaseTestCase {
- private static final Logger LOGGER = LogManager.getLogManager().getLogger(Cartesian2Test.class.getName());
+ private static final Logger LOGGER = LogManager.getLogManager().getLogger(Cartesian2Test.class.getName());
- public void testConstructor() {
- delayTestFinish(10_000);
+ public void testConstructor() {
+ delayTestFinish(10_000);
- super.beginTest(new Test() {
- @Override
- public void execute() {
- Cartesian2 cartesian2 = new Cartesian2(1.0, 2.0);
- assertNotNull(cartesian2);
- assertEquals(1.0, cartesian2.x);
- assertEquals(2.0, cartesian2.y);
- finishTest();
- }
- });
- }
+ super.beginTest(() -> {
+ Cartesian2 cartesian2 = new Cartesian2(1.0, 2.0);
+ assertNotNull(cartesian2);
+ assertEquals(1.0, cartesian2.x);
+ assertEquals(2.0, cartesian2.y);
+ finishTest();
+ });
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/ColorTest.java b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/ColorTest.java
index f2b984eced0b0a18600b919217a23b265d25cefd..a9c86fbb03170acb4a53df92642c92015d85174c 100644
--- a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/ColorTest.java
+++ b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/ColorTest.java
@@ -23,17 +23,14 @@ import org.cesiumjs.cs.BaseTestCase;
*/
public class ColorTest extends BaseTestCase {
- public void testConstructor() {
- delayTestFinish(10_000);
+ public void testConstructor() {
+ delayTestFinish(10_000);
- super.beginTest(new Test() {
- @Override
- public void execute() {
- Color color = new Color(1.0f, 0.0f, 0.0f, 1.0f);
- assertNotNull(color);
- assertEquals(color, Color.RED());
- finishTest();
- }
- });
- }
+ super.beginTest(() -> {
+ Color color = new Color(1.0f, 0.0f, 0.0f, 1.0f);
+ assertNotNull(color);
+ assertEquals(color, Color.RED());
+ finishTest();
+ });
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/DistanceDisplayConditionGeometryInstanceAttributeTest.java b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/DistanceDisplayConditionGeometryInstanceAttributeTest.java
index 72311bbca7c3f089c08496e8d5685616656c0457..6d867a3ddef96af80fb8ca96b5e75413f88fe950 100644
--- a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/DistanceDisplayConditionGeometryInstanceAttributeTest.java
+++ b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/DistanceDisplayConditionGeometryInstanceAttributeTest.java
@@ -27,33 +27,30 @@ import org.cesiumjs.cs.js.JsObject;
* @author Serge Silaev aka iSergio
*/
public class DistanceDisplayConditionGeometryInstanceAttributeTest extends BaseTestCase {
- public void test() {
- delayTestFinish(10_000);
-
- super.beginTest(new Test() {
- @Override
- public void execute() {
- BoxGeometryOptions boxGeometryOptions = new BoxGeometryOptions();
- boxGeometryOptions.vertexFormat = VertexFormat.POSITION_AND_NORMAL();
- boxGeometryOptions.minimum = new Cartesian3(-250000.0, -250000.0, -250000.0);
- boxGeometryOptions.maximum = new Cartesian3(250000.0, 250000.0, 250000.0);
-
- JsObject attributes = JsObject.create();
- attributes.setProperty("show", new DistanceDisplayConditionGeometryInstanceAttribute(100.0, 10000.0));
-
- GeometryInstanceOptions instanceOptions = new GeometryInstanceOptions();
- instanceOptions.geometry = new BoxGeometry(boxGeometryOptions);
- instanceOptions.modelMatrix = Matrix4.multiplyByTranslation(
- Transforms.eastNorthUpToFixedFrame(Cartesian3.fromDegrees(-75.59777, 40.03883)),
- new Cartesian3(0.0, 0.0, 1000000.0), new Matrix4());
- instanceOptions.id = "box";
- instanceOptions.attributes = attributes;
-
- GeometryInstance instance = new GeometryInstance(instanceOptions);
- assertNotNull(instance);
-
- finishTest();
- }
- });
- }
+ public void test() {
+ delayTestFinish(10_000);
+
+ super.beginTest(() -> {
+ BoxGeometryOptions boxGeometryOptions = new BoxGeometryOptions();
+ boxGeometryOptions.vertexFormat = VertexFormat.POSITION_AND_NORMAL();
+ boxGeometryOptions.minimum = new Cartesian3(-250000.0, -250000.0, -250000.0);
+ boxGeometryOptions.maximum = new Cartesian3(250000.0, 250000.0, 250000.0);
+
+ JsObject attributes = JsObject.create();
+ attributes.setProperty("show", new DistanceDisplayConditionGeometryInstanceAttribute(100.0, 10000.0));
+
+ GeometryInstanceOptions instanceOptions = new GeometryInstanceOptions();
+ instanceOptions.geometry = new BoxGeometry(boxGeometryOptions);
+ instanceOptions.modelMatrix = Matrix4.multiplyByTranslation(
+ Transforms.eastNorthUpToFixedFrame(Cartesian3.fromDegrees(-75.59777, 40.03883)),
+ new Cartesian3(0.0, 0.0, 1000000.0), new Matrix4());
+ instanceOptions.id = "box";
+ instanceOptions.attributes = attributes;
+
+ GeometryInstance instance = new GeometryInstance(instanceOptions);
+ assertNotNull(instance);
+
+ finishTest();
+ });
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/Intersections2DTest.java b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/Intersections2DTest.java
index d176bd772bb3d242ed3c237cf55c47781b23c691..3dcbec8625deca2f743c5d718324d2342956c696 100644
--- a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/Intersections2DTest.java
+++ b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/Intersections2DTest.java
@@ -22,54 +22,44 @@ import org.cesiumjs.cs.BaseTestCase;
* @author Serge Silaev aka iSergio
*/
public class Intersections2DTest extends BaseTestCase {
- public void testClipTriangleAtAxisAlignedThreshold() {
- delayTestFinish(10_000);
- super.beginTest(new BaseTestCase.Test() {
- @Override
- public void execute() {
- double[] expected = Intersections2D.clipTriangleAtAxisAlignedThreshold(0.5, false, 0.2, 0.6, 0.4);
- double[] actual = new double[] { 2, 0, -1, 1, 0, 0.25, -1, 1, 2, 0.5 };
- assertEquals(expected[0], actual[0], 0.000001);
- assertEquals(expected[1], actual[1], 0.000001);
- assertEquals(expected[2], actual[2], 0.000001);
- assertEquals(expected[3], actual[3], 0.000001);
- assertEquals(expected[4], actual[4], 0.000001);
- assertEquals(expected[5], actual[5], 0.000001);
- assertEquals(expected[6], actual[6], 0.000001);
- assertEquals(expected[7], actual[7], 0.000001);
- assertEquals(expected[8], actual[8], 0.000001);
- assertEquals(expected[9], actual[9], 0.000001);
- finishTest();
- }
- });
- }
+ public void testClipTriangleAtAxisAlignedThreshold() {
+ delayTestFinish(10_000);
+ super.beginTest(() -> {
+ double[] expected = Intersections2D.clipTriangleAtAxisAlignedThreshold(0.5, false, 0.2, 0.6, 0.4);
+ double[] actual = new double[]{2, 0, -1, 1, 0, 0.25, -1, 1, 2, 0.5};
+ assertEquals(expected[0], actual[0], 0.000001);
+ assertEquals(expected[1], actual[1], 0.000001);
+ assertEquals(expected[2], actual[2], 0.000001);
+ assertEquals(expected[3], actual[3], 0.000001);
+ assertEquals(expected[4], actual[4], 0.000001);
+ assertEquals(expected[5], actual[5], 0.000001);
+ assertEquals(expected[6], actual[6], 0.000001);
+ assertEquals(expected[7], actual[7], 0.000001);
+ assertEquals(expected[8], actual[8], 0.000001);
+ assertEquals(expected[9], actual[9], 0.000001);
+ finishTest();
+ });
+ }
- public void testComputeBarycentricCoordinates() {
- delayTestFinish(10_000);
- super.beginTest(new BaseTestCase.Test() {
- @Override
- public void execute() {
- Cartesian3 expected = Intersections2D.computeBarycentricCoordinates(0.0, 0.0, 0.0, 1.0, -1, -0.5, 1, -0.5);
- Cartesian3 actual = new Cartesian3(1.0 / 3.0, 1.0 / 3.0, 1.0 / 3.0);
- assertEquals(expected.x, actual.x, 0.000001);
- assertEquals(expected.y, actual.y, 0.000001);
- assertEquals(expected.z, actual.z, 0.000001);
- finishTest();
- }
- });
- }
+ public void testComputeBarycentricCoordinates() {
+ delayTestFinish(10_000);
+ super.beginTest(() -> {
+ Cartesian3 expected = Intersections2D.computeBarycentricCoordinates(0.0, 0.0, 0.0, 1.0, -1, -0.5, 1, -0.5);
+ Cartesian3 actual = new Cartesian3(1.0 / 3.0, 1.0 / 3.0, 1.0 / 3.0);
+ assertEquals(expected.x, actual.x, 0.000001);
+ assertEquals(expected.y, actual.y, 0.000001);
+ assertEquals(expected.z, actual.z, 0.000001);
+ finishTest();
+ });
+ }
- public void testComputeLineSegmentLineSegmentIntersection() {
- delayTestFinish(10_000);
- super.beginTest(new BaseTestCase.Test() {
- @Override
- public void execute() {
- Cartesian2 expected = Intersections2D.computeLineSegmentLineSegmentIntersection(0.0, 0.0, 0.0, 2.0, -1, 1, 1,
- 1);
- Cartesian2 actual = new Cartesian2(0.0, 1.0);
- assertEquals(expected, actual);
- finishTest();
- }
- });
- }
+ public void testComputeLineSegmentLineSegmentIntersection() {
+ delayTestFinish(10_000);
+ super.beginTest(() -> {
+ Cartesian2 expected = Intersections2D.computeLineSegmentLineSegmentIntersection(0.0, 0.0, 0.0, 2.0, -1, 1, 1, 1);
+ Cartesian2 actual = new Cartesian2(0.0, 1.0);
+ assertEquals(expected, actual);
+ finishTest();
+ });
+ }
}
diff --git a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/IonResourceTest.java b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/IonResourceTest.java
index 3112ca2ebd60f976c2704540d4b137f456a1bff9..f46ebfc0fc5f3918d1c084e1efa030488eee64cc 100644
--- a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/IonResourceTest.java
+++ b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/IonResourceTest.java
@@ -17,54 +17,26 @@
package org.cesiumjs.cs.core;
import org.cesiumjs.cs.BaseTestCase;
-import org.cesiumjs.cs.promise.Fulfill;
-import org.cesiumjs.cs.promise.Reject;
/**
* @author Serge Silaev aka iSergio
*/
public class IonResourceTest extends BaseTestCase {
- public void testFromAssetId1() {
- delayTestFinish(10_000);
+ public void testFromAssetId1() {
+ delayTestFinish(10_000);
- super.beginTest(new Test() {
- @Override
- public void execute() {
- IonResource.fromAssetId(3827).then(new Fulfill() {
- @Override
- public void onFulfilled(IonResource resource) {
+ super.beginTest(() -> IonResource.fromAssetId(3827).then(resource -> {
assertNotNull(resource);
finishTest();
- }
- }, new Reject() {
- @Override
- public void onRejected(Void value) {
- finishTest();
- }
- });
- }
- });
- }
+ }, value -> fail()));
+ }
- public void testFromAssetId2() {
- delayTestFinish(10_000);
+ public void testFromAssetId2() {
+ delayTestFinish(10_000);
- super.beginTest(new Test() {
- @Override
- public void execute() {
- IonResource.fromAssetId(3956).then(new Fulfill() {
- @Override
- public void onFulfilled(IonResource resource) {
+ super.beginTest(() -> IonResource.fromAssetId(3956).then(resource -> {
assertNotNull(resource);
finishTest();
- }
- }, new Reject() {
- @Override
- public void onRejected(Void value) {
- finishTest();
- }
- });
- }
- });
- }
+ }, value -> fail()));
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/PlaneTest.java b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/PlaneTest.java
index 69cf870e1b36d3027ce1d3c2a3688f24a84b30c2..01a2b420e9d84beb584dfe04f1c00e4f0e4de5c4 100644
--- a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/PlaneTest.java
+++ b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/PlaneTest.java
@@ -23,14 +23,11 @@ import org.cesiumjs.cs.BaseTestCase;
*/
public class PlaneTest extends BaseTestCase {
- public void testProjectPointOntoPlane() {
- super.beginTest(new Test() {
- @Override
- public void execute() {
- Cartesian3 point = new Cartesian3(1, 2, 3);
- Cartesian3 result = Plane.projectPointOntoPlane(Plane.ORIGIN_XY_PLANE(), point);
- assertNotNull(result);
- }
- });
- }
+ public void testProjectPointOntoPlane() {
+ super.beginTest(() -> {
+ Cartesian3 point = new Cartesian3(1, 2, 3);
+ Cartesian3 result = Plane.projectPointOntoPlane(Plane.ORIGIN_XY_PLANE(), point);
+ assertNotNull(result);
+ });
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/geometry/CoplanarPolygonGeometryTest.java b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/geometry/CoplanarPolygonGeometryTest.java
index ce2621ca48852f5a9a599e601107431b52b3ad0f..0bd11104ce5bf66ddd0d5f5e4ac602c78dfb0faa 100644
--- a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/geometry/CoplanarPolygonGeometryTest.java
+++ b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/geometry/CoplanarPolygonGeometryTest.java
@@ -24,20 +24,17 @@ import org.cesiumjs.cs.core.geometry.options.CoplanarPolygonGeometryFromPosition
* @author Serge Silaev aka iSergio
*/
public class CoplanarPolygonGeometryTest extends BaseTestCase {
- public void testFromPositions() {
- delayTestFinish(10_000);
+ public void testFromPositions() {
+ delayTestFinish(10_000);
- super.beginTest(new Test() {
- @Override
- public void execute() {
- Cartesian3[] positions = Cartesian3.fromDegreesArrayHeights(
- new double[] { -90.0, 30.0, 0.0, -90.0, 30.0, 1000.0, -80.0, 30.0, 1000.0, -80.0, 30.0, 0.0 });
- CoplanarPolygonGeometryFromPositionsOptions options = CoplanarPolygonGeometryFromPositionsOptions
- .create(positions);
- CoplanarPolygonGeometry geometry = CoplanarPolygonGeometry.fromPositions(options);
-
- finishTest();
- }
- });
- }
+ super.beginTest(() -> {
+ Cartesian3[] positions = Cartesian3.fromDegreesArrayHeights(
+ new double[]{-90.0, 30.0, 0.0, -90.0, 30.0, 1000.0, -80.0, 30.0, 1000.0, -80.0, 30.0, 0.0});
+ CoplanarPolygonGeometryFromPositionsOptions options = CoplanarPolygonGeometryFromPositionsOptions
+ .create(positions);
+ CoplanarPolygonGeometry geometry = CoplanarPolygonGeometry.fromPositions(options);
+ assertNotNull(geometry);
+ finishTest();
+ });
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/geometry/GroundPolylineGeometryTest.java b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/geometry/GroundPolylineGeometryTest.java
index 3349591e182a3d953453dd9aa97da8a2bafff949..f0175c0a320f2d35afd1c337064fed33d58d7057 100644
--- a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/geometry/GroundPolylineGeometryTest.java
+++ b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/core/geometry/GroundPolylineGeometryTest.java
@@ -23,21 +23,18 @@ import org.cesiumjs.cs.core.Cartesian3;
* @author Serge Silaev aka iSergio
*/
public class GroundPolylineGeometryTest extends BaseTestCase {
- public void testCreate() {
- delayTestFinish(10_000);
+ public void testCreate() {
+ delayTestFinish(10_000);
- super.beginTest(new Test() {
- @Override
- public void execute() {
- Cartesian3[] positions = Cartesian3.fromDegreesArray(new double[] { -112.1340164450331, 36.05494287836128,
- -112.08821010582645, 36.097804071380715, -112.13296079730024, 36.168769146801104 });
- GroundPolylineGeometry geometry = GroundPolylineGeometry.create(positions);
- assertNotNull(geometry);
- assertEquals(1.0, geometry.width);
- assertEquals(9999.0, geometry.granularity);
- assertFalse(geometry.loop);
- finishTest();
- }
- });
- }
+ super.beginTest(() -> {
+ Cartesian3[] positions = Cartesian3.fromDegreesArray(new double[]{-112.1340164450331, 36.05494287836128,
+ -112.08821010582645, 36.097804071380715, -112.13296079730024, 36.168769146801104});
+ GroundPolylineGeometry geometry = GroundPolylineGeometry.create(positions);
+ assertNotNull(geometry);
+ assertEquals(1.0, geometry.width);
+ assertEquals(9999.0, geometry.granularity);
+ assertFalse(geometry.loop);
+ finishTest();
+ });
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/scene/Cesium3DTilesetTest.java b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/scene/Cesium3DTilesetTest.java
index 41b76d1eb4c6a9b4d46a6ca761623d52f41f2dee..3db6a6650487558ab2285856891e5b49c526cd75 100644
--- a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/scene/Cesium3DTilesetTest.java
+++ b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/scene/Cesium3DTilesetTest.java
@@ -18,66 +18,33 @@ package org.cesiumjs.cs.scene;
import org.cesiumjs.cs.BaseTestCase;
import org.cesiumjs.cs.core.IonResource;
-import org.cesiumjs.cs.promise.Fulfill;
-import org.cesiumjs.cs.promise.Promise;
-import org.cesiumjs.cs.promise.Reject;
/**
* @author Serge Silaev aka iSergio
*/
public class Cesium3DTilesetTest extends BaseTestCase {
- public void testCreateResource() {
- delayTestFinish(10_000);
+ public void testCreateResource() {
+ delayTestFinish(10_000);
- super.beginTest(new Test() {
- @Override
- public void execute() {
- Promise promise = IonResource.fromAssetId(3883);
- promise.then(new Fulfill() {
- @Override
- public void onFulfilled(IonResource resource) {
- Cesium3DTileset tileset = Cesium3DTileset.create(resource);
- tileset.readyPromise().then(new Fulfill() {
- @Override
- public void onFulfilled(Cesium3DTileset value) {
- assertNotNull(value);
- finishTest();
- }
- }, new Reject() {
- @Override
- public void onRejected(Void value) {
- finishTest();
- }
- });
- }
- });
- }
- });
- }
+ super.beginTest(() -> IonResource.fromAssetId(3883)
+ .then(resource -> Cesium3DTileset.create(resource).readyPromise()
+ .then(tileSet -> {
+ assertNotNull(tileSet);
+ finishTest();
+ }, value -> fail()))
+ );
+ }
- public void testCreatePromise() {
- delayTestFinish(10_000);
+ public void testCreatePromise() {
+ delayTestFinish(10_000);
- super.beginTest(new Test() {
- @Override
- public void execute() {
- Promise promise = IonResource.fromAssetId(3883);
- Cesium3DTileset tileset = Cesium3DTileset.create(promise);
- tileset.readyPromise().then(new Fulfill() {
- @Override
- public void onFulfilled(Cesium3DTileset value) {
- assertNotNull(value);
- finishTest();
- }
- }, new Reject() {
- @Override
- public void onRejected(Void value) {
- assertTrue(false);
- finishTest();
- }
- });
- }
- });
- }
+ super.beginTest(() -> IonResource.fromAssetId(3883)
+ .then(resource -> Cesium3DTileset.create(resource).readyPromise()
+ .then(tileSet -> {
+ assertNotNull(tileSet);
+ finishTest();
+ }, value -> fail()))
+ );
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/scene/GroundPolylinePrimitiveTest.java b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/scene/GroundPolylinePrimitiveTest.java
index 2f37d6ecfdc378b01ef21e602f3c200a778c55aa..2c0f4d15449436fcd34181d701a85126461a67dd 100644
--- a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/scene/GroundPolylinePrimitiveTest.java
+++ b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/scene/GroundPolylinePrimitiveTest.java
@@ -30,33 +30,30 @@ import org.cesiumjs.cs.scene.options.GroundPolylinePrimitiveOptions;
* @author Serge Silaev aka iSergio
*/
public class GroundPolylinePrimitiveTest extends BaseTestCase {
- public void test() {
- delayTestFinish(10_000);
-
- super.beginTest(new Test() {
- @Override
- public void execute() {
- Cartesian3[] positions = Cartesian3.fromDegreesArray(
- new double[] { -112.1340164450331, 36.05494287836128, -112.08821010582645, 36.097804071380715 });
- GroundPolylineGeometryOptions groundPolylineGeometryOptions = GroundPolylineGeometryOptions.create(positions);
- groundPolylineGeometryOptions.width = 4;
-
- GeometryInstanceOptions geometryInstanceOptions = new GeometryInstanceOptions();
- geometryInstanceOptions.geometry = new GroundPolylineGeometry(groundPolylineGeometryOptions);
- geometryInstanceOptions.id = "object returned when this instance is picked and to get/set per-instance attributes";
-
- PolylineMaterialAppearanceOptions appearanceOptions = new PolylineMaterialAppearanceOptions();
- appearanceOptions.material = Material.fromType("Color");
-
- GroundPolylinePrimitiveOptions primitiveOptions = new GroundPolylinePrimitiveOptions();
- primitiveOptions.geometryInstances = new GeometryInstance[] { new GeometryInstance(geometryInstanceOptions) };
- primitiveOptions.appearance = new PolylineMaterialAppearance(appearanceOptions);
-
- GroundPolylinePrimitive groundPolylinePrimitive = new GroundPolylinePrimitive(primitiveOptions);
- assertNotNull(groundPolylinePrimitive);
-
- finishTest();
- }
- });
- }
+ public void test() {
+ delayTestFinish(10_000);
+
+ super.beginTest(() -> {
+ Cartesian3[] positions = Cartesian3.fromDegreesArray(
+ new double[]{-112.1340164450331, 36.05494287836128, -112.08821010582645, 36.097804071380715});
+ GroundPolylineGeometryOptions groundPolylineGeometryOptions = GroundPolylineGeometryOptions.create(positions);
+ groundPolylineGeometryOptions.width = 4;
+
+ GeometryInstanceOptions geometryInstanceOptions = new GeometryInstanceOptions();
+ geometryInstanceOptions.geometry = new GroundPolylineGeometry(groundPolylineGeometryOptions);
+ geometryInstanceOptions.id = "object returned when this instance is picked and to get/set per-instance attributes";
+
+ PolylineMaterialAppearanceOptions appearanceOptions = new PolylineMaterialAppearanceOptions();
+ appearanceOptions.material = Material.fromType("Color");
+
+ GroundPolylinePrimitiveOptions primitiveOptions = new GroundPolylinePrimitiveOptions();
+ primitiveOptions.geometryInstances = new GeometryInstance[]{new GeometryInstance(geometryInstanceOptions)};
+ primitiveOptions.appearance = new PolylineMaterialAppearance(appearanceOptions);
+
+ GroundPolylinePrimitive groundPolylinePrimitive = new GroundPolylinePrimitive(primitiveOptions);
+ assertNotNull(groundPolylinePrimitive);
+
+ finishTest();
+ });
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/scene/LabelTest.java b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/scene/LabelTest.java
index 19dcb362729c9d7f82a8cad2288745385704a188..122b616775f29ff5cf4f1a16f3e59812715591c6 100644
--- a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/scene/LabelTest.java
+++ b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/scene/LabelTest.java
@@ -26,35 +26,29 @@ import org.cesiumjs.cs.scene.options.LabelOptions;
* @author Serge Silaev aka iSergio
*/
public class LabelTest extends BaseTestCase {
- public void testVerticalOrigin() {
- delayTestFinish(10_000);
+ public void testVerticalOrigin() {
+ delayTestFinish(10_000);
- super.beginTest(new Test() {
- @Override
- public void execute() {
- LabelCollection collection = new LabelCollection();
- LabelOptions options = new LabelOptions();
- options.verticalOrigin = VerticalOrigin.TOP();
- Label label = collection.add(options);
- assertEquals(VerticalOrigin.TOP(), label.verticalOrigin);
- finishTest();
- }
- });
- }
+ super.beginTest(() -> {
+ LabelCollection collection = new LabelCollection();
+ LabelOptions options = new LabelOptions();
+ options.verticalOrigin = VerticalOrigin.TOP();
+ Label label = collection.add(options);
+ assertEquals(VerticalOrigin.TOP(), label.verticalOrigin);
+ finishTest();
+ });
+ }
- public void testHorizontalOrigin() {
- delayTestFinish(10_000);
+ public void testHorizontalOrigin() {
+ delayTestFinish(10_000);
- super.beginTest(new Test() {
- @Override
- public void execute() {
- LabelCollection collection = new LabelCollection();
- LabelOptions options = new LabelOptions();
- options.horizontalOrigin = HorizontalOrigin.RIGHT();
- Label label = collection.add(options);
- assertEquals(HorizontalOrigin.RIGHT(), label.horizontalOrigin);
- finishTest();
- }
- });
- }
+ super.beginTest(() -> {
+ LabelCollection collection = new LabelCollection();
+ LabelOptions options = new LabelOptions();
+ options.horizontalOrigin = HorizontalOrigin.RIGHT();
+ Label label = collection.add(options);
+ assertEquals(HorizontalOrigin.RIGHT(), label.horizontalOrigin);
+ finishTest();
+ });
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/widgets/ViewerPanelTest.java b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/widgets/ViewerPanelTest.java
index 50a33afb0b54302e67f600c346749e13c64c26c5..07492426f46b688a37acec2cfe1132d83329d957 100644
--- a/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/widgets/ViewerPanelTest.java
+++ b/cesiumjs4gwt-main/src/test/java/org/cesiumjs/cs/widgets/ViewerPanelTest.java
@@ -21,7 +21,6 @@ import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.LinkElement;
import com.google.gwt.user.client.ui.RootPanel;
-
import org.cesiumjs.cs.BaseTestCase;
import org.cesiumjs.cs.widgets.options.ViewerOptions;
@@ -29,28 +28,25 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions;
* @author Serge Silaev aka iSergio
*/
public class ViewerPanelTest extends BaseTestCase {
- public void testRequestRenderMode() {
- delayTestFinish(10_000);
+ public void testRequestRenderMode() {
+ delayTestFinish(10_000);
- super.beginTest(new Test() {
- @Override
- public void execute() {
- LinkElement linkElement = Document.get().createLinkElement();
- linkElement.setRel("stylesheet");
- linkElement.setHref("cs/CesiumUnminified/Widgets/widgets.css");
- Document.get().getElementsByTagName("head").getItem(0).appendChild(linkElement);
+ super.beginTest(() -> {
+ LinkElement linkElement = Document.get().createLinkElement();
+ linkElement.setRel("stylesheet");
+ linkElement.setHref("cs/CesiumUnminified/Widgets/widgets.css");
+ Document.get().getElementsByTagName("head").getItem(0).appendChild(linkElement);
- DivElement divElement = RootPanel.get().getElement().getOwnerDocument().createDivElement();
- divElement.setId("cesium");
- RootPanel.get().getElement().appendChild(divElement);
- Element element = RootPanel.get().getElement().getOwnerDocument().getElementById("cesium");
- assertNotNull(element);
- ViewerOptions options = new ViewerOptions();
- assertNotNull(options);
- Viewer viewer = new Viewer(element, options);
- // assertNotNull(viewer);
- finishTest();
- }
- });
- }
+ DivElement divElement = RootPanel.get().getElement().getOwnerDocument().createDivElement();
+ divElement.setId("cesium");
+ RootPanel.get().getElement().appendChild(divElement);
+ Element element = RootPanel.get().getElement().getOwnerDocument().getElementById("cesium");
+ assertNotNull(element);
+ ViewerOptions options = new ViewerOptions();
+ assertNotNull(options);
+ Viewer viewer = new Viewer(element, options);
+ // assertNotNull(viewer);
+ finishTest();
+ });
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/pom.xml b/cesiumjs4gwt-showcase/pom.xml
index 017d22c5d7dd3c4f8bbcd2a2f40cf43482d8fadd..b9051f97989feee1c5e41f60681c81728d29243a 100644
--- a/cesiumjs4gwt-showcase/pom.xml
+++ b/cesiumjs4gwt-showcase/pom.xml
@@ -5,7 +5,7 @@
cesiumjs4gwt
org.cesiumjs
- 1.74
+ 1.79.1-SNAPSHOT
CesiumJS GWT Showcase
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/Showcase.gwt.xml b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/Showcase.gwt.xml
index 258a17cb44b4887f9d444d538bab0a175b6d9375..94109868b4bda588ededd25f095e197e19b69d7e 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/Showcase.gwt.xml
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/Showcase.gwt.xml
@@ -2,7 +2,7 @@
+ "http://www.gwtproject.org/doctype/2.8.2/gwt-module.dtd">
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/DialogBoxWithCloseButton.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/DialogBoxWithCloseButton.java
index dc4fee67da592a987f03cbaf99c867457c99275d..9113ee376169289dbf78bcdf1d6a747009e4097f 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/DialogBoxWithCloseButton.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/DialogBoxWithCloseButton.java
@@ -1,18 +1,17 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase;
@@ -21,7 +20,7 @@ import com.google.gwt.user.client.ui.DialogBox;
/**
* This will create a standard gwt-dialogbox with a close button. the css for
* the close button:
- *
+ *
*
* .gwt-DialogBox-closebutton {
* font-weight: bold;
@@ -38,89 +37,88 @@ import com.google.gwt.user.client.ui.DialogBox;
* color: #ee0000;
* }
*
- *
+ *
* @author Frank Wynants
*/
public class DialogBoxWithCloseButton extends DialogBox {
- /** The count. */
- private static int count = 0;
+ /** The count. */
+ private static int count = 0;
- /**
- * Define closeDialog using JSNI.
- *
- * @param dialogBox The dialog box.
- * @param functionName The name of the function to invoke.
- */
- private static native void redefineClose(DialogBox dialogBox, String functionName)
- /*-{
- $wnd[functionName] = function()
- {
- dialogBox.@org.cleanlogic.cesiumjs4gwt.showcase.DialogBoxWithCloseButton::hideDialog()();
+ /**
+ * Define closeDialog using JSNI.
+ *
+ * @param dialogBox The dialog box.
+ * @param functionName The name of the function to invoke.
+ */
+ private static native void redefineClose(DialogBox dialogBox, String functionName)
+ /*-{
+ $wnd[functionName] = function () {
+ dialogBox.@org.cleanlogic.cesiumjs4gwt.showcase.DialogBoxWithCloseButton::hideDialog()();
}
- }-*/;
+ }-*/;
- /** The id. */
- private final String uid;
+ /** The id. */
+ private final String uid;
- /**
- * Creates an instance.
- */
- public DialogBoxWithCloseButton() {
- this(false);
- }
+ /**
+ * Creates an instance.
+ */
+ public DialogBoxWithCloseButton() {
+ this(false);
+ }
- /**
- * Creates an instance.
- *
- * @param autoHide True to autohide.
- */
- public DialogBoxWithCloseButton(final boolean autoHide) {
- this(autoHide, true);
- }
+ /**
+ * Creates an instance.
+ *
+ * @param autoHide True to autohide.
+ */
+ public DialogBoxWithCloseButton(final boolean autoHide) {
+ this(autoHide, true);
+ }
- /**
- * Creates an instance.
- *
- * @param autoHide True to autohide.
- * @param modal True to make the dialog modal.
- */
- public DialogBoxWithCloseButton(final boolean autoHide, final boolean modal) {
- super(autoHide, modal);
- setGlassEnabled(true);
- this.uid = "DialogBoxWithCloseButton_" + count++ + "_Close";
- setText("Dialog");
- }
+ /**
+ * Creates an instance.
+ *
+ * @param autoHide True to autohide.
+ * @param modal True to make the dialog modal.
+ */
+ public DialogBoxWithCloseButton(final boolean autoHide, final boolean modal) {
+ super(autoHide, modal);
+ setGlassEnabled(true);
+ this.uid = "DialogBoxWithCloseButton_" + count++ + "_Close";
+ setText("Dialog");
+ }
- /**
- * Hides the dialog.
- */
- public void hideDialog() {
- super.hide();
- }
+ /**
+ * Hides the dialog.
+ */
+ public void hideDialog() {
+ super.hide();
+ }
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.user.client.ui.DialogBox#setHTML(java.lang.String)
- */
- @Override
- public void setHTML(final String html) {
- final String styleName = getStyleName() + "-closebutton";
- super.setHTML(
- "");
- redefineClose(this, this.uid);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.google.gwt.user.client.ui.DialogBox#setHTML(java.lang.String)
+ */
+ @Override
+ public void setHTML(final String html) {
+ final String styleName = getStyleName() + "-closebutton";
+ super.setHTML(
+ "");
+ redefineClose(this, this.uid);
+ }
- /*
- * (non-Javadoc)
- *
- * @see com.google.gwt.user.client.ui.DialogBox#setText(java.lang.String)
- */
- @Override
- public void setText(final String text) {
- this.setHTML(text);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.google.gwt.user.client.ui.DialogBox#setText(java.lang.String)
+ */
+ @Override
+ public void setText(final String text) {
+ this.setHTML(text);
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/ExampleBean.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/ExampleBean.java
index df315be412309589b526e5b4d6b5d18f62483fb4..9509502d7b83abe0ee7a47736bc62c3b4aeed458 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/ExampleBean.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/ExampleBean.java
@@ -1,18 +1,17 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase;
@@ -22,115 +21,114 @@ import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
* One example
*
* @author Frank
- *
*/
public class ExampleBean implements Comparable {
- private String name;
- private String description;
- private String[] tags;
- private AbstractExample example;
-
- /**
- * Constructs an example.
- *
- * @param name
- * @param description
- * @param tags
- */
- public ExampleBean(String name, String description, String[] tags, AbstractExample example) {
- super();
- this.name = name;
- this.description = description;
- this.tags = tags;
- this.example = example;
- }
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @return the description
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * @param description the description to set
- */
- public void setDescription(String description) {
- this.description = description;
- }
-
- /**
- * @return the tags
- */
- public String[] getTags() {
- return tags;
- }
-
- /**
- * @param tags the tags to set
- */
- public void setTags(String[] tags) {
- this.tags = tags;
- }
-
- /**
- * @return the example
- */
- public AbstractExample getExample() {
- return example;
- }
-
- /**
- * @param example the example to set
- */
- public void setExample(AbstractExample example) {
- this.example = example;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo(ExampleBean o) {
- return this.getName().compareTo(o.getName());
- }
-
- @Override
- public int hashCode() {
- int hash = 3;
- hash = 79 * hash + (this.name != null ? this.name.hashCode() : 0);
- return hash;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
+ private String name;
+ private String description;
+ private String[] tags;
+ private AbstractExample example;
+
+ /**
+ * Constructs an example.
+ *
+ * @param name
+ * @param description
+ * @param tags
+ */
+ public ExampleBean(String name, String description, String[] tags, AbstractExample example) {
+ super();
+ this.name = name;
+ this.description = description;
+ this.tags = tags;
+ this.example = example;
}
- if (getClass() != obj.getClass()) {
- return false;
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
}
- final ExampleBean other = (ExampleBean) obj;
- if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
- return false;
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @param description the description to set
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * @return the tags
+ */
+ public String[] getTags() {
+ return tags;
+ }
+
+ /**
+ * @param tags the tags to set
+ */
+ public void setTags(String[] tags) {
+ this.tags = tags;
+ }
+
+ /**
+ * @return the example
+ */
+ public AbstractExample getExample() {
+ return example;
+ }
+
+ /**
+ * @param example the example to set
+ */
+ public void setExample(AbstractExample example) {
+ this.example = example;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(ExampleBean o) {
+ return this.getName().compareTo(o.getName());
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 3;
+ hash = 79 * hash + (this.name != null ? this.name.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final ExampleBean other = (ExampleBean) obj;
+ if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
+ return false;
+ }
+ return true;
}
- return true;
- }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/ExamplePanel.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/ExamplePanel.java
index 5d7f83a1797f9047c4c803decbe70a3fd44f8e5e..44eba8567321a04064cf41aa8a1a777cc3897937 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/ExamplePanel.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/ExamplePanel.java
@@ -1,111 +1,97 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Overflow;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.dom.client.MouseOutEvent;
-import com.google.gwt.event.dom.client.MouseOutHandler;
-import com.google.gwt.event.dom.client.MouseOverEvent;
-import com.google.gwt.event.dom.client.MouseOverHandler;
+import com.google.gwt.event.dom.client.*;
import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.FocusPanel;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.Image;
-import com.google.gwt.user.client.ui.Label;
-import com.google.gwt.user.client.ui.ScrollPanel;
-import com.google.gwt.user.client.ui.VerticalPanel;
-
+import com.google.gwt.user.client.ui.*;
import org.cleanlogic.cesiumjs4gwt.showcase.i18n.I18NMessages;
/**
* A clickable example panel.
*
* @author Frank Wynants
- *
*/
public class ExamplePanel extends Composite {
- public static final I18NMessages I18N = (I18NMessages) GWT.create(I18NMessages.class);
+ public static final I18NMessages I18N = (I18NMessages) GWT.create(I18NMessages.class);
- /**
- * Constructs the ExamplePanel using an Example
- *
- * @param example
- */
- public ExamplePanel(final ExampleBean example) {
- final VerticalPanel vp = new VerticalPanel();
- vp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
- vp.setSpacing(5);
+ /**
+ * Constructs the ExamplePanel using an Example
+ *
+ * @param example
+ */
+ public ExamplePanel(final ExampleBean example) {
+ final VerticalPanel vp = new VerticalPanel();
+ vp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+ vp.setSpacing(5);
- final ScrollPanel sp = new ScrollPanel();
- sp.addDomHandler(new MouseOverHandler() {
- @Override
- public void onMouseOver(MouseOverEvent mouseOverEvent) {
- sp.getElement().getStyle().setOverflowX(Overflow.AUTO);
- sp.getElement().getStyle().setOverflowY(Overflow.AUTO);
- }
- }, MouseOverEvent.getType());
- sp.addDomHandler(new MouseOutHandler() {
- @Override
- public void onMouseOut(MouseOutEvent mouseOutEvent) {
+ final ScrollPanel sp = new ScrollPanel();
+ sp.addDomHandler(new MouseOverHandler() {
+ @Override
+ public void onMouseOver(MouseOverEvent mouseOverEvent) {
+ sp.getElement().getStyle().setOverflowX(Overflow.AUTO);
+ sp.getElement().getStyle().setOverflowY(Overflow.AUTO);
+ }
+ }, MouseOverEvent.getType());
+ sp.addDomHandler(new MouseOutHandler() {
+ @Override
+ public void onMouseOut(MouseOutEvent mouseOutEvent) {
+ sp.getElement().getStyle().setOverflowX(Overflow.HIDDEN);
+ sp.getElement().getStyle().setOverflowY(Overflow.HIDDEN);
+ }
+ }, MouseOutEvent.getType());
sp.getElement().getStyle().setOverflowX(Overflow.HIDDEN);
sp.getElement().getStyle().setOverflowY(Overflow.HIDDEN);
- }
- }, MouseOutEvent.getType());
- sp.getElement().getStyle().setOverflowX(Overflow.HIDDEN);
- sp.getElement().getStyle().setOverflowY(Overflow.HIDDEN);
- // sp.setSize("350px", "100px");
- sp.setWidth("250px");
- sp.setHeight("250px");
- sp.setWidget(vp);
+ // sp.setSize("350px", "100px");
+ sp.setWidth("250px");
+ sp.setHeight("250px");
+ sp.setWidget(vp);
- final Label lblName = new Label(example.getName());
- final Image lblImage = new Image(GWT.getModuleBaseURL() + "examples/" + example.getName() + ".jpg");
- final Label lblDescription = new Label(example.getDescription());
- final StringBuffer sb = new StringBuffer();
- final String[] tags = example.getTags();
- for (String tag : tags) {
- sb.append(tag).append(", ");
- }
- final Label lblTags = new Label(I18N.tags(sb.toString().substring(0, sb.toString().length() - 2)));
- lblTags.setStyleName("exampletags");
+ final Label lblName = new Label(example.getName());
+ final Image lblImage = new Image(GWT.getModuleBaseURL() + "examples/" + example.getName() + ".jpg");
+ final Label lblDescription = new Label(example.getDescription());
+ final StringBuffer sb = new StringBuffer();
+ final String[] tags = example.getTags();
+ for (String tag : tags) {
+ sb.append(tag).append(", ");
+ }
+ final Label lblTags = new Label(I18N.tags(sb.toString().substring(0, sb.toString().length() - 2)));
+ lblTags.setStyleName("exampletags");
- lblName.setStyleName("examplename");
- vp.add(lblName);
- vp.add(lblImage);
- vp.add(lblDescription);
- vp.add(lblTags);
+ lblName.setStyleName("examplename");
+ vp.add(lblName);
+ vp.add(lblImage);
+ vp.add(lblDescription);
+ vp.add(lblTags);
- final FocusPanel fp = new FocusPanel(sp);
- this.initWidget(fp);
- this.setStyleName("examplepanel");
+ final FocusPanel fp = new FocusPanel(sp);
+ this.initWidget(fp);
+ this.setStyleName("examplepanel");
- fp.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent event) {
- if (Window.Location.getHref().contains("?")) {
- Window.open(Window.Location.getHref() + "&example=" + example.getName(), "_BLANK", null);
- } else {
- Window.open(Window.Location.getHref() + "?example=" + example.getName(), "_BLANK", null);
- }
- }
- });
- }
+ fp.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ if (Window.Location.getHref().contains("?")) {
+ Window.open(Window.Location.getHref() + "&example=" + example.getName(), "_BLANK", null);
+ } else {
+ Window.open(Window.Location.getHref() + "?example=" + example.getName(), "_BLANK", null);
+ }
+ }
+ });
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/InfoPanel.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/InfoPanel.java
index 1f1e15fe63b1813da3966ab1ec84620b038483e3..e94ba3bfe8d965e8ee6fcfa524293672208bbe02 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/InfoPanel.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/InfoPanel.java
@@ -1,27 +1,21 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.HasVerticalAlignment;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Image;
+import com.google.gwt.user.client.ui.*;
/**
* Een infopanel om algemene informatie aan de gebruiker te tonen.
@@ -31,42 +25,41 @@ import com.google.gwt.user.client.ui.Image;
*
*
* @author fks/Robin Heymans, Bert Roex
- *
*/
public class InfoPanel extends Composite {
- /**
- * The HTML widget that contains the message.
- */
- private HTML lblMessage = new HTML();
+ /**
+ * The HTML widget that contains the message.
+ */
+ private HTML lblMessage = new HTML();
- /**
- * Maak een nieuw infopanel.
- *
- * @param message Het weer te geven bericht
- */
- public InfoPanel(String message) {
- HorizontalPanel container = new HorizontalPanel();
- Image imgInfo = new Image(Resources.INSTANCE.icon_info());
- lblMessage.setHTML(message);
+ /**
+ * Maak een nieuw infopanel.
+ *
+ * @param message Het weer te geven bericht
+ */
+ public InfoPanel(String message) {
+ HorizontalPanel container = new HorizontalPanel();
+ Image imgInfo = new Image(Resources.INSTANCE.icon_info());
+ lblMessage.setHTML(message);
- container.add(imgInfo);
- container.add(lblMessage);
- container.setCellWidth(imgInfo, "70px");
- container.setCellHorizontalAlignment(imgInfo, HasHorizontalAlignment.ALIGN_CENTER);
- container.setCellVerticalAlignment(lblMessage, HasVerticalAlignment.ALIGN_MIDDLE);
- container.setCellVerticalAlignment(imgInfo, HasVerticalAlignment.ALIGN_MIDDLE);
+ container.add(imgInfo);
+ container.add(lblMessage);
+ container.setCellWidth(imgInfo, "70px");
+ container.setCellHorizontalAlignment(imgInfo, HasHorizontalAlignment.ALIGN_CENTER);
+ container.setCellVerticalAlignment(lblMessage, HasVerticalAlignment.ALIGN_MIDDLE);
+ container.setCellVerticalAlignment(imgInfo, HasVerticalAlignment.ALIGN_MIDDLE);
- initWidget(container);
- setStyleName("infopanel");
- setSize("480px", "60px");
- }
+ initWidget(container);
+ setStyleName("infopanel");
+ setSize("480px", "60px");
+ }
- /**
- * Sets the text shown in the infopanel.
- *
- * @param message The HTML message to show
- */
- public void setText(String message) {
- lblMessage.setHTML(message);
- }
+ /**
+ * Sets the text shown in the infopanel.
+ *
+ * @param message The HTML message to show
+ */
+ public void setText(String message) {
+ lblMessage.setHTML(message);
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/Resources.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/Resources.java
index 4c4429c867b8f839073258cf0ae4821cd3f14e20..fca57f1572daba77c909c2c1010b354409c95192 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/Resources.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/Resources.java
@@ -1,18 +1,17 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase;
@@ -24,28 +23,27 @@ import com.google.gwt.resources.client.ImageResource;
* ImageResource stuff.
*
* @author fks/Frank Wynants
- *
*/
public interface Resources extends ClientBundle {
- /**
- * The singleton instance.
- */
- Resources INSTANCE = GWT.create(Resources.class);
+ /**
+ * The singleton instance.
+ */
+ Resources INSTANCE = GWT.create(Resources.class);
- /**
- * The GWT-OL logo.
- *
- * @return The imagery resource.
- */
- @Source("resources/gwt-cs.png")
- ImageResource gwtCsLogo();
+ /**
+ * The GWT-OL logo.
+ *
+ * @return The imagery resource.
+ */
+ @Source("resources/gwt-cs.png")
+ ImageResource gwtCsLogo();
- /**
- * The info icon
- *
- * @return The imagery resource.
- */
- @Source("resources/icon-info.png")
- ImageResource icon_info();
+ /**
+ * The info icon
+ *
+ * @return The imagery resource.
+ */
+ @Source("resources/icon-info.png")
+ ImageResource icon_info();
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/Showcase.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/Showcase.java
index 804e8c636c186a2b3ba4897f2221413be0131175..dbe90dab5ce753a8154f53960ece7c1b9cbc394d 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/Showcase.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/Showcase.java
@@ -1,23 +1,21 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase;
import com.google.gwt.core.client.EntryPoint;
-
import org.cleanlogic.cesiumjs4gwt.showcase.components.responsibility.BuilderManager;
/**
@@ -25,11 +23,11 @@ import org.cleanlogic.cesiumjs4gwt.showcase.components.responsibility.BuilderMan
*/
public class Showcase implements EntryPoint {
- final BuilderManager showcaseBuilder = new BuilderManager();
+ final BuilderManager showcaseBuilder = new BuilderManager();
- @Override
- public void onModuleLoad() {
- showcaseBuilder.buildShowcase();
- }
+ @Override
+ public void onModuleLoad() {
+ showcaseBuilder.buildShowcase();
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/basic/AbstractExample.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/basic/AbstractExample.java
index 47d7802003586f287cecff2b83c72082f8994528..ec0e5f0ab01a8aa1ce2fe476cf268a6ed2c6bc33 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/basic/AbstractExample.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/basic/AbstractExample.java
@@ -1,93 +1,89 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase.basic;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Logger;
-
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
-
import org.cleanlogic.cesiumjs4gwt.showcase.ExampleBean;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ExampleStore;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Logger;
+
/**
* The abstract base for each Example
*
* @author Frank Wynants
- *
*/
public abstract class AbstractExample extends Composite {
- public static final Logger LOGGER = Logger.getLogger(AbstractExample.class.getName());
- protected VerticalPanel contentPanel = new VerticalPanel();
- protected HorizontalPanel horizontalPanel = new HorizontalPanel();
- private final List showSourceButtons = new ArrayList();
- protected ExampleBean example;
+ public static final Logger LOGGER = Logger.getLogger(AbstractExample.class.getName());
+ private final List showSourceButtons = new ArrayList();
+ protected VerticalPanel contentPanel = new VerticalPanel();
+ protected HorizontalPanel horizontalPanel = new HorizontalPanel();
+ protected ExampleBean example;
- public AbstractExample(String name, String description, String[] tags, ExampleStore store) {
- this(name, description, tags);
- store.addExample(example);
- }
+ public AbstractExample(String name, String description, String[] tags, ExampleStore store) {
+ this(name, description, tags);
+ store.addExample(example);
+ }
- /**
- * The constructor.
- *
- */
- public AbstractExample(String name, String description, String[] tags) {
- for (String sourceCodeUrl : getSourceCodeURLs()) {
- ShowSourceButton butShowSource = new ShowSourceButton("");
- butShowSource.setSourceCodeURL(sourceCodeUrl);
- showSourceButtons.add(butShowSource);
+ /**
+ * The constructor.
+ */
+ public AbstractExample(String name, String description, String[] tags) {
+ for (String sourceCodeUrl : getSourceCodeURLs()) {
+ ShowSourceButton butShowSource = new ShowSourceButton("");
+ butShowSource.setSourceCodeURL(sourceCodeUrl);
+ showSourceButtons.add(butShowSource);
+ }
+ setTitle(name);
+ this.example = new ExampleBean(name, description, tags, this);
}
- setTitle(name);
- this.example = new ExampleBean(name, description, tags, this);
- }
- public abstract void buildPanel();
+ public static native void log(Object object) /*-{
+ console.log(object);
+ }-*/;
- public abstract String[] getSourceCodeURLs();
+ public abstract void buildPanel();
- /**
- * @param title the title to set
- */
- @Override
- public void setTitle(String title) {
- for (ShowSourceButton butShowSource : showSourceButtons) {
- horizontalPanel.add(butShowSource);
- }
- contentPanel.setSpacing(5);
- contentPanel.getElement().getStyle().setPadding(10, Unit.PX);
- contentPanel.setWidth("100%");
- contentPanel.add(new HTML("" + title + "
"));
- contentPanel.add(horizontalPanel);
- }
+ public abstract String[] getSourceCodeURLs();
- /**
- * @return the example
- */
- public ExampleBean getExample() {
- return example;
- }
+ /**
+ * @param title the title to set
+ */
+ @Override
+ public void setTitle(String title) {
+ for (ShowSourceButton butShowSource : showSourceButtons) {
+ horizontalPanel.add(butShowSource);
+ }
+ contentPanel.setSpacing(5);
+ contentPanel.getElement().getStyle().setPadding(10, Unit.PX);
+ contentPanel.setWidth("100%");
+ contentPanel.add(new HTML("" + title + "
"));
+ contentPanel.add(horizontalPanel);
+ }
- public static native void log(Object object) /*-{
- console.log(object);
- }-*/;
+ /**
+ * @return the example
+ */
+ public ExampleBean getExample() {
+ return example;
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/basic/AbstractSourceButton.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/basic/AbstractSourceButton.java
index d04aea81e198d70a52e2a3046b01c20009ba4689..ef04f15e01f43a0b2808df4429eb1e471c110083 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/basic/AbstractSourceButton.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/basic/AbstractSourceButton.java
@@ -1,89 +1,81 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase.basic;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.http.client.Request;
-import com.google.gwt.http.client.RequestBuilder;
-import com.google.gwt.http.client.RequestCallback;
-import com.google.gwt.http.client.RequestException;
-import com.google.gwt.http.client.Response;
+import com.google.gwt.http.client.*;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
-
import org.cleanlogic.cesiumjs4gwt.showcase.components.ShowcaseSearchPanel;
/**
- *
* @author Frank Wynants
- *
* @author Giuseppe La Scaleia - CNR IMAA geoSDI Group
* @email giuseppe.lascaleia@geosdi.org
*/
public abstract class AbstractSourceButton extends Composite implements ClickHandler {
- protected Button button;
- private String sourceCodeURL;
+ protected Button button;
+ private String sourceCodeURL;
+
+ public AbstractSourceButton(String source) {
+ this.button = new Button(ShowcaseSearchPanel.I18N.viewSource(source), this);
- public AbstractSourceButton(String source) {
- this.button = new Button(ShowcaseSearchPanel.I18N.viewSource(source), this);
+ super.initWidget(button);
+ }
- super.initWidget(button);
- }
+ /**
+ * @param sourceCodeURL the sourceCodeURL to set
+ */
+ public void setSourceCodeURL(String sourceCodeURL) {
+ String[] sourceCodeURLParts = sourceCodeURL.split("/");
+ button.setText(button.getText() + " - " + sourceCodeURLParts[sourceCodeURLParts.length - 1].replace(".txt", ""));
+ this.sourceCodeURL = sourceCodeURL;
+ }
- /**
- * @param sourceCodeURL the sourceCodeURL to set
- */
- public void setSourceCodeURL(String sourceCodeURL) {
- String[] sourceCodeURLParts = sourceCodeURL.split("/");
- button.setText(button.getText() + " - " + sourceCodeURLParts[sourceCodeURLParts.length - 1].replace(".txt", ""));
- this.sourceCodeURL = sourceCodeURL;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom
+ * .client.ClickEvent)
+ */
+ public void onClick(ClickEvent event) {
+ RequestBuilder reqBuilder = new RequestBuilder(RequestBuilder.GET, this.sourceCodeURL);
+ try {
+ reqBuilder.sendRequest("", new RequestCallback() {
- /*
- * (non-Javadoc)
- *
- * @see
- * com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom
- * .client.ClickEvent)
- */
- public void onClick(ClickEvent event) {
- RequestBuilder reqBuilder = new RequestBuilder(RequestBuilder.GET, this.sourceCodeURL);
- try {
- reqBuilder.sendRequest("", new RequestCallback() {
+ public void onResponseReceived(Request request, Response response) {
+ showSourceCode(response.getText());
+ }
- public void onResponseReceived(Request request, Response response) {
- showSourceCode(response.getText());
- }
+ public void onError(Request request, Throwable exception) {
+ }
- public void onError(Request request, Throwable exception) {
+ });
+ } catch (RequestException ex) {
}
- });
- } catch (RequestException ex) {
}
- }
-
- protected native void doFormat() /*-{
- $wnd.SyntaxHighlighter.highlight();
- }-*/;
+ protected native void doFormat() /*-{
+ $wnd.SyntaxHighlighter.highlight();
+ }-*/;
- protected abstract void showSourceCode(String sourceCode);
+ protected abstract void showSourceCode(String sourceCode);
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/basic/ExampleConstants.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/basic/ExampleConstants.java
index 9cd78126de8cdb831c0a0261abf5a13f730bd828..3fea7c3cee76928cc6272fc64287b2fc84b094ad 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/basic/ExampleConstants.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/basic/ExampleConstants.java
@@ -1,23 +1,22 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase.basic;
public class ExampleConstants {
- public static final String METACARTA_WMS_URL = "http://labs.metacarta.com/wms/vmap0";
- public static final String METACARTA_WMS_BASIC_LAYER = "basic";
+ public static final String METACARTA_WMS_URL = "http://labs.metacarta.com/wms/vmap0";
+ public static final String METACARTA_WMS_BASIC_LAYER = "basic";
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/basic/ShowSourceButton.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/basic/ShowSourceButton.java
index b7c7b9f734729dca1a4e09e8da326f5b889f3aae..5b087a41ac08897b16859ba5b9d97a48fad93614 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/basic/ShowSourceButton.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/basic/ShowSourceButton.java
@@ -1,58 +1,54 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase.basic;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.ScrollPanel;
-
import org.cleanlogic.cesiumjs4gwt.showcase.DialogBoxWithCloseButton;
import org.cleanlogic.cesiumjs4gwt.showcase.components.ShowcaseSearchPanel;
/**
- *
* @author Frank Wynants
- *
* @author Giuseppe La Scaleia - CNR IMAA geoSDI Group
* @email giuseppe.lascaleia@geosdi.org
*/
public class ShowSourceButton extends AbstractSourceButton {
- private String source;
+ private final String source;
- public ShowSourceButton(String source) {
- super(source);
- this.source = source;
- }
+ public ShowSourceButton(String source) {
+ super(source);
+ this.source = source;
+ }
- protected void showSourceCode(String sourceCode) {
- sourceCode = sourceCode.replaceAll("<", "<,").replace(">", ">");
+ protected void showSourceCode(String sourceCode) {
+ sourceCode = sourceCode.replaceAll("<", "<,").replace(">", ">");
- final String html = "
" + sourceCode + "
";
- ScrollPanel sp = new ScrollPanel();
- sp.setSize((Window.getClientWidth() * 0.6) + "px", (Window.getClientHeight() * 0.7) + "px");
- sp.add(new HTML(html));
+ final String html = "" + sourceCode + "
";
+ ScrollPanel sp = new ScrollPanel();
+ sp.setSize((Window.getClientWidth() * 0.6) + "px", (Window.getClientHeight() * 0.7) + "px");
+ sp.add(new HTML(html));
- DialogBoxWithCloseButton dialogBox = new DialogBoxWithCloseButton(false);
- dialogBox.setWidget(sp);
- dialogBox.setText(ShowcaseSearchPanel.I18N.viewSource(source));
- dialogBox.center();
+ DialogBoxWithCloseButton dialogBox = new DialogBoxWithCloseButton(false);
+ dialogBox.setWidget(sp);
+ dialogBox.setText(ShowcaseSearchPanel.I18N.viewSource(source));
+ dialogBox.center();
- super.doFormat();
- }
+ super.doFormat();
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/IShowcaseExamplePanel.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/IShowcaseExamplePanel.java
index af5fd552baff0ba509b5eb9fdc90b4ca7ca6dc5c..c31d725993c01672fe558368777432902d2bea82 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/IShowcaseExamplePanel.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/IShowcaseExamplePanel.java
@@ -1,23 +1,21 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase.components;
import com.google.gwt.event.shared.HandlerRegistration;
-
import org.cleanlogic.cesiumjs4gwt.showcase.puregwt.handler.ExamplePanelBuildHandler;
/**
@@ -27,6 +25,6 @@ import org.cleanlogic.cesiumjs4gwt.showcase.puregwt.handler.ExamplePanelBuildHan
*/
public interface IShowcaseExamplePanel extends ExamplePanelBuildHandler {
- HandlerRegistration addShowcaseExamplePanelHandler();
+ HandlerRegistration addShowcaseExamplePanelHandler();
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/ShowcaseExamplePanel.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/ShowcaseExamplePanel.java
index 6c626dcf0a6b67a628dd0c51f7508c2f2d2969d3..d6baaa753488cb868725ee525f3ae7ed2c5dd2fb 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/ShowcaseExamplePanel.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/ShowcaseExamplePanel.java
@@ -1,18 +1,17 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase.components;
@@ -36,51 +35,51 @@ import org.cleanlogic.cesiumjs4gwt.showcase.puregwt.event.ExampleNumberEvent;
@Singleton
public class ShowcaseExamplePanel extends FlowPanel implements IShowcaseExamplePanel {
- private final ShowcaseExampleStore store;
- private final ShowcaseEventBus bus;
- private final ExampleNumberEvent event = new ExampleNumberEvent();
+ private final ShowcaseExampleStore store;
+ private final ShowcaseEventBus bus;
+ private final ExampleNumberEvent event = new ExampleNumberEvent();
- @Inject
- public ShowcaseExamplePanel(ShowcaseExampleStore theStore, ShowcaseEventBus theBus) {
- super.setWidth("100%");
- this.store = theStore;
- this.bus = theBus;
+ @Inject
+ public ShowcaseExamplePanel(ShowcaseExampleStore theStore, ShowcaseEventBus theBus) {
+ super.setWidth("100%");
+ this.store = theStore;
+ this.bus = theBus;
- addShowcaseExamplePanelHandler();
- }
+ addShowcaseExamplePanelHandler();
+ }
+
+ public void buildExamplePanel(String filter) {
+ super.clear();
- public void buildExamplePanel(String filter) {
- super.clear();
+ int numberOfExamples = 0;
- int numberOfExamples = 0;
+ for (ExampleBean example : store.getExamples()) {
+ boolean show = false;
+ String[] tags = example.getTags();
+ if ((filter == null) || (filter.trim().equals(""))) {
+ show = true;
+ } else {
+ for (String tag : tags) {
+ if (tag.trim().toLowerCase().contains(filter.trim().toLowerCase())) {
+ show = true;
+ break;
+ }
+ }
+ }
- for (ExampleBean example : store.getExamples()) {
- boolean show = false;
- String[] tags = example.getTags();
- if ((filter == null) || (filter.trim().equals(""))) {
- show = true;
- } else {
- for (String tag : tags) {
- if (tag.trim().toLowerCase().contains(filter.trim().toLowerCase())) {
- show = true;
- break;
- }
+ if (show) {
+ super.add(new ExamplePanel(example));
+ numberOfExamples++;
+ }
}
- }
- if (show) {
- super.add(new ExamplePanel(example));
- numberOfExamples++;
- }
+ this.event.setNumber(numberOfExamples);
+ this.bus.fireEvent(event);
}
- this.event.setNumber(numberOfExamples);
- this.bus.fireEvent(event);
- }
+ public final HandlerRegistration addShowcaseExamplePanelHandler() {
+ return this.bus.addHandler(TYPE, this);
- public final HandlerRegistration addShowcaseExamplePanelHandler() {
- return this.bus.addHandler(TYPE, this);
-
- }
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/ShowcaseSearchPanel.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/ShowcaseSearchPanel.java
index 9fd92d016798428ac779ec06cd590a9b9e922f37..62caa0d80ee08b496dbb2f5eb42fee0911aa13eb 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/ShowcaseSearchPanel.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/ShowcaseSearchPanel.java
@@ -1,40 +1,33 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase.components;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
import com.google.gwt.core.client.GWT;
-import com.google.gwt.event.dom.client.BlurEvent;
-import com.google.gwt.event.dom.client.BlurHandler;
-import com.google.gwt.event.dom.client.FocusEvent;
-import com.google.gwt.event.dom.client.FocusHandler;
-import com.google.gwt.event.dom.client.KeyUpEvent;
-import com.google.gwt.event.dom.client.KeyUpHandler;
+import com.google.gwt.event.dom.client.*;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;
-
import org.cleanlogic.cesiumjs4gwt.showcase.i18n.I18NMessages;
import org.cleanlogic.cesiumjs4gwt.showcase.puregwt.ShowcaseEventBus;
import org.cleanlogic.cesiumjs4gwt.showcase.puregwt.event.ExamplePanelBuildEvent;
import org.cleanlogic.cesiumjs4gwt.showcase.puregwt.handler.ExampleNumberHandler;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
/**
*
* @author Giuseppe La Scaleia - CNR IMAA geoSDI Group
@@ -43,64 +36,64 @@ import org.cleanlogic.cesiumjs4gwt.showcase.puregwt.handler.ExampleNumberHandler
@Singleton
public class ShowcaseSearchPanel extends HorizontalPanel implements ExampleNumberHandler {
- private ShowcaseEventBus bus;
- public static final I18NMessages I18N = (I18NMessages) GWT.create(I18NMessages.class);
- private final TextBox txtSearch = new TextBox();
- private final Label lblNumberOfExamples = new Label("(0)");
- private ExamplePanelBuildEvent buildEvent = new ExamplePanelBuildEvent();
+ public static final I18NMessages I18N = GWT.create(I18NMessages.class);
+ private final TextBox txtSearch = new TextBox();
+ private final Label lblNumberOfExamples = new Label("(0)");
+ private final ShowcaseEventBus bus;
+ private final ExamplePanelBuildEvent buildEvent = new ExamplePanelBuildEvent();
- @Inject
- public ShowcaseSearchPanel(ShowcaseEventBus theBus) {
- super.setSpacing(3);
- this.addComponents();
- this.bus = theBus;
+ @Inject
+ public ShowcaseSearchPanel(ShowcaseEventBus theBus) {
+ super.setSpacing(3);
+ this.addComponents();
+ this.bus = theBus;
- this.bus.addHandler(ExampleNumberHandler.TYPE, this);
- }
+ this.bus.addHandler(ExampleNumberHandler.TYPE, this);
+ }
- private void setTxtSearchProperties() {
- txtSearch.setText(I18N.filterByKeywords());
- txtSearch.setStyleName("emptytextbox");
+ private void setTxtSearchProperties() {
+ txtSearch.setText(I18N.filterByKeywords());
+ txtSearch.setStyleName("emptytextbox");
- txtSearch.addFocusHandler(new FocusHandler() {
- public void onFocus(FocusEvent event) {
- if (event.getSource() == txtSearch) {
- if (txtSearch.getText().equals(I18N.filterByKeywords())) {
- txtSearch.setText("");
- txtSearch.removeStyleName("emptytextbox");
- }
- }
- }
- });
+ txtSearch.addFocusHandler(new FocusHandler() {
+ public void onFocus(FocusEvent event) {
+ if (event.getSource() == txtSearch) {
+ if (txtSearch.getText().equals(I18N.filterByKeywords())) {
+ txtSearch.setText("");
+ txtSearch.removeStyleName("emptytextbox");
+ }
+ }
+ }
+ });
- txtSearch.addBlurHandler(new BlurHandler() {
- public void onBlur(BlurEvent event) {
- if (event.getSource() == txtSearch) {
- if (txtSearch.getText().trim().equals("")) {
- txtSearch.setText(I18N.filterByKeywords());
- txtSearch.addStyleName("emptytextbox");
- }
- }
- }
- });
- txtSearch.addKeyUpHandler(new KeyUpHandler() {
- public void onKeyUp(KeyUpEvent event) {
- if (event.getSource() == txtSearch) {
- buildEvent.setFilter(txtSearch.getText());
- bus.fireEvent(buildEvent);
- }
- }
- });
- }
+ txtSearch.addBlurHandler(new BlurHandler() {
+ public void onBlur(BlurEvent event) {
+ if (event.getSource() == txtSearch) {
+ if (txtSearch.getText().trim().equals("")) {
+ txtSearch.setText(I18N.filterByKeywords());
+ txtSearch.addStyleName("emptytextbox");
+ }
+ }
+ }
+ });
+ txtSearch.addKeyUpHandler(new KeyUpHandler() {
+ public void onKeyUp(KeyUpEvent event) {
+ if (event.getSource() == txtSearch) {
+ buildEvent.setFilter(txtSearch.getText());
+ bus.fireEvent(buildEvent);
+ }
+ }
+ });
+ }
- private void addComponents() {
- super.add(txtSearch);
- super.add(lblNumberOfExamples);
+ private void addComponents() {
+ super.add(txtSearch);
+ super.add(lblNumberOfExamples);
- this.setTxtSearchProperties();
- }
+ this.setTxtSearchProperties();
+ }
- public void updateExampleNumber(int number) {
- lblNumberOfExamples.setText("(" + number + ")");
- }
+ public void updateExampleNumber(int number) {
+ lblNumberOfExamples.setText("(" + number + ")");
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/ShowcaseTopPanel.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/ShowcaseTopPanel.java
index 1bbcae24470d850032001cfec702804f8f860c5c..be9d6b0389e54c3a9e3f6a779ed51caebce7ab9f 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/ShowcaseTopPanel.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/ShowcaseTopPanel.java
@@ -1,31 +1,26 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase.components;
+import com.google.gwt.safehtml.shared.SafeHtmlUtils;
+import com.google.gwt.user.client.ui.*;
+
import javax.inject.Inject;
import javax.inject.Singleton;
-import com.google.gwt.safehtml.shared.SafeHtmlUtils;
-import com.google.gwt.user.client.ui.Anchor;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.HasVerticalAlignment;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Image;
-
/**
*
* @author Giuseppe La Scaleia - CNR IMAA geoSDI Group
@@ -34,22 +29,22 @@ import com.google.gwt.user.client.ui.Image;
@Singleton
public class ShowcaseTopPanel extends HorizontalPanel {
- @Inject
- public ShowcaseTopPanel(Image logo, ShowcaseSearchPanel searchPanel) {
- super.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
- super.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
- super.setStyleName("top");
+ @Inject
+ public ShowcaseTopPanel(Image logo, ShowcaseSearchPanel searchPanel) {
+ super.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+ super.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
+ super.setStyleName("top");
- super.setSpacing(1);
+ super.setSpacing(1);
- logo.setSize("32px", "32px");
- super.add(logo);
- Anchor anchor = new Anchor();
- String text = "
";
- anchor.setHTML(SafeHtmlUtils.fromTrustedString(text));
- super.add(anchor);
- super.add(searchPanel);
+ logo.setSize("32px", "32px");
+ super.add(logo);
+ Anchor anchor = new Anchor();
+ String text = "";
+ anchor.setHTML(SafeHtmlUtils.fromTrustedString(text));
+ super.add(anchor);
+ super.add(searchPanel);
- super.setCellWidth(logo, "10px");
- }
+ super.setCellWidth(logo, "10px");
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/list/ULComponent.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/list/ULComponent.java
index ec1830f23379a39e4571370ec9908a8937d07484..117cc3968a7e8a36ddc8aed55e9e1d163b101d1d 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/list/ULComponent.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/list/ULComponent.java
@@ -1,18 +1,17 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase.components.list;
@@ -29,41 +28,14 @@ import com.google.gwt.user.client.ui.Widget;
*/
public class ULComponent extends ComplexPanel implements InsertPanel {
- public ULComponent() {
- setElement(Document.get().createULElement());
- }
-
- private LIComponent wrapWidget(Widget w) {
- LIComponent li = new LIComponent();
- li.add(w);
- return li;
- }
-
- /**
- * Adds a new child widget to the panel.
- *
- * @param w the widget to be added
- */
- @Override
- public void add(Widget w) {
- add(wrapWidget(w), (Element) getElement());
- }
-
- /**
- * Inserts a widget before the specified index.
- *
- * @param w the widget to be inserted
- * @param beforeIndex the index before which it will be inserted
- * @throws IndexOutOfBoundsException if beforeIndex
is out of range
- */
- public void insert(Widget w, int beforeIndex) {
- insert(wrapWidget(w), (Element) getElement(), beforeIndex, true);
- }
-
- private static class LIComponent extends ComplexPanel implements InsertPanel {
+ public ULComponent() {
+ setElement(Document.get().createULElement());
+ }
- protected LIComponent() {
- setElement(Document.get().createLIElement());
+ private LIComponent wrapWidget(Widget w) {
+ LIComponent li = new LIComponent();
+ li.add(w);
+ return li;
}
/**
@@ -73,22 +45,49 @@ public class ULComponent extends ComplexPanel implements InsertPanel {
*/
@Override
public void add(Widget w) {
- add(w, (Element) getElement());
+ add(wrapWidget(w), (Element) getElement());
}
/**
- * Inserts a child widget before the specified index. If the widget is already a
- * child of this panel, it will be moved to the specified index.
+ * Inserts a widget before the specified index.
*
- * @param w the child widget to be inserted
+ * @param w the widget to be inserted
* @param beforeIndex the index before which it will be inserted
* @throws IndexOutOfBoundsException if beforeIndex
is out of range
*/
- @Override
public void insert(Widget w, int beforeIndex) {
- insert(w, (Element) getElement(), beforeIndex, true);
+ insert(wrapWidget(w), (Element) getElement(), beforeIndex, true);
}
- }
+ private static class LIComponent extends ComplexPanel implements InsertPanel {
+
+ protected LIComponent() {
+ setElement(Document.get().createLIElement());
+ }
+
+ /**
+ * Adds a new child widget to the panel.
+ *
+ * @param w the widget to be added
+ */
+ @Override
+ public void add(Widget w) {
+ add(w, (Element) getElement());
+ }
+
+ /**
+ * Inserts a child widget before the specified index. If the widget is already a
+ * child of this panel, it will be moved to the specified index.
+ *
+ * @param w the child widget to be inserted
+ * @param beforeIndex the index before which it will be inserted
+ * @throws IndexOutOfBoundsException if beforeIndex
is out of range
+ */
+ @Override
+ public void insert(Widget w, int beforeIndex) {
+ insert(w, (Element) getElement(), beforeIndex, true);
+ }
+
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/responsibility/AllExamplesHandler.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/responsibility/AllExamplesHandler.java
index 9193850ddf3e0264820690d4f6f591715f8fc208..a17c4d0ae5c7c2a5e13b396b5fde2d4e9c7a4d13 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/responsibility/AllExamplesHandler.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/responsibility/AllExamplesHandler.java
@@ -1,23 +1,21 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase.components.responsibility;
import com.google.gwt.user.client.ui.RootPanel;
-
import org.cleanlogic.cesiumjs4gwt.showcase.puregwt.event.ExamplePanelBuildEvent;
/**
@@ -27,19 +25,19 @@ import org.cleanlogic.cesiumjs4gwt.showcase.puregwt.event.ExamplePanelBuildEvent
*/
public class AllExamplesHandler extends ShowcaseBuilderHandler {
- @Override
- protected void buildShowcase() {
- if (canBuildShowcase()) {
- RootPanel.get().add(injector.getShowcaseTopPanel());
- RootPanel.get().add(injector.getShowcaseExamplePanel());
+ @Override
+ protected void buildShowcase() {
+ if (canBuildShowcase()) {
+ RootPanel.get().add(injector.getShowcaseTopPanel());
+ RootPanel.get().add(injector.getShowcaseExamplePanel());
- injector.getEventBus().fireEvent(new ExamplePanelBuildEvent(""));
+ injector.getEventBus().fireEvent(new ExamplePanelBuildEvent(""));
+ }
}
- }
- @Override
- protected boolean canBuildShowcase() {
- return Boolean.TRUE;
- }
+ @Override
+ protected boolean canBuildShowcase() {
+ return Boolean.TRUE;
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/responsibility/BuilderManager.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/responsibility/BuilderManager.java
index 6cef10b5402f9ff411214808acc9f9b65823b26a..7906f25fddc6837ab816fceb18c62509bbf63b72 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/responsibility/BuilderManager.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/responsibility/BuilderManager.java
@@ -1,18 +1,17 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase.components.responsibility;
@@ -23,10 +22,10 @@ package org.cleanlogic.cesiumjs4gwt.showcase.components.responsibility;
*/
public class BuilderManager implements ShowcaseBuilderManager {
- private final ShowcaseBuilderHandler kvpHandler = new KvpParameterHandler();
+ private final ShowcaseBuilderHandler kvpHandler = new KvpParameterHandler();
- public void buildShowcase() {
- this.kvpHandler.buildShowcase();
- }
+ public void buildShowcase() {
+ this.kvpHandler.buildShowcase();
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/responsibility/KvpParameterHandler.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/responsibility/KvpParameterHandler.java
index f0c12f0e8067878749ffef8be4c8bfee6a4d26db..a1327a845ed9245003e88a9708d66d38df545712 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/responsibility/KvpParameterHandler.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/responsibility/KvpParameterHandler.java
@@ -1,24 +1,22 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase.components.responsibility;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RootPanel;
-
import org.cleanlogic.cesiumjs4gwt.showcase.ExampleBean;
/**
@@ -28,25 +26,25 @@ import org.cleanlogic.cesiumjs4gwt.showcase.ExampleBean;
*/
public class KvpParameterHandler extends ShowcaseBuilderHandler {
- public KvpParameterHandler() {
- super.setSuccessor(new AllExamplesHandler());
- }
+ public KvpParameterHandler() {
+ super.setSuccessor(new AllExamplesHandler());
+ }
- @Override
- protected void buildShowcase() {
- if (canBuildShowcase()) {
- ExampleBean exampleBean = injector.getExampleStore().getExample(Window.Location.getParameter("example"));
- exampleBean.getExample().buildPanel();
- RootPanel.get().add(exampleBean.getExample());
- } else {
- super.forwardBuildShowcase();
+ @Override
+ protected void buildShowcase() {
+ if (canBuildShowcase()) {
+ ExampleBean exampleBean = injector.getExampleStore().getExample(Window.Location.getParameter("example"));
+ exampleBean.getExample().buildPanel();
+ RootPanel.get().add(exampleBean.getExample());
+ } else {
+ super.forwardBuildShowcase();
+ }
}
- }
- @Override
- protected boolean canBuildShowcase() {
- return ((Window.Location.getParameter("example") != null)
- && (injector.getExampleStore().getExample(Window.Location.getParameter("example"))) != null);
- }
+ @Override
+ protected boolean canBuildShowcase() {
+ return ((Window.Location.getParameter("example") != null)
+ && (injector.getExampleStore().getExample(Window.Location.getParameter("example"))) != null);
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/responsibility/ShowcaseBuilderHandler.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/responsibility/ShowcaseBuilderHandler.java
index 333a62f48c462fa899105582d0dd03443046b7bf..523cf4c5197fd175bebd1c6246d26a7cb01fbb69 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/responsibility/ShowcaseBuilderHandler.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/responsibility/ShowcaseBuilderHandler.java
@@ -1,23 +1,21 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase.components.responsibility;
import com.google.gwt.core.client.GWT;
-
import org.cleanlogic.cesiumjs4gwt.showcase.config.Injector;
/**
@@ -27,29 +25,29 @@ import org.cleanlogic.cesiumjs4gwt.showcase.config.Injector;
*/
public abstract class ShowcaseBuilderHandler {
- static {
- injector = GWT.create(Injector.class);
- }
+ protected static final Injector injector;
- protected static final Injector injector;
+ static {
+ injector = GWT.create(Injector.class);
+ }
- private ShowcaseBuilderHandler successor;
+ private ShowcaseBuilderHandler successor;
- /**
- * @param theSuccessor the successor to set
- */
- public void setSuccessor(ShowcaseBuilderHandler theSuccessor) {
- this.successor = theSuccessor;
- }
+ /**
+ * @param theSuccessor the successor to set
+ */
+ public void setSuccessor(ShowcaseBuilderHandler theSuccessor) {
+ this.successor = theSuccessor;
+ }
- protected abstract void buildShowcase();
+ protected abstract void buildShowcase();
- protected void forwardBuildShowcase() {
- if (successor != null) {
- successor.buildShowcase();
+ protected void forwardBuildShowcase() {
+ if (successor != null) {
+ successor.buildShowcase();
+ }
}
- }
- protected abstract boolean canBuildShowcase();
+ protected abstract boolean canBuildShowcase();
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/responsibility/ShowcaseBuilderManager.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/responsibility/ShowcaseBuilderManager.java
index fb8ff3632b1e26330d9ab53ca93d11447f437417..3a7506e56d1674a1539c8ba5be52e174de086760 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/responsibility/ShowcaseBuilderManager.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/responsibility/ShowcaseBuilderManager.java
@@ -1,18 +1,17 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase.components.responsibility;
@@ -23,6 +22,6 @@ package org.cleanlogic.cesiumjs4gwt.showcase.components.responsibility;
*/
public interface ShowcaseBuilderManager {
- void buildShowcase();
+ void buildShowcase();
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/store/ExampleStore.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/store/ExampleStore.java
index 3db14122df713648c14871741d88d6a685b6b1d3..3859d3e22d40951346390ceff2c2d42d3ebbaf4a 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/store/ExampleStore.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/store/ExampleStore.java
@@ -1,25 +1,24 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase.components.store;
-import java.util.List;
-
import org.cleanlogic.cesiumjs4gwt.showcase.ExampleBean;
+import java.util.List;
+
/**
*
* @author Giuseppe La Scaleia - CNR IMAA geoSDI Group
@@ -27,10 +26,10 @@ import org.cleanlogic.cesiumjs4gwt.showcase.ExampleBean;
*/
public interface ExampleStore {
- void addExample(ExampleBean example);
+ void addExample(ExampleBean example);
- List getExamples();
+ List getExamples();
- ExampleBean getExample(String exampleName);
+ ExampleBean getExample(String exampleName);
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/store/ShowcaseExampleStore.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/store/ShowcaseExampleStore.java
index 9a63ab709692c09e2c9227fa8cdc1d5156d0984c..933b7365f8efc9e47ed70ffddc106c7fe519cf4f 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/store/ShowcaseExampleStore.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/components/store/ShowcaseExampleStore.java
@@ -1,30 +1,24 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase.components.store;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import org.cleanlogic.cesiumjs4gwt.showcase.ExampleBean;
import javax.inject.Singleton;
-
-import org.cleanlogic.cesiumjs4gwt.showcase.ExampleBean;
+import java.util.*;
/**
*
@@ -34,23 +28,23 @@ import org.cleanlogic.cesiumjs4gwt.showcase.ExampleBean;
@Singleton
public class ShowcaseExampleStore implements ExampleStore {
- private final Map examples = new HashMap();
+ private final Map examples = new HashMap();
+
+ public final void addExample(ExampleBean example) {
+ if (this.examples.containsValue(example)) {
+ throw new IllegalStateException("Example with Name : " + example.getName() + " already present in the Store");
+ }
+ this.examples.put(example.getName(), example);
+ }
+
+ public List getExamples() {
+ List list = new ArrayList(examples.values());
+ Collections.sort(list);
+ return Collections.unmodifiableList(list);
+ }
- public final void addExample(ExampleBean example) {
- if (this.examples.containsValue(example)) {
- throw new IllegalStateException("Example with Name : " + example.getName() + " already present in the Store");
+ public ExampleBean getExample(String exampleName) {
+ return this.examples.get(exampleName);
}
- this.examples.put(example.getName(), example);
- }
-
- public List getExamples() {
- List list = new ArrayList(examples.values());
- Collections.sort(list);
- return Collections.unmodifiableList(list);
- }
-
- public ExampleBean getExample(String exampleName) {
- return this.examples.get(exampleName);
- }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/config/Injector.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/config/Injector.java
index 961b95692e70a246bbcaf8124f5c50eb55ed3f98..d60a0e3bcdbf3ee84e9d0da284acfe94c1abe1be 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/config/Injector.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/config/Injector.java
@@ -1,25 +1,23 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase.config;
import com.google.gwt.core.client.GWT;
import com.google.gwt.inject.client.GinModules;
import com.google.gwt.inject.client.Ginjector;
-
import org.cleanlogic.cesiumjs4gwt.showcase.components.ShowcaseExamplePanel;
import org.cleanlogic.cesiumjs4gwt.showcase.components.ShowcaseSearchPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.components.ShowcaseTopPanel;
@@ -27,34 +25,33 @@ import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStor
import org.cleanlogic.cesiumjs4gwt.showcase.puregwt.ShowcaseEventBus;
/**
- *
* @author Giuseppe La Scaleia - CNR IMAA geoSDI Group
* @email giuseppe.lascaleia@geosdi.org
*/
-@GinModules(value = { InjectorModule.class })
+@GinModules(value = {InjectorModule.class})
public interface Injector extends Ginjector {
- public static class MainInjector {
+ ShowcaseEventBus getEventBus();
- private static final Injector instance = GWT.create(Injector.class);
+ ShowcaseExampleStore getExampleStore();
- private MainInjector() {
- }
+ ShowcaseSearchPanel getShowcaseSearchPanel();
- public static Injector getInstance() {
- return instance;
- }
+ ShowcaseTopPanel getShowcaseTopPanel();
- }
+ ShowcaseExamplePanel getShowcaseExamplePanel();
- public ShowcaseEventBus getEventBus();
+ class MainInjector {
- public ShowcaseExampleStore getExampleStore();
+ private static final Injector instance = GWT.create(Injector.class);
- public ShowcaseSearchPanel getShowcaseSearchPanel();
+ private MainInjector() {
+ }
- public ShowcaseTopPanel getShowcaseTopPanel();
+ public static Injector getInstance() {
+ return instance;
+ }
- public ShowcaseExamplePanel getShowcaseExamplePanel();
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/config/InjectorModule.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/config/InjectorModule.java
index 3660737db71491f75c098bafbc950d1c1e1ab5f0..8958a6cd63c309c79cf42730899adc32d6956bcc 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/config/InjectorModule.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/config/InjectorModule.java
@@ -1,123 +1,119 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase.config;
-import java.util.List;
-
-import javax.inject.Singleton;
-
import com.google.gwt.inject.client.AbstractGinModule;
import com.google.gwt.user.client.ui.Image;
-
import org.cleanlogic.cesiumjs4gwt.showcase.config.provider.ShowcaseBrandsProvider;
import org.cleanlogic.cesiumjs4gwt.showcase.config.provider.ShowcaseLogoProvider;
import org.cleanlogic.cesiumjs4gwt.showcase.examples.*;
import org.cleanlogic.cesiumjs4gwt.showcase.puregwt.ShowcaseEventBus;
import org.cleanlogic.cesiumjs4gwt.showcase.puregwt.ShowcaseEventBusImpl;
+import javax.inject.Singleton;
+import java.util.List;
+
/**
- *
* @author Giuseppe La Scaleia - CNR IMAA geoSDI Group
* @email giuseppe.lascaleia@geosdi.org
*/
public class InjectorModule extends AbstractGinModule {
- @Override
- protected void configure() {
- bind(ShowcaseEventBus.class).to(ShowcaseEventBusImpl.class).in(Singleton.class);
+ @Override
+ protected void configure() {
+ bind(ShowcaseEventBus.class).to(ShowcaseEventBusImpl.class).in(Singleton.class);
- bind(Image.class).toProvider(ShowcaseLogoProvider.class).in(Singleton.class);
- bind(List.class).toProvider(ShowcaseBrandsProvider.class).in(Singleton.class);
+ bind(Image.class).toProvider(ShowcaseLogoProvider.class).in(Singleton.class);
+ bind(List.class).toProvider(ShowcaseBrandsProvider.class).in(Singleton.class);
- bind(GeometryAndAppearances.class).asEagerSingleton();
- bind(HelloWorld.class).asEagerSingleton();
- bind(Billboards.class).asEagerSingleton();
- bind(Models3D.class).asEagerSingleton();
- bind(Models3DColoring.class).asEagerSingleton();
- bind(SkyAtmosphere.class).asEagerSingleton();
- bind(Terrain.class).asEagerSingleton();
- bind(Picking.class).asEagerSingleton();
- bind(Camera.class).asEagerSingleton();
- bind(ImageryLayersManipulation.class).asEagerSingleton();
- bind(SpheresAndEllipsoids.class).asEagerSingleton();
- bind(GeoJSONAndTopoJSON.class).asEagerSingleton();
- bind(GeoJSONsimplestyle.class).asEagerSingleton();
- bind(Interpolation.class).asEagerSingleton();
- bind(Shadows.class).asEagerSingleton();
- bind(Clustering.class).asEagerSingleton();
- bind(CZML.class).asEagerSingleton();
- bind(CameraTutorial.class).asEagerSingleton();
- bind(CesiumInspector.class).asEagerSingleton();
- bind(Cardboard.class).asEagerSingleton();
- bind(ImageryAdjustment.class).asEagerSingleton();
- bind(ImageryLayers.class).asEagerSingleton();
- bind(KML.class).asEagerSingleton();
- bind(Materials.class).asEagerSingleton();
- bind(Labels.class).asEagerSingleton();
- bind(CustomGeocoder.class).asEagerSingleton();
- bind(CesiumNavigation.class).asEagerSingleton();
- bind(PolylineDash.class).asEagerSingleton();
- bind(GoogleEarthEnterprise.class).asEagerSingleton();
- bind(HeadingPitchRoll.class).asEagerSingleton();
- bind(ImageryLayersSplit.class).asEagerSingleton();
- bind(ParticleSystemFireworks.class).asEagerSingleton();
- bind(ParticleSystem.class).asEagerSingleton();
- bind(Drawing.class).asEagerSingleton();
- bind(Tiles3DFeaturePicking.class).asEagerSingleton();
- bind(Tiles3DBIM.class).asEagerSingleton();
- bind(Tiles3DPointCloud.class).asEagerSingleton();
- bind(Tiles3DInterior.class).asEagerSingleton();
- bind(Tiles3DPhotogrammetry.class).asEagerSingleton();
- bind(Tiles3DInspector.class).asEagerSingleton();
- bind(LoadImages.class).asEagerSingleton();
- bind(TerrainClippingPlanes.class).asEagerSingleton();
- bind(Tiles3DClippingPlanes.class).asEagerSingleton();
- bind(CustomBaseLayerPicker.class).asEagerSingleton();
- bind(CustomHomeButton.class).asEagerSingleton();
- bind(PolylineArrow.class).asEagerSingleton();
- bind(CallbackProperty.class).asEagerSingleton();
- bind(PostProcessing.class).asEagerSingleton();
- bind(AmbientOcclusion.class).asEagerSingleton();
- bind(Bloom.class).asEagerSingleton();
- bind(CustomPostProcess.class).asEagerSingleton();
- bind(DepthOfField.class).asEagerSingleton();
- bind(LensFlare.class).asEagerSingleton();
- bind(CustomPerFeaturePostProcess.class).asEagerSingleton();
- bind(PerFeaturePostProcessing.class).asEagerSingleton();
- bind(GroundPolylinePrimitive.class).asEagerSingleton();
- bind(DrawingOnTerrain.class).asEagerSingleton();
- bind(GeometryHeightReference.class).asEagerSingleton();
- bind(MultipleSyncedViews.class).asEagerSingleton();
- bind(TimeDynamicPointCloud.class).asEagerSingleton();
- bind(GroundAtmosphere.class).asEagerSingleton();
- bind(CartographicLimitRectangle.class).asEagerSingleton();
- bind(Clampto3DModel.class).asEagerSingleton();
- bind(Clampto3DTiles.class).asEagerSingleton();
- bind(ClamptoTerrain.class).asEagerSingleton();
- bind(ImageryCutout.class).asEagerSingleton();
- bind(SampleHeightFrom3DTiles.class).asEagerSingleton();
- bind(ImageBasedLighting.class).asEagerSingleton();
- bind(PolylinesOn3DTiles.class).asEagerSingleton();
- bind(TimeDynamicWheels.class).asEagerSingleton();
- bind(ImageryColorToAlpha.class).asEagerSingleton();
- bind(ExportKML.class).asEagerSingleton();
- bind(ArcGISTiledElevationTerrain.class).asEagerSingleton();
- bind(CZMLModelArticulations.class).asEagerSingleton();
+ bind(GeometryAndAppearances.class).asEagerSingleton();
+ bind(HelloWorld.class).asEagerSingleton();
+ bind(Billboards.class).asEagerSingleton();
+ bind(Models3D.class).asEagerSingleton();
+ bind(Models3DColoring.class).asEagerSingleton();
+ bind(SkyAtmosphere.class).asEagerSingleton();
+ bind(Terrain.class).asEagerSingleton();
+ bind(Picking.class).asEagerSingleton();
+ bind(Camera.class).asEagerSingleton();
+ bind(ImageryLayersManipulation.class).asEagerSingleton();
+ bind(SpheresAndEllipsoids.class).asEagerSingleton();
+ bind(GeoJSONAndTopoJSON.class).asEagerSingleton();
+ bind(GeoJSONsimplestyle.class).asEagerSingleton();
+ bind(Interpolation.class).asEagerSingleton();
+ bind(Shadows.class).asEagerSingleton();
+ bind(Clustering.class).asEagerSingleton();
+ bind(CZML.class).asEagerSingleton();
+ bind(CameraTutorial.class).asEagerSingleton();
+ bind(CesiumInspector.class).asEagerSingleton();
+ bind(Cardboard.class).asEagerSingleton();
+ bind(ImageryAdjustment.class).asEagerSingleton();
+ bind(ImageryLayers.class).asEagerSingleton();
+ bind(KML.class).asEagerSingleton();
+ bind(Materials.class).asEagerSingleton();
+ bind(Labels.class).asEagerSingleton();
+ bind(CustomGeocoder.class).asEagerSingleton();
+ bind(CesiumNavigation.class).asEagerSingleton();
+ bind(PolylineDash.class).asEagerSingleton();
+ bind(GoogleEarthEnterprise.class).asEagerSingleton();
+ bind(HeadingPitchRoll.class).asEagerSingleton();
+ bind(ImageryLayersSplit.class).asEagerSingleton();
+ bind(ParticleSystemFireworks.class).asEagerSingleton();
+ bind(ParticleSystem.class).asEagerSingleton();
+ bind(Drawing.class).asEagerSingleton();
+ bind(Tiles3DFeaturePicking.class).asEagerSingleton();
+ bind(Tiles3DBIM.class).asEagerSingleton();
+ bind(Tiles3DPointCloud.class).asEagerSingleton();
+ bind(Tiles3DInterior.class).asEagerSingleton();
+ bind(Tiles3DPhotogrammetry.class).asEagerSingleton();
+ bind(Tiles3DInspector.class).asEagerSingleton();
+ bind(LoadImages.class).asEagerSingleton();
+ bind(TerrainClippingPlanes.class).asEagerSingleton();
+ bind(Tiles3DClippingPlanes.class).asEagerSingleton();
+ bind(CustomBaseLayerPicker.class).asEagerSingleton();
+ bind(CustomHomeButton.class).asEagerSingleton();
+ bind(PolylineArrow.class).asEagerSingleton();
+ bind(CallbackProperty.class).asEagerSingleton();
+ bind(PostProcessing.class).asEagerSingleton();
+ bind(AmbientOcclusion.class).asEagerSingleton();
+ bind(Bloom.class).asEagerSingleton();
+ bind(CustomPostProcess.class).asEagerSingleton();
+ bind(DepthOfField.class).asEagerSingleton();
+ bind(LensFlare.class).asEagerSingleton();
+ bind(CustomPerFeaturePostProcess.class).asEagerSingleton();
+ bind(PerFeaturePostProcessing.class).asEagerSingleton();
+ bind(GroundPolylinePrimitive.class).asEagerSingleton();
+ bind(DrawingOnTerrain.class).asEagerSingleton();
+ bind(GeometryHeightReference.class).asEagerSingleton();
+ bind(MultipleSyncedViews.class).asEagerSingleton();
+ bind(TimeDynamicPointCloud.class).asEagerSingleton();
+ bind(GroundAtmosphere.class).asEagerSingleton();
+ bind(CartographicLimitRectangle.class).asEagerSingleton();
+ bind(Clampto3DModel.class).asEagerSingleton();
+ bind(Clampto3DTiles.class).asEagerSingleton();
+ bind(ClamptoTerrain.class).asEagerSingleton();
+ bind(ImageryCutout.class).asEagerSingleton();
+ bind(SampleHeightFrom3DTiles.class).asEagerSingleton();
+ bind(ImageBasedLighting.class).asEagerSingleton();
+ bind(PolylinesOn3DTiles.class).asEagerSingleton();
+ bind(TimeDynamicWheels.class).asEagerSingleton();
+ bind(ImageryColorToAlpha.class).asEagerSingleton();
+ bind(ExportKML.class).asEagerSingleton();
+ bind(ArcGISTiledElevationTerrain.class).asEagerSingleton();
+ bind(CZMLModelArticulations.class).asEagerSingleton();
- bind(ElevationBandMaterial.class).asEagerSingleton();
- }
+ bind(ElevationBandMaterial.class).asEagerSingleton();
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/config/provider/ShowcaseBrandsProvider.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/config/provider/ShowcaseBrandsProvider.java
index c695753ba591c65e1af94b0a66abf899a936b6b6..513c608ffb282c89af40ffb101224b7d5c1bd693 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/config/provider/ShowcaseBrandsProvider.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/config/provider/ShowcaseBrandsProvider.java
@@ -5,24 +5,22 @@
*/
package org.cleanlogic.cesiumjs4gwt.showcase.config.provider;
-import java.util.ArrayList;
-import java.util.List;
+import com.google.gwt.user.client.ui.Anchor;
import javax.inject.Provider;
-
-import com.google.gwt.user.client.ui.Anchor;
+import java.util.ArrayList;
+import java.util.List;
/**
- *
* @author iserge
*/
public class ShowcaseBrandsProvider implements Provider> {
- @Override
- public List get() {
- Anchor anchor = new Anchor("Ol3-Cesium");
- List list = new ArrayList();
- list.add(anchor);
- return list;
- }
+ @Override
+ public List get() {
+ Anchor anchor = new Anchor("Ol3-Cesium");
+ List list = new ArrayList();
+ list.add(anchor);
+ return list;
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/config/provider/ShowcaseLogoProvider.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/config/provider/ShowcaseLogoProvider.java
index 47444ce2d63410362088a7c782d96fab02174fc6..f80b4c3a0385a922c955dabdf846621465b2782b 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/config/provider/ShowcaseLogoProvider.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/config/provider/ShowcaseLogoProvider.java
@@ -1,35 +1,32 @@
/**
- *
- * Copyright 2015 sourceforge.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Copyright 2015 sourceforge.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.cleanlogic.cesiumjs4gwt.showcase.config.provider;
-import javax.inject.Provider;
-
import com.google.gwt.user.client.ui.Image;
-
import org.cleanlogic.cesiumjs4gwt.showcase.Resources;
+import javax.inject.Provider;
+
/**
- *
* @author Giuseppe La Scaleia - CNR IMAA geoSDI Group
* @email giuseppe.lascaleia@geosdi.org
*/
public class ShowcaseLogoProvider implements Provider {
- public Image get() {
- return new Image(Resources.INSTANCE.gwtCsLogo());
- }
+ public Image get() {
+ return new Image(Resources.INSTANCE.gwtCsLogo());
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/AmbientOcclusion.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/AmbientOcclusion.java
index bc4c149f7cee75059e629636b451249bb3059af9..3f46f61cc73e217104319315920063d6c1b5f38c 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/AmbientOcclusion.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/AmbientOcclusion.java
@@ -23,7 +23,6 @@ import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
-import javax.inject.Inject;
import org.cesiumjs.cs.Cesium;
import org.cesiumjs.cs.core.Cartesian3;
import org.cesiumjs.cs.core.IonResource;
@@ -37,153 +36,155 @@ import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class AmbientOcclusion extends AbstractExample {
- private ViewerPanel csVPanel;
-
- private CheckBox ambientOcclusionCBox;
- private CheckBox ambientOcclusionOnlyCBox;
- private Slider intensitySlider;
- private Slider lengthCapSlider;
- private Slider stepSizeSlider;
- private Slider biasSlider;
- private Slider blurStepSize;
-
- @Inject
- public AmbientOcclusion(ShowcaseExampleStore store) {
- super("Ambient Occlusion", "Ambient Occlusion", new String[] {
- "Showcase", "Cesium", "3d", "Post processing"
- }, store);
- }
-
- @Override
- public void buildPanel() {
- csVPanel = new ViewerPanel();
-
- if (!PostProcessStageLibrary.isAmbientOcclusionSupported(csVPanel.getViewer().scene())) {
- Cesium.log("This browser does not support the ambient occlusion post process.");
+ private ViewerPanel csVPanel;
+
+ private CheckBox ambientOcclusionCBox;
+ private CheckBox ambientOcclusionOnlyCBox;
+ private Slider intensitySlider;
+ private Slider lengthCapSlider;
+ private Slider stepSizeSlider;
+ private Slider biasSlider;
+ private Slider blurStepSize;
+
+ @Inject
+ public AmbientOcclusion(ShowcaseExampleStore store) {
+ super("Ambient Occlusion", "Ambient Occlusion", new String[]{
+ "Showcase", "Cesium", "3d", "Post processing"
+ }, store);
}
- // Power Plant design model provided by Bentley Systems
- Cesium3DTileset tileset = Cesium3DTileset.create(IonResource.fromAssetId(3837));
- tileset.readyPromise().then(
- value -> csVPanel.getViewer().scene().primitives().add(value),
- value -> Cesium.log("Error load tileset")
- );
-
- ambientOcclusionCBox = new CheckBox();
- ambientOcclusionCBox.setValue(true);
- ambientOcclusionCBox.addValueChangeHandler(new MValueChangeHandler());
-
- ambientOcclusionOnlyCBox = new CheckBox();
- ambientOcclusionOnlyCBox.setValue(false);
- ambientOcclusionOnlyCBox.addValueChangeHandler(new MValueChangeHandler());
-
- intensitySlider = new Slider("intensitySlider", 1, 10, 3);
- intensitySlider.setStep(1);
- intensitySlider.setWidth("150px");
- intensitySlider.addListener(new MSliderListener());
-
- lengthCapSlider = new Slider("lengthCapSlider", 0, 100, 3);
- lengthCapSlider.setStep(1);
- lengthCapSlider.setWidth("150px");
- lengthCapSlider.addListener(new MSliderListener());
-
- stepSizeSlider = new Slider("stepSizeSlider", 100, 1000, 1);
- stepSizeSlider.setStep(1);
- stepSizeSlider.setWidth("150px");
- stepSizeSlider.addListener(new MSliderListener());
-
- biasSlider = new Slider("biasSlider", 0, 100, 1);
- biasSlider.setStep(1);
- biasSlider.setWidth("150px");
- biasSlider.addListener(new MSliderListener());
-
- blurStepSize = new Slider("blurStepSize", 0, 400, 86);
- blurStepSize.setStep(1);
- blurStepSize.setWidth("150px");
- blurStepSize.addListener(new MSliderListener());
-
- FlexTable flexTable = new FlexTable();
- flexTable.setHTML(1, 0, "Ambient Occlusion");
- flexTable.setWidget(1, 1, ambientOcclusionCBox);
- flexTable.setHTML(2, 0, "Ambient Occlusion Only");
- flexTable.setWidget(2, 1, ambientOcclusionOnlyCBox);
- flexTable.setHTML(3, 0, "Intensity");
- flexTable.setWidget(3, 1, intensitySlider);
- flexTable.setHTML(4, 0, "Length Cap");
- flexTable.setWidget(4, 1, lengthCapSlider);
- flexTable.setHTML(5, 0, "Step Size");
- flexTable.setWidget(5, 1, stepSizeSlider);
- flexTable.setHTML(6, 0, "Bias");
- flexTable.setWidget(6, 1, biasSlider);
- flexTable.setHTML(7, 0, "Blur Step Size");
- flexTable.setWidget(7, 1, blurStepSize);
-
- AbsolutePanel absPanel = new AbsolutePanel();
- absPanel.add(csVPanel);
- absPanel.add(flexTable, 20, 20);
-
- contentPanel.add(new HTML("Post processing effects.
"));
- contentPanel.add(absPanel);
-
- initWidget(contentPanel);
- updatePostProcess();
-
- org.cesiumjs.cs.scene.Camera camera = csVPanel.getViewer().scene().camera();
- camera.position = new Cartesian3(1234127.2294710164, -5086011.666443127, 3633337.0413351045);
- camera.direction = new Cartesian3(-0.5310064396211631, -0.30299013818088416, -0.7913464078682514);
- camera.right = new Cartesian3(-0.8468592075426076, 0.1574051185945647, 0.507989282604011);
- camera.up = Cartesian3.cross(camera.right, camera.direction, new Cartesian3());
- }
-
- private void updatePostProcess() {
- PostProcessStageComposite ambientOcclusion = csVPanel.getViewer().scene().postProcessStages.ambientOcclusion();
- ambientOcclusion.enabled = ambientOcclusionCBox.getValue() || ambientOcclusionOnlyCBox.getValue();
- ambientOcclusion.uniforms.setProperty("ambientOcclusionOnly", ambientOcclusionOnlyCBox.getValue());
- ambientOcclusion.uniforms.setProperty("intensity", intensitySlider.getValue());
- ambientOcclusion.uniforms.setProperty("bias", biasSlider.getValue() / 100.0);
- ambientOcclusion.uniforms.setProperty("lengthCap", lengthCapSlider.getValue() / 100.0);
- ambientOcclusion.uniforms.setProperty("stepSize", stepSizeSlider.getValue() / 100.0);
- ambientOcclusion.uniforms.setProperty("blurStepSize", blurStepSize.getValue() / 100.0);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "AmbientOcclusion.txt";
- return sourceCodeURLs;
- }
-
- private class MValueChangeHandler implements ValueChangeHandler {
@Override
- public void onValueChange(ValueChangeEvent event) {
- updatePostProcess();
+ public void buildPanel() {
+ csVPanel = new ViewerPanel();
+
+ if (!PostProcessStageLibrary.isAmbientOcclusionSupported(csVPanel.getViewer().scene())) {
+ Cesium.log("This browser does not support the ambient occlusion post process.");
+ }
+
+ // Power Plant design model provided by Bentley Systems
+ Cesium3DTileset tileset = Cesium3DTileset.create(IonResource.fromAssetId(3837));
+ tileset.readyPromise().then(
+ value -> csVPanel.getViewer().scene().primitives().add(value),
+ value -> Cesium.log("Error load tileset")
+ );
+
+ ambientOcclusionCBox = new CheckBox();
+ ambientOcclusionCBox.setValue(true);
+ ambientOcclusionCBox.addValueChangeHandler(new MValueChangeHandler());
+
+ ambientOcclusionOnlyCBox = new CheckBox();
+ ambientOcclusionOnlyCBox.setValue(false);
+ ambientOcclusionOnlyCBox.addValueChangeHandler(new MValueChangeHandler());
+
+ intensitySlider = new Slider("intensitySlider", 1, 10, 3);
+ intensitySlider.setStep(1);
+ intensitySlider.setWidth("150px");
+ intensitySlider.addListener(new MSliderListener());
+
+ lengthCapSlider = new Slider("lengthCapSlider", 0, 100, 3);
+ lengthCapSlider.setStep(1);
+ lengthCapSlider.setWidth("150px");
+ lengthCapSlider.addListener(new MSliderListener());
+
+ stepSizeSlider = new Slider("stepSizeSlider", 100, 1000, 1);
+ stepSizeSlider.setStep(1);
+ stepSizeSlider.setWidth("150px");
+ stepSizeSlider.addListener(new MSliderListener());
+
+ biasSlider = new Slider("biasSlider", 0, 100, 1);
+ biasSlider.setStep(1);
+ biasSlider.setWidth("150px");
+ biasSlider.addListener(new MSliderListener());
+
+ blurStepSize = new Slider("blurStepSize", 0, 400, 86);
+ blurStepSize.setStep(1);
+ blurStepSize.setWidth("150px");
+ blurStepSize.addListener(new MSliderListener());
+
+ FlexTable flexTable = new FlexTable();
+ flexTable.setHTML(1, 0, "Ambient Occlusion");
+ flexTable.setWidget(1, 1, ambientOcclusionCBox);
+ flexTable.setHTML(2, 0, "Ambient Occlusion Only");
+ flexTable.setWidget(2, 1, ambientOcclusionOnlyCBox);
+ flexTable.setHTML(3, 0, "Intensity");
+ flexTable.setWidget(3, 1, intensitySlider);
+ flexTable.setHTML(4, 0, "Length Cap");
+ flexTable.setWidget(4, 1, lengthCapSlider);
+ flexTable.setHTML(5, 0, "Step Size");
+ flexTable.setWidget(5, 1, stepSizeSlider);
+ flexTable.setHTML(6, 0, "Bias");
+ flexTable.setWidget(6, 1, biasSlider);
+ flexTable.setHTML(7, 0, "Blur Step Size");
+ flexTable.setWidget(7, 1, blurStepSize);
+
+ AbsolutePanel absPanel = new AbsolutePanel();
+ absPanel.add(csVPanel);
+ absPanel.add(flexTable, 20, 20);
+
+ contentPanel.add(new HTML("Post processing effects.
"));
+ contentPanel.add(absPanel);
+
+ initWidget(contentPanel);
+ updatePostProcess();
+
+ org.cesiumjs.cs.scene.Camera camera = csVPanel.getViewer().scene().camera();
+ camera.position = new Cartesian3(1234127.2294710164, -5086011.666443127, 3633337.0413351045);
+ camera.direction = new Cartesian3(-0.5310064396211631, -0.30299013818088416, -0.7913464078682514);
+ camera.right = new Cartesian3(-0.8468592075426076, 0.1574051185945647, 0.507989282604011);
+ camera.up = Cartesian3.cross(camera.right, camera.direction, new Cartesian3());
}
- }
- private class MSliderListener implements SliderListener {
- @Override
- public void onStart(SliderEvent e) {
- //
+ private void updatePostProcess() {
+ PostProcessStageComposite ambientOcclusion = csVPanel.getViewer().scene().postProcessStages.ambientOcclusion();
+ ambientOcclusion.enabled = ambientOcclusionCBox.getValue() || ambientOcclusionOnlyCBox.getValue();
+ ambientOcclusion.uniforms.setProperty("ambientOcclusionOnly", ambientOcclusionOnlyCBox.getValue());
+ ambientOcclusion.uniforms.setProperty("intensity", intensitySlider.getValue());
+ ambientOcclusion.uniforms.setProperty("bias", biasSlider.getValue() / 100.0);
+ ambientOcclusion.uniforms.setProperty("lengthCap", lengthCapSlider.getValue() / 100.0);
+ ambientOcclusion.uniforms.setProperty("stepSize", stepSizeSlider.getValue() / 100.0);
+ ambientOcclusion.uniforms.setProperty("blurStepSize", blurStepSize.getValue() / 100.0);
}
@Override
- public boolean onSlide(SliderEvent e) {
- updatePostProcess();
- return true;
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "AmbientOcclusion.txt";
+ return sourceCodeURLs;
}
- @Override
- public void onChange(SliderEvent e) {
- //
+ private class MValueChangeHandler implements ValueChangeHandler {
+ @Override
+ public void onValueChange(ValueChangeEvent event) {
+ updatePostProcess();
+ }
}
- @Override
- public void onStop(SliderEvent e) {
- //
+ private class MSliderListener implements SliderListener {
+ @Override
+ public void onStart(SliderEvent e) {
+ //
+ }
+
+ @Override
+ public boolean onSlide(SliderEvent e) {
+ updatePostProcess();
+ return true;
+ }
+
+ @Override
+ public void onChange(SliderEvent e) {
+ //
+ }
+
+ @Override
+ public void onStop(SliderEvent e) {
+ //
+ }
}
- }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ArcGISTiledElevationTerrain.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ArcGISTiledElevationTerrain.java
index 2c3540b1ddd50518d80b25740029bfaa231d5f79..584a9066eab7cbcf43bb3bdde8a76482df5a2678 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ArcGISTiledElevationTerrain.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ArcGISTiledElevationTerrain.java
@@ -16,11 +16,8 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.HTML;
-
import org.cesiumjs.cs.core.providers.ArcGISTiledElevationTerrainProvider;
import org.cesiumjs.cs.core.providers.options.ArcGISTiledElevationTerrainProviderOptions;
import org.cesiumjs.cs.widgets.ViewerPanel;
@@ -28,34 +25,36 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class ArcGISTiledElevationTerrain extends AbstractExample {
- @Inject
- public ArcGISTiledElevationTerrain(ShowcaseExampleStore store) {
- super("ArcGIS Tiled Elevation Terrain", "Add terrain from an ArcGIS Server.", new String[] { "Terrain", "ArcGIS" },
- store);
- }
-
- @Override
- public void buildPanel() {
- ViewerOptions options = new ViewerOptions();
- options.terrainProvider = new ArcGISTiledElevationTerrainProvider(ArcGISTiledElevationTerrainProviderOptions
- .create("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"));
- ViewerPanel csVPanel = new ViewerPanel(options);
-
- contentPanel.add(new HTML("Add terrain from an ArcGIS Server.
"));
- contentPanel.add(csVPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ArcGISTiledElevationTerrain.txt";
- return sourceCodeURLs;
- }
+ @Inject
+ public ArcGISTiledElevationTerrain(ShowcaseExampleStore store) {
+ super("ArcGIS Tiled Elevation Terrain", "Add terrain from an ArcGIS Server.", new String[]{"Terrain", "ArcGIS"},
+ store);
+ }
+
+ @Override
+ public void buildPanel() {
+ ViewerOptions options = new ViewerOptions();
+ options.terrainProvider = new ArcGISTiledElevationTerrainProvider(ArcGISTiledElevationTerrainProviderOptions
+ .create("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"));
+ ViewerPanel csVPanel = new ViewerPanel(options);
+
+ contentPanel.add(new HTML("Add terrain from an ArcGIS Server.
"));
+ contentPanel.add(csVPanel);
+
+ initWidget(contentPanel);
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ArcGISTiledElevationTerrain.txt";
+ return sourceCodeURLs;
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Billboards.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Billboards.java
index a747b4399c336fd9f85b96a8ce2a10c7152125ff..537fa9afd9b4f617761bfccba6463d4d4a51c2a4 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Billboards.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Billboards.java
@@ -16,22 +16,14 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.ListBox;
-
-import org.cesiumjs.cs.core.BoundingRectangle;
-import org.cesiumjs.cs.core.Cartesian2;
-import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.Color;
import org.cesiumjs.cs.core.Math;
-import org.cesiumjs.cs.core.NearFarScalar;
-import org.cesiumjs.cs.core.Resource;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.datasources.Entity;
import org.cesiumjs.cs.datasources.graphics.BillboardGraphics;
import org.cesiumjs.cs.datasources.graphics.options.BillboardGraphicsOptions;
@@ -39,294 +31,294 @@ import org.cesiumjs.cs.datasources.options.EntityOptions;
import org.cesiumjs.cs.datasources.properties.ConstantPositionProperty;
import org.cesiumjs.cs.datasources.properties.ConstantProperty;
import org.cesiumjs.cs.js.JsImage;
-import org.cesiumjs.cs.promise.Fulfill;
-import org.cesiumjs.cs.promise.Reject;
import org.cesiumjs.cs.scene.enums.HorizontalOrigin;
import org.cesiumjs.cs.scene.enums.VerticalOrigin;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class Billboards extends AbstractExample {
- ViewerPanel csVPanel;
-
- @Inject
- public Billboards(ShowcaseExampleStore store) {
- super("Billboards", "Add billboard images and markers to the scene",
- new String[] { "Showcase", "Cesium", "3d", "Billboards", "Promise" }, store);
- }
-
- @Override
- public void buildPanel() {
- csVPanel = new ViewerPanel();
- addBillboard();
-
- ListBox billboardsLBox = new ListBox();
- billboardsLBox.addItem("Add billboard", "0");
- billboardsLBox.addItem("Set billboard properties at creation", "1");
- billboardsLBox.addItem("Change billboard properties", "2");
- billboardsLBox.addItem("Size billboard in meters", "3");
- billboardsLBox.addItem("Add multiple billboards", "4");
- billboardsLBox.addItem("Scale by viewer distance", "5");
- billboardsLBox.addItem("Fade by viewer distance", "6");
- billboardsLBox.addItem("Offset by viewer distance", "7");
- billboardsLBox.addItem("Add marker billboards", "8");
- billboardsLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent changeEvent) {
- ListBox source = (ListBox) changeEvent.getSource();
- reset();
- switch (source.getSelectedValue()) {
- case "0":
- addBillboard();
- break;
- case "1":
- setBillboardProperties();
- break;
- case "2":
- changeBillboardProperties();
- break;
- case "3":
- sizeBillboardInMeters();
- break;
- case "4":
- addMultipleBillboards();
- break;
- case "5":
- scaleByDistance();
- break;
- case "6":
- fadeByDistance();
- break;
- case "7":
- offsetByDistance();
- break;
- case "8":
- addMarkerBillboards();
- default:
- break;
- }
- }
- });
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(billboardsLBox, 20, 20);
-
- contentPanel.add(new HTML("Add billboard images and markers to the scene.
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Billboards.txt";
- return sourceCodeURLs;
- }
-
- private void addBillboard() {
- BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png");
- BillboardGraphics billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
- entityOptions.billboard = billboardGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
- }
-
- private void setBillboardProperties() {
- BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png"); // default:
- // undefined
- billboardGraphicsOptions.show = new ConstantProperty<>(true); // default
- billboardGraphicsOptions.pixelOffset = new ConstantProperty<>(new Cartesian2(0, -50)); // default: (0, 0)
- billboardGraphicsOptions.eyeOffset = new ConstantProperty<>(new Cartesian3(0, 0, 0)); // default
- billboardGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.CENTER());// default
- billboardGraphicsOptions.verticalOrigin = new ConstantProperty<>(VerticalOrigin.BOTTOM()); // default: CENTER
- billboardGraphicsOptions.scale = new ConstantProperty<>(2.0); // default: 1.0
- billboardGraphicsOptions.color = new ConstantProperty<>(Color.LIME()); // default: WHITE
- billboardGraphicsOptions.rotation = new ConstantProperty<>(Math.PI_OVER_FOUR()); // default: 0.0
- billboardGraphicsOptions.alignedAxis = new ConstantProperty<>(Cartesian3.ZERO()); // default
- billboardGraphicsOptions.width = new ConstantProperty<>(100); // default: undefined
- billboardGraphicsOptions.height = new ConstantProperty<>(25); // default: undefined
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
- entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
- }
-
- private void changeBillboardProperties() {
- BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png");
- BillboardGraphics billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883, 300000.0));
- entityOptions.billboard = billboardGraphics;
- Entity entity = csVPanel.getViewer().entities().add(new Entity(entityOptions));
- entity.billboard.scale = new ConstantProperty<>(3.0);
- entity.billboard.color = new ConstantProperty<>(Color.WHITE().withAlpha(0.25f));
- }
-
- private void sizeBillboardInMeters() {
- BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png");
- billboardGraphicsOptions.sizeInMeters = new ConstantProperty<>(true);
- BillboardGraphics billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
- entityOptions.billboard = billboardGraphics;
- Entity entity = csVPanel.getViewer().entities().add(new Entity(entityOptions));
- csVPanel.getViewer().zoomTo(entity);
- }
-
- private void addMultipleBillboards() {
- String logoUrl = GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png";
- String facilityUrl = GWT.getModuleBaseURL() + "images/facility.gif";
-
- BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.image = new ConstantProperty<>(logoUrl);
- BillboardGraphics billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
- entityOptions.billboard = billboardGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.image = new ConstantProperty<>(facilityUrl);
- billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-80.50, 35.14));
- entityOptions.billboard = billboardGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.image = new ConstantProperty<>(facilityUrl);
- billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-80.12, 25.46));
- entityOptions.billboard = billboardGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
- }
-
- private void scaleByDistance() {
- BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/facility.gif");
- billboardGraphicsOptions.scaleByDistance = new ConstantProperty<>(new NearFarScalar(1.5e2, 2.0, 1.5e7, 0.5));
- BillboardGraphics billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
- entityOptions.billboard = billboardGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
- }
-
- private void fadeByDistance() {
- BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png");
- billboardGraphicsOptions.translucencyByDistance = new ConstantProperty<>(new NearFarScalar(1.5e2, 2.0, 1.5e7, 0.5));
- BillboardGraphics billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
- entityOptions.billboard = billboardGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
- }
-
- private void offsetByDistance() {
- Resource.fetchImage(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png").then(
- logoImg -> {
- Resource.fetchImage(GWT.getModuleBaseURL() + "images/facility.gif").then(
- facilityImg -> {
- createFacility(logoImg, facilityImg);
- },
- value -> LOGGER.info("Facility not loaded")
- );
- },
- value -> LOGGER.info("facility imagery not loaded")
- );
- }
-
- private void addMarkerBillboards() {
- BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/whiteShapes.png");
- billboardGraphicsOptions.imageSubRegion = new ConstantProperty<>(new BoundingRectangle(49, 43, 18, 18));
- billboardGraphicsOptions.color = new ConstantProperty<>(Color.LIME());
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/whiteShapes.png");
- billboardGraphicsOptions.imageSubRegion = new ConstantProperty<>(new BoundingRectangle(61, 23, 18, 18));
- billboardGraphicsOptions.color = new ConstantProperty<>(new Color(0, 0.5, 1.0, 1.0));
- entityOptions = new EntityOptions();
- entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-84.0, 39.0));
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/whiteShapes.png");
- billboardGraphicsOptions.imageSubRegion = new ConstantProperty<>(new BoundingRectangle(67, 80, 14, 14));
- billboardGraphicsOptions.color = new ConstantProperty<>(new Color(0.5, 0.9, 1.0, 1.0));
- entityOptions = new EntityOptions();
- entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-70.0, 41.0));
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/whiteShapes.png");
- billboardGraphicsOptions.imageSubRegion = new ConstantProperty<>(new BoundingRectangle(27, 103, 22, 22));
- billboardGraphicsOptions.color = new ConstantProperty<>(Color.RED());
- entityOptions = new EntityOptions();
- entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-73.0, 37.0));
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/whiteShapes.png");
- billboardGraphicsOptions.imageSubRegion = new ConstantProperty<>(new BoundingRectangle(105, 105, 18, 18));
- billboardGraphicsOptions.color = new ConstantProperty<>(Color.YELLOW());
- entityOptions = new EntityOptions();
- entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-79.0, 35.0));
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
- }
-
- private void reset() {
- csVPanel.getViewer().camera.flyHome(0);
- csVPanel.getViewer().entities().removeAll();
- }
-
- private void createFacility(JsImage logoImg, JsImage facilityImg) {
- int facilityHeight = facilityImg.height;
-
- BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.image = new ConstantProperty<>(facilityImg);
- billboardGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.CENTER());
- billboardGraphicsOptions.verticalOrigin = new ConstantProperty<>(VerticalOrigin.BOTTOM());
- BillboardGraphics billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.billboard = billboardGraphics;
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.image = new ConstantProperty<>(logoImg);
- billboardGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.CENTER());
- billboardGraphicsOptions.verticalOrigin = new ConstantProperty<>(VerticalOrigin.BOTTOM());
- billboardGraphicsOptions.pixelOffset = new ConstantProperty<>(new Cartesian2(0.0, -facilityHeight));
- billboardGraphicsOptions.pixelOffsetScaleByDistance = new ConstantProperty<>(
- new NearFarScalar(1.0e3, 1.0, 1.5e6, 0.0));
- billboardGraphicsOptions.translucencyByDistance = new ConstantProperty<>(
- new NearFarScalar(1.0e3, 1.0, 1.5e6, 0.1));
- billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.billboard = billboardGraphics;
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
- }
+ ViewerPanel csVPanel;
+
+ @Inject
+ public Billboards(ShowcaseExampleStore store) {
+ super("Billboards", "Add billboard images and markers to the scene",
+ new String[]{"Showcase", "Cesium", "3d", "Billboards", "Promise"}, store);
+ }
+
+ @Override
+ public void buildPanel() {
+ csVPanel = new ViewerPanel();
+ addBillboard();
+
+ ListBox billboardsLBox = new ListBox();
+ billboardsLBox.addItem("Add billboard", "0");
+ billboardsLBox.addItem("Set billboard properties at creation", "1");
+ billboardsLBox.addItem("Change billboard properties", "2");
+ billboardsLBox.addItem("Size billboard in meters", "3");
+ billboardsLBox.addItem("Add multiple billboards", "4");
+ billboardsLBox.addItem("Scale by viewer distance", "5");
+ billboardsLBox.addItem("Fade by viewer distance", "6");
+ billboardsLBox.addItem("Offset by viewer distance", "7");
+ billboardsLBox.addItem("Add marker billboards", "8");
+ billboardsLBox.addChangeHandler(new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent changeEvent) {
+ ListBox source = (ListBox) changeEvent.getSource();
+ reset();
+ switch (source.getSelectedValue()) {
+ case "0":
+ addBillboard();
+ break;
+ case "1":
+ setBillboardProperties();
+ break;
+ case "2":
+ changeBillboardProperties();
+ break;
+ case "3":
+ sizeBillboardInMeters();
+ break;
+ case "4":
+ addMultipleBillboards();
+ break;
+ case "5":
+ scaleByDistance();
+ break;
+ case "6":
+ fadeByDistance();
+ break;
+ case "7":
+ offsetByDistance();
+ break;
+ case "8":
+ addMarkerBillboards();
+ default:
+ break;
+ }
+ }
+ });
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(billboardsLBox, 20, 20);
+
+ contentPanel.add(new HTML("Add billboard images and markers to the scene.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Billboards.txt";
+ return sourceCodeURLs;
+ }
+
+ private void addBillboard() {
+ BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
+ billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png");
+ BillboardGraphics billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
+ entityOptions.billboard = billboardGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ }
+
+ private void setBillboardProperties() {
+ BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
+ billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png"); // default:
+ // undefined
+ billboardGraphicsOptions.show = new ConstantProperty<>(true); // default
+ billboardGraphicsOptions.pixelOffset = new ConstantProperty<>(new Cartesian2(0, -50)); // default: (0, 0)
+ billboardGraphicsOptions.eyeOffset = new ConstantProperty<>(new Cartesian3(0, 0, 0)); // default
+ billboardGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.CENTER());// default
+ billboardGraphicsOptions.verticalOrigin = new ConstantProperty<>(VerticalOrigin.BOTTOM()); // default: CENTER
+ billboardGraphicsOptions.scale = new ConstantProperty<>(2.0); // default: 1.0
+ billboardGraphicsOptions.color = new ConstantProperty<>(Color.LIME()); // default: WHITE
+ billboardGraphicsOptions.rotation = new ConstantProperty<>(Math.PI_OVER_FOUR()); // default: 0.0
+ billboardGraphicsOptions.alignedAxis = new ConstantProperty<>(Cartesian3.ZERO()); // default
+ billboardGraphicsOptions.width = new ConstantProperty<>(100); // default: undefined
+ billboardGraphicsOptions.height = new ConstantProperty<>(25); // default: undefined
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
+ entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ }
+
+ private void changeBillboardProperties() {
+ BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
+ billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png");
+ BillboardGraphics billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883, 300000.0));
+ entityOptions.billboard = billboardGraphics;
+ Entity entity = csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ entity.billboard.scale = new ConstantProperty<>(3.0);
+ entity.billboard.color = new ConstantProperty<>(Color.WHITE().withAlpha(0.25f));
+ }
+
+ private void sizeBillboardInMeters() {
+ BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
+ billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png");
+ billboardGraphicsOptions.sizeInMeters = new ConstantProperty<>(true);
+ BillboardGraphics billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
+ entityOptions.billboard = billboardGraphics;
+ Entity entity = csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ csVPanel.getViewer().zoomTo(entity);
+ }
+
+ private void addMultipleBillboards() {
+ String logoUrl = GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png";
+ String facilityUrl = GWT.getModuleBaseURL() + "images/facility.gif";
+
+ BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
+ billboardGraphicsOptions.image = new ConstantProperty<>(logoUrl);
+ BillboardGraphics billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
+ entityOptions.billboard = billboardGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ billboardGraphicsOptions = new BillboardGraphicsOptions();
+ billboardGraphicsOptions.image = new ConstantProperty<>(facilityUrl);
+ billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-80.50, 35.14));
+ entityOptions.billboard = billboardGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ billboardGraphicsOptions = new BillboardGraphicsOptions();
+ billboardGraphicsOptions.image = new ConstantProperty<>(facilityUrl);
+ billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-80.12, 25.46));
+ entityOptions.billboard = billboardGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ }
+
+ private void scaleByDistance() {
+ BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
+ billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/facility.gif");
+ billboardGraphicsOptions.scaleByDistance = new ConstantProperty<>(new NearFarScalar(1.5e2, 2.0, 1.5e7, 0.5));
+ BillboardGraphics billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
+ entityOptions.billboard = billboardGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ }
+
+ private void fadeByDistance() {
+ BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
+ billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png");
+ billboardGraphicsOptions.translucencyByDistance = new ConstantProperty<>(new NearFarScalar(1.5e2, 2.0, 1.5e7, 0.5));
+ BillboardGraphics billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
+ entityOptions.billboard = billboardGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ }
+
+ private void offsetByDistance() {
+ Resource.fetchImage(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png").then(
+ logoImg -> {
+ Resource.fetchImage(GWT.getModuleBaseURL() + "images/facility.gif").then(
+ facilityImg -> {
+ createFacility(logoImg, facilityImg);
+ },
+ value -> LOGGER.info("Facility not loaded")
+ );
+ },
+ value -> LOGGER.info("facility imagery not loaded")
+ );
+ }
+
+ private void addMarkerBillboards() {
+ BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
+ billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/whiteShapes.png");
+ billboardGraphicsOptions.imageSubRegion = new ConstantProperty<>(new BoundingRectangle(49, 43, 18, 18));
+ billboardGraphicsOptions.color = new ConstantProperty<>(Color.LIME());
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ billboardGraphicsOptions = new BillboardGraphicsOptions();
+ billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/whiteShapes.png");
+ billboardGraphicsOptions.imageSubRegion = new ConstantProperty<>(new BoundingRectangle(61, 23, 18, 18));
+ billboardGraphicsOptions.color = new ConstantProperty<>(new Color(0, 0.5, 1.0, 1.0));
+ entityOptions = new EntityOptions();
+ entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-84.0, 39.0));
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ billboardGraphicsOptions = new BillboardGraphicsOptions();
+ billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/whiteShapes.png");
+ billboardGraphicsOptions.imageSubRegion = new ConstantProperty<>(new BoundingRectangle(67, 80, 14, 14));
+ billboardGraphicsOptions.color = new ConstantProperty<>(new Color(0.5, 0.9, 1.0, 1.0));
+ entityOptions = new EntityOptions();
+ entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-70.0, 41.0));
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ billboardGraphicsOptions = new BillboardGraphicsOptions();
+ billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/whiteShapes.png");
+ billboardGraphicsOptions.imageSubRegion = new ConstantProperty<>(new BoundingRectangle(27, 103, 22, 22));
+ billboardGraphicsOptions.color = new ConstantProperty<>(Color.RED());
+ entityOptions = new EntityOptions();
+ entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-73.0, 37.0));
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ billboardGraphicsOptions = new BillboardGraphicsOptions();
+ billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/whiteShapes.png");
+ billboardGraphicsOptions.imageSubRegion = new ConstantProperty<>(new BoundingRectangle(105, 105, 18, 18));
+ billboardGraphicsOptions.color = new ConstantProperty<>(Color.YELLOW());
+ entityOptions = new EntityOptions();
+ entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-79.0, 35.0));
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ }
+
+ private void reset() {
+ csVPanel.getViewer().camera.flyHome(0);
+ csVPanel.getViewer().entities().removeAll();
+ }
+
+ private void createFacility(JsImage logoImg, JsImage facilityImg) {
+ int facilityHeight = facilityImg.height;
+
+ BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
+ billboardGraphicsOptions.image = new ConstantProperty<>(facilityImg);
+ billboardGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.CENTER());
+ billboardGraphicsOptions.verticalOrigin = new ConstantProperty<>(VerticalOrigin.BOTTOM());
+ BillboardGraphics billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.billboard = billboardGraphics;
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ billboardGraphicsOptions = new BillboardGraphicsOptions();
+ billboardGraphicsOptions.image = new ConstantProperty<>(logoImg);
+ billboardGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.CENTER());
+ billboardGraphicsOptions.verticalOrigin = new ConstantProperty<>(VerticalOrigin.BOTTOM());
+ billboardGraphicsOptions.pixelOffset = new ConstantProperty<>(new Cartesian2(0.0, -facilityHeight));
+ billboardGraphicsOptions.pixelOffsetScaleByDistance = new ConstantProperty<>(
+ new NearFarScalar(1.0e3, 1.0, 1.5e6, 0.0));
+ billboardGraphicsOptions.translucencyByDistance = new ConstantProperty<>(
+ new NearFarScalar(1.0e3, 1.0, 1.5e6, 0.1));
+ billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.billboard = billboardGraphics;
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Bloom.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Bloom.java
index 06d30a9066cd33b28da720e8db59e200d687ec02..1200762f8461d540661e221d15914c4c03ea7e2a 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Bloom.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Bloom.java
@@ -42,159 +42,157 @@ import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
* @author Serge Silaev aka iSergio
*/
public class Bloom extends AbstractExample {
- private ViewerPanel csVPanel;
-
- private CheckBox bloomCBox;
- private CheckBox glowOnlyCBox;
- private Slider contrastSlider;
- private Slider brightnessSlider;
- private Slider deltaSlider;
- private Slider sigmaSlider;
- private Slider stepSizeSlider;
-
- private int numberOfBalloons = 13;
- private double lonIncrement = 0.00025;
- private double initialLon = -122.99875;
- private double lat = 44.0503706;
- private double height = 100.0;
-
- @Inject
- public Bloom(ShowcaseExampleStore store) {
- super("Bloom", "Add bloom effect to the scene", new String[] {
- "Bloom", "Post processing"}, store);
- }
-
- @Override
- public void buildPanel() {
- csVPanel = new ViewerPanel();
-
- for (int i = 0; i < numberOfBalloons; i++) {
- double lon = initialLon + i * lonIncrement;
- createModel(lon, lat, height);
+ private final int numberOfBalloons = 13;
+ private final double lonIncrement = 0.00025;
+ private final double initialLon = -122.99875;
+ private final double lat = 44.0503706;
+ private final double height = 100.0;
+ private ViewerPanel csVPanel;
+ private CheckBox bloomCBox;
+ private CheckBox glowOnlyCBox;
+ private Slider contrastSlider;
+ private Slider brightnessSlider;
+ private Slider deltaSlider;
+ private Slider sigmaSlider;
+ private Slider stepSizeSlider;
+
+ @Inject
+ public Bloom(ShowcaseExampleStore store) {
+ super("Bloom", "Add bloom effect to the scene", new String[]{
+ "Bloom", "Post processing"}, store);
}
- bloomCBox = new CheckBox();
- bloomCBox.setValue(true);
- bloomCBox.addValueChangeHandler(new MValueChangeHandler());
-
- glowOnlyCBox = new CheckBox();
- glowOnlyCBox.setValue(false);
- glowOnlyCBox.addValueChangeHandler(new MValueChangeHandler());
-
- contrastSlider = new Slider("contrastSlider", -25500, 25500, 12800);
- contrastSlider.setStep(1);
- contrastSlider.setWidth("150px");
- contrastSlider.addListener(new MSliderListener());
-
- brightnessSlider = new Slider("brightnessSlider", -100, 100, -30);
- brightnessSlider.setStep(1);
- brightnessSlider.setWidth("150px");
- brightnessSlider.addListener(new MSliderListener());
-
- deltaSlider = new Slider("deltaSlider", 100, 500, 100);
- deltaSlider.setStep(1);
- deltaSlider.setWidth("150px");
- deltaSlider.addListener(new MSliderListener());
-
- sigmaSlider = new Slider("sigmaSlider", 100, 1000, 378);
- sigmaSlider.setStep(1);
- sigmaSlider.setWidth("150px");
- sigmaSlider.addListener(new MSliderListener());
-
- stepSizeSlider = new Slider("stepSizeSlider", 0, 700, 500);
- stepSizeSlider.setStep(1);
- stepSizeSlider.setWidth("150px");
- stepSizeSlider.addListener(new MSliderListener());
-
- FlexTable flexTable = new FlexTable();
- flexTable.setHTML(1, 0, "Bloom");
- flexTable.setWidget(1, 1, bloomCBox);
- flexTable.setHTML(2, 0, "Glow only");
- flexTable.setWidget(2, 1, glowOnlyCBox);
- flexTable.setHTML(3, 0, "Contrast");
- flexTable.setWidget(3, 1, contrastSlider);
- flexTable.setHTML(4, 0, "Brightness");
- flexTable.setWidget(4, 1, brightnessSlider);
- flexTable.setHTML(5, 0, "Delta");
- flexTable.setWidget(5, 1, deltaSlider);
- flexTable.setHTML(6, 0, "Sigma");
- flexTable.setWidget(6, 1, sigmaSlider);
- flexTable.setHTML(7, 0, "Step Size");
- flexTable.setWidget(7, 1, stepSizeSlider);
-
- AbsolutePanel absPanel = new AbsolutePanel();
- absPanel.add(csVPanel);
- absPanel.add(flexTable, 20, 20);
-
- contentPanel.add(new HTML("Post processing effects.
"));
- contentPanel.add(absPanel);
-
- initWidget(contentPanel);
- updatePostProcess();
-
- Cartesian3 target = Cartesian3.fromDegrees(initialLon + lonIncrement, lat, height + 7.5);
- Cartesian3 offset = new Cartesian3(-37.048378684557974, -24.852967044804245, 4.352023653686047);
- csVPanel.getViewer().scene().camera().lookAt(target, offset);
- }
-
- private void createModel(double lon, double lat, double height) {
- Cartesian3 position = Cartesian3.fromDegrees(lon, lat, height);
-
- ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(
- GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb");
- EntityOptions options = new EntityOptions();
- options.name = GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb";
- options.position = new ConstantPositionProperty(position);
- options.model = new ModelGraphics(modelGraphicsOptions);
- csVPanel.getViewer().entities().add(options);
- }
-
- private void updatePostProcess() {
- PostProcessStageComposite bloom = csVPanel.getViewer().scene().postProcessStages.bloom();
- bloom.enabled = bloomCBox.getValue();
- bloom.uniforms.setProperty("glowOnly", glowOnlyCBox.getValue());
- bloom.uniforms.setProperty("contrast", contrastSlider.getValue() / 100.0);
- bloom.uniforms.setProperty("brightness", brightnessSlider.getValue() / 100.0);
- bloom.uniforms.setProperty("delta", deltaSlider.getValue() / 100.0);
- bloom.uniforms.setProperty("sigma", sigmaSlider.getValue() / 100.0);
- bloom.uniforms.setProperty("stepSize", stepSizeSlider.getValue() / 100.0);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Bloom.txt";
- return sourceCodeURLs;
- }
-
- private class MValueChangeHandler implements ValueChangeHandler {
@Override
- public void onValueChange(ValueChangeEvent event) {
- updatePostProcess();
+ public void buildPanel() {
+ csVPanel = new ViewerPanel();
+
+ for (int i = 0; i < numberOfBalloons; i++) {
+ double lon = initialLon + i * lonIncrement;
+ createModel(lon, lat, height);
+ }
+
+ bloomCBox = new CheckBox();
+ bloomCBox.setValue(true);
+ bloomCBox.addValueChangeHandler(new MValueChangeHandler());
+
+ glowOnlyCBox = new CheckBox();
+ glowOnlyCBox.setValue(false);
+ glowOnlyCBox.addValueChangeHandler(new MValueChangeHandler());
+
+ contrastSlider = new Slider("contrastSlider", -25500, 25500, 12800);
+ contrastSlider.setStep(1);
+ contrastSlider.setWidth("150px");
+ contrastSlider.addListener(new MSliderListener());
+
+ brightnessSlider = new Slider("brightnessSlider", -100, 100, -30);
+ brightnessSlider.setStep(1);
+ brightnessSlider.setWidth("150px");
+ brightnessSlider.addListener(new MSliderListener());
+
+ deltaSlider = new Slider("deltaSlider", 100, 500, 100);
+ deltaSlider.setStep(1);
+ deltaSlider.setWidth("150px");
+ deltaSlider.addListener(new MSliderListener());
+
+ sigmaSlider = new Slider("sigmaSlider", 100, 1000, 378);
+ sigmaSlider.setStep(1);
+ sigmaSlider.setWidth("150px");
+ sigmaSlider.addListener(new MSliderListener());
+
+ stepSizeSlider = new Slider("stepSizeSlider", 0, 700, 500);
+ stepSizeSlider.setStep(1);
+ stepSizeSlider.setWidth("150px");
+ stepSizeSlider.addListener(new MSliderListener());
+
+ FlexTable flexTable = new FlexTable();
+ flexTable.setHTML(1, 0, "Bloom");
+ flexTable.setWidget(1, 1, bloomCBox);
+ flexTable.setHTML(2, 0, "Glow only");
+ flexTable.setWidget(2, 1, glowOnlyCBox);
+ flexTable.setHTML(3, 0, "Contrast");
+ flexTable.setWidget(3, 1, contrastSlider);
+ flexTable.setHTML(4, 0, "Brightness");
+ flexTable.setWidget(4, 1, brightnessSlider);
+ flexTable.setHTML(5, 0, "Delta");
+ flexTable.setWidget(5, 1, deltaSlider);
+ flexTable.setHTML(6, 0, "Sigma");
+ flexTable.setWidget(6, 1, sigmaSlider);
+ flexTable.setHTML(7, 0, "Step Size");
+ flexTable.setWidget(7, 1, stepSizeSlider);
+
+ AbsolutePanel absPanel = new AbsolutePanel();
+ absPanel.add(csVPanel);
+ absPanel.add(flexTable, 20, 20);
+
+ contentPanel.add(new HTML("Post processing effects.
"));
+ contentPanel.add(absPanel);
+
+ initWidget(contentPanel);
+ updatePostProcess();
+
+ Cartesian3 target = Cartesian3.fromDegrees(initialLon + lonIncrement, lat, height + 7.5);
+ Cartesian3 offset = new Cartesian3(-37.048378684557974, -24.852967044804245, 4.352023653686047);
+ csVPanel.getViewer().scene().camera().lookAt(target, offset);
}
- }
- private class MSliderListener implements SliderListener {
- @Override
- public void onStart(SliderEvent e) {
- //
+ private void createModel(double lon, double lat, double height) {
+ Cartesian3 position = Cartesian3.fromDegrees(lon, lat, height);
+
+ ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
+ modelGraphicsOptions.uri = new ConstantProperty<>(
+ GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb");
+ EntityOptions options = new EntityOptions();
+ options.name = GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb";
+ options.position = new ConstantPositionProperty(position);
+ options.model = new ModelGraphics(modelGraphicsOptions);
+ csVPanel.getViewer().entities().add(options);
}
- @Override
- public boolean onSlide(SliderEvent e) {
- updatePostProcess();
- return true;
+ private void updatePostProcess() {
+ PostProcessStageComposite bloom = csVPanel.getViewer().scene().postProcessStages.bloom();
+ bloom.enabled = bloomCBox.getValue();
+ bloom.uniforms.setProperty("glowOnly", glowOnlyCBox.getValue());
+ bloom.uniforms.setProperty("contrast", contrastSlider.getValue() / 100.0);
+ bloom.uniforms.setProperty("brightness", brightnessSlider.getValue() / 100.0);
+ bloom.uniforms.setProperty("delta", deltaSlider.getValue() / 100.0);
+ bloom.uniforms.setProperty("sigma", sigmaSlider.getValue() / 100.0);
+ bloom.uniforms.setProperty("stepSize", stepSizeSlider.getValue() / 100.0);
}
@Override
- public void onChange(SliderEvent e) {
- //
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Bloom.txt";
+ return sourceCodeURLs;
}
- @Override
- public void onStop(SliderEvent e) {
- //
+ private class MValueChangeHandler implements ValueChangeHandler {
+ @Override
+ public void onValueChange(ValueChangeEvent event) {
+ updatePostProcess();
+ }
+ }
+
+ private class MSliderListener implements SliderListener {
+ @Override
+ public void onStart(SliderEvent e) {
+ //
+ }
+
+ @Override
+ public boolean onSlide(SliderEvent e) {
+ updatePostProcess();
+ return true;
+ }
+
+ @Override
+ public void onChange(SliderEvent e) {
+ //
+ }
+
+ @Override
+ public void onStop(SliderEvent e) {
+ //
+ }
}
- }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CZML.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CZML.java
index 7c45b02f44ff8d5aa8fa96816d36380d820f0355..5af3bf77c8e4465864415cd46f7174a7b2eff3f1 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CZML.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CZML.java
@@ -16,8 +16,6 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
@@ -25,7 +23,6 @@ import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
-
import org.cesiumjs.cs.core.Cartesian3;
import org.cesiumjs.cs.core.HeadingPitchRoll;
import org.cesiumjs.cs.core.Math;
@@ -35,71 +32,73 @@ import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class CZML extends AbstractExample {
- private ViewerPanel csVPanel;
-
- @Inject
- public CZML(ShowcaseExampleStore store) {
- super("CZML", "A simple CZML example showing four satellites in orbit around the Earth, and some ground objects",
- new String[] { "Showcase", "Cesium", "3d", "Viewer", "CZML" }, store);
- }
+ private ViewerPanel csVPanel;
- @Override
- public void buildPanel() {
- csVPanel = new ViewerPanel();
- csVPanel.getViewer().dataSources().add(CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/simple.czml"));
- csVPanel.getViewer().camera.flyHome(0);
+ @Inject
+ public CZML(ShowcaseExampleStore store) {
+ super("CZML", "A simple CZML example showing four satellites in orbit around the Earth, and some ground objects",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer", "CZML"}, store);
+ }
- Button satellitesBtn = new Button("Satellites");
- satellitesBtn.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent clickEvent) {
- reset();
+ @Override
+ public void buildPanel() {
+ csVPanel = new ViewerPanel();
csVPanel.getViewer().dataSources().add(CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/simple.czml"));
csVPanel.getViewer().camera.flyHome(0);
- }
- });
- Button vehicleBtn = new Button("Vehicle");
- vehicleBtn.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent clickEvent) {
- reset();
- csVPanel.getViewer().dataSources().add(CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/Vehicle.czml"));
- ViewOptions viewOptions = new ViewOptions();
- viewOptions.destinationPos = Cartesian3.fromDegrees(-116.52, 35.02, 95000);
- viewOptions.orientation = new HeadingPitchRoll(6, -Math.PI_OVER_TWO());
- csVPanel.getViewer().scene().camera().setView(viewOptions);
- }
- });
+ Button satellitesBtn = new Button("Satellites");
+ satellitesBtn.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent clickEvent) {
+ reset();
+ csVPanel.getViewer().dataSources().add(CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/simple.czml"));
+ csVPanel.getViewer().camera.flyHome(0);
+ }
+ });
+
+ Button vehicleBtn = new Button("Vehicle");
+ vehicleBtn.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent clickEvent) {
+ reset();
+ csVPanel.getViewer().dataSources().add(CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/Vehicle.czml"));
+ ViewOptions viewOptions = new ViewOptions();
+ viewOptions.destinationPos = Cartesian3.fromDegrees(-116.52, 35.02, 95000);
+ viewOptions.orientation = new HeadingPitchRoll(6, -Math.PI_OVER_TWO());
+ csVPanel.getViewer().scene().camera().setView(viewOptions);
+ }
+ });
- HorizontalPanel hPanel = new HorizontalPanel();
- hPanel.setSpacing(10);
- hPanel.add(satellitesBtn);
- hPanel.add(vehicleBtn);
+ HorizontalPanel hPanel = new HorizontalPanel();
+ hPanel.setSpacing(10);
+ hPanel.add(satellitesBtn);
+ hPanel.add(vehicleBtn);
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(hPanel, 20, 20);
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(hPanel, 20, 20);
- contentPanel.add(new HTML(
- "A simple CZML example showing four satellites in orbit around the Earth, and some ground objects.
"));
- contentPanel.add(aPanel);
+ contentPanel.add(new HTML(
+ "A simple CZML example showing four satellites in orbit around the Earth, and some ground objects.
"));
+ contentPanel.add(aPanel);
- initWidget(contentPanel);
- }
+ initWidget(contentPanel);
+ }
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CZML.txt";
- return sourceCodeURLs;
- }
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CZML.txt";
+ return sourceCodeURLs;
+ }
- public void reset() {
- csVPanel.getViewer().dataSources().removeAll();
- }
+ public void reset() {
+ csVPanel.getViewer().dataSources().removeAll();
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CZMLModelArticulations.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CZMLModelArticulations.java
index b5792d5fe34064b386783b92e45f680c2e195d8c..ea90ea4ae2abe6c7f9584922ddaf41349b10a770 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CZMLModelArticulations.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CZMLModelArticulations.java
@@ -16,11 +16,8 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.HTML;
-
import org.cesiumjs.cs.datasources.CzmlDataSource;
import org.cesiumjs.cs.js.JsObject;
import org.cesiumjs.cs.promise.Fulfill;
@@ -30,91 +27,93 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class CZMLModelArticulations extends AbstractExample {
- @Inject
- public CZMLModelArticulations(ShowcaseExampleStore store) {
- super("CZML Model Articulations", "CZML Model Articulations", new String[] { "CZML", "Model", "Articulations" },
- store);
- }
-
- @Override
- public void buildPanel() {
- JsObject clockCZML = JsObject.create();
- clockCZML.setProperty("interval", "2019-06-01T16:00:00Z/2019-06-01T16:10:00Z");
- clockCZML.setProperty("currentTime", "2019-06-01T16:00:00Z");
- clockCZML.setProperty("multiplier", 60.0);
- clockCZML.setProperty("range", "LOOP_STOP");
- clockCZML.setProperty("step", "SYSTEM_CLOCK_MULTIPLIER");
-
- JsObject firstCZML = JsObject.create();
- firstCZML.setProperty("id", "document");
- firstCZML.setProperty("name", "CZML Model");
- firstCZML.setProperty("version", "1.0");
- firstCZML.setProperty("clock", clockCZML);
-
- JsObject positionCZML = JsObject.create();
- positionCZML.setProperty("cartographicDegrees", new double[] { -77, 37, 10000 });
-
- JsObject fairingOpenCZML = JsObject.create();
- fairingOpenCZML.setProperty("epoch", "2019-06-01T16:00:00Z");
- fairingOpenCZML.setProperty("number", new double[] { 0, 0, 600, 120 });
-
- JsObject fairingSeparateCZML = JsObject.create();
- fairingSeparateCZML.setProperty("epoch", "2019-06-01T16:00:00Z");
- fairingSeparateCZML.setProperty("number", new double[] { 0, 0, 400, -50 });
-
- JsObject fairingDropCZML = JsObject.create();
- fairingDropCZML.setProperty("epoch", "2019-06-01T16:00:00Z");
- fairingDropCZML.setProperty("interpolationAlgorithm", "LAGRANGE");
- fairingDropCZML.setProperty("interpolationDegree", 2);
- fairingDropCZML.setProperty("number", new double[] { 0, 0, 80, 0, 100, 0, 120, -1, 600, -120 });
-
- JsObject articulationsCZML = JsObject.create();
- articulationsCZML.setProperty("Fairing Open", fairingOpenCZML);
- articulationsCZML.setProperty("Fairing Separate", fairingSeparateCZML);
- articulationsCZML.setProperty("Fairing Drop", fairingDropCZML);
-
- JsObject modelCZML = JsObject.create();
- modelCZML.setProperty("gltf", "https://assets.agi.com/models/launchvehicle.glb");
- modelCZML.setProperty("scale", 2.0);
- modelCZML.setProperty("minimumPixelSize", 128);
- modelCZML.setProperty("runAnimations", false);
- modelCZML.setProperty("articulations", articulationsCZML);
-
- JsObject secondCZML = JsObject.create();
- secondCZML.setProperty("id", "test model");
- secondCZML.setProperty("name", "Cesium Air");
- secondCZML.setProperty("position", positionCZML);
- secondCZML.setProperty("model", modelCZML);
-
- ViewerOptions options = new ViewerOptions();
- options.shouldAnimate = true;
- final ViewerPanel csVPanel = new ViewerPanel(options);
-
- Promise dataSourcePromise = csVPanel.getViewer().dataSources()
- .add(CzmlDataSource.load(new JsObject[] { firstCZML, secondCZML }));
-
- dataSourcePromise.then(new Fulfill() {
- @Override
- public void onFulfilled(CzmlDataSource dataSource) {
- csVPanel.getViewer().trackedEntity = dataSource.entities.getById("test model");
- }
- });
-
- contentPanel.add(new HTML("CZML Model Articulations
"));
- contentPanel.add(csVPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CZMLModelArticulations.txt";
- return sourceCodeURLs;
- }
+ @Inject
+ public CZMLModelArticulations(ShowcaseExampleStore store) {
+ super("CZML Model Articulations", "CZML Model Articulations", new String[]{"CZML", "Model", "Articulations"},
+ store);
+ }
+
+ @Override
+ public void buildPanel() {
+ JsObject clockCZML = JsObject.create();
+ clockCZML.setProperty("interval", "2019-06-01T16:00:00Z/2019-06-01T16:10:00Z");
+ clockCZML.setProperty("currentTime", "2019-06-01T16:00:00Z");
+ clockCZML.setProperty("multiplier", 60.0);
+ clockCZML.setProperty("range", "LOOP_STOP");
+ clockCZML.setProperty("step", "SYSTEM_CLOCK_MULTIPLIER");
+
+ JsObject firstCZML = JsObject.create();
+ firstCZML.setProperty("id", "document");
+ firstCZML.setProperty("name", "CZML Model");
+ firstCZML.setProperty("version", "1.0");
+ firstCZML.setProperty("clock", clockCZML);
+
+ JsObject positionCZML = JsObject.create();
+ positionCZML.setProperty("cartographicDegrees", new double[]{-77, 37, 10000});
+
+ JsObject fairingOpenCZML = JsObject.create();
+ fairingOpenCZML.setProperty("epoch", "2019-06-01T16:00:00Z");
+ fairingOpenCZML.setProperty("number", new double[]{0, 0, 600, 120});
+
+ JsObject fairingSeparateCZML = JsObject.create();
+ fairingSeparateCZML.setProperty("epoch", "2019-06-01T16:00:00Z");
+ fairingSeparateCZML.setProperty("number", new double[]{0, 0, 400, -50});
+
+ JsObject fairingDropCZML = JsObject.create();
+ fairingDropCZML.setProperty("epoch", "2019-06-01T16:00:00Z");
+ fairingDropCZML.setProperty("interpolationAlgorithm", "LAGRANGE");
+ fairingDropCZML.setProperty("interpolationDegree", 2);
+ fairingDropCZML.setProperty("number", new double[]{0, 0, 80, 0, 100, 0, 120, -1, 600, -120});
+
+ JsObject articulationsCZML = JsObject.create();
+ articulationsCZML.setProperty("Fairing Open", fairingOpenCZML);
+ articulationsCZML.setProperty("Fairing Separate", fairingSeparateCZML);
+ articulationsCZML.setProperty("Fairing Drop", fairingDropCZML);
+
+ JsObject modelCZML = JsObject.create();
+ modelCZML.setProperty("gltf", "https://assets.agi.com/models/launchvehicle.glb");
+ modelCZML.setProperty("scale", 2.0);
+ modelCZML.setProperty("minimumPixelSize", 128);
+ modelCZML.setProperty("runAnimations", false);
+ modelCZML.setProperty("articulations", articulationsCZML);
+
+ JsObject secondCZML = JsObject.create();
+ secondCZML.setProperty("id", "test model");
+ secondCZML.setProperty("name", "Cesium Air");
+ secondCZML.setProperty("position", positionCZML);
+ secondCZML.setProperty("model", modelCZML);
+
+ ViewerOptions options = new ViewerOptions();
+ options.shouldAnimate = true;
+ final ViewerPanel csVPanel = new ViewerPanel(options);
+
+ Promise dataSourcePromise = csVPanel.getViewer().dataSources()
+ .add(CzmlDataSource.load(new JsObject[]{firstCZML, secondCZML}));
+
+ dataSourcePromise.then(new Fulfill() {
+ @Override
+ public void onFulfilled(CzmlDataSource dataSource) {
+ csVPanel.getViewer().trackedEntity = dataSource.entities.getById("test model");
+ }
+ });
+
+ contentPanel.add(new HTML("CZML Model Articulations
"));
+ contentPanel.add(csVPanel);
+
+ initWidget(contentPanel);
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CZMLModelArticulations.txt";
+ return sourceCodeURLs;
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CZMLPolygonIntervalsAvailability.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CZMLPolygonIntervalsAvailability.java
index f8ae5dd5c77fde247aa7fc312eda77012ca0cf15..dba92a71762146a854c6bb37ea655380540e8a08 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CZMLPolygonIntervalsAvailability.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CZMLPolygonIntervalsAvailability.java
@@ -16,40 +16,39 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.HTML;
-
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class CZMLPolygonIntervalsAvailability extends AbstractExample {
- @Inject
- public CZMLPolygonIntervalsAvailability(ShowcaseExampleStore store) {
- super("CZML Polygon - Intervals,Availability", "CZML Dynamic Polygon - Intervals and Availability",
- new String[] { "Showcase", "Cesium", "3d", "CZML", "Polygon", "Interva;s" }, store);
- }
+ @Inject
+ public CZMLPolygonIntervalsAvailability(ShowcaseExampleStore store) {
+ super("CZML Polygon - Intervals,Availability", "CZML Dynamic Polygon - Intervals and Availability",
+ new String[]{"Showcase", "Cesium", "3d", "CZML", "Polygon", "Interva;s"}, store);
+ }
- @Override
- public void buildPanel() {
- ViewerPanel csVPanel = new ViewerPanel();
+ @Override
+ public void buildPanel() {
+ ViewerPanel csVPanel = new ViewerPanel();
- contentPanel.add(new HTML("CZML Dynamic Polygon - Intervals and Availability.
"));
- contentPanel.add(csVPanel);
+ contentPanel.add(new HTML("CZML Dynamic Polygon - Intervals and Availability.
"));
+ contentPanel.add(csVPanel);
- initWidget(contentPanel);
- }
+ initWidget(contentPanel);
+ }
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CZMLPolygonIntervalsAvailability.txt";
- return sourceCodeURLs;
- }
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CZMLPolygonIntervalsAvailability.txt";
+ return sourceCodeURLs;
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CallbackProperty.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CallbackProperty.java
index 2b9720eeda56c99333f8ed38a31c0cc6962356e2..f05d9db017ca4c5fdbad1a3e4a1ff722450347e5 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CallbackProperty.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CallbackProperty.java
@@ -19,14 +19,7 @@ package org.cleanlogic.cesiumjs4gwt.showcase.examples;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.user.client.ui.HTML;
-import javax.inject.Inject;
-import org.cesiumjs.cs.core.Cartesian2;
-import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.Cartographic;
-import org.cesiumjs.cs.core.Color;
-import org.cesiumjs.cs.core.Ellipsoid;
-import org.cesiumjs.cs.core.EllipsoidGeodesic;
-import org.cesiumjs.cs.core.JulianDate;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.datasources.Entity;
import org.cesiumjs.cs.datasources.graphics.LabelGraphics;
import org.cesiumjs.cs.datasources.graphics.PolylineGraphics;
@@ -39,93 +32,94 @@ import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+import java.lang.Math;
+
/**
* CallbackProperty example.
+ *
* @author Serge Silaev aka iSergio
*/
public class CallbackProperty extends AbstractExample {
- private double startLatitude = 35;
- private double startLongitude = -120;
- private double endLongitude;
- private JulianDate startTime = JulianDate.now();
-
- private Entity redLine;
-
- private Cartographic startCartographic = Cartographic.fromDegrees(startLongitude, startLatitude);
-
- // use scratch object to avoid new allocations per frame.
- private Cartographic endCartographic = new Cartographic();
- private Cartographic scratch = new Cartographic();
- private EllipsoidGeodesic geodesic = new EllipsoidGeodesic();
-
- @Inject
- public CallbackProperty(ShowcaseExampleStore store) {
- super("Callback Property", "Callback property", new String[] {
- "Showcase", "3D Tiles", "Callback property"}, store);
- }
-
- @Override
- public void buildPanel() {
- final ViewerPanel csVPanel = new ViewerPanel();
- csVPanel.getViewer().clock().shouldAnimate = true;
-
- PolylineGraphicsOptions polylineGraphicsOptions = new PolylineGraphicsOptions();
- polylineGraphicsOptions.positions =
- new org.cesiumjs.cs.datasources.properties.CallbackProperty<>(
- (time, result) -> {
- endLongitude = startLongitude + 0.001 * JulianDate.secondsDifference(time, startTime);
- return Cartesian3.fromDegreesArray(
- new double[] { startLongitude, startLatitude, endLongitude, startLatitude },
- Ellipsoid.WGS84(), (Cartesian3[]) result);
- }, false);
-
- polylineGraphicsOptions.width = new ConstantProperty<>(5);
- polylineGraphicsOptions.material = new ColorMaterialProperty(Color.RED());
- EntityOptions options = new EntityOptions();
- options.polyline = new PolylineGraphics(polylineGraphicsOptions);
- redLine = csVPanel.getViewer().entities().add(options);
-
- LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
- labelGraphicsOptions.text = new org.cesiumjs.cs.datasources.properties.CallbackProperty<>(
- this::getLength, false);
- labelGraphicsOptions.font = new ConstantProperty<>("20px sans-serif");
- labelGraphicsOptions.pixelOffset = new ConstantProperty<>(new Cartesian2(0.0, 20));
- options = new EntityOptions();
- options.positionCallback = new org.cesiumjs.cs.datasources.properties.CallbackProperty<>(
- this::getMidpoint, false);
- options.label = new LabelGraphics(labelGraphicsOptions);
-
- csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(options);
-
- contentPanel.add(new HTML(""));
- contentPanel.add(csVPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CallbackProperty.txt";
- return sourceCodeURLs;
- }
-
- private Cartesian3 getMidpoint(JulianDate time, Cartesian3 result) {
- // Get the end position from the polyLine's callback.
- Cartesian3 endPoint = ((Cartesian3[]) redLine.polyline.positions.getValue(time))[1];
- endCartographic = Cartographic.fromCartesian(endPoint);
- geodesic.setEndPoints(startCartographic, endCartographic);
- Cartographic midpointCartographic = geodesic.interpolateUsingFraction(0.5, scratch);
- return Cartesian3.fromRadians(midpointCartographic.longitude, midpointCartographic.latitude);
- }
-
- private String getLength(JulianDate time, String result) {
- // Get the end position from the polyLine's callback.
- Cartesian3 endPoint = ((Cartesian3[]) redLine.polyline.positions.getValue(time))[1];
- endCartographic = Cartographic.fromCartesian(endPoint);
-
- geodesic.setEndPoints(startCartographic, endCartographic);
- double lengthInMeters = Math.round(geodesic.surfaceDistance());
- return NumberFormat.getFormat("#.#").format(lengthInMeters / 1000) + " km";
- }
+ private final double startLatitude = 35;
+ private final double startLongitude = -120;
+ private final JulianDate startTime = JulianDate.now();
+ private final Cartographic startCartographic = Cartographic.fromDegrees(startLongitude, startLatitude);
+ private final Cartographic scratch = new Cartographic();
+ private final EllipsoidGeodesic geodesic = new EllipsoidGeodesic();
+ private double endLongitude;
+ private Entity redLine;
+ // use scratch object to avoid new allocations per frame.
+ private Cartographic endCartographic = new Cartographic();
+
+ @Inject
+ public CallbackProperty(ShowcaseExampleStore store) {
+ super("Callback Property", "Callback property", new String[]{
+ "Showcase", "3D Tiles", "Callback property"}, store);
+ }
+
+ @Override
+ public void buildPanel() {
+ final ViewerPanel csVPanel = new ViewerPanel();
+ csVPanel.getViewer().clock().shouldAnimate = true;
+
+ PolylineGraphicsOptions polylineGraphicsOptions = new PolylineGraphicsOptions();
+ polylineGraphicsOptions.positions =
+ new org.cesiumjs.cs.datasources.properties.CallbackProperty<>(
+ (time, result) -> {
+ endLongitude = startLongitude + 0.001 * JulianDate.secondsDifference(time, startTime);
+ return Cartesian3.fromDegreesArray(
+ new double[]{startLongitude, startLatitude, endLongitude, startLatitude},
+ Ellipsoid.WGS84(), (Cartesian3[]) result);
+ }, false);
+
+ polylineGraphicsOptions.width = new ConstantProperty<>(5);
+ polylineGraphicsOptions.material = new ColorMaterialProperty(Color.RED());
+ EntityOptions options = new EntityOptions();
+ options.polyline = new PolylineGraphics(polylineGraphicsOptions);
+ redLine = csVPanel.getViewer().entities().add(options);
+
+ LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
+ labelGraphicsOptions.text = new org.cesiumjs.cs.datasources.properties.CallbackProperty<>(
+ this::getLength, false);
+ labelGraphicsOptions.font = new ConstantProperty<>("20px sans-serif");
+ labelGraphicsOptions.pixelOffset = new ConstantProperty<>(new Cartesian2(0.0, 20));
+ options = new EntityOptions();
+ options.positionCallback = new org.cesiumjs.cs.datasources.properties.CallbackProperty<>(
+ this::getMidpoint, false);
+ options.label = new LabelGraphics(labelGraphicsOptions);
+
+ csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(options);
+
+ contentPanel.add(new HTML(""));
+ contentPanel.add(csVPanel);
+
+ initWidget(contentPanel);
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CallbackProperty.txt";
+ return sourceCodeURLs;
+ }
+
+ private Cartesian3 getMidpoint(JulianDate time, Cartesian3 result) {
+ // Get the end position from the polyLine's callback.
+ Cartesian3 endPoint = ((Cartesian3[]) redLine.polyline.positions.getValue(time))[1];
+ endCartographic = Cartographic.fromCartesian(endPoint);
+ geodesic.setEndPoints(startCartographic, endCartographic);
+ Cartographic midpointCartographic = geodesic.interpolateUsingFraction(0.5, scratch);
+ return Cartesian3.fromRadians(midpointCartographic.longitude, midpointCartographic.latitude);
+ }
+
+ private String getLength(JulianDate time, String result) {
+ // Get the end position from the polyLine's callback.
+ Cartesian3 endPoint = ((Cartesian3[]) redLine.polyline.positions.getValue(time))[1];
+ endCartographic = Cartographic.fromCartesian(endPoint);
+
+ geodesic.setEndPoints(startCartographic, endCartographic);
+ double lengthInMeters = Math.round(geodesic.surfaceDistance());
+ return NumberFormat.getFormat("#.#").format(lengthInMeters / 1000) + " km";
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Camera.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Camera.java
index 616497cd31139855759c053e8ee48f1e691ab7a9..66fbcc0408528aa3032990d9b05fd7cbbfa50a6d 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Camera.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Camera.java
@@ -16,11 +16,6 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
@@ -28,18 +23,8 @@ import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
-
-import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.Color;
-import org.cesiumjs.cs.core.EasingFunction;
-import org.cesiumjs.cs.core.Event;
-import org.cesiumjs.cs.core.JulianDate;
import org.cesiumjs.cs.core.Math;
-import org.cesiumjs.cs.core.Matrix3;
-import org.cesiumjs.cs.core.Matrix4;
-import org.cesiumjs.cs.core.Rectangle;
-import org.cesiumjs.cs.core.Transforms;
-import org.cesiumjs.cs.core.Utils;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.datasources.Entity;
import org.cesiumjs.cs.datasources.graphics.RectangleGraphics;
import org.cesiumjs.cs.datasources.graphics.options.RectangleGraphicsOptions;
@@ -55,292 +40,296 @@ import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+
/**
* @author Serge Silaev aka iSergio
*/
public class Camera extends AbstractExample {
- private ViewerPanel csVPanel;
- private int _i = 0;
- private Label _eventsLbl;
- private Label _changesLbl;
-
- private Scene.Listener _icrf;
- private Event.RemoveCallback _removeStart;
- private Event.RemoveCallback _removeEnd;
- private Event.RemoveCallback _removeChanged;
-
- @Inject
- public Camera(ShowcaseExampleStore store) {
- super("Camera", "Fly to a specified location or view a geographic rectangle",
- new String[] { "Showcase", "Cesium", "3d", "flyTo" }, store);
- }
-
- @Override
- public void buildPanel() {
- csVPanel = new ViewerPanel();
-
- _eventsLbl = new Label("View Changed");
- _eventsLbl.getElement().getStyle().setColor("red");
- _eventsLbl.setVisible(false);
-
- _changesLbl = new Label();
- _changesLbl.getElement().getStyle().setColor("red");
- _changesLbl.setVisible(false);
-
- ListBox listBox = new ListBox();
- listBox.addItem("Camera Options", "0");
- listBox.addItem("Fly in a city", "1");
- listBox.addItem("Fly to San Diego", "2");
- listBox.addItem("Fly to Location with heading, pitch and roll", "3");
- listBox.addItem("Fly to My Location", "4");
- listBox.addItem("Fly to Rectangle", "5");
- listBox.addItem("View a Rectangle", "6");
- listBox.addItem("Set camera reference frame", "7");
- listBox.addItem("Set camera with heading, pitch, and roll", "8");
- listBox.addItem("View in ICRF", "9");
- listBox.addItem("Move events", "10");
- listBox.addItem("Camera changed event", "11");
- listBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent changeEvent) {
- reset();
- ListBox source = (ListBox) changeEvent.getSource();
- switch (source.getSelectedValue()) {
- case "1":
- flyInACity();
- break;
- case "2":
- flyToSanDiego();
- break;
- case "3":
- flyToHeadingPitchRoll();
- break;
- case "5":
- flyToRectangle();
- break;
- case "6":
- viewRectangle();
- break;
- case "7":
- setReferenceFrame();
- break;
- case "8":
- setHeadingPitchRoll();
- break;
- case "9":
- viewInICRF();
- break;
- case "10":
- cameraEvents();
- break;
- case "11":
- cameraChanges();
- break;
- default:
- break;
- }
- }
- });
-
- AbsolutePanel absPanel = new AbsolutePanel();
- absPanel.add(csVPanel);
- absPanel.add(listBox, 20, 20);
-
- contentPanel.add(
- new HTML("Fly to a specified location or view a geographic rectangle.
"));
- contentPanel.add(_eventsLbl);
- contentPanel.add(_changesLbl);
- contentPanel.add(absPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Camera.txt";
- return sourceCodeURLs;
- }
-
- private void flyInACity() {
- final CameraFlyToOptions cameraFlyToOptions = new CameraFlyToOptions();
- cameraFlyToOptions.destinationPos = Cartesian3.fromDegrees(-73.98580932617188,
- 40.74843406689482, 363.34038727246224);
- cameraFlyToOptions.complete = new org.cesiumjs.cs.scene.Camera.FlightCompleteCallback() {
- @Override
- public void on() {
- Utils.setTimeout(() -> {
- CameraFlyToOptions cameraFlyToOptions = new CameraFlyToOptions();
- cameraFlyToOptions.destinationPos = Cartesian3.fromDegrees(-73.98585975679403,
- 40.75759944127251, 186.50838555841779);
- cameraFlyToOptions.orientation = new org.cesiumjs.cs.core.HeadingPitchRoll(
- Math.toRadians(200.0), Math.toRadians(-50.0));
- cameraFlyToOptions.easingFunction = EasingFunction.LINEAR_NONE();
- csVPanel.getViewer().camera.flyTo(cameraFlyToOptions);
- }, 1000);
- }
- };
- csVPanel.getViewer().camera.flyTo(cameraFlyToOptions);
- }
-
- private void flyToSanDiego() {
- CameraFlyToOptions cameraFlyToOptions = new CameraFlyToOptions();
- cameraFlyToOptions.destinationPos = Cartesian3.fromDegrees(-117.16, 32.71, 15000.0);
- csVPanel.getViewer().camera.flyTo(cameraFlyToOptions);
- }
-
- private void flyToHeadingPitchRoll() {
- CameraFlyToOptions cameraFlyToOptions = new CameraFlyToOptions();
- cameraFlyToOptions.destinationPos = Cartesian3.fromDegrees(-122.22, 46.12, 5000.0);
- cameraFlyToOptions.orientation = new org.cesiumjs.cs.core.HeadingPitchRoll(Math.toRadians(20.0),
- Math.toRadians(-35.0), 0.0);
- csVPanel.getViewer().camera.flyTo(cameraFlyToOptions);
- }
-
- private void viewRectangle() {
- double west = -90.0;
- double south = 38.0;
- double east = -87.0;
- double north = 40.0;
- Rectangle rectangle = Rectangle.fromDegrees(west, south, east, north);
-
- ViewOptions viewOptions = new ViewOptions();
- viewOptions.destinationRec = rectangle;
- csVPanel.getViewer().camera.setView(viewOptions);
-
- RectangleGraphicsOptions rectangleGraphicsOptions = new RectangleGraphicsOptions();
- rectangleGraphicsOptions.coordinates = new ConstantProperty<>(rectangle);
- rectangleGraphicsOptions.fill = new ConstantProperty<>(false);
- rectangleGraphicsOptions.outline = new ConstantProperty<>(true);
- rectangleGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.rectangle = new RectangleGraphics(rectangleGraphicsOptions);
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
- }
-
- private void flyToRectangle() {
- double west = -90.0;
- double south = 38.0;
- double east = -87.0;
- double north = 40.0;
- Rectangle rectangle = Rectangle.fromDegrees(west, south, east, north);
-
- CameraFlyToOptions cameraFlyToOptions = new CameraFlyToOptions();
- cameraFlyToOptions.destinationRec = rectangle;
- csVPanel.getViewer().camera.flyTo(cameraFlyToOptions);
-
- RectangleGraphicsOptions rectangleGraphicsOptions = new RectangleGraphicsOptions();
- rectangleGraphicsOptions.coordinates = new ConstantProperty<>(rectangle);
- rectangleGraphicsOptions.fill = new ConstantProperty<>(false);
- rectangleGraphicsOptions.outline = new ConstantProperty<>(true);
- rectangleGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.rectangle = new RectangleGraphics(rectangleGraphicsOptions);
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
- }
-
- private void setReferenceFrame() {
- Cartesian3 center = Cartesian3.fromDegrees(-75.59777, 40.03883);
- Matrix4 transform = Transforms.eastNorthUpToFixedFrame(center);
-
- csVPanel.getViewer().camera.constrainedAxis = Cartesian3.UNIT_Z();
- csVPanel.getViewer().camera.lookAtTransform(transform, new Cartesian3(-120000.0, -120000.0,
- 120000.0));
-
- DebugModelMatrixPrimitiveOptions debugModelMatrixPrimitiveOptions = new DebugModelMatrixPrimitiveOptions();
- debugModelMatrixPrimitiveOptions.modelMatrix = transform;
- debugModelMatrixPrimitiveOptions.length = 100000.0;
- csVPanel.getViewer().scene().primitives().add(
- new DebugModelMatrixPrimitive(debugModelMatrixPrimitiveOptions));
- }
-
- private void setHeadingPitchRoll() {
- ViewOptions viewOptions = new ViewOptions();
- viewOptions.destinationPos = Cartesian3.fromDegrees(-75.5847, 40.0397, 1000.0);
- viewOptions.orientation = new org.cesiumjs.cs.core.HeadingPitchRoll(-Math.PI_OVER_TWO(),
- -Math.PI_OVER_FOUR(), 0.0);
- csVPanel.getViewer().camera.setView(viewOptions);
- }
-
- private void viewInICRF() {
- _icrf = (scene, time) -> {
- if (scene.mode != SceneMode.SCENE3D()) {
- return;
- }
- Matrix3 icrfToFixed = Transforms.computeIcrfToFixedMatrix(time);
- if (icrfToFixed != null) {
- Cartesian3 offset = Cartesian3.clone(csVPanel.getViewer().camera.position, null);
- Matrix4 transform = Matrix4.fromRotationTranslation(icrfToFixed);
- csVPanel.getViewer().camera.lookAtTransform(transform, offset);
- }
- };
- csVPanel.getViewer().camera.flyHome(0);
-
- csVPanel.getViewer().clock().multiplier = 3 * 60 * 60;
- csVPanel.getViewer().scene().preRender().addEventListener(_icrf);
- csVPanel.getViewer().scene().globe.enableLighting = true;
- }
-
- public void cameraEvents() {
- _removeStart = csVPanel.getViewer().camera.moveStart()
- .addEventListener(new org.cesiumjs.cs.scene.Camera.MoveListener() {
- @Override
- public void function() {
- _eventsLbl.setVisible(true);
- }
- });
- _removeEnd = csVPanel.getViewer().camera.moveEnd()
- .addEventListener(new org.cesiumjs.cs.scene.Camera.MoveListener() {
- @Override
- public void function() {
- _eventsLbl.setVisible(false);
- }
- });
- }
-
- private void cameraChanges() {
- _removeChanged = csVPanel.getViewer().camera.changed()
- .addEventListener(new org.cesiumjs.cs.scene.Camera.ChangedListener() {
- @Override
- public void function(double percentage) {
- ++_i;
- _changesLbl.setText("Camera Changed: " + _i + ", "
- + new BigDecimal(percentage).setScale(6, RoundingMode.HALF_EVEN).toString());
- _changesLbl.setVisible(true);
- }
+ private ViewerPanel csVPanel;
+ private int _i = 0;
+ private Label _eventsLbl;
+ private Label _changesLbl;
+
+ private Scene.Listener _icrf;
+ private Event.RemoveCallback _removeStart;
+ private Event.RemoveCallback _removeEnd;
+ private Event.RemoveCallback _removeChanged;
+
+ @Inject
+ public Camera(ShowcaseExampleStore store) {
+ super("Camera", "Fly to a specified location or view a geographic rectangle",
+ new String[]{"Showcase", "Cesium", "3d", "flyTo"}, store);
+ }
+
+ @Override
+ public void buildPanel() {
+ csVPanel = new ViewerPanel();
+
+ _eventsLbl = new Label("View Changed");
+ _eventsLbl.getElement().getStyle().setColor("red");
+ _eventsLbl.setVisible(false);
+
+ _changesLbl = new Label();
+ _changesLbl.getElement().getStyle().setColor("red");
+ _changesLbl.setVisible(false);
+
+ ListBox listBox = new ListBox();
+ listBox.addItem("Camera Options", "0");
+ listBox.addItem("Fly in a city", "1");
+ listBox.addItem("Fly to San Diego", "2");
+ listBox.addItem("Fly to Location with heading, pitch and roll", "3");
+ listBox.addItem("Fly to My Location", "4");
+ listBox.addItem("Fly to Rectangle", "5");
+ listBox.addItem("View a Rectangle", "6");
+ listBox.addItem("Set camera reference frame", "7");
+ listBox.addItem("Set camera with heading, pitch, and roll", "8");
+ listBox.addItem("View in ICRF", "9");
+ listBox.addItem("Move events", "10");
+ listBox.addItem("Camera changed event", "11");
+ listBox.addChangeHandler(new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent changeEvent) {
+ reset();
+ ListBox source = (ListBox) changeEvent.getSource();
+ switch (source.getSelectedValue()) {
+ case "1":
+ flyInACity();
+ break;
+ case "2":
+ flyToSanDiego();
+ break;
+ case "3":
+ flyToHeadingPitchRoll();
+ break;
+ case "5":
+ flyToRectangle();
+ break;
+ case "6":
+ viewRectangle();
+ break;
+ case "7":
+ setReferenceFrame();
+ break;
+ case "8":
+ setHeadingPitchRoll();
+ break;
+ case "9":
+ viewInICRF();
+ break;
+ case "10":
+ cameraEvents();
+ break;
+ case "11":
+ cameraChanges();
+ break;
+ default:
+ break;
+ }
+ }
});
- }
- private void reset() {
- csVPanel.getViewer().scene().completeMorph();
- csVPanel.getViewer().entities().removeAll();
- csVPanel.getViewer().scene().primitives().removeAll();
- // csVPanel.getViewer().scene().tweens().removeAll();
+ AbsolutePanel absPanel = new AbsolutePanel();
+ absPanel.add(csVPanel);
+ absPanel.add(listBox, 20, 20);
+
+ contentPanel.add(
+ new HTML("Fly to a specified location or view a geographic rectangle.
"));
+ contentPanel.add(_eventsLbl);
+ contentPanel.add(_changesLbl);
+ contentPanel.add(absPanel);
+
+ initWidget(contentPanel);
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Camera.txt";
+ return sourceCodeURLs;
+ }
+
+ private void flyInACity() {
+ final CameraFlyToOptions cameraFlyToOptions = new CameraFlyToOptions();
+ cameraFlyToOptions.destinationPos = Cartesian3.fromDegrees(-73.98580932617188,
+ 40.74843406689482, 363.34038727246224);
+ cameraFlyToOptions.complete = new org.cesiumjs.cs.scene.Camera.FlightCompleteCallback() {
+ @Override
+ public void on() {
+ Utils.setTimeout(() -> {
+ CameraFlyToOptions cameraFlyToOptions = new CameraFlyToOptions();
+ cameraFlyToOptions.destinationPos = Cartesian3.fromDegrees(-73.98585975679403,
+ 40.75759944127251, 186.50838555841779);
+ cameraFlyToOptions.orientation = new org.cesiumjs.cs.core.HeadingPitchRoll(
+ Math.toRadians(200.0), Math.toRadians(-50.0));
+ cameraFlyToOptions.easingFunction = EasingFunction.LINEAR_NONE();
+ csVPanel.getViewer().camera.flyTo(cameraFlyToOptions);
+ }, 1000);
+ }
+ };
+ csVPanel.getViewer().camera.flyTo(cameraFlyToOptions);
+ }
+
+ private void flyToSanDiego() {
+ CameraFlyToOptions cameraFlyToOptions = new CameraFlyToOptions();
+ cameraFlyToOptions.destinationPos = Cartesian3.fromDegrees(-117.16, 32.71, 15000.0);
+ csVPanel.getViewer().camera.flyTo(cameraFlyToOptions);
+ }
+
+ private void flyToHeadingPitchRoll() {
+ CameraFlyToOptions cameraFlyToOptions = new CameraFlyToOptions();
+ cameraFlyToOptions.destinationPos = Cartesian3.fromDegrees(-122.22, 46.12, 5000.0);
+ cameraFlyToOptions.orientation = new org.cesiumjs.cs.core.HeadingPitchRoll(Math.toRadians(20.0),
+ Math.toRadians(-35.0), 0.0);
+ csVPanel.getViewer().camera.flyTo(cameraFlyToOptions);
+ }
+
+ private void viewRectangle() {
+ double west = -90.0;
+ double south = 38.0;
+ double east = -87.0;
+ double north = 40.0;
+ Rectangle rectangle = Rectangle.fromDegrees(west, south, east, north);
+
+ ViewOptions viewOptions = new ViewOptions();
+ viewOptions.destinationRec = rectangle;
+ csVPanel.getViewer().camera.setView(viewOptions);
+
+ RectangleGraphicsOptions rectangleGraphicsOptions = new RectangleGraphicsOptions();
+ rectangleGraphicsOptions.coordinates = new ConstantProperty<>(rectangle);
+ rectangleGraphicsOptions.fill = new ConstantProperty<>(false);
+ rectangleGraphicsOptions.outline = new ConstantProperty<>(true);
+ rectangleGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.rectangle = new RectangleGraphics(rectangleGraphicsOptions);
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ }
+
+ private void flyToRectangle() {
+ double west = -90.0;
+ double south = 38.0;
+ double east = -87.0;
+ double north = 40.0;
+ Rectangle rectangle = Rectangle.fromDegrees(west, south, east, north);
+
+ CameraFlyToOptions cameraFlyToOptions = new CameraFlyToOptions();
+ cameraFlyToOptions.destinationRec = rectangle;
+ csVPanel.getViewer().camera.flyTo(cameraFlyToOptions);
+
+ RectangleGraphicsOptions rectangleGraphicsOptions = new RectangleGraphicsOptions();
+ rectangleGraphicsOptions.coordinates = new ConstantProperty<>(rectangle);
+ rectangleGraphicsOptions.fill = new ConstantProperty<>(false);
+ rectangleGraphicsOptions.outline = new ConstantProperty<>(true);
+ rectangleGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.rectangle = new RectangleGraphics(rectangleGraphicsOptions);
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ }
+
+ private void setReferenceFrame() {
+ Cartesian3 center = Cartesian3.fromDegrees(-75.59777, 40.03883);
+ Matrix4 transform = Transforms.eastNorthUpToFixedFrame(center);
- if (_removeStart != null) {
- _removeStart.function();
- _removeEnd.function();
+ csVPanel.getViewer().camera.constrainedAxis = Cartesian3.UNIT_Z();
+ csVPanel.getViewer().camera.lookAtTransform(transform, new Cartesian3(-120000.0, -120000.0,
+ 120000.0));
- _removeStart = null;
- _removeEnd = null;
+ DebugModelMatrixPrimitiveOptions debugModelMatrixPrimitiveOptions = new DebugModelMatrixPrimitiveOptions();
+ debugModelMatrixPrimitiveOptions.modelMatrix = transform;
+ debugModelMatrixPrimitiveOptions.length = 100000.0;
+ csVPanel.getViewer().scene().primitives().add(
+ new DebugModelMatrixPrimitive(debugModelMatrixPrimitiveOptions));
+ }
- _eventsLbl.setVisible(false);
+ private void setHeadingPitchRoll() {
+ ViewOptions viewOptions = new ViewOptions();
+ viewOptions.destinationPos = Cartesian3.fromDegrees(-75.5847, 40.0397, 1000.0);
+ viewOptions.orientation = new org.cesiumjs.cs.core.HeadingPitchRoll(-Math.PI_OVER_TWO(),
+ -Math.PI_OVER_FOUR(), 0.0);
+ csVPanel.getViewer().camera.setView(viewOptions);
}
- if (_removeChanged != null) {
- _removeChanged.function();
- _removeChanged = null;
+ private void viewInICRF() {
+ _icrf = (scene, time) -> {
+ if (scene.mode != SceneMode.SCENE3D()) {
+ return;
+ }
+ Matrix3 icrfToFixed = Transforms.computeIcrfToFixedMatrix(time);
+ if (icrfToFixed != null) {
+ Cartesian3 offset = Cartesian3.clone(csVPanel.getViewer().camera.position, null);
+ Matrix4 transform = Matrix4.fromRotationTranslation(icrfToFixed);
+ csVPanel.getViewer().camera.lookAtTransform(transform, offset);
+ }
+ };
+ csVPanel.getViewer().camera.flyHome(0);
+
+ csVPanel.getViewer().clock().multiplier = 3 * 60 * 60;
+ csVPanel.getViewer().scene().preRender().addEventListener(_icrf);
+ csVPanel.getViewer().scene().globe.enableLighting = true;
+ }
- _changesLbl.setVisible(false);
+ public void cameraEvents() {
+ _removeStart = csVPanel.getViewer().camera.moveStart()
+ .addEventListener(new org.cesiumjs.cs.scene.Camera.MoveListener() {
+ @Override
+ public void function() {
+ _eventsLbl.setVisible(true);
+ }
+ });
+ _removeEnd = csVPanel.getViewer().camera.moveEnd()
+ .addEventListener(new org.cesiumjs.cs.scene.Camera.MoveListener() {
+ @Override
+ public void function() {
+ _eventsLbl.setVisible(false);
+ }
+ });
}
- csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
+ private void cameraChanges() {
+ _removeChanged = csVPanel.getViewer().camera.changed()
+ .addEventListener(new org.cesiumjs.cs.scene.Camera.ChangedListener() {
+ @Override
+ public void function(double percentage) {
+ ++_i;
+ _changesLbl.setText("Camera Changed: " + _i + ", "
+ + new BigDecimal(percentage).setScale(6, RoundingMode.HALF_EVEN).toString());
+ _changesLbl.setVisible(true);
+ }
+ });
+ }
- csVPanel.getViewer().clock().multiplier = 1.0;
- if (_icrf != null) {
- csVPanel.getViewer().scene().preRender().removeEventListener(_icrf);
- _icrf = null;
+ private void reset() {
+ csVPanel.getViewer().scene().completeMorph();
+ csVPanel.getViewer().entities().removeAll();
+ csVPanel.getViewer().scene().primitives().removeAll();
+ // csVPanel.getViewer().scene().tweens().removeAll();
+
+ if (_removeStart != null) {
+ _removeStart.function();
+ _removeEnd.function();
+
+ _removeStart = null;
+ _removeEnd = null;
+
+ _eventsLbl.setVisible(false);
+ }
+
+ if (_removeChanged != null) {
+ _removeChanged.function();
+ _removeChanged = null;
+
+ _changesLbl.setVisible(false);
+ }
+
+ csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
+
+ csVPanel.getViewer().clock().multiplier = 1.0;
+ if (_icrf != null) {
+ csVPanel.getViewer().scene().preRender().removeEventListener(_icrf);
+ _icrf = null;
+ }
+ csVPanel.getViewer().scene().globe.enableLighting = false;
}
- csVPanel.getViewer().scene().globe.enableLighting = false;
- }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CameraTutorial.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CameraTutorial.java
index 5fa6d440834cfafc94fce67fbadf09e227c39756..1222b616fd697c942c7ba68f20f917bde2c064fb 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CameraTutorial.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CameraTutorial.java
@@ -16,19 +16,11 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.dom.client.KeyDownEvent;
-import com.google.gwt.event.dom.client.KeyDownHandler;
-import com.google.gwt.event.dom.client.KeyUpEvent;
-import com.google.gwt.event.dom.client.KeyUpHandler;
+import com.google.gwt.event.dom.client.*;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
-
import org.cesiumjs.cs.core.Cartesian3;
import org.cesiumjs.cs.core.Clock;
import org.cesiumjs.cs.core.Event;
@@ -38,198 +30,198 @@ import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class CameraTutorial extends AbstractExample {
- private ViewerPanel csVPanel;
-
- private class Flags {
- public boolean looking = false;
- public boolean moveForward = false;
- public boolean moveBackward = false;
- public boolean moveUp = false;
- public boolean moveDown = false;
- public boolean moveLeft = false;
- public boolean moveRight = false;
-
- public Flags() {
+ private final Flags flags = new Flags();
+ private ViewerPanel csVPanel;
+ private Cartesian3 mousePosition;
+ private Cartesian3 startMousePosition;
+ private ScreenSpaceEventHandler handler;
+
+ @Inject
+ public CameraTutorial(ShowcaseExampleStore store) {
+ super("Camera Tutorial", "Use the camera to control the view, and create custom event handlers for input",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer", "Camera"}, store);
+ }
+
+ @Override
+ public void buildPanel() {
+ csVPanel = new ViewerPanel();
+ csVPanel.addHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent clickEvent) {
+ csVPanel.getViewer().canvas().focus();
+ }
+ }, ClickEvent.getType());
+
+ csVPanel.getViewer().canvas().setAttribute("tabindex", "0");
+
+ csVPanel.getViewer().scene().screenSpaceCameraController().enableRotate = false;
+ csVPanel.getViewer().scene().screenSpaceCameraController().enableTranslate = false;
+ csVPanel.getViewer().scene().screenSpaceCameraController().enableZoom = false;
+ csVPanel.getViewer().scene().screenSpaceCameraController().enableTilt = false;
+ csVPanel.getViewer().scene().screenSpaceCameraController().enableLook = false;
+
+ handler = new ScreenSpaceEventHandler(csVPanel.getViewer().canvas());
+ handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
+ @Override
+ public void function(org.cesiumjs.cs.core.events.MouseDownEvent event) {
+ flags.looking = true;
+ mousePosition = startMousePosition = new Cartesian3(event.position.x, event.position.y, 0);
+ }
+ }, ScreenSpaceEventType.LEFT_DOWN());
+
+ handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
+ @Override
+ public void function(org.cesiumjs.cs.core.events.MouseMoveEvent event) {
+ mousePosition = new Cartesian3(event.endPosition.x, event.endPosition.y, 0);
+ }
+ }, ScreenSpaceEventType.MOUSE_MOVE());
+
+ handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
+ @Override
+ public void function(org.cesiumjs.cs.core.events.MouseUpEvent event) {
+ flags.looking = false;
+ }
+ }, ScreenSpaceEventType.LEFT_UP());
+
+ RootPanel.get().addDomHandler(new KeyDownHandler() {
+ @Override
+ public void onKeyDown(KeyDownEvent keyDownEvent) {
+ setFlag(keyDownEvent.getNativeKeyCode(), true);
+ }
+ }, KeyDownEvent.getType());
+
+ RootPanel.get().addDomHandler(new KeyUpHandler() {
+ @Override
+ public void onKeyUp(KeyUpEvent keyUpEvent) {
+ setFlag(keyUpEvent.getNativeKeyCode(), false);
+ }
+ }, KeyUpEvent.getType());
+
+ csVPanel.getViewer().clock().onTick.addEventListener(new Event.Listener() {
+ @Override
+ public void function(Object... o) {
+ org.cesiumjs.cs.scene.Camera camera = csVPanel.getViewer().camera;
+ // First element in array is Clock. Check this.
+ if (o[0] instanceof Clock) {
+ if (flags.looking) {
+ int width = csVPanel.getViewer().canvas().getClientWidth();
+ int height = csVPanel.getViewer().canvas().getClientHeight();
+
+ // Coordinate (0.0, 0.0) will be where the mouse was clicked.
+ double x = (mousePosition.x - startMousePosition.x) / width;
+ double y = -(mousePosition.y - startMousePosition.y) / height;
+
+ double lookFactor = 0.05;
+ camera.lookRight(x * lookFactor);
+ camera.lookUp(y * lookFactor);
+ }
+
+ // Change movement speed based on the distance of the camera to the surface of
+ // the ellipsoid.
+ double cameraHeight = csVPanel.getViewer().scene().globe.ellipsoid
+ .cartesianToCartographic(camera.position).height;
+ double moveRate = cameraHeight / 100.0;
+
+ if (flags.moveForward) {
+ camera.moveForward(moveRate);
+ }
+ if (flags.moveBackward) {
+ camera.moveBackward(moveRate);
+ }
+ if (flags.moveUp) {
+ camera.moveUp(moveRate);
+ }
+ if (flags.moveDown) {
+ camera.moveDown(moveRate);
+ }
+ if (flags.moveLeft) {
+ camera.moveLeft(moveRate);
+ }
+ if (flags.moveRight) {
+ camera.moveRight(moveRate);
+ }
+ }
+ }
+ });
+
+ HTML html = new HTML();
+ html.setHTML("");
+ html.getElement().getStyle().setColor("white");
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(html, 20, 20);
+
+ contentPanel
+ .add(new HTML("Use the camera to control the view, and create custom event handlers for input.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Camera Tutorial.txt";
+ return sourceCodeURLs;
+ }
+
+ private String getFlagForKeyCode(int keyCode) {
+ if ("W".codePointAt(0) == keyCode) {
+ return "moveForward";
+ } else if ("S".codePointAt(0) == keyCode) {
+ return "moveBackward";
+ } else if ("Q".codePointAt(0) == keyCode) {
+ return "moveUp";
+ } else if ("E".codePointAt(0) == keyCode) {
+ return "moveDown";
+ } else if ("D".codePointAt(0) == keyCode) {
+ return "moveRight";
+ } else if ("A".codePointAt(0) == keyCode) {
+ return "moveLeft";
+ } else {
+ return null;
+ }
}
- }
-
- private Cartesian3 mousePosition;
- private Cartesian3 startMousePosition;
-
- private ScreenSpaceEventHandler handler;
- private Flags flags = new Flags();
-
- @Inject
- public CameraTutorial(ShowcaseExampleStore store) {
- super("Camera Tutorial", "Use the camera to control the view, and create custom event handlers for input",
- new String[] { "Showcase", "Cesium", "3d", "Viewer", "Camera" }, store);
- }
-
- @Override
- public void buildPanel() {
- csVPanel = new ViewerPanel();
- csVPanel.addHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent clickEvent) {
- csVPanel.getViewer().canvas().focus();
- }
- }, ClickEvent.getType());
-
- csVPanel.getViewer().canvas().setAttribute("tabindex", "0");
-
- csVPanel.getViewer().scene().screenSpaceCameraController().enableRotate = false;
- csVPanel.getViewer().scene().screenSpaceCameraController().enableTranslate = false;
- csVPanel.getViewer().scene().screenSpaceCameraController().enableZoom = false;
- csVPanel.getViewer().scene().screenSpaceCameraController().enableTilt = false;
- csVPanel.getViewer().scene().screenSpaceCameraController().enableLook = false;
-
- handler = new ScreenSpaceEventHandler(csVPanel.getViewer().canvas());
- handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
- @Override
- public void function(org.cesiumjs.cs.core.events.MouseDownEvent event) {
- flags.looking = true;
- mousePosition = startMousePosition = new Cartesian3(event.position.x, event.position.y, 0);
- }
- }, ScreenSpaceEventType.LEFT_DOWN());
-
- handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
- @Override
- public void function(org.cesiumjs.cs.core.events.MouseMoveEvent event) {
- mousePosition = new Cartesian3(event.endPosition.x, event.endPosition.y, 0);
- }
- }, ScreenSpaceEventType.MOUSE_MOVE());
-
- handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
- @Override
- public void function(org.cesiumjs.cs.core.events.MouseUpEvent event) {
- flags.looking = false;
- }
- }, ScreenSpaceEventType.LEFT_UP());
-
- RootPanel.get().addDomHandler(new KeyDownHandler() {
- @Override
- public void onKeyDown(KeyDownEvent keyDownEvent) {
- setFlag(keyDownEvent.getNativeKeyCode(), true);
- }
- }, KeyDownEvent.getType());
-
- RootPanel.get().addDomHandler(new KeyUpHandler() {
- @Override
- public void onKeyUp(KeyUpEvent keyUpEvent) {
- setFlag(keyUpEvent.getNativeKeyCode(), false);
- }
- }, KeyUpEvent.getType());
-
- csVPanel.getViewer().clock().onTick.addEventListener(new Event.Listener() {
- @Override
- public void function(Object... o) {
- org.cesiumjs.cs.scene.Camera camera = csVPanel.getViewer().camera;
- // First element in array is Clock. Check this.
- if (o[0] instanceof Clock) {
- if (flags.looking) {
- int width = csVPanel.getViewer().canvas().getClientWidth();
- int height = csVPanel.getViewer().canvas().getClientHeight();
-
- // Coordinate (0.0, 0.0) will be where the mouse was clicked.
- double x = (mousePosition.x - startMousePosition.x) / width;
- double y = -(mousePosition.y - startMousePosition.y) / height;
-
- double lookFactor = 0.05;
- camera.lookRight(x * lookFactor);
- camera.lookUp(y * lookFactor);
- }
-
- // Change movement speed based on the distance of the camera to the surface of
- // the ellipsoid.
- double cameraHeight = csVPanel.getViewer().scene().globe.ellipsoid
- .cartesianToCartographic(camera.position).height;
- double moveRate = cameraHeight / 100.0;
-
- if (flags.moveForward) {
- camera.moveForward(moveRate);
- }
- if (flags.moveBackward) {
- camera.moveBackward(moveRate);
- }
- if (flags.moveUp) {
- camera.moveUp(moveRate);
- }
- if (flags.moveDown) {
- camera.moveDown(moveRate);
- }
- if (flags.moveLeft) {
- camera.moveLeft(moveRate);
- }
- if (flags.moveRight) {
- camera.moveRight(moveRate);
- }
+
+ private void setFlag(int keyCode, boolean flag) {
+ String flagName = getFlagForKeyCode(keyCode);
+ if (flagName != null) {
+ if (flagName.equalsIgnoreCase("moveForward")) {
+ flags.moveForward = flag;
+ } else if (flagName.equalsIgnoreCase("moveBackward")) {
+ flags.moveBackward = flag;
+ } else if (flagName.equalsIgnoreCase("moveUp")) {
+ flags.moveUp = flag;
+ } else if (flagName.equalsIgnoreCase("moveDown")) {
+ flags.moveDown = flag;
+ } else if (flagName.equalsIgnoreCase("moveLeft")) {
+ flags.moveLeft = flag;
+ } else if (flagName.equalsIgnoreCase("moveRight")) {
+ flags.moveRight = flag;
+ }
}
- }
- });
-
- HTML html = new HTML();
- html.setHTML("");
- html.getElement().getStyle().setColor("white");
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(html, 20, 20);
-
- contentPanel
- .add(new HTML("Use the camera to control the view, and create custom event handlers for input.
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Camera Tutorial.txt";
- return sourceCodeURLs;
- }
-
- private String getFlagForKeyCode(int keyCode) {
- if ("W".codePointAt(0) == keyCode) {
- return "moveForward";
- } else if ("S".codePointAt(0) == keyCode) {
- return "moveBackward";
- } else if ("Q".codePointAt(0) == keyCode) {
- return "moveUp";
- } else if ("E".codePointAt(0) == keyCode) {
- return "moveDown";
- } else if ("D".codePointAt(0) == keyCode) {
- return "moveRight";
- } else if ("A".codePointAt(0) == keyCode) {
- return "moveLeft";
- } else {
- return null;
}
- }
-
- private void setFlag(int keyCode, boolean flag) {
- String flagName = getFlagForKeyCode(keyCode);
- if (flagName != null) {
- if (flagName.equalsIgnoreCase("moveForward")) {
- flags.moveForward = flag;
- } else if (flagName.equalsIgnoreCase("moveBackward")) {
- flags.moveBackward = flag;
- } else if (flagName.equalsIgnoreCase("moveUp")) {
- flags.moveUp = flag;
- } else if (flagName.equalsIgnoreCase("moveDown")) {
- flags.moveDown = flag;
- } else if (flagName.equalsIgnoreCase("moveLeft")) {
- flags.moveLeft = flag;
- } else if (flagName.equalsIgnoreCase("moveRight")) {
- flags.moveRight = flag;
- }
+
+ private class Flags {
+ public boolean looking = false;
+ public boolean moveForward = false;
+ public boolean moveBackward = false;
+ public boolean moveUp = false;
+ public boolean moveDown = false;
+ public boolean moveLeft = false;
+ public boolean moveRight = false;
+
+ public Flags() {
+ }
}
- }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Cardboard.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Cardboard.java
index 3640cbd457e4090d2b6b5cb91da016284596906e..c00c983ecf5c28057004bb7f1b856d6c4fc670bf 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Cardboard.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Cardboard.java
@@ -16,21 +16,12 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.HTML;
-
import org.cesiumjs.cs.Cesium;
import org.cesiumjs.cs.collections.TimeIntervalCollection;
-import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.JulianDate;
import org.cesiumjs.cs.core.Math;
-import org.cesiumjs.cs.core.Matrix3;
-import org.cesiumjs.cs.core.Matrix4;
-import org.cesiumjs.cs.core.Quaternion;
-import org.cesiumjs.cs.core.TimeInterval;
-import org.cesiumjs.cs.core.Transforms;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.core.enums.ClockRange;
import org.cesiumjs.cs.core.interpolation.HermitePolynomialApproximation;
import org.cesiumjs.cs.core.options.TimeIntervalOptions;
@@ -50,167 +41,169 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class Cardboard extends AbstractExample {
- private JulianDate start;
- private JulianDate stop;
- private Entity entity;
-
- @Inject
- public Cardboard(ShowcaseExampleStore store) {
- super("Cardboard", "Configure viewer to add a button enabling look at a mobile device with cardboard",
- new String[] { "Showcase", "Cesium", "3d", "Viewer" }, store);
- }
-
- @Override
- public void buildPanel() {
- ViewerOptions viewerOptions = new ViewerOptions();
- viewerOptions.vrButton = true;
-
- ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
-
- csVPanel.getViewer().scene().globe.enableLighting = true;
-
- CesiumTerrainProviderOptions cesiumTerrainProviderOptions = new CesiumTerrainProviderOptions();
- cesiumTerrainProviderOptions.url = "https://assets.agi.com/stk-terrain/world";
- cesiumTerrainProviderOptions.requestVertexNormals = true;
- csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(cesiumTerrainProviderOptions);
-
- csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;
-
- // Follow the path of a plane. See the interpolation Sandcastle example.
- Math.setRandomNumberSeed(3);
-
- start = JulianDate.fromDate(new JsDate(2015, 2, 25, 16));
- stop = JulianDate.addSeconds(start, 360, new JulianDate());
-
- csVPanel.getViewer().clock().startTime = start.clone();
- csVPanel.getViewer().clock().stopTime = stop.clone();
- csVPanel.getViewer().clock().currentTime = start.clone();
- csVPanel.getViewer().clock().clockRange = ClockRange.LOOP_STOP();
- csVPanel.getViewer().clock().multiplier = 1.0;
-
- double lon = -112.110693;
- double lat = 36.0994841;
- double radius = 0.03;
-
- String modelURI = GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb";
- EntityOptions entityOptions = new EntityOptions();
- TimeIntervalOptions timeIntervalOptions = new TimeIntervalOptions();
- timeIntervalOptions.start = start;
- timeIntervalOptions.stop = stop;
- entityOptions.availability = new TimeIntervalCollection(
- new TimeInterval[] { new TimeInterval(timeIntervalOptions) });
- entityOptions.position = computeCirclularFlight(lon, lat, radius);
- ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(modelURI);
- modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(64);
- entityOptions.model = new ModelGraphics(modelGraphicsOptions);
- entity = csVPanel.getViewer().entities().add(entityOptions);
-
- SampledPropertyInterpolationOptions sampledPropertyInterpolationOptions = new SampledPropertyInterpolationOptions();
- sampledPropertyInterpolationOptions.interpolationDegree = 2;
- sampledPropertyInterpolationOptions.interpolationAlgorithm = HermitePolynomialApproximation.instance();
- ((SampledPositionProperty) entity.position).setInterpolationOptions(sampledPropertyInterpolationOptions);
-
- // Set initial camera position and orientation to be when in the model's
- // reference frame.
- final org.cesiumjs.cs.scene.Camera camera = csVPanel.getViewer().camera;
- camera.position = new Cartesian3(0.25, 0.0, 0.0);
- camera.direction = new Cartesian3(1.0, 0.0, 0.0);
- camera.up = new Cartesian3(0.0, 0.0, 1.0);
- camera.right = new Cartesian3(0.0, -1.0, 0.0);
-
- csVPanel.getViewer().scene().preRender().addEventListener(new Scene.Listener() {
- @Override
- public void function(Scene scene, JulianDate time) {
- Cartesian3 position = entity.position.getValue(time);
- if (position == null || !Cesium.defined(position)) {
- return;
+ private JulianDate start;
+ private JulianDate stop;
+ private Entity entity;
+
+ @Inject
+ public Cardboard(ShowcaseExampleStore store) {
+ super("Cardboard", "Configure viewer to add a button enabling look at a mobile device with cardboard",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer"}, store);
+ }
+
+ @Override
+ public void buildPanel() {
+ ViewerOptions viewerOptions = new ViewerOptions();
+ viewerOptions.vrButton = true;
+
+ ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
+
+ csVPanel.getViewer().scene().globe.enableLighting = true;
+
+ CesiumTerrainProviderOptions cesiumTerrainProviderOptions = new CesiumTerrainProviderOptions();
+ cesiumTerrainProviderOptions.url = "https://assets.agi.com/stk-terrain/world";
+ cesiumTerrainProviderOptions.requestVertexNormals = true;
+ csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(cesiumTerrainProviderOptions);
+
+ csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;
+
+ // Follow the path of a plane. See the interpolation Sandcastle example.
+ Math.setRandomNumberSeed(3);
+
+ start = JulianDate.fromDate(new JsDate(2015, 2, 25, 16));
+ stop = JulianDate.addSeconds(start, 360, new JulianDate());
+
+ csVPanel.getViewer().clock().startTime = start.clone();
+ csVPanel.getViewer().clock().stopTime = stop.clone();
+ csVPanel.getViewer().clock().currentTime = start.clone();
+ csVPanel.getViewer().clock().clockRange = ClockRange.LOOP_STOP();
+ csVPanel.getViewer().clock().multiplier = 1.0;
+
+ double lon = -112.110693;
+ double lat = 36.0994841;
+ double radius = 0.03;
+
+ String modelURI = GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb";
+ EntityOptions entityOptions = new EntityOptions();
+ TimeIntervalOptions timeIntervalOptions = new TimeIntervalOptions();
+ timeIntervalOptions.start = start;
+ timeIntervalOptions.stop = stop;
+ entityOptions.availability = new TimeIntervalCollection(
+ new TimeInterval[]{new TimeInterval(timeIntervalOptions)});
+ entityOptions.position = computeCirclularFlight(lon, lat, radius);
+ ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
+ modelGraphicsOptions.uri = new ConstantProperty<>(modelURI);
+ modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(64);
+ entityOptions.model = new ModelGraphics(modelGraphicsOptions);
+ entity = csVPanel.getViewer().entities().add(entityOptions);
+
+ SampledPropertyInterpolationOptions sampledPropertyInterpolationOptions = new SampledPropertyInterpolationOptions();
+ sampledPropertyInterpolationOptions.interpolationDegree = 2;
+ sampledPropertyInterpolationOptions.interpolationAlgorithm = HermitePolynomialApproximation.instance();
+ ((SampledPositionProperty) entity.position).setInterpolationOptions(sampledPropertyInterpolationOptions);
+
+ // Set initial camera position and orientation to be when in the model's
+ // reference frame.
+ final org.cesiumjs.cs.scene.Camera camera = csVPanel.getViewer().camera;
+ camera.position = new Cartesian3(0.25, 0.0, 0.0);
+ camera.direction = new Cartesian3(1.0, 0.0, 0.0);
+ camera.up = new Cartesian3(0.0, 0.0, 1.0);
+ camera.right = new Cartesian3(0.0, -1.0, 0.0);
+
+ csVPanel.getViewer().scene().preRender().addEventListener(new Scene.Listener() {
+ @Override
+ public void function(Scene scene, JulianDate time) {
+ Cartesian3 position = entity.position.getValue(time);
+ if (position == null || !Cesium.defined(position)) {
+ return;
+ }
+
+ Matrix4 transform;
+ if (!Cesium.defined(entity.orientation)) {
+ transform = Transforms.eastNorthUpToFixedFrame(position);
+ } else {
+ Quaternion orientation = (Quaternion) entity.orientation.getValue(time);
+ if (!Cesium.defined(orientation)) {
+ return;
+ }
+
+ transform = Matrix4.fromRotationTranslation(Matrix3.fromQuaternion(orientation), position);
+ }
+
+ // Save camera state
+ Cartesian3 offset = camera.position.clone();
+ Cartesian3 direction = camera.direction.clone();
+ Cartesian3 up = camera.up.clone();
+
+ // Set camera to be in model's reference frame.
+ camera.lookAtTransform(transform);
+
+ // Reset the camera state to the saved state so it appears fixed in the model's
+ // frame.
+ offset.clone(camera.position);
+ direction.clone(camera.direction);
+ up.clone(camera.up);
+ Cartesian3.cross(direction, up, camera.right);
+ }
+ });
+
+ // Add a few more balloons flying with the one the viewer is in.
+ int numBalloons = 12;
+ for (int i = 0; i < numBalloons; ++i) {
+ double balloonRadius = (Math.nextRandomNumber() * 2.0 - 1.0) * 0.01 + radius;
+ entityOptions = new EntityOptions();
+ timeIntervalOptions = new TimeIntervalOptions();
+ timeIntervalOptions.start = start;
+ timeIntervalOptions.stop = stop;
+ entityOptions.availability = new TimeIntervalCollection(
+ new TimeInterval[]{new TimeInterval(timeIntervalOptions)});
+ entityOptions.position = computeCirclularFlight(lon, lat, balloonRadius);
+ modelGraphicsOptions = new ModelGraphicsOptions();
+ modelGraphicsOptions.uri = new ConstantProperty<>(modelURI);
+ modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(64);
+ entityOptions.model = new ModelGraphics(modelGraphicsOptions);
+ Entity balloon = csVPanel.getViewer().entities().add(entityOptions);
+
+ sampledPropertyInterpolationOptions = new SampledPropertyInterpolationOptions();
+ sampledPropertyInterpolationOptions.interpolationDegree = 2;
+ sampledPropertyInterpolationOptions.interpolationAlgorithm = HermitePolynomialApproximation.instance();
+ ((SampledPositionProperty) balloon.position).setInterpolationOptions(sampledPropertyInterpolationOptions);
}
- Matrix4 transform;
- if (!Cesium.defined(entity.orientation)) {
- transform = Transforms.eastNorthUpToFixedFrame(position);
- } else {
- Quaternion orientation = (Quaternion) entity.orientation.getValue(time);
- if (!Cesium.defined(orientation)) {
- return;
- }
+ contentPanel
+ .add(new HTML("Configure viewer to add a button enabling look at a mobile device with cardboard.
"));
+ contentPanel.add(csVPanel);
- transform = Matrix4.fromRotationTranslation(Matrix3.fromQuaternion(orientation), position);
- }
+ initWidget(contentPanel);
+ }
- // Save camera state
- Cartesian3 offset = camera.position.clone();
- Cartesian3 direction = camera.direction.clone();
- Cartesian3 up = camera.up.clone();
-
- // Set camera to be in model's reference frame.
- camera.lookAtTransform(transform);
-
- // Reset the camera state to the saved state so it appears fixed in the model's
- // frame.
- offset.clone(camera.position);
- direction.clone(camera.direction);
- up.clone(camera.up);
- Cartesian3.cross(direction, up, camera.right);
- }
- });
-
- // Add a few more balloons flying with the one the viewer is in.
- int numBalloons = 12;
- for (int i = 0; i < numBalloons; ++i) {
- double balloonRadius = (Math.nextRandomNumber() * 2.0 - 1.0) * 0.01 + radius;
- entityOptions = new EntityOptions();
- timeIntervalOptions = new TimeIntervalOptions();
- timeIntervalOptions.start = start;
- timeIntervalOptions.stop = stop;
- entityOptions.availability = new TimeIntervalCollection(
- new TimeInterval[] { new TimeInterval(timeIntervalOptions) });
- entityOptions.position = computeCirclularFlight(lon, lat, balloonRadius);
- modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(modelURI);
- modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(64);
- entityOptions.model = new ModelGraphics(modelGraphicsOptions);
- Entity balloon = csVPanel.getViewer().entities().add(entityOptions);
-
- sampledPropertyInterpolationOptions = new SampledPropertyInterpolationOptions();
- sampledPropertyInterpolationOptions.interpolationDegree = 2;
- sampledPropertyInterpolationOptions.interpolationAlgorithm = HermitePolynomialApproximation.instance();
- ((SampledPositionProperty) balloon.position).setInterpolationOptions(sampledPropertyInterpolationOptions);
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Cardboard.txt";
+ return sourceCodeURLs;
}
- contentPanel
- .add(new HTML("Configure viewer to add a button enabling look at a mobile device with cardboard.
"));
- contentPanel.add(csVPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Cardboard.txt";
- return sourceCodeURLs;
- }
-
- public SampledPositionProperty computeCirclularFlight(double lon, double lat, double radius) {
- SampledPositionProperty property = new SampledPositionProperty();
- double startAngle = Math.nextRandomNumber() * 360.0;
- double endAngle = startAngle + 360.0;
-
- double increment = (Math.nextRandomNumber() * 2.0 - 1.0) * 10.0 + 45.0;
- for (double i = startAngle; i < endAngle; i += increment) {
- double radians = Math.toRadians(i);
- double timeIncrement = i - startAngle;
- JulianDate time = JulianDate.addSeconds(start, (int) timeIncrement, new JulianDate());
- Cartesian3 position = Cartesian3.fromDegrees(lon + (radius * 1.5 * java.lang.Math.cos(radians)),
- lat + (radius * java.lang.Math.sin(radians)), Math.nextRandomNumber() * 500 + 1750);
- property.addSample(time, position);
+ public SampledPositionProperty computeCirclularFlight(double lon, double lat, double radius) {
+ SampledPositionProperty property = new SampledPositionProperty();
+ double startAngle = Math.nextRandomNumber() * 360.0;
+ double endAngle = startAngle + 360.0;
+
+ double increment = (Math.nextRandomNumber() * 2.0 - 1.0) * 10.0 + 45.0;
+ for (double i = startAngle; i < endAngle; i += increment) {
+ double radians = Math.toRadians(i);
+ double timeIncrement = i - startAngle;
+ JulianDate time = JulianDate.addSeconds(start, (int) timeIncrement, new JulianDate());
+ Cartesian3 position = Cartesian3.fromDegrees(lon + (radius * 1.5 * java.lang.Math.cos(radians)),
+ lat + (radius * java.lang.Math.sin(radians)), Math.nextRandomNumber() * 500 + 1750);
+ property.addSample(time, position);
+ }
+ return property;
}
- return property;
- }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CartographicLimitRectangle.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CartographicLimitRectangle.java
index b60e159d1524a4884a75b4babdd3fa0f6eb08530..aeefdb6156314a32a18100d871528fb364b18790 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CartographicLimitRectangle.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CartographicLimitRectangle.java
@@ -16,9 +16,6 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import java.util.ArrayList;
-import java.util.List;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
@@ -27,7 +24,6 @@ import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.inject.Inject;
-
import org.cesiumjs.cs.Cesium;
import org.cesiumjs.cs.core.Color;
import org.cesiumjs.cs.core.Rectangle;
@@ -42,91 +38,94 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* @author Serge Silaev aka iSergio
*/
public class CartographicLimitRectangle extends AbstractExample {
- private ViewerPanel csVPanel;
-
- @Inject
- public CartographicLimitRectangle(ShowcaseExampleStore store) {
- super("Cartographic Limit Rectangle", "Limit terrain and imagery to a cartographic Rectangle area.",
- new String[] { "Terrain", "Cartographic", "Limit", "Rectangle" }, store);
- }
-
- @Override
- public void buildPanel() {
- ViewerOptions viewerOptions = new ViewerOptions();
- viewerOptions.terrainProvider = Cesium.createWorldTerrain();
- csVPanel = new ViewerPanel(viewerOptions);
-
- // Tropics of Cancer and Capricorn
- final Rectangle coffeeBeltRectangle = Rectangle.fromDegrees(-180.0, -23.43687, 180.0, 23.43687);
-
- csVPanel.getViewer().scene().globe.cartographicLimitRectangle = coffeeBeltRectangle;
- csVPanel.getViewer().scene().skyAtmosphere.show = false;
-
- // Add rectangles to show bounds
- final List rectangles = new ArrayList<>();
-
- for (int i = 0; i < 10; i++) {
- RectangleGraphicsOptions rectangleGraphicsOptions = new RectangleGraphicsOptions();
- rectangleGraphicsOptions.coordinates = new ConstantProperty<>(coffeeBeltRectangle);
- rectangleGraphicsOptions.material = new ColorMaterialProperty(Color.WHITE().withAlpha(0.0f));
- rectangleGraphicsOptions.height = new ConstantProperty<>(i * 5000.0);
- rectangleGraphicsOptions.outline = new ConstantProperty<>(true);
- rectangleGraphicsOptions.outlineWidth = new ConstantProperty<>(4.0);
- rectangleGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
-
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.rectangle = new RectangleGraphics(rectangleGraphicsOptions);
-
- rectangles.add(csVPanel.getViewer().entities().add(entityOptions));
+ private ViewerPanel csVPanel;
+
+ @Inject
+ public CartographicLimitRectangle(ShowcaseExampleStore store) {
+ super("Cartographic Limit Rectangle", "Limit terrain and imagery to a cartographic Rectangle area.",
+ new String[]{"Terrain", "Cartographic", "Limit", "Rectangle"}, store);
}
- CheckBox enableLimitCBox = new CheckBox();
- enableLimitCBox.setWidth("100px");
- enableLimitCBox.setValue(true);
- enableLimitCBox.addValueChangeHandler(new ValueChangeHandler() {
- @Override
- public void onValueChange(ValueChangeEvent event) {
- csVPanel.getViewer().scene().globe.cartographicLimitRectangle = event.getValue() ? coffeeBeltRectangle
- : Rectangle.MAX_VALUE();
- }
- });
-
- CheckBox showBoundsBox = new CheckBox();
- showBoundsBox.setWidth("100px");
- showBoundsBox.setValue(true);
- showBoundsBox.addValueChangeHandler(new ValueChangeHandler() {
- @Override
- public void onValueChange(ValueChangeEvent event) {
- for (Entity rectangle : rectangles) {
- rectangle.show = event.getValue();
+ @Override
+ public void buildPanel() {
+ ViewerOptions viewerOptions = new ViewerOptions();
+ viewerOptions.terrainProvider = Cesium.createWorldTerrain();
+ csVPanel = new ViewerPanel(viewerOptions);
+
+ // Tropics of Cancer and Capricorn
+ final Rectangle coffeeBeltRectangle = Rectangle.fromDegrees(-180.0, -23.43687, 180.0, 23.43687);
+
+ csVPanel.getViewer().scene().globe.cartographicLimitRectangle = coffeeBeltRectangle;
+ csVPanel.getViewer().scene().skyAtmosphere.show = false;
+
+ // Add rectangles to show bounds
+ final List rectangles = new ArrayList<>();
+
+ for (int i = 0; i < 10; i++) {
+ RectangleGraphicsOptions rectangleGraphicsOptions = new RectangleGraphicsOptions();
+ rectangleGraphicsOptions.coordinates = new ConstantProperty<>(coffeeBeltRectangle);
+ rectangleGraphicsOptions.material = new ColorMaterialProperty(Color.WHITE().withAlpha(0.0f));
+ rectangleGraphicsOptions.height = new ConstantProperty<>(i * 5000.0);
+ rectangleGraphicsOptions.outline = new ConstantProperty<>(true);
+ rectangleGraphicsOptions.outlineWidth = new ConstantProperty<>(4.0);
+ rectangleGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
+
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.rectangle = new RectangleGraphics(rectangleGraphicsOptions);
+
+ rectangles.add(csVPanel.getViewer().entities().add(entityOptions));
}
- }
- });
-
- FlexTable flexTable = new FlexTable();
- flexTable.setHTML(1, 0, "Limit Enabled");
- flexTable.setWidget(1, 1, enableLimitCBox);
- flexTable.setHTML(2, 0, "Show Bounds");
- flexTable.setWidget(2, 1, showBoundsBox);
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(flexTable, 20, 20);
-
- contentPanel.add(new HTML("Limit terrain and imagery to a cartographic Rectangle area.
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CartographicLimitRectangle.txt";
- return sourceCodeURLs;
- }
+
+ CheckBox enableLimitCBox = new CheckBox();
+ enableLimitCBox.setWidth("100px");
+ enableLimitCBox.setValue(true);
+ enableLimitCBox.addValueChangeHandler(new ValueChangeHandler() {
+ @Override
+ public void onValueChange(ValueChangeEvent event) {
+ csVPanel.getViewer().scene().globe.cartographicLimitRectangle = event.getValue() ? coffeeBeltRectangle
+ : Rectangle.MAX_VALUE();
+ }
+ });
+
+ CheckBox showBoundsBox = new CheckBox();
+ showBoundsBox.setWidth("100px");
+ showBoundsBox.setValue(true);
+ showBoundsBox.addValueChangeHandler(new ValueChangeHandler() {
+ @Override
+ public void onValueChange(ValueChangeEvent event) {
+ for (Entity rectangle : rectangles) {
+ rectangle.show = event.getValue();
+ }
+ }
+ });
+
+ FlexTable flexTable = new FlexTable();
+ flexTable.setHTML(1, 0, "Limit Enabled");
+ flexTable.setWidget(1, 1, enableLimitCBox);
+ flexTable.setHTML(2, 0, "Show Bounds");
+ flexTable.setWidget(2, 1, showBoundsBox);
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(flexTable, 20, 20);
+
+ contentPanel.add(new HTML("Limit terrain and imagery to a cartographic Rectangle area.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CartographicLimitRectangle.txt";
+ return sourceCodeURLs;
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CesiumInspector.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CesiumInspector.java
index 8635366c938f3f2a4442b97cb7bc186deffbacb0..900068da2e50742f6f113ad0d40526024bd1d2b9 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CesiumInspector.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CesiumInspector.java
@@ -16,18 +16,10 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.HTML;
-
import org.cesiumjs.cs.collections.BillboardCollection;
-import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.Color;
-import org.cesiumjs.cs.core.ColorGeometryInstanceAttribute;
-import org.cesiumjs.cs.core.Matrix4;
-import org.cesiumjs.cs.core.Rectangle;
-import org.cesiumjs.cs.core.Transforms;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.core.geometry.BoxGeometry;
import org.cesiumjs.cs.core.geometry.GeometryInstance;
import org.cesiumjs.cs.core.geometry.RectangleGeometry;
@@ -49,89 +41,91 @@ import org.cesiumjs.cs.widgets.viewerCesiumInspectorMixin;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class CesiumInspector extends AbstractExample {
- @Inject
- public CesiumInspector(ShowcaseExampleStore store) {
- super("Cesium Inspector", "Use the cesium inspector as a debugging tool for different primitives.",
- new String[] { "Showcase", "Cesium", "3d", "Viewer", "Debug", "Primitives" }, store);
- }
-
- @Override
- public void buildPanel() {
- ViewerPanel csVPanel = new ViewerPanel();
- Scene scene = csVPanel.getViewer().scene();
- Globe globe = csVPanel.getViewer().scene().globe;
- globe.depthTestAgainstTerrain = true;
-
- CesiumTerrainProviderOptions cesiumTerrainProviderOptions = new CesiumTerrainProviderOptions();
- cesiumTerrainProviderOptions.url = "https://assets.agi.com/stk-terrain/world";
- cesiumTerrainProviderOptions.requestVertexNormals = true;
- cesiumTerrainProviderOptions.requestWaterMask = true;
- csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(cesiumTerrainProviderOptions);
-
- // Add Cesium Inspector
- csVPanel.getViewer().extend(viewerCesiumInspectorMixin.instance());
-
- // Add Primitives
- PrimitiveOptions primitiveOptions = new PrimitiveOptions();
- primitiveOptions.asynchronous = false;
- GeometryInstanceOptions geometryInstanceOptions = new GeometryInstanceOptions();
-
- BoxGeometryOptions boxGeometryOptions = new BoxGeometryOptions();
- boxGeometryOptions.vertexFormat = PerInstanceColorAppearance.VERTEX_FORMAT();
- boxGeometryOptions.dimensions = new Cartesian3(400000.0, 300000.0, 500000.0);
- geometryInstanceOptions.geometry = BoxGeometry.createGeometry(BoxGeometry.fromDimensions(boxGeometryOptions));
-
- geometryInstanceOptions.modelMatrix = Matrix4.multiplyByTranslation(
- Transforms.eastNorthUpToFixedFrame(Cartesian3.fromDegrees(-105.0, 45.0)), new Cartesian3(0.0, 0.0, 250000),
- new Matrix4());
- geometryInstanceOptions.attributes = JsObject.createObject().cast();
- JsObject.$(geometryInstanceOptions.attributes, "color",
- ColorGeometryInstanceAttribute.fromColor(Color.RED().withAlpha(0.5f)));
-
- primitiveOptions.geometryInstances = new GeometryInstance[] { new GeometryInstance(geometryInstanceOptions) };
- PerInstanceColorAppearanceOptions perInstanceColorAppearanceOptions = new PerInstanceColorAppearanceOptions();
- perInstanceColorAppearanceOptions.closed = true;
- primitiveOptions.appearance = new PerInstanceColorAppearance(perInstanceColorAppearanceOptions);
- scene.primitives().add(new Primitive(primitiveOptions));
-
- primitiveOptions = new PrimitiveOptions();
- primitiveOptions.asynchronous = false;
- geometryInstanceOptions = new GeometryInstanceOptions();
-
- RectangleGeometryOptions rectangleGeometryOptions = new RectangleGeometryOptions();
- rectangleGeometryOptions.rectangle = Rectangle.fromDegrees(-100.0, 30.0, -93.0, 37.0);
- rectangleGeometryOptions.height = 100000;
- rectangleGeometryOptions.vertexFormat = PerInstanceColorAppearance.VERTEX_FORMAT();
- geometryInstanceOptions.geometry = RectangleGeometry
- .createGeometry(new RectangleGeometry(rectangleGeometryOptions));
-
- geometryInstanceOptions.attributes = JsObject.createObject().cast();
- JsObject.$(geometryInstanceOptions.attributes, "color", ColorGeometryInstanceAttribute.fromColor(Color.BLUE()));
-
- primitiveOptions.geometryInstances = new GeometryInstance[] { new GeometryInstance(geometryInstanceOptions) };
- primitiveOptions.appearance = new PerInstanceColorAppearance();
- scene.primitives().add(new Primitive(primitiveOptions));
-
- BillboardCollection billboards = (BillboardCollection) scene.primitives().add(new BillboardCollection());
- BillboardOptions billboardOptions = new BillboardOptions();
- billboardOptions.position = Cartesian3.fromDegrees(-75.59777, 40.03883, 150000);
- billboardOptions.image = GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png";
- billboards.add(billboardOptions);
-
- contentPanel.add(new HTML("Use the cesium inspector as a debugging tool for different primitives
"));
- contentPanel.add(csVPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CesiumInspector.txt";
- return sourceCodeURLs;
- }
+ @Inject
+ public CesiumInspector(ShowcaseExampleStore store) {
+ super("Cesium Inspector", "Use the cesium inspector as a debugging tool for different primitives.",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer", "Debug", "Primitives"}, store);
+ }
+
+ @Override
+ public void buildPanel() {
+ ViewerPanel csVPanel = new ViewerPanel();
+ Scene scene = csVPanel.getViewer().scene();
+ Globe globe = csVPanel.getViewer().scene().globe;
+ globe.depthTestAgainstTerrain = true;
+
+ CesiumTerrainProviderOptions cesiumTerrainProviderOptions = new CesiumTerrainProviderOptions();
+ cesiumTerrainProviderOptions.url = "https://assets.agi.com/stk-terrain/world";
+ cesiumTerrainProviderOptions.requestVertexNormals = true;
+ cesiumTerrainProviderOptions.requestWaterMask = true;
+ csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(cesiumTerrainProviderOptions);
+
+ // Add Cesium Inspector
+ csVPanel.getViewer().extend(viewerCesiumInspectorMixin.instance());
+
+ // Add Primitives
+ PrimitiveOptions primitiveOptions = new PrimitiveOptions();
+ primitiveOptions.asynchronous = false;
+ GeometryInstanceOptions geometryInstanceOptions = new GeometryInstanceOptions();
+
+ BoxGeometryOptions boxGeometryOptions = new BoxGeometryOptions();
+ boxGeometryOptions.vertexFormat = PerInstanceColorAppearance.VERTEX_FORMAT();
+ boxGeometryOptions.dimensions = new Cartesian3(400000.0, 300000.0, 500000.0);
+ geometryInstanceOptions.geometry = BoxGeometry.createGeometry(BoxGeometry.fromDimensions(boxGeometryOptions));
+
+ geometryInstanceOptions.modelMatrix = Matrix4.multiplyByTranslation(
+ Transforms.eastNorthUpToFixedFrame(Cartesian3.fromDegrees(-105.0, 45.0)), new Cartesian3(0.0, 0.0, 250000),
+ new Matrix4());
+ geometryInstanceOptions.attributes = JsObject.createObject().cast();
+ JsObject.$(geometryInstanceOptions.attributes, "color",
+ ColorGeometryInstanceAttribute.fromColor(Color.RED().withAlpha(0.5f)));
+
+ primitiveOptions.geometryInstances = new GeometryInstance[]{new GeometryInstance(geometryInstanceOptions)};
+ PerInstanceColorAppearanceOptions perInstanceColorAppearanceOptions = new PerInstanceColorAppearanceOptions();
+ perInstanceColorAppearanceOptions.closed = true;
+ primitiveOptions.appearance = new PerInstanceColorAppearance(perInstanceColorAppearanceOptions);
+ scene.primitives().add(new Primitive(primitiveOptions));
+
+ primitiveOptions = new PrimitiveOptions();
+ primitiveOptions.asynchronous = false;
+ geometryInstanceOptions = new GeometryInstanceOptions();
+
+ RectangleGeometryOptions rectangleGeometryOptions = new RectangleGeometryOptions();
+ rectangleGeometryOptions.rectangle = Rectangle.fromDegrees(-100.0, 30.0, -93.0, 37.0);
+ rectangleGeometryOptions.height = 100000;
+ rectangleGeometryOptions.vertexFormat = PerInstanceColorAppearance.VERTEX_FORMAT();
+ geometryInstanceOptions.geometry = RectangleGeometry
+ .createGeometry(new RectangleGeometry(rectangleGeometryOptions));
+
+ geometryInstanceOptions.attributes = JsObject.createObject().cast();
+ JsObject.$(geometryInstanceOptions.attributes, "color", ColorGeometryInstanceAttribute.fromColor(Color.BLUE()));
+
+ primitiveOptions.geometryInstances = new GeometryInstance[]{new GeometryInstance(geometryInstanceOptions)};
+ primitiveOptions.appearance = new PerInstanceColorAppearance();
+ scene.primitives().add(new Primitive(primitiveOptions));
+
+ BillboardCollection billboards = (BillboardCollection) scene.primitives().add(new BillboardCollection());
+ BillboardOptions billboardOptions = new BillboardOptions();
+ billboardOptions.position = Cartesian3.fromDegrees(-75.59777, 40.03883, 150000);
+ billboardOptions.image = GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png";
+ billboards.add(billboardOptions);
+
+ contentPanel.add(new HTML("Use the cesium inspector as a debugging tool for different primitives
"));
+ contentPanel.add(csVPanel);
+
+ initWidget(contentPanel);
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CesiumInspector.txt";
+ return sourceCodeURLs;
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CesiumNavigation.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CesiumNavigation.java
index 452915654551ead7726e2683a5e3753d4e05a3a8..c2be4703b55bdb90e6cefbb594f87b92388c63c0 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CesiumNavigation.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CesiumNavigation.java
@@ -16,50 +16,49 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.HTML;
-
import org.cesiumjs.cs.core.Rectangle;
import org.cesiumjs.cs.widgets.ViewerPanel;
-import org.cesiumjs.cs.widgets.viewerCesiumNavigationMixin;
import org.cesiumjs.cs.widgets.options.ViewerCesiumNavigationMixinOptions;
+import org.cesiumjs.cs.widgets.viewerCesiumNavigationMixin;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class CesiumNavigation extends AbstractExample {
- @Inject
- public CesiumNavigation(ShowcaseExampleStore store) {
- super("Cesium Navigation", "Use CesiumNavigation plugin with GWT wrapper.",
- new String[] { "Showcase", "Cesium", "3d", "Viewer", "Navigation" }, store);
- }
+ @Inject
+ public CesiumNavigation(ShowcaseExampleStore store) {
+ super("Cesium Navigation", "Use CesiumNavigation plugin with GWT wrapper.",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer", "Navigation"}, store);
+ }
- @Override
- public void buildPanel() {
- ViewerCesiumNavigationMixinOptions options = new ViewerCesiumNavigationMixinOptions();
- options.defaultResetView = Rectangle.fromDegrees(71, 3, 90, 14);
- options.enableCompass = true;
- options.enableZoomControls = true;
- options.enableDistanceLegend = true;
- options.enableCompassOuterRing = true;
+ @Override
+ public void buildPanel() {
+ ViewerCesiumNavigationMixinOptions options = new ViewerCesiumNavigationMixinOptions();
+ options.defaultResetView = Rectangle.fromDegrees(71, 3, 90, 14);
+ options.enableCompass = true;
+ options.enableZoomControls = true;
+ options.enableDistanceLegend = true;
+ options.enableCompassOuterRing = true;
- ViewerPanel csVPanel = new ViewerPanel();
- csVPanel.getViewer().extend(viewerCesiumNavigationMixin.instance(), options);
+ ViewerPanel csVPanel = new ViewerPanel();
+ csVPanel.getViewer().extend(viewerCesiumNavigationMixin.instance(), options);
- contentPanel.add(new HTML("Use CesiumNavigation plugin with GWT wrapper.
"));
- contentPanel.add(csVPanel);
+ contentPanel.add(new HTML("Use CesiumNavigation plugin with GWT wrapper.
"));
+ contentPanel.add(csVPanel);
- initWidget(contentPanel);
- }
+ initWidget(contentPanel);
+ }
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CesiumNavigation.txt";
- return sourceCodeURLs;
- }
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CesiumNavigation.txt";
+ return sourceCodeURLs;
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Clampto3DModel.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Clampto3DModel.java
index 7d66602a160e84b4f36697ef66c0aeb4615a38b2..b7d6582ac403b93b91920f18bfa46e34e9a0315e 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Clampto3DModel.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Clampto3DModel.java
@@ -20,14 +20,8 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.user.client.ui.HTML;
import com.google.inject.Inject;
-
import org.cesiumjs.cs.Cesium;
-import org.cesiumjs.cs.core.Cartesian2;
-import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.Cartographic;
-import org.cesiumjs.cs.core.Color;
-import org.cesiumjs.cs.core.Ellipsoid;
-import org.cesiumjs.cs.core.JulianDate;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.datasources.Entity;
import org.cesiumjs.cs.datasources.graphics.LabelGraphics;
import org.cesiumjs.cs.datasources.graphics.ModelGraphics;
@@ -47,115 +41,116 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import java.lang.Math;
+
/**
* @author Serge Silaev aka iSergio
*/
public class Clampto3DModel extends AbstractExample {
- private ViewerPanel csVPanel;
-
- private double longitude = -2.1480545852753163;
- private double latitude = 0.7688240036937101;
- private double range = 0.000002;
- private double duration = 4.0;
- private Cartographic cartographic = new Cartographic();
- private JsObject[] objectsToExclude;
- private Entity point;
-
- @Inject
- public Clampto3DModel(ShowcaseExampleStore store) {
- super("Clamp to 3D Model", "Clamp a point and label to a model using the sampleHeight function.",
- new String[] { "Clamp", "Point", "Label", "3DModel" }, store);
- }
-
- @Override
- public void buildPanel() {
- ViewerOptions viewerOptions = new ViewerOptions();
- viewerOptions.infoBox = false;
- viewerOptions.selectionIndicator = false;
- viewerOptions.shadows = true;
- viewerOptions.shouldAnimate = true;
- csVPanel = new ViewerPanel(viewerOptions);
-
- csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;
-
- if (!csVPanel.getViewer().scene().sampleHeightSupported()) {
- Cesium.log("This browser does not support sampleHeight.");
+ private final double longitude = -2.1480545852753163;
+ private final double latitude = 0.7688240036937101;
+ private final double range = 0.000002;
+ private final double duration = 4.0;
+ private final Cartographic cartographic = new Cartographic();
+ private ViewerPanel csVPanel;
+ private JsObject[] objectsToExclude;
+ private Entity point;
+
+ @Inject
+ public Clampto3DModel(ShowcaseExampleStore store) {
+ super("Clamp to 3D Model", "Clamp a point and label to a model using the sampleHeight function.",
+ new String[]{"Clamp", "Point", "Label", "3DModel"}, store);
}
- ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(
- GWT.getModuleBaseURL() + "SampleData/models/GroundVehicle/GroundVehicle.glb");
-
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromRadians(longitude, latitude));
- entityOptions.model = new ModelGraphics(modelGraphicsOptions);
-
- Entity entity = csVPanel.getViewer().entities().add(entityOptions);
-
- PointGraphicsOptions pointGraphicsOptions = new PointGraphicsOptions();
- pointGraphicsOptions.pixelSize = new ConstantProperty<>(10);
- pointGraphicsOptions.color = new ConstantProperty<>(Color.YELLOW());
- pointGraphicsOptions.disableDepthTestDistance = new ConstantProperty<>(Double.POSITIVE_INFINITY);
-
- LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
- labelGraphicsOptions.show = new ConstantProperty<>(false);
- labelGraphicsOptions.showBackground = new ConstantProperty<>(true);
- labelGraphicsOptions.font = new ConstantProperty<>("14px monospace");
- labelGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.LEFT());
- labelGraphicsOptions.verticalOrigin = new ConstantProperty<>(VerticalOrigin.BOTTOM());
- labelGraphicsOptions.pixelOffset = new ConstantProperty<>(new Cartesian2(5, 5));
- labelGraphicsOptions.disableDepthTestDistance = new ConstantProperty<>(Double.POSITIVE_INFINITY);
-
- entityOptions = new EntityOptions();
- entityOptions.positionCallback = new CallbackProperty<>(new CallbackProperty.Callback() {
- @Override
- public Cartesian3 function(JulianDate time, Cartesian3 result) {
- return updatePosition(time, result);
- }
- }, false);
- entityOptions.point = new PointGraphics(pointGraphicsOptions);
- entityOptions.label = new LabelGraphics(labelGraphicsOptions);
-
- point = new Entity(entityOptions);
- csVPanel.getViewer().entities().add(point);
-
- objectsToExclude = new JsObject[] { (JsObject) (Object) point };
-
- csVPanel.getViewer().trackedEntity = entity;
+ @Override
+ public void buildPanel() {
+ ViewerOptions viewerOptions = new ViewerOptions();
+ viewerOptions.infoBox = false;
+ viewerOptions.selectionIndicator = false;
+ viewerOptions.shadows = true;
+ viewerOptions.shouldAnimate = true;
+ csVPanel = new ViewerPanel(viewerOptions);
+
+ csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;
+
+ if (!csVPanel.getViewer().scene().sampleHeightSupported()) {
+ Cesium.log("This browser does not support sampleHeight.");
+ }
+
+ ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
+ modelGraphicsOptions.uri = new ConstantProperty<>(
+ GWT.getModuleBaseURL() + "SampleData/models/GroundVehicle/GroundVehicle.glb");
+
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromRadians(longitude, latitude));
+ entityOptions.model = new ModelGraphics(modelGraphicsOptions);
+
+ Entity entity = csVPanel.getViewer().entities().add(entityOptions);
+
+ PointGraphicsOptions pointGraphicsOptions = new PointGraphicsOptions();
+ pointGraphicsOptions.pixelSize = new ConstantProperty<>(10);
+ pointGraphicsOptions.color = new ConstantProperty<>(Color.YELLOW());
+ pointGraphicsOptions.disableDepthTestDistance = new ConstantProperty<>(Double.POSITIVE_INFINITY);
+
+ LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
+ labelGraphicsOptions.show = new ConstantProperty<>(false);
+ labelGraphicsOptions.showBackground = new ConstantProperty<>(true);
+ labelGraphicsOptions.font = new ConstantProperty<>("14px monospace");
+ labelGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.LEFT());
+ labelGraphicsOptions.verticalOrigin = new ConstantProperty<>(VerticalOrigin.BOTTOM());
+ labelGraphicsOptions.pixelOffset = new ConstantProperty<>(new Cartesian2(5, 5));
+ labelGraphicsOptions.disableDepthTestDistance = new ConstantProperty<>(Double.POSITIVE_INFINITY);
+
+ entityOptions = new EntityOptions();
+ entityOptions.positionCallback = new CallbackProperty<>(new CallbackProperty.Callback() {
+ @Override
+ public Cartesian3 function(JulianDate time, Cartesian3 result) {
+ return updatePosition(time, result);
+ }
+ }, false);
+ entityOptions.point = new PointGraphics(pointGraphicsOptions);
+ entityOptions.label = new LabelGraphics(labelGraphicsOptions);
+
+ point = new Entity(entityOptions);
+ csVPanel.getViewer().entities().add(point);
+
+ objectsToExclude = new JsObject[]{(JsObject) (Object) point};
+
+ csVPanel.getViewer().trackedEntity = entity;
+
+ contentPanel.add(new HTML("Clamp a point and label to a model using the sampleHeight function.
"));
+ contentPanel.add(csVPanel);
+
+ initWidget(contentPanel);
+ }
- contentPanel.add(new HTML("Clamp a point and label to a model using the sampleHeight function.
"));
- contentPanel.add(csVPanel);
+ Cartesian3 updatePosition(JulianDate time, Cartesian3 result) {
+ double offset = (time.secondsOfDay % duration) / duration;
+ cartographic.longitude = longitude - range + offset * range * 2.0;
+ cartographic.latitude = latitude;
- initWidget(contentPanel);
- }
+ double height = 0.0;
- Cartesian3 updatePosition(JulianDate time, Cartesian3 result) {
- double offset = (time.secondsOfDay % duration) / duration;
- cartographic.longitude = longitude - range + offset * range * 2.0;
- cartographic.latitude = latitude;
+ if (csVPanel.getViewer().scene().sampleHeightSupported()) {
+ height = csVPanel.getViewer().scene().sampleHeight(cartographic, objectsToExclude);
+ }
- double height = 0.0;
+ if (Cesium.defined(height)) {
+ cartographic.height = height;
+ point.label.text = new ConstantProperty<>(NumberFormat.getFormat("#.##").format(Math.abs(height)) + " m");
+ point.label.show = new ConstantProperty<>(true);
+ } else {
+ cartographic.height = 0.0;
+ point.label.show = new ConstantProperty<>(false);
+ }
- if (csVPanel.getViewer().scene().sampleHeightSupported()) {
- height = csVPanel.getViewer().scene().sampleHeight(cartographic, objectsToExclude);
+ return Cartographic.toCartesian(cartographic, Ellipsoid.WGS84(), result);
}
- if (Cesium.defined(height)) {
- cartographic.height = height;
- point.label.text = new ConstantProperty<>(NumberFormat.getFormat("#.##").format(Math.abs(height)) + " m");
- point.label.show = new ConstantProperty<>(true);
- } else {
- cartographic.height = 0.0;
- point.label.show = new ConstantProperty<>(false);
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Clampto3DModel.txt";
+ return sourceCodeURLs;
}
-
- return Cartographic.toCartesian(cartographic, Ellipsoid.WGS84(), result);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Clampto3DModel.txt";
- return sourceCodeURLs;
- }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Clampto3DTiles.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Clampto3DTiles.java
index f2c113b1fb4fe6111401c44f3eb097c021083a6f..881be63ee2f35cb6c7dfbf8639502e00195dac6e 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Clampto3DTiles.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Clampto3DTiles.java
@@ -19,13 +19,8 @@ package org.cleanlogic.cesiumjs4gwt.showcase.examples;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.HTML;
import com.google.inject.Inject;
-
import org.cesiumjs.cs.Cesium;
-import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.Clock;
-import org.cesiumjs.cs.core.Event;
-import org.cesiumjs.cs.core.IonResource;
-import org.cesiumjs.cs.core.Matrix4;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.datasources.CzmlDataSource;
import org.cesiumjs.cs.datasources.Entity;
import org.cesiumjs.cs.datasources.properties.ConstantPositionProperty;
@@ -45,76 +40,76 @@ import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStor
* @author Serge Silaev aka iSergio
*/
public class Clampto3DTiles extends AbstractExample {
- private ViewerPanel csVPanel;
-
- private Scene scene;
- private Clock clock;
-
- private Entity entity;
- private PositionProperty positionProperty;
-
- @Inject
- public Clampto3DTiles(ShowcaseExampleStore store) {
- super("Clamp to 3D Tiles", "Clamp a model to a 3D Tileset using the clampToHeight function.",
- new String[] { "Clamp", "Point", "Label", "3DTiles" }, store);
- }
+ private ViewerPanel csVPanel;
- @Override
- public void buildPanel() {
- ViewerOptions viewerOptions = new ViewerOptions();
- viewerOptions.terrainProvider = Cesium.createWorldTerrain();
- csVPanel = new ViewerPanel(viewerOptions);
+ private Scene scene;
+ private Clock clock;
- scene = csVPanel.getViewer().scene();
- clock = csVPanel.getViewer().clock();
+ private Entity entity;
+ private PositionProperty positionProperty;
- Promise dataSourcePromise = CzmlDataSource
- .load(GWT.getModuleBaseURL() + "SampleData/ClampToGround.czml");
- csVPanel.getViewer().dataSources().add(dataSourcePromise).then(new Fulfill() {
- @Override
- public void onFulfilled(CzmlDataSource dataSource) {
- entity = dataSource.entities.getById("CesiumMilkTruck");
- positionProperty = entity.position;
- }
- });
+ @Inject
+ public Clampto3DTiles(ShowcaseExampleStore store) {
+ super("Clamp to 3D Tiles", "Clamp a model to a 3D Tileset using the clampToHeight function.",
+ new String[]{"Clamp", "Point", "Label", "3DTiles"}, store);
+ }
- Cesium3DTileset tileset = (Cesium3DTileset) scene.primitives()
- .add(Cesium3DTileset.create(IonResource.fromAssetId(6074)));
+ @Override
+ public void buildPanel() {
+ ViewerOptions viewerOptions = new ViewerOptions();
+ viewerOptions.terrainProvider = Cesium.createWorldTerrain();
+ csVPanel = new ViewerPanel(viewerOptions);
- ViewOptions viewOptions = new ViewOptions();
- viewOptions.destinationPos = new Cartesian3(1216403.8845586285, -4736357.493351395, 4081299.715698949);
- viewOptions.orientation = new org.cesiumjs.cs.core.HeadingPitchRoll(4.2892217081808806, -0.4799070147502502,
- 6.279789177843313);
- viewOptions.endTransform = Matrix4.IDENTITY();
- csVPanel.getViewer().camera.setView(viewOptions);
+ scene = csVPanel.getViewer().scene();
+ clock = csVPanel.getViewer().clock();
- if (scene.clampToHeightSupported()) {
- tileset.initialTilesLoaded.addEventListener(new Event.Listener() {
- @Override
- public void function(Object... o) {
- clock.shouldAnimate = true;
- final JsObject[] objectsToExclude = new JsObject[] { (JsObject) (Object) entity };
- scene.postRender().addEventListener(new Event.Listener() {
+ Promise dataSourcePromise = CzmlDataSource
+ .load(GWT.getModuleBaseURL() + "SampleData/ClampToGround.czml");
+ csVPanel.getViewer().dataSources().add(dataSourcePromise).then(new Fulfill() {
@Override
- public void function(Object... o) {
- Cartesian3 position = positionProperty.getValue(clock.currentTime);
- entity.position = new ConstantPositionProperty(scene.clampToHeight(position, objectsToExclude));
+ public void onFulfilled(CzmlDataSource dataSource) {
+ entity = dataSource.entities.getById("CesiumMilkTruck");
+ positionProperty = entity.position;
}
- });
+ });
+
+ Cesium3DTileset tileset = (Cesium3DTileset) scene.primitives()
+ .add(Cesium3DTileset.create(IonResource.fromAssetId(6074)));
+
+ ViewOptions viewOptions = new ViewOptions();
+ viewOptions.destinationPos = new Cartesian3(1216403.8845586285, -4736357.493351395, 4081299.715698949);
+ viewOptions.orientation = new org.cesiumjs.cs.core.HeadingPitchRoll(4.2892217081808806, -0.4799070147502502,
+ 6.279789177843313);
+ viewOptions.endTransform = Matrix4.IDENTITY();
+ csVPanel.getViewer().camera.setView(viewOptions);
+
+ if (scene.clampToHeightSupported()) {
+ tileset.initialTilesLoaded.addEventListener(new Event.Listener() {
+ @Override
+ public void function(Object... o) {
+ clock.shouldAnimate = true;
+ final JsObject[] objectsToExclude = new JsObject[]{(JsObject) (Object) entity};
+ scene.postRender().addEventListener(new Event.Listener() {
+ @Override
+ public void function(Object... o) {
+ Cartesian3 position = positionProperty.getValue(clock.currentTime);
+ entity.position = new ConstantPositionProperty(scene.clampToHeight(position, objectsToExclude));
+ }
+ });
+ }
+ });
}
- });
- }
- contentPanel.add(new HTML("Clamp a model to a 3D Tileset using the clampToHeight function.
"));
- contentPanel.add(csVPanel);
+ contentPanel.add(new HTML("Clamp a model to a 3D Tileset using the clampToHeight function.
"));
+ contentPanel.add(csVPanel);
- initWidget(contentPanel);
- }
+ initWidget(contentPanel);
+ }
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Clampto3DTiles.txt";
- return sourceCodeURLs;
- }
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Clampto3DTiles.txt";
+ return sourceCodeURLs;
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ClamptoTerrain.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ClamptoTerrain.java
index 91c80765eef5af4eedaa25236e1286d2b1ea1f92..5fb3531833d5b5b04e4bf88e62672f863e5fa24f 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ClamptoTerrain.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ClamptoTerrain.java
@@ -25,40 +25,14 @@ import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.ListBox;
import com.google.inject.Inject;
-
import org.cesiumjs.cs.Cesium;
-import org.cesiumjs.cs.core.Cartesian2;
-import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.Cartographic;
-import org.cesiumjs.cs.core.Color;
-import org.cesiumjs.cs.core.Ellipsoid;
import org.cesiumjs.cs.core.Math;
-import org.cesiumjs.cs.core.Matrix4;
-import org.cesiumjs.cs.core.PolygonHierarchy;
-import org.cesiumjs.cs.core.Rectangle;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.datasources.Entity;
-import org.cesiumjs.cs.datasources.graphics.BillboardGraphics;
-import org.cesiumjs.cs.datasources.graphics.CorridorGraphics;
-import org.cesiumjs.cs.datasources.graphics.LabelGraphics;
-import org.cesiumjs.cs.datasources.graphics.ModelGraphics;
-import org.cesiumjs.cs.datasources.graphics.PointGraphics;
-import org.cesiumjs.cs.datasources.graphics.PolygonGraphics;
-import org.cesiumjs.cs.datasources.graphics.PolylineGraphics;
-import org.cesiumjs.cs.datasources.graphics.RectangleGraphics;
-import org.cesiumjs.cs.datasources.graphics.options.BillboardGraphicsOptions;
-import org.cesiumjs.cs.datasources.graphics.options.CorridorGraphicsOptions;
-import org.cesiumjs.cs.datasources.graphics.options.LabelGraphicsOptions;
-import org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions;
-import org.cesiumjs.cs.datasources.graphics.options.PointGraphicsOptions;
-import org.cesiumjs.cs.datasources.graphics.options.PolygonGraphicsOptions;
-import org.cesiumjs.cs.datasources.graphics.options.PolylineGraphicsOptions;
-import org.cesiumjs.cs.datasources.graphics.options.RectangleGraphicsOptions;
+import org.cesiumjs.cs.datasources.graphics.*;
+import org.cesiumjs.cs.datasources.graphics.options.*;
import org.cesiumjs.cs.datasources.options.EntityOptions;
-import org.cesiumjs.cs.datasources.properties.ColorMaterialProperty;
-import org.cesiumjs.cs.datasources.properties.ConstantPositionProperty;
-import org.cesiumjs.cs.datasources.properties.ConstantProperty;
-import org.cesiumjs.cs.datasources.properties.ImageMaterialProperty;
-import org.cesiumjs.cs.datasources.properties.PolylineOutlineMaterialProperty;
+import org.cesiumjs.cs.datasources.properties.*;
import org.cesiumjs.cs.datasources.properties.options.ImageMaterialPropertyOptions;
import org.cesiumjs.cs.datasources.properties.options.PolylineOutlineMaterialPropertyOptions;
import org.cesiumjs.cs.promise.Fulfill;
@@ -75,297 +49,297 @@ import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStor
* @author Serge Silaev aka iSergio
*/
public class ClamptoTerrain extends AbstractExample {
- private ViewerPanel csVPanel;
-
- @Inject
- public ClamptoTerrain(ShowcaseExampleStore store) {
- super("Clamp to Terrain", "Clamp primitives to the terrain.", new String[] { "Clamp", "Primitive", "Terrain" },
- store);
- }
-
- @Override
- public void buildPanel() {
- ViewerOptions viewerOptions = new ViewerOptions();
- viewerOptions.terrainProvider = Cesium.createWorldTerrain();
- csVPanel = new ViewerPanel(viewerOptions);
-
- csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;
-
- ListBox primitiveLBox = new ListBox();
- primitiveLBox.setWidth("160px");
- primitiveLBox.addItem("Draw Point with Label", "0");
- primitiveLBox.addItem("Draw Billboard", "1");
- primitiveLBox.addItem("Draw Corridor", "2");
- primitiveLBox.addItem("Draw Polygon", "3");
- primitiveLBox.addItem("Draw Textured Polygon", "4");
- primitiveLBox.addItem("Draw Rectangle", "5");
- primitiveLBox.addItem("Draw Model", "6");
- primitiveLBox.addItem("Sample line positions and draw with depth test disabled", "7");
- primitiveLBox.addItem("Draw polyline on terrain", "8");
- primitiveLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent event) {
- csVPanel.getViewer().entities().removeAll();
- ListBox source = (ListBox) event.getSource();
- switch (source.getSelectedValue()) {
- case "0":
- drawPointWithLabel();
- break;
- case "1":
- drawBillboard();
- break;
- case "2":
- drawCorridor();
- break;
- case "3":
- drawPolygon();
- break;
- case "4":
- drawTexturedPolygon();
- break;
- case "5":
- drawRectangle();
- break;
- case "6":
- drawModel();
- break;
- case "7":
- drawSampleLine();
- break;
- case "8":
- drawPolyline();
- break;
- default:
- break;
+ private ViewerPanel csVPanel;
+
+ @Inject
+ public ClamptoTerrain(ShowcaseExampleStore store) {
+ super("Clamp to Terrain", "Clamp primitives to the terrain.", new String[]{"Clamp", "Primitive", "Terrain"},
+ store);
+ }
+
+ @Override
+ public void buildPanel() {
+ ViewerOptions viewerOptions = new ViewerOptions();
+ viewerOptions.terrainProvider = Cesium.createWorldTerrain();
+ csVPanel = new ViewerPanel(viewerOptions);
+
+ csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;
+
+ ListBox primitiveLBox = new ListBox();
+ primitiveLBox.setWidth("160px");
+ primitiveLBox.addItem("Draw Point with Label", "0");
+ primitiveLBox.addItem("Draw Billboard", "1");
+ primitiveLBox.addItem("Draw Corridor", "2");
+ primitiveLBox.addItem("Draw Polygon", "3");
+ primitiveLBox.addItem("Draw Textured Polygon", "4");
+ primitiveLBox.addItem("Draw Rectangle", "5");
+ primitiveLBox.addItem("Draw Model", "6");
+ primitiveLBox.addItem("Sample line positions and draw with depth test disabled", "7");
+ primitiveLBox.addItem("Draw polyline on terrain", "8");
+ primitiveLBox.addChangeHandler(new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent event) {
+ csVPanel.getViewer().entities().removeAll();
+ ListBox source = (ListBox) event.getSource();
+ switch (source.getSelectedValue()) {
+ case "0":
+ drawPointWithLabel();
+ break;
+ case "1":
+ drawBillboard();
+ break;
+ case "2":
+ drawCorridor();
+ break;
+ case "3":
+ drawPolygon();
+ break;
+ case "4":
+ drawTexturedPolygon();
+ break;
+ case "5":
+ drawRectangle();
+ break;
+ case "6":
+ drawModel();
+ break;
+ case "7":
+ drawSampleLine();
+ break;
+ case "8":
+ drawPolyline();
+ break;
+ default:
+ break;
+ }
+ }
+ });
+
+ FlexTable flexTable = new FlexTable();
+ flexTable.setWidget(1, 0, primitiveLBox);
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(flexTable, 20, 20);
+
+ contentPanel.add(new HTML("Clamp primitives to the terrain.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
+
+ drawPointWithLabel();
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ClamptoTerrain.txt";
+ return sourceCodeURLs;
+ }
+
+ private void drawPointWithLabel() {
+ PointGraphicsOptions pointGraphicsOptions = new PointGraphicsOptions();
+ pointGraphicsOptions.color = new ConstantProperty<>(Color.SKYBLUE());
+ pointGraphicsOptions.pixelSize = new ConstantProperty<>(10);
+ pointGraphicsOptions.outlineColor = new ConstantProperty<>(Color.YELLOW());
+ pointGraphicsOptions.outlineWidth = new ConstantProperty<>(3);
+ pointGraphicsOptions.heightReference = new ConstantProperty<>(HeightReference.CLAMP_TO_GROUND());
+
+ LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
+ labelGraphicsOptions.text = new ConstantProperty<>("Clamped to ground");
+ labelGraphicsOptions.heightReference = new ConstantProperty<>(HeightReference.CLAMP_TO_GROUND());
+ labelGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.LEFT());
+ labelGraphicsOptions.verticalOrigin = new ConstantProperty<>(VerticalOrigin.BASELINE());
+ labelGraphicsOptions.fillColor = new ConstantProperty<>(Color.BLACK());
+ labelGraphicsOptions.showBackground = new ConstantProperty<>(true);
+ labelGraphicsOptions.backgroundColor = new ConstantProperty<>(new Color(1, 1, 1, 0.7));
+ labelGraphicsOptions.backgroundPadding = new ConstantProperty<>(new Cartesian2(8, 4));
+ labelGraphicsOptions.disableDepthTestDistance = new ConstantProperty<>(Double.POSITIVE_INFINITY); // draws the label
+ // in front of
+ // terrain
+
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-122.1958, 46.1915));
+ entityOptions.point = new PointGraphics(pointGraphicsOptions);
+ entityOptions.label = new LabelGraphics(labelGraphicsOptions);
+ csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
+ }
+
+ private void drawBillboard() {
+ BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
+ billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/facility.gif");
+ billboardGraphicsOptions.heightReference = new ConstantProperty<>(HeightReference.CLAMP_TO_GROUND());
+
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantProperty<>(Cartesian3.fromDegrees(-122.1958, 46.1915));
+ entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
+
+ csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
+ }
+
+ private void drawCorridor() {
+ CorridorGraphicsOptions corridorGraphicsOptions = new CorridorGraphicsOptions();
+ corridorGraphicsOptions.width = new ConstantProperty(2000.0);
+ corridorGraphicsOptions.material = new ColorMaterialProperty(Color.GREEN().withAlpha(0.5f));
+ corridorGraphicsOptions.positions = new ConstantProperty<>(
+ Cartesian3.fromDegreesArray(new double[]{-122.19, 46.1914, -122.21, 46.21, -122.23, 46.21}));
+
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.corridor = new CorridorGraphics(corridorGraphicsOptions);
+
+ csVPanel.getViewer().zoomTo(csVPanel.getViewer().entities().add(entityOptions));
+ }
+
+ private void drawPolygon() {
+ PolygonGraphicsOptions polygonGraphicsOptions = new PolygonGraphicsOptions();
+ polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(
+ new Cartesian3[]{new Cartesian3(-2358138.847340281, -3744072.459541374, 4581158.5714175375),
+ new Cartesian3(-2357231.4925370603, -3745103.7886602185, 4580702.9757762635),
+ new Cartesian3(-2355912.902205431, -3744249.029778454, 4582402.154378103),
+ new Cartesian3(-2357208.0209552636, -3743553.4420488174, 4581961.863286629)}));
+ polygonGraphicsOptions.material = new ColorMaterialProperty(Color.BLUE().withAlpha(0.5f));
+
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
+
+ csVPanel.getViewer().zoomTo(csVPanel.getViewer().entities().add(entityOptions));
+ }
+
+ private void drawTexturedPolygon() {
+ if (!Entity.supportsMaterialsforEntitiesOnTerrain(csVPanel.getViewer().scene())) {
+ Window.alert("Terrain Entity materials are not supported on this platform");
+ return;
}
- }
- });
-
- FlexTable flexTable = new FlexTable();
- flexTable.setWidget(1, 0, primitiveLBox);
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(flexTable, 20, 20);
-
- contentPanel.add(new HTML("Clamp primitives to the terrain.
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
-
- drawPointWithLabel();
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ClamptoTerrain.txt";
- return sourceCodeURLs;
- }
-
- private void drawPointWithLabel() {
- PointGraphicsOptions pointGraphicsOptions = new PointGraphicsOptions();
- pointGraphicsOptions.color = new ConstantProperty<>(Color.SKYBLUE());
- pointGraphicsOptions.pixelSize = new ConstantProperty<>(10);
- pointGraphicsOptions.outlineColor = new ConstantProperty<>(Color.YELLOW());
- pointGraphicsOptions.outlineWidth = new ConstantProperty<>(3);
- pointGraphicsOptions.heightReference = new ConstantProperty<>(HeightReference.CLAMP_TO_GROUND());
-
- LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
- labelGraphicsOptions.text = new ConstantProperty<>("Clamped to ground");
- labelGraphicsOptions.heightReference = new ConstantProperty<>(HeightReference.CLAMP_TO_GROUND());
- labelGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.LEFT());
- labelGraphicsOptions.verticalOrigin = new ConstantProperty<>(VerticalOrigin.BASELINE());
- labelGraphicsOptions.fillColor = new ConstantProperty<>(Color.BLACK());
- labelGraphicsOptions.showBackground = new ConstantProperty<>(true);
- labelGraphicsOptions.backgroundColor = new ConstantProperty<>(new Color(1, 1, 1, 0.7));
- labelGraphicsOptions.backgroundPadding = new ConstantProperty<>(new Cartesian2(8, 4));
- labelGraphicsOptions.disableDepthTestDistance = new ConstantProperty<>(Double.POSITIVE_INFINITY); // draws the label
- // in front of
- // terrain
-
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-122.1958, 46.1915));
- entityOptions.point = new PointGraphics(pointGraphicsOptions);
- entityOptions.label = new LabelGraphics(labelGraphicsOptions);
- csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
- }
-
- private void drawBillboard() {
- BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/facility.gif");
- billboardGraphicsOptions.heightReference = new ConstantProperty<>(HeightReference.CLAMP_TO_GROUND());
-
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantProperty<>(Cartesian3.fromDegrees(-122.1958, 46.1915));
- entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
-
- csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
- }
-
- private void drawCorridor() {
- CorridorGraphicsOptions corridorGraphicsOptions = new CorridorGraphicsOptions();
- corridorGraphicsOptions.width = new ConstantProperty(2000.0);
- corridorGraphicsOptions.material = new ColorMaterialProperty(Color.GREEN().withAlpha(0.5f));
- corridorGraphicsOptions.positions = new ConstantProperty<>(
- Cartesian3.fromDegreesArray(new double[] { -122.19, 46.1914, -122.21, 46.21, -122.23, 46.21 }));
-
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.corridor = new CorridorGraphics(corridorGraphicsOptions);
-
- csVPanel.getViewer().zoomTo(csVPanel.getViewer().entities().add(entityOptions));
- }
-
- private void drawPolygon() {
- PolygonGraphicsOptions polygonGraphicsOptions = new PolygonGraphicsOptions();
- polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(
- new Cartesian3[] { new Cartesian3(-2358138.847340281, -3744072.459541374, 4581158.5714175375),
- new Cartesian3(-2357231.4925370603, -3745103.7886602185, 4580702.9757762635),
- new Cartesian3(-2355912.902205431, -3744249.029778454, 4582402.154378103),
- new Cartesian3(-2357208.0209552636, -3743553.4420488174, 4581961.863286629) }));
- polygonGraphicsOptions.material = new ColorMaterialProperty(Color.BLUE().withAlpha(0.5f));
-
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
-
- csVPanel.getViewer().zoomTo(csVPanel.getViewer().entities().add(entityOptions));
- }
-
- private void drawTexturedPolygon() {
- if (!Entity.supportsMaterialsforEntitiesOnTerrain(csVPanel.getViewer().scene())) {
- Window.alert("Terrain Entity materials are not supported on this platform");
- return;
+
+ ImageMaterialPropertyOptions imageMaterialPropertyOptions = new ImageMaterialPropertyOptions();
+ imageMaterialPropertyOptions.image = new ConstantProperty<>(
+ GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg");
+
+ PolygonGraphicsOptions polygonGraphicsOptions = new PolygonGraphicsOptions();
+ polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(
+ new Cartesian3[]{new Cartesian3(-2358138.847340281, -3744072.459541374, 4581158.5714175375),
+ new Cartesian3(-2357231.4925370603, -3745103.7886602185, 4580702.9757762635),
+ new Cartesian3(-2355912.902205431, -3744249.029778454, 4582402.154378103),
+ new Cartesian3(-2357208.0209552636, -3743553.4420488174, 4581961.863286629)}));
+ polygonGraphicsOptions.material = new ImageMaterialProperty(imageMaterialPropertyOptions);
+ polygonGraphicsOptions.stRotation = new ConstantProperty<>(Math.toRadians(45));
+ polygonGraphicsOptions.classificationType = new ConstantProperty<>(ClassificationType.TERRAIN());
+
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
+
+ csVPanel.getViewer().zoomTo(csVPanel.getViewer().entities().add(entityOptions));
}
- ImageMaterialPropertyOptions imageMaterialPropertyOptions = new ImageMaterialPropertyOptions();
- imageMaterialPropertyOptions.image = new ConstantProperty<>(
- GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg");
-
- PolygonGraphicsOptions polygonGraphicsOptions = new PolygonGraphicsOptions();
- polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(
- new Cartesian3[] { new Cartesian3(-2358138.847340281, -3744072.459541374, 4581158.5714175375),
- new Cartesian3(-2357231.4925370603, -3745103.7886602185, 4580702.9757762635),
- new Cartesian3(-2355912.902205431, -3744249.029778454, 4582402.154378103),
- new Cartesian3(-2357208.0209552636, -3743553.4420488174, 4581961.863286629) }));
- polygonGraphicsOptions.material = new ImageMaterialProperty(imageMaterialPropertyOptions);
- polygonGraphicsOptions.stRotation = new ConstantProperty<>(Math.toRadians(45));
- polygonGraphicsOptions.classificationType = new ConstantProperty<>(ClassificationType.TERRAIN());
-
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
-
- csVPanel.getViewer().zoomTo(csVPanel.getViewer().entities().add(entityOptions));
- }
-
- private void drawRectangle() {
- RectangleGraphicsOptions rectangleGraphicsOptions = new RectangleGraphicsOptions();
- rectangleGraphicsOptions.coordinates = new ConstantProperty<>(Rectangle.fromDegrees(-122.3, 46.0, -122.0, 46.3));
- rectangleGraphicsOptions.material = new ColorMaterialProperty(Color.RED().withAlpha(0.5f));
-
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.rectangle = new RectangleGraphics(rectangleGraphicsOptions);
-
- csVPanel.getViewer().zoomTo(csVPanel.getViewer().entities().add(entityOptions));
- }
-
- private void drawModel() {
- ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(
- GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb");
- modelGraphicsOptions.heightReference = new ConstantProperty<>(HeightReference.CLAMP_TO_GROUND());
- modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(128);
- modelGraphicsOptions.maximumScale = new ConstantProperty<>(100);
-
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-122.1958, 46.1915));
- entityOptions.model = new ModelGraphics(modelGraphicsOptions);
-
- csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
- }
-
- private void drawSampleLine() {
- int length = 1000;
-
- double startLon = Math.toRadians(86.953793);
- double endLon = Math.toRadians(86.896497);
-
- double lat = Math.toRadians(27.988257);
-
- Cartographic[] terrainSamplePositions = new Cartographic[length];
- for (int i = 0; i < length; ++i) {
- double lon = Math.lerp(endLon, startLon, (double) i / ((double) length - 1.));
- Cartographic position = new Cartographic(lon, lat);
- terrainSamplePositions[i] = position;
+ private void drawRectangle() {
+ RectangleGraphicsOptions rectangleGraphicsOptions = new RectangleGraphicsOptions();
+ rectangleGraphicsOptions.coordinates = new ConstantProperty<>(Rectangle.fromDegrees(-122.3, 46.0, -122.0, 46.3));
+ rectangleGraphicsOptions.material = new ColorMaterialProperty(Color.RED().withAlpha(0.5f));
+
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.rectangle = new RectangleGraphics(rectangleGraphicsOptions);
+
+ csVPanel.getViewer().zoomTo(csVPanel.getViewer().entities().add(entityOptions));
}
- Cesium.sampleTerrainMostDetailed(csVPanel.getViewer().terrainProvider, terrainSamplePositions)
- .then(new Fulfill() {
- @Override
- public void onFulfilled(Cartographic[] samples) {
- double offset = 10.0;
- for (Cartographic sample : samples) {
- sample.height += offset;
- }
+ private void drawModel() {
+ ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
+ modelGraphicsOptions.uri = new ConstantProperty<>(
+ GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb");
+ modelGraphicsOptions.heightReference = new ConstantProperty<>(HeightReference.CLAMP_TO_GROUND());
+ modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(128);
+ modelGraphicsOptions.maximumScale = new ConstantProperty<>(100);
- PolylineGraphicsOptions polylineGraphicsOptions = new PolylineGraphicsOptions();
- polylineGraphicsOptions.positions = new ConstantProperty<>(
- Ellipsoid.WGS84().cartographicArrayToCartesianArray(samples));
- polylineGraphicsOptions.followSurface = new ConstantProperty<>(false);
- polylineGraphicsOptions.width = new ConstantProperty<>(5.0);
-
- PolylineOutlineMaterialPropertyOptions polylineOutlineMaterialPropertyOptions = new PolylineOutlineMaterialPropertyOptions();
- polylineOutlineMaterialPropertyOptions.color = new ConstantProperty<>(Color.ORANGE());
- polylineOutlineMaterialPropertyOptions.outlineWidth = new ConstantProperty<>(2);
- polylineOutlineMaterialPropertyOptions.outlineColor = new ConstantProperty<>(Color.BLACK());
- polylineGraphicsOptions.material = new PolylineOutlineMaterialProperty(
- polylineOutlineMaterialPropertyOptions);
-
- polylineOutlineMaterialPropertyOptions = new PolylineOutlineMaterialPropertyOptions();
- polylineOutlineMaterialPropertyOptions.color = new ConstantProperty<>(Color.RED());
- polylineOutlineMaterialPropertyOptions.outlineWidth = new ConstantProperty<>(2);
- polylineOutlineMaterialPropertyOptions.outlineColor = new ConstantProperty<>(Color.BLACK());
- polylineGraphicsOptions.depthFailMaterial = new PolylineOutlineMaterialProperty(
- polylineOutlineMaterialPropertyOptions);
-
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.polyline = new PolylineGraphics(polylineGraphicsOptions);
-
- csVPanel.getViewer().entities().add(entityOptions);
-
- Cartesian3 target = new Cartesian3(300770.50872389384, 5634912.131394585, 2978152.2865545116);
- csVPanel.getViewer().camera.lookAt(target,
- new Cartesian3(6344.974098678562, -793.3419798081741, 2499.9508860763162));
- csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
- }
- });
- }
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-122.1958, 46.1915));
+ entityOptions.model = new ModelGraphics(modelGraphicsOptions);
- private void drawPolyline() {
- if (!Entity.supportsPolylinesOnTerrain(csVPanel.getViewer().scene())) {
- Window.alert("Polylines on terrain are not supported on this platform");
- return;
+ csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
}
- PolylineOutlineMaterialPropertyOptions polylineOutlineMaterialPropertyOptions = new PolylineOutlineMaterialPropertyOptions();
- polylineOutlineMaterialPropertyOptions.color = new ConstantProperty<>(Color.ORANGE());
- polylineOutlineMaterialPropertyOptions.outlineWidth = new ConstantProperty<>(2);
- polylineOutlineMaterialPropertyOptions.outlineColor = new ConstantProperty<>(Color.BLACK());
+ private void drawSampleLine() {
+ int length = 1000;
+
+ double startLon = Math.toRadians(86.953793);
+ double endLon = Math.toRadians(86.896497);
+
+ double lat = Math.toRadians(27.988257);
- PolylineGraphicsOptions polylineGraphicsOptions = new PolylineGraphicsOptions();
- polylineGraphicsOptions.positions = new ConstantProperty<>(
- Cartesian3.fromDegreesArray(new double[] { 86.953793, 27.928257, 86.953793, 27.988257, 86.896497, 27.988257 }));
- polylineGraphicsOptions.clampToGround = new ConstantProperty<>(true);
- polylineGraphicsOptions.width = new ConstantProperty<>(5.0);
- polylineGraphicsOptions.material = new PolylineOutlineMaterialProperty(polylineOutlineMaterialPropertyOptions);
+ Cartographic[] terrainSamplePositions = new Cartographic[length];
+ for (int i = 0; i < length; ++i) {
+ double lon = Math.lerp(endLon, startLon, (double) i / ((double) length - 1.));
+ Cartographic position = new Cartographic(lon, lat);
+ terrainSamplePositions[i] = position;
+ }
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.polyline = new PolylineGraphics(polylineGraphicsOptions);
+ Cesium.sampleTerrainMostDetailed(csVPanel.getViewer().terrainProvider, terrainSamplePositions)
+ .then(new Fulfill() {
+ @Override
+ public void onFulfilled(Cartographic[] samples) {
+ double offset = 10.0;
+ for (Cartographic sample : samples) {
+ sample.height += offset;
+ }
+
+ PolylineGraphicsOptions polylineGraphicsOptions = new PolylineGraphicsOptions();
+ polylineGraphicsOptions.positions = new ConstantProperty<>(
+ Ellipsoid.WGS84().cartographicArrayToCartesianArray(samples));
+ polylineGraphicsOptions.followSurface = new ConstantProperty<>(false);
+ polylineGraphicsOptions.width = new ConstantProperty<>(5.0);
+
+ PolylineOutlineMaterialPropertyOptions polylineOutlineMaterialPropertyOptions = new PolylineOutlineMaterialPropertyOptions();
+ polylineOutlineMaterialPropertyOptions.color = new ConstantProperty<>(Color.ORANGE());
+ polylineOutlineMaterialPropertyOptions.outlineWidth = new ConstantProperty<>(2);
+ polylineOutlineMaterialPropertyOptions.outlineColor = new ConstantProperty<>(Color.BLACK());
+ polylineGraphicsOptions.material = new PolylineOutlineMaterialProperty(
+ polylineOutlineMaterialPropertyOptions);
+
+ polylineOutlineMaterialPropertyOptions = new PolylineOutlineMaterialPropertyOptions();
+ polylineOutlineMaterialPropertyOptions.color = new ConstantProperty<>(Color.RED());
+ polylineOutlineMaterialPropertyOptions.outlineWidth = new ConstantProperty<>(2);
+ polylineOutlineMaterialPropertyOptions.outlineColor = new ConstantProperty<>(Color.BLACK());
+ polylineGraphicsOptions.depthFailMaterial = new PolylineOutlineMaterialProperty(
+ polylineOutlineMaterialPropertyOptions);
+
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.polyline = new PolylineGraphics(polylineGraphicsOptions);
+
+ csVPanel.getViewer().entities().add(entityOptions);
+
+ Cartesian3 target = new Cartesian3(300770.50872389384, 5634912.131394585, 2978152.2865545116);
+ csVPanel.getViewer().camera.lookAt(target,
+ new Cartesian3(6344.974098678562, -793.3419798081741, 2499.9508860763162));
+ csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
+ }
+ });
+ }
- csVPanel.getViewer().entities().add(entityOptions);
+ private void drawPolyline() {
+ if (!Entity.supportsPolylinesOnTerrain(csVPanel.getViewer().scene())) {
+ Window.alert("Polylines on terrain are not supported on this platform");
+ return;
+ }
- Cartesian3 target = new Cartesian3(300770.50872389384, 5634912.131394585, 2978152.2865545116);
- Cartesian3 offset = new Cartesian3(6344.974098678562, -793.3419798081741, 2499.9508860763162);
- csVPanel.getViewer().camera.lookAt(target, offset);
- csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
- }
+ PolylineOutlineMaterialPropertyOptions polylineOutlineMaterialPropertyOptions = new PolylineOutlineMaterialPropertyOptions();
+ polylineOutlineMaterialPropertyOptions.color = new ConstantProperty<>(Color.ORANGE());
+ polylineOutlineMaterialPropertyOptions.outlineWidth = new ConstantProperty<>(2);
+ polylineOutlineMaterialPropertyOptions.outlineColor = new ConstantProperty<>(Color.BLACK());
+
+ PolylineGraphicsOptions polylineGraphicsOptions = new PolylineGraphicsOptions();
+ polylineGraphicsOptions.positions = new ConstantProperty<>(
+ Cartesian3.fromDegreesArray(new double[]{86.953793, 27.928257, 86.953793, 27.988257, 86.896497, 27.988257}));
+ polylineGraphicsOptions.clampToGround = new ConstantProperty<>(true);
+ polylineGraphicsOptions.width = new ConstantProperty<>(5.0);
+ polylineGraphicsOptions.material = new PolylineOutlineMaterialProperty(polylineOutlineMaterialPropertyOptions);
+
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.polyline = new PolylineGraphics(polylineGraphicsOptions);
+
+ csVPanel.getViewer().entities().add(entityOptions);
+
+ Cartesian3 target = new Cartesian3(300770.50872389384, 5634912.131394585, 2978152.2865545116);
+ Cartesian3 offset = new Cartesian3(6344.974098678562, -793.3419798081741, 2499.9508860763162);
+ csVPanel.getViewer().camera.lookAt(target, offset);
+ csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Clustering.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Clustering.java
index b9399256cad22e6f2b0d96b301fe9aead914dad4..353d9b2ba38e2fc4467c3a77a424187da4ad9ab7 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Clustering.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Clustering.java
@@ -16,22 +16,12 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
-import com.google.gwt.user.client.ui.AbsolutePanel;
-import com.google.gwt.user.client.ui.CheckBox;
-import com.google.gwt.user.client.ui.FlexTable;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.HasVerticalAlignment;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.TextBox;
-
+import com.google.gwt.user.client.ui.*;
import org.cesiumjs.cs.Cesium;
import org.cesiumjs.cs.core.Color;
import org.cesiumjs.cs.core.Event;
@@ -52,221 +42,223 @@ import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class Clustering extends AbstractExample {
- private ViewerPanel csVPanel;
- private Slider pixelRangeSlider;
- private TextBox pixelRangeTBox;
- private Slider minimumClusterSizeSlider;
- private TextBox minimumClusterSizeTBox;
-
- private Event.RemoveCallback removeListener;
- private KmlDataSource _dataSource;
-
- private String pin50;
- private String pin40;
- private String pin30;
- private String pin20;
- private String pin10;
- private String[] singleDigitPins;
-
- @Inject
- public Clustering(ShowcaseExampleStore store) {
- super("Clustering", "Cluster labels, billboards and points",
- new String[] { "Showcase", "Cesium", "3d", "Viewer", "Clustering", "Promise", "KML" }, store);
- }
-
- @Override
- public void buildPanel() {
- csVPanel = new ViewerPanel();
- KmlDataSourceLoadStaticOptions kmlDataSourceOptions = KmlDataSourceLoadStaticOptions
- .create(csVPanel.getViewer().camera, csVPanel.getViewer().canvas());
- Promise dataSourcePromise = csVPanel.getViewer().dataSources().add(
- KmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/kml/facilities/facilities.kml", kmlDataSourceOptions));
- dataSourcePromise.then(new Fulfill() {
- @Override
- public void onFulfilled(KmlDataSource dataSource) {
- int pixelRange = 25;
- int minimumClusterSize = 3;
- boolean enabled = true;
-
- dataSource.clustering.enabled = enabled;
- dataSource.clustering.pixelRange = pixelRange;
- dataSource.clustering.minimumClusterSize = minimumClusterSize;
-
- PinBuilder pinBuilder = new PinBuilder();
- pin50 = pinBuilder.fromText("50+", Color.RED(), 48).toDataUrl();
- pin40 = pinBuilder.fromText("40+", Color.ORANGE(), 48).toDataUrl();
- pin30 = pinBuilder.fromText("30+", Color.YELLOW(), 48).toDataUrl();
- pin20 = pinBuilder.fromText("20+", Color.GREEN(), 48).toDataUrl();
- pin10 = pinBuilder.fromText("10+", Color.BLUE(), 48).toDataUrl();
-
- singleDigitPins = new String[8];
- for (int i = 0; i < singleDigitPins.length; ++i) {
- singleDigitPins[i] = pinBuilder.fromText("" + (i + 2), Color.VIOLET(), 48).toDataUrl();
- }
- // start with custom style
- customStyle(dataSource);
-
- _dataSource = dataSource;
- }
- });
-
- pixelRangeSlider = new Slider("pixelRange", 1, 200, 15);
- pixelRangeSlider.setStep(1);
- pixelRangeSlider.setWidth("150px");
- pixelRangeSlider.addListener(new MSliderListener());
- pixelRangeTBox = new TextBox();
- pixelRangeTBox.addChangeHandler(new MChangeHandler());
- pixelRangeTBox.setText("" + 15);
- pixelRangeTBox.setSize("30px", "12px");
-
- HorizontalPanel pixelRangeHPanel = new HorizontalPanel();
- pixelRangeHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
- pixelRangeHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
- pixelRangeHPanel.setSpacing(10);
- pixelRangeHPanel.add(pixelRangeSlider);
- pixelRangeHPanel.add(pixelRangeTBox);
-
- minimumClusterSizeSlider = new Slider("minimumClusterSize", 1, 20, 3);
- minimumClusterSizeSlider.setStep(1);
- minimumClusterSizeSlider.setWidth("150px");
- minimumClusterSizeSlider.addListener(new MSliderListener());
- minimumClusterSizeTBox = new TextBox();
- pixelRangeTBox.addChangeHandler(new MChangeHandler());
- minimumClusterSizeTBox.setText("" + 3);
- minimumClusterSizeTBox.setSize("30px", "12px");
-
- HorizontalPanel minimumClusterSizeHPanel = new HorizontalPanel();
- minimumClusterSizeHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
- minimumClusterSizeHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
- minimumClusterSizeHPanel.setSpacing(10);
- minimumClusterSizeHPanel.add(minimumClusterSizeSlider);
- minimumClusterSizeHPanel.add(minimumClusterSizeTBox);
-
- CheckBox enabledCBox = new CheckBox();
- enabledCBox.setValue(true);
- enabledCBox.addValueChangeHandler(new ValueChangeHandler() {
- @Override
- public void onValueChange(ValueChangeEvent valueChangeEvent) {
- _dataSource.clustering.enabled = valueChangeEvent.getValue();
- }
- });
-
- CheckBox customStyleCBox = new CheckBox();
- customStyleCBox.setValue(true);
- customStyleCBox.addValueChangeHandler(new ValueChangeHandler() {
- @Override
- public void onValueChange(ValueChangeEvent valueChangeEvent) {
- customStyle(_dataSource);
- }
- });
-
- FlexTable flexTable = new FlexTable();
- flexTable.setHTML(1, 0, "Pixel Range");
- flexTable.setWidget(1, 1, pixelRangeHPanel);
- flexTable.setHTML(2, 0, "Minimum Cluster Size");
- flexTable.setWidget(2, 1, minimumClusterSizeHPanel);
- flexTable.setHTML(3, 0, "Enabled");
- flexTable.setWidget(3, 1, enabledCBox);
- flexTable.setHTML(4, 0, "Custom Style");
- flexTable.setWidget(4, 1, customStyleCBox);
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(flexTable, 20, 20);
-
- contentPanel.add(new HTML("Cluster labels, billboards and points.
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Clustering.txt";
- return sourceCodeURLs;
- }
-
- private class MSliderListener implements SliderListener {
-
- @Override
- public void onStart(SliderEvent e) {
-
+ private ViewerPanel csVPanel;
+ private Slider pixelRangeSlider;
+ private TextBox pixelRangeTBox;
+ private Slider minimumClusterSizeSlider;
+ private TextBox minimumClusterSizeTBox;
+
+ private Event.RemoveCallback removeListener;
+ private KmlDataSource _dataSource;
+
+ private String pin50;
+ private String pin40;
+ private String pin30;
+ private String pin20;
+ private String pin10;
+ private String[] singleDigitPins;
+
+ @Inject
+ public Clustering(ShowcaseExampleStore store) {
+ super("Clustering", "Cluster labels, billboards and points",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer", "Clustering", "Promise", "KML"}, store);
}
@Override
- public boolean onSlide(SliderEvent e) {
- Slider source = e.getSource();
- int value = source.getValue();
- if (source.getElement().getId().equalsIgnoreCase("pixelRange")) {
- _dataSource.clustering.pixelRange = value;
- pixelRangeTBox.setValue("" + value);
- } else if (source.getElement().getId().equalsIgnoreCase("minimumClusterSize")) {
- _dataSource.clustering.minimumClusterSize = value;
- minimumClusterSizeTBox.setValue("" + value);
- }
- return true;
+ public void buildPanel() {
+ csVPanel = new ViewerPanel();
+ KmlDataSourceLoadStaticOptions kmlDataSourceOptions = KmlDataSourceLoadStaticOptions
+ .create(csVPanel.getViewer().camera, csVPanel.getViewer().canvas());
+ Promise dataSourcePromise = csVPanel.getViewer().dataSources().add(
+ KmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/kml/facilities/facilities.kml", kmlDataSourceOptions));
+ dataSourcePromise.then(new Fulfill() {
+ @Override
+ public void onFulfilled(KmlDataSource dataSource) {
+ int pixelRange = 25;
+ int minimumClusterSize = 3;
+ boolean enabled = true;
+
+ dataSource.clustering.enabled = enabled;
+ dataSource.clustering.pixelRange = pixelRange;
+ dataSource.clustering.minimumClusterSize = minimumClusterSize;
+
+ PinBuilder pinBuilder = new PinBuilder();
+ pin50 = pinBuilder.fromText("50+", Color.RED(), 48).toDataUrl();
+ pin40 = pinBuilder.fromText("40+", Color.ORANGE(), 48).toDataUrl();
+ pin30 = pinBuilder.fromText("30+", Color.YELLOW(), 48).toDataUrl();
+ pin20 = pinBuilder.fromText("20+", Color.GREEN(), 48).toDataUrl();
+ pin10 = pinBuilder.fromText("10+", Color.BLUE(), 48).toDataUrl();
+
+ singleDigitPins = new String[8];
+ for (int i = 0; i < singleDigitPins.length; ++i) {
+ singleDigitPins[i] = pinBuilder.fromText("" + (i + 2), Color.VIOLET(), 48).toDataUrl();
+ }
+ // start with custom style
+ customStyle(dataSource);
+
+ _dataSource = dataSource;
+ }
+ });
+
+ pixelRangeSlider = new Slider("pixelRange", 1, 200, 15);
+ pixelRangeSlider.setStep(1);
+ pixelRangeSlider.setWidth("150px");
+ pixelRangeSlider.addListener(new MSliderListener());
+ pixelRangeTBox = new TextBox();
+ pixelRangeTBox.addChangeHandler(new MChangeHandler());
+ pixelRangeTBox.setText("" + 15);
+ pixelRangeTBox.setSize("30px", "12px");
+
+ HorizontalPanel pixelRangeHPanel = new HorizontalPanel();
+ pixelRangeHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+ pixelRangeHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+ pixelRangeHPanel.setSpacing(10);
+ pixelRangeHPanel.add(pixelRangeSlider);
+ pixelRangeHPanel.add(pixelRangeTBox);
+
+ minimumClusterSizeSlider = new Slider("minimumClusterSize", 1, 20, 3);
+ minimumClusterSizeSlider.setStep(1);
+ minimumClusterSizeSlider.setWidth("150px");
+ minimumClusterSizeSlider.addListener(new MSliderListener());
+ minimumClusterSizeTBox = new TextBox();
+ pixelRangeTBox.addChangeHandler(new MChangeHandler());
+ minimumClusterSizeTBox.setText("" + 3);
+ minimumClusterSizeTBox.setSize("30px", "12px");
+
+ HorizontalPanel minimumClusterSizeHPanel = new HorizontalPanel();
+ minimumClusterSizeHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+ minimumClusterSizeHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+ minimumClusterSizeHPanel.setSpacing(10);
+ minimumClusterSizeHPanel.add(minimumClusterSizeSlider);
+ minimumClusterSizeHPanel.add(minimumClusterSizeTBox);
+
+ CheckBox enabledCBox = new CheckBox();
+ enabledCBox.setValue(true);
+ enabledCBox.addValueChangeHandler(new ValueChangeHandler() {
+ @Override
+ public void onValueChange(ValueChangeEvent valueChangeEvent) {
+ _dataSource.clustering.enabled = valueChangeEvent.getValue();
+ }
+ });
+
+ CheckBox customStyleCBox = new CheckBox();
+ customStyleCBox.setValue(true);
+ customStyleCBox.addValueChangeHandler(new ValueChangeHandler() {
+ @Override
+ public void onValueChange(ValueChangeEvent valueChangeEvent) {
+ customStyle(_dataSource);
+ }
+ });
+
+ FlexTable flexTable = new FlexTable();
+ flexTable.setHTML(1, 0, "Pixel Range");
+ flexTable.setWidget(1, 1, pixelRangeHPanel);
+ flexTable.setHTML(2, 0, "Minimum Cluster Size");
+ flexTable.setWidget(2, 1, minimumClusterSizeHPanel);
+ flexTable.setHTML(3, 0, "Enabled");
+ flexTable.setWidget(3, 1, enabledCBox);
+ flexTable.setHTML(4, 0, "Custom Style");
+ flexTable.setWidget(4, 1, customStyleCBox);
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(flexTable, 20, 20);
+
+ contentPanel.add(new HTML("Cluster labels, billboards and points.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
}
@Override
- public void onChange(SliderEvent e) {
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Clustering.txt";
+ return sourceCodeURLs;
+ }
+ public void customStyle(KmlDataSource dataSource) {
+ if (Cesium.defined(removeListener)) {
+ removeListener.function();
+ removeListener = (Event.RemoveCallback) JsObject.undefined();
+ } else {
+ removeListener = dataSource.clustering.clusterEvent.addEventListener(new EntityCluster.newClusterCallback() {
+ @Override
+ public void function(Entity[] clusteredEntities, EntityClusterObject cluster) {
+ cluster.label.show = false;
+ cluster.billboard.show = true;
+ cluster.billboard.verticalOrigin = VerticalOrigin.BOTTOM();
+ if (clusteredEntities.length >= 50) {
+ cluster.billboard.image = pin50;
+ } else if (clusteredEntities.length >= 40) {
+ cluster.billboard.image = pin40;
+ } else if (clusteredEntities.length >= 30) {
+ cluster.billboard.image = pin30;
+ } else if (clusteredEntities.length >= 20) {
+ cluster.billboard.image = pin20;
+ } else if (clusteredEntities.length >= 10) {
+ cluster.billboard.image = pin10;
+ } else {
+ cluster.billboard.image = singleDigitPins[clusteredEntities.length - 2];
+ }
+ }
+ });
+ }
+ // force a re-cluster with the new styling
+ int pixelRange = dataSource.clustering.pixelRange;
+ dataSource.clustering.pixelRange = 0;
+ dataSource.clustering.pixelRange = pixelRange;
}
- @Override
- public void onStop(SliderEvent e) {
+ private class MSliderListener implements SliderListener {
- }
- }
+ @Override
+ public void onStart(SliderEvent e) {
- private class MChangeHandler implements ChangeHandler {
+ }
- @Override
- public void onChange(ChangeEvent changeEvent) {
- TextBox source = (TextBox) changeEvent.getSource();
- int value = Integer.parseInt(source.getText());
- if (source.equals(pixelRangeTBox)) {
- pixelRangeSlider.setValue(value);
- } else if (source.equals(minimumClusterSizeTBox)) {
- minimumClusterSizeSlider.setValue(value);
- }
+ @Override
+ public boolean onSlide(SliderEvent e) {
+ Slider source = e.getSource();
+ int value = source.getValue();
+ if (source.getElement().getId().equalsIgnoreCase("pixelRange")) {
+ _dataSource.clustering.pixelRange = value;
+ pixelRangeTBox.setValue("" + value);
+ } else if (source.getElement().getId().equalsIgnoreCase("minimumClusterSize")) {
+ _dataSource.clustering.minimumClusterSize = value;
+ minimumClusterSizeTBox.setValue("" + value);
+ }
+ return true;
+ }
+
+ @Override
+ public void onChange(SliderEvent e) {
+
+ }
+
+ @Override
+ public void onStop(SliderEvent e) {
+
+ }
}
- }
-
- public void customStyle(KmlDataSource dataSource) {
- if (Cesium.defined(removeListener)) {
- removeListener.function();
- removeListener = (Event.RemoveCallback) JsObject.undefined();
- } else {
- removeListener = dataSource.clustering.clusterEvent.addEventListener(new EntityCluster.newClusterCallback() {
+
+ private class MChangeHandler implements ChangeHandler {
+
@Override
- public void function(Entity[] clusteredEntities, EntityClusterObject cluster) {
- cluster.label.show = false;
- cluster.billboard.show = true;
- cluster.billboard.verticalOrigin = VerticalOrigin.BOTTOM();
- if (clusteredEntities.length >= 50) {
- cluster.billboard.image = pin50;
- } else if (clusteredEntities.length >= 40) {
- cluster.billboard.image = pin40;
- } else if (clusteredEntities.length >= 30) {
- cluster.billboard.image = pin30;
- } else if (clusteredEntities.length >= 20) {
- cluster.billboard.image = pin20;
- } else if (clusteredEntities.length >= 10) {
- cluster.billboard.image = pin10;
- } else {
- cluster.billboard.image = singleDigitPins[clusteredEntities.length - 2];
- }
+ public void onChange(ChangeEvent changeEvent) {
+ TextBox source = (TextBox) changeEvent.getSource();
+ int value = Integer.parseInt(source.getText());
+ if (source.equals(pixelRangeTBox)) {
+ pixelRangeSlider.setValue(value);
+ } else if (source.equals(minimumClusterSizeTBox)) {
+ minimumClusterSizeSlider.setValue(value);
+ }
}
- });
}
- // force a re-cluster with the new styling
- int pixelRange = dataSource.clustering.pixelRange;
- dataSource.clustering.pixelRange = 0;
- dataSource.clustering.pixelRange = pixelRange;
- }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomBaseLayerPicker.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomBaseLayerPicker.java
index f47380e9f0ae67184a51db0138656e9bed1942ea..94f02e8494750e47310f71ec8914359f6232f0ec 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomBaseLayerPicker.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomBaseLayerPicker.java
@@ -16,16 +16,10 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
-
import org.cesiumjs.cs.Cesium;
import org.cesiumjs.cs.core.providers.EllipsoidTerrainProvider;
import org.cesiumjs.cs.core.providers.TerrainProvider;
@@ -46,119 +40,123 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* @author Serge Silaev aka iSergio
*/
public class CustomBaseLayerPicker extends AbstractExample {
- @Inject
- public CustomBaseLayerPicker(ShowcaseExampleStore store) {
- super("Custom BaseLayerPicker widget", "Configure custom BaseLayerPicker widget",
- new String[] { "Showcase", "Cesium", "3d", "BaseLayerPicker", "BaseLayerPickerViewModel" }, store);
- }
-
- @Override
- public void buildPanel() {
- DivElement divElement = RootPanel.get().getElement().getOwnerDocument().createDivElement();
- divElement.setId("baseLayerPickerContainer");
- divElement.setPropertyString("style", "position:absolute;top:50px;right:42px;width:38px;height:38px;");
-
- List imageryViewModels = new ArrayList<>();
- List terrainViewModels = new ArrayList<>();
-
- ProviderViewModelOptions options = new ProviderViewModelOptions();
- options.name = "Open\u00adStreet\u00adMap";
- options.iconUrl = GWT.getModuleBaseURL() + "cs/CesiumUnminified/Widgets/Images/ImageryProviders/openStreetMap.png";
- options.tooltip = "OpenStreetMap (OSM) is a collaborative project to create a free editable map of the world.\nhttp://www.openstreetmap.org";
- options.imageryProviderCreationFunction = new ProviderViewModel.ImageryProviderCreationFunction() {
- @Override
- public ImageryProvider function() {
- OpenStreetMapImageryProviderOptions options = new OpenStreetMapImageryProviderOptions();
- options.url = "https://a.tile.openstreetmap.org/";
- return new OpenStreetMapImageryProvider(options);
- // return
- // Cesium.createOpenStreetMapImageryProvider("https://a.tile.openstreetmap.org/");
- }
- };
- imageryViewModels.add(new ProviderViewModel(options));
-
- options = new ProviderViewModelOptions();
- options.name = "Earth at Night";
- options.iconUrl = GWT.getModuleBaseURL() + "cs/CesiumUnminified/Widgets/Images/ImageryProviders/blueMarble.png";
- options.tooltip = "The lights of cities and villages trace the outlines of civilization \n"
- + " in this global view of the Earth at night as seen by NASA/NOAA\\'s Suomi NPP satellite.";
- options.imageryProviderCreationFunction = new ProviderViewModel.ImageryProviderCreationFunction() {
- @Override
- public ImageryProvider function() {
- return new IonImageryProvider(IonImageryProviderOptions.create(3812));
- }
- };
- imageryViewModels.add(new ProviderViewModel(options));
-
- options = new ProviderViewModelOptions();
- options.name = "Natural Earth\u00a0II";
- options.iconUrl = GWT.getModuleBaseURL() + "cs/CesiumUnminified/Widgets/Images/ImageryProviders/naturalEarthII.png";
- options.tooltip = "The lights of cities and villages trace the outlines of civilization \n"
- + " in this global view of the Earth at night as seen by NASA/NOAA\\'s Suomi NPP satellite.";
- options.imageryProviderCreationFunction = new ProviderViewModel.ImageryProviderCreationFunction() {
- @Override
- public ImageryProvider function() {
- TileMapServiceImageryProviderOptions options = new TileMapServiceImageryProviderOptions();
- options.url = GWT.getModuleBaseURL() + "cs/CesiumUnminified/Assets/Textures/NaturalEarthII";
- return new TileMapServiceImageryProvider(options);
- }
- };
- imageryViewModels.add(new ProviderViewModel(options));
-
- options = new ProviderViewModelOptions();
- options.name = "EllipsoidTerrainProvider";
- options.iconUrl = GWT.getModuleBaseURL() + "cs/CesiumUnminified/Widgets/Images/ImageryProviders/naturalEarthII.png";
- options.tooltip = "Some Terrain Description.";
- options.terrainProviderCreationFunction = new ProviderViewModel.TerrainProviderCreationFunction() {
- @Override
- public TerrainProvider function() {
- return new EllipsoidTerrainProvider();
- }
- };
- terrainViewModels.add(new ProviderViewModel(options));
-
- options = new ProviderViewModelOptions();
- options.name = "WorldTerrain";
- options.iconUrl = GWT.getModuleBaseURL() + "cs/CesiumUnminified/Widgets/Images/ImageryProviders/naturalEarthII.png";
- options.tooltip = "WorldTerrain.";
- options.terrainProviderCreationFunction = new ProviderViewModel.TerrainProviderCreationFunction() {
- @Override
- public TerrainProvider function() {
- return Cesium.createWorldTerrain(Cesium.CreateWorldTerrainOptions.create(true, true));
- }
- };
- terrainViewModels.add(new ProviderViewModel(options));
-
- ViewerOptions viewerOptions = new ViewerOptions();
- viewerOptions.imageryProvider = (ImageryProvider) JsObject.undefined();
- viewerOptions.baseLayerPicker = false;
- ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
- csVPanel.getViewer().scene().imageryLayers().removeAll(true);
-
- csVPanel.getViewer().container().getFirstChildElement().appendChild(divElement);
-
- BaseLayerPickerViewModelOptions baseLayerPickerOptions = BaseLayerPickerViewModelOptions
- .create(csVPanel.getViewer().scene().globe);
- baseLayerPickerOptions.imageryProviderViewModels = imageryViewModels.toArray(new ProviderViewModel[0]);
- baseLayerPickerOptions.terrainProviderViewModels = terrainViewModels.toArray(new ProviderViewModel[0]);
-
- BaseLayerPicker baseLayerPicker = new BaseLayerPicker(divElement, baseLayerPickerOptions);
-
- contentPanel.add(new HTML("Configure custom BaseLayerPicker widget.
"));
- contentPanel.add(csVPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CustomBaseLayerPicker.txt";
- return sourceCodeURLs;
- }
+ @Inject
+ public CustomBaseLayerPicker(ShowcaseExampleStore store) {
+ super("Custom BaseLayerPicker widget", "Configure custom BaseLayerPicker widget",
+ new String[]{"Showcase", "Cesium", "3d", "BaseLayerPicker", "BaseLayerPickerViewModel"}, store);
+ }
+
+ @Override
+ public void buildPanel() {
+ DivElement divElement = RootPanel.get().getElement().getOwnerDocument().createDivElement();
+ divElement.setId("baseLayerPickerContainer");
+ divElement.setPropertyString("style", "position:absolute;top:50px;right:42px;width:38px;height:38px;");
+
+ List imageryViewModels = new ArrayList<>();
+ List terrainViewModels = new ArrayList<>();
+
+ ProviderViewModelOptions options = new ProviderViewModelOptions();
+ options.name = "Open\u00adStreet\u00adMap";
+ options.iconUrl = GWT.getModuleBaseURL() + "cs/CesiumUnminified/Widgets/Images/ImageryProviders/openStreetMap.png";
+ options.tooltip = "OpenStreetMap (OSM) is a collaborative project to create a free editable map of the world.\nhttp://www.openstreetmap.org";
+ options.imageryProviderCreationFunction = new ProviderViewModel.ImageryProviderCreationFunction() {
+ @Override
+ public ImageryProvider function() {
+ OpenStreetMapImageryProviderOptions options = new OpenStreetMapImageryProviderOptions();
+ options.url = "https://a.tile.openstreetmap.org/";
+ return new OpenStreetMapImageryProvider(options);
+ // return
+ // Cesium.createOpenStreetMapImageryProvider("https://a.tile.openstreetmap.org/");
+ }
+ };
+ imageryViewModels.add(new ProviderViewModel(options));
+
+ options = new ProviderViewModelOptions();
+ options.name = "Earth at Night";
+ options.iconUrl = GWT.getModuleBaseURL() + "cs/CesiumUnminified/Widgets/Images/ImageryProviders/blueMarble.png";
+ options.tooltip = "The lights of cities and villages trace the outlines of civilization \n"
+ + " in this global view of the Earth at night as seen by NASA/NOAA\\'s Suomi NPP satellite.";
+ options.imageryProviderCreationFunction = new ProviderViewModel.ImageryProviderCreationFunction() {
+ @Override
+ public ImageryProvider function() {
+ return new IonImageryProvider(IonImageryProviderOptions.create(3812));
+ }
+ };
+ imageryViewModels.add(new ProviderViewModel(options));
+
+ options = new ProviderViewModelOptions();
+ options.name = "Natural Earth\u00a0II";
+ options.iconUrl = GWT.getModuleBaseURL() + "cs/CesiumUnminified/Widgets/Images/ImageryProviders/naturalEarthII.png";
+ options.tooltip = "The lights of cities and villages trace the outlines of civilization \n"
+ + " in this global view of the Earth at night as seen by NASA/NOAA\\'s Suomi NPP satellite.";
+ options.imageryProviderCreationFunction = new ProviderViewModel.ImageryProviderCreationFunction() {
+ @Override
+ public ImageryProvider function() {
+ TileMapServiceImageryProviderOptions options = new TileMapServiceImageryProviderOptions();
+ options.url = GWT.getModuleBaseURL() + "cs/CesiumUnminified/Assets/Textures/NaturalEarthII";
+ return new TileMapServiceImageryProvider(options);
+ }
+ };
+ imageryViewModels.add(new ProviderViewModel(options));
+
+ options = new ProviderViewModelOptions();
+ options.name = "EllipsoidTerrainProvider";
+ options.iconUrl = GWT.getModuleBaseURL() + "cs/CesiumUnminified/Widgets/Images/ImageryProviders/naturalEarthII.png";
+ options.tooltip = "Some Terrain Description.";
+ options.terrainProviderCreationFunction = new ProviderViewModel.TerrainProviderCreationFunction() {
+ @Override
+ public TerrainProvider function() {
+ return new EllipsoidTerrainProvider();
+ }
+ };
+ terrainViewModels.add(new ProviderViewModel(options));
+
+ options = new ProviderViewModelOptions();
+ options.name = "WorldTerrain";
+ options.iconUrl = GWT.getModuleBaseURL() + "cs/CesiumUnminified/Widgets/Images/ImageryProviders/naturalEarthII.png";
+ options.tooltip = "WorldTerrain.";
+ options.terrainProviderCreationFunction = new ProviderViewModel.TerrainProviderCreationFunction() {
+ @Override
+ public TerrainProvider function() {
+ return Cesium.createWorldTerrain(Cesium.CreateWorldTerrainOptions.create(true, true));
+ }
+ };
+ terrainViewModels.add(new ProviderViewModel(options));
+
+ ViewerOptions viewerOptions = new ViewerOptions();
+ viewerOptions.imageryProvider = (ImageryProvider) JsObject.undefined();
+ viewerOptions.baseLayerPicker = false;
+ ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
+ csVPanel.getViewer().scene().imageryLayers().removeAll(true);
+
+ csVPanel.getViewer().container().getFirstChildElement().appendChild(divElement);
+
+ BaseLayerPickerViewModelOptions baseLayerPickerOptions = BaseLayerPickerViewModelOptions
+ .create(csVPanel.getViewer().scene().globe);
+ baseLayerPickerOptions.imageryProviderViewModels = imageryViewModels.toArray(new ProviderViewModel[0]);
+ baseLayerPickerOptions.terrainProviderViewModels = terrainViewModels.toArray(new ProviderViewModel[0]);
+
+ BaseLayerPicker baseLayerPicker = new BaseLayerPicker(divElement, baseLayerPickerOptions);
+
+ contentPanel.add(new HTML("Configure custom BaseLayerPicker widget.
"));
+ contentPanel.add(csVPanel);
+
+ initWidget(contentPanel);
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CustomBaseLayerPicker.txt";
+ return sourceCodeURLs;
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomGeocoder.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomGeocoder.java
index e9fe2ab41f63cfeee69c4b27dd31334ad4fdfc92..61872799b150a6ff1919aae970327c88ebb9adae 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomGeocoder.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomGeocoder.java
@@ -16,13 +16,14 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.user.client.ui.HTML;
-
+import jsinterop.annotations.JsFunction;
+import jsinterop.annotations.JsPackage;
+import jsinterop.annotations.JsProperty;
+import jsinterop.annotations.JsType;
import org.cesiumjs.cs.core.GeocoderResult;
import org.cesiumjs.cs.core.GeocoderService;
import org.cesiumjs.cs.core.Rectangle;
@@ -35,81 +36,78 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
-import jsinterop.annotations.JsFunction;
-import jsinterop.annotations.JsPackage;
-import jsinterop.annotations.JsProperty;
-import jsinterop.annotations.JsType;
+import javax.inject.Inject;
/**
* @author Serge Silaev aka iSergio
*/
public class CustomGeocoder extends AbstractExample {
- private ViewerPanel csVPanel;
+ private ViewerPanel csVPanel;
- @Inject
- public CustomGeocoder(ShowcaseExampleStore store) {
- super("Custom Geocoder",
- "Example of a custom geocoder. It provides geocoding through the OpenStreetMap Nominatim service.",
- new String[] { "Showcase", "Cesium", "3d", "Custom Geocoder", "OpenStreetMap", "osm" }, store);
- }
+ @Inject
+ public CustomGeocoder(ShowcaseExampleStore store) {
+ super("Custom Geocoder",
+ "Example of a custom geocoder. It provides geocoding through the OpenStreetMap Nominatim service.",
+ new String[]{"Showcase", "Cesium", "3d", "Custom Geocoder", "OpenStreetMap", "osm"}, store);
+ }
- @Override
- public void buildPanel() {
- OpenStreetMapNominatimGeocoder openStreetMapNominatimGeocoder = new OpenStreetMapNominatimGeocoder();
- openStreetMapNominatimGeocoder.geocode = new OpenStreetMapNominatimGeocoder.Geocode() {
- @Override
- public Promise function(String input) {
- String endpoint = "http://nominatim.openstreetmap.org/search?";
- String query = "format=json&q=" + input;
- String requestString = endpoint + query;
- Promise promise = Resource.fetchJson(requestString);
- promise.then(new Fulfill() {
- @Override
- public void onFulfilled(JsObject value) {
- JSONArray jsonArray = new JSONArray(value);
- for (int i = 0; i < jsonArray.size(); i++) {
- JSONObject jsonObject = jsonArray.get(i).isObject();
- JSONArray bboxDegrees = jsonObject.get("boundingbox").isArray();
- Rectangle destination = Rectangle.fromDegrees(
- Double.parseDouble(bboxDegrees.get(2).isString().toString().replace("\"", "")),
- Double.parseDouble(bboxDegrees.get(0).isString().toString().replace("\"", "")),
- Double.parseDouble(bboxDegrees.get(3).isString().toString().replace("\"", "")),
- Double.parseDouble(bboxDegrees.get(1).isString().toString().replace("\"", "")));
+ @Override
+ public void buildPanel() {
+ OpenStreetMapNominatimGeocoder openStreetMapNominatimGeocoder = new OpenStreetMapNominatimGeocoder();
+ openStreetMapNominatimGeocoder.geocode = new OpenStreetMapNominatimGeocoder.Geocode() {
+ @Override
+ public Promise function(String input) {
+ String endpoint = "http://nominatim.openstreetmap.org/search?";
+ String query = "format=json&q=" + input;
+ String requestString = endpoint + query;
+ Promise promise = Resource.fetchJson(requestString);
+ promise.then(new Fulfill() {
+ @Override
+ public void onFulfilled(JsObject value) {
+ JSONArray jsonArray = new JSONArray(value);
+ for (int i = 0; i < jsonArray.size(); i++) {
+ JSONObject jsonObject = jsonArray.get(i).isObject();
+ JSONArray bboxDegrees = jsonObject.get("boundingbox").isArray();
+ Rectangle destination = Rectangle.fromDegrees(
+ Double.parseDouble(bboxDegrees.get(2).isString().toString().replace("\"", "")),
+ Double.parseDouble(bboxDegrees.get(0).isString().toString().replace("\"", "")),
+ Double.parseDouble(bboxDegrees.get(3).isString().toString().replace("\"", "")),
+ Double.parseDouble(bboxDegrees.get(1).isString().toString().replace("\"", "")));
- GeocoderResult geocoderResult = new GeocoderResult();
- geocoderResult.displayName = jsonObject.get("display_name").isString().toString();
- geocoderResult.destinationRectangle = destination;
- jsonArray.set(i, new JSONObject((JsObject) (Object) geocoderResult));
+ GeocoderResult geocoderResult = new GeocoderResult();
+ geocoderResult.displayName = jsonObject.get("display_name").isString().toString();
+ geocoderResult.destinationRectangle = destination;
+ jsonArray.set(i, new JSONObject((JsObject) (Object) geocoderResult));
+ }
+ }
+ });
+ return promise;
}
- }
- });
- return promise;
- }
- };
- ViewerOptions viewerOptions = new ViewerOptions();
- viewerOptions.geocoderServices = new GeocoderService[] { openStreetMapNominatimGeocoder };
- csVPanel = new ViewerPanel(viewerOptions);
- contentPanel.add(new HTML("Example of a custom geocoder.
"));
- contentPanel.add(csVPanel);
+ };
+ ViewerOptions viewerOptions = new ViewerOptions();
+ viewerOptions.geocoderServices = new GeocoderService[]{openStreetMapNominatimGeocoder};
+ csVPanel = new ViewerPanel(viewerOptions);
+ contentPanel.add(new HTML("Example of a custom geocoder.
"));
+ contentPanel.add(csVPanel);
- initWidget(contentPanel);
- }
+ initWidget(contentPanel);
+ }
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CustomGeocoder.txt";
- return sourceCodeURLs;
- }
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CustomGeocoder.txt";
+ return sourceCodeURLs;
+ }
- @JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
- private static class OpenStreetMapNominatimGeocoder implements GeocoderService {
- @JsProperty(name = "geocode")
- public Geocode geocode;
+ @JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
+ private static class OpenStreetMapNominatimGeocoder implements GeocoderService {
+ @JsProperty(name = "geocode")
+ public Geocode geocode;
- @JsFunction
- public interface Geocode {
- Promise function(String input);
+ @JsFunction
+ public interface Geocode {
+ Promise function(String input);
+ }
}
- }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomHomeButton.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomHomeButton.java
index fd7e1996dda48dfa7bdb2594a95e7d51b7551042..f5c41b38f4aa6868eb69b1a9684d981ff2a0cf2a 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomHomeButton.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomHomeButton.java
@@ -1,10 +1,7 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.HTML;
-
import org.cesiumjs.cs.core.Cartesian3;
import org.cesiumjs.cs.core.Event;
import org.cesiumjs.cs.datasources.Entity;
@@ -18,47 +15,49 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* Custom behavior for the HomeButton widget.
*/
public class CustomHomeButton extends AbstractExample {
- @Inject
- public CustomHomeButton(ShowcaseExampleStore store) {
- super("Custom HomeButton Behavior", "Listen to HomeButton Command and customize tooltip",
- new String[] { "Showcase", "Cesium", "3d", "HomeButton", "HomeButtonViewModel" }, store);
- }
-
- @Override
- public void buildPanel() {
-
- final PointGraphicsOptions pointOptions = new PointGraphicsOptions();
- pointOptions.pixelSize = new ConstantProperty<>(5);
-
- final EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-73.986555, 40.735396, 0));
- entityOptions.point = new PointGraphics(pointOptions);
-
- final Entity entity = new Entity(entityOptions);
-
- final ViewerOptions viewerOptions = new ViewerOptions();
- final ViewerPanel viewer = new ViewerPanel(viewerOptions);
- viewer.getViewer().homeButton().viewModel.tooltip = "Fly to New York";
- viewer.getViewer().entities().add(entity);
- viewer.getViewer().homeButton().viewModel.command.beforeExecute.addEventListener(new Event.Listener() {
- @Override
- public void function(Object... o) {
- viewer.getViewer().flyTo(entity);
- }
- });
-
- contentPanel.add(new HTML("Click the home button to fly to New York.
"));
- contentPanel.add(viewer);
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- return new String[] { GWT.getModuleBaseURL() + "examples/" + "CustomHomeButton.txt" };
- }
+ @Inject
+ public CustomHomeButton(ShowcaseExampleStore store) {
+ super("Custom HomeButton Behavior", "Listen to HomeButton Command and customize tooltip",
+ new String[]{"Showcase", "Cesium", "3d", "HomeButton", "HomeButtonViewModel"}, store);
+ }
+
+ @Override
+ public void buildPanel() {
+
+ final PointGraphicsOptions pointOptions = new PointGraphicsOptions();
+ pointOptions.pixelSize = new ConstantProperty<>(5);
+
+ final EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-73.986555, 40.735396, 0));
+ entityOptions.point = new PointGraphics(pointOptions);
+
+ final Entity entity = new Entity(entityOptions);
+
+ final ViewerOptions viewerOptions = new ViewerOptions();
+ final ViewerPanel viewer = new ViewerPanel(viewerOptions);
+ viewer.getViewer().homeButton().viewModel.tooltip = "Fly to New York";
+ viewer.getViewer().entities().add(entity);
+ viewer.getViewer().homeButton().viewModel.command.beforeExecute.addEventListener(new Event.Listener() {
+ @Override
+ public void function(Object... o) {
+ viewer.getViewer().flyTo(entity);
+ }
+ });
+
+ contentPanel.add(new HTML("Click the home button to fly to New York.
"));
+ contentPanel.add(viewer);
+ initWidget(contentPanel);
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ return new String[]{GWT.getModuleBaseURL() + "examples/" + "CustomHomeButton.txt"};
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomPerFeaturePostProcess.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomPerFeaturePostProcess.java
index 442da0616b735bd3525a4567dc4ebdf824a5cd94..d37dbfd9d30ec762898e50a1ec510b48d9d47f69 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomPerFeaturePostProcess.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomPerFeaturePostProcess.java
@@ -16,12 +16,9 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.HTML;
-
import org.cesiumjs.cs.Cesium;
import org.cesiumjs.cs.core.Cartesian3;
import org.cesiumjs.cs.core.Color;
@@ -44,81 +41,83 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class CustomPerFeaturePostProcess extends AbstractExample {
- private ViewerPanel csVPanel;
+ private ViewerPanel csVPanel;
- @Inject
- public CustomPerFeaturePostProcess(ShowcaseExampleStore store) {
- super("Custom Per-Feature Post Process", "Custom per-feature post processing effect.",
- new String[] { "Custom post process", "per feature" }, store);
- }
+ @Inject
+ public CustomPerFeaturePostProcess(ShowcaseExampleStore store) {
+ super("Custom Per-Feature Post Process", "Custom per-feature post processing effect.",
+ new String[]{"Custom post process", "per feature"}, store);
+ }
- @Override
- public void buildPanel() {
- ViewerOptions viewerOptions = new ViewerOptions();
- viewerOptions.shouldAnimate = true;
- csVPanel = new ViewerPanel(viewerOptions);
+ @Override
+ public void buildPanel() {
+ ViewerOptions viewerOptions = new ViewerOptions();
+ viewerOptions.shouldAnimate = true;
+ csVPanel = new ViewerPanel(viewerOptions);
- ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(
- GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb");
- EntityOptions options = new EntityOptions();
- options.name = GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb";
- options.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-123.0744619, 44.0503706));
- options.model = new ModelGraphics(modelGraphicsOptions);
- csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(options);
+ ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
+ modelGraphicsOptions.uri = new ConstantProperty<>(
+ GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb");
+ EntityOptions options = new EntityOptions();
+ options.name = GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb";
+ options.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-123.0744619, 44.0503706));
+ options.model = new ModelGraphics(modelGraphicsOptions);
+ csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(options);
- // Shade selected model with highlight.
- String fragmentShaderSource = "uniform sampler2D colorTexture;\n" + "varying vec2 v_textureCoordinates;\n"
- + "uniform vec4 highlight;\n" + "void main() {\n"
- + " vec4 color = texture2D(colorTexture, v_textureCoordinates);\n" + " if (czm_selected()) {\n"
- + " vec3 highlighted = highlight.a * highlight.rgb + (1.0 - highlight.a) * color.rgb;\n"
- + " gl_FragColor = vec4(highlighted, 1.0);\n" + " } else { \n" + " gl_FragColor = color;\n"
- + " }\n" + "}\n";
- JsObject uniforms = JsObject.create();
- uniforms.setProperty("highlight", new Cesium.Function() {
- @Override
- public Color function(Object... args) {
- return new Color(1.0, 0.0, 0.0, 0.5);
- }
- });
- PostProcessStageOptions postProcessStageOptions = PostProcessStageOptions.create(fragmentShaderSource);
- postProcessStageOptions.uniforms = uniforms;
+ // Shade selected model with highlight.
+ String fragmentShaderSource = "uniform sampler2D colorTexture;\n" + "varying vec2 v_textureCoordinates;\n"
+ + "uniform vec4 highlight;\n" + "void main() {\n"
+ + " vec4 color = texture2D(colorTexture, v_textureCoordinates);\n" + " if (czm_selected()) {\n"
+ + " vec3 highlighted = highlight.a * highlight.rgb + (1.0 - highlight.a) * color.rgb;\n"
+ + " gl_FragColor = vec4(highlighted, 1.0);\n" + " } else { \n" + " gl_FragColor = color;\n"
+ + " }\n" + "}\n";
+ JsObject uniforms = JsObject.create();
+ uniforms.setProperty("highlight", new Cesium.Function() {
+ @Override
+ public Color function(Object... args) {
+ return new Color(1.0, 0.0, 0.0, 0.5);
+ }
+ });
+ PostProcessStageOptions postProcessStageOptions = PostProcessStageOptions.create(fragmentShaderSource);
+ postProcessStageOptions.uniforms = uniforms;
- final PostProcess stage = csVPanel.getViewer().scene().postProcessStages
- .add(new PostProcessStage(postProcessStageOptions));
- JsObject.setProperty(stage, "selected", new Primitive[0]);
+ final PostProcess stage = csVPanel.getViewer().scene().postProcessStages
+ .add(new PostProcessStage(postProcessStageOptions));
+ JsObject.setProperty(stage, "selected", new Primitive[0]);
- ScreenSpaceEventHandler handler = new ScreenSpaceEventHandler(csVPanel.getViewer().scene().canvas());
- handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
- @Override
- public void function(Object event) {
- MouseMoveEvent mouseMoveEvent = (MouseMoveEvent) event;
- PickedObject pickedObject = csVPanel.getViewer().scene().pick(mouseMoveEvent.endPosition);
- if (pickedObject != null) {
- JsObject.setProperty(stage, "selected", new Primitive[] { pickedObject.primitive });
- } else {
- JsObject.setProperty(stage, "selected", new Primitive[0]);
- }
- }
- }, ScreenSpaceEventType.MOUSE_MOVE());
+ ScreenSpaceEventHandler handler = new ScreenSpaceEventHandler(csVPanel.getViewer().scene().canvas());
+ handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
+ @Override
+ public void function(Object event) {
+ MouseMoveEvent mouseMoveEvent = (MouseMoveEvent) event;
+ PickedObject pickedObject = csVPanel.getViewer().scene().pick(mouseMoveEvent.endPosition);
+ if (pickedObject != null) {
+ JsObject.setProperty(stage, "selected", new Primitive[]{pickedObject.primitive});
+ } else {
+ JsObject.setProperty(stage, "selected", new Primitive[0]);
+ }
+ }
+ }, ScreenSpaceEventType.MOUSE_MOVE());
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
- contentPanel.add(new HTML("Post processing effects.
"));
- contentPanel.add(aPanel);
+ contentPanel.add(new HTML("Post processing effects.
"));
+ contentPanel.add(aPanel);
- initWidget(contentPanel);
- }
+ initWidget(contentPanel);
+ }
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CustomPerFeaturePostProcess.txt";
- return sourceCodeURLs;
- }
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CustomPerFeaturePostProcess.txt";
+ return sourceCodeURLs;
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomPostProcess.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomPostProcess.java
index b860c22a9e029a55774018d2e5187d3b257ac491..fb68bb7d2d2abf530b98e674f6e2e3f8e1ff72f2 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomPostProcess.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomPostProcess.java
@@ -16,12 +16,9 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.HTML;
-
import org.cesiumjs.cs.core.Cartesian3;
import org.cesiumjs.cs.datasources.graphics.ModelGraphics;
import org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions;
@@ -34,57 +31,59 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class CustomPostProcess extends AbstractExample {
- private ViewerPanel csVPanel;
+ private ViewerPanel csVPanel;
- @Inject
- public CustomPostProcess(ShowcaseExampleStore store) {
- super("Custom Post Process", "Custom post processing effect",
- new String[] { "Custom post process", "Post processing" }, store);
- }
+ @Inject
+ public CustomPostProcess(ShowcaseExampleStore store) {
+ super("Custom Post Process", "Custom post processing effect",
+ new String[]{"Custom post process", "Post processing"}, store);
+ }
- @Override
- public void buildPanel() {
- ViewerOptions viewerOptions = new ViewerOptions();
- viewerOptions.shouldAnimate = true;
- csVPanel = new ViewerPanel(viewerOptions);
+ @Override
+ public void buildPanel() {
+ ViewerOptions viewerOptions = new ViewerOptions();
+ viewerOptions.shouldAnimate = true;
+ csVPanel = new ViewerPanel(viewerOptions);
- ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(
- GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb");
- EntityOptions options = new EntityOptions();
- options.name = GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb";
- options.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-123.0744619, 44.0503706));
- options.model = new ModelGraphics(modelGraphicsOptions);
- csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(options);
+ ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
+ modelGraphicsOptions.uri = new ConstantProperty<>(
+ GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb");
+ EntityOptions options = new EntityOptions();
+ options.name = GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb";
+ options.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-123.0744619, 44.0503706));
+ options.model = new ModelGraphics(modelGraphicsOptions);
+ csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(options);
- String fragmentShaderSource = "uniform sampler2D colorTexture; \n" + "varying vec2 v_textureCoordinates; \n"
- + "const int KERNEL_WIDTH = 16; \n" + "void main(void) \n" + "{ \n"
- + " vec2 step = 1.0 / czm_viewport.zw; \n"
- + " vec2 integralPos = v_textureCoordinates - mod(v_textureCoordinates, 8.0 * step); \n"
- + " vec3 averageValue = vec3(0.0); \n" + " for (int i = 0; i < KERNEL_WIDTH; i++) \n" + " { \n"
- + " for (int j = 0; j < KERNEL_WIDTH; j++) \n" + " { \n"
- + " averageValue += texture2D(colorTexture, integralPos + step * vec2(i, j)).rgb; \n"
- + " } \n" + " } \n" + " averageValue /= float(KERNEL_WIDTH * KERNEL_WIDTH); \n"
- + " gl_FragColor = vec4(averageValue, 1.0); \n" + "} \n";
- csVPanel.getViewer().scene().postProcessStages.add(PostProcessStage.create(fragmentShaderSource));
+ String fragmentShaderSource = "uniform sampler2D colorTexture; \n" + "varying vec2 v_textureCoordinates; \n"
+ + "const int KERNEL_WIDTH = 16; \n" + "void main(void) \n" + "{ \n"
+ + " vec2 step = 1.0 / czm_viewport.zw; \n"
+ + " vec2 integralPos = v_textureCoordinates - mod(v_textureCoordinates, 8.0 * step); \n"
+ + " vec3 averageValue = vec3(0.0); \n" + " for (int i = 0; i < KERNEL_WIDTH; i++) \n" + " { \n"
+ + " for (int j = 0; j < KERNEL_WIDTH; j++) \n" + " { \n"
+ + " averageValue += texture2D(colorTexture, integralPos + step * vec2(i, j)).rgb; \n"
+ + " } \n" + " } \n" + " averageValue /= float(KERNEL_WIDTH * KERNEL_WIDTH); \n"
+ + " gl_FragColor = vec4(averageValue, 1.0); \n" + "} \n";
+ csVPanel.getViewer().scene().postProcessStages.add(PostProcessStage.create(fragmentShaderSource));
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
- contentPanel.add(new HTML("Post processing effects.
"));
- contentPanel.add(aPanel);
+ contentPanel.add(new HTML("Post processing effects.
"));
+ contentPanel.add(aPanel);
- initWidget(contentPanel);
- }
+ initWidget(contentPanel);
+ }
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CustomPostProcess.txt";
- return sourceCodeURLs;
- }
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CustomPostProcess.txt";
+ return sourceCodeURLs;
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/DepthOfField.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/DepthOfField.java
index c6434e80ef36d52f78b9b78345f1cdccc26d761a..00dae78380a2260529a4078ac3d871f709df0966 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/DepthOfField.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/DepthOfField.java
@@ -16,8 +16,6 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
@@ -25,7 +23,6 @@ import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
-
import org.cesiumjs.cs.Cesium;
import org.cesiumjs.cs.core.Cartesian3;
import org.cesiumjs.cs.datasources.graphics.ModelGraphics;
@@ -42,153 +39,152 @@ import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class DepthOfField extends AbstractExample {
- private ViewerPanel csVPanel;
-
- private CheckBox depthOfFieldCBox;
- private Slider focalDistanceSlider;
- private Slider deltaSlider;
- private Slider sigmaSlider;
- private Slider stepSizeSlider;
-
- private int numberOfBalloons = 13;
- private double lonIncrement = 0.00025;
- private double initialLon = -122.99875;
- private double lat = 44.0503706;
- private double height = 100.0;
-
- private PostProcessStageComposite depthOfField;
-
- @Inject
- public DepthOfField(ShowcaseExampleStore store) {
- super("Depth of Field", "Depth of field", new String[] { "Depth of field", "Post processing" }, store);
- }
-
- @Override
- public void buildPanel() {
- csVPanel = new ViewerPanel();
-
- for (int i = 0; i < numberOfBalloons; i++) {
- double lon = initialLon + i * lonIncrement;
- createModel(lon, lat, height);
+ private final int numberOfBalloons = 13;
+ private final double lonIncrement = 0.00025;
+ private final double initialLon = -122.99875;
+ private final double lat = 44.0503706;
+ private final double height = 100.0;
+ private ViewerPanel csVPanel;
+ private CheckBox depthOfFieldCBox;
+ private Slider focalDistanceSlider;
+ private Slider deltaSlider;
+ private Slider sigmaSlider;
+ private Slider stepSizeSlider;
+ private PostProcessStageComposite depthOfField;
+
+ @Inject
+ public DepthOfField(ShowcaseExampleStore store) {
+ super("Depth of Field", "Depth of field", new String[]{"Depth of field", "Post processing"}, store);
}
- depthOfFieldCBox = new CheckBox();
- depthOfFieldCBox.setValue(true);
- depthOfFieldCBox.addValueChangeHandler(new MValueChangeHandler());
-
- focalDistanceSlider = new Slider("focalDistanceSlider", 0, 500, 87);
- focalDistanceSlider.setStep(1);
- focalDistanceSlider.setWidth("150px");
- focalDistanceSlider.addListener(new MSliderListener());
-
- deltaSlider = new Slider("deltaSlider", 10, 200, 100);
- deltaSlider.setStep(1);
- deltaSlider.setWidth("150px");
- deltaSlider.addListener(new MSliderListener());
-
- sigmaSlider = new Slider("sigmaSlider", 50, 500, 378);
- sigmaSlider.setStep(1);
- sigmaSlider.setWidth("150px");
- sigmaSlider.addListener(new MSliderListener());
-
- stepSizeSlider = new Slider("stepSizeSlider", 0, 700, 246);
- stepSizeSlider.setStep(1);
- stepSizeSlider.setWidth("150px");
- stepSizeSlider.addListener(new MSliderListener());
-
- FlexTable flexTable = new FlexTable();
- flexTable.setHTML(1, 0, "Depth Of Field");
- flexTable.setWidget(1, 1, depthOfFieldCBox);
- flexTable.setHTML(2, 0, "Focal Distance");
- flexTable.setWidget(2, 1, focalDistanceSlider);
- flexTable.setHTML(3, 0, "Delta");
- flexTable.setWidget(3, 1, deltaSlider);
- flexTable.setHTML(4, 0, "Sigma");
- flexTable.setWidget(4, 1, sigmaSlider);
- flexTable.setHTML(5, 0, "Step Size");
- flexTable.setWidget(5, 1, stepSizeSlider);
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(flexTable, 20, 20);
-
- contentPanel.add(new HTML("Post processing effects.
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
-
- depthOfField = (PostProcessStageComposite) csVPanel.getViewer().scene().postProcessStages
- .add(PostProcessStageLibrary.createDepthOfFieldStage());
- if (!PostProcessStageLibrary.isDepthOfFieldSupported(csVPanel.getViewer().scene())) {
- Cesium.log("This browser does not support the depth of field post process.");
+ @Override
+ public void buildPanel() {
+ csVPanel = new ViewerPanel();
+
+ for (int i = 0; i < numberOfBalloons; i++) {
+ double lon = initialLon + i * lonIncrement;
+ createModel(lon, lat, height);
+ }
+
+ depthOfFieldCBox = new CheckBox();
+ depthOfFieldCBox.setValue(true);
+ depthOfFieldCBox.addValueChangeHandler(new MValueChangeHandler());
+
+ focalDistanceSlider = new Slider("focalDistanceSlider", 0, 500, 87);
+ focalDistanceSlider.setStep(1);
+ focalDistanceSlider.setWidth("150px");
+ focalDistanceSlider.addListener(new MSliderListener());
+
+ deltaSlider = new Slider("deltaSlider", 10, 200, 100);
+ deltaSlider.setStep(1);
+ deltaSlider.setWidth("150px");
+ deltaSlider.addListener(new MSliderListener());
+
+ sigmaSlider = new Slider("sigmaSlider", 50, 500, 378);
+ sigmaSlider.setStep(1);
+ sigmaSlider.setWidth("150px");
+ sigmaSlider.addListener(new MSliderListener());
+
+ stepSizeSlider = new Slider("stepSizeSlider", 0, 700, 246);
+ stepSizeSlider.setStep(1);
+ stepSizeSlider.setWidth("150px");
+ stepSizeSlider.addListener(new MSliderListener());
+
+ FlexTable flexTable = new FlexTable();
+ flexTable.setHTML(1, 0, "Depth Of Field");
+ flexTable.setWidget(1, 1, depthOfFieldCBox);
+ flexTable.setHTML(2, 0, "Focal Distance");
+ flexTable.setWidget(2, 1, focalDistanceSlider);
+ flexTable.setHTML(3, 0, "Delta");
+ flexTable.setWidget(3, 1, deltaSlider);
+ flexTable.setHTML(4, 0, "Sigma");
+ flexTable.setWidget(4, 1, sigmaSlider);
+ flexTable.setHTML(5, 0, "Step Size");
+ flexTable.setWidget(5, 1, stepSizeSlider);
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(flexTable, 20, 20);
+
+ contentPanel.add(new HTML("Post processing effects.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
+
+ depthOfField = csVPanel.getViewer().scene().postProcessStages
+ .add(PostProcessStageLibrary.createDepthOfFieldStage());
+ if (!PostProcessStageLibrary.isDepthOfFieldSupported(csVPanel.getViewer().scene())) {
+ Cesium.log("This browser does not support the depth of field post process.");
+ }
+
+ updatePostProcess();
+
+ Cartesian3 target = Cartesian3.fromDegrees(initialLon + lonIncrement, lat, height + 7.5);
+ Cartesian3 offset = new Cartesian3(-37.048378684557974, -24.852967044804245, 4.352023653686047);
+ csVPanel.getViewer().scene().camera().lookAt(target, offset);
}
- updatePostProcess();
-
- Cartesian3 target = Cartesian3.fromDegrees(initialLon + lonIncrement, lat, height + 7.5);
- Cartesian3 offset = new Cartesian3(-37.048378684557974, -24.852967044804245, 4.352023653686047);
- csVPanel.getViewer().scene().camera().lookAt(target, offset);
- }
-
- private void createModel(double lon, double lat, double height) {
- Cartesian3 position = Cartesian3.fromDegrees(lon, lat, height);
-
- ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(
- GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb");
- EntityOptions options = new EntityOptions();
- options.name = GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb";
- options.position = new ConstantPositionProperty(position);
- options.model = new ModelGraphics(modelGraphicsOptions);
- csVPanel.getViewer().entities().add(options);
- }
-
- private void updatePostProcess() {
- depthOfField.enabled = depthOfFieldCBox.getValue();
- depthOfField.uniforms.setProperty("focalDistance", focalDistanceSlider.getValue());
- depthOfField.uniforms.setProperty("delta", deltaSlider.getValue() / 100.);
- depthOfField.uniforms.setProperty("sigma", sigmaSlider.getValue() / 100.);
- depthOfField.uniforms.setProperty("stepSize", stepSizeSlider.getValue() / 100.);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "DepthOfField.txt";
- return sourceCodeURLs;
- }
-
- private class MValueChangeHandler implements ValueChangeHandler {
- @Override
- public void onValueChange(ValueChangeEvent event) {
- updatePostProcess();
+ private void createModel(double lon, double lat, double height) {
+ Cartesian3 position = Cartesian3.fromDegrees(lon, lat, height);
+
+ ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
+ modelGraphicsOptions.uri = new ConstantProperty<>(
+ GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb");
+ EntityOptions options = new EntityOptions();
+ options.name = GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb";
+ options.position = new ConstantPositionProperty(position);
+ options.model = new ModelGraphics(modelGraphicsOptions);
+ csVPanel.getViewer().entities().add(options);
}
- }
- private class MSliderListener implements SliderListener {
- @Override
- public void onStart(SliderEvent e) {
- //
+ private void updatePostProcess() {
+ depthOfField.enabled = depthOfFieldCBox.getValue();
+ depthOfField.uniforms.setProperty("focalDistance", focalDistanceSlider.getValue());
+ depthOfField.uniforms.setProperty("delta", deltaSlider.getValue() / 100.);
+ depthOfField.uniforms.setProperty("sigma", sigmaSlider.getValue() / 100.);
+ depthOfField.uniforms.setProperty("stepSize", stepSizeSlider.getValue() / 100.);
}
@Override
- public boolean onSlide(SliderEvent e) {
- updatePostProcess();
- return true;
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "DepthOfField.txt";
+ return sourceCodeURLs;
}
- @Override
- public void onChange(SliderEvent e) {
- //
+ private class MValueChangeHandler implements ValueChangeHandler {
+ @Override
+ public void onValueChange(ValueChangeEvent event) {
+ updatePostProcess();
+ }
}
- @Override
- public void onStop(SliderEvent e) {
- //
+ private class MSliderListener implements SliderListener {
+ @Override
+ public void onStart(SliderEvent e) {
+ //
+ }
+
+ @Override
+ public boolean onSlide(SliderEvent e) {
+ updatePostProcess();
+ return true;
+ }
+
+ @Override
+ public void onChange(SliderEvent e) {
+ //
+ }
+
+ @Override
+ public void onStop(SliderEvent e) {
+ //
+ }
}
- }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Drawing.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Drawing.java
index e7364ff588246f0dd6909a7bfa9f5d175faf8c07..4f64816aee797ea30bb99205439a5f5b767bf13b 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Drawing.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Drawing.java
@@ -22,14 +22,8 @@ import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.AbsolutePanel;
-import com.google.gwt.user.client.ui.FlexTable;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.Image;
-import com.google.gwt.user.client.ui.RootPanel;
-import com.google.gwt.user.client.ui.ToggleButton;
+import com.google.gwt.user.client.ui.*;
import com.google.inject.Inject;
-
import org.cesiumjs.cs.Cesium;
import org.cesiumjs.cs.collections.PointPrimitiveCollection;
import org.cesiumjs.cs.core.Cartesian3;
@@ -39,13 +33,7 @@ import org.cesiumjs.cs.core.geometry.GeometryInstance;
import org.cesiumjs.cs.core.options.GeometryInstanceOptions;
import org.cesiumjs.cs.js.JsObject;
import org.cesiumjs.cs.scene.GroundPrimitive;
-import org.cesiumjs.cs.scene.interaction.CirclePrimitive;
-import org.cesiumjs.cs.scene.interaction.CorridorPrimitive;
-import org.cesiumjs.cs.scene.interaction.DrawInteraction;
-import org.cesiumjs.cs.scene.interaction.MarkerType;
-import org.cesiumjs.cs.scene.interaction.PolygonPrimitive;
-import org.cesiumjs.cs.scene.interaction.PrimitiveType;
-import org.cesiumjs.cs.scene.interaction.RectanglePrimitive;
+import org.cesiumjs.cs.scene.interaction.*;
import org.cesiumjs.cs.scene.interaction.options.DrawInteractionOptions;
import org.cesiumjs.cs.scene.options.GroundPrimitiveOptions;
import org.cesiumjs.cs.scene.options.PointPrimitiveOptions;
@@ -58,260 +46,260 @@ import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStor
*/
public class Drawing extends AbstractExample {
- private ViewerPanel csVPanel;
-
- private DrawInteraction drawInteraction;
+ private ViewerPanel csVPanel;
- private ToggleButton drawPointTBtn;
- private ToggleButton drawLineTBtn;
- private ToggleButton drawExtentTBtn;
- private ToggleButton drawPolygonTBtn;
- private ToggleButton drawCircleTBtn;
+ private DrawInteraction drawInteraction;
- @Inject
- public Drawing(ShowcaseExampleStore store) {
- super("Drawing", "Example to usage drawing interactions",
- new String[] { "Showcase", "Cesium", "3d", "Viewer", "Drawing" }, store);
- }
+ private ToggleButton drawPointTBtn;
+ private ToggleButton drawLineTBtn;
+ private ToggleButton drawExtentTBtn;
+ private ToggleButton drawPolygonTBtn;
+ private ToggleButton drawCircleTBtn;
- @Override
- public void buildPanel() {
- csVPanel = new ViewerPanel();
- csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;
+ @Inject
+ public Drawing(ShowcaseExampleStore store) {
+ super("Drawing", "Example to usage drawing interactions",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer", "Drawing"}, store);
+ }
- Image image = new Image(GWT.getModuleBaseURL() + "images/point.png");
- image.setPixelSize(22, 22);
- drawPointTBtn = new ToggleButton(image);
- drawPointTBtn.setPixelSize(22, 22);
- drawPointTBtn.getElement().getStyle().setBackgroundImage("none");
- drawPointTBtn.getElement().getStyle().setBorderColor("rgba(63,66,70,1)");
- drawPointTBtn.getElement().getStyle().setBackgroundColor("rgba(63,66,70,0.7)");
- drawPointTBtn.addValueChangeHandler(new ValueChangeHandler() {
- @Override
- public void onValueChange(ValueChangeEvent event) {
- drawExtentTBtn.setValue(false, false);
- drawPolygonTBtn.setValue(false, false);
- drawCircleTBtn.setValue(false, false);
- if (drawInteraction != null) {
- drawInteraction.destroy();
- drawInteraction = null;
- }
- if (event.getValue()) {
- DrawInteractionOptions options = new DrawInteractionOptions();
- options.type = PrimitiveType.POINT;
- options.markerType = MarkerType.BILLBOARD_GRAPHIC;
- drawInteraction = new DrawInteraction(csVPanel.getViewer().scene(), options);
- drawInteraction.addDrawListener(new DrawInteractionListener(), DrawInteraction.EventType.DRAW_END);
- }
- }
- });
+ @Override
+ public void buildPanel() {
+ csVPanel = new ViewerPanel();
+ csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;
- image = new Image(GWT.getModuleBaseURL() + "images/line.png");
- image.setPixelSize(22, 22);
- drawLineTBtn = new ToggleButton(image);
- drawLineTBtn.setPixelSize(22, 22);
- drawLineTBtn.getElement().getStyle().setBackgroundImage("none");
- drawLineTBtn.getElement().getStyle().setBorderColor("rgba(63,66,70,1)");
- drawLineTBtn.getElement().getStyle().setBackgroundColor("rgba(63,66,70,0.7)");
- drawLineTBtn.addValueChangeHandler(new ValueChangeHandler() {
- @Override
- public void onValueChange(ValueChangeEvent event) {
- drawExtentTBtn.setValue(false, false);
- drawPolygonTBtn.setValue(false, false);
- drawCircleTBtn.setValue(false, false);
- if (drawInteraction != null) {
- drawInteraction.destroy();
- drawInteraction = null;
- }
- if (event.getValue()) {
- DrawInteractionOptions options = new DrawInteractionOptions();
- options.type = PrimitiveType.CORRIDOR;
- options.markerType = MarkerType.BILLBOARD_GRAPHIC;
- drawInteraction = new DrawInteraction(csVPanel.getViewer().scene(), options);
- drawInteraction.addDrawListener(new DrawInteractionListener(), DrawInteraction.EventType.DRAW_END);
- }
- }
- });
+ Image image = new Image(GWT.getModuleBaseURL() + "images/point.png");
+ image.setPixelSize(22, 22);
+ drawPointTBtn = new ToggleButton(image);
+ drawPointTBtn.setPixelSize(22, 22);
+ drawPointTBtn.getElement().getStyle().setBackgroundImage("none");
+ drawPointTBtn.getElement().getStyle().setBorderColor("rgba(63,66,70,1)");
+ drawPointTBtn.getElement().getStyle().setBackgroundColor("rgba(63,66,70,0.7)");
+ drawPointTBtn.addValueChangeHandler(new ValueChangeHandler() {
+ @Override
+ public void onValueChange(ValueChangeEvent event) {
+ drawExtentTBtn.setValue(false, false);
+ drawPolygonTBtn.setValue(false, false);
+ drawCircleTBtn.setValue(false, false);
+ if (drawInteraction != null) {
+ drawInteraction.destroy();
+ drawInteraction = null;
+ }
+ if (event.getValue()) {
+ DrawInteractionOptions options = new DrawInteractionOptions();
+ options.type = PrimitiveType.POINT;
+ options.markerType = MarkerType.BILLBOARD_GRAPHIC;
+ drawInteraction = new DrawInteraction(csVPanel.getViewer().scene(), options);
+ drawInteraction.addDrawListener(new DrawInteractionListener(), DrawInteraction.EventType.DRAW_END);
+ }
+ }
+ });
- image = new Image(GWT.getModuleBaseURL() + "images/rect.png");
- image.setPixelSize(22, 22);
- drawExtentTBtn = new ToggleButton(image);
- drawExtentTBtn.setPixelSize(22, 22);
- drawExtentTBtn.getElement().getStyle().setBackgroundImage("none");
- drawExtentTBtn.getElement().getStyle().setBorderColor("rgba(63,66,70,1)");
- drawExtentTBtn.getElement().getStyle().setBackgroundColor("rgba(63,66,70,0.7)");
- drawExtentTBtn.addValueChangeHandler(new ValueChangeHandler() {
- @Override
- public void onValueChange(ValueChangeEvent event) {
- drawLineTBtn.setValue(false, false);
- drawPolygonTBtn.setValue(false, false);
- drawCircleTBtn.setValue(false, false);
- if (drawInteraction != null) {
- drawInteraction.destroy();
- drawInteraction = null;
- }
- if (event.getValue()) {
- DrawInteractionOptions options = new DrawInteractionOptions();
- options.markerType = MarkerType.BILLBOARD_GRAPHIC;
- options.outlineColor = Color.RED();
- options.outlineWidth = 1;
- drawInteraction = new DrawInteraction(csVPanel.getViewer().scene(), options);
- drawInteraction.addDrawListener(new DrawInteractionListener(), DrawInteraction.EventType.DRAW_END);
- // As Entity
- // drawInteraction.addDrawListener(new DrawInteraction.Listener() {
- // @Override
- // public void onDraw(DrawInteraction.Event event) {
- // if (!(event.getPrimitive() instanceof RectanglePrimitive)) {
- // return;
- // }
- // RectanglePrimitive primitive = ((RectanglePrimitive) event.getPrimitive());
- // Rectangle rectangle = primitive.getRectangle();
- //
- // RectangleGraphicsOptions rectangleGraphicsOptions = new
- // RectangleGraphicsOptions();
- // rectangleGraphicsOptions.coordinates = new ConstantProperty<>(rectangle);
- // rectangleGraphicsOptions.material = new
- // ColorMaterialProperty(Color.RED().withAlpha(0.5f));
- //
- // EntityOptions entityOptions = new EntityOptions();
- // entityOptions.rectangle = new RectangleGraphics(rectangleGraphicsOptions);
- //
- // csVPanel.getViewer().entities().add(entityOptions);
- // }
- // }, DrawInteraction.EventType.DRAW_END);
- }
- }
- });
+ image = new Image(GWT.getModuleBaseURL() + "images/line.png");
+ image.setPixelSize(22, 22);
+ drawLineTBtn = new ToggleButton(image);
+ drawLineTBtn.setPixelSize(22, 22);
+ drawLineTBtn.getElement().getStyle().setBackgroundImage("none");
+ drawLineTBtn.getElement().getStyle().setBorderColor("rgba(63,66,70,1)");
+ drawLineTBtn.getElement().getStyle().setBackgroundColor("rgba(63,66,70,0.7)");
+ drawLineTBtn.addValueChangeHandler(new ValueChangeHandler() {
+ @Override
+ public void onValueChange(ValueChangeEvent event) {
+ drawExtentTBtn.setValue(false, false);
+ drawPolygonTBtn.setValue(false, false);
+ drawCircleTBtn.setValue(false, false);
+ if (drawInteraction != null) {
+ drawInteraction.destroy();
+ drawInteraction = null;
+ }
+ if (event.getValue()) {
+ DrawInteractionOptions options = new DrawInteractionOptions();
+ options.type = PrimitiveType.CORRIDOR;
+ options.markerType = MarkerType.BILLBOARD_GRAPHIC;
+ drawInteraction = new DrawInteraction(csVPanel.getViewer().scene(), options);
+ drawInteraction.addDrawListener(new DrawInteractionListener(), DrawInteraction.EventType.DRAW_END);
+ }
+ }
+ });
- image = new Image(GWT.getModuleBaseURL() + "images/polygon.png");
- image.setPixelSize(22, 22);
- drawPolygonTBtn = new ToggleButton(image);
- drawPolygonTBtn.setPixelSize(22, 22);
- drawPolygonTBtn.getElement().getStyle().setBackgroundImage("none");
- drawPolygonTBtn.getElement().getStyle().setBorderColor("rgba(63,66,70,1)");
- drawPolygonTBtn.getElement().getStyle().setBackgroundColor("rgba(63,66,70,0.7)");
- drawPolygonTBtn.addValueChangeHandler(new ValueChangeHandler() {
- @Override
- public void onValueChange(ValueChangeEvent event) {
- drawLineTBtn.setValue(false, false);
- drawExtentTBtn.setValue(false, false);
- drawCircleTBtn.setValue(false, false);
- if (drawInteraction != null) {
- drawInteraction.destroy();
- drawInteraction = null;
- }
- if (event.getValue()) {
- DrawInteractionOptions options = new DrawInteractionOptions();
- options.type = PrimitiveType.POLYGON;
- options.markerType = MarkerType.BILLBOARD_GRAPHIC;
- options.color = Color.BLUE().withAlpha(0.5f);
- drawInteraction = new DrawInteraction(csVPanel.getViewer().scene(), options);
- // As GroundPrimitive
- drawInteraction.addDrawListener(new DrawInteractionListener(), DrawInteraction.EventType.DRAW_END);
- }
- }
- });
+ image = new Image(GWT.getModuleBaseURL() + "images/rect.png");
+ image.setPixelSize(22, 22);
+ drawExtentTBtn = new ToggleButton(image);
+ drawExtentTBtn.setPixelSize(22, 22);
+ drawExtentTBtn.getElement().getStyle().setBackgroundImage("none");
+ drawExtentTBtn.getElement().getStyle().setBorderColor("rgba(63,66,70,1)");
+ drawExtentTBtn.getElement().getStyle().setBackgroundColor("rgba(63,66,70,0.7)");
+ drawExtentTBtn.addValueChangeHandler(new ValueChangeHandler() {
+ @Override
+ public void onValueChange(ValueChangeEvent event) {
+ drawLineTBtn.setValue(false, false);
+ drawPolygonTBtn.setValue(false, false);
+ drawCircleTBtn.setValue(false, false);
+ if (drawInteraction != null) {
+ drawInteraction.destroy();
+ drawInteraction = null;
+ }
+ if (event.getValue()) {
+ DrawInteractionOptions options = new DrawInteractionOptions();
+ options.markerType = MarkerType.BILLBOARD_GRAPHIC;
+ options.outlineColor = Color.RED();
+ options.outlineWidth = 1;
+ drawInteraction = new DrawInteraction(csVPanel.getViewer().scene(), options);
+ drawInteraction.addDrawListener(new DrawInteractionListener(), DrawInteraction.EventType.DRAW_END);
+ // As Entity
+ // drawInteraction.addDrawListener(new DrawInteraction.Listener() {
+ // @Override
+ // public void onDraw(DrawInteraction.Event event) {
+ // if (!(event.getPrimitive() instanceof RectanglePrimitive)) {
+ // return;
+ // }
+ // RectanglePrimitive primitive = ((RectanglePrimitive) event.getPrimitive());
+ // Rectangle rectangle = primitive.getRectangle();
+ //
+ // RectangleGraphicsOptions rectangleGraphicsOptions = new
+ // RectangleGraphicsOptions();
+ // rectangleGraphicsOptions.coordinates = new ConstantProperty<>(rectangle);
+ // rectangleGraphicsOptions.material = new
+ // ColorMaterialProperty(Color.RED().withAlpha(0.5f));
+ //
+ // EntityOptions entityOptions = new EntityOptions();
+ // entityOptions.rectangle = new RectangleGraphics(rectangleGraphicsOptions);
+ //
+ // csVPanel.getViewer().entities().add(entityOptions);
+ // }
+ // }, DrawInteraction.EventType.DRAW_END);
+ }
+ }
+ });
- image = new Image(GWT.getModuleBaseURL() + "images/circle.png");
- image.setPixelSize(22, 22);
- drawCircleTBtn = new ToggleButton(image);
- drawCircleTBtn.setPixelSize(22, 22);
- drawCircleTBtn.getElement().getStyle().setBackgroundImage("none");
- drawCircleTBtn.getElement().getStyle().setBorderColor("rgba(63,66,70,1)");
- drawCircleTBtn.getElement().getStyle().setBackgroundColor("rgba(63,66,70,0.7)");
- drawCircleTBtn.addValueChangeHandler(new ValueChangeHandler() {
- @Override
- public void onValueChange(ValueChangeEvent event) {
- drawLineTBtn.setValue(false, false);
- drawExtentTBtn.setValue(false, false);
- drawPolygonTBtn.setValue(false, false);
- if (drawInteraction != null) {
- drawInteraction.destroy();
- drawInteraction = null;
- }
- if (event.getValue()) {
- DrawInteractionOptions options = new DrawInteractionOptions();
- options.type = PrimitiveType.CIRCLE;
- options.markerType = MarkerType.BILLBOARD_GRAPHIC;
- drawInteraction = new DrawInteraction(csVPanel.getViewer().scene(), options);
- // As GroundPrimitive
- drawInteraction.addDrawListener(new DrawInteractionListener(), DrawInteraction.EventType.DRAW_END);
- }
- }
- });
+ image = new Image(GWT.getModuleBaseURL() + "images/polygon.png");
+ image.setPixelSize(22, 22);
+ drawPolygonTBtn = new ToggleButton(image);
+ drawPolygonTBtn.setPixelSize(22, 22);
+ drawPolygonTBtn.getElement().getStyle().setBackgroundImage("none");
+ drawPolygonTBtn.getElement().getStyle().setBorderColor("rgba(63,66,70,1)");
+ drawPolygonTBtn.getElement().getStyle().setBackgroundColor("rgba(63,66,70,0.7)");
+ drawPolygonTBtn.addValueChangeHandler(new ValueChangeHandler() {
+ @Override
+ public void onValueChange(ValueChangeEvent event) {
+ drawLineTBtn.setValue(false, false);
+ drawExtentTBtn.setValue(false, false);
+ drawCircleTBtn.setValue(false, false);
+ if (drawInteraction != null) {
+ drawInteraction.destroy();
+ drawInteraction = null;
+ }
+ if (event.getValue()) {
+ DrawInteractionOptions options = new DrawInteractionOptions();
+ options.type = PrimitiveType.POLYGON;
+ options.markerType = MarkerType.BILLBOARD_GRAPHIC;
+ options.color = Color.BLUE().withAlpha(0.5f);
+ drawInteraction = new DrawInteraction(csVPanel.getViewer().scene(), options);
+ // As GroundPrimitive
+ drawInteraction.addDrawListener(new DrawInteractionListener(), DrawInteraction.EventType.DRAW_END);
+ }
+ }
+ });
- final FlexTable flexTable = new FlexTable();
- flexTable.setWidget(1, 0, drawPointTBtn);
- flexTable.setWidget(2, 0, drawLineTBtn);
- flexTable.setWidget(3, 0, drawExtentTBtn);
- flexTable.setWidget(4, 0, drawPolygonTBtn);
- flexTable.setWidget(5, 0, drawCircleTBtn);
+ image = new Image(GWT.getModuleBaseURL() + "images/circle.png");
+ image.setPixelSize(22, 22);
+ drawCircleTBtn = new ToggleButton(image);
+ drawCircleTBtn.setPixelSize(22, 22);
+ drawCircleTBtn.getElement().getStyle().setBackgroundImage("none");
+ drawCircleTBtn.getElement().getStyle().setBorderColor("rgba(63,66,70,1)");
+ drawCircleTBtn.getElement().getStyle().setBackgroundColor("rgba(63,66,70,0.7)");
+ drawCircleTBtn.addValueChangeHandler(new ValueChangeHandler() {
+ @Override
+ public void onValueChange(ValueChangeEvent event) {
+ drawLineTBtn.setValue(false, false);
+ drawExtentTBtn.setValue(false, false);
+ drawPolygonTBtn.setValue(false, false);
+ if (drawInteraction != null) {
+ drawInteraction.destroy();
+ drawInteraction = null;
+ }
+ if (event.getValue()) {
+ DrawInteractionOptions options = new DrawInteractionOptions();
+ options.type = PrimitiveType.CIRCLE;
+ options.markerType = MarkerType.BILLBOARD_GRAPHIC;
+ drawInteraction = new DrawInteraction(csVPanel.getViewer().scene(), options);
+ // As GroundPrimitive
+ drawInteraction.addDrawListener(new DrawInteractionListener(), DrawInteraction.EventType.DRAW_END);
+ }
+ }
+ });
- final AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(flexTable, RootPanel.get().getOffsetWidth() - 74, 42);
+ final FlexTable flexTable = new FlexTable();
+ flexTable.setWidget(1, 0, drawPointTBtn);
+ flexTable.setWidget(2, 0, drawLineTBtn);
+ flexTable.setWidget(3, 0, drawExtentTBtn);
+ flexTable.setWidget(4, 0, drawPolygonTBtn);
+ flexTable.setWidget(5, 0, drawCircleTBtn);
- contentPanel.add(new HTML(
- "Use Viewer to start building new applications or easily embed Cesium into existing applications.
"));
- contentPanel.add(aPanel);
+ final AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(flexTable, RootPanel.get().getOffsetWidth() - 74, 42);
- Window.addResizeHandler(new ResizeHandler() {
- @Override
- public void onResize(ResizeEvent resizeEvent) {
- aPanel.setWidgetPosition(flexTable, RootPanel.get().getOffsetWidth() - 74, 42);
- }
- });
+ contentPanel.add(new HTML(
+ "Use Viewer to start building new applications or easily embed Cesium into existing applications.
"));
+ contentPanel.add(aPanel);
- initWidget(contentPanel);
- }
+ Window.addResizeHandler(new ResizeHandler() {
+ @Override
+ public void onResize(ResizeEvent resizeEvent) {
+ aPanel.setWidgetPosition(flexTable, RootPanel.get().getOffsetWidth() - 74, 42);
+ }
+ });
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Drawing.txt";
- return sourceCodeURLs;
- }
+ initWidget(contentPanel);
+ }
- private class DrawInteractionListener implements DrawInteraction.Listener {
@Override
- public void onDraw(DrawInteraction.Event event) {
- Cartesian3[] positions = null;
- if (event.getPrimitive() instanceof PolygonPrimitive) {
- positions = ((PolygonPrimitive) event.getPrimitive()).getPositions();
- } else if (event.getPrimitive() instanceof RectanglePrimitive) {
- positions = ((RectanglePrimitive) event.getPrimitive()).getPositions();
- } else if (event.getPrimitive() instanceof CorridorPrimitive) {
- positions = ((CorridorPrimitive) event.getPrimitive()).getPositions();
- } else if (event.getPrimitive() instanceof CirclePrimitive) {
- positions = ((CirclePrimitive) event.getPrimitive()).getPositions();
- } else if (event.getPrimitive() instanceof org.cesiumjs.cs.scene.interaction.PointPrimitive) {
- positions = ((org.cesiumjs.cs.scene.interaction.PointPrimitive) event.getPrimitive()).getPositions();
- }
- if (positions != null) {
- Cesium.log(positions);
- }
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Drawing.txt";
+ return sourceCodeURLs;
+ }
- if (event.getPrimitive() instanceof org.cesiumjs.cs.scene.interaction.PointPrimitive) {
- PointPrimitiveOptions pointPrimitiveOptions = new PointPrimitiveOptions();
- pointPrimitiveOptions.color = Color.RED().withAlpha(0.5f);
- pointPrimitiveOptions.pixelSize = 10;
- pointPrimitiveOptions.position = positions[0];
- pointPrimitiveOptions.show = true;
+ private class DrawInteractionListener implements DrawInteraction.Listener {
+ @Override
+ public void onDraw(DrawInteraction.Event event) {
+ Cartesian3[] positions = null;
+ if (event.getPrimitive() instanceof PolygonPrimitive) {
+ positions = ((PolygonPrimitive) event.getPrimitive()).getPositions();
+ } else if (event.getPrimitive() instanceof RectanglePrimitive) {
+ positions = ((RectanglePrimitive) event.getPrimitive()).getPositions();
+ } else if (event.getPrimitive() instanceof CorridorPrimitive) {
+ positions = ((CorridorPrimitive) event.getPrimitive()).getPositions();
+ } else if (event.getPrimitive() instanceof CirclePrimitive) {
+ positions = ((CirclePrimitive) event.getPrimitive()).getPositions();
+ } else if (event.getPrimitive() instanceof org.cesiumjs.cs.scene.interaction.PointPrimitive) {
+ positions = ((org.cesiumjs.cs.scene.interaction.PointPrimitive) event.getPrimitive()).getPositions();
+ }
+ if (positions != null) {
+ Cesium.log(positions);
+ }
- PointPrimitiveCollection pointPrimitiveCollection = (PointPrimitiveCollection) csVPanel.getViewer().scene()
- .primitives().add(new PointPrimitiveCollection());
- pointPrimitiveCollection.add(pointPrimitiveOptions);
- } else {
- GeometryInstanceOptions geometryInstanceOptions = new GeometryInstanceOptions();
- geometryInstanceOptions.geometry = event.getPrimitive().getGeometry();
- geometryInstanceOptions.attributes = new Object();
- JsObject.setProperty(geometryInstanceOptions.attributes, "color",
- ColorGeometryInstanceAttribute.fromColor(Color.RED().withAlpha(0.5f)));
+ if (event.getPrimitive() instanceof org.cesiumjs.cs.scene.interaction.PointPrimitive) {
+ PointPrimitiveOptions pointPrimitiveOptions = new PointPrimitiveOptions();
+ pointPrimitiveOptions.color = Color.RED().withAlpha(0.5f);
+ pointPrimitiveOptions.pixelSize = 10;
+ pointPrimitiveOptions.position = positions[0];
+ pointPrimitiveOptions.show = true;
- GroundPrimitiveOptions options = new GroundPrimitiveOptions();
- options.geometryInstances = new GeometryInstance[] { new GeometryInstance(geometryInstanceOptions) };
- csVPanel.getViewer().scene().groundPrimitives().add(new GroundPrimitive(options));
- }
+ PointPrimitiveCollection pointPrimitiveCollection = (PointPrimitiveCollection) csVPanel.getViewer().scene()
+ .primitives().add(new PointPrimitiveCollection());
+ pointPrimitiveCollection.add(pointPrimitiveOptions);
+ } else {
+ GeometryInstanceOptions geometryInstanceOptions = new GeometryInstanceOptions();
+ geometryInstanceOptions.geometry = event.getPrimitive().getGeometry();
+ geometryInstanceOptions.attributes = new Object();
+ JsObject.setProperty(geometryInstanceOptions.attributes, "color",
+ ColorGeometryInstanceAttribute.fromColor(Color.RED().withAlpha(0.5f)));
+
+ GroundPrimitiveOptions options = new GroundPrimitiveOptions();
+ options.geometryInstances = new GeometryInstance[]{new GeometryInstance(geometryInstanceOptions)};
+ csVPanel.getViewer().scene().groundPrimitives().add(new GroundPrimitive(options));
+ }
+ }
}
- }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/DrawingOnTerrain.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/DrawingOnTerrain.java
index 73f1bae350c6274216b6085fcf6873039b8e802f..0dc8f5d4e0b68811124f92eac444f26202610834 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/DrawingOnTerrain.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/DrawingOnTerrain.java
@@ -16,11 +16,6 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
@@ -28,13 +23,8 @@ import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.ListBox;
-
import org.cesiumjs.cs.Cesium;
-import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.Color;
-import org.cesiumjs.cs.core.JulianDate;
-import org.cesiumjs.cs.core.Matrix4;
-import org.cesiumjs.cs.core.ScreenSpaceEventHandler;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.core.enums.ScreenSpaceEventType;
import org.cesiumjs.cs.core.events.MouseClickEvent;
import org.cesiumjs.cs.core.events.MouseMoveEvent;
@@ -56,194 +46,197 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* @author Serge Silaev aka iSergio
*/
public class DrawingOnTerrain extends AbstractExample {
- private enum SHAPE {
- LINE, POLYGON
- }
-
- private ViewerPanel csVPanel;
- private List shapePoints = new ArrayList<>();
- private Entity currentPoint = null;
- private Entity currentShape = null;
-
- private SHAPE shape = SHAPE.LINE;
-
- @Inject
- public DrawingOnTerrain(ShowcaseExampleStore store) {
- super("Drawing on Terrain", "Draw lines and polygons on terrain with mouse clicks.",
- new String[] { "drawing", "event", "callback" }, store);
- }
-
- @Override
- public void buildPanel() {
- ViewerOptions viewerOptions = new ViewerOptions();
- viewerOptions.selectionIndicator = false;
- viewerOptions.infoBox = false;
- viewerOptions.terrainProvider = Cesium.createWorldTerrain();
-
- csVPanel = new ViewerPanel(viewerOptions);
-
- csVPanel.getViewer().cesiumWidget.screenSpaceEventHandler
- .removeInputAction(ScreenSpaceEventType.LEFT_DOUBLE_CLICK());
-
- ScreenSpaceEventHandler handler = new ScreenSpaceEventHandler(csVPanel.getViewer().canvas());
- handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
- @Override
- public void function(Object event) {
- MouseClickEvent mouseClickEvent = (MouseClickEvent) event;
- if (mouseClickEvent.position == null) {
- return;
- }
- Cartesian3 position = csVPanel.getViewer().scene().pickPosition(mouseClickEvent.position);
- if (position == null) {
- return;
- }
- if (shapePoints.size() == 0) {
- currentPoint = createPoint(position);
- shapePoints.add(position);
- CallbackProperty callbackProperty = new CallbackProperty<>(
- new CallbackProperty.Callback() {
- @Override
- public Cartesian3[] function(JulianDate time, Cartesian3[] result) {
- return shapePoints.toArray(new Cartesian3[0]);
+ private final List shapePoints = new ArrayList<>();
+ private ViewerPanel csVPanel;
+ private Entity currentPoint = null;
+ private Entity currentShape = null;
+ private SHAPE shape = SHAPE.LINE;
+
+ @Inject
+ public DrawingOnTerrain(ShowcaseExampleStore store) {
+ super("Drawing on Terrain", "Draw lines and polygons on terrain with mouse clicks.",
+ new String[]{"drawing", "event", "callback"}, store);
+ }
+
+ @Override
+ public void buildPanel() {
+ ViewerOptions viewerOptions = new ViewerOptions();
+ viewerOptions.selectionIndicator = false;
+ viewerOptions.infoBox = false;
+ viewerOptions.terrainProvider = Cesium.createWorldTerrain();
+
+ csVPanel = new ViewerPanel(viewerOptions);
+
+ csVPanel.getViewer().cesiumWidget.screenSpaceEventHandler
+ .removeInputAction(ScreenSpaceEventType.LEFT_DOUBLE_CLICK());
+
+ ScreenSpaceEventHandler handler = new ScreenSpaceEventHandler(csVPanel.getViewer().canvas());
+ handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
+ @Override
+ public void function(Object event) {
+ MouseClickEvent mouseClickEvent = (MouseClickEvent) event;
+ if (mouseClickEvent.position == null) {
+ return;
}
- }, false);
- currentShape = drawShape(callbackProperty);
- }
- shapePoints.add(position);
- createPoint(position);
- }
- }, ScreenSpaceEventType.LEFT_CLICK());
- handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
- @Override
- public void function(Object event) {
- if (currentPoint == null) {
- return;
- }
- MouseMoveEvent mouseMoveEvent = (MouseMoveEvent) event;
- if (mouseMoveEvent.endPosition == null) {
- return;
+ Cartesian3 position = csVPanel.getViewer().scene().pickPosition(mouseClickEvent.position);
+ if (position == null) {
+ return;
+ }
+ if (shapePoints.size() == 0) {
+ currentPoint = createPoint(position);
+ shapePoints.add(position);
+ CallbackProperty callbackProperty = new CallbackProperty<>(
+ new CallbackProperty.Callback() {
+ @Override
+ public Cartesian3[] function(JulianDate time, Cartesian3[] result) {
+ return shapePoints.toArray(new Cartesian3[0]);
+ }
+ }, false);
+ currentShape = drawShape(callbackProperty);
+ }
+ shapePoints.add(position);
+ createPoint(position);
+ }
+ }, ScreenSpaceEventType.LEFT_CLICK());
+ handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
+ @Override
+ public void function(Object event) {
+ if (currentPoint == null) {
+ return;
+ }
+ MouseMoveEvent mouseMoveEvent = (MouseMoveEvent) event;
+ if (mouseMoveEvent.endPosition == null) {
+ return;
+ }
+ Cartesian3 position = csVPanel.getViewer().scene().pickPosition(mouseMoveEvent.endPosition);
+ if (position == null) {
+ return;
+ }
+ ((ConstantPositionProperty) currentPoint.position).setValue(position);
+ shapePoints.remove(shapePoints.size() - 1);
+ shapePoints.add(position);
+ }
+ }, ScreenSpaceEventType.MOUSE_MOVE());
+ handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
+ @Override
+ public void function(Object event) {
+ terminateShape();
+ }
+ }, ScreenSpaceEventType.LEFT_DOUBLE_CLICK());
+
+ ListBox shapesLBox = new ListBox();
+ shapesLBox.addItem("Lines", "0");
+ shapesLBox.addItem("Polygons", "1");
+ shapesLBox.addChangeHandler(new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent event) {
+ ListBox source = (ListBox) event.getSource();
+ if (source.getSelectedValue().equalsIgnoreCase("0")) {
+ shape = SHAPE.LINE;
+ } else if (source.getSelectedValue().equalsIgnoreCase("1")) {
+ shape = SHAPE.POLYGON;
+ }
+ terminateShape();
+ }
+ });
+
+ FlexTable flexTable = new FlexTable();
+ flexTable.setHTML(1, 0, "Draw");
+ flexTable.setWidget(1, 1, shapesLBox);
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(flexTable, 20, 20);
+
+ contentPanel.add(new HTML(
+ "Draw lines and polygons on terrain with mouse clicks.
Left click to add a vertex.
Double left click to start new shape.
"));
+ contentPanel.add(aPanel);
+
+ csVPanel.getViewer().camera.lookAt(Cartesian3.fromDegrees(-122.2058, 46.1955, 1000.0),
+ new Cartesian3(5000.0, 5000.0, 5000.0));
+ csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
+
+ initWidget(contentPanel);
+ }
+
+ private Entity createPoint(Cartesian3 position) {
+ PointGraphicsOptions pointGraphicsOptions = new PointGraphicsOptions();
+ pointGraphicsOptions.color = new ConstantProperty<>(Color.RED());
+ pointGraphicsOptions.pixelSize = new ConstantProperty<>(5);
+ pointGraphicsOptions.heightReference = new ConstantProperty<>(HeightReference.CLAMP_TO_GROUND());
+
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(position);
+ entityOptions.point = new PointGraphics(pointGraphicsOptions);
+
+ return csVPanel.getViewer().entities().add(entityOptions);
+ }
+
+ private Entity drawShape(CallbackProperty callbackProperty) {
+ EntityOptions entityOptions = new EntityOptions();
+ if (shape == SHAPE.LINE) {
+ PolylineGraphicsOptions polylineGraphicsOptions = new PolylineGraphicsOptions();
+ polylineGraphicsOptions.positions = callbackProperty;
+ polylineGraphicsOptions.clampToGround = new ConstantProperty<>(true);
+ polylineGraphicsOptions.material = new ColorMaterialProperty(Color.RED().withAlpha(0.7f));
+ polylineGraphicsOptions.width = new ConstantProperty<>(3);
+
+ entityOptions.polyline = new PolylineGraphics(polylineGraphicsOptions);
+ } else if (shape == SHAPE.POLYGON) {
+ PolygonGraphicsOptions polygonGraphicsOptions = new PolygonGraphicsOptions();
+ polygonGraphicsOptions.hierarchy = callbackProperty;
+ polygonGraphicsOptions.material = new ColorMaterialProperty(Color.RED().withAlpha(0.7f));
+ entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
}
- Cartesian3 position = csVPanel.getViewer().scene().pickPosition(mouseMoveEvent.endPosition);
- if (position == null) {
- return;
+ return csVPanel.getViewer().entities().add(entityOptions);
+ }
+
+ private Entity drawShape(List positions) {
+ EntityOptions entityOptions = new EntityOptions();
+ if (shape == SHAPE.LINE) {
+ PolylineGraphicsOptions polylineGraphicsOptions = new PolylineGraphicsOptions();
+ polylineGraphicsOptions.positions = new ConstantProperty<>(positions.toArray(new Cartesian3[0]));
+ polylineGraphicsOptions.clampToGround = new ConstantProperty<>(true);
+ polylineGraphicsOptions.material = new ColorMaterialProperty(Color.RED().withAlpha(0.7f));
+ polylineGraphicsOptions.width = new ConstantProperty<>(3);
+
+ entityOptions.polyline = new PolylineGraphics(polylineGraphicsOptions);
+ } else if (shape == SHAPE.POLYGON) {
+ PolygonGraphicsOptions polygonGraphicsOptions = new PolygonGraphicsOptions();
+ polygonGraphicsOptions.hierarchy = new ConstantProperty<>(positions.toArray(new Cartesian3[0]));
+ polygonGraphicsOptions.material = new ColorMaterialProperty(Color.RED().withAlpha(0.7f));
+ entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
}
- ((ConstantPositionProperty) currentPoint.position).setValue(position);
+ return csVPanel.getViewer().entities().add(entityOptions);
+ }
+
+ private void terminateShape() {
shapePoints.remove(shapePoints.size() - 1);
- shapePoints.add(position);
- }
- }, ScreenSpaceEventType.MOUSE_MOVE());
- handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
- @Override
- public void function(Object event) {
- terminateShape();
- }
- }, ScreenSpaceEventType.LEFT_DOUBLE_CLICK());
-
- ListBox shapesLBox = new ListBox();
- shapesLBox.addItem("Lines", "0");
- shapesLBox.addItem("Polygons", "1");
- shapesLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent event) {
- ListBox source = (ListBox) event.getSource();
- if (source.getSelectedValue().equalsIgnoreCase("0")) {
- shape = SHAPE.LINE;
- } else if (source.getSelectedValue().equalsIgnoreCase("1")) {
- shape = SHAPE.POLYGON;
- }
- terminateShape();
- }
- });
-
- FlexTable flexTable = new FlexTable();
- flexTable.setHTML(1, 0, "Draw");
- flexTable.setWidget(1, 1, shapesLBox);
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(flexTable, 20, 20);
-
- contentPanel.add(new HTML(
- "Draw lines and polygons on terrain with mouse clicks.
Left click to add a vertex.
Double left click to start new shape.
"));
- contentPanel.add(aPanel);
-
- csVPanel.getViewer().camera.lookAt(Cartesian3.fromDegrees(-122.2058, 46.1955, 1000.0),
- new Cartesian3(5000.0, 5000.0, 5000.0));
- csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
-
- initWidget(contentPanel);
- }
-
- private Entity createPoint(Cartesian3 position) {
- PointGraphicsOptions pointGraphicsOptions = new PointGraphicsOptions();
- pointGraphicsOptions.color = new ConstantProperty<>(Color.RED());
- pointGraphicsOptions.pixelSize = new ConstantProperty<>(5);
- pointGraphicsOptions.heightReference = new ConstantProperty<>(HeightReference.CLAMP_TO_GROUND());
-
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(position);
- entityOptions.point = new PointGraphics(pointGraphicsOptions);
-
- return csVPanel.getViewer().entities().add(entityOptions);
- }
-
- private Entity drawShape(CallbackProperty callbackProperty) {
- EntityOptions entityOptions = new EntityOptions();
- if (shape == SHAPE.LINE) {
- PolylineGraphicsOptions polylineGraphicsOptions = new PolylineGraphicsOptions();
- polylineGraphicsOptions.positions = callbackProperty;
- polylineGraphicsOptions.clampToGround = new ConstantProperty<>(true);
- polylineGraphicsOptions.material = new ColorMaterialProperty(Color.RED().withAlpha(0.7f));
- polylineGraphicsOptions.width = new ConstantProperty<>(3);
-
- entityOptions.polyline = new PolylineGraphics(polylineGraphicsOptions);
- } else if (shape == SHAPE.POLYGON) {
- PolygonGraphicsOptions polygonGraphicsOptions = new PolygonGraphicsOptions();
- polygonGraphicsOptions.hierarchy = callbackProperty;
- polygonGraphicsOptions.material = new ColorMaterialProperty(Color.RED().withAlpha(0.7f));
- entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
+ drawShape(shapePoints);
+ csVPanel.getViewer().entities().remove(currentPoint);
+ csVPanel.getViewer().entities().remove(currentShape);
+ currentPoint = null;
+ currentShape = null;
+ shapePoints.clear();
}
- return csVPanel.getViewer().entities().add(entityOptions);
- }
-
- private Entity drawShape(List positions) {
- EntityOptions entityOptions = new EntityOptions();
- if (shape == SHAPE.LINE) {
- PolylineGraphicsOptions polylineGraphicsOptions = new PolylineGraphicsOptions();
- polylineGraphicsOptions.positions = new ConstantProperty<>(positions.toArray(new Cartesian3[0]));
- polylineGraphicsOptions.clampToGround = new ConstantProperty<>(true);
- polylineGraphicsOptions.material = new ColorMaterialProperty(Color.RED().withAlpha(0.7f));
- polylineGraphicsOptions.width = new ConstantProperty<>(3);
-
- entityOptions.polyline = new PolylineGraphics(polylineGraphicsOptions);
- } else if (shape == SHAPE.POLYGON) {
- PolygonGraphicsOptions polygonGraphicsOptions = new PolygonGraphicsOptions();
- polygonGraphicsOptions.hierarchy = new ConstantProperty<>(positions.toArray(new Cartesian3[0]));
- polygonGraphicsOptions.material = new ColorMaterialProperty(Color.RED().withAlpha(0.7f));
- entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "DrawingOnTerrain.txt";
+ return sourceCodeURLs;
+ }
+
+ private enum SHAPE {
+ LINE, POLYGON
}
- return csVPanel.getViewer().entities().add(entityOptions);
- }
-
- private void terminateShape() {
- shapePoints.remove(shapePoints.size() - 1);
- drawShape(shapePoints);
- csVPanel.getViewer().entities().remove(currentPoint);
- csVPanel.getViewer().entities().remove(currentShape);
- currentPoint = null;
- currentShape = null;
- shapePoints.clear();
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "DrawingOnTerrain.txt";
- return sourceCodeURLs;
- }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ElevationBandMaterial.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ElevationBandMaterial.java
index f00c0a6032186fb698222b88370570b976b97b02..86824481b4fe77e87c7adf26d2cfa57815a2b71f 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ElevationBandMaterial.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ElevationBandMaterial.java
@@ -59,7 +59,7 @@ public class ElevationBandMaterial extends AbstractExample {
public ElevationBandMaterial(ShowcaseExampleStore store) {
super("Elevation Band Material",
"Apply elevation band material to the globe",
- new String[] { "Showcase", "Cesium", "3d", "Viewer", "Elevation", "Band", "Material" }, store);
+ new String[]{"Showcase", "Cesium", "3d", "Viewer", "Elevation", "Band", "Material"}, store);
}
@Override
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ExportKML.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ExportKML.java
index 5532b5fd26c66d89d607c342daba71d3b04751e6..b3776bc43d2fba8deed373cd0514ebb8e5be9284 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ExportKML.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ExportKML.java
@@ -16,19 +16,12 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.user.client.ui.AbsolutePanel;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.FlexTable;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.ListBox;
-
+import com.google.gwt.user.client.ui.*;
import org.cesiumjs.cs.Cesium;
import org.cesiumjs.cs.core.JulianDate;
import org.cesiumjs.cs.core.Resource;
@@ -45,166 +38,168 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class ExportKML extends AbstractExample {
- private Viewer viewer;
- private Promise dataSourcePromise;
- private String filenameToSave;
-
- @Inject
- public ExportKML(ShowcaseExampleStore store) {
- super("Export KML", "How to export a subset of a CesiumJS scene as a KML/KMZ file.",
- new String[] { "Export", "KML" }, store);
- }
-
- @Override
- public void buildPanel() {
- // We fetch the resources that will be embedded in the KMZ file.
- final Promise daeModelPromise = Resource
- .fetchBlob(GWT.getModuleBaseURL() + "SampleData/models/CesiumMilkTruck/CesiumMilkTruck.dae");
- final Promise texturePromise = Resource
- .fetchBlob(GWT.getModuleBaseURL() + "SampleData/models/CesiumMilkTruck/CesiumMilkTruck.png");
-
- // This callback allows us to set the URL of the model to use
- // a COLLADA version of the model instead of the glTF version.
- // It also lets us specify the files that will be embedded in the exported KMZ.
- final Cesium.ExportKmlOptions.ModelCallback modelCallback = new Cesium.ExportKmlOptions.ModelCallback() {
- @Override
- public String Callback(ModelGraphics model, JulianDate time, JsObject externalFiles) {
- Resource resource = (Resource) model.uri.getValue(time);
-
- if (resource.url.indexOf("CesiumMilkTruck") != -1) {
- externalFiles.setProperty("model/CesiumMilkTruck.dae", daeModelPromise);
- externalFiles.setProperty("model/CesiumMilkTruck.png", texturePromise);
-
- return "model/CesiumMilkTruck.dae";
- }
+ private Viewer viewer;
+ private Promise dataSourcePromise;
+ private String filenameToSave;
+
+ @Inject
+ public ExportKML(ShowcaseExampleStore store) {
+ super("Export KML", "How to export a subset of a CesiumJS scene as a KML/KMZ file.",
+ new String[]{"Export", "KML"}, store);
+ }
+
+ @Override
+ public void buildPanel() {
+ // We fetch the resources that will be embedded in the KMZ file.
+ final Promise daeModelPromise = Resource
+ .fetchBlob(GWT.getModuleBaseURL() + "SampleData/models/CesiumMilkTruck/CesiumMilkTruck.dae");
+ final Promise texturePromise = Resource
+ .fetchBlob(GWT.getModuleBaseURL() + "SampleData/models/CesiumMilkTruck/CesiumMilkTruck.png");
+
+ // This callback allows us to set the URL of the model to use
+ // a COLLADA version of the model instead of the glTF version.
+ // It also lets us specify the files that will be embedded in the exported KMZ.
+ final Cesium.ExportKmlOptions.ModelCallback modelCallback = new Cesium.ExportKmlOptions.ModelCallback() {
+ @Override
+ public String Callback(ModelGraphics model, JulianDate time, JsObject externalFiles) {
+ Resource resource = (Resource) model.uri.getValue(time);
+
+ if (resource.url.indexOf("CesiumMilkTruck") != -1) {
+ externalFiles.setProperty("model/CesiumMilkTruck.dae", daeModelPromise);
+ externalFiles.setProperty("model/CesiumMilkTruck.png", texturePromise);
+
+ return "model/CesiumMilkTruck.dae";
+ }
- return "";
- }
- };
-
- final JsObject[] modelCzml = new JsObject[2];
- JsObject descriptionCzml = JsObject.create();
- descriptionCzml.setProperty("id", "document");
- descriptionCzml.setProperty("name", "CZML Model");
- descriptionCzml.setProperty("version", "1.0");
- modelCzml[0] = descriptionCzml;
-
- JsObject bodyCzml = JsObject.create();
- bodyCzml.setProperty("id", "aircraft model");
- bodyCzml.setProperty("name", "Cesium Air");
-
- JsObject positionCzml = JsObject.create();
- positionCzml.setProperty("cartographicDegrees", new double[] { -77, 37, 0 });
- bodyCzml.setProperty("position", positionCzml);
-
- JsObject gltfCzml = JsObject.create();
- gltfCzml.setProperty("gltf", GWT.getModuleBaseURL() + "SampleData/models/CesiumMilkTruck/CesiumMilkTruck.glb");
- bodyCzml.setProperty("model", gltfCzml);
- modelCzml[1] = bodyCzml;
-
- ViewerOptions viewerOptions = new ViewerOptions();
- viewerOptions.shouldAnimate = true;
-
- ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
- viewer = csVPanel.getViewer();
-
- ListBox sourceLBox = new ListBox();
- sourceLBox.addItem("Satellites", "0");
- sourceLBox.addItem("Model", "1");
- sourceLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent event) {
- ListBox source = (ListBox) event.getSource();
- reset();
- if (source.getSelectedValue().equalsIgnoreCase("0")) {
- filenameToSave = "Satellites.kmz";
- dataSourcePromise = CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/simple.czml");
- viewer.dataSources().add(dataSourcePromise);
-
- viewer.camera.flyHome(0);
- } else if (source.getSelectedValue().equalsIgnoreCase("1")) {
- filenameToSave = "Model.kmz";
- dataSourcePromise = CzmlDataSource.load(modelCzml);
- viewer.dataSources().add(dataSourcePromise).then(new Fulfill() {
+ return "";
+ }
+ };
+
+ final JsObject[] modelCzml = new JsObject[2];
+ JsObject descriptionCzml = JsObject.create();
+ descriptionCzml.setProperty("id", "document");
+ descriptionCzml.setProperty("name", "CZML Model");
+ descriptionCzml.setProperty("version", "1.0");
+ modelCzml[0] = descriptionCzml;
+
+ JsObject bodyCzml = JsObject.create();
+ bodyCzml.setProperty("id", "aircraft model");
+ bodyCzml.setProperty("name", "Cesium Air");
+
+ JsObject positionCzml = JsObject.create();
+ positionCzml.setProperty("cartographicDegrees", new double[]{-77, 37, 0});
+ bodyCzml.setProperty("position", positionCzml);
+
+ JsObject gltfCzml = JsObject.create();
+ gltfCzml.setProperty("gltf", GWT.getModuleBaseURL() + "SampleData/models/CesiumMilkTruck/CesiumMilkTruck.glb");
+ bodyCzml.setProperty("model", gltfCzml);
+ modelCzml[1] = bodyCzml;
+
+ ViewerOptions viewerOptions = new ViewerOptions();
+ viewerOptions.shouldAnimate = true;
+
+ ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
+ viewer = csVPanel.getViewer();
+
+ ListBox sourceLBox = new ListBox();
+ sourceLBox.addItem("Satellites", "0");
+ sourceLBox.addItem("Model", "1");
+ sourceLBox.addChangeHandler(new ChangeHandler() {
@Override
- public void onFulfilled(CzmlDataSource dataSource) {
- viewer.trackedEntity = dataSource.entities.getById("aircraft model");
+ public void onChange(ChangeEvent event) {
+ ListBox source = (ListBox) event.getSource();
+ reset();
+ if (source.getSelectedValue().equalsIgnoreCase("0")) {
+ filenameToSave = "Satellites.kmz";
+ dataSourcePromise = CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/simple.czml");
+ viewer.dataSources().add(dataSourcePromise);
+
+ viewer.camera.flyHome(0);
+ } else if (source.getSelectedValue().equalsIgnoreCase("1")) {
+ filenameToSave = "Model.kmz";
+ dataSourcePromise = CzmlDataSource.load(modelCzml);
+ viewer.dataSources().add(dataSourcePromise).then(new Fulfill() {
+ @Override
+ public void onFulfilled(CzmlDataSource dataSource) {
+ viewer.trackedEntity = dataSource.entities.getById("aircraft model");
+ }
+ });
+ }
+ }
+ });
+
+ Button downloadBtn = new Button("Download");
+ downloadBtn.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent clickEvent) {
+ dataSourcePromise.then(new Fulfill() {
+ @Override
+ public void onFulfilled(CzmlDataSource dataSource) {
+ Cesium.ExportKmlOptions options = Cesium.ExportKmlOptions.create(dataSource.entities);
+ options.kmz = true;
+ options.modelCallback = modelCallback;
+ Cesium.exportKml(options).then(new Fulfill() {
+ @Override
+ public void onFulfilled(JsObject value) {
+ downloadBlob(filenameToSave, (JsBlob) value.getObject("kmz"));
+ }
+ });
+ }
+ });
}
- });
- }
- }
- });
-
- Button downloadBtn = new Button("Download");
- downloadBtn.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent clickEvent) {
- dataSourcePromise.then(new Fulfill() {
- @Override
- public void onFulfilled(CzmlDataSource dataSource) {
- Cesium.ExportKmlOptions options = Cesium.ExportKmlOptions.create(dataSource.entities);
- options.kmz = true;
- options.modelCallback = modelCallback;
- Cesium.exportKml(options).then(new Fulfill() {
- @Override
- public void onFulfilled(JsObject value) {
- downloadBlob(filenameToSave, (JsBlob) value.getObject("kmz"));
- }
- });
- }
});
- }
- });
-
- FlexTable flexTable = new FlexTable();
- flexTable.setCellSpacing(1);
- flexTable.setCellPadding(1);
- flexTable.setWidget(0, 0, sourceLBox);
- flexTable.setWidget(1, 0, downloadBtn);
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(flexTable, 20, 20);
-
- contentPanel.add(new HTML("How to export a subset of a CesiumJS scene as a KML/KMZ file.
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
-
- // Initial
- filenameToSave = "Satellites.kmz";
- dataSourcePromise = CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/simple.czml");
- viewer.dataSources().add(dataSourcePromise);
-
- viewer.camera.flyHome(0);
- }
-
- private native void downloadBlob(String filename, JsBlob blob) /*-{
- if ($wnd.navigator.msSaveOrOpenBlob) {
- $wnd.navigator.msSaveBlob(blob, filename);
- } else {
- var elem = $wnd.document.createElement('a');
- elem.href = $wnd.URL.createObjectURL(blob);
- elem.download = filename;
- document.body.appendChild(elem);
- elem.click();
- document.body.removeChild(elem);
- }
- }-*/;
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ExportKML.txt";
- return sourceCodeURLs;
- }
-
- private void reset() {
- viewer.trackedEntity = (Entity) JsObject.undefined();
- viewer.dataSources().removeAll();
- }
+
+ FlexTable flexTable = new FlexTable();
+ flexTable.setCellSpacing(1);
+ flexTable.setCellPadding(1);
+ flexTable.setWidget(0, 0, sourceLBox);
+ flexTable.setWidget(1, 0, downloadBtn);
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(flexTable, 20, 20);
+
+ contentPanel.add(new HTML("How to export a subset of a CesiumJS scene as a KML/KMZ file.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
+
+ // Initial
+ filenameToSave = "Satellites.kmz";
+ dataSourcePromise = CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/simple.czml");
+ viewer.dataSources().add(dataSourcePromise);
+
+ viewer.camera.flyHome(0);
+ }
+
+ private native void downloadBlob(String filename, JsBlob blob) /*-{
+ if ($wnd.navigator.msSaveOrOpenBlob) {
+ $wnd.navigator.msSaveBlob(blob, filename);
+ } else {
+ var elem = $wnd.document.createElement('a');
+ elem.href = $wnd.URL.createObjectURL(blob);
+ elem.download = filename;
+ document.body.appendChild(elem);
+ elem.click();
+ document.body.removeChild(elem);
+ }
+ }-*/;
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ExportKML.txt";
+ return sourceCodeURLs;
+ }
+
+ private void reset() {
+ viewer.trackedEntity = (Entity) JsObject.undefined();
+ viewer.dataSources().removeAll();
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GeoJSONAndTopoJSON.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GeoJSONAndTopoJSON.java
index 9dc945b47c9500806e18557f4309735742f6be0b..c3eb03d09c8dbf8825e42f141cb4b7e6e4cfb1fc 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GeoJSONAndTopoJSON.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GeoJSONAndTopoJSON.java
@@ -16,24 +16,14 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import java.util.HashMap;
-
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.AbsolutePanel;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-
-import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.Color;
+import com.google.gwt.user.client.ui.*;
+import org.cesiumjs.cs.Cesium;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.core.Math;
-import org.cesiumjs.cs.core.Matrix4;
import org.cesiumjs.cs.core.options.ColorRandomOptions;
import org.cesiumjs.cs.datasources.Entity;
import org.cesiumjs.cs.datasources.GeoJsonDataSource;
@@ -48,120 +38,114 @@ import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+import java.util.HashMap;
+
/**
* @author Serge Silaev aka iSergio
*/
public class GeoJSONAndTopoJSON extends AbstractExample {
- private ViewerPanel csVPanel;
-
- @Inject
- public GeoJSONAndTopoJSON(ShowcaseExampleStore store) {
- super("GeoJSON and TopoJSON", "Load GeoJSON or TopoJSON data and apply custom styling",
- new String[] { "Showcase", "Cesium", "3d", "Viewer", "GeoJSON", "TopoJSON", "JSON", "Promise" }, store);
- }
-
- @Override
- public void buildPanel() {
- csVPanel = new ViewerPanel();
-
- csVPanel.getViewer().dataSources().removeAll();
- csVPanel.getViewer().camera.lookAt(Cartesian3.fromDegrees(-98.0, 40.0), new Cartesian3(0.0, -4790000.0, 3930000.0));
- csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
-
- Button defaultStylingBtn = new Button("Default styling");
- defaultStylingBtn.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent clickEvent) {
- reset();
- csVPanel.getViewer().dataSources()
- .add(GeoJsonDataSource.load(GWT.getModuleBaseURL() + "SampleData/ne_10m_us_states.topojson"));
- }
- });
-
- Button basicStylingBtn = new Button("Basic styling");
- basicStylingBtn.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent clickEvent) {
+ private ViewerPanel csVPanel;
+
+ @Inject
+ public GeoJSONAndTopoJSON(ShowcaseExampleStore store) {
+ super("GeoJSON and TopoJSON", "Load GeoJSON or TopoJSON data and apply custom styling",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer", "GeoJSON", "TopoJSON", "JSON", "Promise"}, store);
+ }
+
+ @Override
+ public void buildPanel() {
+ csVPanel = new ViewerPanel();
+
+ csVPanel.getViewer().dataSources().removeAll();
+ csVPanel.getViewer().camera.lookAt(Cartesian3.fromDegrees(-98.0, 40.0), new Cartesian3(0.0, -4790000.0, 3930000.0));
+ csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
+
+ Button defaultStylingBtn = new Button("Default styling");
+ defaultStylingBtn.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent clickEvent) {
+ reset();
+ csVPanel.getViewer().dataSources()
+ .add(GeoJsonDataSource.load(GWT.getModuleBaseURL() + "SampleData/ne_10m_us_states.topojson"));
+ }
+ });
+
+ Button basicStylingBtn = new Button("Basic styling");
+ basicStylingBtn.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent clickEvent) {
+ reset();
+ GeoJsonDataSourceOptions options = new GeoJsonDataSourceOptions();
+ options.stroke = Color.HOTPINK();
+ options.fill = Color.DEEPPINK().withAlpha(0.5f);
+ options.strokeWidth = 3;
+ csVPanel.getViewer().dataSources()
+ .add(GeoJsonDataSource.load(GWT.getModuleBaseURL() + "SampleData/ne_10m_us_states.topojson", options));
+ }
+ });
+
+ Button customStylingBtn = new Button("Custom styling");
+ customStylingBtn.addClickHandler(clickEvent -> {
+ Math.setRandomNumberSeed(0);
+
+ GeoJsonDataSource.load(GWT.getModuleBaseURL() + "SampleData/ne_10m_us_states.topojson")
+ .then(this::generateEntitys, error -> /*Window::alert not worked in lambda function*/Window.alert(error));
+ });
+
+ HorizontalPanel hPanel = new HorizontalPanel();
+ hPanel.setSpacing(5);
+ hPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+
+ hPanel.add(defaultStylingBtn);
+ hPanel.add(basicStylingBtn);
+ hPanel.add(customStylingBtn);
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(hPanel, 20, 20);
+
+ contentPanel.add(new HTML("Load GeoJSON or TopoJSON data and apply custom styling.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "GeoJSONAndTopoJSON.txt";
+ return sourceCodeURLs;
+ }
+
+ public void reset() {
+ csVPanel.getViewer().dataSources().removeAll();
+ csVPanel.getViewer().camera.lookAt(Cartesian3.fromDegrees(-98.0, 40.0), new Cartesian3(0.0, -4790000.0, 3930000.0));
+ csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
+ }
+
+ public void generateEntitys(GeoJsonDataSource dataSource) {
+ Window.alert("!!!!");
reset();
- GeoJsonDataSourceOptions options = new GeoJsonDataSourceOptions();
- options.stroke = Color.HOTPINK();
- options.fill = Color.DEEPPINK().withAlpha(0.5f);
- options.strokeWidth = 3;
- csVPanel.getViewer().dataSources()
- .add(GeoJsonDataSource.load(GWT.getModuleBaseURL() + "SampleData/ne_10m_us_states.topojson", options));
- }
- });
-
- Button customStylingBtn = new Button("Custom styling");
- customStylingBtn.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent clickEvent) {
- Math.setRandomNumberSeed(0);
-
- Promise promise = GeoJsonDataSource
- .load(GWT.getModuleBaseURL() + "SampleData/ne_10m_us_states.topojson");
- promise.then(new Fulfill() {
- @Override
- public void onFulfilled(GeoJsonDataSource dataSource) {
- reset();
- csVPanel.getViewer().dataSources().add(dataSource);
-
- Entity[] entities = dataSource.entities.values();
- HashMap colorHash = new HashMap<>();
- for (int i = 0; i < entities.length; i++) {
- Entity entity = entities[i];
- String name = entity.name;
- Color color = colorHash.get(name);
- if (color == null) {
+ csVPanel.getViewer().dataSources().add(dataSource);
+
+ Entity[] entities = dataSource.entities.values();
+ HashMap colorHash = new HashMap<>();
+ for (Entity entity : entities) {
+ String name = entity.name;
+ Color color = colorHash.get(name);
+ if (!Cesium.defined(color)) {
ColorRandomOptions options = new ColorRandomOptions();
options.alpha = 1.0f;
color = Color.fromRandom(options);
colorHash.put(name, color);
- }
-
- entity.polygon.material = new ColorMaterialProperty(new ConstantProperty<>(color));
- entity.polygon.outline = new ConstantProperty<>(false);
- entity.polygon.extrudedHeight = new ConstantProperty<>(
- JsObject.getObject(entity, "properties").getNumber("Population").doubleValue() / 50.);
}
- }
- }, new Reject() {
- @Override
- public void onRejected(String value) {
- Window.alert(value);
- }
- });
- }
- });
-
- HorizontalPanel hPanel = new HorizontalPanel();
- hPanel.setSpacing(5);
- hPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
-
- hPanel.add(defaultStylingBtn);
- hPanel.add(basicStylingBtn);
- hPanel.add(customStylingBtn);
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(hPanel, 20, 20);
-
- contentPanel.add(new HTML("Load GeoJSON or TopoJSON data and apply custom styling.
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "GeoJSONAndTopoJSON.txt";
- return sourceCodeURLs;
- }
-
- public void reset() {
- csVPanel.getViewer().dataSources().removeAll();
- csVPanel.getViewer().camera.lookAt(Cartesian3.fromDegrees(-98.0, 40.0), new Cartesian3(0.0, -4790000.0, 3930000.0));
- csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
- }
+
+ ConstantProperty populationProperty = (ConstantProperty) (Object) JsObject.getObject(entity.properties, "Population");
+
+ entity.polygon.material = new ColorMaterialProperty(new ConstantProperty<>(color));
+ entity.polygon.outline = new ConstantProperty<>(false);
+ entity.polygon.extrudedHeight = new ConstantProperty<>(populationProperty.getValue().intValue() / 50.);
+ }
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GeoJSONsimplestyle.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GeoJSONsimplestyle.java
index c022ad1b4694ad7e8173f46c2159314e356bbca5..053645f47f5888574e03440367a6c1fb511a95ff 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GeoJSONsimplestyle.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GeoJSONsimplestyle.java
@@ -16,11 +16,8 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.HTML;
-
import org.cesiumjs.cs.datasources.GeoJsonDataSource;
import org.cesiumjs.cs.promise.Fulfill;
import org.cesiumjs.cs.promise.Promise;
@@ -30,46 +27,48 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class GeoJSONsimplestyle extends AbstractExample {
- private ViewerPanel csVPanel;
+ private ViewerPanel csVPanel;
- @Inject
- public GeoJSONsimplestyle(ShowcaseExampleStore store) {
- super("GeoJSON simplestyle", "Load GeoJSON with simplestyle information",
- new String[] { "Showcase", "Cesium", "3d", "Viewer" }, store);
- }
+ @Inject
+ public GeoJSONsimplestyle(ShowcaseExampleStore store) {
+ super("GeoJSON simplestyle", "Load GeoJSON with simplestyle information",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer"}, store);
+ }
- @Override
- public void buildPanel() {
- ViewerOptions viewerOptions = new ViewerOptions();
- viewerOptions.sceneMode = SceneMode.SCENE2D();
- viewerOptions.timeline = false;
- viewerOptions.animation = false;
- csVPanel = new ViewerPanel(viewerOptions);
+ @Override
+ public void buildPanel() {
+ ViewerOptions viewerOptions = new ViewerOptions();
+ viewerOptions.sceneMode = SceneMode.SCENE2D();
+ viewerOptions.timeline = false;
+ viewerOptions.animation = false;
+ csVPanel = new ViewerPanel(viewerOptions);
- Promise dataSource = GeoJsonDataSource
- .load(GWT.getModuleBaseURL() + "SampleData/simplestyles.geojson");
- csVPanel.getViewer().dataSources().add(dataSource);
- dataSource.then(new Fulfill() {
- @Override
- public void onFulfilled(GeoJsonDataSource value) {
- csVPanel.getViewer().zoomTo(value);
- }
- });
+ Promise dataSource = GeoJsonDataSource
+ .load(GWT.getModuleBaseURL() + "SampleData/simplestyles.geojson");
+ csVPanel.getViewer().dataSources().add(dataSource);
+ dataSource.then(new Fulfill() {
+ @Override
+ public void onFulfilled(GeoJsonDataSource value) {
+ csVPanel.getViewer().zoomTo(value);
+ }
+ });
- contentPanel.add(new HTML("Load GeoJSON with simplestyle information.
"));
- contentPanel.add(csVPanel);
+ contentPanel.add(new HTML("Load GeoJSON with simplestyle information.
"));
+ contentPanel.add(csVPanel);
- initWidget(contentPanel);
- }
+ initWidget(contentPanel);
+ }
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "GeoJSONsimplestyle.txt";
- return sourceCodeURLs;
- }
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "GeoJSONsimplestyle.txt";
+ return sourceCodeURLs;
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GeometryAndAppearances.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GeometryAndAppearances.java
index 6fdb4a025f65074d91109b22f30e7fbf9470782e..edd3bf73fe04b86b452b138915add4cda5608dd6 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GeometryAndAppearances.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GeometryAndAppearances.java
@@ -16,49 +16,16 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.HTML;
-
-import org.cesiumjs.cs.core.Cartesian2;
-import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.Color;
import org.cesiumjs.cs.core.Math;
-import org.cesiumjs.cs.core.PolygonHierarchy;
-import org.cesiumjs.cs.core.Rectangle;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.core.options.ColorRandomOptions;
import org.cesiumjs.cs.datasources.Entity;
-import org.cesiumjs.cs.datasources.graphics.BoxGraphics;
-import org.cesiumjs.cs.datasources.graphics.CorridorGraphics;
-import org.cesiumjs.cs.datasources.graphics.CylinderGraphics;
-import org.cesiumjs.cs.datasources.graphics.EllipseGraphics;
-import org.cesiumjs.cs.datasources.graphics.EllipsoidGraphics;
-import org.cesiumjs.cs.datasources.graphics.PolygonGraphics;
-import org.cesiumjs.cs.datasources.graphics.PolylineGraphics;
-import org.cesiumjs.cs.datasources.graphics.PolylineVolumeGraphics;
-import org.cesiumjs.cs.datasources.graphics.RectangleGraphics;
-import org.cesiumjs.cs.datasources.graphics.WallGraphics;
-import org.cesiumjs.cs.datasources.graphics.options.BoxGraphicsOptions;
-import org.cesiumjs.cs.datasources.graphics.options.CorridorGraphicsOptions;
-import org.cesiumjs.cs.datasources.graphics.options.CylinderGraphicsOptions;
-import org.cesiumjs.cs.datasources.graphics.options.EllipseGraphicsOptions;
-import org.cesiumjs.cs.datasources.graphics.options.EllipsoidGraphicsOptions;
-import org.cesiumjs.cs.datasources.graphics.options.PolygonGraphicsOptions;
-import org.cesiumjs.cs.datasources.graphics.options.PolylineGraphicsOptions;
-import org.cesiumjs.cs.datasources.graphics.options.PolylineVolumeGraphicsOptions;
-import org.cesiumjs.cs.datasources.graphics.options.RectangleGraphicsOptions;
-import org.cesiumjs.cs.datasources.graphics.options.WallGraphicsOptions;
+import org.cesiumjs.cs.datasources.graphics.*;
+import org.cesiumjs.cs.datasources.graphics.options.*;
import org.cesiumjs.cs.datasources.options.EntityOptions;
-import org.cesiumjs.cs.datasources.properties.CheckerboardMaterialProperty;
-import org.cesiumjs.cs.datasources.properties.ColorMaterialProperty;
-import org.cesiumjs.cs.datasources.properties.ConstantPositionProperty;
-import org.cesiumjs.cs.datasources.properties.ConstantProperty;
-import org.cesiumjs.cs.datasources.properties.PolylineGlowMaterialProperty;
-import org.cesiumjs.cs.datasources.properties.StripeMaterialProperty;
+import org.cesiumjs.cs.datasources.properties.*;
import org.cesiumjs.cs.datasources.properties.options.CheckerboardMaterialPropertyOptions;
import org.cesiumjs.cs.datasources.properties.options.PolylineGlowMaterialPropertyOptions;
import org.cesiumjs.cs.datasources.properties.options.StripeMaterialPropertyOptions;
@@ -66,529 +33,533 @@ import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* @author Serge Silaev aka iSergio
*/
public class GeometryAndAppearances extends AbstractExample {
- private Cartesian2[] startPositions(int arms, double rOuter, double rInner) {
- double angle = Math.PI() / arms;
- List pos = new ArrayList<>();
- for (int i = 0; i < 2 * arms; i++) {
- double r = (i % 2) == 0 ? rOuter : rInner;
- Cartesian2 p = new Cartesian2(java.lang.Math.cos(i * angle) * r, java.lang.Math.sin(i * angle) * r);
- pos.add(p);
- }
- return pos.toArray(new Cartesian2[pos.size()]);
- }
-
- private Cartesian2[] computeCircle(double radius) {
- List pos = new ArrayList<>();
- for (int i = 0; i < 360; i++) {
- double radians = Math.toRadians(i);
- pos.add(new Cartesian2(radius * java.lang.Math.cos(radians), radius * java.lang.Math.sin(radians)));
- }
- return pos.toArray(new Cartesian2[pos.size()]);
- }
-
- @Inject
- public GeometryAndAppearances(ShowcaseExampleStore store) {
- super("Geometry and Appearances", "Demonstrates the wide variety of available geometry and appearances",
- new String[] { "Showcase", "cesium", "3d", "graphics", "materials" }, store);
- }
-
- @Override
- public void buildPanel() {
- Math.setRandomNumberSeed(1234);
-
- ViewerPanel csVPanel = new ViewerPanel();
-
- StripeMaterialPropertyOptions stripeMaterialPropertyOptions = new StripeMaterialPropertyOptions();
- stripeMaterialPropertyOptions.evenColor = new ConstantProperty<>(Color.WHITE().withAlpha(0.5f));
- stripeMaterialPropertyOptions.oddColor = new ConstantProperty<>(Color.BLUE().withAlpha(0.5f));
- stripeMaterialPropertyOptions.repeat = new ConstantProperty<>(5.0);
- StripeMaterialProperty stripeMaterialProperty = new StripeMaterialProperty(stripeMaterialPropertyOptions);
-
- RectangleGraphicsOptions rectangleGraphicsOptions = new RectangleGraphicsOptions();
- rectangleGraphicsOptions.coordinates = new ConstantProperty<>(Rectangle.fromDegrees(-92.0, 20.0, -86.0, 27.0));
- rectangleGraphicsOptions.outline = new ConstantProperty<>(true);
- rectangleGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
- rectangleGraphicsOptions.outlineWidth = new ConstantProperty<>(4);
- rectangleGraphicsOptions.stRotation = new ConstantProperty<>(Math.toRadians(45));
- rectangleGraphicsOptions.material = stripeMaterialProperty;
- RectangleGraphics rectangleGraphics = new RectangleGraphics(rectangleGraphicsOptions);
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.rectangle = rectangleGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- PolygonGraphicsOptions polygonGraphicsOptions = new PolygonGraphicsOptions();
- polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(Cartesian3
- .fromDegreesArray(new double[] { -107.0, 27.0, -107.0, 22.0, -102.0, 23.0, -97.0, 21.0, -97.0, 25.0 })));
- polygonGraphicsOptions.outline = new ConstantProperty<>(true);
- polygonGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
- polygonGraphicsOptions.outlineWidth = new ConstantProperty<>(4);
- polygonGraphicsOptions.material = stripeMaterialProperty;
- PolygonGraphics polygonGraphics = new PolygonGraphics(polygonGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.polygon = polygonGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- EllipseGraphicsOptions ellipseGraphicsOptions = new EllipseGraphicsOptions();
- ellipseGraphicsOptions.semiMinorAxis = new ConstantProperty<>(300000.0);
- ellipseGraphicsOptions.semiMajorAxis = new ConstantProperty<>(500000.0);
- ellipseGraphicsOptions.rotation = new ConstantProperty<>(Math.toRadians(-40.0));
- ellipseGraphicsOptions.outline = new ConstantProperty<>(true);
- ellipseGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
- ellipseGraphicsOptions.outlineWidth = new ConstantProperty<>(4);
- ellipseGraphicsOptions.stRotation = new ConstantProperty<>(Math.toRadians(22));
- ellipseGraphicsOptions.material = stripeMaterialProperty;
- EllipseGraphics ellipseGraphics = new EllipseGraphics(ellipseGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-80.0, 25.0));
- entityOptions.ellipse = ellipseGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- ellipseGraphicsOptions = new EllipseGraphicsOptions();
- ellipseGraphicsOptions.semiMinorAxis = new ConstantProperty<>(250000.0);
- ellipseGraphicsOptions.semiMajorAxis = new ConstantProperty<>(250000.0);
- ellipseGraphicsOptions.rotation = new ConstantProperty<>(Math.toRadians(-40.0));
- ellipseGraphicsOptions.outline = new ConstantProperty<>(true);
- ellipseGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
- ellipseGraphicsOptions.outlineWidth = new ConstantProperty<>(4);
- ellipseGraphicsOptions.stRotation = new ConstantProperty<>(Math.toRadians(90));
- ellipseGraphicsOptions.material = stripeMaterialProperty;
- ellipseGraphics = new EllipseGraphics(ellipseGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-72.0, 25.0));
- entityOptions.ellipse = ellipseGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- rectangleGraphicsOptions = new RectangleGraphicsOptions();
- rectangleGraphicsOptions.coordinates = new ConstantProperty<>(Rectangle.fromDegrees(-118.0, 38.0, -116.0, 40.0));
- rectangleGraphicsOptions.extrudedHeight = new ConstantProperty<>(500000.0);
- rectangleGraphicsOptions.outline = new ConstantProperty<>(true);
- rectangleGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
- rectangleGraphicsOptions.outlineWidth = new ConstantProperty<>(4);
- rectangleGraphicsOptions.stRotation = new ConstantProperty<>(Math.toRadians(45));
- ColorRandomOptions colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 1.0f;
- rectangleGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- rectangleGraphics = new RectangleGraphics(rectangleGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.rectangle = rectangleGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- ellipseGraphicsOptions = new EllipseGraphicsOptions();
- ellipseGraphicsOptions.semiMinorAxis = new ConstantProperty<>(100000.0);
- ellipseGraphicsOptions.semiMajorAxis = new ConstantProperty<>(200000.0);
- ellipseGraphicsOptions.height = new ConstantProperty<>(100000.0);
- ellipseGraphicsOptions.extrudedHeight = new ConstantProperty<>(200000.0);
- ellipseGraphicsOptions.rotation = new ConstantProperty<>(Math.toRadians(90.0));
- ellipseGraphicsOptions.outline = new ConstantProperty<>(true);
- ellipseGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
- ellipseGraphicsOptions.outlineWidth = new ConstantProperty<>(4);
- colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 1.0f;
- ellipseGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- ellipseGraphics = new EllipseGraphics(ellipseGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-117.0, 35.0));
- entityOptions.ellipse = ellipseGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- polygonGraphicsOptions = new PolygonGraphicsOptions();
- polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(
- Cartesian3.fromDegreesArray(new double[] { -118.0, 30.0, -115.0, 30.0, -117.1, 31.1, -118.0, 33.0 })));
- polygonGraphicsOptions.height = new ConstantProperty<>(300000.0);
- polygonGraphicsOptions.extrudedHeight = new ConstantProperty<>(700000.0);
- polygonGraphicsOptions.outline = new ConstantProperty<>(true);
- polygonGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
- polygonGraphicsOptions.outlineWidth = new ConstantProperty<>(4);
- colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 1.0f;
- polygonGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- polygonGraphics = new PolygonGraphics(polygonGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.polygon = polygonGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- CylinderGraphicsOptions cylinderGraphicsOptions = new CylinderGraphicsOptions();
- cylinderGraphicsOptions.length = new ConstantProperty<>(200000.0);
- cylinderGraphicsOptions.topRadius = new ConstantProperty<>(150000.0);
- cylinderGraphicsOptions.bottomRadius = new ConstantProperty<>(150000.0);
- cylinderGraphicsOptions.outline = new ConstantProperty<>(true);
- cylinderGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
- cylinderGraphicsOptions.outlineWidth = new ConstantProperty<>(4);
- colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 1.0f;
- cylinderGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- CylinderGraphics cylinderGraphics = new CylinderGraphics(cylinderGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-70.0, 45.0, 100000.0));
- entityOptions.cylinder = cylinderGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- for (int i = 0; i < 5; ++i) {
- double height = 100000.0 + (200000.0 * i);
- BoxGraphicsOptions boxGraphicsOptions = new BoxGraphicsOptions();
- boxGraphicsOptions.dimensions = new ConstantPositionProperty(new Cartesian3(90000.0, 90000.0, 90000.0));
- boxGraphicsOptions.outline = new ConstantProperty<>(true);
- boxGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
- colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 0.5f;
- boxGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- BoxGraphics boxGraphics = new BoxGraphics(boxGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-106.0, 45.0, height));
- entityOptions.box = boxGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- EllipsoidGraphicsOptions ellipsoidGraphicsOptions = new EllipsoidGraphicsOptions();
- ellipsoidGraphicsOptions.radii = new ConstantPositionProperty(new Cartesian3(45000.0, 45000.0, 90000.0));
- ellipsoidGraphicsOptions.outline = new ConstantProperty<>(true);
- ellipsoidGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
- ellipsoidGraphicsOptions.outlineWidth = new ConstantProperty<>(2);
- colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 0.5f;
- ellipsoidGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- EllipsoidGraphics ellipsoidGraphics = new EllipsoidGraphics(ellipsoidGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-102.0, 45.0, height));
- entityOptions.ellipsoid = ellipsoidGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- ellipsoidGraphicsOptions = new EllipsoidGraphicsOptions();
- ellipsoidGraphicsOptions.radii = new ConstantPositionProperty(new Cartesian3(67500.0, 67500.0, 67500.0));
- ellipsoidGraphicsOptions.outline = new ConstantProperty<>(true);
- ellipsoidGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
- ellipsoidGraphicsOptions.outlineWidth = new ConstantProperty<>(2);
- colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 0.5f;
- ellipsoidGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- ellipsoidGraphics = new EllipsoidGraphics(ellipsoidGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-98.0, 45.0, height));
- entityOptions.ellipsoid = ellipsoidGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ @Inject
+ public GeometryAndAppearances(ShowcaseExampleStore store) {
+ super("Geometry and Appearances", "Demonstrates the wide variety of available geometry and appearances",
+ new String[]{"Showcase", "cesium", "3d", "graphics", "materials"}, store);
}
- WallGraphicsOptions wallGraphicsOptions = new WallGraphicsOptions();
- wallGraphicsOptions.positions = new ConstantProperty<>(
- Cartesian3.fromDegreesArray(new double[] { -95.0, 50.0, -85.0, 50.0, -75.0, 50.0 }));
- wallGraphicsOptions.maximumHeights = new ConstantProperty<>(new double[] { 500000, 1000000, 500000 });
- wallGraphicsOptions.minimumHeights = new ConstantProperty<>(new double[] { 0, 500000, 0 });
- wallGraphicsOptions.outline = new ConstantProperty<>(true);
- wallGraphicsOptions.outlineColor = new ConstantProperty<>(Color.LIGHTGRAY());
- wallGraphicsOptions.outlineWidth = new ConstantProperty<>(4);
- colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 0.7f;
- wallGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- WallGraphics wallGraphics = new WallGraphics(wallGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.wall = wallGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- rectangleGraphicsOptions = new RectangleGraphicsOptions();
- rectangleGraphicsOptions.coordinates = new ConstantProperty<>(Rectangle.fromDegrees(-92.0, 30.0, -85.0, 40.0));
- rectangleGraphicsOptions.material = stripeMaterialProperty;
- entityOptions = new EntityOptions();
- entityOptions.rectangle = rectangleGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- polygonGraphicsOptions = new PolygonGraphicsOptions();
- PolygonHierarchy polygonHierarchy = new PolygonHierarchy(
- Cartesian3.fromDegreesArray(new double[] { -109.0, 30.0, -95.0, 30.0, -95.0, 40.0, -109.0, 40.0 }),
- new PolygonHierarchy[] { new PolygonHierarchy(
- Cartesian3.fromDegreesArray(new double[] { -107.0, 31.0, -107.0, 39.0, -97.0, 39.0, -97.0, 31.0 }),
- new PolygonHierarchy[] { new PolygonHierarchy(
- Cartesian3.fromDegreesArray(new double[] { -105.0, 33.0, -99.0, 33.0, -99.0, 37.0, -105.0, 37.0 }),
- new PolygonHierarchy[] { new PolygonHierarchy(Cartesian3.fromDegreesArray(
- new double[] { -103.0, 34.0, -101.0, 34.0, -101.0, 36.0, -103.0, 36.0 })) }) }) });
- polygonGraphicsOptions.hierarchy = new ConstantProperty<>(polygonHierarchy);
- polygonGraphicsOptions.material = stripeMaterialProperty;
- polygonGraphics = new PolygonGraphics(polygonGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.polygon = polygonGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- ellipseGraphicsOptions = new EllipseGraphicsOptions();
- ellipseGraphicsOptions.semiMinorAxis = new ConstantProperty<>(200000.0);
- ellipseGraphicsOptions.semiMajorAxis = new ConstantProperty<>(500000.0);
- ellipseGraphicsOptions.rotation = new ConstantProperty<>(Math.toRadians(30.0));
- ellipseGraphicsOptions.material = stripeMaterialProperty;
- ellipseGraphics = new EllipseGraphics(ellipseGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.ellipse = ellipseGraphics;
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-80.0, 35.0));
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- ellipseGraphicsOptions = new EllipseGraphicsOptions();
- ellipseGraphicsOptions.semiMinorAxis = new ConstantProperty<>(200000.0);
- ellipseGraphicsOptions.semiMajorAxis = new ConstantProperty<>(200000.0);
- ellipseGraphicsOptions.rotation = new ConstantProperty<>(Math.toRadians(30.0));
- ellipseGraphicsOptions.material = stripeMaterialProperty;
- ellipseGraphics = new EllipseGraphics(ellipseGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.ellipse = ellipseGraphics;
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-72.0, 35.0));
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- rectangleGraphicsOptions = new RectangleGraphicsOptions();
- rectangleGraphicsOptions.coordinates = new ConstantProperty<>(Rectangle.fromDegrees(-110.0, 38.0, -107.0, 40.0));
- rectangleGraphicsOptions.height = new ConstantProperty<>(700000.0);
- rectangleGraphicsOptions.extrudedHeight = new ConstantProperty<>(1000000.0);
- rectangleGraphicsOptions.rotation = new ConstantProperty<>(Math.toRadians(45));
- colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 1.0f;
- rectangleGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- rectangleGraphics = new RectangleGraphics(rectangleGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.rectangle = rectangleGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- ellipseGraphicsOptions = new EllipseGraphicsOptions();
- ellipseGraphicsOptions.semiMinorAxis = new ConstantProperty<>(100000.0);
- ellipseGraphicsOptions.semiMajorAxis = new ConstantProperty<>(200000.0);
- ellipseGraphicsOptions.height = new ConstantProperty<>(300000.0);
- ellipseGraphicsOptions.extrudedHeight = new ConstantProperty<>(700000.0);
- ellipseGraphicsOptions.rotation = new ConstantProperty<>(Math.toRadians(-40.0));
- colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 1.0f;
- ellipseGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- ellipseGraphics = new EllipseGraphics(ellipseGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.ellipse = ellipseGraphics;
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-110.0, 35.0));
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- polygonGraphicsOptions = new PolygonGraphicsOptions();
- polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(Cartesian3
- .fromDegreesArray(new double[] { -113.0, 30.0, -110.0, 30.0, -110.0, 33.0, -111.5, 31.0, -113.0, 33.0 })));
- polygonGraphicsOptions.extrudedHeight = new ConstantProperty<>(300000.0);
- colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 1.0f;
- polygonGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- polygonGraphics = new PolygonGraphics(polygonGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.polygon = polygonGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- cylinderGraphicsOptions = new CylinderGraphicsOptions();
- cylinderGraphicsOptions.length = new ConstantProperty<>(400000.0);
- cylinderGraphicsOptions.topRadius = new ConstantProperty<>(0.0);
- cylinderGraphicsOptions.bottomRadius = new ConstantProperty<>(200000.0);
- colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 1.0f;
- cylinderGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- cylinderGraphics = new CylinderGraphics(cylinderGraphicsOptions);
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-70.0, 40.0, 200000.0));
- entityOptions.cylinder = cylinderGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- for (int i = 0; i < 5; ++i) {
- double height = 200000.0 * i;
- ellipseGraphicsOptions = new EllipseGraphicsOptions();
- ellipseGraphicsOptions.semiMinorAxis = new ConstantProperty<>(200000.0);
- ellipseGraphicsOptions.semiMajorAxis = new ConstantProperty<>(200000.0);
- ellipseGraphicsOptions.height = new ConstantProperty<>(height);
- colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 0.5f;
- ellipseGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- ellipseGraphics = new EllipseGraphics(ellipseGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.ellipse = ellipseGraphics;
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-65.0, 35.0));
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- rectangleGraphicsOptions = new RectangleGraphicsOptions();
- rectangleGraphicsOptions.coordinates = new ConstantProperty<>(Rectangle.fromDegrees(-67.0, 27.0, -63.0, 32.0));
- rectangleGraphicsOptions.height = new ConstantProperty<>(height);
- colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 0.5f;
- rectangleGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- rectangleGraphics = new RectangleGraphics(rectangleGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.rectangle = rectangleGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ private Cartesian2[] startPositions(int arms, double rOuter, double rInner) {
+ double angle = Math.PI() / arms;
+ List pos = new ArrayList<>();
+ for (int i = 0; i < 2 * arms; i++) {
+ double r = (i % 2) == 0 ? rOuter : rInner;
+ Cartesian2 p = new Cartesian2(java.lang.Math.cos(i * angle) * r, java.lang.Math.sin(i * angle) * r);
+ pos.add(p);
+ }
+ return pos.toArray(new Cartesian2[pos.size()]);
}
- for (int i = 0; i < 5; ++i) {
- double height = 100000.0 + (200000.0 * i);
- BoxGraphicsOptions boxGraphicsOptions = new BoxGraphicsOptions();
- boxGraphicsOptions.dimensions = new ConstantProperty<>(new Cartesian3(90000.0, 90000.0, 90000.0));
- colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 1.0f;
- boxGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- BoxGraphics boxGraphics = new BoxGraphics(boxGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-108.0, 45.0, height));
- entityOptions.box = boxGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- EllipsoidGraphicsOptions ellipsoidGraphicsOptions = new EllipsoidGraphicsOptions();
- ellipsoidGraphicsOptions.radii = new ConstantPositionProperty(new Cartesian3(45000.0, 45000.0, 90000.0));
- colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 1.0f;
- ellipsoidGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- EllipsoidGraphics ellipsoidGraphics = new EllipsoidGraphics(ellipsoidGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-104.0, 45.0, height));
- entityOptions.ellipsoid = ellipsoidGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- ellipsoidGraphicsOptions = new EllipsoidGraphicsOptions();
- ellipsoidGraphicsOptions.radii = new ConstantPositionProperty(new Cartesian3(67500.0, 67500.0, 67500.0));
- colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 1.0f;
- ellipsoidGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- ellipsoidGraphics = new EllipsoidGraphics(ellipsoidGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-100.0, 45.0, height));
- entityOptions.ellipsoid = ellipsoidGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ private Cartesian2[] computeCircle(double radius) {
+ List pos = new ArrayList<>();
+ for (int i = 0; i < 360; i++) {
+ double radians = Math.toRadians(i);
+ pos.add(new Cartesian2(radius * java.lang.Math.cos(radians), radius * java.lang.Math.sin(radians)));
+ }
+ return pos.toArray(new Cartesian2[pos.size()]);
}
- Cartesian3[] positions = new Cartesian3[40];
- for (int i = 0; i < 40; ++i) {
- positions[i] = Cartesian3.fromDegrees(-100.0 + i, 15.0);
+ @Override
+ public void buildPanel() {
+ Math.setRandomNumberSeed(1234);
+
+ ViewerPanel csVPanel = new ViewerPanel();
+
+ StripeMaterialPropertyOptions stripeMaterialPropertyOptions = new StripeMaterialPropertyOptions();
+ stripeMaterialPropertyOptions.evenColor = new ConstantProperty<>(Color.WHITE().withAlpha(0.5f));
+ stripeMaterialPropertyOptions.oddColor = new ConstantProperty<>(Color.BLUE().withAlpha(0.5f));
+ stripeMaterialPropertyOptions.repeat = new ConstantProperty<>(5.0);
+ StripeMaterialProperty stripeMaterialProperty = new StripeMaterialProperty(stripeMaterialPropertyOptions);
+
+ RectangleGraphicsOptions rectangleGraphicsOptions = new RectangleGraphicsOptions();
+ rectangleGraphicsOptions.coordinates = new ConstantProperty<>(Rectangle.fromDegrees(-92.0, 20.0, -86.0, 27.0));
+ rectangleGraphicsOptions.outline = new ConstantProperty<>(true);
+ rectangleGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
+ rectangleGraphicsOptions.outlineWidth = new ConstantProperty<>(4);
+ rectangleGraphicsOptions.stRotation = new ConstantProperty<>(Math.toRadians(45));
+ rectangleGraphicsOptions.material = stripeMaterialProperty;
+ RectangleGraphics rectangleGraphics = new RectangleGraphics(rectangleGraphicsOptions);
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.rectangle = rectangleGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ PolygonGraphicsOptions polygonGraphicsOptions = new PolygonGraphicsOptions();
+ polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(Cartesian3
+ .fromDegreesArray(new double[]{-107.0, 27.0, -107.0, 22.0, -102.0, 23.0, -97.0, 21.0, -97.0, 25.0})));
+ polygonGraphicsOptions.outline = new ConstantProperty<>(true);
+ polygonGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
+ polygonGraphicsOptions.outlineWidth = new ConstantProperty<>(4);
+ polygonGraphicsOptions.material = stripeMaterialProperty;
+ PolygonGraphics polygonGraphics = new PolygonGraphics(polygonGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.polygon = polygonGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ EllipseGraphicsOptions ellipseGraphicsOptions = new EllipseGraphicsOptions();
+ ellipseGraphicsOptions.semiMinorAxis = new ConstantProperty<>(300000.0);
+ ellipseGraphicsOptions.semiMajorAxis = new ConstantProperty<>(500000.0);
+ ellipseGraphicsOptions.rotation = new ConstantProperty<>(Math.toRadians(-40.0));
+ ellipseGraphicsOptions.outline = new ConstantProperty<>(true);
+ ellipseGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
+ ellipseGraphicsOptions.outlineWidth = new ConstantProperty<>(4);
+ ellipseGraphicsOptions.stRotation = new ConstantProperty<>(Math.toRadians(22));
+ ellipseGraphicsOptions.material = stripeMaterialProperty;
+ EllipseGraphics ellipseGraphics = new EllipseGraphics(ellipseGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-80.0, 25.0));
+ entityOptions.ellipse = ellipseGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ ellipseGraphicsOptions = new EllipseGraphicsOptions();
+ ellipseGraphicsOptions.semiMinorAxis = new ConstantProperty<>(250000.0);
+ ellipseGraphicsOptions.semiMajorAxis = new ConstantProperty<>(250000.0);
+ ellipseGraphicsOptions.rotation = new ConstantProperty<>(Math.toRadians(-40.0));
+ ellipseGraphicsOptions.outline = new ConstantProperty<>(true);
+ ellipseGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
+ ellipseGraphicsOptions.outlineWidth = new ConstantProperty<>(4);
+ ellipseGraphicsOptions.stRotation = new ConstantProperty<>(Math.toRadians(90));
+ ellipseGraphicsOptions.material = stripeMaterialProperty;
+ ellipseGraphics = new EllipseGraphics(ellipseGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-72.0, 25.0));
+ entityOptions.ellipse = ellipseGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ rectangleGraphicsOptions = new RectangleGraphicsOptions();
+ rectangleGraphicsOptions.coordinates = new ConstantProperty<>(Rectangle.fromDegrees(-118.0, 38.0, -116.0, 40.0));
+ rectangleGraphicsOptions.extrudedHeight = new ConstantProperty<>(500000.0);
+ rectangleGraphicsOptions.outline = new ConstantProperty<>(true);
+ rectangleGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
+ rectangleGraphicsOptions.outlineWidth = new ConstantProperty<>(4);
+ rectangleGraphicsOptions.stRotation = new ConstantProperty<>(Math.toRadians(45));
+ ColorRandomOptions colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 1.0f;
+ rectangleGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ rectangleGraphics = new RectangleGraphics(rectangleGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.rectangle = rectangleGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ ellipseGraphicsOptions = new EllipseGraphicsOptions();
+ ellipseGraphicsOptions.semiMinorAxis = new ConstantProperty<>(100000.0);
+ ellipseGraphicsOptions.semiMajorAxis = new ConstantProperty<>(200000.0);
+ ellipseGraphicsOptions.height = new ConstantProperty<>(100000.0);
+ ellipseGraphicsOptions.extrudedHeight = new ConstantProperty<>(200000.0);
+ ellipseGraphicsOptions.rotation = new ConstantProperty<>(Math.toRadians(90.0));
+ ellipseGraphicsOptions.outline = new ConstantProperty<>(true);
+ ellipseGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
+ ellipseGraphicsOptions.outlineWidth = new ConstantProperty<>(4);
+ colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 1.0f;
+ ellipseGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ ellipseGraphics = new EllipseGraphics(ellipseGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-117.0, 35.0));
+ entityOptions.ellipse = ellipseGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ polygonGraphicsOptions = new PolygonGraphicsOptions();
+ polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(
+ Cartesian3.fromDegreesArray(new double[]{-118.0, 30.0, -115.0, 30.0, -117.1, 31.1, -118.0, 33.0})));
+ polygonGraphicsOptions.height = new ConstantProperty<>(300000.0);
+ polygonGraphicsOptions.extrudedHeight = new ConstantProperty<>(700000.0);
+ polygonGraphicsOptions.outline = new ConstantProperty<>(true);
+ polygonGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
+ polygonGraphicsOptions.outlineWidth = new ConstantProperty<>(4);
+ colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 1.0f;
+ polygonGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ polygonGraphics = new PolygonGraphics(polygonGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.polygon = polygonGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ CylinderGraphicsOptions cylinderGraphicsOptions = new CylinderGraphicsOptions();
+ cylinderGraphicsOptions.length = new ConstantProperty<>(200000.0);
+ cylinderGraphicsOptions.topRadius = new ConstantProperty<>(150000.0);
+ cylinderGraphicsOptions.bottomRadius = new ConstantProperty<>(150000.0);
+ cylinderGraphicsOptions.outline = new ConstantProperty<>(true);
+ cylinderGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
+ cylinderGraphicsOptions.outlineWidth = new ConstantProperty<>(4);
+ colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 1.0f;
+ cylinderGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ CylinderGraphics cylinderGraphics = new CylinderGraphics(cylinderGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-70.0, 45.0, 100000.0));
+ entityOptions.cylinder = cylinderGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ for (int i = 0; i < 5; ++i) {
+ double height = 100000.0 + (200000.0 * i);
+ BoxGraphicsOptions boxGraphicsOptions = new BoxGraphicsOptions();
+ boxGraphicsOptions.dimensions = new ConstantPositionProperty(new Cartesian3(90000.0, 90000.0, 90000.0));
+ boxGraphicsOptions.outline = new ConstantProperty<>(true);
+ boxGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
+ colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 0.5f;
+ boxGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ BoxGraphics boxGraphics = new BoxGraphics(boxGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-106.0, 45.0, height));
+ entityOptions.box = boxGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ EllipsoidGraphicsOptions ellipsoidGraphicsOptions = new EllipsoidGraphicsOptions();
+ ellipsoidGraphicsOptions.radii = new ConstantPositionProperty(new Cartesian3(45000.0, 45000.0, 90000.0));
+ ellipsoidGraphicsOptions.outline = new ConstantProperty<>(true);
+ ellipsoidGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
+ ellipsoidGraphicsOptions.outlineWidth = new ConstantProperty<>(2);
+ colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 0.5f;
+ ellipsoidGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ EllipsoidGraphics ellipsoidGraphics = new EllipsoidGraphics(ellipsoidGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-102.0, 45.0, height));
+ entityOptions.ellipsoid = ellipsoidGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ ellipsoidGraphicsOptions = new EllipsoidGraphicsOptions();
+ ellipsoidGraphicsOptions.radii = new ConstantPositionProperty(new Cartesian3(67500.0, 67500.0, 67500.0));
+ ellipsoidGraphicsOptions.outline = new ConstantProperty<>(true);
+ ellipsoidGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
+ ellipsoidGraphicsOptions.outlineWidth = new ConstantProperty<>(2);
+ colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 0.5f;
+ ellipsoidGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ ellipsoidGraphics = new EllipsoidGraphics(ellipsoidGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-98.0, 45.0, height));
+ entityOptions.ellipsoid = ellipsoidGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ }
+
+ WallGraphicsOptions wallGraphicsOptions = new WallGraphicsOptions();
+ wallGraphicsOptions.positions = new ConstantProperty<>(
+ Cartesian3.fromDegreesArray(new double[]{-95.0, 50.0, -85.0, 50.0, -75.0, 50.0}));
+ wallGraphicsOptions.maximumHeights = new ConstantProperty<>(new double[]{500000, 1000000, 500000});
+ wallGraphicsOptions.minimumHeights = new ConstantProperty<>(new double[]{0, 500000, 0});
+ wallGraphicsOptions.outline = new ConstantProperty<>(true);
+ wallGraphicsOptions.outlineColor = new ConstantProperty<>(Color.LIGHTGRAY());
+ wallGraphicsOptions.outlineWidth = new ConstantProperty<>(4);
+ colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 0.7f;
+ wallGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ WallGraphics wallGraphics = new WallGraphics(wallGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.wall = wallGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ rectangleGraphicsOptions = new RectangleGraphicsOptions();
+ rectangleGraphicsOptions.coordinates = new ConstantProperty<>(Rectangle.fromDegrees(-92.0, 30.0, -85.0, 40.0));
+ rectangleGraphicsOptions.material = stripeMaterialProperty;
+ entityOptions = new EntityOptions();
+ entityOptions.rectangle = rectangleGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ polygonGraphicsOptions = new PolygonGraphicsOptions();
+ PolygonHierarchy polygonHierarchy = new PolygonHierarchy(
+ Cartesian3.fromDegreesArray(new double[]{-109.0, 30.0, -95.0, 30.0, -95.0, 40.0, -109.0, 40.0}),
+ new PolygonHierarchy[]{new PolygonHierarchy(
+ Cartesian3.fromDegreesArray(new double[]{-107.0, 31.0, -107.0, 39.0, -97.0, 39.0, -97.0, 31.0}),
+ new PolygonHierarchy[]{new PolygonHierarchy(
+ Cartesian3.fromDegreesArray(new double[]{-105.0, 33.0, -99.0, 33.0, -99.0, 37.0, -105.0, 37.0}),
+ new PolygonHierarchy[]{new PolygonHierarchy(Cartesian3.fromDegreesArray(
+ new double[]{-103.0, 34.0, -101.0, 34.0, -101.0, 36.0, -103.0, 36.0}))})})});
+ polygonGraphicsOptions.hierarchy = new ConstantProperty<>(polygonHierarchy);
+ polygonGraphicsOptions.material = stripeMaterialProperty;
+ polygonGraphics = new PolygonGraphics(polygonGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.polygon = polygonGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ ellipseGraphicsOptions = new EllipseGraphicsOptions();
+ ellipseGraphicsOptions.semiMinorAxis = new ConstantProperty<>(200000.0);
+ ellipseGraphicsOptions.semiMajorAxis = new ConstantProperty<>(500000.0);
+ ellipseGraphicsOptions.rotation = new ConstantProperty<>(Math.toRadians(30.0));
+ ellipseGraphicsOptions.material = stripeMaterialProperty;
+ ellipseGraphics = new EllipseGraphics(ellipseGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.ellipse = ellipseGraphics;
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-80.0, 35.0));
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ ellipseGraphicsOptions = new EllipseGraphicsOptions();
+ ellipseGraphicsOptions.semiMinorAxis = new ConstantProperty<>(200000.0);
+ ellipseGraphicsOptions.semiMajorAxis = new ConstantProperty<>(200000.0);
+ ellipseGraphicsOptions.rotation = new ConstantProperty<>(Math.toRadians(30.0));
+ ellipseGraphicsOptions.material = stripeMaterialProperty;
+ ellipseGraphics = new EllipseGraphics(ellipseGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.ellipse = ellipseGraphics;
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-72.0, 35.0));
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ rectangleGraphicsOptions = new RectangleGraphicsOptions();
+ rectangleGraphicsOptions.coordinates = new ConstantProperty<>(Rectangle.fromDegrees(-110.0, 38.0, -107.0, 40.0));
+ rectangleGraphicsOptions.height = new ConstantProperty<>(700000.0);
+ rectangleGraphicsOptions.extrudedHeight = new ConstantProperty<>(1000000.0);
+ rectangleGraphicsOptions.rotation = new ConstantProperty<>(Math.toRadians(45));
+ colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 1.0f;
+ rectangleGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ rectangleGraphics = new RectangleGraphics(rectangleGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.rectangle = rectangleGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ ellipseGraphicsOptions = new EllipseGraphicsOptions();
+ ellipseGraphicsOptions.semiMinorAxis = new ConstantProperty<>(100000.0);
+ ellipseGraphicsOptions.semiMajorAxis = new ConstantProperty<>(200000.0);
+ ellipseGraphicsOptions.height = new ConstantProperty<>(300000.0);
+ ellipseGraphicsOptions.extrudedHeight = new ConstantProperty<>(700000.0);
+ ellipseGraphicsOptions.rotation = new ConstantProperty<>(Math.toRadians(-40.0));
+ colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 1.0f;
+ ellipseGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ ellipseGraphics = new EllipseGraphics(ellipseGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.ellipse = ellipseGraphics;
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-110.0, 35.0));
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ polygonGraphicsOptions = new PolygonGraphicsOptions();
+ polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(Cartesian3
+ .fromDegreesArray(new double[]{-113.0, 30.0, -110.0, 30.0, -110.0, 33.0, -111.5, 31.0, -113.0, 33.0})));
+ polygonGraphicsOptions.extrudedHeight = new ConstantProperty<>(300000.0);
+ colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 1.0f;
+ polygonGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ polygonGraphics = new PolygonGraphics(polygonGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.polygon = polygonGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ cylinderGraphicsOptions = new CylinderGraphicsOptions();
+ cylinderGraphicsOptions.length = new ConstantProperty<>(400000.0);
+ cylinderGraphicsOptions.topRadius = new ConstantProperty<>(0.0);
+ cylinderGraphicsOptions.bottomRadius = new ConstantProperty<>(200000.0);
+ colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 1.0f;
+ cylinderGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ cylinderGraphics = new CylinderGraphics(cylinderGraphicsOptions);
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-70.0, 40.0, 200000.0));
+ entityOptions.cylinder = cylinderGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ for (int i = 0; i < 5; ++i) {
+ double height = 200000.0 * i;
+ ellipseGraphicsOptions = new EllipseGraphicsOptions();
+ ellipseGraphicsOptions.semiMinorAxis = new ConstantProperty<>(200000.0);
+ ellipseGraphicsOptions.semiMajorAxis = new ConstantProperty<>(200000.0);
+ ellipseGraphicsOptions.height = new ConstantProperty<>(height);
+ colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 0.5f;
+ ellipseGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ ellipseGraphics = new EllipseGraphics(ellipseGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.ellipse = ellipseGraphics;
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-65.0, 35.0));
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ rectangleGraphicsOptions = new RectangleGraphicsOptions();
+ rectangleGraphicsOptions.coordinates = new ConstantProperty<>(Rectangle.fromDegrees(-67.0, 27.0, -63.0, 32.0));
+ rectangleGraphicsOptions.height = new ConstantProperty<>(height);
+ colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 0.5f;
+ rectangleGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ rectangleGraphics = new RectangleGraphics(rectangleGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.rectangle = rectangleGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ }
+
+ for (int i = 0; i < 5; ++i) {
+ double height = 100000.0 + (200000.0 * i);
+ BoxGraphicsOptions boxGraphicsOptions = new BoxGraphicsOptions();
+ boxGraphicsOptions.dimensions = new ConstantProperty<>(new Cartesian3(90000.0, 90000.0, 90000.0));
+ colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 1.0f;
+ boxGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ BoxGraphics boxGraphics = new BoxGraphics(boxGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-108.0, 45.0, height));
+ entityOptions.box = boxGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ EllipsoidGraphicsOptions ellipsoidGraphicsOptions = new EllipsoidGraphicsOptions();
+ ellipsoidGraphicsOptions.radii = new ConstantPositionProperty(new Cartesian3(45000.0, 45000.0, 90000.0));
+ colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 1.0f;
+ ellipsoidGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ EllipsoidGraphics ellipsoidGraphics = new EllipsoidGraphics(ellipsoidGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-104.0, 45.0, height));
+ entityOptions.ellipsoid = ellipsoidGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ ellipsoidGraphicsOptions = new EllipsoidGraphicsOptions();
+ ellipsoidGraphicsOptions.radii = new ConstantPositionProperty(new Cartesian3(67500.0, 67500.0, 67500.0));
+ colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 1.0f;
+ ellipsoidGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ ellipsoidGraphics = new EllipsoidGraphics(ellipsoidGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-100.0, 45.0, height));
+ entityOptions.ellipsoid = ellipsoidGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ }
+
+ Cartesian3[] positions = new Cartesian3[40];
+ for (int i = 0; i < 40; ++i) {
+ positions[i] = Cartesian3.fromDegrees(-100.0 + i, 15.0);
+ }
+ PolylineGraphicsOptions polylineGraphicsOptions = new PolylineGraphicsOptions();
+ polylineGraphicsOptions.positions = new ConstantProperty<>(positions);
+ polylineGraphicsOptions.width = new ConstantProperty<>(10.0);
+ PolylineGlowMaterialPropertyOptions polylineGlowMaterialPropertyOptions = new PolylineGlowMaterialPropertyOptions();
+ polylineGlowMaterialPropertyOptions.color = new ConstantProperty<>(Color.DEEPSKYBLUE());
+ polylineGlowMaterialPropertyOptions.glowPower = new ConstantProperty<>(0.25);
+ polylineGraphicsOptions.material = new PolylineGlowMaterialProperty(polylineGlowMaterialPropertyOptions);
+ PolylineGraphics polylineGraphics = new PolylineGraphics(polylineGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.polyline = polylineGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ positions = new Cartesian3[40];
+ for (int i = 0; i < 40; ++i) {
+ positions[i] = Cartesian3.fromDegrees(-100.0 + i, 9.0);
+ }
+ wallGraphicsOptions = new WallGraphicsOptions();
+ wallGraphicsOptions.positions = new ConstantProperty<>(Cartesian3.fromDegreesArrayHeights(new double[]{-90.0,
+ 43.0, 100000.0, -87.5, 45.0, 100000.0, -85.0, 43.0, 100000.0, -87.5, 41.0, 100000.0, -90.0, 43.0, 100000.0}));
+ CheckerboardMaterialPropertyOptions checkerboardMaterialPropertyOptions = new CheckerboardMaterialPropertyOptions();
+ checkerboardMaterialPropertyOptions.repeat = new ConstantProperty<>(new Cartesian2(20.0, 6.0));
+ wallGraphicsOptions.material = new CheckerboardMaterialProperty(checkerboardMaterialPropertyOptions);
+ wallGraphics = new WallGraphics(wallGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.wall = wallGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ CorridorGraphicsOptions corridorGraphicsOptions = new CorridorGraphicsOptions();
+ corridorGraphicsOptions.positions = new ConstantProperty<>(
+ Cartesian3.fromDegreesArray(new double[]{-120.0, 45.0, -125.0, 50.0, -125.0, 55.0}));
+ corridorGraphicsOptions.width = new ConstantProperty<>(100000);
+ colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 1.0f;
+ corridorGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ CorridorGraphics corridorGraphics = new CorridorGraphics(corridorGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.corridor = corridorGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ corridorGraphicsOptions = new CorridorGraphicsOptions();
+ corridorGraphicsOptions.positions = new ConstantProperty<>(
+ Cartesian3.fromDegreesArray(new double[]{-120.0, 45.0, -125.0, 50.0, -125.0, 55.0}));
+ corridorGraphicsOptions.width = new ConstantProperty<>(100000);
+ corridorGraphicsOptions.height = new ConstantProperty<>(300000);
+ corridorGraphicsOptions.extrudedHeight = new ConstantProperty<>(400000);
+ colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 0.7f;
+ corridorGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ corridorGraphics = new CorridorGraphics(corridorGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.corridor = corridorGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ corridorGraphicsOptions = new CorridorGraphicsOptions();
+ corridorGraphicsOptions.positions = new ConstantProperty<>(
+ Cartesian3.fromDegreesArray(new double[]{-120.0, 45.0, -125.0, 50.0, -125.0, 55.0}));
+ corridorGraphicsOptions.width = new ConstantProperty<>(100000);
+ corridorGraphicsOptions.height = new ConstantProperty<>(700000.0);
+ corridorGraphicsOptions.outline = new ConstantProperty<>(true);
+ corridorGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
+ corridorGraphicsOptions.outlineWidth = new ConstantProperty<>(4);
+ colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 0.7f;
+ corridorGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ corridorGraphics = new CorridorGraphics(corridorGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.corridor = corridorGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ PolylineVolumeGraphicsOptions polylineVolumeGraphicsOptions = new PolylineVolumeGraphicsOptions();
+ polylineVolumeGraphicsOptions.positions = new ConstantProperty<>(Cartesian3.fromDegreesArrayHeights(
+ new double[]{-102.0, 15.0, 100000.0, -105.0, 20.0, 200000.0, -110.0, 20.0, 100000.0}));
+ polylineVolumeGraphicsOptions.outline = new ConstantProperty<>(true);
+ polylineVolumeGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
+ polylineVolumeGraphicsOptions.outlineWidth = new ConstantProperty<>(1);
+ colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 1.0f;
+ polylineVolumeGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ polylineVolumeGraphicsOptions.shape = new ConstantProperty<>(startPositions(7, 30000.0, 20000.0));
+ PolylineVolumeGraphics polylineVolumeGraphics = new PolylineVolumeGraphics(polylineVolumeGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.polylineVolume = polylineVolumeGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ polylineVolumeGraphicsOptions = new PolylineVolumeGraphicsOptions();
+ polylineVolumeGraphicsOptions.positions = new ConstantProperty<>(
+ Cartesian3.fromDegreesArray(new double[]{-102.0, 15.0, -105.0, 20.0, -110.0, 20.0}));
+ colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 1.0f;
+ polylineVolumeGraphicsOptions.material = new ColorMaterialProperty(
+ new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
+ polylineVolumeGraphicsOptions.shape = new ConstantProperty<>(startPositions(7, 30000.0, 20000.0));
+ polylineVolumeGraphics = new PolylineVolumeGraphics(polylineVolumeGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.polylineVolume = polylineVolumeGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ polylineVolumeGraphicsOptions = new PolylineVolumeGraphicsOptions();
+ polylineVolumeGraphicsOptions.positions = new ConstantProperty<>(
+ Cartesian3.fromDegreesArray(new double[]{-104.0, 13.0, -107.0, 18.0, -112.0, 18.0}));
+ polylineVolumeGraphicsOptions.material = new ColorMaterialProperty(new ConstantProperty<>(Color.WHITE()));
+ polylineVolumeGraphicsOptions.shape = new ConstantProperty<>(computeCircle(40000));
+ polylineVolumeGraphics = new PolylineVolumeGraphics(polylineVolumeGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.polylineVolume = polylineVolumeGraphics;
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ contentPanel.add(new HTML("Demonstrates the wide variety of available geometry and appearances.
"));
+ contentPanel.add(csVPanel);
+
+ initWidget(contentPanel);
}
- PolylineGraphicsOptions polylineGraphicsOptions = new PolylineGraphicsOptions();
- polylineGraphicsOptions.positions = new ConstantProperty<>(positions);
- polylineGraphicsOptions.width = new ConstantProperty<>(10.0);
- PolylineGlowMaterialPropertyOptions polylineGlowMaterialPropertyOptions = new PolylineGlowMaterialPropertyOptions();
- polylineGlowMaterialPropertyOptions.color = new ConstantProperty<>(Color.DEEPSKYBLUE());
- polylineGlowMaterialPropertyOptions.glowPower = new ConstantProperty<>(0.25);
- polylineGraphicsOptions.material = new PolylineGlowMaterialProperty(polylineGlowMaterialPropertyOptions);
- PolylineGraphics polylineGraphics = new PolylineGraphics(polylineGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.polyline = polylineGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- positions = new Cartesian3[40];
- for (int i = 0; i < 40; ++i) {
- positions[i] = Cartesian3.fromDegrees(-100.0 + i, 9.0);
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "GeometryAndAppearances.txt";
+ return sourceCodeURLs;
}
- wallGraphicsOptions = new WallGraphicsOptions();
- wallGraphicsOptions.positions = new ConstantProperty<>(Cartesian3.fromDegreesArrayHeights(new double[] { -90.0,
- 43.0, 100000.0, -87.5, 45.0, 100000.0, -85.0, 43.0, 100000.0, -87.5, 41.0, 100000.0, -90.0, 43.0, 100000.0 }));
- CheckerboardMaterialPropertyOptions checkerboardMaterialPropertyOptions = new CheckerboardMaterialPropertyOptions();
- checkerboardMaterialPropertyOptions.repeat = new ConstantProperty<>(new Cartesian2(20.0, 6.0));
- wallGraphicsOptions.material = new CheckerboardMaterialProperty(checkerboardMaterialPropertyOptions);
- wallGraphics = new WallGraphics(wallGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.wall = wallGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- CorridorGraphicsOptions corridorGraphicsOptions = new CorridorGraphicsOptions();
- corridorGraphicsOptions.positions = new ConstantProperty<>(
- Cartesian3.fromDegreesArray(new double[] { -120.0, 45.0, -125.0, 50.0, -125.0, 55.0 }));
- corridorGraphicsOptions.width = new ConstantProperty<>(100000);
- colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 1.0f;
- corridorGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- CorridorGraphics corridorGraphics = new CorridorGraphics(corridorGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.corridor = corridorGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- corridorGraphicsOptions = new CorridorGraphicsOptions();
- corridorGraphicsOptions.positions = new ConstantProperty<>(
- Cartesian3.fromDegreesArray(new double[] { -120.0, 45.0, -125.0, 50.0, -125.0, 55.0 }));
- corridorGraphicsOptions.width = new ConstantProperty<>(100000);
- corridorGraphicsOptions.height = new ConstantProperty<>(300000);
- corridorGraphicsOptions.extrudedHeight = new ConstantProperty<>(400000);
- colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 0.7f;
- corridorGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- corridorGraphics = new CorridorGraphics(corridorGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.corridor = corridorGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- corridorGraphicsOptions = new CorridorGraphicsOptions();
- corridorGraphicsOptions.positions = new ConstantProperty<>(
- Cartesian3.fromDegreesArray(new double[] { -120.0, 45.0, -125.0, 50.0, -125.0, 55.0 }));
- corridorGraphicsOptions.width = new ConstantProperty<>(100000);
- corridorGraphicsOptions.height = new ConstantProperty<>(700000.0);
- corridorGraphicsOptions.outline = new ConstantProperty<>(true);
- corridorGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
- corridorGraphicsOptions.outlineWidth = new ConstantProperty<>(4);
- colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 0.7f;
- corridorGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- corridorGraphics = new CorridorGraphics(corridorGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.corridor = corridorGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- PolylineVolumeGraphicsOptions polylineVolumeGraphicsOptions = new PolylineVolumeGraphicsOptions();
- polylineVolumeGraphicsOptions.positions = new ConstantProperty<>(Cartesian3.fromDegreesArrayHeights(
- new double[] { -102.0, 15.0, 100000.0, -105.0, 20.0, 200000.0, -110.0, 20.0, 100000.0 }));
- polylineVolumeGraphicsOptions.outline = new ConstantProperty<>(true);
- polylineVolumeGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
- polylineVolumeGraphicsOptions.outlineWidth = new ConstantProperty<>(1);
- colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 1.0f;
- polylineVolumeGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- polylineVolumeGraphicsOptions.shape = new ConstantProperty<>(startPositions(7, 30000.0, 20000.0));
- PolylineVolumeGraphics polylineVolumeGraphics = new PolylineVolumeGraphics(polylineVolumeGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.polylineVolume = polylineVolumeGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- polylineVolumeGraphicsOptions = new PolylineVolumeGraphicsOptions();
- polylineVolumeGraphicsOptions.positions = new ConstantProperty<>(
- Cartesian3.fromDegreesArray(new double[] { -102.0, 15.0, -105.0, 20.0, -110.0, 20.0 }));
- colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 1.0f;
- polylineVolumeGraphicsOptions.material = new ColorMaterialProperty(
- new ConstantProperty<>(Color.fromRandom(colorRandomOptions)));
- polylineVolumeGraphicsOptions.shape = new ConstantProperty<>(startPositions(7, 30000.0, 20000.0));
- polylineVolumeGraphics = new PolylineVolumeGraphics(polylineVolumeGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.polylineVolume = polylineVolumeGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- polylineVolumeGraphicsOptions = new PolylineVolumeGraphicsOptions();
- polylineVolumeGraphicsOptions.positions = new ConstantProperty<>(
- Cartesian3.fromDegreesArray(new double[] { -104.0, 13.0, -107.0, 18.0, -112.0, 18.0 }));
- polylineVolumeGraphicsOptions.material = new ColorMaterialProperty(new ConstantProperty<>(Color.WHITE()));
- polylineVolumeGraphicsOptions.shape = new ConstantProperty<>(computeCircle(40000));
- polylineVolumeGraphics = new PolylineVolumeGraphics(polylineVolumeGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.polylineVolume = polylineVolumeGraphics;
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- contentPanel.add(new HTML("Demonstrates the wide variety of available geometry and appearances.
"));
- contentPanel.add(csVPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "GeometryAndAppearances.txt";
- return sourceCodeURLs;
- }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GeometryHeightReference.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GeometryHeightReference.java
index c3f710d09b30cd9f9aa0654a53a88ae49ca1a8b5..37fc821d4b5d0f9dd23d53e292283a0ee9cf5708 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GeometryHeightReference.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GeometryHeightReference.java
@@ -16,8 +16,6 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
@@ -25,13 +23,9 @@ import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.ListBox;
-
import org.cesiumjs.cs.Cesium;
-import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.Color;
-import org.cesiumjs.cs.core.HeadingPitchRange;
import org.cesiumjs.cs.core.Math;
-import org.cesiumjs.cs.core.Matrix4;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.core.options.ColorRandomOptions;
import org.cesiumjs.cs.core.providers.CesiumTerrainProvider;
import org.cesiumjs.cs.core.providers.EllipsoidTerrainProvider;
@@ -46,112 +40,113 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class GeometryHeightReference extends AbstractExample {
- private CesiumTerrainProvider cesiumTerrainProvider;
- private EllipsoidTerrainProvider ellipsoidTerrainProvider;
- private ViewerPanel csVPanel;
-
- double longitude = 6.850615989890521;
- double latitude = 45.89546589994886;
- double delta = 0.001;
-
- @Inject
- public GeometryHeightReference(ShowcaseExampleStore store) {
- super("Geometry Height Reference",
- "An example for how to use the GeometryHeightProperty to height reference a corridor, ellipse, polygon or rectangle.",
- new String[] { "GeometryHeightProperty", "corridor", "ellipse", "polygon", "rectangle" }, store);
- }
-
- @Override
- public void buildPanel() {
- cesiumTerrainProvider = Cesium.createWorldTerrain();
- ellipsoidTerrainProvider = new EllipsoidTerrainProvider();
-
- ViewerOptions viewerOptions = new ViewerOptions();
- viewerOptions.baseLayerPicker = false;
- viewerOptions.terrainProvider = cesiumTerrainProvider;
- csVPanel = new ViewerPanel(viewerOptions);
-
- csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;
-
- ListBox terrainLBox = new ListBox();
- terrainLBox.addItem("Disabled", "0");
- terrainLBox.addItem("Enabled", "1");
- terrainLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent event) {
- ListBox source = (ListBox) event.getSource();
- if (source.getSelectedValue().equalsIgnoreCase("0")) {
- csVPanel.getViewer().terrainProvider = ellipsoidTerrainProvider;
- } else if (source.getSelectedValue().equalsIgnoreCase("1")) {
- csVPanel.getViewer().terrainProvider = cesiumTerrainProvider;
- }
- }
- });
- terrainLBox.setSelectedIndex(1);
-
- FlexTable flexTable = new FlexTable();
- flexTable.setHTML(1, 0, "Terrain");
- flexTable.setWidget(1, 1, terrainLBox);
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(flexTable, 20, 20);
+ double longitude = 6.850615989890521;
+ double latitude = 45.89546589994886;
+ double delta = 0.001;
+ private CesiumTerrainProvider cesiumTerrainProvider;
+ private EllipsoidTerrainProvider ellipsoidTerrainProvider;
+ private ViewerPanel csVPanel;
+
+ @Inject
+ public GeometryHeightReference(ShowcaseExampleStore store) {
+ super("Geometry Height Reference",
+ "An example for how to use the GeometryHeightProperty to height reference a corridor, ellipse, polygon or rectangle.",
+ new String[]{"GeometryHeightProperty", "corridor", "ellipse", "polygon", "rectangle"}, store);
+ }
- contentPanel.add(new HTML(
- "An example for how to use the GeometryHeightProperty to height reference a corridor, ellipse, polygon or rectangle..
"));
- contentPanel.add(aPanel);
+ @Override
+ public void buildPanel() {
+ cesiumTerrainProvider = Cesium.createWorldTerrain();
+ ellipsoidTerrainProvider = new EllipsoidTerrainProvider();
+
+ ViewerOptions viewerOptions = new ViewerOptions();
+ viewerOptions.baseLayerPicker = false;
+ viewerOptions.terrainProvider = cesiumTerrainProvider;
+ csVPanel = new ViewerPanel(viewerOptions);
+
+ csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;
+
+ ListBox terrainLBox = new ListBox();
+ terrainLBox.addItem("Disabled", "0");
+ terrainLBox.addItem("Enabled", "1");
+ terrainLBox.addChangeHandler(new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent event) {
+ ListBox source = (ListBox) event.getSource();
+ if (source.getSelectedValue().equalsIgnoreCase("0")) {
+ csVPanel.getViewer().terrainProvider = ellipsoidTerrainProvider;
+ } else if (source.getSelectedValue().equalsIgnoreCase("1")) {
+ csVPanel.getViewer().terrainProvider = cesiumTerrainProvider;
+ }
+ }
+ });
+ terrainLBox.setSelectedIndex(1);
+
+ FlexTable flexTable = new FlexTable();
+ flexTable.setHTML(1, 0, "Terrain");
+ flexTable.setWidget(1, 1, terrainLBox);
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(flexTable, 20, 20);
+
+ contentPanel.add(new HTML(
+ "An example for how to use the GeometryHeightProperty to height reference a corridor, ellipse, polygon or rectangle..
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
+
+ // create 16 polygons that are side-by-side
+ for (int i = 0; i < 4; i++) {
+ for (int j = 0; j < 4; j++) {
+ addEntity(i, j);
+ }
+ }
- initWidget(contentPanel);
+ csVPanel.getViewer().camera.lookAt(Cartesian3.fromDegrees(longitude, latitude, 500),
+ new HeadingPitchRange(Math.PI(), -Math.PI_OVER_FOUR(), 2000));
+ csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());// Sandcastle_End
+ }
- // create 16 polygons that are side-by-side
- for (int i = 0; i < 4; i++) {
- for (int j = 0; j < 4; j++) {
- addEntity(i, j);
- }
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "GeometryHeightReference.txt";
+ return sourceCodeURLs;
}
- csVPanel.getViewer().camera.lookAt(Cartesian3.fromDegrees(longitude, latitude, 500),
- new HeadingPitchRange(Math.PI(), -Math.PI_OVER_FOUR(), 2000));
- csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());// Sandcastle_End
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "GeometryHeightReference.txt";
- return sourceCodeURLs;
- }
-
- private void addEntity(int i, int j) {
- double west = longitude + delta * i;
- double east = longitude + delta * i + delta;
-
- double south = latitude + delta * j;
- double north = latitude + delta * j + delta;
- Cartesian3 a = Cartesian3.fromDegrees(west, south);
- Cartesian3 b = Cartesian3.fromDegrees(west, north);
- Cartesian3 c = Cartesian3.fromDegrees(east, north);
- Cartesian3 d = Cartesian3.fromDegrees(east, south);
-
- Cartesian3[] positions = new Cartesian3[] { a, b, c, d };
-
- ColorRandomOptions colorRandomOptions = new ColorRandomOptions();
- colorRandomOptions.alpha = 1.0f;
-
- PolygonGraphicsOptions polygonGraphicsOptions = new PolygonGraphicsOptions();
- polygonGraphicsOptions.hierarchy = new ConstantProperty<>(positions);
- polygonGraphicsOptions.material = new ColorMaterialProperty(Color.fromRandom(colorRandomOptions));
- polygonGraphicsOptions.height = new ConstantProperty<>(40.0);
- polygonGraphicsOptions.heightReference = new ConstantProperty<>(HeightReference.RELATIVE_TO_GROUND());
- polygonGraphicsOptions.extrudedHeight = new ConstantProperty<>(0.0);
- polygonGraphicsOptions.extrudedHeightReference = new ConstantProperty<>(HeightReference.CLAMP_TO_GROUND());
-
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
- csVPanel.getViewer().entities().add(entityOptions);
- }
+ private void addEntity(int i, int j) {
+ double west = longitude + delta * i;
+ double east = longitude + delta * i + delta;
+
+ double south = latitude + delta * j;
+ double north = latitude + delta * j + delta;
+ Cartesian3 a = Cartesian3.fromDegrees(west, south);
+ Cartesian3 b = Cartesian3.fromDegrees(west, north);
+ Cartesian3 c = Cartesian3.fromDegrees(east, north);
+ Cartesian3 d = Cartesian3.fromDegrees(east, south);
+
+ Cartesian3[] positions = new Cartesian3[]{a, b, c, d};
+
+ ColorRandomOptions colorRandomOptions = new ColorRandomOptions();
+ colorRandomOptions.alpha = 1.0f;
+
+ PolygonGraphicsOptions polygonGraphicsOptions = new PolygonGraphicsOptions();
+ polygonGraphicsOptions.hierarchy = new ConstantProperty<>(positions);
+ polygonGraphicsOptions.material = new ColorMaterialProperty(Color.fromRandom(colorRandomOptions));
+ polygonGraphicsOptions.height = new ConstantProperty<>(40.0);
+ polygonGraphicsOptions.heightReference = new ConstantProperty<>(HeightReference.RELATIVE_TO_GROUND());
+ polygonGraphicsOptions.extrudedHeight = new ConstantProperty<>(0.0);
+ polygonGraphicsOptions.extrudedHeightReference = new ConstantProperty<>(HeightReference.CLAMP_TO_GROUND());
+
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
+ csVPanel.getViewer().entities().add(entityOptions);
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GoogleEarthEnterprise.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GoogleEarthEnterprise.java
index 11b4aa34c9f9add973ccfaa81ca9a5fc51a42864..a52c89a1afd14ce17b6151466ee9251fa4e033f0 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GoogleEarthEnterprise.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GoogleEarthEnterprise.java
@@ -16,11 +16,8 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.HTML;
-
import org.cesiumjs.cs.core.GoogleEarthEnterpriseMetadata;
import org.cesiumjs.cs.core.Rectangle;
import org.cesiumjs.cs.core.providers.GoogleEarthEnterpriseTerrainProvider;
@@ -31,42 +28,44 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class GoogleEarthEnterprise extends AbstractExample {
- @Inject
- public GoogleEarthEnterprise(ShowcaseExampleStore store) {
- super("Google Earth Enterprise", "Add imagery from a Web Map Service (WMS) server.",
- new String[] { "Showcase", "Cesium", "3d", "GoogleEarthEnterprise", "ImageryProvider" }, store);
- }
+ @Inject
+ public GoogleEarthEnterprise(ShowcaseExampleStore store) {
+ super("Google Earth Enterprise", "Add imagery from a Web Map Service (WMS) server.",
+ new String[]{"Showcase", "Cesium", "3d", "GoogleEarthEnterprise", "ImageryProvider"}, store);
+ }
- @Override
- public void buildPanel() {
- GoogleEarthEnterpriseMetadata geeMetadata = GoogleEarthEnterpriseMetadata
- .create("http://www.earthenterprise.org/3d");
+ @Override
+ public void buildPanel() {
+ GoogleEarthEnterpriseMetadata geeMetadata = GoogleEarthEnterpriseMetadata
+ .create("http://www.earthenterprise.org/3d");
- ViewerOptions options = new ViewerOptions();
- options.imageryProvider = GoogleEarthEnterpriseImageryProvider.create(geeMetadata);
- options.terrainProvider = GoogleEarthEnterpriseTerrainProvider.create(geeMetadata);
- options.baseLayerPicker = false;
- ViewerPanel csVPanel = new ViewerPanel(options);
+ ViewerOptions options = new ViewerOptions();
+ options.imageryProvider = GoogleEarthEnterpriseImageryProvider.create(geeMetadata);
+ options.terrainProvider = GoogleEarthEnterpriseTerrainProvider.create(geeMetadata);
+ options.baseLayerPicker = false;
+ ViewerPanel csVPanel = new ViewerPanel(options);
- ViewOptions viewOptions = new ViewOptions();
- viewOptions.destinationRec = Rectangle.fromDegrees(-123.0, 36.0, -121.7, 39.0);
- csVPanel.getViewer().camera.setView(viewOptions);
+ ViewOptions viewOptions = new ViewOptions();
+ viewOptions.destinationRec = Rectangle.fromDegrees(-123.0, 36.0, -121.7, 39.0);
+ csVPanel.getViewer().camera.setView(viewOptions);
- contentPanel.add(new HTML("Add imagery from a Web Map Service (WMS) server.
"));
- contentPanel.add(csVPanel);
+ contentPanel.add(new HTML("Add imagery from a Web Map Service (WMS) server.
"));
+ contentPanel.add(csVPanel);
- initWidget(contentPanel);
- }
+ initWidget(contentPanel);
+ }
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "GoogleEarthEnterprise.txt";
- return sourceCodeURLs;
- }
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "GoogleEarthEnterprise.txt";
+ return sourceCodeURLs;
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GroundAtmosphere.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GroundAtmosphere.java
index 78f5d35560c3e127dea76ca59c89b4d9a582d3d8..5ff28c3b31e97c257379ef72a03cb81fe7daa0c4 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GroundAtmosphere.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GroundAtmosphere.java
@@ -23,18 +23,8 @@ import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
-import com.google.gwt.user.client.ui.AbsolutePanel;
-import com.google.gwt.user.client.ui.CheckBox;
-import com.google.gwt.user.client.ui.FlexTable;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.HasVerticalAlignment;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.ListBox;
-import com.google.gwt.user.client.ui.PushButton;
-import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.*;
import com.google.inject.Inject;
-
import org.cesiumjs.cs.Cesium;
import org.cesiumjs.cs.core.providers.EllipsoidTerrainProvider;
import org.cesiumjs.cs.scene.Globe;
@@ -51,284 +41,284 @@ import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
* @author Serge Silaev aka iSergio
*/
public class GroundAtmosphere extends AbstractExample {
- private ViewerPanel csVPanel;
- private Scene scene;
- private Globe globe;
-
- private Slider lightingFadeOutDistanceSlider;
- private TextBox lightingFadeOutDistanceTBox;
-
- private Slider lightingFadeInDistanceSlider;
- private TextBox lightingFadeInDistanceTBox;
-
- private Slider nightFadeOutDistanceSlider;
- private TextBox nightFadeOutDistanceTBox;
-
- private Slider nightFadeInDistanceSlider;
- private TextBox nightFadeInDistanceTBox;
-
- private double lightingFadeOutDistance;
- private double lightingFadeInDistance;
- private double nightFadeOutDistance;
- private double nightFadeInDistance;
-
- @Inject
- public GroundAtmosphere(ShowcaseExampleStore store) {
- super("Ground Atmosphere", "Adjust hue, saturation, and brightness of the sky/atmosphere.",
- new String[] { "Atmosphere", "Sky", "hue", "saturation", "brightness" }, store);
- }
-
- @Override
- public void buildPanel() {
- ViewerOptions viewerOptions = new ViewerOptions();
- viewerOptions.sceneModePicker = false;
- csVPanel = new ViewerPanel(viewerOptions);
-
- scene = csVPanel.getViewer().scene();
- globe = scene.globe;
-
- lightingFadeOutDistance = globe.lightingFadeOutDistance;
- lightingFadeInDistance = globe.lightingFadeInDistance;
- nightFadeOutDistance = globe.nightFadeOutDistance;
- nightFadeInDistance = globe.nightFadeInDistance;
-
- HorizontalPanel lightingFadeOutDistanceHPanel = new HorizontalPanel();
- lightingFadeOutDistanceHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
- lightingFadeOutDistanceHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
- lightingFadeOutDistanceHPanel.setSpacing(10);
- lightingFadeOutDistanceSlider = new Slider("lightingFadeOutDistance", 1, 100, 10);
- lightingFadeOutDistanceSlider.setStep(1);
- lightingFadeOutDistanceSlider.setWidth("150px");
- lightingFadeOutDistanceSlider.addListener(new MSliderListener());
- lightingFadeOutDistanceTBox = new TextBox();
- lightingFadeOutDistanceTBox.addChangeHandler(new MChangeHandler());
- lightingFadeOutDistanceTBox.setText("" + 10 * 1e6);
- lightingFadeOutDistanceTBox.setSize("100px", "12px");
- lightingFadeOutDistanceHPanel.add(lightingFadeOutDistanceSlider);
- lightingFadeOutDistanceHPanel.add(lightingFadeOutDistanceTBox);
-
- HorizontalPanel lightingFadeInDistanceHPanel = new HorizontalPanel();
- lightingFadeInDistanceHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
- lightingFadeInDistanceHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
- lightingFadeInDistanceHPanel.setSpacing(10);
- lightingFadeInDistanceSlider = new Slider("lightingFadeInDistance", 1, 100, 20);
- lightingFadeInDistanceSlider.setStep(1);
- lightingFadeInDistanceSlider.setWidth("150px");
- lightingFadeInDistanceSlider.addListener(new MSliderListener());
- lightingFadeInDistanceTBox = new TextBox();
- lightingFadeInDistanceTBox.addChangeHandler(new MChangeHandler());
- lightingFadeInDistanceTBox.setText("" + 20 * 1e6);
- lightingFadeInDistanceTBox.setSize("100px", "12px");
- lightingFadeInDistanceHPanel.add(lightingFadeInDistanceSlider);
- lightingFadeInDistanceHPanel.add(lightingFadeInDistanceTBox);
-
- HorizontalPanel nightFadeOutDistanceHPanel = new HorizontalPanel();
- nightFadeOutDistanceHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
- nightFadeOutDistanceHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
- nightFadeOutDistanceHPanel.setSpacing(10);
- nightFadeOutDistanceSlider = new Slider("nightFadeOutDistance", 1, 100, 10);
- nightFadeOutDistanceSlider.setStep(1);
- nightFadeOutDistanceSlider.setWidth("150px");
- nightFadeOutDistanceSlider.addListener(new MSliderListener());
- nightFadeOutDistanceTBox = new TextBox();
- nightFadeOutDistanceTBox.addChangeHandler(new MChangeHandler());
- nightFadeOutDistanceTBox.setText("" + 10 * 1e6);
- nightFadeOutDistanceTBox.setSize("100px", "12px");
- nightFadeOutDistanceHPanel.add(nightFadeOutDistanceSlider);
- nightFadeOutDistanceHPanel.add(nightFadeOutDistanceTBox);
-
- HorizontalPanel nightFadeInDistanceHPanel = new HorizontalPanel();
- nightFadeInDistanceHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
- nightFadeInDistanceHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
- nightFadeInDistanceHPanel.setSpacing(10);
- nightFadeInDistanceSlider = new Slider("nightFadeInDistance", 1, 100, 50);
- nightFadeInDistanceSlider.setStep(1);
- nightFadeInDistanceSlider.setWidth("150px");
- nightFadeInDistanceSlider.addListener(new MSliderListener());
- nightFadeInDistanceTBox = new TextBox();
- nightFadeInDistanceTBox.addChangeHandler(new MChangeHandler());
- nightFadeInDistanceTBox.setText("" + 50 * 1e6);
- nightFadeInDistanceTBox.setSize("100px", "12px");
- nightFadeInDistanceHPanel.add(nightFadeInDistanceSlider);
- nightFadeInDistanceHPanel.add(nightFadeInDistanceTBox);
-
- CheckBox groundAtmosphereCBox = new CheckBox();
- groundAtmosphereCBox.setWidth("100px");
- groundAtmosphereCBox.setValue(true);
- groundAtmosphereCBox.addValueChangeHandler(new ValueChangeHandler() {
- @Override
- public void onValueChange(ValueChangeEvent event) {
- globe.showGroundAtmosphere = event.getValue();
- }
- });
-
- CheckBox lightingBox = new CheckBox();
- lightingBox.setWidth("100px");
- lightingBox.setValue(false);
- lightingBox.addValueChangeHandler(new ValueChangeHandler() {
- @Override
- public void onValueChange(ValueChangeEvent event) {
- globe.enableLighting = event.getValue();
- }
- });
-
- ListBox terrainsLBox = new ListBox();
- terrainsLBox.setWidth("160px");
- terrainsLBox.addItem("Cesium World Terrain - no effects", "0");
- terrainsLBox.addItem("Cesium World Terrain w/ Vertex Normals", "1");
- terrainsLBox.addItem("Cesium World Terrain w/ Water", "2");
- terrainsLBox.addItem("Cesium World Terrain w/ Vertex Normals and Water", "3");
- terrainsLBox.addItem("EllipsoidTerrainProvider", "4");
- terrainsLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent changeEvent) {
- ListBox source = (ListBox) changeEvent.getSource();
- switch (source.getSelectedValue()) {
- case "0": {
- csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain();
- }
- break;
- case "1": {
- Cesium.CreateWorldTerrainOptions options = new Cesium.CreateWorldTerrainOptions();
- options.requestVertexNormals = true;
- csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain(options);
- }
- break;
- case "2": {
- Cesium.CreateWorldTerrainOptions options = new Cesium.CreateWorldTerrainOptions();
- options.requestWaterMask = true;
- csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain(options);
- }
- break;
- case "3": {
- Cesium.CreateWorldTerrainOptions options = new Cesium.CreateWorldTerrainOptions();
- options.requestVertexNormals = true;
- options.requestWaterMask = true;
- csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain(options);
- }
- break;
- case "4": {
- csVPanel.getViewer().terrainProvider = new EllipsoidTerrainProvider();
- }
- break;
- default:
- break;
- }
- }
- });
-
- PushButton resetFadeDistancesPBtn = new PushButton();
- resetFadeDistancesPBtn.setText("Reset Fade Distances");
- resetFadeDistancesPBtn.setWidth("160px");
- resetFadeDistancesPBtn.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent clickEvent) {
- globe.lightingFadeOutDistance = lightingFadeOutDistance;
- globe.lightingFadeInDistance = lightingFadeInDistance;
- globe.nightFadeOutDistance = nightFadeOutDistance;
- globe.nightFadeInDistance = nightFadeInDistance;
-
- lightingFadeOutDistanceSlider.setValue((int) (lightingFadeOutDistance / 1e6));
- lightingFadeInDistanceSlider.setValue((int) (lightingFadeInDistance / 1e6));
- nightFadeOutDistanceSlider.setValue((int) (nightFadeOutDistance / 1e6));
- nightFadeInDistanceSlider.setValue((int) (nightFadeInDistance / 1e6));
-
- lightingFadeOutDistanceTBox.setValue(String.valueOf(lightingFadeOutDistance), true);
- lightingFadeInDistanceTBox.setValue(String.valueOf(lightingFadeInDistance), true);
- nightFadeOutDistanceTBox.setValue(String.valueOf(nightFadeOutDistance), true);
- nightFadeInDistanceTBox.setValue(String.valueOf(nightFadeInDistance), true);
- }
- });
-
- FlexTable flexTable = new FlexTable();
- flexTable.setHTML(1, 0, "Lighting Fade Out Distance");
- flexTable.setWidget(1, 1, lightingFadeOutDistanceHPanel);
- flexTable.setHTML(2, 0, "Lighting Fade In Distance");
- flexTable.setWidget(2, 1, lightingFadeInDistanceHPanel);
- flexTable.setHTML(3, 0, "Night Fade Out Distance");
- flexTable.setWidget(3, 1, nightFadeOutDistanceHPanel);
- flexTable.setHTML(4, 0, "Night Fade In Distance");
- flexTable.setWidget(4, 1, nightFadeInDistanceHPanel);
- flexTable.setHTML(5, 0, "Ground atmosphere");
- flexTable.setWidget(5, 1, groundAtmosphereCBox);
- flexTable.setHTML(6, 0, "Lighting");
- flexTable.setWidget(6, 1, lightingBox);
- flexTable.setWidget(7, 1, terrainsLBox);
- flexTable.setWidget(8, 1, resetFadeDistancesPBtn);
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(flexTable, 20, 20);
-
- contentPanel.add(new HTML("Adjust hue, saturation, and brightness of the sky/atmosphere.
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "GroundAtmosphere.txt";
- return sourceCodeURLs;
- }
-
- private class MSliderListener implements SliderListener {
+ private ViewerPanel csVPanel;
+ private Scene scene;
+ private Globe globe;
- @Override
- public void onStart(SliderEvent e) {
+ private Slider lightingFadeOutDistanceSlider;
+ private TextBox lightingFadeOutDistanceTBox;
+
+ private Slider lightingFadeInDistanceSlider;
+ private TextBox lightingFadeInDistanceTBox;
+
+ private Slider nightFadeOutDistanceSlider;
+ private TextBox nightFadeOutDistanceTBox;
+
+ private Slider nightFadeInDistanceSlider;
+ private TextBox nightFadeInDistanceTBox;
+ private double lightingFadeOutDistance;
+ private double lightingFadeInDistance;
+ private double nightFadeOutDistance;
+ private double nightFadeInDistance;
+
+ @Inject
+ public GroundAtmosphere(ShowcaseExampleStore store) {
+ super("Ground Atmosphere", "Adjust hue, saturation, and brightness of the sky/atmosphere.",
+ new String[]{"Atmosphere", "Sky", "hue", "saturation", "brightness"}, store);
}
@Override
- public boolean onSlide(SliderEvent e) {
- Slider source = e.getSource();
- double value = source.getValue() * 1e6;
- if (source == lightingFadeOutDistanceSlider) {
- globe.lightingFadeOutDistance = value;
- lightingFadeOutDistanceTBox.setText("" + value);
- } else if (source == lightingFadeInDistanceSlider) {
- globe.lightingFadeInDistance = value;
- lightingFadeInDistanceTBox.setText("" + value);
- } else if (source == nightFadeOutDistanceSlider) {
- globe.nightFadeOutDistance = value;
- nightFadeOutDistanceTBox.setText("" + value);
- } else if (source == nightFadeInDistanceSlider) {
- globe.nightFadeInDistance = value;
- nightFadeInDistanceTBox.setText("" + value);
- }
- return true;
+ public void buildPanel() {
+ ViewerOptions viewerOptions = new ViewerOptions();
+ viewerOptions.sceneModePicker = false;
+ csVPanel = new ViewerPanel(viewerOptions);
+
+ scene = csVPanel.getViewer().scene();
+ globe = scene.globe;
+
+ lightingFadeOutDistance = globe.lightingFadeOutDistance;
+ lightingFadeInDistance = globe.lightingFadeInDistance;
+ nightFadeOutDistance = globe.nightFadeOutDistance;
+ nightFadeInDistance = globe.nightFadeInDistance;
+
+ HorizontalPanel lightingFadeOutDistanceHPanel = new HorizontalPanel();
+ lightingFadeOutDistanceHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+ lightingFadeOutDistanceHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+ lightingFadeOutDistanceHPanel.setSpacing(10);
+ lightingFadeOutDistanceSlider = new Slider("lightingFadeOutDistance", 1, 100, 10);
+ lightingFadeOutDistanceSlider.setStep(1);
+ lightingFadeOutDistanceSlider.setWidth("150px");
+ lightingFadeOutDistanceSlider.addListener(new MSliderListener());
+ lightingFadeOutDistanceTBox = new TextBox();
+ lightingFadeOutDistanceTBox.addChangeHandler(new MChangeHandler());
+ lightingFadeOutDistanceTBox.setText("" + 10 * 1e6);
+ lightingFadeOutDistanceTBox.setSize("100px", "12px");
+ lightingFadeOutDistanceHPanel.add(lightingFadeOutDistanceSlider);
+ lightingFadeOutDistanceHPanel.add(lightingFadeOutDistanceTBox);
+
+ HorizontalPanel lightingFadeInDistanceHPanel = new HorizontalPanel();
+ lightingFadeInDistanceHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+ lightingFadeInDistanceHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+ lightingFadeInDistanceHPanel.setSpacing(10);
+ lightingFadeInDistanceSlider = new Slider("lightingFadeInDistance", 1, 100, 20);
+ lightingFadeInDistanceSlider.setStep(1);
+ lightingFadeInDistanceSlider.setWidth("150px");
+ lightingFadeInDistanceSlider.addListener(new MSliderListener());
+ lightingFadeInDistanceTBox = new TextBox();
+ lightingFadeInDistanceTBox.addChangeHandler(new MChangeHandler());
+ lightingFadeInDistanceTBox.setText("" + 20 * 1e6);
+ lightingFadeInDistanceTBox.setSize("100px", "12px");
+ lightingFadeInDistanceHPanel.add(lightingFadeInDistanceSlider);
+ lightingFadeInDistanceHPanel.add(lightingFadeInDistanceTBox);
+
+ HorizontalPanel nightFadeOutDistanceHPanel = new HorizontalPanel();
+ nightFadeOutDistanceHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+ nightFadeOutDistanceHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+ nightFadeOutDistanceHPanel.setSpacing(10);
+ nightFadeOutDistanceSlider = new Slider("nightFadeOutDistance", 1, 100, 10);
+ nightFadeOutDistanceSlider.setStep(1);
+ nightFadeOutDistanceSlider.setWidth("150px");
+ nightFadeOutDistanceSlider.addListener(new MSliderListener());
+ nightFadeOutDistanceTBox = new TextBox();
+ nightFadeOutDistanceTBox.addChangeHandler(new MChangeHandler());
+ nightFadeOutDistanceTBox.setText("" + 10 * 1e6);
+ nightFadeOutDistanceTBox.setSize("100px", "12px");
+ nightFadeOutDistanceHPanel.add(nightFadeOutDistanceSlider);
+ nightFadeOutDistanceHPanel.add(nightFadeOutDistanceTBox);
+
+ HorizontalPanel nightFadeInDistanceHPanel = new HorizontalPanel();
+ nightFadeInDistanceHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+ nightFadeInDistanceHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+ nightFadeInDistanceHPanel.setSpacing(10);
+ nightFadeInDistanceSlider = new Slider("nightFadeInDistance", 1, 100, 50);
+ nightFadeInDistanceSlider.setStep(1);
+ nightFadeInDistanceSlider.setWidth("150px");
+ nightFadeInDistanceSlider.addListener(new MSliderListener());
+ nightFadeInDistanceTBox = new TextBox();
+ nightFadeInDistanceTBox.addChangeHandler(new MChangeHandler());
+ nightFadeInDistanceTBox.setText("" + 50 * 1e6);
+ nightFadeInDistanceTBox.setSize("100px", "12px");
+ nightFadeInDistanceHPanel.add(nightFadeInDistanceSlider);
+ nightFadeInDistanceHPanel.add(nightFadeInDistanceTBox);
+
+ CheckBox groundAtmosphereCBox = new CheckBox();
+ groundAtmosphereCBox.setWidth("100px");
+ groundAtmosphereCBox.setValue(true);
+ groundAtmosphereCBox.addValueChangeHandler(new ValueChangeHandler() {
+ @Override
+ public void onValueChange(ValueChangeEvent event) {
+ globe.showGroundAtmosphere = event.getValue();
+ }
+ });
+
+ CheckBox lightingBox = new CheckBox();
+ lightingBox.setWidth("100px");
+ lightingBox.setValue(false);
+ lightingBox.addValueChangeHandler(new ValueChangeHandler() {
+ @Override
+ public void onValueChange(ValueChangeEvent event) {
+ globe.enableLighting = event.getValue();
+ }
+ });
+
+ ListBox terrainsLBox = new ListBox();
+ terrainsLBox.setWidth("160px");
+ terrainsLBox.addItem("Cesium World Terrain - no effects", "0");
+ terrainsLBox.addItem("Cesium World Terrain w/ Vertex Normals", "1");
+ terrainsLBox.addItem("Cesium World Terrain w/ Water", "2");
+ terrainsLBox.addItem("Cesium World Terrain w/ Vertex Normals and Water", "3");
+ terrainsLBox.addItem("EllipsoidTerrainProvider", "4");
+ terrainsLBox.addChangeHandler(new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent changeEvent) {
+ ListBox source = (ListBox) changeEvent.getSource();
+ switch (source.getSelectedValue()) {
+ case "0": {
+ csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain();
+ }
+ break;
+ case "1": {
+ Cesium.CreateWorldTerrainOptions options = new Cesium.CreateWorldTerrainOptions();
+ options.requestVertexNormals = true;
+ csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain(options);
+ }
+ break;
+ case "2": {
+ Cesium.CreateWorldTerrainOptions options = new Cesium.CreateWorldTerrainOptions();
+ options.requestWaterMask = true;
+ csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain(options);
+ }
+ break;
+ case "3": {
+ Cesium.CreateWorldTerrainOptions options = new Cesium.CreateWorldTerrainOptions();
+ options.requestVertexNormals = true;
+ options.requestWaterMask = true;
+ csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain(options);
+ }
+ break;
+ case "4": {
+ csVPanel.getViewer().terrainProvider = new EllipsoidTerrainProvider();
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ });
+
+ PushButton resetFadeDistancesPBtn = new PushButton();
+ resetFadeDistancesPBtn.setText("Reset Fade Distances");
+ resetFadeDistancesPBtn.setWidth("160px");
+ resetFadeDistancesPBtn.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent clickEvent) {
+ globe.lightingFadeOutDistance = lightingFadeOutDistance;
+ globe.lightingFadeInDistance = lightingFadeInDistance;
+ globe.nightFadeOutDistance = nightFadeOutDistance;
+ globe.nightFadeInDistance = nightFadeInDistance;
+
+ lightingFadeOutDistanceSlider.setValue((int) (lightingFadeOutDistance / 1e6));
+ lightingFadeInDistanceSlider.setValue((int) (lightingFadeInDistance / 1e6));
+ nightFadeOutDistanceSlider.setValue((int) (nightFadeOutDistance / 1e6));
+ nightFadeInDistanceSlider.setValue((int) (nightFadeInDistance / 1e6));
+
+ lightingFadeOutDistanceTBox.setValue(String.valueOf(lightingFadeOutDistance), true);
+ lightingFadeInDistanceTBox.setValue(String.valueOf(lightingFadeInDistance), true);
+ nightFadeOutDistanceTBox.setValue(String.valueOf(nightFadeOutDistance), true);
+ nightFadeInDistanceTBox.setValue(String.valueOf(nightFadeInDistance), true);
+ }
+ });
+
+ FlexTable flexTable = new FlexTable();
+ flexTable.setHTML(1, 0, "Lighting Fade Out Distance");
+ flexTable.setWidget(1, 1, lightingFadeOutDistanceHPanel);
+ flexTable.setHTML(2, 0, "Lighting Fade In Distance");
+ flexTable.setWidget(2, 1, lightingFadeInDistanceHPanel);
+ flexTable.setHTML(3, 0, "Night Fade Out Distance");
+ flexTable.setWidget(3, 1, nightFadeOutDistanceHPanel);
+ flexTable.setHTML(4, 0, "Night Fade In Distance");
+ flexTable.setWidget(4, 1, nightFadeInDistanceHPanel);
+ flexTable.setHTML(5, 0, "Ground atmosphere");
+ flexTable.setWidget(5, 1, groundAtmosphereCBox);
+ flexTable.setHTML(6, 0, "Lighting");
+ flexTable.setWidget(6, 1, lightingBox);
+ flexTable.setWidget(7, 1, terrainsLBox);
+ flexTable.setWidget(8, 1, resetFadeDistancesPBtn);
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(flexTable, 20, 20);
+
+ contentPanel.add(new HTML("Adjust hue, saturation, and brightness of the sky/atmosphere.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
}
@Override
- public void onChange(SliderEvent e) {
-
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "GroundAtmosphere.txt";
+ return sourceCodeURLs;
}
- @Override
- public void onStop(SliderEvent e) {
+ private class MSliderListener implements SliderListener {
+ @Override
+ public void onStart(SliderEvent e) {
+
+ }
+
+ @Override
+ public boolean onSlide(SliderEvent e) {
+ Slider source = e.getSource();
+ double value = source.getValue() * 1e6;
+ if (source == lightingFadeOutDistanceSlider) {
+ globe.lightingFadeOutDistance = value;
+ lightingFadeOutDistanceTBox.setText("" + value);
+ } else if (source == lightingFadeInDistanceSlider) {
+ globe.lightingFadeInDistance = value;
+ lightingFadeInDistanceTBox.setText("" + value);
+ } else if (source == nightFadeOutDistanceSlider) {
+ globe.nightFadeOutDistance = value;
+ nightFadeOutDistanceTBox.setText("" + value);
+ } else if (source == nightFadeInDistanceSlider) {
+ globe.nightFadeInDistance = value;
+ nightFadeInDistanceTBox.setText("" + value);
+ }
+ return true;
+ }
+
+ @Override
+ public void onChange(SliderEvent e) {
+
+ }
+
+ @Override
+ public void onStop(SliderEvent e) {
+
+ }
}
- }
- private class MChangeHandler implements ChangeHandler {
- @Override
- public void onChange(ChangeEvent changeEvent) {
- TextBox source = (TextBox) changeEvent.getSource();
- double value = Double.parseDouble(source.getValue());
- if (source == lightingFadeOutDistanceTBox) {
- globe.lightingFadeOutDistance = value;
- lightingFadeOutDistanceSlider.setValue((int) (value / 1e6));
- } else if (source == lightingFadeInDistanceTBox) {
- globe.lightingFadeInDistance = value;
- lightingFadeInDistanceSlider.setValue((int) (value / 1e6));
- } else if (source == nightFadeOutDistanceTBox) {
- globe.nightFadeOutDistance = value;
- nightFadeOutDistanceSlider.setValue((int) (value / 1e6));
- } else if (source == nightFadeInDistanceTBox) {
- globe.nightFadeInDistance = value;
- nightFadeInDistanceSlider.setValue((int) (value / 1e6));
- }
+ private class MChangeHandler implements ChangeHandler {
+ @Override
+ public void onChange(ChangeEvent changeEvent) {
+ TextBox source = (TextBox) changeEvent.getSource();
+ double value = Double.parseDouble(source.getValue());
+ if (source == lightingFadeOutDistanceTBox) {
+ globe.lightingFadeOutDistance = value;
+ lightingFadeOutDistanceSlider.setValue((int) (value / 1e6));
+ } else if (source == lightingFadeInDistanceTBox) {
+ globe.lightingFadeInDistance = value;
+ lightingFadeInDistanceSlider.setValue((int) (value / 1e6));
+ } else if (source == nightFadeOutDistanceTBox) {
+ globe.nightFadeOutDistance = value;
+ nightFadeOutDistanceSlider.setValue((int) (value / 1e6));
+ } else if (source == nightFadeInDistanceTBox) {
+ globe.nightFadeInDistance = value;
+ nightFadeInDistanceSlider.setValue((int) (value / 1e6));
+ }
+ }
}
- }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GroundPolylinePrimitive.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GroundPolylinePrimitive.java
index 755b25937a359a27a0fad1c0081df19406ebd93e..4ee6b49cfe3a6de73eb25e417c538fe19efa02eb 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GroundPolylinePrimitive.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GroundPolylinePrimitive.java
@@ -1,15 +1,9 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.HTML;
-
-import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.Color;
-import org.cesiumjs.cs.core.ColorGeometryInstanceAttribute;
-import org.cesiumjs.cs.core.DistanceDisplayConditionGeometryInstanceAttribute;
import org.cesiumjs.cs.core.Math;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.core.geometry.GeometryInstance;
import org.cesiumjs.cs.core.geometry.GroundPolylineGeometry;
import org.cesiumjs.cs.core.geometry.options.GroundPolylineGeometryOptions;
@@ -25,81 +19,83 @@ import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class GroundPolylinePrimitive extends AbstractExample {
- @Inject
- public GroundPolylinePrimitive(ShowcaseExampleStore store) {
- super("GroundPolylinePrimitive", "Show how use GroundPolylinePrimitive's",
- new String[] { "ground", "polyline", "primitive" }, store);
- }
-
- @Override
- public void buildPanel() {
- ViewerPanel csVPanel = new ViewerPanel();
-
- contentPanel.add(new HTML("Show how use GroundPolylinePrimitive's.
"));
- contentPanel.add(csVPanel);
-
- Cartesian3[] positions = Cartesian3.fromDegreesArray(
- new double[] { -112.1340164450331, 36.05494287836128, -112.08821010582645, 36.097804071380715 });
- GroundPolylineGeometryOptions groundPolylineGeometryOptions = GroundPolylineGeometryOptions.create(positions);
- groundPolylineGeometryOptions.width = 4;
-
- GeometryInstanceOptions geometryInstanceOptions = new GeometryInstanceOptions();
- geometryInstanceOptions.geometry = new GroundPolylineGeometry(groundPolylineGeometryOptions);
- geometryInstanceOptions.id = "object returned when this instance is picked and to get/set per-instance attributes";
-
- PolylineMaterialAppearanceOptions appearanceOptions = new PolylineMaterialAppearanceOptions();
- appearanceOptions.material = Material.fromType("Color");
-
- GroundPolylinePrimitiveOptions primitiveOptions = new GroundPolylinePrimitiveOptions();
- primitiveOptions.geometryInstances = new GeometryInstance[] { new GeometryInstance(geometryInstanceOptions) };
- primitiveOptions.appearance = new PolylineMaterialAppearance(appearanceOptions);
-
- org.cesiumjs.cs.scene.GroundPolylinePrimitive groundPolylinePrimitive = new org.cesiumjs.cs.scene.GroundPolylinePrimitive(
- primitiveOptions);
-
- csVPanel.getViewer().scene().groundPrimitives().add(groundPolylinePrimitive);
-
- positions = Cartesian3.fromDegreesArray(new double[] { -112.1340164450331, 36.05494287836128, -112.08821010582645,
- 36.097804071380715, -112.13296079730024, 36.168769146801104 });
- groundPolylineGeometryOptions = GroundPolylineGeometryOptions.create(positions);
- groundPolylineGeometryOptions.width = 4;
- groundPolylineGeometryOptions.loop = true;
-
- JsObject attributes = JsObject.create();
- attributes.setProperty("color",
- ColorGeometryInstanceAttribute.fromColor(Color.fromCssColorString("green", new Color()).withAlpha(0.7f)));
- attributes.setProperty("distanceDisplayCondition",
- new DistanceDisplayConditionGeometryInstanceAttribute(1000, 30000));
-
- geometryInstanceOptions = new GeometryInstanceOptions();
- geometryInstanceOptions.geometry = new GroundPolylineGeometry(groundPolylineGeometryOptions);
- geometryInstanceOptions.attributes = attributes;
- geometryInstanceOptions.id = "object returned when this instance is picked and to get/set per-instance attributes";
-
- primitiveOptions = new GroundPolylinePrimitiveOptions();
- primitiveOptions.geometryInstances = new GeometryInstance[] { new GeometryInstance(geometryInstanceOptions) };
- primitiveOptions.appearance = new PolylineColorAppearance();
-
- groundPolylinePrimitive = new org.cesiumjs.cs.scene.GroundPolylinePrimitive(primitiveOptions);
- csVPanel.getViewer().scene().groundPrimitives().add(groundPolylinePrimitive);
-
- ViewOptions viewOptions = new ViewOptions();
- viewOptions.destinationPos = Cartesian3.fromDegrees(-112.08821010582645, 36.097804071380715, 1000.0);
- viewOptions.orientation = new org.cesiumjs.cs.core.HeadingPitchRoll(-Math.PI_OVER_TWO(), -Math.PI_OVER_FOUR(), 0.0);
- csVPanel.getViewer().camera.setView(viewOptions);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "GroundPolylinePrimitive.txt";
- return sourceCodeURLs;
- }
+ @Inject
+ public GroundPolylinePrimitive(ShowcaseExampleStore store) {
+ super("GroundPolylinePrimitive", "Show how use GroundPolylinePrimitive's",
+ new String[]{"ground", "polyline", "primitive"}, store);
+ }
+
+ @Override
+ public void buildPanel() {
+ ViewerPanel csVPanel = new ViewerPanel();
+
+ contentPanel.add(new HTML("Show how use GroundPolylinePrimitive's.
"));
+ contentPanel.add(csVPanel);
+
+ Cartesian3[] positions = Cartesian3.fromDegreesArray(
+ new double[]{-112.1340164450331, 36.05494287836128, -112.08821010582645, 36.097804071380715});
+ GroundPolylineGeometryOptions groundPolylineGeometryOptions = GroundPolylineGeometryOptions.create(positions);
+ groundPolylineGeometryOptions.width = 4;
+
+ GeometryInstanceOptions geometryInstanceOptions = new GeometryInstanceOptions();
+ geometryInstanceOptions.geometry = new GroundPolylineGeometry(groundPolylineGeometryOptions);
+ geometryInstanceOptions.id = "object returned when this instance is picked and to get/set per-instance attributes";
+
+ PolylineMaterialAppearanceOptions appearanceOptions = new PolylineMaterialAppearanceOptions();
+ appearanceOptions.material = Material.fromType("Color");
+
+ GroundPolylinePrimitiveOptions primitiveOptions = new GroundPolylinePrimitiveOptions();
+ primitiveOptions.geometryInstances = new GeometryInstance[]{new GeometryInstance(geometryInstanceOptions)};
+ primitiveOptions.appearance = new PolylineMaterialAppearance(appearanceOptions);
+
+ org.cesiumjs.cs.scene.GroundPolylinePrimitive groundPolylinePrimitive = new org.cesiumjs.cs.scene.GroundPolylinePrimitive(
+ primitiveOptions);
+
+ csVPanel.getViewer().scene().groundPrimitives().add(groundPolylinePrimitive);
+
+ positions = Cartesian3.fromDegreesArray(new double[]{-112.1340164450331, 36.05494287836128, -112.08821010582645,
+ 36.097804071380715, -112.13296079730024, 36.168769146801104});
+ groundPolylineGeometryOptions = GroundPolylineGeometryOptions.create(positions);
+ groundPolylineGeometryOptions.width = 4;
+ groundPolylineGeometryOptions.loop = true;
+
+ JsObject attributes = JsObject.create();
+ attributes.setProperty("color",
+ ColorGeometryInstanceAttribute.fromColor(Color.fromCssColorString("green", new Color()).withAlpha(0.7f)));
+ attributes.setProperty("distanceDisplayCondition",
+ new DistanceDisplayConditionGeometryInstanceAttribute(1000, 30000));
+
+ geometryInstanceOptions = new GeometryInstanceOptions();
+ geometryInstanceOptions.geometry = new GroundPolylineGeometry(groundPolylineGeometryOptions);
+ geometryInstanceOptions.attributes = attributes;
+ geometryInstanceOptions.id = "object returned when this instance is picked and to get/set per-instance attributes";
+
+ primitiveOptions = new GroundPolylinePrimitiveOptions();
+ primitiveOptions.geometryInstances = new GeometryInstance[]{new GeometryInstance(geometryInstanceOptions)};
+ primitiveOptions.appearance = new PolylineColorAppearance();
+
+ groundPolylinePrimitive = new org.cesiumjs.cs.scene.GroundPolylinePrimitive(primitiveOptions);
+ csVPanel.getViewer().scene().groundPrimitives().add(groundPolylinePrimitive);
+
+ ViewOptions viewOptions = new ViewOptions();
+ viewOptions.destinationPos = Cartesian3.fromDegrees(-112.08821010582645, 36.097804071380715, 1000.0);
+ viewOptions.orientation = new org.cesiumjs.cs.core.HeadingPitchRoll(-Math.PI_OVER_TWO(), -Math.PI_OVER_FOUR(), 0.0);
+ csVPanel.getViewer().camera.setView(viewOptions);
+
+ initWidget(contentPanel);
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "GroundPolylinePrimitive.txt";
+ return sourceCodeURLs;
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/HeadingPitchRoll.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/HeadingPitchRoll.java
index cabec4a5eb24434fa0b663e243bdf7a375c4b884..d49919fe6f7beeb15c1a9ff4e3b851601ca85aa8 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/HeadingPitchRoll.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/HeadingPitchRoll.java
@@ -16,30 +16,12 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import static java.lang.Math.max;
-import static java.lang.Math.min;
-
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.event.dom.client.KeyDownHandler;
-import com.google.gwt.user.client.ui.AbsolutePanel;
-import com.google.gwt.user.client.ui.CheckBox;
-import com.google.gwt.user.client.ui.FlexTable;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.Label;
-import com.google.gwt.user.client.ui.RootPanel;
-
-import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.Color;
-import org.cesiumjs.cs.core.Ellipsoid;
-import org.cesiumjs.cs.core.HeadingPitchRange;
-import org.cesiumjs.cs.core.JulianDate;
+import com.google.gwt.user.client.ui.*;
import org.cesiumjs.cs.core.Math;
-import org.cesiumjs.cs.core.Matrix4;
-import org.cesiumjs.cs.core.PerspectiveFrustum;
-import org.cesiumjs.cs.core.Transforms;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.datasources.Entity;
import org.cesiumjs.cs.datasources.graphics.PathGraphics;
import org.cesiumjs.cs.datasources.graphics.options.PathGraphicsOptions;
@@ -58,217 +40,222 @@ import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
+import static java.lang.Math.max;
+import static java.lang.Math.min;
+
/**
* @author Serge Silaev aka iSergio
*/
public class HeadingPitchRoll extends AbstractExample {
- double deltaRadians = Math.toRadians(3.0);
- SampledPositionProperty pathPosition;
- double speed = 10;
- double r = 0;
- Cartesian3 position;
- Cartesian3 speedVector;
- Model planePrimitive;
-
- CheckBox fromBehind;
+ double deltaRadians = Math.toRadians(3.0);
+ SampledPositionProperty pathPosition;
+ double speed = 10;
+ double r = 0;
+ Cartesian3 position;
+ Cartesian3 speedVector;
+ Model planePrimitive;
- @Inject
- public HeadingPitchRoll(ShowcaseExampleStore store) {
- super("HeadingPitchRoll", "Use HeadingPitchRoll",
- new String[] { "Showcase", "Cesium", "3d", "Viewer", "Heading", "Pitch", "Roll" }, store);
- }
+ CheckBox fromBehind;
- @Override
- public void buildPanel() {
- ViewerPanel csVPanel = new ViewerPanel();
+ @Inject
+ public HeadingPitchRoll(ShowcaseExampleStore store) {
+ super("HeadingPitchRoll", "Use HeadingPitchRoll",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer", "Heading", "Pitch", "Roll"}, store);
+ }
- pathPosition = new SampledPositionProperty();
+ @Override
+ public void buildPanel() {
+ ViewerPanel csVPanel = new ViewerPanel();
- PathGraphicsOptions pathGraphicsOptions = new PathGraphicsOptions();
- pathGraphicsOptions.show = new ConstantProperty<>(true);
- pathGraphicsOptions.leadTime = new ConstantProperty<>(0);
- pathGraphicsOptions.trailTime = new ConstantProperty<>(60);
- pathGraphicsOptions.width = new ConstantProperty<>(10);
- pathGraphicsOptions.resolution = new ConstantProperty<>(1);
- pathGraphicsOptions.material = PolylineGlowMaterialProperty.create(Color.PALEGOLDENROD(), 0.3);
+ pathPosition = new SampledPositionProperty();
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = pathPosition;
- entityOptions.name = "path";
- entityOptions.path = new PathGraphics(pathGraphicsOptions);
- Entity entityPath = csVPanel.getViewer().entities().add(entityOptions);
+ PathGraphicsOptions pathGraphicsOptions = new PathGraphicsOptions();
+ pathGraphicsOptions.show = new ConstantProperty<>(true);
+ pathGraphicsOptions.leadTime = new ConstantProperty<>(0);
+ pathGraphicsOptions.trailTime = new ConstantProperty<>(60);
+ pathGraphicsOptions.width = new ConstantProperty<>(10);
+ pathGraphicsOptions.resolution = new ConstantProperty<>(1);
+ pathGraphicsOptions.material = PolylineGlowMaterialProperty.create(Color.PALEGOLDENROD(), 0.3);
- final org.cesiumjs.cs.scene.Camera camera = csVPanel.getViewer().camera;
- final ScreenSpaceCameraController controller = csVPanel.getViewer().scene().screenSpaceCameraController();
- final Cartesian3 center = new Cartesian3();
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = pathPosition;
+ entityOptions.name = "path";
+ entityOptions.path = new PathGraphics(pathGraphicsOptions);
+ Entity entityPath = csVPanel.getViewer().entities().add(entityOptions);
- final org.cesiumjs.cs.core.HeadingPitchRoll hpRoll = new org.cesiumjs.cs.core.HeadingPitchRoll();
- final HeadingPitchRange hpRange = new HeadingPitchRange();
+ final org.cesiumjs.cs.scene.Camera camera = csVPanel.getViewer().camera;
+ final ScreenSpaceCameraController controller = csVPanel.getViewer().scene().screenSpaceCameraController();
+ final Cartesian3 center = new Cartesian3();
- position = Cartesian3.fromDegrees(-123.0744619, 44.0503706, 5000.0);
- speedVector = new Cartesian3();
- final Transforms.LocalFrameToFixedFrame fixedFrameTransform = Transforms.localFrameToFixedFrameGenerator("north",
- "west");
+ final org.cesiumjs.cs.core.HeadingPitchRoll hpRoll = new org.cesiumjs.cs.core.HeadingPitchRoll();
+ final HeadingPitchRange hpRange = new HeadingPitchRange();
- FromGltfOptions fromGltfOptions = new FromGltfOptions();
- fromGltfOptions.url = GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb";
- fromGltfOptions.modelMatrix = Transforms.headingPitchRollToFixedFrame(position, hpRoll, Ellipsoid.WGS84());// ,
- // fixedFrameTransform);
- fromGltfOptions.minimumPixelSize = 128;
- planePrimitive = (Model) csVPanel.getViewer().scene().primitives().add(Model.fromGltf(fromGltfOptions));
- planePrimitive.readyPromise().then(new Fulfill() {
- @Override
- public void onFulfilled(Model model) {
- ModelAnimationOptions modelAnimationOptions = new ModelAnimationOptions();
- modelAnimationOptions.multiplier = 0.5;
- modelAnimationOptions.loop = ModelAnimationLoop.REPEAT();
- model.activeAnimations.addAll(modelAnimationOptions);
- // Zoom to model
- r = 2.0 * max(model.boundingSphere().radius, ((PerspectiveFrustum) camera.frustum).near);
- controller.minimumZoomDistance = r * 0.5;
- Matrix4.multiplyByPoint(model.modelMatrix, model.boundingSphere().center, center);
- double heading = Math.toRadians(230.0);
- double pitch = Math.toRadians(-20.0);
- hpRange.heading = heading;
- hpRange.pitch = pitch;
- hpRange.range = r * 50.0;
- camera.lookAt(center, hpRange);
- }
- });
+ position = Cartesian3.fromDegrees(-123.0744619, 44.0503706, 5000.0);
+ speedVector = new Cartesian3();
+ final Transforms.LocalFrameToFixedFrame fixedFrameTransform = Transforms.localFrameToFixedFrameGenerator("north",
+ "west");
- fromBehind = new CheckBox();
- fromBehind.getElement().getStyle().setColor("white");
- fromBehind.setWidth("100px");
- fromBehind.setValue(false);
+ FromGltfOptions fromGltfOptions = new FromGltfOptions();
+ fromGltfOptions.url = GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb";
+ fromGltfOptions.modelMatrix = Transforms.headingPitchRollToFixedFrame(position, hpRoll, Ellipsoid.WGS84());// ,
+ // fixedFrameTransform);
+ fromGltfOptions.minimumPixelSize = 128;
+ planePrimitive = (Model) csVPanel.getViewer().scene().primitives().add(Model.fromGltf(fromGltfOptions));
+ planePrimitive.readyPromise().then(new Fulfill() {
+ @Override
+ public void onFulfilled(Model model) {
+ ModelAnimationOptions modelAnimationOptions = new ModelAnimationOptions();
+ modelAnimationOptions.multiplier = 0.5;
+ modelAnimationOptions.loop = ModelAnimationLoop.REPEAT();
+ model.activeAnimations.addAll(modelAnimationOptions);
+ // Zoom to model
+ r = 2.0 * max(model.boundingSphere().radius, camera.frustum.near);
+ controller.minimumZoomDistance = r * 0.5;
+ Matrix4.multiplyByPoint(model.modelMatrix, model.boundingSphere().center, center);
+ double heading = Math.toRadians(230.0);
+ double pitch = Math.toRadians(-20.0);
+ hpRange.heading = heading;
+ hpRange.pitch = pitch;
+ hpRange.range = r * 50.0;
+ camera.lookAt(center, hpRange);
+ }
+ });
- final com.google.gwt.user.client.ui.Label headingLabel = new Label();
- headingLabel.getElement().getStyle().setColor("white");
- headingLabel.setText("Heading:°");
+ fromBehind = new CheckBox();
+ fromBehind.getElement().getStyle().setColor("white");
+ fromBehind.setWidth("100px");
+ fromBehind.setValue(false);
- final com.google.gwt.user.client.ui.Label pitchLabel = new Label();
- pitchLabel.getElement().getStyle().setColor("white");
- pitchLabel.setText("Pitch:°");
+ final com.google.gwt.user.client.ui.Label headingLabel = new Label();
+ headingLabel.getElement().getStyle().setColor("white");
+ headingLabel.setText("Heading:°");
- final com.google.gwt.user.client.ui.Label rollLabel = new Label();
- rollLabel.getElement().getStyle().setColor("white");
- rollLabel.setText("Roll:°");
+ final com.google.gwt.user.client.ui.Label pitchLabel = new Label();
+ pitchLabel.getElement().getStyle().setColor("white");
+ pitchLabel.setText("Pitch:°");
- final com.google.gwt.user.client.ui.Label speedLabel = new Label();
- speedLabel.getElement().getStyle().setColor("white");
- speedLabel.setText("Speed:m/s");
+ final com.google.gwt.user.client.ui.Label rollLabel = new Label();
+ rollLabel.getElement().getStyle().setColor("white");
+ rollLabel.setText("Roll:°");
- FlexTable flexTable = new FlexTable();
- flexTable.setWidget(0, 0, headingLabel);
- flexTable.setHTML(1, 0, "← to left/→ to right");
- flexTable.setWidget(2, 0, pitchLabel);
- flexTable.setHTML(3, 0, "↑ to up/↓ to down");
- flexTable.setWidget(4, 0, rollLabel);
- flexTable.setHTML(5, 0, "← + ⇧ left/→ + ⇧ right");
- flexTable.setWidget(6, 0, speedLabel);
- flexTable.setHTML(7, 0, "↑ + ⇧ to speed up/↓ + ⇧ to speed down");
- flexTable.setHTML(8, 0, "Following aircraft");
- flexTable.setWidget(8, 1, fromBehind);
+ final com.google.gwt.user.client.ui.Label speedLabel = new Label();
+ speedLabel.getElement().getStyle().setColor("white");
+ speedLabel.setText("Speed:m/s");
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(flexTable, 20, 20);
+ FlexTable flexTable = new FlexTable();
+ flexTable.setWidget(0, 0, headingLabel);
+ flexTable.setHTML(1, 0, "← to left/→ to right");
+ flexTable.setWidget(2, 0, pitchLabel);
+ flexTable.setHTML(3, 0, "↑ to up/↓ to down");
+ flexTable.setWidget(4, 0, rollLabel);
+ flexTable.setHTML(5, 0, "← + ⇧ left/→ + ⇧ right");
+ flexTable.setWidget(6, 0, speedLabel);
+ flexTable.setHTML(7, 0, "↑ + ⇧ to speed up/↓ + ⇧ to speed down");
+ flexTable.setHTML(8, 0, "Following aircraft");
+ flexTable.setWidget(8, 1, fromBehind);
- contentPanel.add(new HTML("Click on the 3D window then use the keyboard to change settings.
"));
- contentPanel.add(aPanel);
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(flexTable, 20, 20);
- csVPanel.getViewer().scene().preRender().addEventListener(new Scene.Listener() {
- @Override
- public void function(Scene scene, JulianDate time) {
- headingLabel.setText("Heading:" + Math.toDegrees(hpRoll.heading) + "°");
- pitchLabel.setText("Pitch:" + Math.toDegrees(hpRoll.pitch) + "°");
- rollLabel.setText("Roll:" + Math.toDegrees(hpRoll.roll) + "°");
- speedLabel.setText("Speed:" + speed + "m/s");
+ contentPanel.add(new HTML("Click on the 3D window then use the keyboard to change settings.
"));
+ contentPanel.add(aPanel);
- speedVector = Cartesian3.multiplyByScalar(Cartesian3.UNIT_X(), speed / 10, speedVector);
- position = Matrix4.multiplyByPoint(planePrimitive.modelMatrix, speedVector, position);
- pathPosition.addSample(JulianDate.now(), position);
- Transforms.headingPitchRollToFixedFrame(position, hpRoll, Ellipsoid.WGS84(), fixedFrameTransform,
- planePrimitive.modelMatrix);
+ csVPanel.getViewer().scene().preRender().addEventListener(new Scene.Listener() {
+ @Override
+ public void function(Scene scene, JulianDate time) {
+ headingLabel.setText("Heading:" + Math.toDegrees(hpRoll.heading) + "°");
+ pitchLabel.setText("Pitch:" + Math.toDegrees(hpRoll.pitch) + "°");
+ rollLabel.setText("Roll:" + Math.toDegrees(hpRoll.roll) + "°");
+ speedLabel.setText("Speed:" + speed + "m/s");
- if (fromBehind.getValue()) {
- // Zoom to model
- Matrix4.multiplyByPoint(planePrimitive.modelMatrix, planePrimitive.boundingSphere().center, center);
- hpRange.heading = hpRoll.heading;
- hpRange.pitch = hpRoll.pitch;
- camera.lookAt(center, hpRange);
- }
- }
- });
+ speedVector = Cartesian3.multiplyByScalar(Cartesian3.UNIT_X(), speed / 10, speedVector);
+ position = Matrix4.multiplyByPoint(planePrimitive.modelMatrix, speedVector, position);
+ pathPosition.addSample(JulianDate.now(), position);
+ Transforms.headingPitchRollToFixedFrame(position, hpRoll, Ellipsoid.WGS84(), fixedFrameTransform,
+ planePrimitive.modelMatrix);
- RootPanel.get().addDomHandler(new KeyDownHandler() {
- @Override
- public void onKeyDown(KeyDownEvent keyDownEvent) {
- switch (keyDownEvent.getNativeKeyCode()) {
- case 40:
- if (keyDownEvent.getNativeEvent().getShiftKey()) {
- speed = max(--speed, 1);
- } else {
- hpRoll.pitch -= deltaRadians;
- if (hpRoll.pitch < -Math.TWO_PI()) {
- hpRoll.pitch += Math.TWO_PI();
- }
- }
- break;
- case 38:
- if (keyDownEvent.getNativeEvent().getShiftKey()) {
- // speed up
- speed = min(++speed, 100);
- } else {
- // pitch up
- hpRoll.pitch += deltaRadians;
- if (hpRoll.pitch > Math.TWO_PI()) {
- hpRoll.pitch -= Math.TWO_PI();
- }
+ if (fromBehind.getValue()) {
+ // Zoom to model
+ Matrix4.multiplyByPoint(planePrimitive.modelMatrix, planePrimitive.boundingSphere().center, center);
+ hpRange.heading = hpRoll.heading;
+ hpRange.pitch = hpRoll.pitch;
+ camera.lookAt(center, hpRange);
+ }
}
- break;
- case 39:
- if (keyDownEvent.getNativeEvent().getShiftKey()) {
- // roll right
- hpRoll.roll += deltaRadians;
- if (hpRoll.roll > Math.TWO_PI()) {
- hpRoll.roll -= Math.TWO_PI();
- }
- } else {
- // turn right
- hpRoll.heading += deltaRadians;
- if (hpRoll.heading > Math.TWO_PI()) {
- hpRoll.heading -= Math.TWO_PI();
- }
- }
- break;
- case 37:
- if (keyDownEvent.getNativeEvent().getShiftKey()) {
- // roll left until
- hpRoll.roll -= deltaRadians;
- if (hpRoll.roll < 0.0) {
- hpRoll.roll += Math.TWO_PI();
- }
- } else {
- // turn left
- hpRoll.heading -= deltaRadians;
- if (hpRoll.heading < 0.0) {
- hpRoll.heading += Math.TWO_PI();
- }
+ });
+
+ RootPanel.get().addDomHandler(new KeyDownHandler() {
+ @Override
+ public void onKeyDown(KeyDownEvent keyDownEvent) {
+ switch (keyDownEvent.getNativeKeyCode()) {
+ case 40:
+ if (keyDownEvent.getNativeEvent().getShiftKey()) {
+ speed = max(--speed, 1);
+ } else {
+ hpRoll.pitch -= deltaRadians;
+ if (hpRoll.pitch < -Math.TWO_PI()) {
+ hpRoll.pitch += Math.TWO_PI();
+ }
+ }
+ break;
+ case 38:
+ if (keyDownEvent.getNativeEvent().getShiftKey()) {
+ // speed up
+ speed = min(++speed, 100);
+ } else {
+ // pitch up
+ hpRoll.pitch += deltaRadians;
+ if (hpRoll.pitch > Math.TWO_PI()) {
+ hpRoll.pitch -= Math.TWO_PI();
+ }
+ }
+ break;
+ case 39:
+ if (keyDownEvent.getNativeEvent().getShiftKey()) {
+ // roll right
+ hpRoll.roll += deltaRadians;
+ if (hpRoll.roll > Math.TWO_PI()) {
+ hpRoll.roll -= Math.TWO_PI();
+ }
+ } else {
+ // turn right
+ hpRoll.heading += deltaRadians;
+ if (hpRoll.heading > Math.TWO_PI()) {
+ hpRoll.heading -= Math.TWO_PI();
+ }
+ }
+ break;
+ case 37:
+ if (keyDownEvent.getNativeEvent().getShiftKey()) {
+ // roll left until
+ hpRoll.roll -= deltaRadians;
+ if (hpRoll.roll < 0.0) {
+ hpRoll.roll += Math.TWO_PI();
+ }
+ } else {
+ // turn left
+ hpRoll.heading -= deltaRadians;
+ if (hpRoll.heading < 0.0) {
+ hpRoll.heading += Math.TWO_PI();
+ }
+ }
+ break;
+ default:
+ break;
+ }
}
- break;
- default:
- break;
- }
- }
- }, KeyDownEvent.getType());
+ }, KeyDownEvent.getType());
- initWidget(contentPanel);
- }
+ initWidget(contentPanel);
+ }
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "HeadingPitchRoll.txt";
- return sourceCodeURLs;
- }
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "HeadingPitchRoll.txt";
+ return sourceCodeURLs;
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/HelloWorld.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/HelloWorld.java
index e7c0b148916a7fd710a57d06e7aa4fd8260aaf23..83ba64150cd9651a240578d49d3bda4fb54bfe92 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/HelloWorld.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/HelloWorld.java
@@ -16,42 +16,41 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.HTML;
-
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class HelloWorld extends AbstractExample {
- @Inject
- public HelloWorld(ShowcaseExampleStore store) {
- super("Hello World",
- "Use Viewer to start building new applications or easily embed Cesium into existing applications",
- new String[] { "Showcase", "Cesium", "3d", "Viewer" }, store);
- }
-
- @Override
- public void buildPanel() {
- ViewerPanel csVPanel = new ViewerPanel();
-
- contentPanel.add(new HTML(
- "Use Viewer to start building new applications or easily embed Cesium into existing applications.
"));
- contentPanel.add(csVPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "HelloWorld.txt";
- return sourceCodeURLs;
- }
+ @Inject
+ public HelloWorld(ShowcaseExampleStore store) {
+ super("Hello World",
+ "Use Viewer to start building new applications or easily embed Cesium into existing applications",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer"}, store);
+ }
+
+ @Override
+ public void buildPanel() {
+ ViewerPanel csVPanel = new ViewerPanel();
+
+ contentPanel.add(new HTML(
+ "Use Viewer to start building new applications or easily embed Cesium into existing applications.
"));
+ contentPanel.add(csVPanel);
+
+ initWidget(contentPanel);
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "HelloWorld.txt";
+ return sourceCodeURLs;
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageBasedLighting.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageBasedLighting.java
index 925aed85acb1719dca3e46b895184fe50b01ca70..16e08ac026385a16f5f8e1ae9982432364fd9593 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageBasedLighting.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageBasedLighting.java
@@ -16,20 +16,13 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.AbsolutePanel;
-import com.google.gwt.user.client.ui.CheckBox;
-import com.google.gwt.user.client.ui.FlexTable;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.TextBox;
-
+import com.google.gwt.user.client.ui.*;
import org.cesiumjs.cs.core.Cartesian3;
import org.cesiumjs.cs.core.Matrix4;
import org.cesiumjs.cs.core.Transforms;
@@ -48,165 +41,167 @@ import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class ImageBasedLighting extends AbstractExample {
- public Viewer viewer;
- private Model model;
- private String environmentMapURL;
- private Cartesian3[] coefficients;
-
- private Slider luminanceAtZenithSlider;
- private TextBox luminanceAtZenithTBox;
-
- @Inject
- public ImageBasedLighting(ShowcaseExampleStore store) {
- super("Image-Based Lighting", "Use image-based lighting to light a model", new String[] { "Model", "lighting" },
- store);
- }
-
- @Override
- public void buildPanel() {
- ViewerPanel csVPanel = new ViewerPanel();
- viewer = csVPanel.getViewer();
-
- environmentMapURL = GWT.getModuleBaseURL() + "SampleData/EnvironmentMap/kiara_6_afternoon_2k_ibl.ktx";
- String modelURL = GWT.getModuleBaseURL() + "SampleData/models/Pawns/Pawns.glb";
-
- // This environment map was processed using Google's Filament project. To
- // process your own:
- // 1 - Download the Filament release
- // (https://github.com/google/filament/releases).
- // 2 - Run `cmgen --type=ktx --deploy=/path/to/output /path/to/image.hdr`. Other
- // formats are also supported. Run `cmgen --help` for all options.
- // 3 - Take the generated coefficients and the KTX file and load them in
- // CesiumJS as shown below.
-
- Cartesian3 L00 = new Cartesian3(0.170455150831422, 0.163151083190219, 0.196966760289763);
- Cartesian3 L1_1 = new Cartesian3(-0.066550267689383, -0.022088055746048, 0.078835009246127);
- Cartesian3 L10 = new Cartesian3(0.038364097478591, 0.045714300098753, 0.063498904606215);
- Cartesian3 L11 = new Cartesian3(-0.014365363312810, -0.026490613715151, -0.050189404066020);
- Cartesian3 L2_2 = new Cartesian3(-0.051532786917890, -0.050777795729986, -0.056449044453032);
- Cartesian3 L2_1 = new Cartesian3(0.043454596136534, 0.046672590104157, 0.057530107646610);
- Cartesian3 L20 = new Cartesian3(-0.001640466274110, 0.001286638231156, 0.007228908989616);
- Cartesian3 L21 = new Cartesian3(-0.042260855700641, -0.046394335094707, -0.057562936365585);
- Cartesian3 L22 = new Cartesian3(-0.004953478914091, -0.000479681664876, 0.008508150106928);
- coefficients = new Cartesian3[] { L00, L1_1, L10, L11, L2_2, L2_1, L20, L21, L22 };
-
- double height = 0.0;
- org.cesiumjs.cs.core.HeadingPitchRoll hpr = new org.cesiumjs.cs.core.HeadingPitchRoll(0.0, 0.0, 0.0);
- Cartesian3 origin = Cartesian3.fromDegrees(-123.0744619, 44.0503706, height);
- Matrix4 modelMatrix = Transforms.headingPitchRollToFixedFrame(origin, hpr);
-
- FromGltfOptions fromGltfOptions = new FromGltfOptions();
- fromGltfOptions.url = modelURL;
- fromGltfOptions.modelMatrix = modelMatrix;
- fromGltfOptions.minimumPixelSize = 128.0;
- model = (Model) csVPanel.getViewer().scene().primitives().add(Model.fromGltf(fromGltfOptions));
- model.readyPromise().then(new Fulfill() {
- @Override
- public void onFulfilled(Model value) {
- Camera camera = viewer.camera;
-
- // Zoom to model
- ScreenSpaceCameraController controller = viewer.scene().screenSpaceCameraController();
- double r = 2.0 * Math.max(model.boundingSphere().radius, camera.frustum.near);
- controller.minimumZoomDistance = r * 0.5;
-
- Cartesian3 center = Matrix4.multiplyByPoint(model.modelMatrix, model.boundingSphere().center, new Cartesian3());
- double heading = Math.toRadians(230.0);
- double pitch = Math.toRadians(-20.0);
- camera.lookAt(center, new org.cesiumjs.cs.core.HeadingPitchRange(heading, pitch, r * 2.0));
- camera.lookAtTransform(Matrix4.IDENTITY());
-
- model.sphericalHarmonicCoefficients = coefficients;
- model.specularEnvironmentMaps = environmentMapURL;
- }
- }, new Reject() {
- @Override
- public void onRejected(Void value) {
- Window.alert("Error");
- }
- });
-
- luminanceAtZenithSlider = new Slider("LuminanceAtZenith", 0, 200, 50);
- luminanceAtZenithSlider.setStep(1);
- luminanceAtZenithSlider.addListener(new SliderListener() {
- @Override
- public void onStart(SliderEvent e) {
- //
- }
-
- @Override
- public boolean onSlide(SliderEvent e) {
- Slider source = e.getSource();
- double value = source.getValue() / 100.0;
- model.luminanceAtZenith = value;
- luminanceAtZenithTBox.setValue(value + "");
- return true;
- }
-
- @Override
- public void onChange(SliderEvent e) {
- //
- }
-
- @Override
- public void onStop(SliderEvent e) {
- //
- }
- });
- luminanceAtZenithTBox = new TextBox();
- luminanceAtZenithTBox.setSize("30px", "12px");
- luminanceAtZenithTBox.setValue("" + 0.5);
- luminanceAtZenithTBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent event) {
- TextBox source = (TextBox) event.getSource();
- float value = Float.parseFloat(source.getValue());
- luminanceAtZenithSlider.setValue((int) (value * 100));
- model.luminanceAtZenith = value;
- }
- });
-
- CheckBox useProceduralImageCBox = new CheckBox("Use procedural image");
- useProceduralImageCBox.getElement().getStyle().setColor("white");
- useProceduralImageCBox.setWidth("100px");
- useProceduralImageCBox.setValue(false);
- useProceduralImageCBox.addValueChangeHandler(new ValueChangeHandler() {
- @Override
- public void onValueChange(ValueChangeEvent event) {
- if (!event.getValue()) {
- model.sphericalHarmonicCoefficients = coefficients;
- model.specularEnvironmentMaps = environmentMapURL;
- } else {
- model.sphericalHarmonicCoefficients = (Cartesian3[]) JsObject.undefined();
- model.specularEnvironmentMaps = (String) JsObject.undefined();
- }
- }
- });
-
- FlexTable flexTable = new FlexTable();
- flexTable.setHTML(1, 0, "Luminance at Zenith");
- flexTable.setWidget(1, 1, luminanceAtZenithSlider);
- flexTable.setWidget(1, 2, luminanceAtZenithTBox);
- flexTable.setWidget(2, 1, useProceduralImageCBox);
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(flexTable, 20, 20);
-
- contentPanel.add(new HTML("Use image-based lighting to light a model.
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ImageBasedLighting.txt";
- return sourceCodeURLs;
- }
+ public Viewer viewer;
+ private Model model;
+ private String environmentMapURL;
+ private Cartesian3[] coefficients;
+
+ private Slider luminanceAtZenithSlider;
+ private TextBox luminanceAtZenithTBox;
+
+ @Inject
+ public ImageBasedLighting(ShowcaseExampleStore store) {
+ super("Image-Based Lighting", "Use image-based lighting to light a model", new String[]{"Model", "lighting"},
+ store);
+ }
+
+ @Override
+ public void buildPanel() {
+ ViewerPanel csVPanel = new ViewerPanel();
+ viewer = csVPanel.getViewer();
+
+ environmentMapURL = GWT.getModuleBaseURL() + "SampleData/EnvironmentMap/kiara_6_afternoon_2k_ibl.ktx";
+ String modelURL = GWT.getModuleBaseURL() + "SampleData/models/Pawns/Pawns.glb";
+
+ // This environment map was processed using Google's Filament project. To
+ // process your own:
+ // 1 - Download the Filament release
+ // (https://github.com/google/filament/releases).
+ // 2 - Run `cmgen --type=ktx --deploy=/path/to/output /path/to/image.hdr`. Other
+ // formats are also supported. Run `cmgen --help` for all options.
+ // 3 - Take the generated coefficients and the KTX file and load them in
+ // CesiumJS as shown below.
+
+ Cartesian3 L00 = new Cartesian3(0.170455150831422, 0.163151083190219, 0.196966760289763);
+ Cartesian3 L1_1 = new Cartesian3(-0.066550267689383, -0.022088055746048, 0.078835009246127);
+ Cartesian3 L10 = new Cartesian3(0.038364097478591, 0.045714300098753, 0.063498904606215);
+ Cartesian3 L11 = new Cartesian3(-0.014365363312810, -0.026490613715151, -0.050189404066020);
+ Cartesian3 L2_2 = new Cartesian3(-0.051532786917890, -0.050777795729986, -0.056449044453032);
+ Cartesian3 L2_1 = new Cartesian3(0.043454596136534, 0.046672590104157, 0.057530107646610);
+ Cartesian3 L20 = new Cartesian3(-0.001640466274110, 0.001286638231156, 0.007228908989616);
+ Cartesian3 L21 = new Cartesian3(-0.042260855700641, -0.046394335094707, -0.057562936365585);
+ Cartesian3 L22 = new Cartesian3(-0.004953478914091, -0.000479681664876, 0.008508150106928);
+ coefficients = new Cartesian3[]{L00, L1_1, L10, L11, L2_2, L2_1, L20, L21, L22};
+
+ double height = 0.0;
+ org.cesiumjs.cs.core.HeadingPitchRoll hpr = new org.cesiumjs.cs.core.HeadingPitchRoll(0.0, 0.0, 0.0);
+ Cartesian3 origin = Cartesian3.fromDegrees(-123.0744619, 44.0503706, height);
+ Matrix4 modelMatrix = Transforms.headingPitchRollToFixedFrame(origin, hpr);
+
+ FromGltfOptions fromGltfOptions = new FromGltfOptions();
+ fromGltfOptions.url = modelURL;
+ fromGltfOptions.modelMatrix = modelMatrix;
+ fromGltfOptions.minimumPixelSize = 128.0;
+ model = (Model) csVPanel.getViewer().scene().primitives().add(Model.fromGltf(fromGltfOptions));
+ model.readyPromise().then(new Fulfill() {
+ @Override
+ public void onFulfilled(Model value) {
+ Camera camera = viewer.camera;
+
+ // Zoom to model
+ ScreenSpaceCameraController controller = viewer.scene().screenSpaceCameraController();
+ double r = 2.0 * Math.max(model.boundingSphere().radius, camera.frustum.near);
+ controller.minimumZoomDistance = r * 0.5;
+
+ Cartesian3 center = Matrix4.multiplyByPoint(model.modelMatrix, model.boundingSphere().center, new Cartesian3());
+ double heading = Math.toRadians(230.0);
+ double pitch = Math.toRadians(-20.0);
+ camera.lookAt(center, new org.cesiumjs.cs.core.HeadingPitchRange(heading, pitch, r * 2.0));
+ camera.lookAtTransform(Matrix4.IDENTITY());
+
+ model.sphericalHarmonicCoefficients = coefficients;
+ model.specularEnvironmentMaps = environmentMapURL;
+ }
+ }, new Reject() {
+ @Override
+ public void onRejected(Void value) {
+ Window.alert("Error");
+ }
+ });
+
+ luminanceAtZenithSlider = new Slider("LuminanceAtZenith", 0, 200, 50);
+ luminanceAtZenithSlider.setStep(1);
+ luminanceAtZenithSlider.addListener(new SliderListener() {
+ @Override
+ public void onStart(SliderEvent e) {
+ //
+ }
+
+ @Override
+ public boolean onSlide(SliderEvent e) {
+ Slider source = e.getSource();
+ double value = source.getValue() / 100.0;
+ model.luminanceAtZenith = value;
+ luminanceAtZenithTBox.setValue(value + "");
+ return true;
+ }
+
+ @Override
+ public void onChange(SliderEvent e) {
+ //
+ }
+
+ @Override
+ public void onStop(SliderEvent e) {
+ //
+ }
+ });
+ luminanceAtZenithTBox = new TextBox();
+ luminanceAtZenithTBox.setSize("30px", "12px");
+ luminanceAtZenithTBox.setValue("" + 0.5);
+ luminanceAtZenithTBox.addChangeHandler(new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent event) {
+ TextBox source = (TextBox) event.getSource();
+ float value = Float.parseFloat(source.getValue());
+ luminanceAtZenithSlider.setValue((int) (value * 100));
+ model.luminanceAtZenith = value;
+ }
+ });
+
+ CheckBox useProceduralImageCBox = new CheckBox("Use procedural image");
+ useProceduralImageCBox.getElement().getStyle().setColor("white");
+ useProceduralImageCBox.setWidth("100px");
+ useProceduralImageCBox.setValue(false);
+ useProceduralImageCBox.addValueChangeHandler(new ValueChangeHandler() {
+ @Override
+ public void onValueChange(ValueChangeEvent event) {
+ if (!event.getValue()) {
+ model.sphericalHarmonicCoefficients = coefficients;
+ model.specularEnvironmentMaps = environmentMapURL;
+ } else {
+ model.sphericalHarmonicCoefficients = (Cartesian3[]) JsObject.undefined();
+ model.specularEnvironmentMaps = (String) JsObject.undefined();
+ }
+ }
+ });
+
+ FlexTable flexTable = new FlexTable();
+ flexTable.setHTML(1, 0, "Luminance at Zenith");
+ flexTable.setWidget(1, 1, luminanceAtZenithSlider);
+ flexTable.setWidget(1, 2, luminanceAtZenithTBox);
+ flexTable.setWidget(2, 1, useProceduralImageCBox);
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(flexTable, 20, 20);
+
+ contentPanel.add(new HTML("Use image-based lighting to light a model.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ImageBasedLighting.txt";
+ return sourceCodeURLs;
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryAdjustment.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryAdjustment.java
index 17c659d4335266565f02b17dcccac252a9f5fec1..d17191d3abfe7dff53655079058be78d2b9de710 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryAdjustment.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryAdjustment.java
@@ -16,19 +16,10 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
-import com.google.gwt.user.client.ui.AbsolutePanel;
-import com.google.gwt.user.client.ui.FlexTable;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.HasVerticalAlignment;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.TextBox;
-
+import com.google.gwt.user.client.ui.*;
import org.cesiumjs.cs.core.Event;
import org.cesiumjs.cs.scene.ImageryLayer;
import org.cesiumjs.cs.widgets.ViewerPanel;
@@ -38,242 +29,244 @@ import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class ImageryAdjustment extends AbstractExample {
- Slider brightnessSlider;
- Slider contrastSlider;
- Slider hueSlider;
- Slider saturationSlider;
- Slider gammaSlider;
-
- TextBox brightnessTBox;
- TextBox contrastTBox;
- TextBox hueTBox;
- TextBox saturationTBox;
- TextBox gammaTBox;
-
- ViewerPanel csVPanel;
-
- float brightness = 0.f;
- float contrast = 0.f;
- float hue = 0.f;
- float saturation = 0.f;
- float gamma = 0.f;
-
- @Inject
- public ImageryAdjustment(ShowcaseExampleStore store) {
- super("Imagery Adjustment", "Adjust brightness, contrast, hue, saturation, and gamma of an imagery layer",
- new String[] { "Showcase", "Cesium", "3d", "Viewer" }, store);
- }
-
- @Override
- public void buildPanel() {
- csVPanel = new ViewerPanel();
- csVPanel.getViewer().imageryLayers().layerAdded.addEventListener(new UpdateViewModel());
- csVPanel.getViewer().imageryLayers().layerRemoved.addEventListener(new UpdateViewModel());
- csVPanel.getViewer().imageryLayers().layerMoved.addEventListener(new UpdateViewModel());
-
- brightnessSlider = new Slider("brightness", 0, 300, 100);
- brightnessSlider.setStep(1);
- brightnessSlider.setWidth("150px");
- brightnessSlider.addListener(new MSliderListener());
- brightnessTBox = new TextBox();
- brightnessTBox.addChangeHandler(new MChangeHandler());
- brightnessTBox.setText("" + 1);
- brightnessTBox.setSize("30px", "12px");
-
- HorizontalPanel brightnessHPanel = new HorizontalPanel();
- brightnessHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
- brightnessHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
- brightnessHPanel.setSpacing(10);
- brightnessHPanel.add(brightnessSlider);
- brightnessHPanel.add(brightnessTBox);
-
- contrastSlider = new Slider("contrast", 0, 300, 100);
- contrastSlider.setStep(1);
- contrastSlider.setWidth("150px");
- contrastSlider.addListener(new MSliderListener());
- contrastTBox = new TextBox();
- contrastTBox.addChangeHandler(new MChangeHandler());
- contrastTBox.setText("" + 1);
- contrastTBox.setSize("30px", "12px");
-
- HorizontalPanel contrastHPanel = new HorizontalPanel();
- contrastHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
- contrastHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
- contrastHPanel.setSpacing(10);
- contrastHPanel.add(contrastSlider);
- contrastHPanel.add(contrastTBox);
-
- hueSlider = new Slider("hue", 0, 300, 0);
- hueSlider.setStep(1);
- hueSlider.setWidth("150px");
- hueSlider.addListener(new MSliderListener());
- hueTBox = new TextBox();
- hueTBox.addChangeHandler(new MChangeHandler());
- hueTBox.setText("" + 0);
- hueTBox.setSize("30px", "12px");
-
- HorizontalPanel hueHPanel = new HorizontalPanel();
- hueHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
- hueHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
- hueHPanel.setSpacing(10);
- hueHPanel.add(hueSlider);
- hueHPanel.add(hueTBox);
-
- saturationSlider = new Slider("saturation", 0, 300, 100);
- saturationSlider.setStep(1);
- saturationSlider.setWidth("150px");
- saturationSlider.addListener(new MSliderListener());
- saturationTBox = new TextBox();
- saturationTBox.addChangeHandler(new MChangeHandler());
- saturationTBox.setText("" + 1);
- saturationTBox.setSize("30px", "12px");
-
- HorizontalPanel saturationHPanel = new HorizontalPanel();
- saturationHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
- saturationHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
- saturationHPanel.setSpacing(10);
- saturationHPanel.add(saturationSlider);
- saturationHPanel.add(saturationTBox);
-
- gammaSlider = new Slider("gamma", 0, 300, 100);
- gammaSlider.setStep(1);
- gammaSlider.setWidth("150px");
- gammaSlider.addListener(new MSliderListener());
- gammaTBox = new TextBox();
- gammaTBox.addChangeHandler(new MChangeHandler());
- gammaTBox.setText("" + 1);
- gammaTBox.setSize("30px", "12px");
-
- HorizontalPanel gammaHPanel = new HorizontalPanel();
- gammaHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
- gammaHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
- gammaHPanel.setSpacing(10);
- gammaHPanel.add(gammaSlider);
- gammaHPanel.add(gammaTBox);
-
- FlexTable flexTable = new FlexTable();
- flexTable.setCellSpacing(1);
- flexTable.setCellPadding(1);
- flexTable.setHTML(1, 0, "Brightness");
- flexTable.setWidget(1, 1, brightnessHPanel);
- flexTable.setHTML(2, 0, "Contrast");
- flexTable.setWidget(2, 1, contrastHPanel);
- flexTable.setHTML(3, 0, "Hue");
- flexTable.setWidget(3, 1, hueHPanel);
- flexTable.setHTML(4, 0, "Saturation");
- flexTable.setWidget(4, 1, saturationHPanel);
- flexTable.setHTML(5, 0, "Gamma");
- flexTable.setWidget(5, 1, gammaHPanel);
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(flexTable, 20, 20);
-
- contentPanel.add(new HTML("Adjust brightness, contrast, hue, saturation, and gamma of an imagery layer.
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ImageryAdjustment.txt";
- return sourceCodeURLs;
- }
-
- private class MSliderListener implements SliderListener {
- @Override
- public void onStart(SliderEvent e) {
-
+ Slider brightnessSlider;
+ Slider contrastSlider;
+ Slider hueSlider;
+ Slider saturationSlider;
+ Slider gammaSlider;
+
+ TextBox brightnessTBox;
+ TextBox contrastTBox;
+ TextBox hueTBox;
+ TextBox saturationTBox;
+ TextBox gammaTBox;
+
+ ViewerPanel csVPanel;
+
+ float brightness = 0.f;
+ float contrast = 0.f;
+ float hue = 0.f;
+ float saturation = 0.f;
+ float gamma = 0.f;
+
+ @Inject
+ public ImageryAdjustment(ShowcaseExampleStore store) {
+ super("Imagery Adjustment", "Adjust brightness, contrast, hue, saturation, and gamma of an imagery layer",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer"}, store);
}
@Override
- public boolean onSlide(SliderEvent e) {
- Slider source = e.getSource();
- float value = source.getValue() / 100.f;
- if (source.getElement().getId().equalsIgnoreCase("brightness")) {
- csVPanel.getViewer().imageryLayers().get(0).brightness = value;
- brightnessTBox.setValue("" + value);
- } else if (source.getElement().getId().equalsIgnoreCase("contrast")) {
- csVPanel.getViewer().imageryLayers().get(0).contrast = value;
- contrastTBox.setValue("" + value);
- } else if (source.getElement().getId().equalsIgnoreCase("hue")) {
- csVPanel.getViewer().imageryLayers().get(0).hue = value;
- hueTBox.setValue("" + value);
- } else if (source.getElement().getId().equalsIgnoreCase("saturation")) {
- csVPanel.getViewer().imageryLayers().get(0).saturation = value;
- saturationTBox.setValue("" + value);
- } else if (source.getElement().getId().equalsIgnoreCase("gamma")) {
- csVPanel.getViewer().imageryLayers().get(0).gamma = value;
- gammaTBox.setValue("" + value);
- }
- return true;
+ public void buildPanel() {
+ csVPanel = new ViewerPanel();
+ csVPanel.getViewer().imageryLayers().layerAdded.addEventListener(new UpdateViewModel());
+ csVPanel.getViewer().imageryLayers().layerRemoved.addEventListener(new UpdateViewModel());
+ csVPanel.getViewer().imageryLayers().layerMoved.addEventListener(new UpdateViewModel());
+
+ brightnessSlider = new Slider("brightness", 0, 300, 100);
+ brightnessSlider.setStep(1);
+ brightnessSlider.setWidth("150px");
+ brightnessSlider.addListener(new MSliderListener());
+ brightnessTBox = new TextBox();
+ brightnessTBox.addChangeHandler(new MChangeHandler());
+ brightnessTBox.setText("" + 1);
+ brightnessTBox.setSize("30px", "12px");
+
+ HorizontalPanel brightnessHPanel = new HorizontalPanel();
+ brightnessHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+ brightnessHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+ brightnessHPanel.setSpacing(10);
+ brightnessHPanel.add(brightnessSlider);
+ brightnessHPanel.add(brightnessTBox);
+
+ contrastSlider = new Slider("contrast", 0, 300, 100);
+ contrastSlider.setStep(1);
+ contrastSlider.setWidth("150px");
+ contrastSlider.addListener(new MSliderListener());
+ contrastTBox = new TextBox();
+ contrastTBox.addChangeHandler(new MChangeHandler());
+ contrastTBox.setText("" + 1);
+ contrastTBox.setSize("30px", "12px");
+
+ HorizontalPanel contrastHPanel = new HorizontalPanel();
+ contrastHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+ contrastHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+ contrastHPanel.setSpacing(10);
+ contrastHPanel.add(contrastSlider);
+ contrastHPanel.add(contrastTBox);
+
+ hueSlider = new Slider("hue", 0, 300, 0);
+ hueSlider.setStep(1);
+ hueSlider.setWidth("150px");
+ hueSlider.addListener(new MSliderListener());
+ hueTBox = new TextBox();
+ hueTBox.addChangeHandler(new MChangeHandler());
+ hueTBox.setText("" + 0);
+ hueTBox.setSize("30px", "12px");
+
+ HorizontalPanel hueHPanel = new HorizontalPanel();
+ hueHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+ hueHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+ hueHPanel.setSpacing(10);
+ hueHPanel.add(hueSlider);
+ hueHPanel.add(hueTBox);
+
+ saturationSlider = new Slider("saturation", 0, 300, 100);
+ saturationSlider.setStep(1);
+ saturationSlider.setWidth("150px");
+ saturationSlider.addListener(new MSliderListener());
+ saturationTBox = new TextBox();
+ saturationTBox.addChangeHandler(new MChangeHandler());
+ saturationTBox.setText("" + 1);
+ saturationTBox.setSize("30px", "12px");
+
+ HorizontalPanel saturationHPanel = new HorizontalPanel();
+ saturationHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+ saturationHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+ saturationHPanel.setSpacing(10);
+ saturationHPanel.add(saturationSlider);
+ saturationHPanel.add(saturationTBox);
+
+ gammaSlider = new Slider("gamma", 0, 300, 100);
+ gammaSlider.setStep(1);
+ gammaSlider.setWidth("150px");
+ gammaSlider.addListener(new MSliderListener());
+ gammaTBox = new TextBox();
+ gammaTBox.addChangeHandler(new MChangeHandler());
+ gammaTBox.setText("" + 1);
+ gammaTBox.setSize("30px", "12px");
+
+ HorizontalPanel gammaHPanel = new HorizontalPanel();
+ gammaHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+ gammaHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+ gammaHPanel.setSpacing(10);
+ gammaHPanel.add(gammaSlider);
+ gammaHPanel.add(gammaTBox);
+
+ FlexTable flexTable = new FlexTable();
+ flexTable.setCellSpacing(1);
+ flexTable.setCellPadding(1);
+ flexTable.setHTML(1, 0, "Brightness");
+ flexTable.setWidget(1, 1, brightnessHPanel);
+ flexTable.setHTML(2, 0, "Contrast");
+ flexTable.setWidget(2, 1, contrastHPanel);
+ flexTable.setHTML(3, 0, "Hue");
+ flexTable.setWidget(3, 1, hueHPanel);
+ flexTable.setHTML(4, 0, "Saturation");
+ flexTable.setWidget(4, 1, saturationHPanel);
+ flexTable.setHTML(5, 0, "Gamma");
+ flexTable.setWidget(5, 1, gammaHPanel);
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(flexTable, 20, 20);
+
+ contentPanel.add(new HTML("Adjust brightness, contrast, hue, saturation, and gamma of an imagery layer.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
}
@Override
- public void onChange(SliderEvent e) {
-
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ImageryAdjustment.txt";
+ return sourceCodeURLs;
}
- @Override
- public void onStop(SliderEvent e) {
+ private class MSliderListener implements SliderListener {
+ @Override
+ public void onStart(SliderEvent e) {
- }
- }
+ }
- private class MChangeHandler implements ChangeHandler {
+ @Override
+ public boolean onSlide(SliderEvent e) {
+ Slider source = e.getSource();
+ float value = source.getValue() / 100.f;
+ if (source.getElement().getId().equalsIgnoreCase("brightness")) {
+ csVPanel.getViewer().imageryLayers().get(0).brightness = value;
+ brightnessTBox.setValue("" + value);
+ } else if (source.getElement().getId().equalsIgnoreCase("contrast")) {
+ csVPanel.getViewer().imageryLayers().get(0).contrast = value;
+ contrastTBox.setValue("" + value);
+ } else if (source.getElement().getId().equalsIgnoreCase("hue")) {
+ csVPanel.getViewer().imageryLayers().get(0).hue = value;
+ hueTBox.setValue("" + value);
+ } else if (source.getElement().getId().equalsIgnoreCase("saturation")) {
+ csVPanel.getViewer().imageryLayers().get(0).saturation = value;
+ saturationTBox.setValue("" + value);
+ } else if (source.getElement().getId().equalsIgnoreCase("gamma")) {
+ csVPanel.getViewer().imageryLayers().get(0).gamma = value;
+ gammaTBox.setValue("" + value);
+ }
+ return true;
+ }
- @Override
- public void onChange(ChangeEvent changeEvent) {
- TextBox source = (TextBox) changeEvent.getSource();
- float value = Float.parseFloat(source.getText());
- if (source.equals(brightnessTBox)) {
- brightnessSlider.setValue((int) (value * 100));
- } else if (source.equals(contrastTBox)) {
- contrastSlider.setValue((int) (value * 100));
- } else if (source.equals(hueTBox)) {
- hueSlider.setValue((int) (value * 100));
- } else if (source.equals(saturationTBox)) {
- saturationSlider.setValue((int) (value * 100));
- } else if (source.equals(gammaTBox)) {
- gammaSlider.setValue((int) (value * 100));
- }
+ @Override
+ public void onChange(SliderEvent e) {
+
+ }
+
+ @Override
+ public void onStop(SliderEvent e) {
+
+ }
}
- }
- private final class UpdateViewModel implements Event.Listener {
- @Override
- public void function(Object... o) {
- if (csVPanel.getViewer().imageryLayers().length() > 0) {
- ImageryLayer layer = csVPanel.getViewer().imageryLayers().get(0);
- brightness = layer.brightness;
- contrast = layer.contrast;
- hue = layer.hue;
- saturation = layer.saturation;
- gamma = layer.gamma;
-
- if (brightnessSlider != null && contrastSlider != null && hueSlider != null && saturationSlider != null
- && gammaSlider != null) {
- brightnessSlider.setValue((int) (brightness * 100));
- contrastSlider.setValue((int) (contrast * 100));
- hueSlider.setValue((int) (hue * 100));
- saturationSlider.setValue((int) (saturation * 100));
- gammaSlider.setValue((int) (gamma * 100));
+ private class MChangeHandler implements ChangeHandler {
+
+ @Override
+ public void onChange(ChangeEvent changeEvent) {
+ TextBox source = (TextBox) changeEvent.getSource();
+ float value = Float.parseFloat(source.getText());
+ if (source.equals(brightnessTBox)) {
+ brightnessSlider.setValue((int) (value * 100));
+ } else if (source.equals(contrastTBox)) {
+ contrastSlider.setValue((int) (value * 100));
+ } else if (source.equals(hueTBox)) {
+ hueSlider.setValue((int) (value * 100));
+ } else if (source.equals(saturationTBox)) {
+ saturationSlider.setValue((int) (value * 100));
+ } else if (source.equals(gammaTBox)) {
+ gammaSlider.setValue((int) (value * 100));
+ }
}
- if (brightnessTBox != null && contrastTBox != null && hueTBox != null && saturationTBox != null
- && gammaTBox != null) {
- brightnessTBox.setValue("" + brightness);
- contrastTBox.setValue("" + brightness);
- hueTBox.setValue("" + brightness);
- saturationTBox.setValue("" + brightness);
- gammaTBox.setValue("" + brightness);
+ }
+
+ private final class UpdateViewModel implements Event.Listener {
+ @Override
+ public void function(Object... o) {
+ if (csVPanel.getViewer().imageryLayers().length() > 0) {
+ ImageryLayer layer = csVPanel.getViewer().imageryLayers().get(0);
+ brightness = layer.brightness;
+ contrast = layer.contrast;
+ hue = layer.hue;
+ saturation = layer.saturation;
+ gamma = layer.gamma;
+
+ if (brightnessSlider != null && contrastSlider != null && hueSlider != null && saturationSlider != null
+ && gammaSlider != null) {
+ brightnessSlider.setValue((int) (brightness * 100));
+ contrastSlider.setValue((int) (contrast * 100));
+ hueSlider.setValue((int) (hue * 100));
+ saturationSlider.setValue((int) (saturation * 100));
+ gammaSlider.setValue((int) (gamma * 100));
+ }
+ if (brightnessTBox != null && contrastTBox != null && hueTBox != null && saturationTBox != null
+ && gammaTBox != null) {
+ brightnessTBox.setValue("" + brightness);
+ contrastTBox.setValue("" + brightness);
+ hueTBox.setValue("" + brightness);
+ saturationTBox.setValue("" + brightness);
+ gammaTBox.setValue("" + brightness);
+ }
+ }
}
- }
}
- }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryColorToAlpha.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryColorToAlpha.java
index bc8a4bc4ac1225790cee2b945f4fc472cbafcba0..fd05ebffbc9af0f46ed03f941c6c1d30506d1bd6 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryColorToAlpha.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryColorToAlpha.java
@@ -21,7 +21,6 @@ import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.inject.Inject;
-
import org.cesiumjs.cs.collections.ImageryLayerCollection;
import org.cesiumjs.cs.core.Color;
import org.cesiumjs.cs.core.Rectangle;
@@ -39,81 +38,81 @@ import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
* @author Serge Silaev aka iSergio
*/
public class ImageryColorToAlpha extends AbstractExample {
- private ImageryLayer singleTileLayer;
-
- @Inject
- public ImageryColorToAlpha(ShowcaseExampleStore store) {
- super("Imagery Color To Alpha", "Apply simple color-to-alpha on imagery layers.",
- new String[] { "Showcase", "color to alpha" }, store);
- }
-
- @Override
- public void buildPanel() {
- ViewerPanel csVPanel = new ViewerPanel();
-
- ImageryLayerCollection layers = csVPanel.getViewer().scene().imageryLayers();
-
- // Set oceans on Bing base layer to transparent
- ImageryLayer baseLayer = layers.get(0);
- baseLayer.colorToAlpha = new Color(0.0, 0.016, 0.059, 1.0f);
- baseLayer.colorToAlphaThreshold = 0.2;
-
- // Add a bump layer with adjustable threshold
- SingleTileImageryProviderOptions options = new SingleTileImageryProviderOptions();
- options.url = GWT.getModuleBaseURL() + "images/earthbump1k.jpg";
- options.rectangle = Rectangle.fromDegrees(-180.0, -90.0, 180.0, 90.0);
- singleTileLayer = layers.addImageryProvider(new SingleTileImageryProvider(options));
- singleTileLayer.colorToAlpha = new Color(0.0, 0.0, 0.0, 1.0);
- singleTileLayer.colorToAlphaThreshold = 0.1;
-
- Slider thresholdSlider = new Slider("thresholdSlider", 0, 100, 10);
- thresholdSlider.setStep(1);
- thresholdSlider.setWidth("150px");
- thresholdSlider.addListener(new MSliderListener());
-
- FlexTable flexTable = new FlexTable();
- flexTable.setHTML(1, 0, "Threshold");
- flexTable.setWidget(1, 1, thresholdSlider);
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(flexTable, 20, 20);
-
- contentPanel.add(new HTML("Apply simple color-to-alpha on imagery layers.
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ImageryColorToAlpha.txt";
- return sourceCodeURLs;
- }
-
- private class MSliderListener implements SliderListener {
- @Override
- public void onStart(SliderEvent e) {
+ private ImageryLayer singleTileLayer;
+ @Inject
+ public ImageryColorToAlpha(ShowcaseExampleStore store) {
+ super("Imagery Color To Alpha", "Apply simple color-to-alpha on imagery layers.",
+ new String[]{"Showcase", "color to alpha"}, store);
}
@Override
- public boolean onSlide(SliderEvent e) {
- Slider source = e.getSource();
- int value = source.getValue();
- singleTileLayer.colorToAlphaThreshold = value / 100.0f;
- return true;
- }
+ public void buildPanel() {
+ ViewerPanel csVPanel = new ViewerPanel();
- @Override
- public void onChange(SliderEvent e) {
+ ImageryLayerCollection layers = csVPanel.getViewer().scene().imageryLayers();
+
+ // Set oceans on Bing base layer to transparent
+ ImageryLayer baseLayer = layers.get(0);
+ baseLayer.colorToAlpha = new Color(0.0, 0.016, 0.059, 1.0f);
+ baseLayer.colorToAlphaThreshold = 0.2;
+
+ // Add a bump layer with adjustable threshold
+ SingleTileImageryProviderOptions options = new SingleTileImageryProviderOptions();
+ options.url = GWT.getModuleBaseURL() + "images/earthbump1k.jpg";
+ options.rectangle = Rectangle.fromDegrees(-180.0, -90.0, 180.0, 90.0);
+ singleTileLayer = layers.addImageryProvider(new SingleTileImageryProvider(options));
+ singleTileLayer.colorToAlpha = new Color(0.0, 0.0, 0.0, 1.0);
+ singleTileLayer.colorToAlphaThreshold = 0.1;
+
+ Slider thresholdSlider = new Slider("thresholdSlider", 0, 100, 10);
+ thresholdSlider.setStep(1);
+ thresholdSlider.setWidth("150px");
+ thresholdSlider.addListener(new MSliderListener());
+
+ FlexTable flexTable = new FlexTable();
+ flexTable.setHTML(1, 0, "Threshold");
+ flexTable.setWidget(1, 1, thresholdSlider);
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(flexTable, 20, 20);
+ contentPanel.add(new HTML("Apply simple color-to-alpha on imagery layers.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
}
@Override
- public void onStop(SliderEvent e) {
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ImageryColorToAlpha.txt";
+ return sourceCodeURLs;
+ }
+
+ private class MSliderListener implements SliderListener {
+ @Override
+ public void onStart(SliderEvent e) {
+
+ }
+
+ @Override
+ public boolean onSlide(SliderEvent e) {
+ Slider source = e.getSource();
+ int value = source.getValue();
+ singleTileLayer.colorToAlphaThreshold = value / 100.0f;
+ return true;
+ }
+
+ @Override
+ public void onChange(SliderEvent e) {
+
+ }
+
+ @Override
+ public void onStop(SliderEvent e) {
+ }
}
- }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryCutout.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryCutout.java
index a2efc1d90f9a4abf80c3f53f02596624af673647..bbee40858d430fe82916eeeff72d3ce60df3cfc7 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryCutout.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryCutout.java
@@ -16,19 +16,11 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.dom.client.KeyDownEvent;
-import com.google.gwt.event.dom.client.KeyDownHandler;
-import com.google.gwt.event.dom.client.KeyUpEvent;
-import com.google.gwt.event.dom.client.KeyUpHandler;
+import com.google.gwt.event.dom.client.*;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
-
import org.cesiumjs.cs.Cesium;
import org.cesiumjs.cs.collections.ImageryLayerCollection;
import org.cesiumjs.cs.core.Event;
@@ -46,170 +38,172 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class ImageryCutout extends AbstractExample {
- private class Flags {
- boolean moveEast = false;
- boolean moveWest = false;
- boolean moveNorth = false;
- boolean moveSouth = false;
+ private final Flags flags = new Flags();
+ private final double moveIncrement = 0.05;
+ private ViewerPanel csVPanel;
+
+ @Inject
+ public ImageryCutout(ShowcaseExampleStore store) {
+ super("Imagery Cutout", "Demonstration of imagery layers with rectangular cutouts.",
+ new String[]{"ImageryLayer", "Cutouts"}, store);
+ }
+
+ @Override
+ public void buildPanel() {
+ TileMapServiceImageryProviderOptions tmsOptions = new TileMapServiceImageryProviderOptions();
+ tmsOptions.url = Cesium.buildModuleUrl("Assets/Textures/NaturalEarthII");
+ ViewerOptions viewerOptions = new ViewerOptions();
+ viewerOptions.imageryProvider = new TileMapServiceImageryProvider(tmsOptions);
+ viewerOptions.baseLayerPicker = false;
+
+ csVPanel = new ViewerPanel(viewerOptions);
+
+ csVPanel.addHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent clickEvent) {
+ csVPanel.getViewer().canvas().focus();
+ }
+ }, ClickEvent.getType());
+
+ csVPanel.getViewer().canvas().setAttribute("tabindex", "0");
+
+ Rectangle defaultImageryLayerCutout = Rectangle.fromDegrees(-90, 20, -70, 40);
+
+ // Cut a rectangle out of the base layer
+ ImageryLayerCollection layers = csVPanel.getViewer().imageryLayers();
+ ImageryLayer imageryBaseLayer = layers.get(0);
+
+ imageryBaseLayer.cutoutRectangle = defaultImageryLayerCutout;
+
+ // Fit a SingleTileImageryProvider inside the cutout on the lowest layer
+ SingleTileImageryProviderOptions singleTileImageryProviderOptions = new SingleTileImageryProviderOptions();
+ singleTileImageryProviderOptions.url = GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png";
+ singleTileImageryProviderOptions.rectangle = defaultImageryLayerCutout;
+ layers.addImageryProvider(new SingleTileImageryProvider(singleTileImageryProviderOptions));
+
+ // Add an Earth at Night layer and a "traveling" cutout
+ final ImageryLayer earthAtNight = layers
+ .addImageryProvider(new IonImageryProvider(IonImageryProviderOptions.create(3812)));
+ earthAtNight.cutoutRectangle = Rectangle.fromDegrees(-100, 10, -60, 50);
+ earthAtNight.alpha = 0.9f;
+
+ RootPanel.get().addDomHandler(new KeyDownHandler() {
+ @Override
+ public void onKeyDown(KeyDownEvent keyDownEvent) {
+ setFlag(keyDownEvent.getNativeKeyCode(), true);
+ }
+ }, KeyDownEvent.getType());
+
+ RootPanel.get().addDomHandler(new KeyUpHandler() {
+ @Override
+ public void onKeyUp(KeyUpEvent keyUpEvent) {
+ setFlag(keyUpEvent.getNativeKeyCode(), false);
+ }
+ }, KeyUpEvent.getType());
+
+ csVPanel.getViewer().clock().onTick.addEventListener(new Event.Listener() {
+ @Override
+ public void function(Object... o) {
+ Rectangle travelingRectangle = earthAtNight.cutoutRectangle;
+ if (flags.moveNorth && travelingRectangle.north + moveIncrement < Math.PI_OVER_TWO()) {
+ travelingRectangle.north += moveIncrement;
+ travelingRectangle.south += moveIncrement;
+ }
+ if (flags.moveSouth && travelingRectangle.south - moveIncrement > -Math.PI_OVER_TWO()) {
+ travelingRectangle.north -= moveIncrement;
+ travelingRectangle.south -= moveIncrement;
+ }
+ if (flags.moveEast) {
+ travelingRectangle.east += moveIncrement;
+ travelingRectangle.west += moveIncrement;
+ }
+ if (flags.moveWest) {
+ travelingRectangle.east -= moveIncrement;
+ travelingRectangle.west -= moveIncrement;
+ }
+ travelingRectangle.east = wrapLongitude(travelingRectangle.east);
+ travelingRectangle.west = wrapLongitude(travelingRectangle.west);
+ }
+ });
+
+ HTML html = new HTML();
+ html.setHTML("");
+ html.getElement().getStyle().setColor("white");
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(html, 20, 20);
+
+ contentPanel.add(new HTML("Demonstration of imagery layers with rectangular cutouts.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
+ }
- public Flags() {
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ImageryCutout.txt";
+ return sourceCodeURLs;
}
- }
-
- private ViewerPanel csVPanel;
- private Flags flags = new Flags();
- private double moveIncrement = 0.05;
-
- @Inject
- public ImageryCutout(ShowcaseExampleStore store) {
- super("Imagery Cutout", "Demonstration of imagery layers with rectangular cutouts.",
- new String[] { "ImageryLayer", "Cutouts" }, store);
- }
-
- @Override
- public void buildPanel() {
- TileMapServiceImageryProviderOptions tmsOptions = new TileMapServiceImageryProviderOptions();
- tmsOptions.url = Cesium.buildModuleUrl("Assets/Textures/NaturalEarthII");
- ViewerOptions viewerOptions = new ViewerOptions();
- viewerOptions.imageryProvider = new TileMapServiceImageryProvider(tmsOptions);
- viewerOptions.baseLayerPicker = false;
-
- csVPanel = new ViewerPanel(viewerOptions);
-
- csVPanel.addHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent clickEvent) {
- csVPanel.getViewer().canvas().focus();
- }
- }, ClickEvent.getType());
-
- csVPanel.getViewer().canvas().setAttribute("tabindex", "0");
-
- Rectangle defaultImageryLayerCutout = Rectangle.fromDegrees(-90, 20, -70, 40);
-
- // Cut a rectangle out of the base layer
- ImageryLayerCollection layers = csVPanel.getViewer().imageryLayers();
- ImageryLayer imageryBaseLayer = layers.get(0);
-
- imageryBaseLayer.cutoutRectangle = defaultImageryLayerCutout;
-
- // Fit a SingleTileImageryProvider inside the cutout on the lowest layer
- SingleTileImageryProviderOptions singleTileImageryProviderOptions = new SingleTileImageryProviderOptions();
- singleTileImageryProviderOptions.url = GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png";
- singleTileImageryProviderOptions.rectangle = defaultImageryLayerCutout;
- layers.addImageryProvider(new SingleTileImageryProvider(singleTileImageryProviderOptions));
-
- // Add an Earth at Night layer and a "traveling" cutout
- final ImageryLayer earthAtNight = layers
- .addImageryProvider(new IonImageryProvider(IonImageryProviderOptions.create(3812)));
- earthAtNight.cutoutRectangle = Rectangle.fromDegrees(-100, 10, -60, 50);
- earthAtNight.alpha = 0.9f;
-
- RootPanel.get().addDomHandler(new KeyDownHandler() {
- @Override
- public void onKeyDown(KeyDownEvent keyDownEvent) {
- setFlag(keyDownEvent.getNativeKeyCode(), true);
- }
- }, KeyDownEvent.getType());
-
- RootPanel.get().addDomHandler(new KeyUpHandler() {
- @Override
- public void onKeyUp(KeyUpEvent keyUpEvent) {
- setFlag(keyUpEvent.getNativeKeyCode(), false);
- }
- }, KeyUpEvent.getType());
-
- csVPanel.getViewer().clock().onTick.addEventListener(new Event.Listener() {
- @Override
- public void function(Object... o) {
- Rectangle travelingRectangle = earthAtNight.cutoutRectangle;
- if (flags.moveNorth && travelingRectangle.north + moveIncrement < Math.PI_OVER_TWO()) {
- travelingRectangle.north += moveIncrement;
- travelingRectangle.south += moveIncrement;
+
+ private String getFlagForKeyCode(int keyCode) {
+ if ("W".codePointAt(0) == keyCode) {
+ return "moveNorth";
+ } else if ("S".codePointAt(0) == keyCode) {
+ return "moveSouth";
+ } else if ("D".codePointAt(0) == keyCode) {
+ return "moveEast";
+ } else if ("A".codePointAt(0) == keyCode) {
+ return "moveWest";
+ } else {
+ return null;
}
- if (flags.moveSouth && travelingRectangle.south - moveIncrement > -Math.PI_OVER_TWO()) {
- travelingRectangle.north -= moveIncrement;
- travelingRectangle.south -= moveIncrement;
+ }
+
+ private void setFlag(int keyCode, boolean flag) {
+ String flagName = getFlagForKeyCode(keyCode);
+ if (flagName != null) {
+ if (flagName.equalsIgnoreCase("moveNorth")) {
+ flags.moveNorth = flag;
+ } else if (flagName.equalsIgnoreCase("moveSouth")) {
+ flags.moveSouth = flag;
+ } else if (flagName.equalsIgnoreCase("moveEast")) {
+ flags.moveEast = flag;
+ } else if (flagName.equalsIgnoreCase("moveWest")) {
+ flags.moveWest = flag;
+ }
}
- if (flags.moveEast) {
- travelingRectangle.east += moveIncrement;
- travelingRectangle.west += moveIncrement;
+ }
+
+ private double wrapLongitude(double value) {
+ if (value < -Math.PI()) {
+ return value + Math.TWO_PI();
}
- if (flags.moveWest) {
- travelingRectangle.east -= moveIncrement;
- travelingRectangle.west -= moveIncrement;
+ if (value > Math.PI()) {
+ return value - Math.TWO_PI();
}
- travelingRectangle.east = wrapLongitude(travelingRectangle.east);
- travelingRectangle.west = wrapLongitude(travelingRectangle.west);
- }
- });
-
- HTML html = new HTML();
- html.setHTML("");
- html.getElement().getStyle().setColor("white");
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(html, 20, 20);
-
- contentPanel.add(new HTML("Demonstration of imagery layers with rectangular cutouts.
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ImageryCutout.txt";
- return sourceCodeURLs;
- }
-
- private String getFlagForKeyCode(int keyCode) {
- if ("W".codePointAt(0) == keyCode) {
- return "moveNorth";
- } else if ("S".codePointAt(0) == keyCode) {
- return "moveSouth";
- } else if ("D".codePointAt(0) == keyCode) {
- return "moveEast";
- } else if ("A".codePointAt(0) == keyCode) {
- return "moveWest";
- } else {
- return null;
+ return value;
}
- }
-
- private void setFlag(int keyCode, boolean flag) {
- String flagName = getFlagForKeyCode(keyCode);
- if (flagName != null) {
- if (flagName.equalsIgnoreCase("moveNorth")) {
- flags.moveNorth = flag;
- } else if (flagName.equalsIgnoreCase("moveSouth")) {
- flags.moveSouth = flag;
- } else if (flagName.equalsIgnoreCase("moveEast")) {
- flags.moveEast = flag;
- } else if (flagName.equalsIgnoreCase("moveWest")) {
- flags.moveWest = flag;
- }
- }
- }
- private double wrapLongitude(double value) {
- if (value < -Math.PI()) {
- return value + Math.TWO_PI();
- }
- if (value > Math.PI()) {
- return value - Math.TWO_PI();
+ private class Flags {
+ boolean moveEast = false;
+ boolean moveWest = false;
+ boolean moveNorth = false;
+ boolean moveSouth = false;
+
+ public Flags() {
+ }
}
- return value;
- }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryLayers.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryLayers.java
index 8c413385d210d19769290585564d565f20592b47..9be6c297f7843ffc6c8d735179f3a0aa3802786d 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryLayers.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryLayers.java
@@ -16,11 +16,8 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.HTML;
-
import org.cesiumjs.cs.collections.ImageryLayerCollection;
import org.cesiumjs.cs.core.Credit;
import org.cesiumjs.cs.core.Rectangle;
@@ -36,50 +33,52 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class ImageryLayers extends AbstractExample {
- @Inject
- public ImageryLayers(ShowcaseExampleStore store) {
- super("Imagery Layers", "Create imagery layers from multiple sources",
- new String[] { "Showcase", "Cesium", "3d", "Viewer" }, store);
- }
+ @Inject
+ public ImageryLayers(ShowcaseExampleStore store) {
+ super("Imagery Layers", "Create imagery layers from multiple sources",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer"}, store);
+ }
- @Override
- public void buildPanel() {
- ViewerOptions viewerOptions = new ViewerOptions();
- ArcGisMapServerImageryProviderOptions arcGisMapServerImageryProviderOptions = new ArcGisMapServerImageryProviderOptions();
- arcGisMapServerImageryProviderOptions.url = "https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
- viewerOptions.imageryProvider = new ArcGisMapServerImageryProvider(arcGisMapServerImageryProviderOptions);
- viewerOptions.baseLayerPicker = false;
- ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
+ @Override
+ public void buildPanel() {
+ ViewerOptions viewerOptions = new ViewerOptions();
+ ArcGisMapServerImageryProviderOptions arcGisMapServerImageryProviderOptions = new ArcGisMapServerImageryProviderOptions();
+ arcGisMapServerImageryProviderOptions.url = "https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
+ viewerOptions.imageryProvider = new ArcGisMapServerImageryProvider(arcGisMapServerImageryProviderOptions);
+ viewerOptions.baseLayerPicker = false;
+ ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
- ImageryLayerCollection layers = csVPanel.getViewer().imageryLayers();
- TileMapServiceImageryProviderOptions tileMapServiceImageryProviderOptions = new TileMapServiceImageryProviderOptions();
- tileMapServiceImageryProviderOptions.url = "https://cesiumjs.org/blackmarble";
- tileMapServiceImageryProviderOptions.credit = Credit.create("Black Marble imagery courtesy NASA Earth Observatory");
- tileMapServiceImageryProviderOptions.flipXY = true;
- ImageryLayer blackMarble = layers
- .addImageryProvider(new TileMapServiceImageryProvider(tileMapServiceImageryProviderOptions));
- blackMarble.alpha = 0.5f;
- blackMarble.brightness = 2.0f;
+ ImageryLayerCollection layers = csVPanel.getViewer().imageryLayers();
+ TileMapServiceImageryProviderOptions tileMapServiceImageryProviderOptions = new TileMapServiceImageryProviderOptions();
+ tileMapServiceImageryProviderOptions.url = "https://cesiumjs.org/blackmarble";
+ tileMapServiceImageryProviderOptions.credit = Credit.create("Black Marble imagery courtesy NASA Earth Observatory");
+ tileMapServiceImageryProviderOptions.flipXY = true;
+ ImageryLayer blackMarble = layers
+ .addImageryProvider(new TileMapServiceImageryProvider(tileMapServiceImageryProviderOptions));
+ blackMarble.alpha = 0.5f;
+ blackMarble.brightness = 2.0f;
- SingleTileImageryProviderOptions singleTileImageryProviderOptions = new SingleTileImageryProviderOptions();
- singleTileImageryProviderOptions.url = GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png";
- singleTileImageryProviderOptions.rectangle = Rectangle.fromDegrees(-75.0, 28.0, -67.0, 29.75);
- layers.addImageryProvider(new SingleTileImageryProvider(singleTileImageryProviderOptions));
+ SingleTileImageryProviderOptions singleTileImageryProviderOptions = new SingleTileImageryProviderOptions();
+ singleTileImageryProviderOptions.url = GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png";
+ singleTileImageryProviderOptions.rectangle = Rectangle.fromDegrees(-75.0, 28.0, -67.0, 29.75);
+ layers.addImageryProvider(new SingleTileImageryProvider(singleTileImageryProviderOptions));
- contentPanel.add(new HTML("Create imagery layers from multiple sources.
"));
- contentPanel.add(csVPanel);
+ contentPanel.add(new HTML("Create imagery layers from multiple sources.
"));
+ contentPanel.add(csVPanel);
- initWidget(contentPanel);
- }
+ initWidget(contentPanel);
+ }
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ImageryLayers.txt";
- return sourceCodeURLs;
- }
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ImageryLayers.txt";
+ return sourceCodeURLs;
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryLayersManipulation.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryLayersManipulation.java
index fbe56438677103eb7f8a0151eded703def240864..5d9e8388eb328f33bfc9cd55dec0b49f1e4c2aa5 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryLayersManipulation.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryLayersManipulation.java
@@ -16,46 +16,18 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.inject.Inject;
-
import com.google.gwt.core.client.Callback;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.HasVerticalAlignment;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.ListBox;
-
+import com.google.gwt.user.client.ui.*;
import org.cesiumjs.cs.collections.ImageryLayerCollection;
import org.cesiumjs.cs.core.Credit;
import org.cesiumjs.cs.core.Rectangle;
import org.cesiumjs.cs.scene.ImageryLayer;
import org.cesiumjs.cs.scene.WebMapServiceParameters;
-import org.cesiumjs.cs.scene.providers.ArcGisMapServerImageryProvider;
-import org.cesiumjs.cs.scene.providers.BingMapsImageryProvider;
-import org.cesiumjs.cs.scene.providers.BingMapsStyle;
-import org.cesiumjs.cs.scene.providers.GridImageryProvider;
-import org.cesiumjs.cs.scene.providers.ImageryProvider;
-import org.cesiumjs.cs.scene.providers.OpenStreetMapImageryProvider;
-import org.cesiumjs.cs.scene.providers.SingleTileImageryProvider;
-import org.cesiumjs.cs.scene.providers.TileCoordinatesImageryProvider;
-import org.cesiumjs.cs.scene.providers.TileMapServiceImageryProvider;
-import org.cesiumjs.cs.scene.providers.WebMapServiceImageryProvider;
-import org.cesiumjs.cs.scene.providers.WebMapTileServiceImageryProvider;
-import org.cesiumjs.cs.scene.providers.options.ArcGisMapServerImageryProviderOptions;
-import org.cesiumjs.cs.scene.providers.options.BingMapsImageryProviderOptions;
-import org.cesiumjs.cs.scene.providers.options.OpenStreetMapImageryProviderOptions;
-import org.cesiumjs.cs.scene.providers.options.SingleTileImageryProviderOptions;
-import org.cesiumjs.cs.scene.providers.options.TileMapServiceImageryProviderOptions;
-import org.cesiumjs.cs.scene.providers.options.WebMapServiceImageryProviderOptions;
-import org.cesiumjs.cs.scene.providers.options.WebMapTileServiceImageryProviderOptions;
+import org.cesiumjs.cs.scene.providers.*;
+import org.cesiumjs.cs.scene.providers.options.*;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
@@ -64,240 +36,246 @@ import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
/**
* @author Serge Silaev aka iSergio
*/
public class ImageryLayersManipulation extends AbstractExample {
- private ImageryLayerCollection imageryLayers;
- private List layers = new ArrayList<>();
- private HashMap baseLayers = new HashMap<>();
- private HashMap additionalLayers = new HashMap<>();
- private ImageryLayer selectedLayer;
-
- private Callback _callback;
-
- @Inject
- public ImageryLayersManipulation(ShowcaseExampleStore store) {
- super("Imagery Layers Manipulation",
- "Layer imagery from multiple sources, including WMS servers, Bing Maps, ArcGIS Online, OpenStreetMaps, and more, and adjust the alpha of each independently",
- new String[] { "Showcase", "Cesium", "3d", "Viewer" }, store);
- }
-
- @Override
- public void buildPanel() {
- ViewerOptions viewerOptions = new ViewerOptions();
- viewerOptions.baseLayerPicker = false;
- ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
-
- imageryLayers = csVPanel.getViewer().imageryLayers();
-
- setupLayers();
- updateLayerList();
-
- _callback.onSuccess(null);
-
- HorizontalPanel baseLayersHPanel = new HorizontalPanel();
- baseLayersHPanel.setSpacing(5);
- baseLayersHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
- baseLayersHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
-
- final ListBox baseLayersLBox = new ListBox();
- baseLayersHPanel.add(baseLayersLBox);
-
- Slider baseLayersSlider = new Slider("baseLayersAlpha", 0, 100, 100);
- baseLayersSlider.setWidth("200px");
- baseLayersSlider.addListener(new MSliderListener());
- baseLayersHPanel.add(baseLayersSlider);
-
- baseLayersLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent changeEvent) {
- ListBox source = (ListBox) changeEvent.getSource();
- ImageryLayer baseLayer = baseLayers.get(source.getSelectedValue());
-
- int activeLayerIndex = 0;
- int numLayers = layers.size();
- for (int i = 0; i < numLayers; ++i) {
- if (baseLayers.containsValue(layers.get(i))) {
- activeLayerIndex = i;
- }
- }
- ImageryLayer activeLayer = layers.get(activeLayerIndex);
- float alpha = activeLayer.alpha;
- boolean show = activeLayer.show;
- imageryLayers.remove(activeLayer, false);
- imageryLayers.add(baseLayer, numLayers - activeLayerIndex - 1);
- baseLayer.show = show;
- baseLayer.alpha = alpha;
- updateLayerList();
+ private ImageryLayerCollection imageryLayers;
+ private final List layers = new ArrayList<>();
+ private final HashMap baseLayers = new HashMap<>();
+ private final HashMap additionalLayers = new HashMap<>();
+ private ImageryLayer selectedLayer;
+
+ private Callback _callback;
+
+ @Inject
+ public ImageryLayersManipulation(ShowcaseExampleStore store) {
+ super("Imagery Layers Manipulation",
+ "Layer imagery from multiple sources, including WMS servers, Bing Maps, ArcGIS Online, OpenStreetMaps, and more, and adjust the alpha of each independently",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer"}, store);
+ }
- selectedLayer = baseLayer;
- }
- });
+ @Override
+ public void buildPanel() {
+ ViewerOptions viewerOptions = new ViewerOptions();
+ viewerOptions.baseLayerPicker = false;
+ ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
- Callback cesiumCreated = new Callback() {
- @Override
- public void onFailure(Void aVoid) {
- //
- }
+ imageryLayers = csVPanel.getViewer().imageryLayers();
- @Override
- public void onSuccess(Void aVoid) {
- for (Map.Entry entry : baseLayers.entrySet()) {
- baseLayersLBox.addItem(entry.getKey(), entry.getKey());
- }
- }
- };
- addCallback(cesiumCreated);
-
- contentPanel.add(new HTML(
- "Layer imagery from multiple sources, including WMS servers, Bing Maps, ArcGIS Online, OpenStreetMaps, and more, and adjust the alpha of each independently.
"));
- contentPanel.add(baseLayersHPanel);
- contentPanel.add(csVPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ImageryLayersManipulation.txt";
- return sourceCodeURLs;
- }
-
- private class MSliderListener implements SliderListener {
- @Override
- public void onStart(SliderEvent e) {
+ setupLayers();
+ updateLayerList();
+ _callback.onSuccess(null);
+
+ HorizontalPanel baseLayersHPanel = new HorizontalPanel();
+ baseLayersHPanel.setSpacing(5);
+ baseLayersHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+ baseLayersHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+
+ final ListBox baseLayersLBox = new ListBox();
+ baseLayersHPanel.add(baseLayersLBox);
+
+ Slider baseLayersSlider = new Slider("baseLayersAlpha", 0, 100, 100);
+ baseLayersSlider.setWidth("200px");
+ baseLayersSlider.addListener(new MSliderListener());
+ baseLayersHPanel.add(baseLayersSlider);
+
+ baseLayersLBox.addChangeHandler(new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent changeEvent) {
+ ListBox source = (ListBox) changeEvent.getSource();
+ ImageryLayer baseLayer = baseLayers.get(source.getSelectedValue());
+
+ int activeLayerIndex = 0;
+ int numLayers = layers.size();
+ for (int i = 0; i < numLayers; ++i) {
+ if (baseLayers.containsValue(layers.get(i))) {
+ activeLayerIndex = i;
+ }
+ }
+ ImageryLayer activeLayer = layers.get(activeLayerIndex);
+ float alpha = activeLayer.alpha;
+ boolean show = activeLayer.show;
+ imageryLayers.remove(activeLayer, false);
+ imageryLayers.add(baseLayer, numLayers - activeLayerIndex - 1);
+ baseLayer.show = show;
+ baseLayer.alpha = alpha;
+ updateLayerList();
+
+ selectedLayer = baseLayer;
+ }
+ });
+
+ Callback cesiumCreated = new Callback() {
+ @Override
+ public void onFailure(Void aVoid) {
+ //
+ }
+
+ @Override
+ public void onSuccess(Void aVoid) {
+ for (Map.Entry entry : baseLayers.entrySet()) {
+ baseLayersLBox.addItem(entry.getKey(), entry.getKey());
+ }
+ }
+ };
+ addCallback(cesiumCreated);
+
+ contentPanel.add(new HTML(
+ "Layer imagery from multiple sources, including WMS servers, Bing Maps, ArcGIS Online, OpenStreetMaps, and more, and adjust the alpha of each independently.
"));
+ contentPanel.add(baseLayersHPanel);
+ contentPanel.add(csVPanel);
+
+ initWidget(contentPanel);
}
@Override
- public boolean onSlide(SliderEvent e) {
- Slider source = e.getSource();
- selectedLayer.alpha = (float) source.getValue() / 100.0f;
- return true;
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ImageryLayersManipulation.txt";
+ return sourceCodeURLs;
}
- @Override
- public void onChange(SliderEvent e) {
-
+ private void setupLayers() {
+ addBaseLayerOption("Bing Maps Aerial", null);
+
+ BingMapsImageryProviderOptions bingMapsImageryProviderOptions = new BingMapsImageryProviderOptions();
+ bingMapsImageryProviderOptions.url = "https://dev.virtualearth.net";
+ bingMapsImageryProviderOptions.mapStyle = BingMapsStyle.ROAD();
+ addBaseLayerOption("Bing Maps Road", new BingMapsImageryProvider(bingMapsImageryProviderOptions));
+
+ ArcGisMapServerImageryProviderOptions arcGisMapServerImageryProviderOptions = new ArcGisMapServerImageryProviderOptions();
+ arcGisMapServerImageryProviderOptions.url = "https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
+ addBaseLayerOption("ArcGIS World Street Maps",
+ new ArcGisMapServerImageryProvider(arcGisMapServerImageryProviderOptions));
+
+ addBaseLayerOption("OpenStreetMaps", new OpenStreetMapImageryProvider());
+
+ OpenStreetMapImageryProviderOptions openStreetMapImageryProviderOptions = new OpenStreetMapImageryProviderOptions();
+ openStreetMapImageryProviderOptions.url = "https://otile1-s.mqcdn.com/tiles/1.0.0/osm/";
+ addBaseLayerOption("MapQuest OpenStreetMaps",
+ new OpenStreetMapImageryProvider(openStreetMapImageryProviderOptions));
+
+ openStreetMapImageryProviderOptions = new OpenStreetMapImageryProviderOptions();
+ openStreetMapImageryProviderOptions.url = "https://stamen-tiles.a.ssl.fastly.net/watercolor/";
+ openStreetMapImageryProviderOptions.fileExtension = "jpg";
+ openStreetMapImageryProviderOptions.credit = Credit
+ .create("Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under CC BY SA.");
+ addBaseLayerOption("Stamen Maps", new OpenStreetMapImageryProvider(openStreetMapImageryProviderOptions));
+
+ TileMapServiceImageryProviderOptions tileMapServiceImageryProviderOptions = new TileMapServiceImageryProviderOptions();
+ tileMapServiceImageryProviderOptions.url = GWT.getModuleBaseURL()
+ + "JavaScript/Cesium/Assets/Textures/NaturalEarthII";
+ addBaseLayerOption("Natural Earth II (local)",
+ new TileMapServiceImageryProvider(tileMapServiceImageryProviderOptions));
+
+ WebMapTileServiceImageryProviderOptions webMapTileServiceImageryProviderOptions = new WebMapTileServiceImageryProviderOptions();
+ webMapTileServiceImageryProviderOptions.url = "http://basemap.nationalmap.gov/arcgis/rest/services/USGSShadedReliefOnly/MapServer/WMTS";
+ webMapTileServiceImageryProviderOptions.layer = "USGSShadedReliefOnly";
+ webMapTileServiceImageryProviderOptions.style = "default";
+ webMapTileServiceImageryProviderOptions.format = "image/jpeg";
+ webMapTileServiceImageryProviderOptions.tileMatrixSetID = "default028mm";
+ webMapTileServiceImageryProviderOptions.maximumLevel = 19;
+ webMapTileServiceImageryProviderOptions.credit = Credit.create("U. S. Geological Survey");
+ addBaseLayerOption("USGS Shaded Relief (via WMTS)",
+ new WebMapTileServiceImageryProvider(webMapTileServiceImageryProviderOptions));
+
+ WebMapServiceParameters parameters = new WebMapServiceParameters();
+ parameters.format = "image/png";
+ parameters.transparent = true;
+ WebMapServiceImageryProviderOptions webMapServiceImageryProviderOptions = new WebMapServiceImageryProviderOptions();
+ webMapServiceImageryProviderOptions.url = "https://mesonet.agron.iastate.edu/cgi-bin/wms/goes/conus_ir.cgi?";
+ webMapServiceImageryProviderOptions.layers = "goes_conus_ir";
+ webMapServiceImageryProviderOptions.credit = Credit.create("Infrared data courtesy Iowa Environmental Mesonet");
+ webMapServiceImageryProviderOptions.parameters = parameters;
+ addAdditionalLayerOption("United States GOES Infrared",
+ new WebMapServiceImageryProvider(webMapServiceImageryProviderOptions), 1, true);
+
+ parameters = new WebMapServiceParameters();
+ parameters.format = "image/png";
+ parameters.transparent = true;
+ webMapServiceImageryProviderOptions = new WebMapServiceImageryProviderOptions();
+ webMapServiceImageryProviderOptions.url = "https://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi?";
+ webMapServiceImageryProviderOptions.layers = "nexrad-n0r";
+ webMapServiceImageryProviderOptions.credit = Credit.create("Radar data courtesy Iowa Environmental Mesonet");
+ webMapServiceImageryProviderOptions.parameters = parameters;
+ addAdditionalLayerOption("United States GOES Infrared",
+ new WebMapServiceImageryProvider(webMapServiceImageryProviderOptions), 1, true);
+
+ tileMapServiceImageryProviderOptions = new TileMapServiceImageryProviderOptions();
+ tileMapServiceImageryProviderOptions.url = GWT.getModuleBaseURL() + "images/cesium_maptiler/Cesium_Logo_Color";
+ addAdditionalLayerOption("TileMapService Image",
+ new TileMapServiceImageryProvider(tileMapServiceImageryProviderOptions), 0.2f, true);
+
+ SingleTileImageryProviderOptions singleTileImageryProviderOptions = new SingleTileImageryProviderOptions();
+ singleTileImageryProviderOptions.url = GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png";
+ singleTileImageryProviderOptions.rectangle = Rectangle.fromDegrees(-115.0, 38.0, -107, 39.75);
+ addAdditionalLayerOption("Single Image", new SingleTileImageryProvider(singleTileImageryProviderOptions), 1.0f,
+ true);
+
+ addAdditionalLayerOption("Grid", new GridImageryProvider(), 1.0f, false);
+
+ addAdditionalLayerOption("Tile Coordinates", new TileCoordinatesImageryProvider(), 1.0f, false);
}
- @Override
- public void onStop(SliderEvent e) {
+ private void addBaseLayerOption(String name, ImageryProvider imageryProvider) {
+ ImageryLayer layer = null;
+ if (imageryProvider == null) {
+ layer = imageryLayers.get(0);
+ selectedLayer = layer;
+ } else {
+ layer = new ImageryLayer(imageryProvider);
+ }
+ baseLayers.put(name, layer);
+ }
+ private void addAdditionalLayerOption(String name, ImageryProvider imageryProvider, float alpha, boolean show) {
+ ImageryLayer layer = imageryLayers.addImageryProvider(imageryProvider);
+ layer.alpha = alpha;
+ layer.show = show;
+ additionalLayers.put(name, layer);
}
- }
-
- private void setupLayers() {
- addBaseLayerOption("Bing Maps Aerial", null);
-
- BingMapsImageryProviderOptions bingMapsImageryProviderOptions = new BingMapsImageryProviderOptions();
- bingMapsImageryProviderOptions.url = "https://dev.virtualearth.net";
- bingMapsImageryProviderOptions.mapStyle = BingMapsStyle.ROAD();
- addBaseLayerOption("Bing Maps Road", new BingMapsImageryProvider(bingMapsImageryProviderOptions));
-
- ArcGisMapServerImageryProviderOptions arcGisMapServerImageryProviderOptions = new ArcGisMapServerImageryProviderOptions();
- arcGisMapServerImageryProviderOptions.url = "https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
- addBaseLayerOption("ArcGIS World Street Maps",
- new ArcGisMapServerImageryProvider(arcGisMapServerImageryProviderOptions));
-
- addBaseLayerOption("OpenStreetMaps", new OpenStreetMapImageryProvider());
-
- OpenStreetMapImageryProviderOptions openStreetMapImageryProviderOptions = new OpenStreetMapImageryProviderOptions();
- openStreetMapImageryProviderOptions.url = "https://otile1-s.mqcdn.com/tiles/1.0.0/osm/";
- addBaseLayerOption("MapQuest OpenStreetMaps",
- new OpenStreetMapImageryProvider(openStreetMapImageryProviderOptions));
-
- openStreetMapImageryProviderOptions = new OpenStreetMapImageryProviderOptions();
- openStreetMapImageryProviderOptions.url = "https://stamen-tiles.a.ssl.fastly.net/watercolor/";
- openStreetMapImageryProviderOptions.fileExtension = "jpg";
- openStreetMapImageryProviderOptions.credit = Credit
- .create("Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under CC BY SA.");
- addBaseLayerOption("Stamen Maps", new OpenStreetMapImageryProvider(openStreetMapImageryProviderOptions));
-
- TileMapServiceImageryProviderOptions tileMapServiceImageryProviderOptions = new TileMapServiceImageryProviderOptions();
- tileMapServiceImageryProviderOptions.url = GWT.getModuleBaseURL()
- + "JavaScript/Cesium/Assets/Textures/NaturalEarthII";
- addBaseLayerOption("Natural Earth II (local)",
- new TileMapServiceImageryProvider(tileMapServiceImageryProviderOptions));
-
- WebMapTileServiceImageryProviderOptions webMapTileServiceImageryProviderOptions = new WebMapTileServiceImageryProviderOptions();
- webMapTileServiceImageryProviderOptions.url = "http://basemap.nationalmap.gov/arcgis/rest/services/USGSShadedReliefOnly/MapServer/WMTS";
- webMapTileServiceImageryProviderOptions.layer = "USGSShadedReliefOnly";
- webMapTileServiceImageryProviderOptions.style = "default";
- webMapTileServiceImageryProviderOptions.format = "image/jpeg";
- webMapTileServiceImageryProviderOptions.tileMatrixSetID = "default028mm";
- webMapTileServiceImageryProviderOptions.maximumLevel = 19;
- webMapTileServiceImageryProviderOptions.credit = Credit.create("U. S. Geological Survey");
- addBaseLayerOption("USGS Shaded Relief (via WMTS)",
- new WebMapTileServiceImageryProvider(webMapTileServiceImageryProviderOptions));
-
- WebMapServiceParameters parameters = new WebMapServiceParameters();
- parameters.format = "image/png";
- parameters.transparent = true;
- WebMapServiceImageryProviderOptions webMapServiceImageryProviderOptions = new WebMapServiceImageryProviderOptions();
- webMapServiceImageryProviderOptions.url = "https://mesonet.agron.iastate.edu/cgi-bin/wms/goes/conus_ir.cgi?";
- webMapServiceImageryProviderOptions.layers = "goes_conus_ir";
- webMapServiceImageryProviderOptions.credit = Credit.create("Infrared data courtesy Iowa Environmental Mesonet");
- webMapServiceImageryProviderOptions.parameters = parameters;
- addAdditionalLayerOption("United States GOES Infrared",
- new WebMapServiceImageryProvider(webMapServiceImageryProviderOptions), 1, true);
-
- parameters = new WebMapServiceParameters();
- parameters.format = "image/png";
- parameters.transparent = true;
- webMapServiceImageryProviderOptions = new WebMapServiceImageryProviderOptions();
- webMapServiceImageryProviderOptions.url = "https://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi?";
- webMapServiceImageryProviderOptions.layers = "nexrad-n0r";
- webMapServiceImageryProviderOptions.credit = Credit.create("Radar data courtesy Iowa Environmental Mesonet");
- webMapServiceImageryProviderOptions.parameters = parameters;
- addAdditionalLayerOption("United States GOES Infrared",
- new WebMapServiceImageryProvider(webMapServiceImageryProviderOptions), 1, true);
-
- tileMapServiceImageryProviderOptions = new TileMapServiceImageryProviderOptions();
- tileMapServiceImageryProviderOptions.url = GWT.getModuleBaseURL() + "images/cesium_maptiler/Cesium_Logo_Color";
- addAdditionalLayerOption("TileMapService Image",
- new TileMapServiceImageryProvider(tileMapServiceImageryProviderOptions), 0.2f, true);
-
- SingleTileImageryProviderOptions singleTileImageryProviderOptions = new SingleTileImageryProviderOptions();
- singleTileImageryProviderOptions.url = GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png";
- singleTileImageryProviderOptions.rectangle = Rectangle.fromDegrees(-115.0, 38.0, -107, 39.75);
- addAdditionalLayerOption("Single Image", new SingleTileImageryProvider(singleTileImageryProviderOptions), 1.0f,
- true);
-
- addAdditionalLayerOption("Grid", new GridImageryProvider(), 1.0f, false);
-
- addAdditionalLayerOption("Tile Coordinates", new TileCoordinatesImageryProvider(), 1.0f, false);
- }
-
- private void addBaseLayerOption(String name, ImageryProvider imageryProvider) {
- ImageryLayer layer = null;
- if (imageryProvider == null) {
- layer = imageryLayers.get(0);
- selectedLayer = layer;
- } else {
- layer = new ImageryLayer(imageryProvider);
+
+ private void updateLayerList() {
+ int numLayers = imageryLayers.length();
+ layers.clear();
+ for (int i = numLayers - 1; i >= 0; --i) {
+ layers.add(imageryLayers.get(i));
+ }
}
- baseLayers.put(name, layer);
- }
-
- private void addAdditionalLayerOption(String name, ImageryProvider imageryProvider, float alpha, boolean show) {
- ImageryLayer layer = imageryLayers.addImageryProvider(imageryProvider);
- layer.alpha = alpha;
- layer.show = show;
- additionalLayers.put(name, layer);
- }
-
- private void updateLayerList() {
- int numLayers = imageryLayers.length();
- layers.clear();
- for (int i = numLayers - 1; i >= 0; --i) {
- layers.add(imageryLayers.get(i));
+
+ public void addCallback(Callback callback) {
+ _callback = callback;
}
- }
- public void addCallback(Callback callback) {
- _callback = callback;
- }
+ private class MSliderListener implements SliderListener {
+ @Override
+ public void onStart(SliderEvent e) {
+
+ }
+
+ @Override
+ public boolean onSlide(SliderEvent e) {
+ Slider source = e.getSource();
+ selectedLayer.alpha = (float) source.getValue() / 100.0f;
+ return true;
+ }
+
+ @Override
+ public void onChange(SliderEvent e) {
+
+ }
+
+ @Override
+ public void onStop(SliderEvent e) {
+
+ }
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryLayersSplit.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryLayersSplit.java
index ebd6eee014d78d1691566ee9ffedbcef4c1c9316..4742a2127a690f5d3a7c615d58d6e000ac694c49 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryLayersSplit.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryLayersSplit.java
@@ -42,73 +42,73 @@ import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
*/
public class ImageryLayersSplit extends AbstractExample {
- @Inject
- public ImageryLayersSplit(ShowcaseExampleStore store) {
- super("Imagery Layers Split", "Use the split property to only show layers on one side of a slider.",
- new String[] { "Showcase", "Cesium", "3d", "Viewer", "Slider", "Split" }, store);
- }
-
- @Override
- public void buildPanel() {
- ViewerOptions viewerOptions = new ViewerOptions();
- viewerOptions.imageryProvider = ArcGisMapServerImageryProvider
- .create("https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
- viewerOptions.baseLayerPicker = false;
- final ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
-
- ImageryLayerCollection layers = csVPanel.getViewer().imageryLayers();
- TileMapServiceImageryProviderOptions tileMapServiceImageryProviderOptions = new TileMapServiceImageryProviderOptions();
- tileMapServiceImageryProviderOptions.url = "https://cesiumjs.org/blackmarble";
- tileMapServiceImageryProviderOptions.credit = Credit.create("Black Marble imagery courtesy NASA Earth Observatory");
- tileMapServiceImageryProviderOptions.flipXY = true;
- ImageryLayer blackMarble = layers
- .addImageryProvider(new TileMapServiceImageryProvider(tileMapServiceImageryProviderOptions));
- blackMarble.splitDirection = ImagerySplitDirection.LEFT();
-
- csVPanel.getViewer().scene().imagerySplitPosition = 0.5;
-
- Slider slider = new Slider("Slider", 0, 100, 50);
- slider.setStep(1);
- slider.setWidth("100%");
- slider.addListener(new SliderListener() {
- @Override
- public void onStart(SliderEvent e) {
- //
- }
-
- @Override
- public boolean onSlide(SliderEvent e) {
- Slider source = e.getSource();
- double value = source.getValue() / 100.;
- csVPanel.getViewer().scene().imagerySplitPosition = value;
- return true;
- }
-
- @Override
- public void onChange(SliderEvent e) {
- //
- }
-
- @Override
- public void onStop(SliderEvent e) {
- //
- }
- });
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(slider, 0, 5);
-
- contentPanel.add(aPanel);
- contentPanel.add(new HTML("Use the split property to only show layers on one side of a slider.
"));
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ImageryLayersSplit.txt";
- return sourceCodeURLs;
- }
+ @Inject
+ public ImageryLayersSplit(ShowcaseExampleStore store) {
+ super("Imagery Layers Split", "Use the split property to only show layers on one side of a slider.",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer", "Slider", "Split"}, store);
+ }
+
+ @Override
+ public void buildPanel() {
+ ViewerOptions viewerOptions = new ViewerOptions();
+ viewerOptions.imageryProvider = ArcGisMapServerImageryProvider
+ .create("https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
+ viewerOptions.baseLayerPicker = false;
+ final ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
+
+ ImageryLayerCollection layers = csVPanel.getViewer().imageryLayers();
+ TileMapServiceImageryProviderOptions tileMapServiceImageryProviderOptions = new TileMapServiceImageryProviderOptions();
+ tileMapServiceImageryProviderOptions.url = "https://cesiumjs.org/blackmarble";
+ tileMapServiceImageryProviderOptions.credit = Credit.create("Black Marble imagery courtesy NASA Earth Observatory");
+ tileMapServiceImageryProviderOptions.flipXY = true;
+ ImageryLayer blackMarble = layers
+ .addImageryProvider(new TileMapServiceImageryProvider(tileMapServiceImageryProviderOptions));
+ blackMarble.splitDirection = ImagerySplitDirection.LEFT();
+
+ csVPanel.getViewer().scene().imagerySplitPosition = 0.5;
+
+ Slider slider = new Slider("Slider", 0, 100, 50);
+ slider.setStep(1);
+ slider.setWidth("100%");
+ slider.addListener(new SliderListener() {
+ @Override
+ public void onStart(SliderEvent e) {
+ //
+ }
+
+ @Override
+ public boolean onSlide(SliderEvent e) {
+ Slider source = e.getSource();
+ double value = source.getValue() / 100.;
+ csVPanel.getViewer().scene().imagerySplitPosition = value;
+ return true;
+ }
+
+ @Override
+ public void onChange(SliderEvent e) {
+ //
+ }
+
+ @Override
+ public void onStop(SliderEvent e) {
+ //
+ }
+ });
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(slider, 0, 5);
+
+ contentPanel.add(aPanel);
+ contentPanel.add(new HTML("Use the split property to only show layers on one side of a slider.
"));
+
+ initWidget(contentPanel);
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ImageryLayersSplit.txt";
+ return sourceCodeURLs;
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Interpolation.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Interpolation.java
index 0558e7ec83eea57052a594d2d90de09c7cb928b5..37c7a1fb09cf849bc6ad16989d6bed65bc9ba8c2 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Interpolation.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Interpolation.java
@@ -16,27 +16,15 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.user.client.ui.AbsolutePanel;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HasVerticalAlignment;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.ListBox;
-
+import com.google.gwt.user.client.ui.*;
import org.cesiumjs.cs.collections.TimeIntervalCollection;
-import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.Color;
-import org.cesiumjs.cs.core.HeadingPitchRange;
-import org.cesiumjs.cs.core.JulianDate;
import org.cesiumjs.cs.core.Math;
-import org.cesiumjs.cs.core.TimeInterval;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.core.enums.ClockRange;
import org.cesiumjs.cs.core.interpolation.HermitePolynomialApproximation;
import org.cesiumjs.cs.core.interpolation.LagrangePolynomialApproximation;
@@ -52,12 +40,7 @@ import org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions;
import org.cesiumjs.cs.datasources.graphics.options.PathGraphicsOptions;
import org.cesiumjs.cs.datasources.graphics.options.PointGraphicsOptions;
import org.cesiumjs.cs.datasources.options.EntityOptions;
-import org.cesiumjs.cs.datasources.properties.ConstantPositionProperty;
-import org.cesiumjs.cs.datasources.properties.ConstantProperty;
-import org.cesiumjs.cs.datasources.properties.PolylineGlowMaterialProperty;
-import org.cesiumjs.cs.datasources.properties.PositionProperty;
-import org.cesiumjs.cs.datasources.properties.SampledPositionProperty;
-import org.cesiumjs.cs.datasources.properties.VelocityOrientationProperty;
+import org.cesiumjs.cs.datasources.properties.*;
import org.cesiumjs.cs.datasources.properties.options.PolylineGlowMaterialPropertyOptions;
import org.cesiumjs.cs.datasources.properties.options.SampledPropertyInterpolationOptions;
import org.cesiumjs.cs.js.JsDate;
@@ -67,178 +50,180 @@ import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class Interpolation extends AbstractExample {
- private ViewerPanel csVPanel;
-
- private JulianDate _start;
- private JulianDate _stop;
- private Entity _entity;
-
- @Inject
- public Interpolation(ShowcaseExampleStore store) {
- super("Interpolation", "Interpolation example",
- new String[] { "Showcase", "Cesium", "3d", "Interpolation", "Timeline", "Interval" }, store);
- }
-
- @Override
- public void buildPanel() {
- csVPanel = new ViewerPanel();
-
- csVPanel.getViewer().scene().globe.enableLighting = false;
- CesiumTerrainProviderOptions cesiumTerrainProviderOptions = new CesiumTerrainProviderOptions();
- cesiumTerrainProviderOptions.url = "https://assets.agi.com/stk-terrain/world";
- cesiumTerrainProviderOptions.requestWaterMask = true;
- cesiumTerrainProviderOptions.requestVertexNormals = true;
- csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(cesiumTerrainProviderOptions);
-
- csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;
-
- Math.setRandomNumberSeed(3);
-
- _start = JulianDate.fromDate(new JsDate(2015, 2, 25, 16));
- _stop = JulianDate.addSeconds(_start, 360, new JulianDate());
-
- csVPanel.getViewer().clock().startTime = _start.clone();
- csVPanel.getViewer().clock().stopTime = _stop.clone();
- csVPanel.getViewer().clock().currentTime = _start.clone();
- csVPanel.getViewer().clock().clockRange = ClockRange.LOOP_STOP();
- csVPanel.getViewer().clock().multiplier = 10;
-
- csVPanel.getViewer().timeline().zoomTo(_start, _stop);
-
- PositionProperty position = computeCirclularFlight(-112.110693, 36.0994841, 0.03);
- TimeIntervalOptions timeIntervalOptions = new TimeIntervalOptions();
- timeIntervalOptions.start = _start;
- timeIntervalOptions.stop = _stop;
-
- ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(
- GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.gltf");
- modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(64);
-
- PolylineGlowMaterialPropertyOptions polylineGlowMaterialPropertyOptions = new PolylineGlowMaterialPropertyOptions();
- polylineGlowMaterialPropertyOptions.glowPower = new ConstantProperty<>(0.1);
- polylineGlowMaterialPropertyOptions.color = new ConstantProperty<>(Color.YELLOW());
- PathGraphicsOptions pathGraphicsOptions = new PathGraphicsOptions();
- pathGraphicsOptions.resolution = new ConstantProperty<>(1);
- pathGraphicsOptions.material = new PolylineGlowMaterialProperty(polylineGlowMaterialPropertyOptions);
- pathGraphicsOptions.width = new ConstantProperty<>(10);
-
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.availability = new TimeIntervalCollection(
- new TimeInterval[] { new TimeInterval(timeIntervalOptions) });
- entityOptions.position = position;
- entityOptions.orientation = new VelocityOrientationProperty(position);
- entityOptions.model = new ModelGraphics(modelGraphicsOptions);
- entityOptions.path = new PathGraphics(pathGraphicsOptions);
- _entity = csVPanel.getViewer().entities().add(entityOptions);
-
- ListBox interpolationsLBox = new ListBox();
- interpolationsLBox.addItem("Interpolation: Linear Approximation", "0");
- interpolationsLBox.addItem("Interpolation: Lagrange Polynomial Approximation", "1");
- interpolationsLBox.addItem("Interpolation: Hermite Polynomial Approximation", "2");
- interpolationsLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent changeEvent) {
- ListBox source = (ListBox) changeEvent.getSource();
- SampledPropertyInterpolationOptions sampledPropertyInterpolationOptions = new SampledPropertyInterpolationOptions();
- switch (source.getSelectedValue()) {
- case "0":
- sampledPropertyInterpolationOptions.interpolationDegree = 1;
- sampledPropertyInterpolationOptions.interpolationAlgorithm = LinearApproximation.instance();
- ((SampledPositionProperty) _entity.position).setInterpolationOptions(sampledPropertyInterpolationOptions);
- break;
- case "1":
- sampledPropertyInterpolationOptions.interpolationDegree = 5;
- sampledPropertyInterpolationOptions.interpolationAlgorithm = LagrangePolynomialApproximation.instance();
- ((SampledPositionProperty) _entity.position).setInterpolationOptions(sampledPropertyInterpolationOptions);
- break;
- case "2":
- sampledPropertyInterpolationOptions.interpolationDegree = 2;
- sampledPropertyInterpolationOptions.interpolationAlgorithm = HermitePolynomialApproximation.instance();
- ((SampledPositionProperty) _entity.position).setInterpolationOptions(sampledPropertyInterpolationOptions);
- break;
- default:
- break;
+ private ViewerPanel csVPanel;
+
+ private JulianDate _start;
+ private JulianDate _stop;
+ private Entity _entity;
+
+ @Inject
+ public Interpolation(ShowcaseExampleStore store) {
+ super("Interpolation", "Interpolation example",
+ new String[]{"Showcase", "Cesium", "3d", "Interpolation", "Timeline", "Interval"}, store);
+ }
+
+ @Override
+ public void buildPanel() {
+ csVPanel = new ViewerPanel();
+
+ csVPanel.getViewer().scene().globe.enableLighting = false;
+ CesiumTerrainProviderOptions cesiumTerrainProviderOptions = new CesiumTerrainProviderOptions();
+ cesiumTerrainProviderOptions.url = "https://assets.agi.com/stk-terrain/world";
+ cesiumTerrainProviderOptions.requestWaterMask = true;
+ cesiumTerrainProviderOptions.requestVertexNormals = true;
+ csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(cesiumTerrainProviderOptions);
+
+ csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;
+
+ Math.setRandomNumberSeed(3);
+
+ _start = JulianDate.fromDate(new JsDate(2015, 2, 25, 16));
+ _stop = JulianDate.addSeconds(_start, 360, new JulianDate());
+
+ csVPanel.getViewer().clock().startTime = _start.clone();
+ csVPanel.getViewer().clock().stopTime = _stop.clone();
+ csVPanel.getViewer().clock().currentTime = _start.clone();
+ csVPanel.getViewer().clock().clockRange = ClockRange.LOOP_STOP();
+ csVPanel.getViewer().clock().multiplier = 10;
+
+ csVPanel.getViewer().timeline().zoomTo(_start, _stop);
+
+ PositionProperty position = computeCirclularFlight(-112.110693, 36.0994841, 0.03);
+ TimeIntervalOptions timeIntervalOptions = new TimeIntervalOptions();
+ timeIntervalOptions.start = _start;
+ timeIntervalOptions.stop = _stop;
+
+ ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
+ modelGraphicsOptions.uri = new ConstantProperty<>(
+ GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.gltf");
+ modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(64);
+
+ PolylineGlowMaterialPropertyOptions polylineGlowMaterialPropertyOptions = new PolylineGlowMaterialPropertyOptions();
+ polylineGlowMaterialPropertyOptions.glowPower = new ConstantProperty<>(0.1);
+ polylineGlowMaterialPropertyOptions.color = new ConstantProperty<>(Color.YELLOW());
+ PathGraphicsOptions pathGraphicsOptions = new PathGraphicsOptions();
+ pathGraphicsOptions.resolution = new ConstantProperty<>(1);
+ pathGraphicsOptions.material = new PolylineGlowMaterialProperty(polylineGlowMaterialPropertyOptions);
+ pathGraphicsOptions.width = new ConstantProperty<>(10);
+
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.availability = new TimeIntervalCollection(
+ new TimeInterval[]{new TimeInterval(timeIntervalOptions)});
+ entityOptions.position = position;
+ entityOptions.orientation = new VelocityOrientationProperty(position);
+ entityOptions.model = new ModelGraphics(modelGraphicsOptions);
+ entityOptions.path = new PathGraphics(pathGraphicsOptions);
+ _entity = csVPanel.getViewer().entities().add(entityOptions);
+
+ ListBox interpolationsLBox = new ListBox();
+ interpolationsLBox.addItem("Interpolation: Linear Approximation", "0");
+ interpolationsLBox.addItem("Interpolation: Lagrange Polynomial Approximation", "1");
+ interpolationsLBox.addItem("Interpolation: Hermite Polynomial Approximation", "2");
+ interpolationsLBox.addChangeHandler(new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent changeEvent) {
+ ListBox source = (ListBox) changeEvent.getSource();
+ SampledPropertyInterpolationOptions sampledPropertyInterpolationOptions = new SampledPropertyInterpolationOptions();
+ switch (source.getSelectedValue()) {
+ case "0":
+ sampledPropertyInterpolationOptions.interpolationDegree = 1;
+ sampledPropertyInterpolationOptions.interpolationAlgorithm = LinearApproximation.instance();
+ ((SampledPositionProperty) _entity.position).setInterpolationOptions(sampledPropertyInterpolationOptions);
+ break;
+ case "1":
+ sampledPropertyInterpolationOptions.interpolationDegree = 5;
+ sampledPropertyInterpolationOptions.interpolationAlgorithm = LagrangePolynomialApproximation.instance();
+ ((SampledPositionProperty) _entity.position).setInterpolationOptions(sampledPropertyInterpolationOptions);
+ break;
+ case "2":
+ sampledPropertyInterpolationOptions.interpolationDegree = 2;
+ sampledPropertyInterpolationOptions.interpolationAlgorithm = HermitePolynomialApproximation.instance();
+ ((SampledPositionProperty) _entity.position).setInterpolationOptions(sampledPropertyInterpolationOptions);
+ break;
+ default:
+ break;
+ }
+ }
+ });
+
+ Button viewTopDownBtn = new Button("View Top Down");
+ viewTopDownBtn.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent clickEvent) {
+ Viewer viewer = csVPanel.getViewer();
+ viewer.trackedEntity = (Entity) JsObject.undefined();
+ viewer.zoomTo(viewer.entities(), new HeadingPitchRange(0, Math.toRadians(-90), 0));
+
+ }
+ });
+ Button viewSideBtn = new Button("View Side");
+ viewSideBtn.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent clickEvent) {
+ Viewer viewer = csVPanel.getViewer();
+ viewer.trackedEntity = (Entity) JsObject.undefined();
+ viewer.zoomTo(viewer.entities(), new HeadingPitchRange(Math.toRadians(-90), Math.toRadians(-15), 7500.0));
+ }
+ });
+ Button viewAircraftBtn = new Button("View Aircraft");
+ viewAircraftBtn.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent clickEvent) {
+ Viewer viewer = csVPanel.getViewer();
+ viewer.trackedEntity = _entity;
+ }
+ });
+
+ HorizontalPanel btnHPanel = new HorizontalPanel();
+ btnHPanel.setSpacing(5);
+ btnHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+
+ btnHPanel.add(interpolationsLBox);
+ btnHPanel.add(viewTopDownBtn);
+ btnHPanel.add(viewSideBtn);
+ btnHPanel.add(viewAircraftBtn);
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(btnHPanel, 20, 20);
+
+ contentPanel.add(new HTML("This example shows simple Cesium application
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Interpolation.txt";
+ return sourceCodeURLs;
+ }
+
+ private PositionProperty computeCirclularFlight(double lon, double lat, double radius) {
+ SampledPositionProperty property = new SampledPositionProperty();
+ for (int i = 0; i <= 360; i += 45) {
+ double radians = Math.toRadians(i);
+ JulianDate time = JulianDate.addSeconds(_start, i, new JulianDate());
+ Cartesian3 position = Cartesian3.fromDegrees(lon + (radius * 1.5 * java.lang.Math.cos(radians)),
+ lat + (radius * java.lang.Math.sin(radians)), Math.nextRandomNumber() * 500 + 1750);
+ property.addSample(time, position);
+ PointGraphicsOptions pointGraphicsOptions = new PointGraphicsOptions();
+ pointGraphicsOptions.pixelSize = new ConstantProperty<>(8);
+ pointGraphicsOptions.color = new ConstantProperty<>(Color.TRANSPARENT());
+ pointGraphicsOptions.outlineColor = new ConstantProperty<>(Color.YELLOW());
+ pointGraphicsOptions.outlineWidth = new ConstantProperty<>(3);
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(position);
+ entityOptions.point = new PointGraphics(pointGraphicsOptions);
+ csVPanel.getViewer().entities().add(entityOptions);
}
- }
- });
-
- Button viewTopDownBtn = new Button("View Top Down");
- viewTopDownBtn.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent clickEvent) {
- Viewer viewer = csVPanel.getViewer();
- viewer.trackedEntity = (Entity) JsObject.undefined();
- viewer.zoomTo(viewer.entities(), new HeadingPitchRange(0, Math.toRadians(-90), 0));
-
- }
- });
- Button viewSideBtn = new Button("View Side");
- viewSideBtn.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent clickEvent) {
- Viewer viewer = csVPanel.getViewer();
- viewer.trackedEntity = (Entity) JsObject.undefined();
- viewer.zoomTo(viewer.entities(), new HeadingPitchRange(Math.toRadians(-90), Math.toRadians(-15), 7500.0));
- }
- });
- Button viewAircraftBtn = new Button("View Aircraft");
- viewAircraftBtn.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent clickEvent) {
- Viewer viewer = csVPanel.getViewer();
- viewer.trackedEntity = _entity;
- }
- });
-
- HorizontalPanel btnHPanel = new HorizontalPanel();
- btnHPanel.setSpacing(5);
- btnHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
-
- btnHPanel.add(interpolationsLBox);
- btnHPanel.add(viewTopDownBtn);
- btnHPanel.add(viewSideBtn);
- btnHPanel.add(viewAircraftBtn);
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(btnHPanel, 20, 20);
-
- contentPanel.add(new HTML("This example shows simple Cesium application
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Interpolation.txt";
- return sourceCodeURLs;
- }
-
- private PositionProperty computeCirclularFlight(double lon, double lat, double radius) {
- SampledPositionProperty property = new SampledPositionProperty();
- for (int i = 0; i <= 360; i += 45) {
- double radians = Math.toRadians(i);
- JulianDate time = JulianDate.addSeconds(_start, i, new JulianDate());
- Cartesian3 position = Cartesian3.fromDegrees(lon + (radius * 1.5 * java.lang.Math.cos(radians)),
- lat + (radius * java.lang.Math.sin(radians)), Math.nextRandomNumber() * 500 + 1750);
- property.addSample(time, position);
- PointGraphicsOptions pointGraphicsOptions = new PointGraphicsOptions();
- pointGraphicsOptions.pixelSize = new ConstantProperty<>(8);
- pointGraphicsOptions.color = new ConstantProperty<>(Color.TRANSPARENT());
- pointGraphicsOptions.outlineColor = new ConstantProperty<>(Color.YELLOW());
- pointGraphicsOptions.outlineWidth = new ConstantProperty<>(3);
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(position);
- entityOptions.point = new PointGraphics(pointGraphicsOptions);
- csVPanel.getViewer().entities().add(entityOptions);
+ return property;
}
- return property;
- }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/KML.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/KML.java
index 626c8a65291003d7b40fd1faa4ef5613c07fad76..50a6683239693ed98f506f29d62c872f2f8ae11b 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/KML.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/KML.java
@@ -16,8 +16,6 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.CanvasElement;
import com.google.gwt.event.dom.client.ChangeEvent;
@@ -25,7 +23,6 @@ import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.ListBox;
-
import org.cesiumjs.cs.core.enums.ClockRange;
import org.cesiumjs.cs.core.enums.ClockStep;
import org.cesiumjs.cs.datasources.Entity;
@@ -37,81 +34,83 @@ import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class KML extends AbstractExample {
- private ViewerPanel csVPanel;
+ private ViewerPanel csVPanel;
- @Inject
- public KML(ShowcaseExampleStore store) {
- super("KML", "A simple KML example", new String[] { "Showcase", "Cesium", "3d", "Viewer" }, store);
- }
+ @Inject
+ public KML(ShowcaseExampleStore store) {
+ super("KML", "A simple KML example", new String[]{"Showcase", "Cesium", "3d", "Viewer"}, store);
+ }
- @Override
- public void buildPanel() {
- csVPanel = new ViewerPanel();
+ @Override
+ public void buildPanel() {
+ csVPanel = new ViewerPanel();
- ListBox kmlLBox = new ListBox();
- kmlLBox.addItem("KML - Global Science Facilities",
- GWT.getModuleBaseURL() + "SampleData/kml/facilities/facilities.kml");
- kmlLBox.addItem("KMZ with embedded data - GDP per capita",
- GWT.getModuleBaseURL() + "SampleData/kml/gdpPerCapita2008.kmz");
- kmlLBox.addItem("gx KML extensions - Bike Ride", GWT.getModuleBaseURL() + "SampleData/kml/bikeRide.kml");
- kmlLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent changeEvent) {
- reset();
- ListBox source = (ListBox) changeEvent.getSource();
- final Viewer viewer = csVPanel.getViewer();
- org.cesiumjs.cs.scene.Camera camera = viewer.camera;
- CanvasElement canvas = viewer.canvas();
- camera.flyHome(0);
- KmlDataSourceLoadStaticOptions kmlDataSourceOptions = KmlDataSourceLoadStaticOptions.create(camera, canvas);
- if (!source.getSelectedValue().contains("bikeRide")) {
- csVPanel.getViewer().dataSources().add(KmlDataSource.load(source.getSelectedValue(), kmlDataSourceOptions));
- } else {
- csVPanel.getViewer().dataSources().add(KmlDataSource.load(source.getSelectedValue(), kmlDataSourceOptions))
- .then(new Fulfill() {
- @Override
- public void onFulfilled(KmlDataSource dataSource) {
- viewer.clock().shouldAnimate = false;
- final Entity rider = dataSource.entities.getById("tour");
- viewer.flyTo(rider).then(new Fulfill() {
- @Override
- public void onFulfilled(Boolean value) {
- viewer.trackedEntity = rider;
- viewer.selectedEntity = viewer.trackedEntity;
- viewer.clock().multiplier = 30;
- viewer.clock().shouldAnimate = true;
- }
- });
+ ListBox kmlLBox = new ListBox();
+ kmlLBox.addItem("KML - Global Science Facilities",
+ GWT.getModuleBaseURL() + "SampleData/kml/facilities/facilities.kml");
+ kmlLBox.addItem("KMZ with embedded data - GDP per capita",
+ GWT.getModuleBaseURL() + "SampleData/kml/gdpPerCapita2008.kmz");
+ kmlLBox.addItem("gx KML extensions - Bike Ride", GWT.getModuleBaseURL() + "SampleData/kml/bikeRide.kml");
+ kmlLBox.addChangeHandler(new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent changeEvent) {
+ reset();
+ ListBox source = (ListBox) changeEvent.getSource();
+ final Viewer viewer = csVPanel.getViewer();
+ org.cesiumjs.cs.scene.Camera camera = viewer.camera;
+ CanvasElement canvas = viewer.canvas();
+ camera.flyHome(0);
+ KmlDataSourceLoadStaticOptions kmlDataSourceOptions = KmlDataSourceLoadStaticOptions.create(camera, canvas);
+ if (!source.getSelectedValue().contains("bikeRide")) {
+ csVPanel.getViewer().dataSources().add(KmlDataSource.load(source.getSelectedValue(), kmlDataSourceOptions));
+ } else {
+ csVPanel.getViewer().dataSources().add(KmlDataSource.load(source.getSelectedValue(), kmlDataSourceOptions))
+ .then(new Fulfill() {
+ @Override
+ public void onFulfilled(KmlDataSource dataSource) {
+ viewer.clock().shouldAnimate = false;
+ final Entity rider = dataSource.entities.getById("tour");
+ viewer.flyTo(rider).then(new Fulfill() {
+ @Override
+ public void onFulfilled(Boolean value) {
+ viewer.trackedEntity = rider;
+ viewer.selectedEntity = viewer.trackedEntity;
+ viewer.clock().multiplier = 30;
+ viewer.clock().shouldAnimate = true;
+ }
+ });
+ }
+ });
}
- });
- }
- }
- });
+ }
+ });
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(kmlLBox, 20, 20);
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(kmlLBox, 20, 20);
- contentPanel.add(new HTML("A simple KML example.
"));
- contentPanel.add(aPanel);
+ contentPanel.add(new HTML("A simple KML example.
"));
+ contentPanel.add(aPanel);
- initWidget(contentPanel);
- }
+ initWidget(contentPanel);
+ }
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "KML.txt";
- return sourceCodeURLs;
- }
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "KML.txt";
+ return sourceCodeURLs;
+ }
- public void reset() {
- csVPanel.getViewer().dataSources().removeAll();
- csVPanel.getViewer().clock().clockRange = ClockRange.UNBOUNDED();
- csVPanel.getViewer().clock().clockStep = ClockStep.SYSTEM_CLOCK();
- }
+ public void reset() {
+ csVPanel.getViewer().dataSources().removeAll();
+ csVPanel.getViewer().clock().clockRange = ClockRange.UNBOUNDED();
+ csVPanel.getViewer().clock().clockStep = ClockStep.SYSTEM_CLOCK();
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Labels.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Labels.java
index a983bc06a5e47765540c3d8a531cdada87c65741..5c406579069c8c19463f8957181ebd7c39e125fa 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Labels.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Labels.java
@@ -16,15 +16,12 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.ListBox;
-
import org.cesiumjs.cs.core.Cartesian2;
import org.cesiumjs.cs.core.Cartesian3;
import org.cesiumjs.cs.core.Color;
@@ -45,187 +42,189 @@ import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class Labels extends AbstractExample {
- private ViewerPanel csVPanel;
-
- @Inject
- public Labels(ShowcaseExampleStore store) {
- super("Labels", "Create labels on scene", new String[] { "Showcase", "Cesium", "3d", "labels" }, store);
- }
-
- @Override
- public void buildPanel() {
- csVPanel = new ViewerPanel();
- addLabel();
-
- ListBox labelsLBox = new ListBox();
- labelsLBox.addItem("Add label", "0");
- labelsLBox.addItem("Set font", "1");
- labelsLBox.addItem("Set properties", "2");
- labelsLBox.addItem("Offset label by distance", "3");
- labelsLBox.addItem("Fade label by distance", "4");
- labelsLBox.addItem("Scale label by distance", "5");
- labelsLBox.addItem("Set label with right-to-left language", "6");
- labelsLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent event) {
- ListBox source = (ListBox) event.getSource();
- reset();
- switch (source.getSelectedValue()) {
- case "0":
- addLabel();
- break;
- case "1":
- setFont();
- break;
- case "2":
- setProperties();
- break;
- case "3":
- offsetByDistance();
- break;
- case "4":
- fadeByDistance();
- break;
- case "5":
- scaleByDistance();
- break;
- case "6":
- setRightToLeft();
- break;
- default:
- break;
- }
- }
- });
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(labelsLBox, 20, 20);
-
- contentPanel.add(new HTML("Create Labels
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Labels.txt";
- return sourceCodeURLs;
- }
-
- private void reset() {
- csVPanel.getViewer().entities().removeAll();
- }
-
- private void addLabel() {
- LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
- labelGraphicsOptions.text = new ConstantProperty<>("Philadelphia");
-
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.1641667, 39.9522222));
- entityOptions.label = new LabelGraphics(labelGraphicsOptions);
- csVPanel.getViewer().entities().add(entityOptions);
- }
-
- private void setFont() {
- LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
- labelGraphicsOptions.text = new ConstantProperty<>("Philadelphia");
- labelGraphicsOptions.font = new ConstantProperty<>("24px Helvetica");
- labelGraphicsOptions.fillColor = new ConstantProperty<>(Color.SKYBLUE());
- labelGraphicsOptions.outlineColor = new ConstantProperty<>(Color.BLACK());
- labelGraphicsOptions.outlineWidth = new ConstantProperty<>(2);
- labelGraphicsOptions.style = new ConstantProperty<>(LabelStyle.FILL_AND_OUTLINE());
-
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.1641667, 39.9522222));
- entityOptions.label = new LabelGraphics(labelGraphicsOptions);
- csVPanel.getViewer().entities().add(entityOptions);
- }
-
- private void setProperties() {
- LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
- labelGraphicsOptions.text = new ConstantProperty<>("Philadelphia");
-
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.1641667, 39.9522222, 300000.0));
- entityOptions.label = new LabelGraphics(labelGraphicsOptions);
- Entity entity = csVPanel.getViewer().entities().add(entityOptions);
-
- entity.label.scale = new ConstantProperty<>(2.0);
- entity.label.showBackground = new ConstantProperty<>(true);
- }
-
- private void offsetByDistance() {
- final JsImage image = new JsImage();
- image.onload = new JsImage.Listener() {
- @Override
- public void function() {
- BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.scaleByDistance = new ConstantProperty<>(new NearFarScalar(1.5e2, 5.0, 1.5e7, 0.5));
- billboardGraphicsOptions.image = new ConstantProperty<>(image);
+ private ViewerPanel csVPanel;
+
+ @Inject
+ public Labels(ShowcaseExampleStore store) {
+ super("Labels", "Create labels on scene", new String[]{"Showcase", "Cesium", "3d", "labels"}, store);
+ }
+
+ @Override
+ public void buildPanel() {
+ csVPanel = new ViewerPanel();
+ addLabel();
+
+ ListBox labelsLBox = new ListBox();
+ labelsLBox.addItem("Add label", "0");
+ labelsLBox.addItem("Set font", "1");
+ labelsLBox.addItem("Set properties", "2");
+ labelsLBox.addItem("Offset label by distance", "3");
+ labelsLBox.addItem("Fade label by distance", "4");
+ labelsLBox.addItem("Scale label by distance", "5");
+ labelsLBox.addItem("Set label with right-to-left language", "6");
+ labelsLBox.addChangeHandler(new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent event) {
+ ListBox source = (ListBox) event.getSource();
+ reset();
+ switch (source.getSelectedValue()) {
+ case "0":
+ addLabel();
+ break;
+ case "1":
+ setFont();
+ break;
+ case "2":
+ setProperties();
+ break;
+ case "3":
+ offsetByDistance();
+ break;
+ case "4":
+ fadeByDistance();
+ break;
+ case "5":
+ scaleByDistance();
+ break;
+ case "6":
+ setRightToLeft();
+ break;
+ default:
+ break;
+ }
+ }
+ });
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(labelsLBox, 20, 20);
+
+ contentPanel.add(new HTML("Create Labels
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Labels.txt";
+ return sourceCodeURLs;
+ }
+
+ private void reset() {
+ csVPanel.getViewer().entities().removeAll();
+ }
+
+ private void addLabel() {
+ LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
+ labelGraphicsOptions.text = new ConstantProperty<>("Philadelphia");
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.1641667, 39.9522222));
+ entityOptions.label = new LabelGraphics(labelGraphicsOptions);
+ csVPanel.getViewer().entities().add(entityOptions);
+ }
+
+ private void setFont() {
LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
- labelGraphicsOptions.text = new ConstantProperty<>("Label on top of scaling billboard");
- labelGraphicsOptions.font = new ConstantProperty<>("20px sans-serif");
- labelGraphicsOptions.showBackground = new ConstantProperty<>(true);
- labelGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.CENTER());
- labelGraphicsOptions.pixelOffset = new ConstantProperty<>(new Cartesian2(0.0, -image.height));
- labelGraphicsOptions.pixelOffsetScaleByDistance = new ConstantProperty<>(
- new NearFarScalar(1.5e2, 3.0, 1.5e7, 0.5));
+ labelGraphicsOptions.text = new ConstantProperty<>("Philadelphia");
+ labelGraphicsOptions.font = new ConstantProperty<>("24px Helvetica");
+ labelGraphicsOptions.fillColor = new ConstantProperty<>(Color.SKYBLUE());
+ labelGraphicsOptions.outlineColor = new ConstantProperty<>(Color.BLACK());
+ labelGraphicsOptions.outlineWidth = new ConstantProperty<>(2);
+ labelGraphicsOptions.style = new ConstantProperty<>(LabelStyle.FILL_AND_OUTLINE());
EntityOptions entityOptions = new EntityOptions();
entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.1641667, 39.9522222));
- entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
entityOptions.label = new LabelGraphics(labelGraphicsOptions);
csVPanel.getViewer().entities().add(entityOptions);
- }
- };
- image.src = GWT.getModuleBaseURL() + "images/facility.gif";
- }
-
- private void fadeByDistance() {
- LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
- labelGraphicsOptions.text = new ConstantProperty<>("New York");
- labelGraphicsOptions.translucencyByDistance = new ConstantProperty<>(new NearFarScalar(1.5e2, 1.0, 1.5e8, 0.0));
-
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-73.94, 40.67));
- entityOptions.label = new LabelGraphics(labelGraphicsOptions);
- csVPanel.getViewer().entities().add(entityOptions);
-
- labelGraphicsOptions = new LabelGraphicsOptions();
- labelGraphicsOptions.text = new ConstantProperty<>("'Atlanta'");
- labelGraphicsOptions.translucencyByDistance = new ConstantProperty<>(new NearFarScalar(1.5e5, 1.0, 1.5e7, 0.0));
-
- entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-84.39, 33.75));
- entityOptions.label = new LabelGraphics(labelGraphicsOptions);
- csVPanel.getViewer().entities().add(entityOptions);
- }
-
- private void scaleByDistance() {
- LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
- labelGraphicsOptions.text = new ConstantProperty<>("Philadelphia");
- labelGraphicsOptions.scaleByDistance = new NearFarScalar(1.5e2, 2.0, 1.5e7, 0.5);
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.1641667, 39.9522222));
- entityOptions.label = new LabelGraphics(labelGraphicsOptions);
- csVPanel.getViewer().entities().add(entityOptions);
- }
-
- private void setRightToLeft() {
- Label.enableRightToLeftDetection = true;
- LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
- labelGraphicsOptions.text = new ConstantProperty<>("Master (אדון): Hello\nתלמיד (student): שלום");
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.1641667, 39.9522222));
- entityOptions.label = new LabelGraphics(labelGraphicsOptions);
- csVPanel.getViewer().entities().add(entityOptions);
- }
+ }
+
+ private void setProperties() {
+ LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
+ labelGraphicsOptions.text = new ConstantProperty<>("Philadelphia");
+
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.1641667, 39.9522222, 300000.0));
+ entityOptions.label = new LabelGraphics(labelGraphicsOptions);
+ Entity entity = csVPanel.getViewer().entities().add(entityOptions);
+
+ entity.label.scale = new ConstantProperty<>(2.0);
+ entity.label.showBackground = new ConstantProperty<>(true);
+ }
+
+ private void offsetByDistance() {
+ final JsImage image = new JsImage();
+ image.onload = new JsImage.Listener() {
+ @Override
+ public void function() {
+ BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
+ billboardGraphicsOptions.scaleByDistance = new ConstantProperty<>(new NearFarScalar(1.5e2, 5.0, 1.5e7, 0.5));
+ billboardGraphicsOptions.image = new ConstantProperty<>(image);
+
+ LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
+ labelGraphicsOptions.text = new ConstantProperty<>("Label on top of scaling billboard");
+ labelGraphicsOptions.font = new ConstantProperty<>("20px sans-serif");
+ labelGraphicsOptions.showBackground = new ConstantProperty<>(true);
+ labelGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.CENTER());
+ labelGraphicsOptions.pixelOffset = new ConstantProperty<>(new Cartesian2(0.0, -image.height));
+ labelGraphicsOptions.pixelOffsetScaleByDistance = new ConstantProperty<>(
+ new NearFarScalar(1.5e2, 3.0, 1.5e7, 0.5));
+
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.1641667, 39.9522222));
+ entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
+ entityOptions.label = new LabelGraphics(labelGraphicsOptions);
+ csVPanel.getViewer().entities().add(entityOptions);
+ }
+ };
+ image.src = GWT.getModuleBaseURL() + "images/facility.gif";
+ }
+
+ private void fadeByDistance() {
+ LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
+ labelGraphicsOptions.text = new ConstantProperty<>("New York");
+ labelGraphicsOptions.translucencyByDistance = new ConstantProperty<>(new NearFarScalar(1.5e2, 1.0, 1.5e8, 0.0));
+
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-73.94, 40.67));
+ entityOptions.label = new LabelGraphics(labelGraphicsOptions);
+ csVPanel.getViewer().entities().add(entityOptions);
+
+ labelGraphicsOptions = new LabelGraphicsOptions();
+ labelGraphicsOptions.text = new ConstantProperty<>("'Atlanta'");
+ labelGraphicsOptions.translucencyByDistance = new ConstantProperty<>(new NearFarScalar(1.5e5, 1.0, 1.5e7, 0.0));
+
+ entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-84.39, 33.75));
+ entityOptions.label = new LabelGraphics(labelGraphicsOptions);
+ csVPanel.getViewer().entities().add(entityOptions);
+ }
+
+ private void scaleByDistance() {
+ LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
+ labelGraphicsOptions.text = new ConstantProperty<>("Philadelphia");
+ labelGraphicsOptions.scaleByDistance = new NearFarScalar(1.5e2, 2.0, 1.5e7, 0.5);
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.1641667, 39.9522222));
+ entityOptions.label = new LabelGraphics(labelGraphicsOptions);
+ csVPanel.getViewer().entities().add(entityOptions);
+ }
+
+ private void setRightToLeft() {
+ Label.enableRightToLeftDetection = true;
+ LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
+ labelGraphicsOptions.text = new ConstantProperty<>("Master (אדון): Hello\nתלמיד (student): שלום");
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.1641667, 39.9522222));
+ entityOptions.label = new LabelGraphics(labelGraphicsOptions);
+ csVPanel.getViewer().entities().add(entityOptions);
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/LensFlare.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/LensFlare.java
index 5be3a9c37a4673b4919697c298ed69cc22eced5b..de62eb35215202da813b163aa65f000bfbf1cd12 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/LensFlare.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/LensFlare.java
@@ -16,8 +16,6 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
@@ -25,7 +23,6 @@ import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
-
import org.cesiumjs.cs.core.Cartesian3;
import org.cesiumjs.cs.core.Ellipsoid;
import org.cesiumjs.cs.core.JulianDate;
@@ -38,131 +35,133 @@ import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class LensFlare extends AbstractExample {
- private ViewerPanel csVPanel;
-
- private CheckBox lensFlareCBox;
- private Slider intensitySlider;
- private Slider distortionSlider;
- private Slider dispersionSlider;
- private Slider haloWidthSlider;
-
- private PostProcessStage lensFlare;
-
- @Inject
- public LensFlare(ShowcaseExampleStore store) {
- super("LensFlare", "Lens Flare", new String[] { "Lens Flare", "Post processing" }, store);
- }
-
- @Override
- public void buildPanel() {
- csVPanel = new ViewerPanel();
-
- lensFlareCBox = new CheckBox();
- lensFlareCBox.setValue(false);
- lensFlareCBox.addValueChangeHandler(new MValueChangeHandler());
-
- intensitySlider = new Slider("intensitySlider", 0, 1000, 200);
- intensitySlider.setStep(1);
- intensitySlider.setWidth("150px");
- intensitySlider.addListener(new MSliderListener());
-
- distortionSlider = new Slider("distortionSlider", 100, 2000, 1000);
- distortionSlider.setStep(1);
- distortionSlider.setWidth("150px");
- distortionSlider.addListener(new MSliderListener());
-
- dispersionSlider = new Slider("dispersionSlider", 0, 100, 40);
- dispersionSlider.setStep(1);
- dispersionSlider.setWidth("150px");
- dispersionSlider.addListener(new MSliderListener());
-
- haloWidthSlider = new Slider("haloWidthSlider", 0, 100, 40);
- haloWidthSlider.setStep(1);
- haloWidthSlider.setWidth("150px");
- haloWidthSlider.addListener(new MSliderListener());
-
- FlexTable flexTable = new FlexTable();
- flexTable.setHTML(1, 0, "Lens Flare");
- flexTable.setWidget(1, 1, lensFlareCBox);
- flexTable.setHTML(2, 0, "Intensity");
- flexTable.setWidget(2, 1, intensitySlider);
- flexTable.setHTML(3, 0, "Distortion");
- flexTable.setWidget(3, 1, distortionSlider);
- flexTable.setHTML(4, 0, "Dispersion");
- flexTable.setWidget(4, 1, dispersionSlider);
- flexTable.setHTML(5, 0, "Halo Width");
- flexTable.setWidget(5, 1, haloWidthSlider);
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(flexTable, 20, 20);
-
- contentPanel.add(new HTML("Post processing effects.
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
-
- lensFlare = (PostProcessStage) csVPanel.getViewer().scene().postProcessStages
- .add(PostProcessStageLibrary.createLensFlareStage());
-
- updatePostProcess();
-
- org.cesiumjs.cs.scene.Camera camera = csVPanel.getViewer().scene().camera();
- camera.position = new Cartesian3(40010447.97500168, 56238683.46406788, 20776576.752223067);
- camera.direction = new Cartesian3(-0.5549701431494752, -0.7801872010801355, -0.2886452346452218);
- camera.up = new Cartesian3(-0.3016252360948521, -0.13464820558887716, 0.9438707950150912);
- camera.right = Cartesian3.cross(camera.direction, camera.up, new Cartesian3());
-
- csVPanel.getViewer().clock().currentTime = new JulianDate(2458047, 27399.860215000022);
- }
-
- private void updatePostProcess() {
- lensFlare.enabled = lensFlareCBox.getValue();
- lensFlare.uniforms().setProperty("intensity", intensitySlider.getValue() / 100.);
- lensFlare.uniforms().setProperty("distortion", distortionSlider.getValue() / 100.);
- lensFlare.uniforms().setProperty("ghostDispersal", dispersionSlider.getValue() / 100.);
- lensFlare.uniforms().setProperty("haloWidth", haloWidthSlider.getValue() / 100.);
- lensFlare.uniforms().setProperty("earthRadius", Ellipsoid.WGS84().maximumRadius());
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "LensFlare.txt";
- return sourceCodeURLs;
- }
-
- private class MValueChangeHandler implements ValueChangeHandler {
- @Override
- public void onValueChange(ValueChangeEvent event) {
- updatePostProcess();
+ private ViewerPanel csVPanel;
+
+ private CheckBox lensFlareCBox;
+ private Slider intensitySlider;
+ private Slider distortionSlider;
+ private Slider dispersionSlider;
+ private Slider haloWidthSlider;
+
+ private PostProcessStage lensFlare;
+
+ @Inject
+ public LensFlare(ShowcaseExampleStore store) {
+ super("LensFlare", "Lens Flare", new String[]{"Lens Flare", "Post processing"}, store);
}
- }
- private class MSliderListener implements SliderListener {
@Override
- public void onStart(SliderEvent e) {
- //
+ public void buildPanel() {
+ csVPanel = new ViewerPanel();
+
+ lensFlareCBox = new CheckBox();
+ lensFlareCBox.setValue(false);
+ lensFlareCBox.addValueChangeHandler(new MValueChangeHandler());
+
+ intensitySlider = new Slider("intensitySlider", 0, 1000, 200);
+ intensitySlider.setStep(1);
+ intensitySlider.setWidth("150px");
+ intensitySlider.addListener(new MSliderListener());
+
+ distortionSlider = new Slider("distortionSlider", 100, 2000, 1000);
+ distortionSlider.setStep(1);
+ distortionSlider.setWidth("150px");
+ distortionSlider.addListener(new MSliderListener());
+
+ dispersionSlider = new Slider("dispersionSlider", 0, 100, 40);
+ dispersionSlider.setStep(1);
+ dispersionSlider.setWidth("150px");
+ dispersionSlider.addListener(new MSliderListener());
+
+ haloWidthSlider = new Slider("haloWidthSlider", 0, 100, 40);
+ haloWidthSlider.setStep(1);
+ haloWidthSlider.setWidth("150px");
+ haloWidthSlider.addListener(new MSliderListener());
+
+ FlexTable flexTable = new FlexTable();
+ flexTable.setHTML(1, 0, "Lens Flare");
+ flexTable.setWidget(1, 1, lensFlareCBox);
+ flexTable.setHTML(2, 0, "Intensity");
+ flexTable.setWidget(2, 1, intensitySlider);
+ flexTable.setHTML(3, 0, "Distortion");
+ flexTable.setWidget(3, 1, distortionSlider);
+ flexTable.setHTML(4, 0, "Dispersion");
+ flexTable.setWidget(4, 1, dispersionSlider);
+ flexTable.setHTML(5, 0, "Halo Width");
+ flexTable.setWidget(5, 1, haloWidthSlider);
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(flexTable, 20, 20);
+
+ contentPanel.add(new HTML("Post processing effects.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
+
+ lensFlare = csVPanel.getViewer().scene().postProcessStages
+ .add(PostProcessStageLibrary.createLensFlareStage());
+
+ updatePostProcess();
+
+ org.cesiumjs.cs.scene.Camera camera = csVPanel.getViewer().scene().camera();
+ camera.position = new Cartesian3(40010447.97500168, 56238683.46406788, 20776576.752223067);
+ camera.direction = new Cartesian3(-0.5549701431494752, -0.7801872010801355, -0.2886452346452218);
+ camera.up = new Cartesian3(-0.3016252360948521, -0.13464820558887716, 0.9438707950150912);
+ camera.right = Cartesian3.cross(camera.direction, camera.up, new Cartesian3());
+
+ csVPanel.getViewer().clock().currentTime = new JulianDate(2458047, 27399.860215000022);
}
- @Override
- public boolean onSlide(SliderEvent e) {
- updatePostProcess();
- return true;
+ private void updatePostProcess() {
+ lensFlare.enabled = lensFlareCBox.getValue();
+ lensFlare.uniforms().setProperty("intensity", intensitySlider.getValue() / 100.);
+ lensFlare.uniforms().setProperty("distortion", distortionSlider.getValue() / 100.);
+ lensFlare.uniforms().setProperty("ghostDispersal", dispersionSlider.getValue() / 100.);
+ lensFlare.uniforms().setProperty("haloWidth", haloWidthSlider.getValue() / 100.);
+ lensFlare.uniforms().setProperty("earthRadius", Ellipsoid.WGS84().maximumRadius());
}
@Override
- public void onChange(SliderEvent e) {
- //
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "LensFlare.txt";
+ return sourceCodeURLs;
}
- @Override
- public void onStop(SliderEvent e) {
- //
+ private class MValueChangeHandler implements ValueChangeHandler {
+ @Override
+ public void onValueChange(ValueChangeEvent event) {
+ updatePostProcess();
+ }
+ }
+
+ private class MSliderListener implements SliderListener {
+ @Override
+ public void onStart(SliderEvent e) {
+ //
+ }
+
+ @Override
+ public boolean onSlide(SliderEvent e) {
+ updatePostProcess();
+ return true;
+ }
+
+ @Override
+ public void onChange(SliderEvent e) {
+ //
+ }
+
+ @Override
+ public void onStop(SliderEvent e) {
+ //
+ }
}
- }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/LoadImages.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/LoadImages.java
index 5c077575412bb4820e67e405da5c46ad074acbfa..6fb2c5d35f4d2fab651dbb503bfcad04cbbbcd34 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/LoadImages.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/LoadImages.java
@@ -16,8 +16,6 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.canvas.client.Canvas;
import com.google.gwt.canvas.dom.client.Context2d;
import com.google.gwt.core.client.GWT;
@@ -25,7 +23,6 @@ import com.google.gwt.dom.client.CanvasElement;
import com.google.gwt.dom.client.ImageElement;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.HTML;
-
import org.cesiumjs.cs.Cesium;
import org.cesiumjs.cs.core.Cartesian3;
import org.cesiumjs.cs.core.Color;
@@ -43,144 +40,146 @@ import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class LoadImages extends AbstractExample {
- private ViewerPanel csVPanel;
-
- @Inject
- public LoadImages(ShowcaseExampleStore store) {
- super("LoadImages", "Load images into base64 string and set as image on BillboardGraphics",
- new String[] { "Showcase", "Cesium", "3d", "Base64" }, store);
- }
-
- @Override
- public void buildPanel() {
- csVPanel = new ViewerPanel();
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
-
- org.cesiumjs.cs.core.PinBuilder pinBuilder = new org.cesiumjs.cs.core.PinBuilder();
- pinBuilder.fromUrlPromise(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color_Overlay.png",
- Color.WHITE().withAlpha(0.0f), 256).then(new Fulfill() {
- @Override
- public void onFulfilled(CanvasElement value) {
- BillboardGraphicsOptions billboardOptions = new BillboardGraphicsOptions();
- billboardOptions.image = new ConstantProperty<>(value.toDataUrl());
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.name = "Pin billboard through fromUrl";
- entityOptions.billboard = new BillboardGraphics(billboardOptions);
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(35, 35));
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
- }
- });
-
- Resource.fetchImage((ResourceImageOptions) ResourceImageOptions
- .create(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color_Overlay.png")).then(new Fulfill() {
- @Override
- public void onFulfilled(JsImage value) {
- Canvas canvas = Canvas.createIfSupported();
- canvas.setWidth(value.width + "px");
- canvas.setHeight(value.height + "px");
- Context2d context = canvas.getContext2d();
- context.scale(0.1, 0.1);
- context.drawImage((ImageElement) (Object) value, 0, 0);
-
- BillboardGraphicsOptions billboardOptions = new BillboardGraphicsOptions();
- billboardOptions.image = new ConstantProperty<>(canvas.toDataUrl());
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.name = "Pin billboard through canvas";
- entityOptions.billboard = new BillboardGraphics(billboardOptions);
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(45, 45));
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
- }
+ private ViewerPanel csVPanel;
+
+ @Inject
+ public LoadImages(ShowcaseExampleStore store) {
+ super("LoadImages", "Load images into base64 string and set as image on BillboardGraphics",
+ new String[]{"Showcase", "Cesium", "3d", "Base64"}, store);
+ }
+
+ @Override
+ public void buildPanel() {
+ csVPanel = new ViewerPanel();
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+
+ org.cesiumjs.cs.core.PinBuilder pinBuilder = new org.cesiumjs.cs.core.PinBuilder();
+ pinBuilder.fromUrlPromise(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color_Overlay.png",
+ Color.WHITE().withAlpha(0.0f), 256).then(new Fulfill() {
+ @Override
+ public void onFulfilled(CanvasElement value) {
+ BillboardGraphicsOptions billboardOptions = new BillboardGraphicsOptions();
+ billboardOptions.image = new ConstantProperty<>(value.toDataUrl());
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.name = "Pin billboard through fromUrl";
+ entityOptions.billboard = new BillboardGraphics(billboardOptions);
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(35, 35));
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ }
});
- // CORS not loaded
- Resource
- .fetchImage(
- (ResourceImageOptions) ResourceImageOptions.create("https://www.linux.org.ru/tango/img/games-logo.png"))
- .then(new Fulfill() {
- @Override
- public void onFulfilled(JsImage value) {
- Canvas canvas = Canvas.createIfSupported();
- canvas.setWidth(value.width + "px");
- canvas.setHeight(value.height + "px");
- Context2d context = canvas.getContext2d();
- context.scale(0.1, 0.1);
- context.drawImage((ImageElement) (Object) value, 0, 0);
-
- BillboardGraphicsOptions billboardOptions = new BillboardGraphicsOptions();
- billboardOptions.image = new ConstantProperty<>(canvas.toDataUrl());
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.name = "Pin billboard CORS";
- entityOptions.billboard = new BillboardGraphics(billboardOptions);
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(55, 55));
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
- }
+ Resource.fetchImage((ResourceImageOptions) ResourceImageOptions
+ .create(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color_Overlay.png")).then(new Fulfill() {
+ @Override
+ public void onFulfilled(JsImage value) {
+ Canvas canvas = Canvas.createIfSupported();
+ canvas.setWidth(value.width + "px");
+ canvas.setHeight(value.height + "px");
+ Context2d context = canvas.getContext2d();
+ context.scale(0.1, 0.1);
+ context.drawImage((ImageElement) (Object) value, 0, 0);
+
+ BillboardGraphicsOptions billboardOptions = new BillboardGraphicsOptions();
+ billboardOptions.image = new ConstantProperty<>(canvas.toDataUrl());
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.name = "Pin billboard through canvas";
+ entityOptions.billboard = new BillboardGraphics(billboardOptions);
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(45, 45));
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ }
});
- // Cors not loaded!
- final JsImage imageAmz = new JsImage();
- imageAmz.crossOrigin = "*";
- imageAmz.onload = new JsImage.Listener() {
- @Override
- public void function() {
- Cesium.log(imageAmz);
- /*
- * Canvas canvas = Canvas.createIfSupported(); canvas.setWidth(imageAmz.width +
- * "px"); canvas.setHeight(imageAmz.height + "px"); Context2d context =
- * canvas.getContext2d(); context.scale(0.1, 0.1);
- * context.drawImage((ImageElement) (Object) imageAmz, 0, 0);
- */
- BillboardGraphicsOptions billboardOptions = new BillboardGraphicsOptions();
- billboardOptions.image = new ConstantProperty<>(imageAmz);
- // billboardOptions.image = new
- // ConstantProperty<>(canvas.toDataUrl("image/png"));
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.name = "Pin billboard CORS";
- entityOptions.billboard = new BillboardGraphics(billboardOptions);
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(65, 65));
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
- }
- };
- imageAmz.src = "https://d1.awsstatic.com/products/cloudfront/cloudfront-100_PoP_600x400.4a1edd6022833c54c41370ad9f615ae818350a23.png";
-
- // Worked, have Access-Control-Allow-Origin: *
- final JsImage imageWiki = new JsImage();
- imageWiki.crossOrigin = "*";
- imageWiki.onload = new JsImage.Listener() {
- @Override
- public void function() {
- Cesium.log(imageWiki);
- Canvas canvas = Canvas.createIfSupported();
- canvas.setWidth(imageWiki.width + "px");
- canvas.setHeight(imageWiki.height + "px");
- Context2d context = canvas.getContext2d();
- context.drawImage((ImageElement) (Object) imageWiki, 0, 0);
- BillboardGraphicsOptions billboardOptions = new BillboardGraphicsOptions();
- billboardOptions.image = new ConstantProperty<>(canvas.toDataUrl("image/png"));
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.name = "Pin billboard CORS";
- entityOptions.billboard = new BillboardGraphics(billboardOptions);
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(75, 75));
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
- }
- };
- imageWiki.src = "https://ru.wikipedia.org/static/images/project-logos/ruwiki-2x.png";
-
- contentPanel.add(new HTML("Cluster labels, billboards and points.
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "LoadImages.txt";
- return sourceCodeURLs;
- }
+ // CORS not loaded
+ Resource
+ .fetchImage(
+ (ResourceImageOptions) ResourceImageOptions.create("https://www.linux.org.ru/tango/img/games-logo.png"))
+ .then(new Fulfill() {
+ @Override
+ public void onFulfilled(JsImage value) {
+ Canvas canvas = Canvas.createIfSupported();
+ canvas.setWidth(value.width + "px");
+ canvas.setHeight(value.height + "px");
+ Context2d context = canvas.getContext2d();
+ context.scale(0.1, 0.1);
+ context.drawImage((ImageElement) (Object) value, 0, 0);
+
+ BillboardGraphicsOptions billboardOptions = new BillboardGraphicsOptions();
+ billboardOptions.image = new ConstantProperty<>(canvas.toDataUrl());
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.name = "Pin billboard CORS";
+ entityOptions.billboard = new BillboardGraphics(billboardOptions);
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(55, 55));
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ }
+ });
+
+ // Cors not loaded!
+ final JsImage imageAmz = new JsImage();
+ imageAmz.crossOrigin = "*";
+ imageAmz.onload = new JsImage.Listener() {
+ @Override
+ public void function() {
+ Cesium.log(imageAmz);
+ /*
+ * Canvas canvas = Canvas.createIfSupported(); canvas.setWidth(imageAmz.width +
+ * "px"); canvas.setHeight(imageAmz.height + "px"); Context2d context =
+ * canvas.getContext2d(); context.scale(0.1, 0.1);
+ * context.drawImage((ImageElement) (Object) imageAmz, 0, 0);
+ */
+ BillboardGraphicsOptions billboardOptions = new BillboardGraphicsOptions();
+ billboardOptions.image = new ConstantProperty<>(imageAmz);
+ // billboardOptions.image = new
+ // ConstantProperty<>(canvas.toDataUrl("image/png"));
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.name = "Pin billboard CORS";
+ entityOptions.billboard = new BillboardGraphics(billboardOptions);
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(65, 65));
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ }
+ };
+ imageAmz.src = "https://d1.awsstatic.com/products/cloudfront/cloudfront-100_PoP_600x400.4a1edd6022833c54c41370ad9f615ae818350a23.png";
+
+ // Worked, have Access-Control-Allow-Origin: *
+ final JsImage imageWiki = new JsImage();
+ imageWiki.crossOrigin = "*";
+ imageWiki.onload = new JsImage.Listener() {
+ @Override
+ public void function() {
+ Cesium.log(imageWiki);
+ Canvas canvas = Canvas.createIfSupported();
+ canvas.setWidth(imageWiki.width + "px");
+ canvas.setHeight(imageWiki.height + "px");
+ Context2d context = canvas.getContext2d();
+ context.drawImage((ImageElement) (Object) imageWiki, 0, 0);
+ BillboardGraphicsOptions billboardOptions = new BillboardGraphicsOptions();
+ billboardOptions.image = new ConstantProperty<>(canvas.toDataUrl("image/png"));
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.name = "Pin billboard CORS";
+ entityOptions.billboard = new BillboardGraphics(billboardOptions);
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(75, 75));
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ }
+ };
+ imageWiki.src = "https://ru.wikipedia.org/static/images/project-logos/ruwiki-2x.png";
+
+ contentPanel.add(new HTML("Cluster labels, billboards and points.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "LoadImages.txt";
+ return sourceCodeURLs;
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Materials.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Materials.java
index 48909d33c207c88f779430a5dc96b46bdfc856a2..59d810d55c6095d2fb64817aa759c587c43738a7 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Materials.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Materials.java
@@ -16,8 +16,6 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JsonUtils;
import com.google.gwt.event.dom.client.ChangeEvent;
@@ -29,7 +27,6 @@ import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.ListBox;
-
import org.cesiumjs.cs.collections.PolylineCollection;
import org.cesiumjs.cs.core.Cartesian3;
import org.cesiumjs.cs.core.PolylinePipeline;
@@ -53,492 +50,494 @@ import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class Materials extends AbstractExample {
- private Primitive rectangle;
- private Primitive worldRectangle;
- private Polyline polyline;
-
- private ViewerPanel csVPanel;
-
- private ListBox commonMaterialLBox;
- private ListBox proceduralTexturesLBox;
- private ListBox baseMaterialsLBox;
- private ListBox miscMaterialsLBox;
- private ListBox exampleCompositeMaterialsLBox;
- private ListBox polylineMaterialsLBox;
-
- @Inject
- public Materials(ShowcaseExampleStore store) {
- super("Materials", "Browse Cesium's built in materials and define new ones using the Fabric schema",
- new String[] { "Showcase", "Cesium", "3d", "Viewer" }, store);
- }
-
- @Override
- public void buildPanel() {
- csVPanel = new ViewerPanel();
- createPrimitives(csVPanel.getViewer().scene());
- applyColorMaterial(rectangle);
-
- commonMaterialLBox = new ListBox();
- commonMaterialLBox.addChangeHandler(new MChangeHandler());
- commonMaterialLBox.addItem("Select", "0");
- commonMaterialLBox.addItem("Color", "1");
- commonMaterialLBox.addItem("Image", "2");
-
- proceduralTexturesLBox = new ListBox();
- proceduralTexturesLBox.addChangeHandler(new MChangeHandler());
- proceduralTexturesLBox.addItem("Select", "0");
- proceduralTexturesLBox.addItem("Checkerboard", "1");
- proceduralTexturesLBox.addItem("Dot", "2");
- proceduralTexturesLBox.addItem("Grid", "3");
- proceduralTexturesLBox.addItem("Stripe", "4");
-
- baseMaterialsLBox = new ListBox();
- baseMaterialsLBox.addChangeHandler(new MChangeHandler());
- baseMaterialsLBox.addItem("Select", "0");
- baseMaterialsLBox.addItem("Alpha Map", "1");
- baseMaterialsLBox.addItem("Bump Map", "2");
- baseMaterialsLBox.addItem("Diffuse", "3");
- baseMaterialsLBox.addItem("Emission Map", "4");
- baseMaterialsLBox.addItem("Normal Map", "5");
- baseMaterialsLBox.addItem("Specular Map", "6");
-
- miscMaterialsLBox = new ListBox();
- miscMaterialsLBox.addChangeHandler(new MChangeHandler());
- miscMaterialsLBox.addItem("Select", "0");
- miscMaterialsLBox.addItem("Rim Lighting", "1");
- miscMaterialsLBox.addItem("Water", "2");
-
- exampleCompositeMaterialsLBox = new ListBox();
- exampleCompositeMaterialsLBox.addChangeHandler(new MChangeHandler());
- exampleCompositeMaterialsLBox.addItem("Select", "0");
- exampleCompositeMaterialsLBox.addItem("Composite Example", "1");
-
- polylineMaterialsLBox = new ListBox();
- polylineMaterialsLBox.addChangeHandler(new MChangeHandler());
- polylineMaterialsLBox.addItem("Select", "0");
- polylineMaterialsLBox.addItem("Polyline Arrow", "1");
- polylineMaterialsLBox.addItem("Polyline Glow", "2");
- polylineMaterialsLBox.addItem("Polyline Outline", "3");
-
- FlexTable flexTable = new FlexTable();
- flexTable.setCellSpacing(1);
- flexTable.setCellPadding(1);
- flexTable.setHTML(1, 0, "Common materials");
- flexTable.setWidget(1, 1, commonMaterialLBox);
- flexTable.setHTML(2, 0, "Procedural textures");
- flexTable.setWidget(2, 1, proceduralTexturesLBox);
- flexTable.setHTML(3, 0, "Base materials");
- flexTable.setWidget(3, 1, baseMaterialsLBox);
- flexTable.setHTML(4, 0, "Misc materials");
- flexTable.setWidget(4, 1, miscMaterialsLBox);
- flexTable.setHTML(5, 0, "Example composite materials");
- flexTable.setWidget(5, 1, exampleCompositeMaterialsLBox);
- flexTable.setHTML(6, 0, "Polyline materials");
- flexTable.setWidget(6, 1, polylineMaterialsLBox);
- //
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(flexTable, 20, 20);
-
- contentPanel
- .add(new HTML("Browse Cesium's built in materials and define new ones using the Fabric schema.
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Materials.txt";
- return sourceCodeURLs;
- }
-
- private class MChangeHandler implements ChangeHandler {
+ private Primitive rectangle;
+ private Primitive worldRectangle;
+ private Polyline polyline;
+
+ private ViewerPanel csVPanel;
+
+ private ListBox commonMaterialLBox;
+ private ListBox proceduralTexturesLBox;
+ private ListBox baseMaterialsLBox;
+ private ListBox miscMaterialsLBox;
+ private ListBox exampleCompositeMaterialsLBox;
+ private ListBox polylineMaterialsLBox;
+
+ @Inject
+ public Materials(ShowcaseExampleStore store) {
+ super("Materials", "Browse Cesium's built in materials and define new ones using the Fabric schema",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer"}, store);
+ }
+
@Override
- public void onChange(ChangeEvent changeEvent) {
- ListBox source = (ListBox) changeEvent.getSource();
- int value = Integer.parseInt(source.getSelectedValue());
- if (source.equals(commonMaterialLBox)) {
- toggleRectangleVisibility();
- if (value == 1) {
- applyColorMaterial(rectangle);
- } else if (value == 2) {
- applyImageMaterial(rectangle);
- }
- } else if (source.equals(proceduralTexturesLBox)) {
- toggleRectangleVisibility();
- if (value == 1) {
- applyCheckerboardMaterial(rectangle);
- } else if (value == 2) {
- applyDotMaterial(rectangle);
- } else if (value == 3) {
- applyGridMaterial(rectangle);
- } else if (value == 4) {
- applyStripeMaterial(rectangle);
- }
- } else if (source.equals(baseMaterialsLBox)) {
- toggleRectangleVisibility();
- if (value == 1) {
- applyAlphaMapMaterial(rectangle);
- } else if (value == 2) {
- applyBumpMapMaterial(rectangle);
- } else if (value == 3) {
- applyDiffuseMaterial(rectangle);
- } else if (value == 4) {
- applyEmissionMapMaterial(rectangle);
- } else if (value == 5) {
- applyNormalMapMaterial(rectangle);
- } else if (value == 6) {
- applySpecularMapMaterial(rectangle);
- }
- } else if (source.equals(miscMaterialsLBox)) {
- toggleWorldRectangleVisibility();
- if (value == 1) {
- applyRimLightingMaterial(worldRectangle);
- } else if (value == 2) {
- applyWaterMaterial(worldRectangle);
- }
- } else if (source.equals(exampleCompositeMaterialsLBox)) {
- toggleWorldRectangleVisibility();
- if (value == 1) {
- applyCompositeMaterial(worldRectangle);
- }
- } else if (source.equals(polylineMaterialsLBox)) {
- togglePolylineVisibility();
- if (value == 1) {
- applyPolylineArrowMaterial(polyline);
- } else if (value == 2) {
- applyPolylineGlowMaterial(polyline);
- } else if (value == 3) {
- applyPolylineOutlineMaterial(polyline);
+ public void buildPanel() {
+ csVPanel = new ViewerPanel();
+ createPrimitives(csVPanel.getViewer().scene());
+ applyColorMaterial(rectangle);
+
+ commonMaterialLBox = new ListBox();
+ commonMaterialLBox.addChangeHandler(new MChangeHandler());
+ commonMaterialLBox.addItem("Select", "0");
+ commonMaterialLBox.addItem("Color", "1");
+ commonMaterialLBox.addItem("Image", "2");
+
+ proceduralTexturesLBox = new ListBox();
+ proceduralTexturesLBox.addChangeHandler(new MChangeHandler());
+ proceduralTexturesLBox.addItem("Select", "0");
+ proceduralTexturesLBox.addItem("Checkerboard", "1");
+ proceduralTexturesLBox.addItem("Dot", "2");
+ proceduralTexturesLBox.addItem("Grid", "3");
+ proceduralTexturesLBox.addItem("Stripe", "4");
+
+ baseMaterialsLBox = new ListBox();
+ baseMaterialsLBox.addChangeHandler(new MChangeHandler());
+ baseMaterialsLBox.addItem("Select", "0");
+ baseMaterialsLBox.addItem("Alpha Map", "1");
+ baseMaterialsLBox.addItem("Bump Map", "2");
+ baseMaterialsLBox.addItem("Diffuse", "3");
+ baseMaterialsLBox.addItem("Emission Map", "4");
+ baseMaterialsLBox.addItem("Normal Map", "5");
+ baseMaterialsLBox.addItem("Specular Map", "6");
+
+ miscMaterialsLBox = new ListBox();
+ miscMaterialsLBox.addChangeHandler(new MChangeHandler());
+ miscMaterialsLBox.addItem("Select", "0");
+ miscMaterialsLBox.addItem("Rim Lighting", "1");
+ miscMaterialsLBox.addItem("Water", "2");
+
+ exampleCompositeMaterialsLBox = new ListBox();
+ exampleCompositeMaterialsLBox.addChangeHandler(new MChangeHandler());
+ exampleCompositeMaterialsLBox.addItem("Select", "0");
+ exampleCompositeMaterialsLBox.addItem("Composite Example", "1");
+
+ polylineMaterialsLBox = new ListBox();
+ polylineMaterialsLBox.addChangeHandler(new MChangeHandler());
+ polylineMaterialsLBox.addItem("Select", "0");
+ polylineMaterialsLBox.addItem("Polyline Arrow", "1");
+ polylineMaterialsLBox.addItem("Polyline Glow", "2");
+ polylineMaterialsLBox.addItem("Polyline Outline", "3");
+
+ FlexTable flexTable = new FlexTable();
+ flexTable.setCellSpacing(1);
+ flexTable.setCellPadding(1);
+ flexTable.setHTML(1, 0, "Common materials");
+ flexTable.setWidget(1, 1, commonMaterialLBox);
+ flexTable.setHTML(2, 0, "Procedural textures");
+ flexTable.setWidget(2, 1, proceduralTexturesLBox);
+ flexTable.setHTML(3, 0, "Base materials");
+ flexTable.setWidget(3, 1, baseMaterialsLBox);
+ flexTable.setHTML(4, 0, "Misc materials");
+ flexTable.setWidget(4, 1, miscMaterialsLBox);
+ flexTable.setHTML(5, 0, "Example composite materials");
+ flexTable.setWidget(5, 1, exampleCompositeMaterialsLBox);
+ flexTable.setHTML(6, 0, "Polyline materials");
+ flexTable.setWidget(6, 1, polylineMaterialsLBox);
+ //
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(flexTable, 20, 20);
+
+ contentPanel
+ .add(new HTML("Browse Cesium's built in materials and define new ones using the Fabric schema.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Materials.txt";
+ return sourceCodeURLs;
+ }
+
+ public void createPrimitives(Scene scene) {
+ PrimitiveOptions primitiveOptions = new PrimitiveOptions();
+ GeometryInstanceOptions geometryInstanceOptions = new GeometryInstanceOptions();
+ RectangleGeometryOptions rectangleGeometryOptions = new RectangleGeometryOptions();
+ rectangleGeometryOptions.rectangle = Rectangle.fromDegrees(-120.0, 20.0, -60.0, 40.0);
+ rectangleGeometryOptions.vertexFormat = EllipsoidSurfaceAppearance.VERTEX_FORMAT();
+ geometryInstanceOptions.geometry = RectangleGeometry
+ .createGeometry(new RectangleGeometry(rectangleGeometryOptions));
+ primitiveOptions.geometryInstances = new GeometryInstance[]{new GeometryInstance(geometryInstanceOptions)};
+ EllipsoidSurfaceAppearanceOptions ellipsoidSurfaceAppearanceOptions = new EllipsoidSurfaceAppearanceOptions();
+ ellipsoidSurfaceAppearanceOptions.aboveGround = false;
+ primitiveOptions.asynchronous = false;
+ primitiveOptions.appearance = new EllipsoidSurfaceAppearance(ellipsoidSurfaceAppearanceOptions);
+ rectangle = (Primitive) scene.primitives().add(new Primitive(primitiveOptions));
+
+ primitiveOptions = new PrimitiveOptions();
+ geometryInstanceOptions = new GeometryInstanceOptions();
+ rectangleGeometryOptions = new RectangleGeometryOptions();
+ rectangleGeometryOptions.rectangle = Rectangle.fromDegrees(-180.0, -90.0, 180.0, 90.0);
+ rectangleGeometryOptions.vertexFormat = EllipsoidSurfaceAppearance.VERTEX_FORMAT();
+ geometryInstanceOptions.geometry = RectangleGeometry
+ .createGeometry(new RectangleGeometry(rectangleGeometryOptions));
+ primitiveOptions.geometryInstances = new GeometryInstance[]{new GeometryInstance(geometryInstanceOptions)};
+ ellipsoidSurfaceAppearanceOptions = new EllipsoidSurfaceAppearanceOptions();
+ ellipsoidSurfaceAppearanceOptions.aboveGround = false;
+ primitiveOptions.appearance = new EllipsoidSurfaceAppearance(ellipsoidSurfaceAppearanceOptions);
+ primitiveOptions.show = false;
+ primitiveOptions.asynchronous = false;
+ worldRectangle = (Primitive) scene.primitives().add(new Primitive(primitiveOptions));
+
+ PolylineCollection polylines = (PolylineCollection) scene.primitives().add(new PolylineCollection());
+ PolylineOptions polylineOptions = new PolylineOptions();
+ PolylinePipelineOptions polylinePipelineOptions = new PolylinePipelineOptions();
+ polylinePipelineOptions.positions = Cartesian3
+ .fromDegreesArray(new double[]{-110.0, 42.0, -85.0, 36.0, -100.0, 25.0, -77.0, 12.0});
+ polylineOptions.positions = PolylinePipeline.generateCartesianArc(polylinePipelineOptions);
+ polylineOptions.width = 10.0;
+ polylineOptions.show = false;
+ polyline = polylines.add(polylineOptions);
+ }
+
+ public void toggleRectangleVisibility() {
+ rectangle.show = true;
+ worldRectangle.show = false;
+ polyline.show = false;
+ }
+
+ public void toggleWorldRectangleVisibility() {
+ rectangle.show = false;
+ worldRectangle.show = true;
+ polyline.show = false;
+ }
+
+ public void togglePolylineVisibility() {
+ rectangle.show = false;
+ worldRectangle.show = false;
+ polyline.show = true;
+ }
+
+ public void applyColorMaterial(Primitive primitive) {
+ primitive.appearance.material = Material.fromType("Color");
+ }
+
+ public void applyImageMaterial(Primitive primitive) {
+ JSONObject uniforms = new JSONObject();
+ uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg"));
+
+ JSONObject fabric = new JSONObject();
+ fabric.put("type", new JSONString("Image"));
+ fabric.put("uniforms", uniforms);
+
+ MaterialOptions materialOptions = new MaterialOptions();
+ materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
+ primitive.appearance.material = new Material(materialOptions);
+ }
+
+ public void applyCheckerboardMaterial(Primitive primitive) {
+ primitive.appearance.material = Material.fromType("Checkerboard");
+ }
+
+ public void applyDotMaterial(Primitive primitive) {
+ primitive.appearance.material = Material.fromType("Dot");
+ }
+
+ public void applyGridMaterial(Primitive primitive) {
+ primitive.appearance.material = Material.fromType("Grid");
+ }
+
+ public void applyStripeMaterial(Primitive primitive) {
+ primitive.appearance.material = Material.fromType("Stripe");
+ }
+
+ public void applyAlphaMapMaterial(Primitive primitive) {
+ JSONObject uniforms = new JSONObject();
+ uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg"));
+ uniforms.put("channel", new JSONString("r"));
+
+ JSONObject alphaMaterial = new JSONObject();
+ alphaMaterial.put("type", new JSONString("AlphaMap"));
+ alphaMaterial.put("uniforms", uniforms);
+
+ JSONObject materials = new JSONObject();
+ materials.put("alphaMaterial", alphaMaterial);
+
+ JSONObject components = new JSONObject();
+ components.put("diffuse", new JSONString("vec3(1.0)"));
+ components.put("alpha", new JSONString("alphaMaterial.alpha"));
+
+ JSONObject fabric = new JSONObject();
+ fabric.put("materials", materials);
+ fabric.put("components", components);
+
+ MaterialOptions materialOptions = new MaterialOptions();
+ materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
+ primitive.appearance.material = new Material(materialOptions);
+ }
+
+ public void applyBumpMapMaterial(Primitive primitive) {
+ JSONObject uniforms = new JSONObject();
+ uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/bumpmap.png"));
+
+ JSONObject diffuseMaterial = new JSONObject();
+ diffuseMaterial.put("type", new JSONString("DiffuseMap"));
+ diffuseMaterial.put("uniforms", uniforms);
+
+ uniforms = new JSONObject();
+ uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/bumpmap.png"));
+ uniforms.put("strength", new JSONNumber(0.8));
+
+ JSONObject bumpMaterial = new JSONObject();
+ bumpMaterial.put("type", new JSONString("BumpMap"));
+ bumpMaterial.put("uniforms", uniforms);
+
+ JSONObject materials = new JSONObject();
+ materials.put("diffuseMaterial", diffuseMaterial);
+ materials.put("bumpMaterial", bumpMaterial);
+
+ JSONObject components = new JSONObject();
+ components.put("diffuse", new JSONString("diffuseMaterial.diffuse"));
+ components.put("specular", new JSONNumber(0.01));
+ components.put("normal", new JSONString("bumpMaterial.normal"));
+
+ JSONObject fabric = new JSONObject();
+ fabric.put("materials", materials);
+ fabric.put("components", components);
+
+ MaterialOptions materialOptions = new MaterialOptions();
+ materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
+ primitive.appearance.material = new Material(materialOptions);
+ }
+
+ public void applyDiffuseMaterial(Primitive primitive) {
+ JSONObject uniforms = new JSONObject();
+ uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg"));
+
+ JSONObject fabric = new JSONObject();
+ fabric.put("type", new JSONString("DiffuseMap"));
+ fabric.put("uniforms", uniforms);
+
+ MaterialOptions materialOptions = new MaterialOptions();
+ materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
+ primitive.appearance.material = new Material(materialOptions);
+ }
+
+ public void applyEmissionMapMaterial(Primitive primitive) {
+ JSONObject uniforms = new JSONObject();
+ uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg"));
+
+ JSONObject diffuseMaterial = new JSONObject();
+ diffuseMaterial.put("type", new JSONString("DiffuseMap"));
+ diffuseMaterial.put("uniforms", uniforms);
+
+ JSONObject repeat = new JSONObject();
+ repeat.put("x", new JSONNumber(1));
+ repeat.put("y", new JSONNumber(0.5));
+
+ uniforms = new JSONObject();
+ uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/checkerboard.png"));
+ uniforms.put("repeat", repeat);
+
+ JSONObject emissionMaterial = new JSONObject();
+ emissionMaterial.put("type", new JSONString("EmissionMap"));
+ emissionMaterial.put("uniforms", uniforms);
+
+ JSONObject materials = new JSONObject();
+ materials.put("diffuseMaterial", diffuseMaterial);
+ materials.put("emissionMaterial", emissionMaterial);
+
+ JSONObject components = new JSONObject();
+ components.put("diffuse", new JSONString("diffuseMaterial.diffuse"));
+ components.put("emission", new JSONString("emissionMaterial.emission * 0.2"));
+
+ JSONObject fabric = new JSONObject();
+ fabric.put("materials", materials);
+ fabric.put("components", components);
+
+ MaterialOptions materialOptions = new MaterialOptions();
+ materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
+ primitive.appearance.material = new Material(materialOptions);
+ }
+
+ public void applyNormalMapMaterial(Primitive primitive) {
+ JSONObject uniforms = new JSONObject();
+ uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/bumpmap.png"));
+
+ JSONObject diffuseMaterial = new JSONObject();
+ diffuseMaterial.put("type", new JSONString("DiffuseMap"));
+ diffuseMaterial.put("uniforms", uniforms);
+
+ uniforms = new JSONObject();
+ uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/normalmap.png"));
+ uniforms.put("strength", new JSONNumber(0.6));
+
+ JSONObject normalMap = new JSONObject();
+ normalMap.put("type", new JSONString("NormalMap"));
+ normalMap.put("uniforms", uniforms);
+
+ JSONObject materials = new JSONObject();
+ materials.put("diffuseMaterial", diffuseMaterial);
+ materials.put("normalMap", normalMap);
+
+ JSONObject components = new JSONObject();
+ components.put("diffuse", new JSONString("diffuseMaterial.diffuse"));
+ components.put("specular", new JSONNumber(0.01));
+ components.put("normal", new JSONString("normalMap.normal"));
+
+ JSONObject fabric = new JSONObject();
+ fabric.put("materials", materials);
+ fabric.put("components", components);
+
+ MaterialOptions materialOptions = new MaterialOptions();
+ materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
+ primitive.appearance.material = new Material(materialOptions);
+ }
+
+ public void applySpecularMapMaterial(Primitive primitive) {
+ JSONObject uniforms = new JSONObject();
+ uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg"));
+ uniforms.put("channel", new JSONString("r"));
+
+ JSONObject fabric = new JSONObject();
+ fabric.put("type", new JSONString("SpecularMap"));
+ fabric.put("uniforms", uniforms);
+
+ MaterialOptions materialOptions = new MaterialOptions();
+ materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
+ primitive.appearance.material = new Material(materialOptions);
+ }
+
+ public void applyRimLightingMaterial(Primitive primitive) {
+ primitive.appearance.material = Material.fromType("RimLighting");
+ }
+
+ public void applyWaterMaterial(Primitive primitive) {
+ JSONObject uniforms = new JSONObject();
+ uniforms.put("specularMap", new JSONString(GWT.getModuleBaseURL() + "images/earthspec1k.jpg"));
+ uniforms.put("normalMap", new JSONString(GWT.getModuleBaseURL() + "images/waterNormals.jpg"));
+ uniforms.put("frequency", new JSONNumber(10000.0));
+ uniforms.put("animationSpeed", new JSONNumber(0.01));
+ uniforms.put("amplitude", new JSONNumber(1.0));
+
+ JSONObject fabric = new JSONObject();
+ fabric.put("type", new JSONString("Water"));
+ fabric.put("uniforms", uniforms);
+
+ MaterialOptions materialOptions = new MaterialOptions();
+ materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
+ primitive.appearance.material = new Material(materialOptions);
+ }
+
+ public void applyCompositeMaterial(Primitive primitive) {
+ JSONObject fabric = new JSONObject();
+
+ JSONObject uniforms = new JSONObject();
+ uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/earthspec1k.jpg"));
+ uniforms.put("heightField", new JSONString(GWT.getModuleBaseURL() + "images/earthbump1k.jpg"));
+ fabric.put("uniforms", uniforms);
+
+ uniforms = new JSONObject();
+ uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/earthbump1k.jpg"));
+
+ JSONObject bumpMap = new JSONObject();
+ bumpMap.put("type", new JSONString("BumpMap"));
+ bumpMap.put("uniforms", uniforms);
+
+ JSONObject materials = new JSONObject();
+ materials.put("bumpMap", bumpMap);
+
+ fabric.put("materials", materials);
+ fabric.put("source",
+ new JSONString("czm_material czm_getMaterial(czm_materialInput materialInput) {"
+ + "czm_material material = czm_getDefaultMaterial(materialInput);"
+ + "float heightValue = texture2D(heightField, materialInput.st).r;"
+ + "material.diffuse = mix(vec3(0.2, 0.6, 0.2), vec3(1.0, 0.5, 0.2), heightValue);"
+ + "material.alpha = (1.0 - texture2D(image, materialInput.st).r) * 0.7;"
+ + "material.normal = bumpMap.normal;" + "material.specular = step(0.1, heightValue);" + // Specular mountain
+ // tops
+ "material.shininess = 8.0;" + // Sharpen highlight
+ "return material;" + "}"));
+
+ MaterialOptions materialOptions = new MaterialOptions();
+ materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
+ primitive.appearance.material = new Material(materialOptions);
+ }
+
+ public void applyPolylineArrowMaterial(Polyline primitive) {
+ primitive.material = Material.fromType("PolylineArrow");
+ }
+
+ public void applyPolylineGlowMaterial(Polyline primitive) {
+ JsObject jsOobject = JsObject.create();
+ primitive.material = Material.fromType("PolylineGlow", JsObject.$(jsOobject, "innerWidth", primitive.width / 2.0));
+ }
+
+ public void applyPolylineOutlineMaterial(Polyline primitive) {
+ JsObject jsOobject = JsObject.create();
+ primitive.material = Material.fromType("PolylineOutline",
+ JsObject.$(jsOobject, "outlineWidth", primitive.width / 2.0));
+ }
+
+ private class MChangeHandler implements ChangeHandler {
+ @Override
+ public void onChange(ChangeEvent changeEvent) {
+ ListBox source = (ListBox) changeEvent.getSource();
+ int value = Integer.parseInt(source.getSelectedValue());
+ if (source.equals(commonMaterialLBox)) {
+ toggleRectangleVisibility();
+ if (value == 1) {
+ applyColorMaterial(rectangle);
+ } else if (value == 2) {
+ applyImageMaterial(rectangle);
+ }
+ } else if (source.equals(proceduralTexturesLBox)) {
+ toggleRectangleVisibility();
+ if (value == 1) {
+ applyCheckerboardMaterial(rectangle);
+ } else if (value == 2) {
+ applyDotMaterial(rectangle);
+ } else if (value == 3) {
+ applyGridMaterial(rectangle);
+ } else if (value == 4) {
+ applyStripeMaterial(rectangle);
+ }
+ } else if (source.equals(baseMaterialsLBox)) {
+ toggleRectangleVisibility();
+ if (value == 1) {
+ applyAlphaMapMaterial(rectangle);
+ } else if (value == 2) {
+ applyBumpMapMaterial(rectangle);
+ } else if (value == 3) {
+ applyDiffuseMaterial(rectangle);
+ } else if (value == 4) {
+ applyEmissionMapMaterial(rectangle);
+ } else if (value == 5) {
+ applyNormalMapMaterial(rectangle);
+ } else if (value == 6) {
+ applySpecularMapMaterial(rectangle);
+ }
+ } else if (source.equals(miscMaterialsLBox)) {
+ toggleWorldRectangleVisibility();
+ if (value == 1) {
+ applyRimLightingMaterial(worldRectangle);
+ } else if (value == 2) {
+ applyWaterMaterial(worldRectangle);
+ }
+ } else if (source.equals(exampleCompositeMaterialsLBox)) {
+ toggleWorldRectangleVisibility();
+ if (value == 1) {
+ applyCompositeMaterial(worldRectangle);
+ }
+ } else if (source.equals(polylineMaterialsLBox)) {
+ togglePolylineVisibility();
+ if (value == 1) {
+ applyPolylineArrowMaterial(polyline);
+ } else if (value == 2) {
+ applyPolylineGlowMaterial(polyline);
+ } else if (value == 3) {
+ applyPolylineOutlineMaterial(polyline);
+ }
+ }
}
- }
}
- }
-
- public void createPrimitives(Scene scene) {
- PrimitiveOptions primitiveOptions = new PrimitiveOptions();
- GeometryInstanceOptions geometryInstanceOptions = new GeometryInstanceOptions();
- RectangleGeometryOptions rectangleGeometryOptions = new RectangleGeometryOptions();
- rectangleGeometryOptions.rectangle = Rectangle.fromDegrees(-120.0, 20.0, -60.0, 40.0);
- rectangleGeometryOptions.vertexFormat = EllipsoidSurfaceAppearance.VERTEX_FORMAT();
- geometryInstanceOptions.geometry = RectangleGeometry
- .createGeometry(new RectangleGeometry(rectangleGeometryOptions));
- primitiveOptions.geometryInstances = new GeometryInstance[] { new GeometryInstance(geometryInstanceOptions) };
- EllipsoidSurfaceAppearanceOptions ellipsoidSurfaceAppearanceOptions = new EllipsoidSurfaceAppearanceOptions();
- ellipsoidSurfaceAppearanceOptions.aboveGround = false;
- primitiveOptions.asynchronous = false;
- primitiveOptions.appearance = new EllipsoidSurfaceAppearance(ellipsoidSurfaceAppearanceOptions);
- rectangle = (Primitive) scene.primitives().add(new Primitive(primitiveOptions));
-
- primitiveOptions = new PrimitiveOptions();
- geometryInstanceOptions = new GeometryInstanceOptions();
- rectangleGeometryOptions = new RectangleGeometryOptions();
- rectangleGeometryOptions.rectangle = Rectangle.fromDegrees(-180.0, -90.0, 180.0, 90.0);
- rectangleGeometryOptions.vertexFormat = EllipsoidSurfaceAppearance.VERTEX_FORMAT();
- geometryInstanceOptions.geometry = RectangleGeometry
- .createGeometry(new RectangleGeometry(rectangleGeometryOptions));
- primitiveOptions.geometryInstances = new GeometryInstance[] { new GeometryInstance(geometryInstanceOptions) };
- ellipsoidSurfaceAppearanceOptions = new EllipsoidSurfaceAppearanceOptions();
- ellipsoidSurfaceAppearanceOptions.aboveGround = false;
- primitiveOptions.appearance = new EllipsoidSurfaceAppearance(ellipsoidSurfaceAppearanceOptions);
- primitiveOptions.show = false;
- primitiveOptions.asynchronous = false;
- worldRectangle = (Primitive) scene.primitives().add(new Primitive(primitiveOptions));
-
- PolylineCollection polylines = (PolylineCollection) scene.primitives().add(new PolylineCollection());
- PolylineOptions polylineOptions = new PolylineOptions();
- PolylinePipelineOptions polylinePipelineOptions = new PolylinePipelineOptions();
- polylinePipelineOptions.positions = Cartesian3
- .fromDegreesArray(new double[] { -110.0, 42.0, -85.0, 36.0, -100.0, 25.0, -77.0, 12.0 });
- polylineOptions.positions = PolylinePipeline.generateCartesianArc(polylinePipelineOptions);
- polylineOptions.width = 10.0;
- polylineOptions.show = false;
- polyline = polylines.add(polylineOptions);
- }
-
- public void toggleRectangleVisibility() {
- rectangle.show = true;
- worldRectangle.show = false;
- polyline.show = false;
- }
-
- public void toggleWorldRectangleVisibility() {
- rectangle.show = false;
- worldRectangle.show = true;
- polyline.show = false;
- }
-
- public void togglePolylineVisibility() {
- rectangle.show = false;
- worldRectangle.show = false;
- polyline.show = true;
- }
-
- public void applyColorMaterial(Primitive primitive) {
- primitive.appearance.material = Material.fromType("Color");
- }
-
- public void applyImageMaterial(Primitive primitive) {
- JSONObject uniforms = new JSONObject();
- uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg"));
-
- JSONObject fabric = new JSONObject();
- fabric.put("type", new JSONString("Image"));
- fabric.put("uniforms", uniforms);
-
- MaterialOptions materialOptions = new MaterialOptions();
- materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
- primitive.appearance.material = new Material(materialOptions);
- }
-
- public void applyCheckerboardMaterial(Primitive primitive) {
- primitive.appearance.material = Material.fromType("Checkerboard");
- }
-
- public void applyDotMaterial(Primitive primitive) {
- primitive.appearance.material = Material.fromType("Dot");
- }
-
- public void applyGridMaterial(Primitive primitive) {
- primitive.appearance.material = Material.fromType("Grid");
- }
-
- public void applyStripeMaterial(Primitive primitive) {
- primitive.appearance.material = Material.fromType("Stripe");
- }
-
- public void applyAlphaMapMaterial(Primitive primitive) {
- JSONObject uniforms = new JSONObject();
- uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg"));
- uniforms.put("channel", new JSONString("r"));
-
- JSONObject alphaMaterial = new JSONObject();
- alphaMaterial.put("type", new JSONString("AlphaMap"));
- alphaMaterial.put("uniforms", uniforms);
-
- JSONObject materials = new JSONObject();
- materials.put("alphaMaterial", alphaMaterial);
-
- JSONObject components = new JSONObject();
- components.put("diffuse", new JSONString("vec3(1.0)"));
- components.put("alpha", new JSONString("alphaMaterial.alpha"));
-
- JSONObject fabric = new JSONObject();
- fabric.put("materials", materials);
- fabric.put("components", components);
-
- MaterialOptions materialOptions = new MaterialOptions();
- materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
- primitive.appearance.material = new Material(materialOptions);
- }
-
- public void applyBumpMapMaterial(Primitive primitive) {
- JSONObject uniforms = new JSONObject();
- uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/bumpmap.png"));
-
- JSONObject diffuseMaterial = new JSONObject();
- diffuseMaterial.put("type", new JSONString("DiffuseMap"));
- diffuseMaterial.put("uniforms", uniforms);
-
- uniforms = new JSONObject();
- uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/bumpmap.png"));
- uniforms.put("strength", new JSONNumber(0.8));
-
- JSONObject bumpMaterial = new JSONObject();
- bumpMaterial.put("type", new JSONString("BumpMap"));
- bumpMaterial.put("uniforms", uniforms);
-
- JSONObject materials = new JSONObject();
- materials.put("diffuseMaterial", diffuseMaterial);
- materials.put("bumpMaterial", bumpMaterial);
-
- JSONObject components = new JSONObject();
- components.put("diffuse", new JSONString("diffuseMaterial.diffuse"));
- components.put("specular", new JSONNumber(0.01));
- components.put("normal", new JSONString("bumpMaterial.normal"));
-
- JSONObject fabric = new JSONObject();
- fabric.put("materials", materials);
- fabric.put("components", components);
-
- MaterialOptions materialOptions = new MaterialOptions();
- materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
- primitive.appearance.material = new Material(materialOptions);
- }
-
- public void applyDiffuseMaterial(Primitive primitive) {
- JSONObject uniforms = new JSONObject();
- uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg"));
-
- JSONObject fabric = new JSONObject();
- fabric.put("type", new JSONString("DiffuseMap"));
- fabric.put("uniforms", uniforms);
-
- MaterialOptions materialOptions = new MaterialOptions();
- materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
- primitive.appearance.material = new Material(materialOptions);
- }
-
- public void applyEmissionMapMaterial(Primitive primitive) {
- JSONObject uniforms = new JSONObject();
- uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg"));
-
- JSONObject diffuseMaterial = new JSONObject();
- diffuseMaterial.put("type", new JSONString("DiffuseMap"));
- diffuseMaterial.put("uniforms", uniforms);
-
- JSONObject repeat = new JSONObject();
- repeat.put("x", new JSONNumber(1));
- repeat.put("y", new JSONNumber(0.5));
-
- uniforms = new JSONObject();
- uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/checkerboard.png"));
- uniforms.put("repeat", repeat);
-
- JSONObject emissionMaterial = new JSONObject();
- emissionMaterial.put("type", new JSONString("EmissionMap"));
- emissionMaterial.put("uniforms", uniforms);
-
- JSONObject materials = new JSONObject();
- materials.put("diffuseMaterial", diffuseMaterial);
- materials.put("emissionMaterial", emissionMaterial);
-
- JSONObject components = new JSONObject();
- components.put("diffuse", new JSONString("diffuseMaterial.diffuse"));
- components.put("emission", new JSONString("emissionMaterial.emission * 0.2"));
-
- JSONObject fabric = new JSONObject();
- fabric.put("materials", materials);
- fabric.put("components", components);
-
- MaterialOptions materialOptions = new MaterialOptions();
- materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
- primitive.appearance.material = new Material(materialOptions);
- }
-
- public void applyNormalMapMaterial(Primitive primitive) {
- JSONObject uniforms = new JSONObject();
- uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/bumpmap.png"));
-
- JSONObject diffuseMaterial = new JSONObject();
- diffuseMaterial.put("type", new JSONString("DiffuseMap"));
- diffuseMaterial.put("uniforms", uniforms);
-
- uniforms = new JSONObject();
- uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/normalmap.png"));
- uniforms.put("strength", new JSONNumber(0.6));
-
- JSONObject normalMap = new JSONObject();
- normalMap.put("type", new JSONString("NormalMap"));
- normalMap.put("uniforms", uniforms);
-
- JSONObject materials = new JSONObject();
- materials.put("diffuseMaterial", diffuseMaterial);
- materials.put("normalMap", normalMap);
-
- JSONObject components = new JSONObject();
- components.put("diffuse", new JSONString("diffuseMaterial.diffuse"));
- components.put("specular", new JSONNumber(0.01));
- components.put("normal", new JSONString("normalMap.normal"));
-
- JSONObject fabric = new JSONObject();
- fabric.put("materials", materials);
- fabric.put("components", components);
-
- MaterialOptions materialOptions = new MaterialOptions();
- materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
- primitive.appearance.material = new Material(materialOptions);
- }
-
- public void applySpecularMapMaterial(Primitive primitive) {
- JSONObject uniforms = new JSONObject();
- uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg"));
- uniforms.put("channel", new JSONString("r"));
-
- JSONObject fabric = new JSONObject();
- fabric.put("type", new JSONString("SpecularMap"));
- fabric.put("uniforms", uniforms);
-
- MaterialOptions materialOptions = new MaterialOptions();
- materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
- primitive.appearance.material = new Material(materialOptions);
- }
-
- public void applyRimLightingMaterial(Primitive primitive) {
- primitive.appearance.material = Material.fromType("RimLighting");
- }
-
- public void applyWaterMaterial(Primitive primitive) {
- JSONObject uniforms = new JSONObject();
- uniforms.put("specularMap", new JSONString(GWT.getModuleBaseURL() + "images/earthspec1k.jpg"));
- uniforms.put("normalMap", new JSONString(GWT.getModuleBaseURL() + "images/waterNormals.jpg"));
- uniforms.put("frequency", new JSONNumber(10000.0));
- uniforms.put("animationSpeed", new JSONNumber(0.01));
- uniforms.put("amplitude", new JSONNumber(1.0));
-
- JSONObject fabric = new JSONObject();
- fabric.put("type", new JSONString("Water"));
- fabric.put("uniforms", uniforms);
-
- MaterialOptions materialOptions = new MaterialOptions();
- materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
- primitive.appearance.material = new Material(materialOptions);
- }
-
- public void applyCompositeMaterial(Primitive primitive) {
- JSONObject fabric = new JSONObject();
-
- JSONObject uniforms = new JSONObject();
- uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/earthspec1k.jpg"));
- uniforms.put("heightField", new JSONString(GWT.getModuleBaseURL() + "images/earthbump1k.jpg"));
- fabric.put("uniforms", uniforms);
-
- uniforms = new JSONObject();
- uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/earthbump1k.jpg"));
-
- JSONObject bumpMap = new JSONObject();
- bumpMap.put("type", new JSONString("BumpMap"));
- bumpMap.put("uniforms", uniforms);
-
- JSONObject materials = new JSONObject();
- materials.put("bumpMap", bumpMap);
-
- fabric.put("materials", materials);
- fabric.put("source",
- new JSONString("czm_material czm_getMaterial(czm_materialInput materialInput) {"
- + "czm_material material = czm_getDefaultMaterial(materialInput);"
- + "float heightValue = texture2D(heightField, materialInput.st).r;"
- + "material.diffuse = mix(vec3(0.2, 0.6, 0.2), vec3(1.0, 0.5, 0.2), heightValue);"
- + "material.alpha = (1.0 - texture2D(image, materialInput.st).r) * 0.7;"
- + "material.normal = bumpMap.normal;" + "material.specular = step(0.1, heightValue);" + // Specular mountain
- // tops
- "material.shininess = 8.0;" + // Sharpen highlight
- "return material;" + "}"));
-
- MaterialOptions materialOptions = new MaterialOptions();
- materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
- primitive.appearance.material = new Material(materialOptions);
- }
-
- public void applyPolylineArrowMaterial(Polyline primitive) {
- primitive.material = Material.fromType("PolylineArrow");
- }
-
- public void applyPolylineGlowMaterial(Polyline primitive) {
- JsObject jsOobject = JsObject.create();
- primitive.material = Material.fromType("PolylineGlow", JsObject.$(jsOobject, "innerWidth", primitive.width / 2.0));
- }
-
- public void applyPolylineOutlineMaterial(Polyline primitive) {
- JsObject jsOobject = JsObject.create();
- primitive.material = Material.fromType("PolylineOutline",
- JsObject.$(jsOobject, "outlineWidth", primitive.width / 2.0));
- }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Models3D.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Models3D.java
index ac0e9dac5c86b2d404de209fe7809bd954dec3ae..e31fb745756c1651ed4640776df7c76156b003f6 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Models3D.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Models3D.java
@@ -16,15 +16,12 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.ListBox;
-
import org.cesiumjs.cs.core.Cartesian3;
import org.cesiumjs.cs.core.Math;
import org.cesiumjs.cs.core.Quaternion;
@@ -39,116 +36,117 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class Models3D extends AbstractExample {
- private ViewerPanel csVPanel;
-
- @Inject
- public Models3D(ShowcaseExampleStore store) {
- super("3D Models", "Create 3D models using glTF",
- new String[] { "Showcase", "Cesium", "3d", "gltf", "glb", "models" }, store);
- }
-
- @Override
- public void buildPanel() {
- ViewerOptions csViewerOptions = new ViewerOptions();
- csViewerOptions.infoBox = false;
- csViewerOptions.selectionIndicator = false;
- csViewerOptions.shadows = false;
- csVPanel = new ViewerPanel(csViewerOptions);
-
- ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(
- GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb");
- modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(128);
- modelGraphicsOptions.maximumScale = new ConstantProperty<>(20000);
- ModelGraphics modelGraphics = new ModelGraphics(modelGraphicsOptions);
-
- Cartesian3 position = Cartesian3.fromDegrees(-123.0744619, 44.0503706, 5000.0);
- double heading = Math.toRadians(135);
- double pitch = 0;
- double roll = 0;
- Quaternion orientation = Transforms.headingPitchRollQuaternion(position,
- new org.cesiumjs.cs.core.HeadingPitchRoll(heading, pitch, roll));
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.name = GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb";
- entityOptions.position = new ConstantPositionProperty(position);
- entityOptions.orientation = new ConstantProperty<>(orientation);
- entityOptions.model = modelGraphics;
- csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
-
- final ListBox modelsLBox = new ListBox();
- modelsLBox.addItem("Aircraft", "0");
- modelsLBox.addItem("Ground vehicle", "1");
- modelsLBox.addItem("Hot Air Balloon", "2");
- modelsLBox.addItem("Milk truck", "3");
- modelsLBox.addItem("Skinned character", "4");
- modelsLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent changeEvent) {
+ private ViewerPanel csVPanel;
+
+ @Inject
+ public Models3D(ShowcaseExampleStore store) {
+ super("3D Models", "Create 3D models using glTF",
+ new String[]{"Showcase", "Cesium", "3d", "gltf", "glb", "models"}, store);
+ }
+
+ @Override
+ public void buildPanel() {
+ ViewerOptions csViewerOptions = new ViewerOptions();
+ csViewerOptions.infoBox = false;
+ csViewerOptions.selectionIndicator = false;
+ csViewerOptions.shadows = false;
+ csVPanel = new ViewerPanel(csViewerOptions);
+
+ ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
+ modelGraphicsOptions.uri = new ConstantProperty<>(
+ GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb");
+ modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(128);
+ modelGraphicsOptions.maximumScale = new ConstantProperty<>(20000);
+ ModelGraphics modelGraphics = new ModelGraphics(modelGraphicsOptions);
+
+ Cartesian3 position = Cartesian3.fromDegrees(-123.0744619, 44.0503706, 5000.0);
+ double heading = Math.toRadians(135);
+ double pitch = 0;
+ double roll = 0;
+ Quaternion orientation = Transforms.headingPitchRollQuaternion(position,
+ new org.cesiumjs.cs.core.HeadingPitchRoll(heading, pitch, roll));
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.name = GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb";
+ entityOptions.position = new ConstantPositionProperty(position);
+ entityOptions.orientation = new ConstantProperty<>(orientation);
+ entityOptions.model = modelGraphics;
+ csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
+
+ final ListBox modelsLBox = new ListBox();
+ modelsLBox.addItem("Aircraft", "0");
+ modelsLBox.addItem("Ground vehicle", "1");
+ modelsLBox.addItem("Hot Air Balloon", "2");
+ modelsLBox.addItem("Milk truck", "3");
+ modelsLBox.addItem("Skinned character", "4");
+ modelsLBox.addChangeHandler(new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent changeEvent) {
+ csVPanel.getViewer().entities().removeAll();
+ switch (modelsLBox.getSelectedValue()) {
+ case "0":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb", 5000.0);
+ break;
+ case "1":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumGround/Cesium_Ground.glb", 0);
+ break;
+ case "2":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb", 1000.0);
+ break;
+ case "3":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumMilkTruck/CesiumMilkTruck-kmc.glb", 0);
+ break;
+ case "4":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb", 0);
+ break;
+ default:
+ break;
+ }
+ }
+ });
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(modelsLBox, 20, 20);
+
+ contentPanel.add(new HTML("Create 3D models using glTF.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Models3D.txt";
+ return sourceCodeURLs;
+ }
+
+ private void createModel(String url, double height) {
csVPanel.getViewer().entities().removeAll();
- switch (modelsLBox.getSelectedValue()) {
- case "0":
- createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb", 5000.0);
- break;
- case "1":
- createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumGround/Cesium_Ground.glb", 0);
- break;
- case "2":
- createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb", 1000.0);
- break;
- case "3":
- createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumMilkTruck/CesiumMilkTruck-kmc.glb", 0);
- break;
- case "4":
- createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb", 0);
- break;
- default:
- break;
- }
- }
- });
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(modelsLBox, 20, 20);
-
- contentPanel.add(new HTML("Create 3D models using glTF.
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Models3D.txt";
- return sourceCodeURLs;
- }
-
- private void createModel(String url, double height) {
- csVPanel.getViewer().entities().removeAll();
-
- ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(url);
- modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(128);
- modelGraphicsOptions.maximumScale = new ConstantProperty<>(20000);
- ModelGraphics modelGraphics = new ModelGraphics(modelGraphicsOptions);
-
- Cartesian3 position = Cartesian3.fromDegrees(-123.0744619, 44.0503706, height);
- double heading = Math.toRadians(135);
- double pitch = 0;
- double roll = 0;
- Quaternion orientation = Transforms.headingPitchRollQuaternion(position,
- new org.cesiumjs.cs.core.HeadingPitchRoll(heading, pitch, roll));
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.name = url;
- entityOptions.position = new ConstantPositionProperty(position);
- entityOptions.orientation = new ConstantProperty<>(orientation);
- entityOptions.model = modelGraphics;
- csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
- ;
- }
+
+ ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
+ modelGraphicsOptions.uri = new ConstantProperty<>(url);
+ modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(128);
+ modelGraphicsOptions.maximumScale = new ConstantProperty<>(20000);
+ ModelGraphics modelGraphics = new ModelGraphics(modelGraphicsOptions);
+
+ Cartesian3 position = Cartesian3.fromDegrees(-123.0744619, 44.0503706, height);
+ double heading = Math.toRadians(135);
+ double pitch = 0;
+ double roll = 0;
+ Quaternion orientation = Transforms.headingPitchRollQuaternion(position,
+ new org.cesiumjs.cs.core.HeadingPitchRoll(heading, pitch, roll));
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.name = url;
+ entityOptions.position = new ConstantPositionProperty(position);
+ entityOptions.orientation = new ConstantProperty<>(orientation);
+ entityOptions.model = modelGraphics;
+ csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Models3DColoring.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Models3DColoring.java
index f1a66dfa225c4fafed390088ada9fffba964aebe..85e86995f66da78b5ea5cfdcccecad8c852793ee 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Models3DColoring.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Models3DColoring.java
@@ -16,25 +16,14 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
-import com.google.gwt.user.client.ui.AbsolutePanel;
-import com.google.gwt.user.client.ui.CheckBox;
-import com.google.gwt.user.client.ui.FlexTable;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.ListBox;
-import com.google.gwt.user.client.ui.TextBox;
-
-import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.Color;
+import com.google.gwt.user.client.ui.*;
import org.cesiumjs.cs.core.Math;
-import org.cesiumjs.cs.core.Quaternion;
-import org.cesiumjs.cs.core.Transforms;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.datasources.graphics.ModelGraphics;
import org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions;
import org.cesiumjs.cs.datasources.options.EntityOptions;
@@ -49,365 +38,366 @@ import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class Models3DColoring extends AbstractExample {
- private ViewerPanel csVPanel;
- private Slider mixSlider;
- private TextBox mixTBox;
-
- private Slider alphaSlider;
- private TextBox alphaTBox;
-
- private Slider silhouetteAlphaSlider;
- private TextBox silhouetteAlphaTBox;
-
- private Slider silhouetteSizeSlider;
- private TextBox silhouetteSizeTBox;
-
- // private Color color = Color.RED();
- private String colorStr = "red";
- private float alpha = 1.0f;
- private Number colorBlendMode = ColorBlendMode.HIGHLIGHT();
- private float colorBlendAmount = 0.5f;
-
- private Color silhouetteColor = Color.RED();
- private String silhouetteColorStr = "red";
- private float silhouetteAlpha = 1.0f;
- private float silhouetteSize = 2.0f;
-
- @Inject
- public Models3DColoring(ShowcaseExampleStore store) {
- super("3D Models Coloring", "Create 3D models coloring",
- new String[] { "Showcase", "Cesium", "3d", "gltf", "glb", "models", "ColorBlendMode" }, store);
- }
-
- @Override
- public void buildPanel() {
- ViewerOptions csViewerOptions = new ViewerOptions();
- csViewerOptions.infoBox = false;
- csViewerOptions.selectionIndicator = false;
- csViewerOptions.shadows = false;
- csVPanel = new ViewerPanel(csViewerOptions);
-
- ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(
- GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb");
- modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(128);
- modelGraphicsOptions.maximumScale = new ConstantProperty<>(20000);
- modelGraphicsOptions.color = new ConstantProperty<>(getColor("red", alpha));
- modelGraphicsOptions.colorBlendMode = new ConstantProperty<>(ColorBlendMode.HIGHLIGHT());
- modelGraphicsOptions.colorBlendAmount = new ConstantProperty<>(colorBlendAmount);
- modelGraphicsOptions.silhouetteColor = new ConstantProperty<>(getColor("red", alpha));
- modelGraphicsOptions.silhouetteSize = new ConstantProperty<>(silhouetteSize);
-
- ModelGraphics modelGraphics = new ModelGraphics(modelGraphicsOptions);
-
- Cartesian3 position = Cartesian3.fromDegrees(-123.0744619, 44.0503706, 5000.0);
- double heading = Math.toRadians(135);
- double pitch = 0;
- double roll = 0;
- org.cesiumjs.cs.core.HeadingPitchRoll hpr = new org.cesiumjs.cs.core.HeadingPitchRoll(heading, pitch, roll);
- Quaternion orientation = Transforms.headingPitchRollQuaternion(position, hpr);
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.name = GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb";
- entityOptions.position = new ConstantPositionProperty(position);
- entityOptions.orientation = new ConstantProperty<>(orientation);
- entityOptions.model = modelGraphics;
- csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
-
- ListBox modeLBox = new ListBox();
- modeLBox.addItem("Hightlight", "0");
- modeLBox.addItem("Replace", "1");
- modeLBox.addItem("Mix", "2");
- modeLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent event) {
- ListBox source = (ListBox) event.getSource();
+ private ViewerPanel csVPanel;
+ private Slider mixSlider;
+ private TextBox mixTBox;
+
+ private Slider alphaSlider;
+ private TextBox alphaTBox;
+
+ private Slider silhouetteAlphaSlider;
+ private TextBox silhouetteAlphaTBox;
+
+ private Slider silhouetteSizeSlider;
+ private TextBox silhouetteSizeTBox;
+
+ // private Color color = Color.RED();
+ private String colorStr = "red";
+ private float alpha = 1.0f;
+ private Number colorBlendMode = ColorBlendMode.HIGHLIGHT();
+ private float colorBlendAmount = 0.5f;
+
+ private Color silhouetteColor = Color.RED();
+ private String silhouetteColorStr = "red";
+ private float silhouetteAlpha = 1.0f;
+ private float silhouetteSize = 2.0f;
+
+ @Inject
+ public Models3DColoring(ShowcaseExampleStore store) {
+ super("3D Models Coloring", "Create 3D models coloring",
+ new String[]{"Showcase", "Cesium", "3d", "gltf", "glb", "models", "ColorBlendMode"}, store);
+ }
+
+ @Override
+ public void buildPanel() {
+ ViewerOptions csViewerOptions = new ViewerOptions();
+ csViewerOptions.infoBox = false;
+ csViewerOptions.selectionIndicator = false;
+ csViewerOptions.shadows = false;
+ csVPanel = new ViewerPanel(csViewerOptions);
+
+ ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
+ modelGraphicsOptions.uri = new ConstantProperty<>(
+ GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb");
+ modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(128);
+ modelGraphicsOptions.maximumScale = new ConstantProperty<>(20000);
+ modelGraphicsOptions.color = new ConstantProperty<>(getColor("red", alpha));
+ modelGraphicsOptions.colorBlendMode = new ConstantProperty<>(ColorBlendMode.HIGHLIGHT());
+ modelGraphicsOptions.colorBlendAmount = new ConstantProperty<>(colorBlendAmount);
+ modelGraphicsOptions.silhouetteColor = new ConstantProperty<>(getColor("red", alpha));
+ modelGraphicsOptions.silhouetteSize = new ConstantProperty<>(silhouetteSize);
+
+ ModelGraphics modelGraphics = new ModelGraphics(modelGraphicsOptions);
+
+ Cartesian3 position = Cartesian3.fromDegrees(-123.0744619, 44.0503706, 5000.0);
+ double heading = Math.toRadians(135);
+ double pitch = 0;
+ double roll = 0;
+ org.cesiumjs.cs.core.HeadingPitchRoll hpr = new org.cesiumjs.cs.core.HeadingPitchRoll(heading, pitch, roll);
+ Quaternion orientation = Transforms.headingPitchRollQuaternion(position, hpr);
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.name = GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb";
+ entityOptions.position = new ConstantPositionProperty(position);
+ entityOptions.orientation = new ConstantProperty<>(orientation);
+ entityOptions.model = modelGraphics;
+ csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
+
+ ListBox modeLBox = new ListBox();
+ modeLBox.addItem("Hightlight", "0");
+ modeLBox.addItem("Replace", "1");
+ modeLBox.addItem("Mix", "2");
+ modeLBox.addChangeHandler(new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent event) {
+ ListBox source = (ListBox) event.getSource();
+ mixSlider.setVisible(false);
+ mixTBox.setVisible(false);
+ if (source.getSelectedValue().equalsIgnoreCase("0")) {
+ colorBlendMode = ColorBlendMode.HIGHLIGHT();
+ } else if (source.getSelectedValue().equalsIgnoreCase("1")) {
+ colorBlendMode = ColorBlendMode.REPLACE();
+ } else if (source.getSelectedValue().equalsIgnoreCase("2")) {
+ colorBlendMode = ColorBlendMode.MIX();
+ mixSlider.setVisible(true);
+ mixTBox.setVisible(true);
+ }
+
+ csVPanel.getViewer().trackedEntity.model.colorBlendMode = new ConstantProperty<>(colorBlendMode);
+ }
+ });
+
+ ListBox colorLBox = new ListBox();
+ colorLBox.addItem("White", "White");
+ colorLBox.addItem("Red", "Red");
+ colorLBox.addItem("Green", "Green");
+ colorLBox.addItem("Blue", "Blue");
+ colorLBox.addItem("Yellow", "Yellow");
+ colorLBox.addItem("Gray", "Gray");
+ colorLBox.setSelectedIndex(1);
+ colorLBox.addChangeHandler(new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent event) {
+ ListBox source = (ListBox) event.getSource();
+ colorStr = source.getSelectedValue();
+ csVPanel.getViewer().trackedEntity.model.color = new ConstantProperty<>(
+ getColor(source.getSelectedValue(), alpha));
+ }
+ });
+
+ alphaSlider = new Slider("Alpha", 0, 100, 100);
+ alphaSlider.setWidth("100px");
+ alphaSlider.setStep(1);
+ alphaSlider.addListener(new MSliderListener());
+ alphaTBox = new TextBox();
+ alphaTBox.setSize("30px", "12px");
+ alphaTBox.setValue("" + 1);
+ alphaTBox.addChangeHandler(new MChangeHandler());
+
+ mixSlider = new Slider("Mix", 0, 100, 50);
+ mixSlider.setStep(1);
mixSlider.setVisible(false);
+ mixSlider.addListener(new MSliderListener());
+ mixTBox = new TextBox();
+ mixTBox.setSize("30px", "12px");
+ mixTBox.setValue("0.5");
mixTBox.setVisible(false);
- if (source.getSelectedValue().equalsIgnoreCase("0")) {
- colorBlendMode = ColorBlendMode.HIGHLIGHT();
- } else if (source.getSelectedValue().equalsIgnoreCase("1")) {
- colorBlendMode = ColorBlendMode.REPLACE();
- } else if (source.getSelectedValue().equalsIgnoreCase("2")) {
- colorBlendMode = ColorBlendMode.MIX();
- mixSlider.setVisible(true);
- mixTBox.setVisible(true);
- }
-
- csVPanel.getViewer().trackedEntity.model.colorBlendMode = new ConstantProperty<>(colorBlendMode);
- }
- });
-
- ListBox colorLBox = new ListBox();
- colorLBox.addItem("White", "White");
- colorLBox.addItem("Red", "Red");
- colorLBox.addItem("Green", "Green");
- colorLBox.addItem("Blue", "Blue");
- colorLBox.addItem("Yellow", "Yellow");
- colorLBox.addItem("Gray", "Gray");
- colorLBox.setSelectedIndex(1);
- colorLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent event) {
- ListBox source = (ListBox) event.getSource();
- colorStr = source.getSelectedValue();
- csVPanel.getViewer().trackedEntity.model.color = new ConstantProperty<>(
- getColor(source.getSelectedValue(), alpha));
- }
- });
-
- alphaSlider = new Slider("Alpha", 0, 100, 100);
- alphaSlider.setWidth("100px");
- alphaSlider.setStep(1);
- alphaSlider.addListener(new MSliderListener());
- alphaTBox = new TextBox();
- alphaTBox.setSize("30px", "12px");
- alphaTBox.setValue("" + 1);
- alphaTBox.addChangeHandler(new MChangeHandler());
-
- mixSlider = new Slider("Mix", 0, 100, 50);
- mixSlider.setStep(1);
- mixSlider.setVisible(false);
- mixSlider.addListener(new MSliderListener());
- mixTBox = new TextBox();
- mixTBox.setSize("30px", "12px");
- mixTBox.setValue("0.5");
- mixTBox.setVisible(false);
- mixTBox.addChangeHandler(new MChangeHandler());
-
- ListBox silhouetteColorLBox = new ListBox();
- silhouetteColorLBox.addItem("Red", "Red");
- silhouetteColorLBox.addItem("Green", "Green");
- silhouetteColorLBox.addItem("Blue", "Blue");
- silhouetteColorLBox.addItem("Yellow", "Yellow");
- silhouetteColorLBox.addItem("Gray", "Gray");
- silhouetteColorLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent event) {
- ListBox source = (ListBox) event.getSource();
- silhouetteColorStr = source.getSelectedValue();
- silhouetteColor = getColor(source.getSelectedValue(), alpha);
- csVPanel.getViewer().trackedEntity.model.silhouetteColor = new ConstantProperty<>(
- getColor(silhouetteColorStr, silhouetteAlpha));
- }
- });
-
- silhouetteAlphaSlider = new Slider("SilhouetteAlpha", 0, 100, 100);
- silhouetteAlphaSlider.setStep(1);
- silhouetteAlphaSlider.addListener(new MSliderListener());
- silhouetteAlphaTBox = new TextBox();
- silhouetteAlphaTBox.setSize("30px", "12px");
- silhouetteAlphaTBox.setValue("" + 1);
- silhouetteAlphaTBox.addChangeHandler(new MChangeHandler());
-
- silhouetteSizeSlider = new Slider("SizeAlpha", 0, 1000, 20);
- silhouetteSizeSlider.setStep(1);
- silhouetteSizeSlider.addListener(new MSliderListener());
- silhouetteSizeTBox = new TextBox();
- silhouetteSizeTBox.setSize("30px", "12px");
- silhouetteSizeTBox.setValue("" + 2);
- silhouetteSizeTBox.addChangeHandler(new MChangeHandler());
-
- final ListBox modelsLBox = new ListBox();
- modelsLBox.addItem("Aircraft", "0");
- modelsLBox.addItem("Ground vehicle", "1");
- modelsLBox.addItem("Hot Air Balloon", "2");
- modelsLBox.addItem("Milk truck", "3");
- modelsLBox.addItem("Skinned character", "4");
- modelsLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent changeEvent) {
- csVPanel.getViewer().entities().removeAll();
- switch (modelsLBox.getSelectedValue()) {
- case "0":
- createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb", 5000.0);
- break;
- case "1":
- createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumGround/Cesium_Ground.glb", 0);
- break;
- case "2":
- createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb", 1000.0);
- break;
- case "3":
- createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumMilkTruck/CesiumMilkTruck-kmc.glb", 0);
- break;
- case "4":
- createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb", 0);
- break;
- default:
- break;
- }
- }
- });
-
- CheckBox shadowsCBox = new CheckBox("Shadows");
- shadowsCBox.getElement().getStyle().setColor("white");
- shadowsCBox.setWidth("100px");
- shadowsCBox.setValue(true);
- shadowsCBox.addValueChangeHandler(new ValueChangeHandler() {
- @Override
- public void onValueChange(ValueChangeEvent event) {
- csVPanel.getViewer().shadows = event.getValue();
- }
- });
-
- FlexTable flexTable = new FlexTable();
- flexTable.setHTML(1, 0, "Model Color");
- flexTable.setHTML(2, 0, "Mode");
- flexTable.setWidget(2, 1, modeLBox);
- flexTable.setHTML(3, 0, "Color");
- flexTable.setWidget(3, 1, colorLBox);
- flexTable.setHTML(4, 0, "Alpha");
- flexTable.setWidget(4, 1, alphaSlider);
- flexTable.setWidget(4, 2, alphaTBox);
- flexTable.setHTML(5, 0, "Mix");
- flexTable.setWidget(5, 1, mixSlider);
- flexTable.setWidget(5, 2, mixTBox);
- flexTable.setHTML(6, 0, "Model Silhouette");
- flexTable.setHTML(7, 0, "Color");
- flexTable.setWidget(7, 1, silhouetteColorLBox);
- flexTable.setHTML(8, 0, "Alpha");
- flexTable.setWidget(8, 1, silhouetteAlphaSlider);
- flexTable.setWidget(8, 2, silhouetteAlphaTBox);
- flexTable.setHTML(9, 0, "Size");
- flexTable.setWidget(9, 1, silhouetteSizeSlider);
- flexTable.setWidget(9, 2, silhouetteSizeTBox);
-
- flexTable.setWidget(10, 0, modelsLBox);
- flexTable.setWidget(10, 1, shadowsCBox);
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(flexTable, 20, 20);
-
- contentPanel.add(new HTML("Create 3D coloring models.
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Models3DColoring.txt";
- return sourceCodeURLs;
- }
-
- private void createModel(String url, double height) {
- csVPanel.getViewer().entities().removeAll();
-
- ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(url);
- modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(128);
- modelGraphicsOptions.maximumScale = new ConstantProperty<>(20000);
- modelGraphicsOptions.color = new ConstantProperty<>(getColor(colorStr, alpha));
- modelGraphicsOptions.colorBlendAmount = new ConstantProperty<>(colorBlendMode);
- modelGraphicsOptions.silhouetteColor = new ConstantProperty<>(silhouetteColor);
- modelGraphicsOptions.silhouetteSize = new ConstantProperty<>(silhouetteSize);
- ModelGraphics modelGraphics = new ModelGraphics(modelGraphicsOptions);
-
- Cartesian3 position = Cartesian3.fromDegrees(-123.0744619, 44.0503706, height);
- double heading = Math.toRadians(135);
- double pitch = 0;
- double roll = 0;
- org.cesiumjs.cs.core.HeadingPitchRoll hpr = new org.cesiumjs.cs.core.HeadingPitchRoll(heading, pitch, roll);
- Quaternion orientation = Transforms.headingPitchRollQuaternion(position, hpr);
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.name = url;
- entityOptions.position = new ConstantPositionProperty(position);
- entityOptions.orientation = new ConstantProperty<>(orientation);
- entityOptions.model = modelGraphics;
- csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
- ;
- }
-
- private Color getColor(String colorName, float alpha) {
- Color color = null;
- if (colorName.equalsIgnoreCase("White")) {
- color = Color.WHITE();
- } else if (colorName.equalsIgnoreCase("Red")) {
- color = Color.RED();
- } else if (colorName.equalsIgnoreCase("Green")) {
- color = Color.GREEN();
- } else if (colorName.equalsIgnoreCase("Blue")) {
- color = Color.BLUE();
- } else if (colorName.equalsIgnoreCase("Yellow")) {
- color = Color.YELLOW();
- } else if (colorName.equalsIgnoreCase("Gray")) {
- color = Color.GRAY();
+ mixTBox.addChangeHandler(new MChangeHandler());
+
+ ListBox silhouetteColorLBox = new ListBox();
+ silhouetteColorLBox.addItem("Red", "Red");
+ silhouetteColorLBox.addItem("Green", "Green");
+ silhouetteColorLBox.addItem("Blue", "Blue");
+ silhouetteColorLBox.addItem("Yellow", "Yellow");
+ silhouetteColorLBox.addItem("Gray", "Gray");
+ silhouetteColorLBox.addChangeHandler(new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent event) {
+ ListBox source = (ListBox) event.getSource();
+ silhouetteColorStr = source.getSelectedValue();
+ silhouetteColor = getColor(source.getSelectedValue(), alpha);
+ csVPanel.getViewer().trackedEntity.model.silhouetteColor = new ConstantProperty<>(
+ getColor(silhouetteColorStr, silhouetteAlpha));
+ }
+ });
+
+ silhouetteAlphaSlider = new Slider("SilhouetteAlpha", 0, 100, 100);
+ silhouetteAlphaSlider.setStep(1);
+ silhouetteAlphaSlider.addListener(new MSliderListener());
+ silhouetteAlphaTBox = new TextBox();
+ silhouetteAlphaTBox.setSize("30px", "12px");
+ silhouetteAlphaTBox.setValue("" + 1);
+ silhouetteAlphaTBox.addChangeHandler(new MChangeHandler());
+
+ silhouetteSizeSlider = new Slider("SizeAlpha", 0, 1000, 20);
+ silhouetteSizeSlider.setStep(1);
+ silhouetteSizeSlider.addListener(new MSliderListener());
+ silhouetteSizeTBox = new TextBox();
+ silhouetteSizeTBox.setSize("30px", "12px");
+ silhouetteSizeTBox.setValue("" + 2);
+ silhouetteSizeTBox.addChangeHandler(new MChangeHandler());
+
+ final ListBox modelsLBox = new ListBox();
+ modelsLBox.addItem("Aircraft", "0");
+ modelsLBox.addItem("Ground vehicle", "1");
+ modelsLBox.addItem("Hot Air Balloon", "2");
+ modelsLBox.addItem("Milk truck", "3");
+ modelsLBox.addItem("Skinned character", "4");
+ modelsLBox.addChangeHandler(new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent changeEvent) {
+ csVPanel.getViewer().entities().removeAll();
+ switch (modelsLBox.getSelectedValue()) {
+ case "0":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb", 5000.0);
+ break;
+ case "1":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumGround/Cesium_Ground.glb", 0);
+ break;
+ case "2":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb", 1000.0);
+ break;
+ case "3":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumMilkTruck/CesiumMilkTruck-kmc.glb", 0);
+ break;
+ case "4":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb", 0);
+ break;
+ default:
+ break;
+ }
+ }
+ });
+
+ CheckBox shadowsCBox = new CheckBox("Shadows");
+ shadowsCBox.getElement().getStyle().setColor("white");
+ shadowsCBox.setWidth("100px");
+ shadowsCBox.setValue(true);
+ shadowsCBox.addValueChangeHandler(new ValueChangeHandler() {
+ @Override
+ public void onValueChange(ValueChangeEvent event) {
+ csVPanel.getViewer().shadows = event.getValue();
+ }
+ });
+
+ FlexTable flexTable = new FlexTable();
+ flexTable.setHTML(1, 0, "Model Color");
+ flexTable.setHTML(2, 0, "Mode");
+ flexTable.setWidget(2, 1, modeLBox);
+ flexTable.setHTML(3, 0, "Color");
+ flexTable.setWidget(3, 1, colorLBox);
+ flexTable.setHTML(4, 0, "Alpha");
+ flexTable.setWidget(4, 1, alphaSlider);
+ flexTable.setWidget(4, 2, alphaTBox);
+ flexTable.setHTML(5, 0, "Mix");
+ flexTable.setWidget(5, 1, mixSlider);
+ flexTable.setWidget(5, 2, mixTBox);
+ flexTable.setHTML(6, 0, "Model Silhouette");
+ flexTable.setHTML(7, 0, "Color");
+ flexTable.setWidget(7, 1, silhouetteColorLBox);
+ flexTable.setHTML(8, 0, "Alpha");
+ flexTable.setWidget(8, 1, silhouetteAlphaSlider);
+ flexTable.setWidget(8, 2, silhouetteAlphaTBox);
+ flexTable.setHTML(9, 0, "Size");
+ flexTable.setWidget(9, 1, silhouetteSizeSlider);
+ flexTable.setWidget(9, 2, silhouetteSizeTBox);
+
+ flexTable.setWidget(10, 0, modelsLBox);
+ flexTable.setWidget(10, 1, shadowsCBox);
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(flexTable, 20, 20);
+
+ contentPanel.add(new HTML("Create 3D coloring models.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
}
- return Color.fromAlpha(color, alpha, null);
- }
- private class MChangeHandler implements ChangeHandler {
@Override
- public void onChange(ChangeEvent event) {
- TextBox source = (TextBox) event.getSource();
- float value = Float.parseFloat(source.getValue());
- if (source == alphaTBox) {
- alphaSlider.setValue((int) (value * 100));
- alpha = value;
- csVPanel.getViewer().trackedEntity.model.color = new ConstantProperty<>(getColor(colorStr, alpha));
- } else if (source == mixTBox) {
- mixSlider.setValue((int) (value * 100));
- colorBlendAmount = value;
- csVPanel.getViewer().trackedEntity.model.colorBlendAmount = new ConstantProperty<>(colorBlendAmount);
- } else if (source == silhouetteAlphaTBox) {
- silhouetteAlphaSlider.setValue((int) (value * 100));
- silhouetteAlpha = value;
- csVPanel.getViewer().trackedEntity.model.silhouetteColor = new ConstantProperty<>(
- getColor(silhouetteColorStr, silhouetteAlpha));
- } else if (source == silhouetteSizeTBox) {
- silhouetteSizeSlider.setValue((int) (value * 100));
- silhouetteSize = value;
- csVPanel.getViewer().trackedEntity.model.silhouetteSize = new ConstantProperty<>(silhouetteSize);
- }
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Models3DColoring.txt";
+ return sourceCodeURLs;
}
- }
- private class MSliderListener implements SliderListener {
+ private void createModel(String url, double height) {
+ csVPanel.getViewer().entities().removeAll();
- @Override
- public void onStart(SliderEvent e) {
+ ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
+ modelGraphicsOptions.uri = new ConstantProperty<>(url);
+ modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(128);
+ modelGraphicsOptions.maximumScale = new ConstantProperty<>(20000);
+ modelGraphicsOptions.color = new ConstantProperty<>(getColor(colorStr, alpha));
+ modelGraphicsOptions.colorBlendAmount = new ConstantProperty<>(colorBlendMode);
+ modelGraphicsOptions.silhouetteColor = new ConstantProperty<>(silhouetteColor);
+ modelGraphicsOptions.silhouetteSize = new ConstantProperty<>(silhouetteSize);
+ ModelGraphics modelGraphics = new ModelGraphics(modelGraphicsOptions);
+
+ Cartesian3 position = Cartesian3.fromDegrees(-123.0744619, 44.0503706, height);
+ double heading = Math.toRadians(135);
+ double pitch = 0;
+ double roll = 0;
+ org.cesiumjs.cs.core.HeadingPitchRoll hpr = new org.cesiumjs.cs.core.HeadingPitchRoll(heading, pitch, roll);
+ Quaternion orientation = Transforms.headingPitchRollQuaternion(position, hpr);
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.name = url;
+ entityOptions.position = new ConstantPositionProperty(position);
+ entityOptions.orientation = new ConstantProperty<>(orientation);
+ entityOptions.model = modelGraphics;
+ csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
+ }
+ private Color getColor(String colorName, float alpha) {
+ Color color = null;
+ if (colorName.equalsIgnoreCase("White")) {
+ color = Color.WHITE();
+ } else if (colorName.equalsIgnoreCase("Red")) {
+ color = Color.RED();
+ } else if (colorName.equalsIgnoreCase("Green")) {
+ color = Color.GREEN();
+ } else if (colorName.equalsIgnoreCase("Blue")) {
+ color = Color.BLUE();
+ } else if (colorName.equalsIgnoreCase("Yellow")) {
+ color = Color.YELLOW();
+ } else if (colorName.equalsIgnoreCase("Gray")) {
+ color = Color.GRAY();
+ }
+ return Color.fromAlpha(color, alpha, null);
}
- @Override
- public boolean onSlide(SliderEvent e) {
- Slider source = e.getSource();
- float value = source.getValue() / 100.0f;
- if (source == alphaSlider) {
- alphaTBox.setValue("" + value);
- alpha = value;
- csVPanel.getViewer().trackedEntity.model.color = new ConstantProperty<>(getColor(colorStr, alpha));
- } else if (source == mixSlider) {
- mixTBox.setValue("" + value);
- colorBlendAmount = value;
- csVPanel.getViewer().trackedEntity.model.colorBlendAmount = new ConstantProperty<>(colorBlendAmount);
- } else if (source == silhouetteAlphaSlider) {
- silhouetteAlphaTBox.setValue("" + value);
- silhouetteAlpha = value;
- csVPanel.getViewer().trackedEntity.model.silhouetteColor = new ConstantProperty<>(
- getColor(silhouetteColorStr, silhouetteAlpha));
- } else if (source == silhouetteSizeSlider) {
- silhouetteSizeTBox.setValue("" + value);
- silhouetteSize = value;
- csVPanel.getViewer().trackedEntity.model.silhouetteSize = new ConstantProperty<>(silhouetteSize);
- }
- return true;
+ private class MChangeHandler implements ChangeHandler {
+ @Override
+ public void onChange(ChangeEvent event) {
+ TextBox source = (TextBox) event.getSource();
+ float value = Float.parseFloat(source.getValue());
+ if (source == alphaTBox) {
+ alphaSlider.setValue((int) (value * 100));
+ alpha = value;
+ csVPanel.getViewer().trackedEntity.model.color = new ConstantProperty<>(getColor(colorStr, alpha));
+ } else if (source == mixTBox) {
+ mixSlider.setValue((int) (value * 100));
+ colorBlendAmount = value;
+ csVPanel.getViewer().trackedEntity.model.colorBlendAmount = new ConstantProperty<>(colorBlendAmount);
+ } else if (source == silhouetteAlphaTBox) {
+ silhouetteAlphaSlider.setValue((int) (value * 100));
+ silhouetteAlpha = value;
+ csVPanel.getViewer().trackedEntity.model.silhouetteColor = new ConstantProperty<>(
+ getColor(silhouetteColorStr, silhouetteAlpha));
+ } else if (source == silhouetteSizeTBox) {
+ silhouetteSizeSlider.setValue((int) (value * 100));
+ silhouetteSize = value;
+ csVPanel.getViewer().trackedEntity.model.silhouetteSize = new ConstantProperty<>(silhouetteSize);
+ }
+ }
}
- @Override
- public void onChange(SliderEvent e) {
+ private class MSliderListener implements SliderListener {
- }
+ @Override
+ public void onStart(SliderEvent e) {
- @Override
- public void onStop(SliderEvent e) {
+ }
+ @Override
+ public boolean onSlide(SliderEvent e) {
+ Slider source = e.getSource();
+ float value = source.getValue() / 100.0f;
+ if (source == alphaSlider) {
+ alphaTBox.setValue("" + value);
+ alpha = value;
+ csVPanel.getViewer().trackedEntity.model.color = new ConstantProperty<>(getColor(colorStr, alpha));
+ } else if (source == mixSlider) {
+ mixTBox.setValue("" + value);
+ colorBlendAmount = value;
+ csVPanel.getViewer().trackedEntity.model.colorBlendAmount = new ConstantProperty<>(colorBlendAmount);
+ } else if (source == silhouetteAlphaSlider) {
+ silhouetteAlphaTBox.setValue("" + value);
+ silhouetteAlpha = value;
+ csVPanel.getViewer().trackedEntity.model.silhouetteColor = new ConstantProperty<>(
+ getColor(silhouetteColorStr, silhouetteAlpha));
+ } else if (source == silhouetteSizeSlider) {
+ silhouetteSizeTBox.setValue("" + value);
+ silhouetteSize = value;
+ csVPanel.getViewer().trackedEntity.model.silhouetteSize = new ConstantProperty<>(silhouetteSize);
+ }
+ return true;
+ }
+
+ @Override
+ public void onChange(SliderEvent e) {
+
+ }
+
+ @Override
+ public void onStop(SliderEvent e) {
+
+ }
}
- }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/MultipleSyncedViews.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/MultipleSyncedViews.java
index 574ced12f3ddde0bfe254d416d9ef7eb76ec83e0..2a4e0fbc2792c32ddd7ef5f162d2270bcb327e50 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/MultipleSyncedViews.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/MultipleSyncedViews.java
@@ -16,12 +16,9 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
-
import org.cesiumjs.cs.core.Cartesian2;
import org.cesiumjs.cs.core.Cartesian3;
import org.cesiumjs.cs.core.Event;
@@ -32,92 +29,94 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class MultipleSyncedViews extends AbstractExample {
- private ViewerPanel view3D;
- private ViewerPanel view2D;
+ private ViewerPanel view3D;
+ private ViewerPanel view2D;
- private Cartesian3 worldPosition;
- private double distance;
+ private Cartesian3 worldPosition;
+ private double distance;
- @Inject
- public MultipleSyncedViews(ShowcaseExampleStore store) {
- super("Multiple Synced Views", "Multiple views synced across time and space", new String[] { "sync" }, store);
- }
+ @Inject
+ public MultipleSyncedViews(ShowcaseExampleStore store) {
+ super("Multiple Synced Views", "Multiple views synced across time and space", new String[]{"sync"}, store);
+ }
- @Override
- public void buildPanel() {
- ClockViewModel clockViewModel = new ClockViewModel();
+ @Override
+ public void buildPanel() {
+ ClockViewModel clockViewModel = new ClockViewModel();
- ViewerOptions viewer3dOptions = new ViewerOptions();
- viewer3dOptions.fullscreenButton = false;
- viewer3dOptions.sceneModePicker = false;
- viewer3dOptions.clockViewModel = clockViewModel;
- view3D = new ViewerPanel(viewer3dOptions);
- view3D.setWidth("500px");
- view3D.getViewer().camera.changed().addEventListener(new Event.Listener() {
- @Override
- public void function(Object... o) {
- sync2DView();
- }
- });
- view3D.getViewer().camera.percentageChanged = 0.01f;
+ ViewerOptions viewer3dOptions = new ViewerOptions();
+ viewer3dOptions.fullscreenButton = false;
+ viewer3dOptions.sceneModePicker = false;
+ viewer3dOptions.clockViewModel = clockViewModel;
+ view3D = new ViewerPanel(viewer3dOptions);
+ view3D.setWidth("500px");
+ view3D.getViewer().camera.changed().addEventListener(new Event.Listener() {
+ @Override
+ public void function(Object... o) {
+ sync2DView();
+ }
+ });
+ view3D.getViewer().camera.percentageChanged = 0.01f;
- ViewerOptions viewer2dOptions = new ViewerOptions();
- viewer2dOptions.homeButton = false;
- viewer2dOptions.fullscreenButton = false;
- viewer2dOptions.sceneModePicker = false;
- viewer2dOptions.clockViewModel = clockViewModel;
- viewer2dOptions.infoBox = false;
- viewer2dOptions.geocoder = false;
- viewer2dOptions.sceneMode = SceneMode.SCENE2D();
- viewer2dOptions.navigationHelpButton = false;
- viewer2dOptions.animation = false;
- view2D = new ViewerPanel(viewer2dOptions);
- view2D.setWidth("500px");
- view2D.getViewer().scene().screenSpaceCameraController().enableRotate = false;
- view2D.getViewer().scene().screenSpaceCameraController().enableTranslate = false;
- view2D.getViewer().scene().screenSpaceCameraController().enableZoom = false;
- view2D.getViewer().scene().screenSpaceCameraController().enableTilt = false;
- view2D.getViewer().scene().screenSpaceCameraController().enableLook = false;
+ ViewerOptions viewer2dOptions = new ViewerOptions();
+ viewer2dOptions.homeButton = false;
+ viewer2dOptions.fullscreenButton = false;
+ viewer2dOptions.sceneModePicker = false;
+ viewer2dOptions.clockViewModel = clockViewModel;
+ viewer2dOptions.infoBox = false;
+ viewer2dOptions.geocoder = false;
+ viewer2dOptions.sceneMode = SceneMode.SCENE2D();
+ viewer2dOptions.navigationHelpButton = false;
+ viewer2dOptions.animation = false;
+ view2D = new ViewerPanel(viewer2dOptions);
+ view2D.setWidth("500px");
+ view2D.getViewer().scene().screenSpaceCameraController().enableRotate = false;
+ view2D.getViewer().scene().screenSpaceCameraController().enableTranslate = false;
+ view2D.getViewer().scene().screenSpaceCameraController().enableZoom = false;
+ view2D.getViewer().scene().screenSpaceCameraController().enableTilt = false;
+ view2D.getViewer().scene().screenSpaceCameraController().enableLook = false;
- HorizontalPanel hPanel = new HorizontalPanel();
- hPanel.add(view3D);
- hPanel.add(view2D);
+ HorizontalPanel hPanel = new HorizontalPanel();
+ hPanel.add(view3D);
+ hPanel.add(view2D);
- contentPanel.add(new HTML("Multiple views synced across time and space.
"));
- contentPanel.add(hPanel);
+ contentPanel.add(new HTML("Multiple views synced across time and space.
"));
+ contentPanel.add(hPanel);
- initWidget(contentPanel);
- }
+ initWidget(contentPanel);
+ }
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "MultipleSyncedViews.txt";
- return sourceCodeURLs;
- }
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "MultipleSyncedViews.txt";
+ return sourceCodeURLs;
+ }
- private void sync2DView() {
- // The center of the view is the point that the 3D camera is focusing on
- Cartesian2 viewCenter = new Cartesian2(Math.floor(view3D.getViewer().canvas().getClientWidth() / 2),
- Math.floor(view3D.getViewer().canvas().getClientHeight() / 2));
- // Given the pixel in the center, get the world position
- Cartesian3 newWorldPosition = view3D.getViewer().scene().camera().pickEllipsoid(viewCenter);
- if (newWorldPosition != null) {
- // Guard against the case where the center of the screen
- // does not fall on a position on the globe
- worldPosition = newWorldPosition;
+ private void sync2DView() {
+ // The center of the view is the point that the 3D camera is focusing on
+ Cartesian2 viewCenter = new Cartesian2(Math.floor(view3D.getViewer().canvas().getClientWidth() / 2),
+ Math.floor(view3D.getViewer().canvas().getClientHeight() / 2));
+ // Given the pixel in the center, get the world position
+ Cartesian3 newWorldPosition = view3D.getViewer().scene().camera().pickEllipsoid(viewCenter);
+ if (newWorldPosition != null) {
+ // Guard against the case where the center of the screen
+ // does not fall on a position on the globe
+ worldPosition = newWorldPosition;
+ }
+ // Get the distance between the world position of the point the camera is
+ // focusing on, and the camera's world position
+ distance = Cartesian3.distance(worldPosition, view3D.getViewer().scene().camera().positionWC());
+ // Tell the 2D camera to look at the point of focus. The distance controls how
+ // zoomed in the 2D view is
+ // (try replacing `distance` in the line below with `1e7`. The view will still
+ // sync, but will have a constant zoom)
+ view2D.getViewer().scene().camera().lookAt(worldPosition, new Cartesian3(0.0, 0.0, distance));
}
- // Get the distance between the world position of the point the camera is
- // focusing on, and the camera's world position
- distance = Cartesian3.distance(worldPosition, view3D.getViewer().scene().camera().positionWC());
- // Tell the 2D camera to look at the point of focus. The distance controls how
- // zoomed in the 2D view is
- // (try replacing `distance` in the line below with `1e7`. The view will still
- // sync, but will have a constant zoom)
- view2D.getViewer().scene().camera().lookAt(worldPosition, new Cartesian3(0.0, 0.0, distance));
- }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ParticleSystem.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ParticleSystem.java
index 6d308c11db9440f91d25551763f97a56a7965f92..008da8bea58ed426493aecdfba8970e6efcde7a6 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ParticleSystem.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ParticleSystem.java
@@ -16,46 +16,23 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
-import com.google.gwt.user.client.ui.AbsolutePanel;
-import com.google.gwt.user.client.ui.CheckBox;
-import com.google.gwt.user.client.ui.FlexTable;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.ListBox;
-import com.google.gwt.user.client.ui.TextBox;
-
+import com.google.gwt.user.client.ui.*;
import org.cesiumjs.cs.Cesium;
import org.cesiumjs.cs.collections.TimeIntervalCollection;
-import org.cesiumjs.cs.core.Cartesian2;
-import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.Color;
-import org.cesiumjs.cs.core.Ellipsoid;
-import org.cesiumjs.cs.core.Event;
-import org.cesiumjs.cs.core.JulianDate;
import org.cesiumjs.cs.core.Math;
-import org.cesiumjs.cs.core.Matrix3;
-import org.cesiumjs.cs.core.Matrix4;
-import org.cesiumjs.cs.core.Quaternion;
-import org.cesiumjs.cs.core.TimeInterval;
-import org.cesiumjs.cs.core.Transforms;
-import org.cesiumjs.cs.core.TranslationRotationScale;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.core.enums.ClockRange;
import org.cesiumjs.cs.core.options.TimeIntervalOptions;
import org.cesiumjs.cs.datasources.Entity;
import org.cesiumjs.cs.datasources.graphics.ModelGraphics;
import org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions;
import org.cesiumjs.cs.datasources.options.EntityOptions;
-import org.cesiumjs.cs.datasources.properties.ConstantPositionProperty;
-import org.cesiumjs.cs.datasources.properties.ConstantProperty;
-import org.cesiumjs.cs.datasources.properties.Property;
-import org.cesiumjs.cs.datasources.properties.SampledPositionProperty;
-import org.cesiumjs.cs.datasources.properties.VelocityOrientationProperty;
+import org.cesiumjs.cs.datasources.properties.*;
import org.cesiumjs.cs.js.JsDate;
import org.cesiumjs.cs.js.JsObject;
import org.cesiumjs.cs.scene.Scene;
@@ -73,614 +50,616 @@ import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import javax.inject.Inject;
+
/**
* @author Serge Silaev aka iSergio
*/
public class ParticleSystem extends AbstractExample {
- private ViewModel viewModel = new ViewModel();
+ private final ViewModel viewModel = new ViewModel();
- private Slider rateSlider;
- private TextBox rateTBox;
+ private Slider rateSlider;
+ private TextBox rateTBox;
- private Slider sizeSlider;
- private TextBox sizeTBox;
+ private Slider sizeSlider;
+ private TextBox sizeTBox;
- private Slider minLifeSlider;
- private TextBox minLifeTBox;
+ private Slider minLifeSlider;
+ private TextBox minLifeTBox;
- private Slider maxLifeSlider;
- private TextBox maxLifeTBox;
+ private Slider maxLifeSlider;
+ private TextBox maxLifeTBox;
- private Slider minSpeedSlider;
- private TextBox minSpeedTBox;
+ private Slider minSpeedSlider;
+ private TextBox minSpeedTBox;
- private Slider maxSpeedSlider;
- private TextBox maxSpeedTBox;
+ private Slider maxSpeedSlider;
+ private TextBox maxSpeedTBox;
- private Slider startScaleSlider;
- private TextBox startScaleTBox;
+ private Slider startScaleSlider;
+ private TextBox startScaleTBox;
- private Slider endScaleSlider;
- private TextBox endScaleTBox;
+ private Slider endScaleSlider;
+ private TextBox endScaleTBox;
- private Slider gravitySlider;
- private TextBox gravityTBox;
+ private Slider gravitySlider;
+ private TextBox gravityTBox;
- private TextBox translationXTBox;
- private TextBox translationYTBox;
- private TextBox translationZTBox;
+ private TextBox translationXTBox;
+ private TextBox translationYTBox;
+ private TextBox translationZTBox;
- private TextBox rotationHTBox;
- private TextBox rotationPTBox;
- private TextBox rotationRTBox;
+ private TextBox rotationHTBox;
+ private TextBox rotationPTBox;
+ private TextBox rotationRTBox;
- private CheckBox spinCBox;
- private CheckBox flyCBox;
- private CheckBox showCBox;
+ private CheckBox spinCBox;
+ private CheckBox flyCBox;
+ private CheckBox showCBox;
- private SampledPositionProperty circularPosition;
- private Cartesian3 staticPosition;
+ private SampledPositionProperty circularPosition;
+ private Cartesian3 staticPosition;
- // Set bounds of our simulation time
- private JulianDate start = JulianDate.fromDate(new JsDate(2015, 2, 25, 16));
- private JulianDate stop = JulianDate.addSeconds(start, 360, new JulianDate());
+ // Set bounds of our simulation time
+ private final JulianDate start = JulianDate.fromDate(new JsDate(2015, 2, 25, 16));
+ private final JulianDate stop = JulianDate.addSeconds(start, 360, new JulianDate());
- private Cartesian3 entityPosition = new Cartesian3();
- private Quaternion entityOrientation = new Quaternion();
- private Matrix3 rotationMatrix = new Matrix3();
- private Matrix4 modelMatrix = new Matrix4();
+ private final Cartesian3 entityPosition = new Cartesian3();
+ private final Quaternion entityOrientation = new Quaternion();
+ private final Matrix3 rotationMatrix = new Matrix3();
+ private Matrix4 modelMatrix = new Matrix4();
- private Matrix4 emitterModelMatrix = new Matrix4();
- private Cartesian3 translation = new Cartesian3();
- private Quaternion rotation = new Quaternion();
- private org.cesiumjs.cs.core.HeadingPitchRoll hpr = new org.cesiumjs.cs.core.HeadingPitchRoll();
- private TranslationRotationScale trs = new TranslationRotationScale();
+ private final Matrix4 emitterModelMatrix = new Matrix4();
+ private final Cartesian3 translation = new Cartesian3();
+ private final Quaternion rotation = new Quaternion();
+ private org.cesiumjs.cs.core.HeadingPitchRoll hpr = new org.cesiumjs.cs.core.HeadingPitchRoll();
+ private final TranslationRotationScale trs = new TranslationRotationScale();
- private Cartesian3 gravityScratch = new Cartesian3();
+ private final Cartesian3 gravityScratch = new Cartesian3();
- private Entity entity;
- private org.cesiumjs.cs.scene.particle.ParticleSystem particleSystem;
+ private Entity entity;
+ private org.cesiumjs.cs.scene.particle.ParticleSystem particleSystem;
- @Inject
- public ParticleSystem(ShowcaseExampleStore store) {
- super("Particle System", "Particle systems.", new String[] { "Showcase", "Cesium", "3d", "Viewer", "Particle" },
- store);
- }
+ @Inject
+ public ParticleSystem(ShowcaseExampleStore store) {
+ super("Particle System", "Particle systems.", new String[]{"Showcase", "Cesium", "3d", "Viewer", "Particle"},
+ store);
+ }
- @Override
- public void buildPanel() {
- ViewerPanel csVPanel = new ViewerPanel();
+ @Override
+ public void buildPanel() {
+ ViewerPanel csVPanel = new ViewerPanel();
- // Set the random number seed for consistent results.
- Math.setRandomNumberSeed(3);
+ // Set the random number seed for consistent results.
+ Math.setRandomNumberSeed(3);
- // Make sure viewer is at the desired time.
- csVPanel.getViewer().clock().startTime = start.clone();
- csVPanel.getViewer().clock().stopTime = stop.clone();
- csVPanel.getViewer().clock().currentTime = start.clone();
- csVPanel.getViewer().clock().clockRange = ClockRange.LOOP_STOP(); // Loop at the end
- csVPanel.getViewer().clock().multiplier = 1;
- csVPanel.getViewer().clock().shouldAnimate = true;
+ // Make sure viewer is at the desired time.
+ csVPanel.getViewer().clock().startTime = start.clone();
+ csVPanel.getViewer().clock().stopTime = stop.clone();
+ csVPanel.getViewer().clock().currentTime = start.clone();
+ csVPanel.getViewer().clock().clockRange = ClockRange.LOOP_STOP(); // Loop at the end
+ csVPanel.getViewer().clock().multiplier = 1;
+ csVPanel.getViewer().clock().shouldAnimate = true;
- // Set timeline to simulation bounds
- csVPanel.getViewer().timeline().zoomTo(start, stop);
+ // Set timeline to simulation bounds
+ csVPanel.getViewer().timeline().zoomTo(start, stop);
- // Compute the entity position property.
- circularPosition = computeCirclularFlight(-112.110693, 36.0994841, 0.03);
- staticPosition = Cartesian3.fromDegrees(-112.110693, 36.0994841, 1000);
+ // Compute the entity position property.
+ circularPosition = computeCirclularFlight(-112.110693, 36.0994841, 0.03);
+ staticPosition = Cartesian3.fromDegrees(-112.110693, 36.0994841, 1000);
- TimeIntervalOptions timeIntervalOptions = new TimeIntervalOptions();
- timeIntervalOptions.start = start;
- timeIntervalOptions.stop = stop;
+ TimeIntervalOptions timeIntervalOptions = new TimeIntervalOptions();
+ timeIntervalOptions.start = start;
+ timeIntervalOptions.stop = stop;
- ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(
- GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.gltf");
- modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(64);
+ ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
+ modelGraphicsOptions.uri = new ConstantProperty<>(
+ GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.gltf");
+ modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(64);
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.availability = new TimeIntervalCollection(
- new TimeInterval[] { new TimeInterval(timeIntervalOptions) });
- entityOptions.model = new ModelGraphics(modelGraphicsOptions);
- entityOptions.position = new ConstantPositionProperty(staticPosition);
- entity = csVPanel.getViewer().entities().add(entityOptions);
- csVPanel.getViewer().trackedEntity = entity;
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.availability = new TimeIntervalCollection(
+ new TimeInterval[]{new TimeInterval(timeIntervalOptions)});
+ entityOptions.model = new ModelGraphics(modelGraphicsOptions);
+ entityOptions.position = new ConstantPositionProperty(staticPosition);
+ entity = csVPanel.getViewer().entities().add(entityOptions);
+ csVPanel.getViewer().trackedEntity = entity;
- ParticleSystemOptions particleSystemOptions = new ParticleSystemOptions();
- particleSystemOptions.image = GWT.getModuleBaseURL() + "SampleData/fire.png";
+ ParticleSystemOptions particleSystemOptions = new ParticleSystemOptions();
+ particleSystemOptions.image = GWT.getModuleBaseURL() + "SampleData/fire.png";
- particleSystemOptions.startColor = Color.RED().withAlpha(0.7f);
- particleSystemOptions.endColor = Color.YELLOW().withAlpha(0.3f);
+ particleSystemOptions.startColor = Color.RED().withAlpha(0.7f);
+ particleSystemOptions.endColor = Color.YELLOW().withAlpha(0.3f);
- particleSystemOptions.startScale = viewModel.startScale;
- particleSystemOptions.endScale = viewModel.endScale;
+ particleSystemOptions.startScale = viewModel.startScale;
+ particleSystemOptions.endScale = viewModel.endScale;
- particleSystemOptions.minimumParticleLife = viewModel.minimumParticleLife;
- particleSystemOptions.maximumParticleLife = viewModel.maximumParticleLife;
+ particleSystemOptions.minimumParticleLife = viewModel.minimumParticleLife;
+ particleSystemOptions.maximumParticleLife = viewModel.maximumParticleLife;
- particleSystemOptions.minimumSpeed = viewModel.minimumSpeed;
- particleSystemOptions.maximumSpeed = viewModel.maximumSpeed;
+ particleSystemOptions.minimumSpeed = viewModel.minimumSpeed;
+ particleSystemOptions.maximumSpeed = viewModel.maximumSpeed;
- particleSystemOptions.imageSize = new Cartesian2(viewModel.particleSize, viewModel.particleSize);
+ particleSystemOptions.imageSize = new Cartesian2(viewModel.particleSize, viewModel.particleSize);
- particleSystemOptions.emissionRate = viewModel.emissionRate;
+ particleSystemOptions.emissionRate = viewModel.emissionRate;
- particleSystemOptions.bursts = new ParticleBurst[] { ParticleBurst.create(5.0, 300, 500),
- ParticleBurst.create(10.0, 50, 100), ParticleBurst.create(15.0, 200, 300) };
+ particleSystemOptions.bursts = new ParticleBurst[]{ParticleBurst.create(5.0, 300, 500),
+ ParticleBurst.create(10.0, 50, 100), ParticleBurst.create(15.0, 200, 300)};
- particleSystemOptions.lifetime = 16.0;
+ particleSystemOptions.lifetime = 16.0;
- particleSystemOptions.emitter = new CircleEmitter(2.0);
+ particleSystemOptions.emitter = new CircleEmitter(2.0);
- particleSystemOptions.emitterModelMatrix = computeEmitterModelMatrix();
+ particleSystemOptions.emitterModelMatrix = computeEmitterModelMatrix();
- particleSystemOptions.updateCallback = new org.cesiumjs.cs.scene.particle.ParticleSystem.UpdateCallback() {
- @Override
- public void function(Particle particle, double dt) {
- Cartesian3 position = particle.position;
+ particleSystemOptions.updateCallback = new org.cesiumjs.cs.scene.particle.ParticleSystem.UpdateCallback() {
+ @Override
+ public void function(Particle particle, double dt) {
+ Cartesian3 position = particle.position;
- Cartesian3.normalize(position, gravityScratch);
- Cartesian3.multiplyByScalar(gravityScratch, viewModel.gravity * dt, gravityScratch);
+ Cartesian3.normalize(position, gravityScratch);
+ Cartesian3.multiplyByScalar(gravityScratch, viewModel.gravity * dt, gravityScratch);
- particle.velocity = Cartesian3.add(particle.velocity, gravityScratch, particle.velocity);
- }
- };
+ particle.velocity = Cartesian3.add(particle.velocity, gravityScratch, particle.velocity);
+ }
+ };
- particleSystem = (org.cesiumjs.cs.scene.particle.ParticleSystem) csVPanel.getViewer().scene().primitives()
- .add(new org.cesiumjs.cs.scene.particle.ParticleSystem(particleSystemOptions));
+ particleSystem = (org.cesiumjs.cs.scene.particle.ParticleSystem) csVPanel.getViewer().scene().primitives()
+ .add(new org.cesiumjs.cs.scene.particle.ParticleSystem(particleSystemOptions));
- csVPanel.getViewer().scene().preRender().addEventListener(new Event.Listener() {
- @Override
- public void function(Object... o) {
- Scene scene = (Scene) o[0];
- JulianDate time = (JulianDate) o[1];
- particleSystem.modelMatrix = computeModelMatrix(entity, time);
+ csVPanel.getViewer().scene().preRender().addEventListener(new Event.Listener() {
+ @Override
+ public void function(Object... o) {
+ Scene scene = (Scene) o[0];
+ JulianDate time = (JulianDate) o[1];
+ particleSystem.modelMatrix = computeModelMatrix(entity, time);
- // Account for any changes to the emitter model matrix.
- particleSystem.emitterModelMatrix = computeEmitterModelMatrix();
+ // Account for any changes to the emitter model matrix.
+ particleSystem.emitterModelMatrix = computeEmitterModelMatrix();
- // Spin the emitter if enabled.
- if (viewModel.spin) {
- viewModel.heading += 1.0;
- viewModel.pitch += 1.0;
- viewModel.roll += 1.0;
+ // Spin the emitter if enabled.
+ if (viewModel.spin) {
+ viewModel.heading += 1.0;
+ viewModel.pitch += 1.0;
+ viewModel.roll += 1.0;
- rotationHTBox.setValue(viewModel.heading + "");
- rotationPTBox.setValue(viewModel.pitch + "");
- rotationRTBox.setValue(viewModel.roll + "");
- }
- }
- });
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(createWidget(), 20, 20);
-
- contentPanel.add(new HTML("Particle systems.
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
- }
-
- public FlexTable createWidget() {
- MSliderListener sliderListener = new MSliderListener();
- MChangeHandler tboxListener = new MChangeHandler();
-
- rateSlider = new Slider("rate", 0, 100, (int) viewModel.emissionRate);
- rateSlider.setStep(1);
- rateSlider.setWidth("150px");
- rateSlider.addListener(sliderListener);
- rateTBox = new TextBox();
- rateTBox.setValue("" + (int) viewModel.emissionRate);
- rateTBox.setSize("30px", "12px");
- rateTBox.addChangeHandler(tboxListener);
-
- sizeSlider = new Slider("size", 2, 60, (int) viewModel.particleSize);
- sizeSlider.setStep(1);
- sizeSlider.setWidth("150px");
- sizeSlider.addListener(sliderListener);
- sizeTBox = new TextBox();
- sizeTBox.setValue("" + (int) viewModel.particleSize);
- sizeTBox.setSize("30px", "12px");
- sizeTBox.addChangeHandler(tboxListener);
-
- minLifeSlider = new Slider("minLife", 1, 30, (int) viewModel.minimumParticleLife);
- minLifeSlider.setStep(1);
- minLifeSlider.setWidth("150px");
- minLifeSlider.addListener(sliderListener);
- minLifeTBox = new TextBox();
- minLifeTBox.setValue("" + (int) viewModel.minimumParticleLife);
- minLifeTBox.setSize("30px", "12px");
- minLifeTBox.addChangeHandler(tboxListener);
-
- maxLifeSlider = new Slider("maxLife", 1, 30, (int) viewModel.maximumParticleLife);
- maxLifeSlider.setStep(1);
- maxLifeSlider.setWidth("150px");
- maxLifeSlider.addListener(sliderListener);
- maxLifeTBox = new TextBox();
- maxLifeTBox.setValue("" + (int) viewModel.maximumParticleLife);
- maxLifeTBox.setSize("30px", "12px");
- maxLifeTBox.addChangeHandler(tboxListener);
-
- minSpeedSlider = new Slider("minSpeed", 0, 30, (int) viewModel.minimumSpeed);
- minSpeedSlider.setStep(1);
- minSpeedSlider.setWidth("150px");
- minSpeedSlider.addListener(sliderListener);
- minSpeedTBox = new TextBox();
- minSpeedTBox.setValue("" + (int) viewModel.minimumSpeed);
- minSpeedTBox.setSize("30px", "12px");
- minSpeedTBox.addChangeHandler(tboxListener);
-
- maxSpeedSlider = new Slider("maxSpeed", 0, 30, (int) viewModel.maximumSpeed);
- maxSpeedSlider.setStep(1);
- maxSpeedSlider.setWidth("150px");
- maxSpeedSlider.addListener(sliderListener);
- maxSpeedTBox = new TextBox();
- maxSpeedTBox.setValue("" + (int) viewModel.maximumSpeed);
- maxSpeedTBox.setSize("30px", "12px");
- maxSpeedTBox.addChangeHandler(tboxListener);
-
- startScaleSlider = new Slider("startScale", 0, 10, (int) viewModel.startScale);
- startScaleSlider.setStep(1);
- startScaleSlider.setWidth("150px");
- startScaleSlider.addListener(sliderListener);
- startScaleTBox = new TextBox();
- startScaleTBox.setValue("" + (int) viewModel.startScale);
- startScaleTBox.setSize("30px", "12px");
- startScaleTBox.addChangeHandler(tboxListener);
-
- endScaleSlider = new Slider("endScale", 0, 10, (int) viewModel.endScale);
- endScaleSlider.setStep(1);
- endScaleSlider.setWidth("150px");
- endScaleSlider.addListener(sliderListener);
- endScaleTBox = new TextBox();
- endScaleTBox.setValue("" + (int) viewModel.endScale);
- endScaleTBox.setSize("30px", "12px");
- endScaleTBox.addChangeHandler(tboxListener);
-
- gravitySlider = new Slider("gravity", -20, 20, (int) viewModel.gravity);
- gravitySlider.setStep(1);
- gravitySlider.setWidth("150px");
- gravitySlider.addListener(sliderListener);
- gravityTBox = new TextBox();
- gravityTBox.setValue("" + (int) viewModel.gravity);
- gravityTBox.setSize("30px", "12px");
- gravityTBox.addChangeHandler(tboxListener);
-
- translationXTBox = new TextBox();
- translationXTBox.setSize("30px", "12px");
- translationXTBox.setValue(viewModel.transX + "");
- translationXTBox.addChangeHandler(tboxListener);
- translationYTBox = new TextBox();
- translationYTBox.setSize("30px", "12px");
- translationYTBox.setValue(viewModel.transY + "");
- translationYTBox.addChangeHandler(tboxListener);
- translationZTBox = new TextBox();
- translationZTBox.setSize("30px", "12px");
- translationZTBox.setValue(viewModel.transZ + "");
- translationZTBox.addChangeHandler(tboxListener);
-
- rotationHTBox = new TextBox();
- rotationHTBox.setSize("30px", "12px");
- rotationHTBox.setValue(viewModel.heading + "");
- rotationHTBox.addChangeHandler(tboxListener);
- rotationPTBox = new TextBox();
- rotationPTBox.setSize("30px", "12px");
- rotationPTBox.setValue(viewModel.pitch + "");
- rotationPTBox.addChangeHandler(tboxListener);
- rotationRTBox = new TextBox();
- rotationRTBox.setSize("30px", "12px");
- rotationRTBox.setValue(viewModel.roll + "");
- rotationRTBox.addChangeHandler(tboxListener);
-
- spinCBox = new CheckBox();
- spinCBox.setHTML("Spin");
- spinCBox.addValueChangeHandler(new MValueChangeHandler());
-
- flyCBox = new CheckBox();
- flyCBox.setHTML("Fly");
- flyCBox.addValueChangeHandler(new MValueChangeHandler());
-
- showCBox = new CheckBox();
- showCBox.setHTML("Show");
- showCBox.setValue(true);
- showCBox.addValueChangeHandler(new MValueChangeHandler());
-
- ListBox emitterLBox = new ListBox();
- emitterLBox.addItem("Circle", "Circle");
- emitterLBox.addItem("Cone", "Cone");
- emitterLBox.addItem("Box", "Box");
- emitterLBox.addItem("Sphere", "Sphere");
- emitterLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent changeEvent) {
- ListBox source = (ListBox) changeEvent.getSource();
- switch (source.getSelectedValue()) {
- case "Circle":
- particleSystem.emitter = new CircleEmitter(0.5);
- break;
- case "Cone":
- particleSystem.emitter = new ConeEmitter(Math.toRadians(45.0));
- break;
- case "Box":
- particleSystem.emitter = new BoxEmitter(new Cartesian3(10.0, 10.0, 10.0));
- break;
- case "Sphere":
- particleSystem.emitter = new SphereEmitter(5.0);
- break;
- default:
- break;
- }
- }
- });
-
- FlexTable flexTable = new FlexTable();
- flexTable.getElement().getStyle().setBackgroundColor("rgba(0, 0, 0, 0.5)");
- flexTable.setCellSpacing(2);
- flexTable.setCellPadding(2);
-
- flexTable.setHTML(0, 0, "Rate");
- flexTable.setWidget(0, 1, rateSlider);
- flexTable.setWidget(0, 2, rateTBox);
-
- flexTable.setHTML(1, 0, "Size");
- flexTable.setWidget(1, 1, sizeSlider);
- flexTable.setWidget(1, 2, sizeTBox);
-
- flexTable.setHTML(2, 0, "Min Life");
- flexTable.setWidget(2, 1, minLifeSlider);
- flexTable.setWidget(2, 2, minLifeTBox);
-
- flexTable.setHTML(3, 0, "Max Life");
- flexTable.setWidget(3, 1, maxLifeSlider);
- flexTable.setWidget(3, 2, maxLifeTBox);
-
- flexTable.setHTML(4, 0, "Min Speed");
- flexTable.setWidget(4, 1, minSpeedSlider);
- flexTable.setWidget(4, 2, minSpeedTBox);
-
- flexTable.setHTML(5, 0, "Max Speed");
- flexTable.setWidget(5, 1, maxSpeedSlider);
- flexTable.setWidget(5, 2, maxSpeedTBox);
-
- flexTable.setHTML(6, 0, "Start Scale");
- flexTable.setWidget(6, 1, startScaleSlider);
- flexTable.setWidget(6, 2, startScaleTBox);
-
- flexTable.setHTML(7, 0, "End Scale");
- flexTable.setWidget(7, 1, endScaleSlider);
- flexTable.setWidget(7, 2, endScaleTBox);
-
- flexTable.setHTML(8, 0, "Gravity");
- flexTable.setWidget(8, 1, gravitySlider);
- flexTable.setWidget(8, 2, gravityTBox);
-
- FlexTable transactionFTable = new FlexTable();
- transactionFTable.setHTML(0, 0, "X");
- transactionFTable.setWidget(0, 1, translationXTBox);
- transactionFTable.setHTML(0, 2, "Y");
- transactionFTable.setWidget(0, 3, translationYTBox);
- transactionFTable.setHTML(0, 4, "Z");
- transactionFTable.setWidget(0, 5, translationZTBox);
-
- flexTable.setHTML(9, 0, "Translation");
- flexTable.setWidget(9, 1, transactionFTable);
-
- FlexTable rotationFTable = new FlexTable();
- rotationFTable.setHTML(0, 0, "H");
- rotationFTable.setWidget(0, 1, rotationHTBox);
- rotationFTable.setHTML(0, 2, "P");
- rotationFTable.setWidget(0, 3, rotationPTBox);
- rotationFTable.setHTML(0, 4, "R");
- rotationFTable.setWidget(0, 5, rotationRTBox);
-
- flexTable.setHTML(10, 0, "Rotation");
- flexTable.setWidget(10, 1, rotationFTable);
-
- FlexTable btnFTable = new FlexTable();
- btnFTable.setWidget(0, 0, spinCBox);
- btnFTable.setWidget(0, 1, flyCBox);
- btnFTable.setWidget(0, 2, showCBox);
- btnFTable.setWidget(0, 3, emitterLBox);
-
- flexTable.setWidget(11, 1, btnFTable);
-
- return flexTable;
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ParticleSystem.txt";
- return sourceCodeURLs;
- }
-
- public static class ViewModel {
- double emissionRate = 5.0;
- double gravity = 0.0;
- double minimumParticleLife = 1.0;
- double maximumParticleLife = 1.0;
- double minimumSpeed = 1.0;
- double maximumSpeed = 4.0;
- double startScale = 1.0;
- double endScale = 5.0;
- double particleSize = 25.0;
- double transX = 2.5;
- double transY = 4.0;
- double transZ = 1.0;
- double heading = 0.0;
- double pitch = 0.0;
- double roll = 0.0;
- boolean fly = true;
- boolean spin = true;
- boolean show = true;
- }
-
- private Matrix4 computeModelMatrix(Entity entity, JulianDate time) {
- Cartesian3 position = Property.getValueOrUndefined(entity.position, time, entityPosition);
- if (!Cesium.defined(position)) {
- return (Matrix4) JsObject.undefined();
- }
+ rotationHTBox.setValue(viewModel.heading + "");
+ rotationPTBox.setValue(viewModel.pitch + "");
+ rotationRTBox.setValue(viewModel.roll + "");
+ }
+ }
+ });
- Quaternion orientation = Property.getValueOrUndefined(entity.orientation, time, entityOrientation);
- if (!Cesium.defined(orientation)) {
- modelMatrix = Transforms.eastNorthUpToFixedFrame(position, (Ellipsoid) JsObject.undefined(), modelMatrix);
- } else {
- modelMatrix = Matrix4.fromRotationTranslation(Matrix3.fromQuaternion(orientation, rotationMatrix), position,
- modelMatrix);
- }
- return modelMatrix;
- }
-
- private Matrix4 computeEmitterModelMatrix() {
- hpr = org.cesiumjs.cs.core.HeadingPitchRoll.fromDegrees(viewModel.heading, viewModel.pitch, viewModel.roll, hpr);
-
- trs.translation = Cartesian3.fromElements(viewModel.transX, viewModel.transY, viewModel.transZ, translation);
- trs.rotation = Quaternion.fromHeadingPitchRoll(hpr, rotation);
-
- return Matrix4.fromTranslationRotationScale(trs, emitterModelMatrix);
- }
-
- // Generate a random circular pattern with varying heights.
- private SampledPositionProperty computeCirclularFlight(double lon, double lat, double radius) {
- SampledPositionProperty property = new SampledPositionProperty();
- for (int i = 0; i <= 360; i += 45) {
- double radians = Math.toRadians(i);
- JulianDate time = JulianDate.addSeconds(start, i, new JulianDate());
- Cartesian3 position = Cartesian3.fromDegrees(lon + (radius * 1.5 * java.lang.Math.cos(radians)),
- lat + (radius * java.lang.Math.sin(radians)), Math.nextRandomNumber() * 500 + 1750);
- property.addSample(time, position);
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(createWidget(), 20, 20);
+
+ contentPanel.add(new HTML("Particle systems.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
}
- return property;
- }
- private class MSliderListener implements SliderListener {
+ public FlexTable createWidget() {
+ MSliderListener sliderListener = new MSliderListener();
+ MChangeHandler tboxListener = new MChangeHandler();
+
+ rateSlider = new Slider("rate", 0, 100, (int) viewModel.emissionRate);
+ rateSlider.setStep(1);
+ rateSlider.setWidth("150px");
+ rateSlider.addListener(sliderListener);
+ rateTBox = new TextBox();
+ rateTBox.setValue("" + (int) viewModel.emissionRate);
+ rateTBox.setSize("30px", "12px");
+ rateTBox.addChangeHandler(tboxListener);
+
+ sizeSlider = new Slider("size", 2, 60, (int) viewModel.particleSize);
+ sizeSlider.setStep(1);
+ sizeSlider.setWidth("150px");
+ sizeSlider.addListener(sliderListener);
+ sizeTBox = new TextBox();
+ sizeTBox.setValue("" + (int) viewModel.particleSize);
+ sizeTBox.setSize("30px", "12px");
+ sizeTBox.addChangeHandler(tboxListener);
+
+ minLifeSlider = new Slider("minLife", 1, 30, (int) viewModel.minimumParticleLife);
+ minLifeSlider.setStep(1);
+ minLifeSlider.setWidth("150px");
+ minLifeSlider.addListener(sliderListener);
+ minLifeTBox = new TextBox();
+ minLifeTBox.setValue("" + (int) viewModel.minimumParticleLife);
+ minLifeTBox.setSize("30px", "12px");
+ minLifeTBox.addChangeHandler(tboxListener);
+
+ maxLifeSlider = new Slider("maxLife", 1, 30, (int) viewModel.maximumParticleLife);
+ maxLifeSlider.setStep(1);
+ maxLifeSlider.setWidth("150px");
+ maxLifeSlider.addListener(sliderListener);
+ maxLifeTBox = new TextBox();
+ maxLifeTBox.setValue("" + (int) viewModel.maximumParticleLife);
+ maxLifeTBox.setSize("30px", "12px");
+ maxLifeTBox.addChangeHandler(tboxListener);
+
+ minSpeedSlider = new Slider("minSpeed", 0, 30, (int) viewModel.minimumSpeed);
+ minSpeedSlider.setStep(1);
+ minSpeedSlider.setWidth("150px");
+ minSpeedSlider.addListener(sliderListener);
+ minSpeedTBox = new TextBox();
+ minSpeedTBox.setValue("" + (int) viewModel.minimumSpeed);
+ minSpeedTBox.setSize("30px", "12px");
+ minSpeedTBox.addChangeHandler(tboxListener);
+
+ maxSpeedSlider = new Slider("maxSpeed", 0, 30, (int) viewModel.maximumSpeed);
+ maxSpeedSlider.setStep(1);
+ maxSpeedSlider.setWidth("150px");
+ maxSpeedSlider.addListener(sliderListener);
+ maxSpeedTBox = new TextBox();
+ maxSpeedTBox.setValue("" + (int) viewModel.maximumSpeed);
+ maxSpeedTBox.setSize("30px", "12px");
+ maxSpeedTBox.addChangeHandler(tboxListener);
+
+ startScaleSlider = new Slider("startScale", 0, 10, (int) viewModel.startScale);
+ startScaleSlider.setStep(1);
+ startScaleSlider.setWidth("150px");
+ startScaleSlider.addListener(sliderListener);
+ startScaleTBox = new TextBox();
+ startScaleTBox.setValue("" + (int) viewModel.startScale);
+ startScaleTBox.setSize("30px", "12px");
+ startScaleTBox.addChangeHandler(tboxListener);
+
+ endScaleSlider = new Slider("endScale", 0, 10, (int) viewModel.endScale);
+ endScaleSlider.setStep(1);
+ endScaleSlider.setWidth("150px");
+ endScaleSlider.addListener(sliderListener);
+ endScaleTBox = new TextBox();
+ endScaleTBox.setValue("" + (int) viewModel.endScale);
+ endScaleTBox.setSize("30px", "12px");
+ endScaleTBox.addChangeHandler(tboxListener);
+
+ gravitySlider = new Slider("gravity", -20, 20, (int) viewModel.gravity);
+ gravitySlider.setStep(1);
+ gravitySlider.setWidth("150px");
+ gravitySlider.addListener(sliderListener);
+ gravityTBox = new TextBox();
+ gravityTBox.setValue("" + (int) viewModel.gravity);
+ gravityTBox.setSize("30px", "12px");
+ gravityTBox.addChangeHandler(tboxListener);
+
+ translationXTBox = new TextBox();
+ translationXTBox.setSize("30px", "12px");
+ translationXTBox.setValue(viewModel.transX + "");
+ translationXTBox.addChangeHandler(tboxListener);
+ translationYTBox = new TextBox();
+ translationYTBox.setSize("30px", "12px");
+ translationYTBox.setValue(viewModel.transY + "");
+ translationYTBox.addChangeHandler(tboxListener);
+ translationZTBox = new TextBox();
+ translationZTBox.setSize("30px", "12px");
+ translationZTBox.setValue(viewModel.transZ + "");
+ translationZTBox.addChangeHandler(tboxListener);
+
+ rotationHTBox = new TextBox();
+ rotationHTBox.setSize("30px", "12px");
+ rotationHTBox.setValue(viewModel.heading + "");
+ rotationHTBox.addChangeHandler(tboxListener);
+ rotationPTBox = new TextBox();
+ rotationPTBox.setSize("30px", "12px");
+ rotationPTBox.setValue(viewModel.pitch + "");
+ rotationPTBox.addChangeHandler(tboxListener);
+ rotationRTBox = new TextBox();
+ rotationRTBox.setSize("30px", "12px");
+ rotationRTBox.setValue(viewModel.roll + "");
+ rotationRTBox.addChangeHandler(tboxListener);
+
+ spinCBox = new CheckBox();
+ spinCBox.setHTML("Spin");
+ spinCBox.addValueChangeHandler(new MValueChangeHandler());
+
+ flyCBox = new CheckBox();
+ flyCBox.setHTML("Fly");
+ flyCBox.addValueChangeHandler(new MValueChangeHandler());
+
+ showCBox = new CheckBox();
+ showCBox.setHTML("Show");
+ showCBox.setValue(true);
+ showCBox.addValueChangeHandler(new MValueChangeHandler());
+
+ ListBox emitterLBox = new ListBox();
+ emitterLBox.addItem("Circle", "Circle");
+ emitterLBox.addItem("Cone", "Cone");
+ emitterLBox.addItem("Box", "Box");
+ emitterLBox.addItem("Sphere", "Sphere");
+ emitterLBox.addChangeHandler(new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent changeEvent) {
+ ListBox source = (ListBox) changeEvent.getSource();
+ switch (source.getSelectedValue()) {
+ case "Circle":
+ particleSystem.emitter = new CircleEmitter(0.5);
+ break;
+ case "Cone":
+ particleSystem.emitter = new ConeEmitter(Math.toRadians(45.0));
+ break;
+ case "Box":
+ particleSystem.emitter = new BoxEmitter(new Cartesian3(10.0, 10.0, 10.0));
+ break;
+ case "Sphere":
+ particleSystem.emitter = new SphereEmitter(5.0);
+ break;
+ default:
+ break;
+ }
+ }
+ });
+
+ FlexTable flexTable = new FlexTable();
+ flexTable.getElement().getStyle().setBackgroundColor("rgba(0, 0, 0, 0.5)");
+ flexTable.setCellSpacing(2);
+ flexTable.setCellPadding(2);
+
+ flexTable.setHTML(0, 0, "Rate");
+ flexTable.setWidget(0, 1, rateSlider);
+ flexTable.setWidget(0, 2, rateTBox);
+
+ flexTable.setHTML(1, 0, "Size");
+ flexTable.setWidget(1, 1, sizeSlider);
+ flexTable.setWidget(1, 2, sizeTBox);
+
+ flexTable.setHTML(2, 0, "Min Life");
+ flexTable.setWidget(2, 1, minLifeSlider);
+ flexTable.setWidget(2, 2, minLifeTBox);
+
+ flexTable.setHTML(3, 0, "Max Life");
+ flexTable.setWidget(3, 1, maxLifeSlider);
+ flexTable.setWidget(3, 2, maxLifeTBox);
+
+ flexTable.setHTML(4, 0, "Min Speed");
+ flexTable.setWidget(4, 1, minSpeedSlider);
+ flexTable.setWidget(4, 2, minSpeedTBox);
+
+ flexTable.setHTML(5, 0, "Max Speed");
+ flexTable.setWidget(5, 1, maxSpeedSlider);
+ flexTable.setWidget(5, 2, maxSpeedTBox);
+
+ flexTable.setHTML(6, 0, "Start Scale");
+ flexTable.setWidget(6, 1, startScaleSlider);
+ flexTable.setWidget(6, 2, startScaleTBox);
+
+ flexTable.setHTML(7, 0, "End Scale");
+ flexTable.setWidget(7, 1, endScaleSlider);
+ flexTable.setWidget(7, 2, endScaleTBox);
+
+ flexTable.setHTML(8, 0, "Gravity");
+ flexTable.setWidget(8, 1, gravitySlider);
+ flexTable.setWidget(8, 2, gravityTBox);
+
+ FlexTable transactionFTable = new FlexTable();
+ transactionFTable.setHTML(0, 0, "X");
+ transactionFTable.setWidget(0, 1, translationXTBox);
+ transactionFTable.setHTML(0, 2, "Y");
+ transactionFTable.setWidget(0, 3, translationYTBox);
+ transactionFTable.setHTML(0, 4, "Z");
+ transactionFTable.setWidget(0, 5, translationZTBox);
+
+ flexTable.setHTML(9, 0, "Translation");
+ flexTable.setWidget(9, 1, transactionFTable);
+
+ FlexTable rotationFTable = new FlexTable();
+ rotationFTable.setHTML(0, 0, "H");
+ rotationFTable.setWidget(0, 1, rotationHTBox);
+ rotationFTable.setHTML(0, 2, "P");
+ rotationFTable.setWidget(0, 3, rotationPTBox);
+ rotationFTable.setHTML(0, 4, "R");
+ rotationFTable.setWidget(0, 5, rotationRTBox);
+
+ flexTable.setHTML(10, 0, "Rotation");
+ flexTable.setWidget(10, 1, rotationFTable);
+
+ FlexTable btnFTable = new FlexTable();
+ btnFTable.setWidget(0, 0, spinCBox);
+ btnFTable.setWidget(0, 1, flyCBox);
+ btnFTable.setWidget(0, 2, showCBox);
+ btnFTable.setWidget(0, 3, emitterLBox);
+
+ flexTable.setWidget(11, 1, btnFTable);
+
+ return flexTable;
+ }
@Override
- public void onStart(SliderEvent e) {
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ParticleSystem.txt";
+ return sourceCodeURLs;
+ }
+ private Matrix4 computeModelMatrix(Entity entity, JulianDate time) {
+ Cartesian3 position = Property.getValueOrUndefined(entity.position, time, entityPosition);
+ if (!Cesium.defined(position)) {
+ return (Matrix4) JsObject.undefined();
+ }
+
+ Quaternion orientation = Property.getValueOrUndefined(entity.orientation, time, entityOrientation);
+ if (!Cesium.defined(orientation)) {
+ modelMatrix = Transforms.eastNorthUpToFixedFrame(position, (Ellipsoid) JsObject.undefined(), modelMatrix);
+ } else {
+ modelMatrix = Matrix4.fromRotationTranslation(Matrix3.fromQuaternion(orientation, rotationMatrix), position,
+ modelMatrix);
+ }
+ return modelMatrix;
}
- @Override
- public boolean onSlide(SliderEvent e) {
- Slider source = e.getSource();
- int value = source.getValue();
- if (source == rateSlider) {
- particleSystem.emissionRate = value;
- rateTBox.setValue("" + value);
- } else if (source == sizeSlider) {
- particleSystem.minimumImageSize.x = value;
- particleSystem.minimumImageSize.y = value;
- particleSystem.maximumImageSize.x = value;
- particleSystem.maximumImageSize.y = value;
- sizeTBox.setValue("" + value);
- } else if (source == minLifeSlider) {
- particleSystem.minimumParticleLife = value;
- minLifeTBox.setValue("" + value);
- } else if (source == maxLifeSlider) {
- particleSystem.maximumParticleLife = value;
- maxLifeTBox.setValue("" + value);
- } else if (source == minSpeedSlider) {
- particleSystem.minimumSpeed = value;
- minSpeedTBox.setValue("" + value);
- } else if (source == maxSpeedSlider) {
- particleSystem.maximumSpeed = value;
- maxSpeedTBox.setValue("" + value);
- } else if (source == startScaleSlider) {
- particleSystem.startScale = value;
- startScaleTBox.setValue("" + value);
- } else if (source == endScaleSlider) {
- particleSystem.endScale = value;
- endScaleTBox.setValue("" + value);
- } else if (source == gravitySlider) {
- viewModel.gravity = value;
- gravityTBox.setValue("" + value);
- }
- return true;
+ private Matrix4 computeEmitterModelMatrix() {
+ hpr = org.cesiumjs.cs.core.HeadingPitchRoll.fromDegrees(viewModel.heading, viewModel.pitch, viewModel.roll, hpr);
+
+ trs.translation = Cartesian3.fromElements(viewModel.transX, viewModel.transY, viewModel.transZ, translation);
+ trs.rotation = Quaternion.fromHeadingPitchRoll(hpr, rotation);
+
+ return Matrix4.fromTranslationRotationScale(trs, emitterModelMatrix);
}
- @Override
- public void onChange(SliderEvent e) {
+ // Generate a random circular pattern with varying heights.
+ private SampledPositionProperty computeCirclularFlight(double lon, double lat, double radius) {
+ SampledPositionProperty property = new SampledPositionProperty();
+ for (int i = 0; i <= 360; i += 45) {
+ double radians = Math.toRadians(i);
+ JulianDate time = JulianDate.addSeconds(start, i, new JulianDate());
+ Cartesian3 position = Cartesian3.fromDegrees(lon + (radius * 1.5 * java.lang.Math.cos(radians)),
+ lat + (radius * java.lang.Math.sin(radians)), Math.nextRandomNumber() * 500 + 1750);
+ property.addSample(time, position);
+ }
+ return property;
+ }
+ public static class ViewModel {
+ double emissionRate = 5.0;
+ double gravity = 0.0;
+ double minimumParticleLife = 1.0;
+ double maximumParticleLife = 1.0;
+ double minimumSpeed = 1.0;
+ double maximumSpeed = 4.0;
+ double startScale = 1.0;
+ double endScale = 5.0;
+ double particleSize = 25.0;
+ double transX = 2.5;
+ double transY = 4.0;
+ double transZ = 1.0;
+ double heading = 0.0;
+ double pitch = 0.0;
+ double roll = 0.0;
+ boolean fly = true;
+ boolean spin = true;
+ boolean show = true;
}
- @Override
- public void onStop(SliderEvent e) {
+ private class MSliderListener implements SliderListener {
+
+ @Override
+ public void onStart(SliderEvent e) {
+
+ }
+
+ @Override
+ public boolean onSlide(SliderEvent e) {
+ Slider source = e.getSource();
+ int value = source.getValue();
+ if (source == rateSlider) {
+ particleSystem.emissionRate = value;
+ rateTBox.setValue("" + value);
+ } else if (source == sizeSlider) {
+ particleSystem.minimumImageSize.x = value;
+ particleSystem.minimumImageSize.y = value;
+ particleSystem.maximumImageSize.x = value;
+ particleSystem.maximumImageSize.y = value;
+ sizeTBox.setValue("" + value);
+ } else if (source == minLifeSlider) {
+ particleSystem.minimumParticleLife = value;
+ minLifeTBox.setValue("" + value);
+ } else if (source == maxLifeSlider) {
+ particleSystem.maximumParticleLife = value;
+ maxLifeTBox.setValue("" + value);
+ } else if (source == minSpeedSlider) {
+ particleSystem.minimumSpeed = value;
+ minSpeedTBox.setValue("" + value);
+ } else if (source == maxSpeedSlider) {
+ particleSystem.maximumSpeed = value;
+ maxSpeedTBox.setValue("" + value);
+ } else if (source == startScaleSlider) {
+ particleSystem.startScale = value;
+ startScaleTBox.setValue("" + value);
+ } else if (source == endScaleSlider) {
+ particleSystem.endScale = value;
+ endScaleTBox.setValue("" + value);
+ } else if (source == gravitySlider) {
+ viewModel.gravity = value;
+ gravityTBox.setValue("" + value);
+ }
+ return true;
+ }
+
+ @Override
+ public void onChange(SliderEvent e) {
+
+ }
+
+ @Override
+ public void onStop(SliderEvent e) {
+ }
}
- }
- private class MChangeHandler implements ChangeHandler {
- @Override
- public void onChange(ChangeEvent changeEvent) {
- TextBox source = (TextBox) changeEvent.getSource();
- int value = Integer.parseInt(source.getValue());
- if (source == rateTBox) {
- rateSlider.setValue(value);
- particleSystem.emissionRate = value;
- } else if (source == sizeTBox) {
- particleSystem.minimumImageSize.x = value;
- particleSystem.minimumImageSize.y = value;
- particleSystem.maximumImageSize.x = value;
- particleSystem.maximumImageSize.y = value;
- sizeSlider.setValue(value);
- } else if (source == minLifeTBox) {
- particleSystem.minimumParticleLife = value;
- minLifeSlider.setValue(value);
- } else if (source == maxLifeTBox) {
- particleSystem.maximumParticleLife = value;
- maxLifeSlider.setValue(value);
- } else if (source == minSpeedTBox) {
- particleSystem.minimumSpeed = value;
- minSpeedSlider.setValue(value);
- } else if (source == maxSpeedTBox) {
- particleSystem.maximumSpeed = value;
- maxSpeedSlider.setValue(value);
- } else if (source == startScaleTBox) {
- particleSystem.startScale = value;
- startScaleSlider.setValue(value);
- } else if (source == endScaleTBox) {
- particleSystem.endScale = value;
- endScaleSlider.setValue(value);
- } else if (source == gravityTBox) {
- viewModel.gravity = value;
- gravitySlider.setValue(value);
- } else if (source == translationXTBox) {
- viewModel.transX = value;
- } else if (source == translationYTBox) {
- viewModel.transY = value;
- } else if (source == translationZTBox) {
- viewModel.transZ = value;
- } else if (source == rotationHTBox) {
- viewModel.heading = value;
- } else if (source == rotationPTBox) {
- viewModel.pitch = value;
- } else if (source == rotationRTBox) {
- viewModel.roll = value;
- }
+ private class MChangeHandler implements ChangeHandler {
+ @Override
+ public void onChange(ChangeEvent changeEvent) {
+ TextBox source = (TextBox) changeEvent.getSource();
+ int value = Integer.parseInt(source.getValue());
+ if (source == rateTBox) {
+ rateSlider.setValue(value);
+ particleSystem.emissionRate = value;
+ } else if (source == sizeTBox) {
+ particleSystem.minimumImageSize.x = value;
+ particleSystem.minimumImageSize.y = value;
+ particleSystem.maximumImageSize.x = value;
+ particleSystem.maximumImageSize.y = value;
+ sizeSlider.setValue(value);
+ } else if (source == minLifeTBox) {
+ particleSystem.minimumParticleLife = value;
+ minLifeSlider.setValue(value);
+ } else if (source == maxLifeTBox) {
+ particleSystem.maximumParticleLife = value;
+ maxLifeSlider.setValue(value);
+ } else if (source == minSpeedTBox) {
+ particleSystem.minimumSpeed = value;
+ minSpeedSlider.setValue(value);
+ } else if (source == maxSpeedTBox) {
+ particleSystem.maximumSpeed = value;
+ maxSpeedSlider.setValue(value);
+ } else if (source == startScaleTBox) {
+ particleSystem.startScale = value;
+ startScaleSlider.setValue(value);
+ } else if (source == endScaleTBox) {
+ particleSystem.endScale = value;
+ endScaleSlider.setValue(value);
+ } else if (source == gravityTBox) {
+ viewModel.gravity = value;
+ gravitySlider.setValue(value);
+ } else if (source == translationXTBox) {
+ viewModel.transX = value;
+ } else if (source == translationYTBox) {
+ viewModel.transY = value;
+ } else if (source == translationZTBox) {
+ viewModel.transZ = value;
+ } else if (source == rotationHTBox) {
+ viewModel.heading = value;
+ } else if (source == rotationPTBox) {
+ viewModel.pitch = value;
+ } else if (source == rotationRTBox) {
+ viewModel.roll = value;
+ }
+ }
}
- }
- private class MValueChangeHandler implements ValueChangeHandler {
- @Override
- public void onValueChange(ValueChangeEvent valueChangeEvent) {
- CheckBox source = (CheckBox) valueChangeEvent.getSource();
- boolean value = valueChangeEvent.getValue();
- if (source == spinCBox) {
- viewModel.spin = value;
- } else if (source == flyCBox) {
- if (value) {
- entity.position = circularPosition;
- entity.orientation = new VelocityOrientationProperty(circularPosition);
- } else {
- entity.position = new ConstantPositionProperty(staticPosition);
- entity.orientation = (Property) JsObject.undefined();
+ private class MValueChangeHandler implements ValueChangeHandler {
+ @Override
+ public void onValueChange(ValueChangeEvent valueChangeEvent) {
+ CheckBox source = (CheckBox) valueChangeEvent.getSource();
+ boolean value = valueChangeEvent.getValue();
+ if (source == spinCBox) {
+ viewModel.spin = value;
+ } else if (source == flyCBox) {
+ if (value) {
+ entity.position = circularPosition;
+ entity.orientation = new VelocityOrientationProperty(circularPosition);
+ } else {
+ entity.position = new ConstantPositionProperty(staticPosition);
+ entity.orientation = (Property) JsObject.undefined();
+ }
+ } else if (source == showCBox) {
+ viewModel.show = value;
+ entity.show = value;
+ particleSystem.show = value;
+ }
}
- } else if (source == showCBox) {
- viewModel.show = value;
- entity.show = value;
- particleSystem.show = value;
- }
}
- }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ParticleSystemFireworks.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ParticleSystemFireworks.java
index eac2ff66d6b1e43f5a52bc7c674003971988a963..e30326e0e3ce4c1c7cab1d17dffd02f6b3783268 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ParticleSystemFireworks.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ParticleSystemFireworks.java
@@ -16,24 +16,14 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.inject.Inject;
-
import com.google.gwt.canvas.dom.client.Context2d;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.CanvasElement;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
-
import org.cesiumjs.cs.Cesium;
-import org.cesiumjs.cs.core.Cartesian2;
-import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.Color;
import org.cesiumjs.cs.core.Math;
-import org.cesiumjs.cs.core.Matrix4;
-import org.cesiumjs.cs.core.Transforms;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.core.options.ColorRandomOptions;
import org.cesiumjs.cs.scene.Scene;
import org.cesiumjs.cs.scene.emitters.SphereEmitter;
@@ -47,162 +37,166 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* @author Serge Silaev aka iSergio
*/
public class ParticleSystemFireworks extends AbstractExample {
- private Matrix4 emitterModelMatrixScratch = new Matrix4();
- private Cartesian3 emitterInitialLocation = new Cartesian3(0.0, 0.0, 100.0);
- private Matrix4 modelMatrix = Transforms.eastNorthUpToFixedFrame(Cartesian3.fromDegrees(-75.59777, 40.03883));
-
- private CanvasElement particleCanvas;
-
- private double minimumExplosionSize = 30.0;
- private double maximumExplosionSize = 100.0;
- private Cartesian2 particlePixelSize = new Cartesian2(7.0, 7.0);
- private double burstSize = 400.0;
- private double lifetime = 10.0;
- private double numberOfFireworks = 20.0;
-
- private double xMin = -100.0;
- private double xMax = 100.0;
- private double yMin = -80.0;
- private double yMax = 100.0;
- private double zMin = -50.0;
- private double zMax = 50.0;
-
- @Inject
- public ParticleSystemFireworks(ShowcaseExampleStore store) {
- super("Particle System Fireworks", "Particle system fireworks.",
- new String[] { "Showcase", "Cesium", "3d", "Viewer", "Particle" }, store);
- }
-
- @Override
- public void buildPanel() {
- ViewerOptions viewerOptions = new ViewerOptions();
- viewerOptions.shouldAnimate = true;
- ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
-
- csVPanel.getViewer().scene().debugShowFramesPerSecond = true;
-
- Math.setRandomNumberSeed(315);
-
- ColorRandomOptions[] colorRandomOptions = new ColorRandomOptions[4];
- for (int i = 0; i < 4; i++) {
- colorRandomOptions[i] = new ColorRandomOptions();
- }
- colorRandomOptions[0].minimumRed = 0.75f;
- colorRandomOptions[0].green = 0.0f;
- colorRandomOptions[0].minimumBlue = 0.8f;
- colorRandomOptions[0].alpha = 1.0f;
- colorRandomOptions[1].red = 0.0f;
- colorRandomOptions[1].minimumGreen = 0.75f;
- colorRandomOptions[1].minimumBlue = 0.8f;
- colorRandomOptions[1].alpha = 1.0f;
- colorRandomOptions[2].red = 0.0f;
- colorRandomOptions[2].green = 0.0f;
- colorRandomOptions[2].minimumBlue = 0.8f;
- colorRandomOptions[2].alpha = 1.0f;
- colorRandomOptions[3].minimumRed = 0.75f;
- colorRandomOptions[3].minimumGreen = 0.75f;
- colorRandomOptions[3].blue = 0.0f;
- colorRandomOptions[3].alpha = 1.0f;
-
- for (int i = 0; i < numberOfFireworks; ++i) {
- double x = Math.randomBetween(xMin, xMax);
- double y = Math.randomBetween(yMin, yMax);
- double z = Math.randomBetween(zMin, zMax);
- Cartesian3 offset = new Cartesian3(x, y, z);
- Color color = Color.fromRandom(colorRandomOptions[i % colorRandomOptions.length]);
-
- List bursts = new ArrayList<>();
- for (int j = 0; j < 3; ++j) {
- ParticleBurstOptions particleBurstOptions = new ParticleBurstOptions();
- particleBurstOptions.time = Math.nextRandomNumber() * lifetime;
- particleBurstOptions.minimum = burstSize;
- particleBurstOptions.maximum = burstSize;
- bursts.add(new ParticleBurst(particleBurstOptions));
- }
-
- createFirework(csVPanel.getViewer().scene(), offset, color, bursts.toArray(new ParticleBurst[bursts.size()]));
+ private final Matrix4 emitterModelMatrixScratch = new Matrix4();
+ private final Cartesian3 emitterInitialLocation = new Cartesian3(0.0, 0.0, 100.0);
+ private final Matrix4 modelMatrix = Transforms.eastNorthUpToFixedFrame(Cartesian3.fromDegrees(-75.59777, 40.03883));
+
+ private CanvasElement particleCanvas;
+
+ private final double minimumExplosionSize = 30.0;
+ private final double maximumExplosionSize = 100.0;
+ private final Cartesian2 particlePixelSize = new Cartesian2(7.0, 7.0);
+ private final double burstSize = 400.0;
+ private final double lifetime = 10.0;
+ private final double numberOfFireworks = 20.0;
+
+ private final double xMin = -100.0;
+ private final double xMax = 100.0;
+ private final double yMin = -80.0;
+ private final double yMax = 100.0;
+ private final double zMin = -50.0;
+ private final double zMax = 50.0;
+
+ @Inject
+ public ParticleSystemFireworks(ShowcaseExampleStore store) {
+ super("Particle System Fireworks", "Particle system fireworks.",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer", "Particle"}, store);
}
- org.cesiumjs.cs.scene.Camera camera = csVPanel.getViewer().scene().camera();
- Cartesian3 cameraOffset = new Cartesian3(-300.0, 0.0, 0.0);
- camera.lookAtTransform(modelMatrix, cameraOffset);
- camera.lookAtTransform(Matrix4.IDENTITY());
-
- Cartesian3 toFireworks = Cartesian3.subtract(emitterInitialLocation, cameraOffset, new Cartesian3());
- Cartesian3.normalize(toFireworks, toFireworks);
- double angle = Math.PI_OVER_TWO() - java.lang.Math.acos(Cartesian3.dot(toFireworks, Cartesian3.UNIT_Z()));
- camera.lookUp(angle);
-
- contentPanel.add(new HTML(""));
- contentPanel.add(csVPanel);
-
- initWidget(contentPanel);
- }
-
- private CanvasElement getImage() {
- if (!Cesium.defined(particleCanvas)) {
- particleCanvas = RootPanel.get().getElement().getOwnerDocument().createCanvasElement();
- particleCanvas.setWidth(20);
- particleCanvas.setHeight(20);
- Context2d context2d = particleCanvas.getContext2d();
- context2d.beginPath();
- context2d.arc(8, 8, 8, 0, Math.TWO_PI(), true);
- context2d.closePath();
- context2d.setFillStyle("rgb(255, 255, 255)");
- context2d.fill();
- Cesium.log(particleCanvas);
+ @Override
+ public void buildPanel() {
+ ViewerOptions viewerOptions = new ViewerOptions();
+ viewerOptions.shouldAnimate = true;
+ ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
+
+ csVPanel.getViewer().scene().debugShowFramesPerSecond = true;
+
+ Math.setRandomNumberSeed(315);
+
+ ColorRandomOptions[] colorRandomOptions = new ColorRandomOptions[4];
+ for (int i = 0; i < 4; i++) {
+ colorRandomOptions[i] = new ColorRandomOptions();
+ }
+ colorRandomOptions[0].minimumRed = 0.75f;
+ colorRandomOptions[0].green = 0.0f;
+ colorRandomOptions[0].minimumBlue = 0.8f;
+ colorRandomOptions[0].alpha = 1.0f;
+ colorRandomOptions[1].red = 0.0f;
+ colorRandomOptions[1].minimumGreen = 0.75f;
+ colorRandomOptions[1].minimumBlue = 0.8f;
+ colorRandomOptions[1].alpha = 1.0f;
+ colorRandomOptions[2].red = 0.0f;
+ colorRandomOptions[2].green = 0.0f;
+ colorRandomOptions[2].minimumBlue = 0.8f;
+ colorRandomOptions[2].alpha = 1.0f;
+ colorRandomOptions[3].minimumRed = 0.75f;
+ colorRandomOptions[3].minimumGreen = 0.75f;
+ colorRandomOptions[3].blue = 0.0f;
+ colorRandomOptions[3].alpha = 1.0f;
+
+ for (int i = 0; i < numberOfFireworks; ++i) {
+ double x = Math.randomBetween(xMin, xMax);
+ double y = Math.randomBetween(yMin, yMax);
+ double z = Math.randomBetween(zMin, zMax);
+ Cartesian3 offset = new Cartesian3(x, y, z);
+ Color color = Color.fromRandom(colorRandomOptions[i % colorRandomOptions.length]);
+
+ List bursts = new ArrayList<>();
+ for (int j = 0; j < 3; ++j) {
+ ParticleBurstOptions particleBurstOptions = new ParticleBurstOptions();
+ particleBurstOptions.time = Math.nextRandomNumber() * lifetime;
+ particleBurstOptions.minimum = burstSize;
+ particleBurstOptions.maximum = burstSize;
+ bursts.add(new ParticleBurst(particleBurstOptions));
+ }
+
+ createFirework(csVPanel.getViewer().scene(), offset, color, bursts.toArray(new ParticleBurst[bursts.size()]));
+ }
+
+ org.cesiumjs.cs.scene.Camera camera = csVPanel.getViewer().scene().camera();
+ Cartesian3 cameraOffset = new Cartesian3(-300.0, 0.0, 0.0);
+ camera.lookAtTransform(modelMatrix, cameraOffset);
+ camera.lookAtTransform(Matrix4.IDENTITY());
+
+ Cartesian3 toFireworks = Cartesian3.subtract(emitterInitialLocation, cameraOffset, new Cartesian3());
+ Cartesian3.normalize(toFireworks, toFireworks);
+ double angle = Math.PI_OVER_TWO() - java.lang.Math.acos(Cartesian3.dot(toFireworks, Cartesian3.UNIT_Z()));
+ camera.lookUp(angle);
+
+ contentPanel.add(new HTML(""));
+ contentPanel.add(csVPanel);
+
+ initWidget(contentPanel);
}
- return particleCanvas;
- }
-
- private void createFirework(Scene scene, Cartesian3 offset, Color color, ParticleBurst[] bursts) {
- Cartesian3 position = Cartesian3.add(emitterInitialLocation, offset, new Cartesian3());
- Matrix4 emitterModelMatrix = Matrix4.fromTranslation(position, emitterModelMatrixScratch);
- Matrix4 particleToWorld = Matrix4.multiply(modelMatrix, emitterModelMatrix, new Matrix4());
- final Matrix4 worldToParticle = Matrix4.inverseTransformation(particleToWorld, particleToWorld);
-
- final double size = Math.randomBetween(minimumExplosionSize, maximumExplosionSize);
- final Cartesian3 particlePositionScratch = new Cartesian3();
-
- ParticleSystem.UpdateCallback updateCallback = new ParticleSystem.UpdateCallback() {
- @Override
- public void function(Particle particle, double dt) {
- Cartesian3 position = Matrix4.multiplyByPoint(worldToParticle, particle.position, particlePositionScratch);
- if (Cartesian3.magnitudeSquared(position) >= size * size) {
- Cartesian3.clone(Cartesian3.ZERO(), particle.velocity);
+
+ private CanvasElement getImage() {
+ if (!Cesium.defined(particleCanvas)) {
+ particleCanvas = RootPanel.get().getElement().getOwnerDocument().createCanvasElement();
+ particleCanvas.setWidth(20);
+ particleCanvas.setHeight(20);
+ Context2d context2d = particleCanvas.getContext2d();
+ context2d.beginPath();
+ context2d.arc(8, 8, 8, 0, Math.TWO_PI(), true);
+ context2d.closePath();
+ context2d.setFillStyle("rgb(255, 255, 255)");
+ context2d.fill();
+ Cesium.log(particleCanvas);
}
- }
- };
- double normalSize = (size - minimumExplosionSize) / (maximumExplosionSize - minimumExplosionSize);
- double minLife = 0.3;
- double maxLife = 1.0;
- double life = normalSize * (maxLife - minLife) + minLife;
-
- ParticleSystemOptions particleSystemOptions = new ParticleSystemOptions();
- particleSystemOptions.image = getImage();
- particleSystemOptions.startColor = color;
- particleSystemOptions.endColor = color.withAlpha(0.0f);
- particleSystemOptions.particleLife = life;
- particleSystemOptions.speed = 100.0;
- particleSystemOptions.imageSize = particlePixelSize;
- particleSystemOptions.emissionRate = 0;
- particleSystemOptions.emitter = new SphereEmitter(0.1);
- particleSystemOptions.bursts = bursts;
- particleSystemOptions.lifetime = lifetime;
- particleSystemOptions.updateCallback = updateCallback;
- particleSystemOptions.modelMatrix = modelMatrix;
- particleSystemOptions.emitterModelMatrix = emitterModelMatrix;
- scene.primitives().add(new ParticleSystem(particleSystemOptions));
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ParticleSysteFireworks.txt";
- return sourceCodeURLs;
- }
+ return particleCanvas;
+ }
+
+ private void createFirework(Scene scene, Cartesian3 offset, Color color, ParticleBurst[] bursts) {
+ Cartesian3 position = Cartesian3.add(emitterInitialLocation, offset, new Cartesian3());
+ Matrix4 emitterModelMatrix = Matrix4.fromTranslation(position, emitterModelMatrixScratch);
+ Matrix4 particleToWorld = Matrix4.multiply(modelMatrix, emitterModelMatrix, new Matrix4());
+ final Matrix4 worldToParticle = Matrix4.inverseTransformation(particleToWorld, particleToWorld);
+
+ final double size = Math.randomBetween(minimumExplosionSize, maximumExplosionSize);
+ final Cartesian3 particlePositionScratch = new Cartesian3();
+
+ ParticleSystem.UpdateCallback updateCallback = new ParticleSystem.UpdateCallback() {
+ @Override
+ public void function(Particle particle, double dt) {
+ Cartesian3 position = Matrix4.multiplyByPoint(worldToParticle, particle.position, particlePositionScratch);
+ if (Cartesian3.magnitudeSquared(position) >= size * size) {
+ Cartesian3.clone(Cartesian3.ZERO(), particle.velocity);
+ }
+ }
+ };
+ double normalSize = (size - minimumExplosionSize) / (maximumExplosionSize - minimumExplosionSize);
+ double minLife = 0.3;
+ double maxLife = 1.0;
+ double life = normalSize * (maxLife - minLife) + minLife;
+
+ ParticleSystemOptions particleSystemOptions = new ParticleSystemOptions();
+ particleSystemOptions.image = getImage();
+ particleSystemOptions.startColor = color;
+ particleSystemOptions.endColor = color.withAlpha(0.0f);
+ particleSystemOptions.particleLife = life;
+ particleSystemOptions.speed = 100.0;
+ particleSystemOptions.imageSize = particlePixelSize;
+ particleSystemOptions.emissionRate = 0;
+ particleSystemOptions.emitter = new SphereEmitter(0.1);
+ particleSystemOptions.bursts = bursts;
+ particleSystemOptions.lifetime = lifetime;
+ particleSystemOptions.updateCallback = updateCallback;
+ particleSystemOptions.modelMatrix = modelMatrix;
+ particleSystemOptions.emitterModelMatrix = emitterModelMatrix;
+ scene.primitives().add(new ParticleSystem(particleSystemOptions));
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ParticleSysteFireworks.txt";
+ return sourceCodeURLs;
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/PerFeaturePostProcessing.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/PerFeaturePostProcessing.java
index 3f6bf1f2893197653b965317ed56ef5973ac973c..f5cabe38e433b9f07b1571dfcb4f174942416474 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/PerFeaturePostProcessing.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/PerFeaturePostProcessing.java
@@ -53,111 +53,111 @@ import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStor
* @author Serge Silaev aka iSergio
*/
public class PerFeaturePostProcessing extends AbstractExample {
- private ViewerPanel csVPanel;
- private ScreenSpaceEventHandler handler;
-
- @Inject
- public PerFeaturePostProcessing(ShowcaseExampleStore store) {
- super("Per-Feature Post Processing", "Post processing effects.", new String[] { "Post process" }, store);
- }
-
- @Override
- public void buildPanel() {
- ViewerOptions viewerOptions = new ViewerOptions();
- viewerOptions.shouldAnimate = true;
- csVPanel = new ViewerPanel(viewerOptions);
-
- ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(
- GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb");
- EntityOptions options = new EntityOptions();
- options.name = GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb";
- options.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-123.0744619, 44.0503706));
- options.model = new ModelGraphics(modelGraphicsOptions);
- csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(options);
-
- if (!PostProcessStageLibrary.isSilhouetteSupported(csVPanel.getViewer().scene())) {
- Cesium.log("This browser does not support the silhouette post process.");
+ private ViewerPanel csVPanel;
+ private ScreenSpaceEventHandler handler;
+
+ @Inject
+ public PerFeaturePostProcessing(ShowcaseExampleStore store) {
+ super("Per-Feature Post Processing", "Post processing effects.", new String[]{"Post process"}, store);
}
- PostProcessStageCollection stages = csVPanel.getViewer().scene().postProcessStages;
- PostProcessStageComposite postProcessStageComposite = PostProcessStageLibrary.createSilhouetteStage();
- postProcessStageComposite.uniforms = JsObject.create();
- postProcessStageComposite.uniforms.setProperty("color", Color.LIME());
- final PostProcessStageComposite silhouette = stages.add(postProcessStageComposite);
-
- PostProcessStage postProcessStage = PostProcessStageLibrary.createBlackAndWhiteStage();
- postProcessStage.uniforms().setProperty("gradations", 5.0);
- final PostProcessStage blackAndWhite = stages.add(PostProcessStageLibrary.createBlackAndWhiteStage());
-
- ListBox selectionLBox = new ListBox();
- selectionLBox.addItem("Mouse-over Black and White", "0");
- selectionLBox.addItem("Mouse-over Silhouette", "1");
- selectionLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent event) {
- ListBox source = (ListBox) event.getSource();
- if (source.getSelectedValue().equalsIgnoreCase("0")) {
- blackAndWhite.enabled = true;
- silhouette.enabled = false;
-
- removeMouseOver(silhouette);
- addMouseOver(blackAndWhite);
- } else if (source.getSelectedValue().equalsIgnoreCase("1")) {
- blackAndWhite.enabled = false;
- silhouette.enabled = true;
-
- removeMouseOver(blackAndWhite);
- addMouseOver(silhouette);
+ @Override
+ public void buildPanel() {
+ ViewerOptions viewerOptions = new ViewerOptions();
+ viewerOptions.shouldAnimate = true;
+ csVPanel = new ViewerPanel(viewerOptions);
+
+ ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
+ modelGraphicsOptions.uri = new ConstantProperty<>(
+ GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb");
+ EntityOptions options = new EntityOptions();
+ options.name = GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb";
+ options.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-123.0744619, 44.0503706));
+ options.model = new ModelGraphics(modelGraphicsOptions);
+ csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(options);
+
+ if (!PostProcessStageLibrary.isSilhouetteSupported(csVPanel.getViewer().scene())) {
+ Cesium.log("This browser does not support the silhouette post process.");
}
- }
- });
- selectionLBox.setSelectedIndex(0);
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(selectionLBox, 20, 20);
-
- contentPanel.add(new HTML("Post processing effects.
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
-
- blackAndWhite.enabled = true;
- silhouette.enabled = false;
-
- removeMouseOver(silhouette);
- addMouseOver(blackAndWhite);
- }
-
- private void addMouseOver(final PostProcess stage) {
- handler = new ScreenSpaceEventHandler(csVPanel.getViewer().scene().canvas());
- handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
- @Override
- public void function(Object event) {
- MouseMoveEvent mouseMoveEvent = (MouseMoveEvent) event;
- PickedObject pickedObject = csVPanel.getViewer().scene().pick(mouseMoveEvent.endPosition);
- if (pickedObject != null) {
- JsObject.setProperty(stage, "selected", new Primitive[] { pickedObject.primitive });
- } else {
- JsObject.setProperty(stage, "selected", new Primitive[0]);
+
+ PostProcessStageCollection stages = csVPanel.getViewer().scene().postProcessStages;
+ PostProcessStageComposite postProcessStageComposite = PostProcessStageLibrary.createSilhouetteStage();
+ postProcessStageComposite.uniforms = JsObject.create();
+ postProcessStageComposite.uniforms.setProperty("color", Color.LIME());
+ final PostProcessStageComposite silhouette = stages.add(postProcessStageComposite);
+
+ PostProcessStage postProcessStage = PostProcessStageLibrary.createBlackAndWhiteStage();
+ postProcessStage.uniforms().setProperty("gradations", 5.0);
+ final PostProcessStage blackAndWhite = stages.add(PostProcessStageLibrary.createBlackAndWhiteStage());
+
+ ListBox selectionLBox = new ListBox();
+ selectionLBox.addItem("Mouse-over Black and White", "0");
+ selectionLBox.addItem("Mouse-over Silhouette", "1");
+ selectionLBox.addChangeHandler(new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent event) {
+ ListBox source = (ListBox) event.getSource();
+ if (source.getSelectedValue().equalsIgnoreCase("0")) {
+ blackAndWhite.enabled = true;
+ silhouette.enabled = false;
+
+ removeMouseOver(silhouette);
+ addMouseOver(blackAndWhite);
+ } else if (source.getSelectedValue().equalsIgnoreCase("1")) {
+ blackAndWhite.enabled = false;
+ silhouette.enabled = true;
+
+ removeMouseOver(blackAndWhite);
+ addMouseOver(silhouette);
+ }
+ }
+ });
+ selectionLBox.setSelectedIndex(0);
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(selectionLBox, 20, 20);
+
+ contentPanel.add(new HTML("Post processing effects.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
+
+ blackAndWhite.enabled = true;
+ silhouette.enabled = false;
+
+ removeMouseOver(silhouette);
+ addMouseOver(blackAndWhite);
+ }
+
+ private void addMouseOver(final PostProcess stage) {
+ handler = new ScreenSpaceEventHandler(csVPanel.getViewer().scene().canvas());
+ handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
+ @Override
+ public void function(Object event) {
+ MouseMoveEvent mouseMoveEvent = (MouseMoveEvent) event;
+ PickedObject pickedObject = csVPanel.getViewer().scene().pick(mouseMoveEvent.endPosition);
+ if (pickedObject != null) {
+ JsObject.setProperty(stage, "selected", new Primitive[]{pickedObject.primitive});
+ } else {
+ JsObject.setProperty(stage, "selected", new Primitive[0]);
+ }
+ }
+ }, ScreenSpaceEventType.MOUSE_MOVE());
+ }
+
+ void removeMouseOver(PostProcess stage) {
+ if (handler != null) {
+ handler.destroy();
+ handler = null;
}
- }
- }, ScreenSpaceEventType.MOUSE_MOVE());
- }
-
- void removeMouseOver(PostProcess stage) {
- if (handler != null) {
- handler.destroy();
- handler = null;
+ JsObject.setProperty(stage, "selected", new Primitive[0]);
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "PerFeaturePostProcessing.txt";
+ return sourceCodeURLs;
}
- JsObject.setProperty(stage, "selected", new Primitive[0]);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "PerFeaturePostProcessing.txt";
- return sourceCodeURLs;
- }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Picking.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Picking.java
index 17453a09c1d1f4ff796af31814a914887aa8ac5b..e2e0452c38141c3ec1d8613c823c0b35367753ee 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Picking.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Picking.java
@@ -16,12 +16,6 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.logging.Logger;
-
-import javax.inject.Inject;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
@@ -29,17 +23,9 @@ import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.ToggleButton;
-
import org.cesiumjs.cs.collections.EntityCollection;
-import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.Cartographic;
-import org.cesiumjs.cs.core.Color;
-import org.cesiumjs.cs.core.JulianDate;
import org.cesiumjs.cs.core.Math;
-import org.cesiumjs.cs.core.PerspectiveFrustum;
-import org.cesiumjs.cs.core.PickedObject;
-import org.cesiumjs.cs.core.PolygonHierarchy;
-import org.cesiumjs.cs.core.ScreenSpaceEventHandler;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.core.enums.ScreenSpaceEventType;
import org.cesiumjs.cs.core.events.MouseMoveEvent;
import org.cesiumjs.cs.datasources.Entity;
@@ -63,276 +49,280 @@ import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import javax.inject.Inject;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.logging.Logger;
+
/**
* @author Serge Silaev aka iSergio
*/
public class Picking extends AbstractExample {
- private final static Logger LOGGER = Logger.getLogger(Picking.class.getName());
- private EntityCollection _pickedEntities;
- private Color _pickColor;
- private ViewerPanel viewerPanel;
- private ScreenSpaceEventHandler _handler;
-
- ToggleButton _showPosOnMouseOverTBtn;
- ToggleButton _pickEntityTBtn;
- ToggleButton _drillDownPickingTBtn;
- ToggleButton _pickPositionTBtn;
-
- @Inject
- public Picking(ShowcaseExampleStore store) {
- super("Picking", "Use the mouse to select and manipulate objects in the scene",
- new String[] { "Showcase", "Cesium", "3d", "Viewer" }, store);
- }
-
- @Override
- public void buildPanel() {
- viewerPanel = new ViewerPanel();
- showCartographicPositionOnMouseOver();
-
- _showPosOnMouseOverTBtn = new ToggleButton("Show Cartographic Position on Mouse Over");
- _showPosOnMouseOverTBtn.setValue(true);
- _showPosOnMouseOverTBtn.addValueChangeHandler(new MValueChangeHandler());
-
- _pickEntityTBtn = new ToggleButton("Pick Entity");
- _pickEntityTBtn.addValueChangeHandler(new MValueChangeHandler());
-
- _drillDownPickingTBtn = new ToggleButton("Drill-Down Picking");
- _drillDownPickingTBtn.addValueChangeHandler(new MValueChangeHandler());
-
- _pickPositionTBtn = new ToggleButton("Pick position");
- _pickPositionTBtn.addValueChangeHandler(new MValueChangeHandler());
-
- HorizontalPanel hPanel = new HorizontalPanel();
- hPanel.add(_showPosOnMouseOverTBtn);
- hPanel.add(_pickEntityTBtn);
- hPanel.add(_drillDownPickingTBtn);
- hPanel.add(_pickPositionTBtn);
-
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(viewerPanel);
- aPanel.add(hPanel, 20, 20);
-
- contentPanel.add(new HTML("Use the mouse to select and manipulate objects in the scene.
"));
- contentPanel.add(aPanel);
-
- initWidget(contentPanel);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Picking.txt";
- return sourceCodeURLs;
- }
-
- private class MValueChangeHandler implements ValueChangeHandler {
+ private final static Logger LOGGER = Logger.getLogger(Picking.class.getName());
+ ToggleButton _showPosOnMouseOverTBtn;
+ ToggleButton _pickEntityTBtn;
+ ToggleButton _drillDownPickingTBtn;
+ ToggleButton _pickPositionTBtn;
+ private EntityCollection _pickedEntities;
+ private Color _pickColor;
+ private ViewerPanel viewerPanel;
+ private ScreenSpaceEventHandler _handler;
+
+ @Inject
+ public Picking(ShowcaseExampleStore store) {
+ super("Picking", "Use the mouse to select and manipulate objects in the scene",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer"}, store);
+ }
+
@Override
- public void onValueChange(ValueChangeEvent valueChangeEvent) {
- ToggleButton source = (ToggleButton) valueChangeEvent.getSource();
- reset();
- if (source.equals(_showPosOnMouseOverTBtn)) {
+ public void buildPanel() {
+ viewerPanel = new ViewerPanel();
showCartographicPositionOnMouseOver();
- _pickEntityTBtn.setValue(false);
- _drillDownPickingTBtn.setValue(false);
- _pickPositionTBtn.setValue(false);
- } else if (source.equals(_pickEntityTBtn)) {
- pickEntity();
-
- _showPosOnMouseOverTBtn.setValue(false);
- _drillDownPickingTBtn.setValue(false);
- _pickPositionTBtn.setValue(false);
- } else if (source.equals(_drillDownPickingTBtn)) {
- drillDownPicking();
-
- _showPosOnMouseOverTBtn.setValue(false);
- _pickEntityTBtn.setValue(false);
- _pickPositionTBtn.setValue(false);
- } else if (source.equals(_pickPositionTBtn)) {
- pickPosition();
-
- _showPosOnMouseOverTBtn.setValue(false);
- _pickEntityTBtn.setValue(false);
- _drillDownPickingTBtn.setValue(false);
- }
+ _showPosOnMouseOverTBtn = new ToggleButton("Show Cartographic Position on Mouse Over");
+ _showPosOnMouseOverTBtn.setValue(true);
+ _showPosOnMouseOverTBtn.addValueChangeHandler(new MValueChangeHandler());
+
+ _pickEntityTBtn = new ToggleButton("Pick Entity");
+ _pickEntityTBtn.addValueChangeHandler(new MValueChangeHandler());
+
+ _drillDownPickingTBtn = new ToggleButton("Drill-Down Picking");
+ _drillDownPickingTBtn.addValueChangeHandler(new MValueChangeHandler());
+
+ _pickPositionTBtn = new ToggleButton("Pick position");
+ _pickPositionTBtn.addValueChangeHandler(new MValueChangeHandler());
+
+ HorizontalPanel hPanel = new HorizontalPanel();
+ hPanel.add(_showPosOnMouseOverTBtn);
+ hPanel.add(_pickEntityTBtn);
+ hPanel.add(_drillDownPickingTBtn);
+ hPanel.add(_pickPositionTBtn);
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(viewerPanel);
+ aPanel.add(hPanel, 20, 20);
+
+ contentPanel.add(new HTML("Use the mouse to select and manipulate objects in the scene.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
}
- }
-
- public void showCartographicPositionOnMouseOver() {
- LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
- labelGraphicsOptions.show = new ConstantProperty<>(true);
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.label = new LabelGraphics(labelGraphicsOptions);
- final Entity entity = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
-
- _handler = new ScreenSpaceEventHandler(viewerPanel.getViewer().scene().canvas());
- _handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
- @Override
- public void function(MouseMoveEvent event) {
- Cartesian3 cartesian = viewerPanel.getViewer().camera.pickEllipsoid(event.endPosition,
- viewerPanel.getViewer().scene().globe.ellipsoid);
- if (cartesian != null) {
- Cartographic cartographic = Cartographic.fromCartesian(cartesian);
- String lon = new BigDecimal(Math.toDegrees(cartographic.longitude)).setScale(2, RoundingMode.HALF_EVEN)
- .toString();
- String lat = new BigDecimal(Math.toDegrees(cartographic.latitude)).setScale(2, RoundingMode.HALF_EVEN)
- .toString();
-
- entity.position = new ConstantPositionProperty(cartesian);
- entity.label.show = new ConstantProperty<>(true);
- entity.label.text = new ConstantProperty<>("(" + lon + ", " + lat + ")");
- } else {
- entity.label.show = new ConstantProperty<>(false);
- }
- }
- }, ScreenSpaceEventType.MOUSE_MOVE());
- }
-
- private void pickEntity() {
- BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png");
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
- entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
- final Entity entity = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
-
- _handler = new ScreenSpaceEventHandler(viewerPanel.getViewer().scene().canvas());
- _handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
- @Override
- public void function(MouseMoveEvent event) {
- PickedObject pickedObject = viewerPanel.getViewer().scene().pick(event.endPosition);
- if (pickedObject != null && pickedObject.id == entity) {
- entity.billboard.scale = new ConstantProperty<>(2.0);
- entity.billboard.color = new ConstantProperty<>(Color.YELLOW());
- } else {
- entity.billboard.scale = new ConstantProperty<>(1.0);
- entity.billboard.color = new ConstantProperty<>(Color.WHITE());
- }
- }
- }, ScreenSpaceEventType.MOUSE_MOVE());
- }
-
- private void makeProperty(final Entity entity, final Color color) {
- Property colorProperty = new org.cesiumjs.cs.datasources.properties.CallbackProperty<>(
- new org.cesiumjs.cs.datasources.properties.CallbackProperty.Callback() {
- @Override
- public Color function(JulianDate time, Color result) {
- if (_pickedEntities.contains(entity)) {
- return _pickColor.clone(result);
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Picking.txt";
+ return sourceCodeURLs;
+ }
+
+ public void showCartographicPositionOnMouseOver() {
+ LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
+ labelGraphicsOptions.show = new ConstantProperty<>(true);
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.label = new LabelGraphics(labelGraphicsOptions);
+ final Entity entity = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ _handler = new ScreenSpaceEventHandler(viewerPanel.getViewer().scene().canvas());
+ _handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
+ @Override
+ public void function(MouseMoveEvent event) {
+ Cartesian3 cartesian = viewerPanel.getViewer().camera.pickEllipsoid(event.endPosition,
+ viewerPanel.getViewer().scene().globe.ellipsoid);
+ if (cartesian != null) {
+ Cartographic cartographic = Cartographic.fromCartesian(cartesian);
+ String lon = new BigDecimal(Math.toDegrees(cartographic.longitude)).setScale(2, RoundingMode.HALF_EVEN)
+ .toString();
+ String lat = new BigDecimal(Math.toDegrees(cartographic.latitude)).setScale(2, RoundingMode.HALF_EVEN)
+ .toString();
+
+ entity.position = new ConstantPositionProperty(cartesian);
+ entity.label.show = new ConstantProperty<>(true);
+ entity.label.text = new ConstantProperty<>("(" + lon + ", " + lat + ")");
+ } else {
+ entity.label.show = new ConstantProperty<>(false);
+ }
}
- return color.clone(result);
- }
- }, false);
- entity.polygon.material = new ColorMaterialProperty(colorProperty);
- }
-
- private void drillDownPicking() {
- _pickedEntities = new EntityCollection();
- _pickColor = Color.YELLOW().withAlpha(0.5f);
-
- PolygonGraphicsOptions polygonGraphicsOptions = new PolygonGraphicsOptions();
- polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(
- Cartesian3.fromDegreesArray(new double[] { -70.0, 30.0, -60.0, 30.0, -60.0, 40.0, -70.0, 40.0 })));
- polygonGraphicsOptions.height = new ConstantProperty<>(0);
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
- Entity red = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
- makeProperty(red, Color.RED().withAlpha(0.5f));
-
- polygonGraphicsOptions = new PolygonGraphicsOptions();
- polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(
- Cartesian3.fromDegreesArray(new double[] { -75.0, 34.0, -63.0, 34.0, -63.0, 40.0, -75.0, 40.0 })));
- polygonGraphicsOptions.height = new ConstantProperty<>(0);
- entityOptions = new EntityOptions();
- entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
- Entity blue = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
- makeProperty(blue, Color.BLUE().withAlpha(0.5f));
-
- polygonGraphicsOptions = new PolygonGraphicsOptions();
- polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(
- Cartesian3.fromDegreesArray(new double[] { -67.0, 36.0, -55.0, 36.0, -55.0, 30.0, -67.0, 30.0 })));
- polygonGraphicsOptions.height = new ConstantProperty<>(0);
- entityOptions = new EntityOptions();
- entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
- Entity green = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
- makeProperty(green, Color.GREEN().withAlpha(0.5f));
-
- // Move the primitive that the mouse is over to the top.
- _handler = new ScreenSpaceEventHandler(viewerPanel.getViewer().scene().canvas());
- _handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
- @Override
- public void function(MouseMoveEvent event) {
- PickedObject[] pickedObjects = viewerPanel.getViewer().scene().drillPick(event.endPosition);
- if (pickedObjects != null) {
- _pickedEntities.removeAll();
- for (PickedObject pickedObject : pickedObjects) {
- Entity entity = (Entity) pickedObject.id;
- _pickedEntities.add(entity);
- }
- }
- }
- }, ScreenSpaceEventType.MOUSE_MOVE());
- }
-
- private void pickPosition() {
- ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(
- GWT.getModuleBaseURL() + "SampleData/models/CesiumMilkTruck/CesiumMilkTruck-kmc.gltf");
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-123.0744619, 44.0503706));
- entityOptions.name = "milktruck";
- entityOptions.model = new ModelGraphics(modelGraphicsOptions);
- final Entity modelEntity = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
- viewerPanel.getViewer().zoomTo(modelEntity);
-
- LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
- labelGraphicsOptions.show = new ConstantProperty<>(false);
- labelGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.LEFT());
- entityOptions = new EntityOptions();
- entityOptions.label = new LabelGraphics(labelGraphicsOptions);
- final Entity labelEntity = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
- _handler = new ScreenSpaceEventHandler(viewerPanel.getViewer().scene().canvas());
- _handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
- @Override
- public void function(MouseMoveEvent event) {
- boolean foundPosition = false;
-
- Scene scene = viewerPanel.getViewer().scene();
- PickedObject pickedObject = scene.pick(event.endPosition);
- if (scene.pickPositionSupported() && pickedObject != null && pickedObject.id == modelEntity) {
- Cartesian3 cartesian = viewerPanel.getViewer().scene().pickPosition(event.endPosition);
-
- if (cartesian != null) {
- Cartographic cartographic = Cartographic.fromCartesian(cartesian);
- String lon = new BigDecimal(Math.toDegrees(cartographic.longitude)).setScale(2, RoundingMode.HALF_EVEN)
- .toString();
- String lat = new BigDecimal(Math.toDegrees(cartographic.latitude)).setScale(2, RoundingMode.HALF_EVEN)
- .toString();
- String height = new BigDecimal(cartographic.height).setScale(2, RoundingMode.HALF_EVEN).toString();
-
- labelEntity.position = new ConstantPositionProperty(cartesian);
- labelEntity.label.show = new ConstantProperty<>(true);
- labelEntity.label.text = new ConstantProperty<>("(" + lon + ", " + lat + ", " + height + ")");
-
- Camera camera = scene.camera();
- labelEntity.label.eyeOffset = new ConstantProperty<>(
- new Cartesian3(0.0, 0.0, ((PerspectiveFrustum) camera.frustum).near * 1.5
- - (double) Cartesian3.distance(cartesian, camera.position)));
-
- foundPosition = true;
- }
- }
+ }, ScreenSpaceEventType.MOUSE_MOVE());
+ }
+
+ private void pickEntity() {
+ BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
+ billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png");
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
+ entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
+ final Entity entity = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ _handler = new ScreenSpaceEventHandler(viewerPanel.getViewer().scene().canvas());
+ _handler.setInputAction(new ScreenSpaceEventHandler.Listener() {
+ @Override
+ public void function(MouseMoveEvent event) {
+ PickedObject pickedObject = viewerPanel.getViewer().scene().pick(event.endPosition);
+ if (pickedObject != null && pickedObject.id == entity) {
+ entity.billboard.scale = new ConstantProperty<>(2.0);
+ entity.billboard.color = new ConstantProperty<>(Color.YELLOW());
+ } else {
+ entity.billboard.scale = new ConstantProperty<>(1.0);
+ entity.billboard.color = new ConstantProperty<>(Color.WHITE());
+ }
+ }
+ }, ScreenSpaceEventType.MOUSE_MOVE());
+ }
+
+ private void makeProperty(final Entity entity, final Color color) {
+ Property