Search in sources :

Example 36 with ViewerPanel

use of org.cesiumjs.cs.widgets.ViewerPanel in project gwt-cs by iSergio.

the class CustomGeocoder method buildPanel.

@Override
public void buildPanel() {
    OpenStreetMapNominatimGeocoder openStreetMapNominatimGeocoder = new OpenStreetMapNominatimGeocoder();
    openStreetMapNominatimGeocoder.geocode = new OpenStreetMapNominatimGeocoder.Geocode() {

        @Override
        public Promise<JsObject, Void> function(String input) {
            String endpoint = "http://nominatim.openstreetmap.org/search?";
            String query = "format=json&q=" + input;
            String requestString = endpoint + query;
            Promise<JsObject, Void> promise = Resource.fetchJson(requestString);
            promise.then(new Fulfill<JsObject>() {

                @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));
                    }
                }
            });
            return promise;
        }
    };
    ViewerOptions viewerOptions = new ViewerOptions();
    viewerOptions.geocoder = openStreetMapNominatimGeocoder;
    csVPanel = new ViewerPanel(viewerOptions);
    contentPanel.add(new HTML("<p>Example of a custom geocoder.</p>"));
    contentPanel.add(csVPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) JsObject(org.cesiumjs.cs.js.JsObject) JSONArray(com.google.gwt.json.client.JSONArray) Rectangle(org.cesiumjs.cs.core.Rectangle) ViewerOptions(org.cesiumjs.cs.widgets.options.ViewerOptions) HTML(com.google.gwt.user.client.ui.HTML) Promise(org.cesiumjs.cs.promise.Promise) JSONObject(com.google.gwt.json.client.JSONObject) Fulfill(org.cesiumjs.cs.promise.Fulfill) GeocoderResult(org.cesiumjs.cs.core.GeocoderResult)

Example 37 with ViewerPanel

use of org.cesiumjs.cs.widgets.ViewerPanel in project gwt-cs by iSergio.

the class Drawing method buildPanel.

@Override
public void buildPanel() {
    csVPanel = new ViewerPanel();
    csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;
    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<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> 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/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<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> 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/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<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> 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/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<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> 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/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<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> 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 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);
    final AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(csVPanel);
    aPanel.add(flexTable, RootPanel.get().getOffsetWidth() - 74, 42);
    contentPanel.add(new HTML("<p>Use Viewer to start building new applications or easily embed Cesium into existing applications.</p>"));
    contentPanel.add(aPanel);
    Window.addResizeHandler(new ResizeHandler() {

        @Override
        public void onResize(ResizeEvent resizeEvent) {
            aPanel.setWidgetPosition(flexTable, RootPanel.get().getOffsetWidth() - 74, 42);
        }
    });
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) DrawInteractionOptions(org.cesiumjs.cs.scene.interaction.options.DrawInteractionOptions) ResizeEvent(com.google.gwt.event.logical.shared.ResizeEvent) ResizeHandler(com.google.gwt.event.logical.shared.ResizeHandler)

Example 38 with ViewerPanel

use of org.cesiumjs.cs.widgets.ViewerPanel in project gwt-cs by iSergio.

the class GeoJSONsimplestyle method buildPanel.

@Override
public void buildPanel() {
    ViewerOptions viewerOptions = new ViewerOptions();
    viewerOptions.sceneMode = SceneMode.SCENE2D();
    viewerOptions.timeline = false;
    viewerOptions.animation = false;
    csVPanel = new ViewerPanel(viewerOptions);
    Promise<GeoJsonDataSource, String> dataSource = GeoJsonDataSource.load(GWT.getModuleBaseURL() + "SampleData/simplestyles.geojson");
    csVPanel.getViewer().dataSources().add(dataSource);
    dataSource.then(new Fulfill<GeoJsonDataSource>() {

        @Override
        public void onFulfilled(GeoJsonDataSource value) {
            csVPanel.getViewer().zoomTo(value);
        }
    });
    contentPanel.add(new HTML("<p>Load GeoJSON with simplestyle information.</p>"));
    contentPanel.add(csVPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) GeoJsonDataSource(org.cesiumjs.cs.datasources.GeoJsonDataSource) ViewerOptions(org.cesiumjs.cs.widgets.options.ViewerOptions) HTML(com.google.gwt.user.client.ui.HTML)

Example 39 with ViewerPanel

use of org.cesiumjs.cs.widgets.ViewerPanel in project gwt-cs by iSergio.

the class GoogleEarthEnterprise method buildPanel.

@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);
    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("<p>Add imagery from a Web Map Service (WMS) server.</p>"));
    contentPanel.add(csVPanel);
    initWidget(contentPanel);
}
Also used : GoogleEarthEnterpriseMetadata(org.cesiumjs.cs.core.GoogleEarthEnterpriseMetadata) ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) ViewOptions(org.cesiumjs.cs.scene.options.ViewOptions) ViewerOptions(org.cesiumjs.cs.widgets.options.ViewerOptions) HTML(com.google.gwt.user.client.ui.HTML)

Example 40 with ViewerPanel

use of org.cesiumjs.cs.widgets.ViewerPanel in project gwt-cs by iSergio.

the class HelloWorld method buildPanel.

@Override
public void buildPanel() {
    ViewerPanel csVPanel = new ViewerPanel();
    contentPanel.add(new HTML("<p>Use Viewer to start building new applications or easily embed Cesium into existing applications.</p>"));
    contentPanel.add(csVPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) HTML(com.google.gwt.user.client.ui.HTML)

Aggregations

ViewerPanel (org.cesiumjs.cs.widgets.ViewerPanel)46 HTML (com.google.gwt.user.client.ui.HTML)34 ViewerOptions (org.cesiumjs.cs.widgets.options.ViewerOptions)14 AbsolutePanel (com.google.gwt.user.client.ui.AbsolutePanel)13 Entity (org.cesiumjs.cs.datasources.Entity)13 EntityOptions (org.cesiumjs.cs.datasources.options.EntityOptions)13 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)12 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)11 ListBox (com.google.gwt.user.client.ui.ListBox)7 Cartesian3 (org.cesiumjs.cs.core.Cartesian3)7 ModelGraphics (org.cesiumjs.cs.datasources.graphics.ModelGraphics)7 ModelGraphicsOptions (org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions)7 ConstantProperty (org.cesiumjs.cs.datasources.properties.ConstantProperty)7 CesiumTerrainProvider (org.cesiumjs.cs.core.providers.CesiumTerrainProvider)6 CesiumTerrainProviderOptions (org.cesiumjs.cs.core.providers.options.CesiumTerrainProviderOptions)6 Cesium3DTileset (org.cesiumjs.cs.scene.Cesium3DTileset)6 Slider (org.cleanlogic.showcase.client.examples.slider.Slider)6 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)5 ColorMaterialProperty (org.cesiumjs.cs.datasources.properties.ColorMaterialProperty)5 ConstantPositionProperty (org.cesiumjs.cs.datasources.properties.ConstantPositionProperty)5