Commit c381ee9e authored by iSergio's avatar iSergio
Browse files

Start code refactoring for checkstyle

parent 8552b3e1
Loading
Loading
Loading
Loading
+351 −279
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package org.cesiumjs.cs;

import jsinterop.annotations.*;
import org.cesiumjs.cs.collections.EntityCollection;
import org.cesiumjs.cs.core.Cartographic;
import org.cesiumjs.cs.core.Ellipsoid;
@@ -27,13 +26,18 @@ import org.cesiumjs.cs.core.providers.TerrainProvider;
import org.cesiumjs.cs.datasources.graphics.ModelGraphics;
import org.cesiumjs.cs.js.JsObject;
import org.cesiumjs.cs.promise.Promise;
import org.cesiumjs.cs.scene.providers.UrlTemplateImageryProvider;
import org.cesiumjs.cs.scene.providers.options.OpenStreetMapImageryProviderOptions;
import org.cesiumjs.cs.scene.providers.options.TileMapServiceImageryProviderOptions;
import org.cesiumjs.cs.widgets.Command;

import jsinterop.annotations.JsConstructor;
import jsinterop.annotations.JsFunction;
import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;

/**
 * @author Serge Silaev aka iSergio <s.serge.b@gmail.com>
 * @author Serge Silaev aka iSergio
 */
public class Cesium {
  @JsProperty(namespace = JsPackage.GLOBAL, name = "Cesium")
@@ -50,8 +54,8 @@ public class Cesium {
                                               }-*/;

  /**
     * Fix for SmartGWT
     * Thanks for Mark Erikson (https://groups.google.com/forum/#!msg/cesium-dev/ZfyW0CNRsSU/lP6KTaUpEQAJ)
   * Fix for SmartGWT Thanks for Mark Erikson
   * (https://groups.google.com/forum/#!msg/cesium-dev/ZfyW0CNRsSU/lP6KTaUpEQAJ)
   */
  public static native void fixSmartGWT() /*-{
                                          if ($wnd.buildInDataView !== undefined) {
@@ -63,9 +67,10 @@ public class Cesium {
                                          }-*/;

  /**
     * Given a non-relative moduleID, returns an absolute URL to the file represented by that module ID,
     * using, in order of preference, require.toUrl, the value of a global CESIUM_BASE_URL, or
     * the base URL of the Cesium.js script.
   * Given a non-relative moduleID, returns an absolute URL to the file
   * represented by that module ID, using, in order of preference, require.toUrl,
   * the value of a global CESIUM_BASE_URL, or the base URL of the Cesium.js
   * script.
   */
  @JsMethod(namespace = "Cesium", name = "buildModuleUrl")
  public static native String buildModuleUrl(String moduleId);
@@ -74,26 +79,37 @@ public class Cesium {
  public static native boolean defined(Object object);

  /**
     * Initiates a terrain height query for an array of {@link Cartographic} positions by requesting tiles from a terrain provider,
     * sampling, and interpolating. The interpolation matches the triangles used to render the terrain at the specified level.
     * The query happens asynchronously, so this function returns a promise that is resolved when the query completes.
     * Each point height is modified in place. If a height can not be determined because no terrain data is available
     * for the specified level at that location, or another error occurs, the height is set to undefined.
     * As is typical of the {@link Cartographic} type, the supplied height is a height above the reference
     * ellipsoid (such as {@link Ellipsoid#WGS84()}) rather than an altitude above mean sea level.
     * In other words, it will not necessarily be 0.0 if sampled in the ocean.
   * Initiates a terrain height query for an array of {@link Cartographic}
   * positions by requesting tiles from a terrain provider, sampling, and
   * interpolating. The interpolation matches the triangles used to render the
   * terrain at the specified level. The query happens asynchronously, so this
   * function returns a promise that is resolved when the query completes. Each
   * point height is modified in place. If a height can not be determined because
   * no terrain data is available for the specified level at that location, or
   * another error occurs, the height is set to undefined. As is typical of the
   * {@link Cartographic} type, the supplied height is a height above the
   * reference ellipsoid (such as {@link Ellipsoid#WGS84()}) rather than an
   * altitude above mean sea level. In other words, it will not necessarily be 0.0
   * if sampled in the ocean.
   * 
   * @param terrainProvider The terrain provider from which to query heights.
     * @param level The terrain level-of-detail from which to query terrain heights.
   * @param level           The terrain level-of-detail from which to query
   *                        terrain heights.
   * @param positions       The positions to update with terrain heights.
     * @return A promise that resolves to the provided list of positions when terrain the query has completed.
   * @return A promise that resolves to the provided list of positions when
   *         terrain the query has completed.
   */
  @JsMethod(namespace = "Cesium", name = "sampleTerrain")
    public static native Promise<Cartographic[], Void> sampleTerrain(TerrainProvider terrainProvider, int level, Cartographic[] positions);
  public static native Promise<Cartographic[], Void> sampleTerrain(TerrainProvider terrainProvider, int level,
      Cartographic[] positions);

  /**
     * Create a Command from a given function, for use with ViewModels. A Command is a function with an extra canExecute
     * observable property to determine whether the command can be executed. When executed, a Command function will check
     * the value of canExecute and throw if false. It also provides events for when a command has been or is about to be executed.
   * Create a Command from a given function, for use with ViewModels. A Command is
   * a function with an extra canExecute observable property to determine whether
   * the command can be executed. When executed, a Command function will check the
   * value of canExecute and throw if false. It also provides events for when a
   * command has been or is about to be executed.
   * 
   * @param func The function to execute.
   * @return Command function
   */
@@ -101,38 +117,51 @@ public class Cesium {
  public static native Command createCommand(Function func);

  /**
     * Create a Command from a given function, for use with ViewModels. A Command is a function with an extra canExecute
     * observable property to determine whether the command can be executed. When executed, a Command function will check
     * the value of canExecute and throw if false. It also provides events for when a command has been or is about to be executed.
   * Create a Command from a given function, for use with ViewModels. A Command is
   * a function with an extra canExecute observable property to determine whether
   * the command can be executed. When executed, a Command function will check the
   * value of canExecute and throw if false. It also provides events for when a
   * command has been or is about to be executed.
   * 
   * @param func       The function to execute.
     * @param canExecute A boolean indicating whether the function can currently be executed.
   * @param canExecute A boolean indicating whether the function can currently be
   *                   executed.
   * @return Command function
   */
  @JsMethod(namespace = "Cesium", name = "createCommand")
  public static native Command createCommand(Function func, boolean canExecute);

  /**
     * A browser-independent function to request a new animation frame. This is used to create an application's
     * draw loop as shown in the example below.
   * A browser-independent function to request a new animation frame. This is used
   * to create an application's draw loop as shown in the example below.
   * 
   * @param callback The function to call when the next frame should be drawn.
     * @return An ID that can be passed to {@link #cancelAnimationFrame} to cancel the request.
   * @return An ID that can be passed to {@link #cancelAnimationFrame} to cancel
   *         the request.
   */
  // TODO Example
  @JsMethod(namespace = "Cesium", name = "requestAnimationFrame")
  public static native Number requestAnimationFrame(RequestAnimationFrameCallback callback);

  /**
     * A browser-independent function to cancel an animation frame requested using requestAnimationFrame.
   * A browser-independent function to cancel an animation frame requested using
   * requestAnimationFrame.
   * 
   * @param requestID The value returned by requestAnimationFrame.
   */
  @JsMethod(namespace = "Cesium", name = "cancelAnimationFrame")
  public static native void cancelAnimationFrame(Number requestID);

  /**
     * Initiates a sampleTerrain() request at the maximum available tile level for a terrain dataset.
   * Initiates a sampleTerrain() request at the maximum available tile level for a
   * terrain dataset.
   * 
   * @param terrainProvider The terrain provider from which to query heights.
   * @param positions       The positions to update with terrain heights.
     * @return A promise that resolves to the provided list of positions when terrain the query has completed. This promise will reject if the terrain provider's `availability` property is undefined.
   * @return A promise that resolves to the provided list of positions when
   *         terrain the query has completed. This promise will reject if the
   *         terrain provider's `availability` property is undefined.
   * 
   *         <pre>
   *     Example:
   *     {@code
@@ -151,18 +180,23 @@ public class Cesium {
   *         </pre>
   */
  @JsMethod(namespace = "Cesium", name = "sampleTerrainMostDetailed")
    public static native Promise<Cartographic[], Void> sampleTerrainMostDetailed(TerrainProvider terrainProvider, Cartographic[] positions);
  public static native Promise<Cartographic[], Void> sampleTerrainMostDetailed(TerrainProvider terrainProvider,
      Cartographic[] positions);

  // TODO: Example
  /**
     * 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.
   * 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
   *
     * 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.
   * 
     * 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.
   */
  @JsMethod(namespace = "Cesium", name = "destroyObject")
@@ -170,47 +204,69 @@ public class Cesium {

  // TODO: Example
  /**
     * 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.
   * 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
   * 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.
   * 
     * 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.
   * @param message The message to include in the exception that is thrown if a
   *                destroyed object's function is called.
   */
  @JsMethod(namespace = "Cesium", name = "destroyObject")
  public static native void destroyObject(Object object, String message);

  /**
     * Creates a {@link CesiumTerrainProvider} instance for the <a href="https://cesium.com/content/cesiumworldterrain">Cesium World Terrain</a>.
     * @return {@link CesiumTerrainProvider} instance for the <a href="https://cesium.com/content/cesiumworldterrain">Cesium World Terrain</a>.
   * Creates a {@link CesiumTerrainProvider} instance for the
   * <a href="https://cesium.com/content/cesiumworldterrain">Cesium World
   * Terrain</a>.
   * 
   * @return {@link CesiumTerrainProvider} instance for the
   *         <a href="https://cesium.com/content/cesiumworldterrain">Cesium World
   *         Terrain</a>.
   */
  @JsMethod(namespace = "Cesium", name = "createWorldTerrain")
  public static native CesiumTerrainProvider createWorldTerrain();

  /**
     * Creates a {@link CesiumTerrainProvider} instance for the <a href="https://cesium.com/content/cesiumworldterrain">Cesium World Terrain</a>.
   * Creates a {@link CesiumTerrainProvider} instance for the
   * <a href="https://cesium.com/content/cesiumworldterrain">Cesium World
   * Terrain</a>.
   * 
   * @param options {@link CreateWorldTerrainOptions} object.
     * @return {@link CesiumTerrainProvider} instance for the <a href="https://cesium.com/content/cesiumworldterrain">Cesium World Terrain</a>.
   * @return {@link CesiumTerrainProvider} instance for the
   *         <a href="https://cesium.com/content/cesiumworldterrain">Cesium World
   *         Terrain</a>.
   */
  @JsMethod(namespace = "Cesium", name = "createWorldTerrain")
  public static native CesiumTerrainProvider createWorldTerrain(CreateWorldTerrainOptions options);

  /**
     * 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.
   * 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.
   * @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.
   */
  @JsMethod(namespace = "Cesium", name = "exportKml")
  public static native Promise<JsObject, Void> exportKml(ExportKmlOptions options);
@@ -224,6 +280,7 @@ public class Cesium {
  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")
@@ -233,25 +290,28 @@ public class Cesium {
  @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
     * 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
     * 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() {}
    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.
     * @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
@@ -264,8 +324,12 @@ public class Cesium {
    /**
     * 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.
     * @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
@@ -288,14 +352,14 @@ public class Cesium {
    @JsProperty
    public EntityCollection entities;
    /**
         * The ellipsoid for the output file.
         * Default: {@link Ellipsoid#WGS84()}
     * 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.
     * 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;
@@ -310,20 +374,21 @@ public class Cesium {
    @JsProperty
    public TimeInterval defaultAvailability;
    /**
         * The number of seconds to sample properties that are varying in KML.
         * Default: 60
     * 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
     * If true KML and external files will be compressed into a kmz file. Default:
     * false
     */
    @JsProperty
    public boolean kmz;

    @JsConstructor
        private ExportKmlOptions() {}
    private ExportKmlOptions() {
    }

    @JsOverlay
    public static ExportKmlOptions create(EntityCollection entities) {
@@ -333,19 +398,26 @@ public class Cesium {
    }

    /**
         * 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.
     * 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.
       * 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.
       * @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);
+12 −12
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;

/**
 * @author Serge Silaev aka iSergio <s.serge.b@gmail.com>
 * @author Serge Silaev aka iSergio
 */
public class CesiumEntryPoint implements EntryPoint {
  @Override
@@ -28,10 +28,10 @@ public class CesiumEntryPoint implements EntryPoint {
    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 <script src='..../Cesium.js'> " +
                    "to load Cesium, \nalso you need include necessary css (Example: <link type=\"text/css\" href=\".../Cesium/Widgets/widget.css\">.\n" +
                    "By default Cesium path is [GWT App Name]/js/Cesium";
      String message = "The Core of Cesium (Cesium.js) JavaScript libraryes not loaded.\n"
          + "If you inherit Cesium from NoScript gwt.xml, \nyou need include <script src='..../Cesium.js'> "
          + "to load Cesium, \nalso you need include necessary css (Example: <link type=\"text/css\" href=\".../Cesium/Widgets/widget.css\">.\n"
          + "By default Cesium path is [GWT App Name]/js/Cesium";
      GWT.log(message);
    }
  }
+109 −85

File changed.

Preview size limit exceeded, changes collapsed.

+67 −63

File changed.

Preview size limit exceeded, changes collapsed.

+31 −29
Original line number Diff line number Diff line
@@ -22,19 +22,21 @@ import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;

/**
 * @author Serge Silaev aka iSergio <s.serge.b@gmail.com>
 * Abstract class of Collection, not use it directly!.
 * @author Serge Silaev aka iSergio
 */
@JsType(isNative = true, namespace = "Cesium", name = "Collection")
public abstract class Collection<T> {
  /**
     * Returns the number of elements in this collection.
     * This is commonly used with Collection#get to iterate over all the elements in the collection.
   * Returns the number of elements in this collection. This is commonly used with
   * Collection#get to iterate over all the elements in the collection.
   */
  @JsProperty(name = "length")
  public native int length();

  @JsConstructor
    protected Collection() {}
  protected Collection() {
  }

  @JsMethod
  public native T add(T value);
Loading