Search in sources :

Example 36 with ChangeHandler

use of com.google.gwt.event.dom.client.ChangeHandler in project data-access by pentaho.

the class MetadataImportDialogController method addLocalizedBundle.

@Bindable
public void addLocalizedBundle() {
    final FileUpload localizedBundleUpload = new FileUpload();
    localizedBundleUpload.setName("localeFiles");
    localizedBundleUpload.getElement().setId("propertyFileUpload" + FILE_UPLOAD_SUFFIX++);
    localizedBundleUpload.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            String fileName = ((FileUpload) event.getSource()).getFilename();
            if (fileName == null || fileName.length() < 1) {
                // Trying to detect a cancel
                propertiesFileImportPanel.remove(localizedBundleUpload);
            } else {
                importDialogModel.addLocalizedBundle(fileName, fileName);
            }
        }
    });
    propertiesFileImportPanel.add(localizedBundleUpload);
    jsClickUpload(localizedBundleUpload.getElement().getId());
}
Also used : ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) PropertyChangeEvent(java.beans.PropertyChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) FileUpload(com.google.gwt.user.client.ui.FileUpload) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 37 with ChangeHandler

use of com.google.gwt.event.dom.client.ChangeHandler in project gwt-cs by iSergio.

the class KML method buildPanel.

@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);
            // camera, canvas);
            KmlDataSourceOptions kmlDataSourceOptions = new KmlDataSourceOptions();
            kmlDataSourceOptions.canvas = canvas;
            kmlDataSourceOptions.camera = camera;
            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<KmlDataSource>() {

                    @Override
                    public void onFulfilled(KmlDataSource dataSource) {
                        viewer.clock().shouldAnimate = false;
                        final Entity rider = dataSource.entities.getById("tour");
                        viewer.flyTo(rider).then(new Fulfill<Boolean>() {

                            @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);
    contentPanel.add(new HTML("<p>A simple KML example.</p>"));
    contentPanel.add(aPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) Entity(org.cesiumjs.cs.datasources.Entity) KmlDataSource(org.cesiumjs.cs.datasources.KmlDataSource) AbsolutePanel(com.google.gwt.user.client.ui.AbsolutePanel) Viewer(org.cesiumjs.cs.widgets.Viewer) HTML(com.google.gwt.user.client.ui.HTML) KmlDataSourceOptions(org.cesiumjs.cs.datasources.options.KmlDataSourceOptions) CanvasElement(com.google.gwt.dom.client.CanvasElement) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ListBox(com.google.gwt.user.client.ui.ListBox) Fulfill(org.cesiumjs.cs.promise.Fulfill)

Example 38 with ChangeHandler

use of com.google.gwt.event.dom.client.ChangeHandler in project gwt-cs by iSergio.

the class Models3D method buildPanel.

@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("<p>Create 3D models using glTF.</p>"));
    contentPanel.add(aPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) Quaternion(org.cesiumjs.cs.core.Quaternion) ViewerOptions(org.cesiumjs.cs.widgets.options.ViewerOptions) AbsolutePanel(com.google.gwt.user.client.ui.AbsolutePanel) HTML(com.google.gwt.user.client.ui.HTML) ConstantPositionProperty(org.cesiumjs.cs.datasources.properties.ConstantPositionProperty) ModelGraphics(org.cesiumjs.cs.datasources.graphics.ModelGraphics) EntityOptions(org.cesiumjs.cs.datasources.options.EntityOptions) ModelGraphicsOptions(org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) Cartesian3(org.cesiumjs.cs.core.Cartesian3) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ListBox(com.google.gwt.user.client.ui.ListBox)

Example 39 with ChangeHandler

use of com.google.gwt.event.dom.client.ChangeHandler in project gwt-cs by iSergio.

the class Shadows method buildPanel.

@Override
public void buildPanel() {
    ViewerOptions viewerOptions = new ViewerOptions();
    viewerOptions.infoBox = false;
    viewerOptions.selectionIndicator = false;
    viewerOptions.shadows = true;
    viewerOptions.terrainShadows = ShadowMode.ENABLED();
    csVPanel = new ViewerPanel(viewerOptions);
    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);
    shadowMap = csVPanel.getViewer().shadowMap();
    shadowMap.maximumDistance = 10000.0;
    ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
    modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb");
    EntityOptions entityOptions = new EntityOptions();
    entityOptions.name = "Cesium Air";
    entityOptions.model = new ModelGraphics(modelGraphicsOptions);
    JsObject.$(entityOptions, "height", 20.0);
    cesiumAir = csVPanel.getViewer().entities().add(entityOptions);
    modelGraphicsOptions = new ModelGraphicsOptions();
    modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/CesiumGround/Cesium_Ground.glb");
    entityOptions = new EntityOptions();
    entityOptions.name = "Ground Vehicle";
    JsObject.$(entityOptions, "height", 0.0);
    entityOptions.model = new ModelGraphics(modelGraphicsOptions);
    groundVehicle = csVPanel.getViewer().entities().add(entityOptions);
    modelGraphicsOptions = new ModelGraphicsOptions();
    modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb");
    entityOptions = new EntityOptions();
    entityOptions.name = "Cesium Man";
    JsObject.$(entityOptions, "height", 0.0);
    entityOptions.model = new ModelGraphics(modelGraphicsOptions);
    cesiumMan = csVPanel.getViewer().entities().add(entityOptions);
    modelGraphicsOptions = new ModelGraphicsOptions();
    modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/WoodTower/Wood_Tower.gltf");
    entityOptions = new EntityOptions();
    entityOptions.name = "Wood Tower";
    JsObject.$(entityOptions, "height", 0.0);
    entityOptions.model = new ModelGraphics(modelGraphicsOptions);
    woodTower = csVPanel.getViewer().entities().add(entityOptions);
    modelGraphicsOptions = new ModelGraphicsOptions();
    modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/ShadowTester/Shadow_Tester_4.gltf");
    entityOptions = new EntityOptions();
    entityOptions.name = "Simple City";
    JsObject.$(entityOptions, "height", 0.0);
    entityOptions.model = new ModelGraphics(modelGraphicsOptions);
    simpleCity = csVPanel.getViewer().entities().add(entityOptions);
    BoxGraphicsOptions boxGraphicsOptions = new BoxGraphicsOptions();
    boxGraphicsOptions.dimensions = new ConstantProperty<>(new Cartesian3(10.0, 10.0, 10.0));
    boxGraphicsOptions.material = new ColorMaterialProperty(Color.RED());
    boxGraphicsOptions.shadows = new ConstantProperty<>(ShadowMode.ENABLED());
    entityOptions = new EntityOptions();
    entityOptions.name = "Box";
    JsObject.$(entityOptions, "height", 10.0);
    entityOptions.box = new BoxGraphics(boxGraphicsOptions);
    boxEntity = csVPanel.getViewer().entities().add(entityOptions);
    CheckerboardMaterialPropertyOptions checkerboardMaterialPropertyOptions = new CheckerboardMaterialPropertyOptions();
    checkerboardMaterialPropertyOptions.evenColor = new ConstantProperty<>(Color.RED().withAlpha(0.5f));
    checkerboardMaterialPropertyOptions.oddColor = new ConstantProperty<>(Color.RED().withAlpha(0.0f));
    checkerboardMaterialPropertyOptions.repeat = new ConstantProperty<>(new Cartesian2(5.0, 10.0));
    CheckerboardMaterialProperty checkerMaterial = new CheckerboardMaterialProperty(checkerboardMaterialPropertyOptions);
    boxGraphicsOptions = new BoxGraphicsOptions();
    boxGraphicsOptions.dimensions = new ConstantProperty<>(new Cartesian3(10.0, 10.0, 10.0));
    boxGraphicsOptions.material = checkerMaterial;
    boxGraphicsOptions.outline = new ConstantProperty<>(true);
    boxGraphicsOptions.outlineColor = new ConstantProperty<>(Color.RED());
    boxGraphicsOptions.shadows = new ConstantProperty<>(ShadowMode.ENABLED());
    entityOptions = new EntityOptions();
    entityOptions.name = "Checkered Box";
    JsObject.$(entityOptions, "height", 10.0);
    entityOptions.box = new BoxGraphics(boxGraphicsOptions);
    checkerEntity = csVPanel.getViewer().entities().add(entityOptions);
    EllipsoidGraphicsOptions ellipsoidGraphicsOptions = new EllipsoidGraphicsOptions();
    ellipsoidGraphicsOptions.radii = new ConstantProperty<>(new Cartesian3(15.0, 15.0, 15.0));
    ellipsoidGraphicsOptions.material = new ColorMaterialProperty(Color.BLUE().withAlpha(0.5f));
    ellipsoidGraphicsOptions.slicePartitions = new ConstantProperty<>(24);
    ellipsoidGraphicsOptions.stackPartitions = new ConstantProperty<>(36);
    ellipsoidGraphicsOptions.shadows = new ConstantProperty<>(ShadowMode.ENABLED());
    entityOptions = new EntityOptions();
    entityOptions.name = "Sphere";
    JsObject.$(entityOptions, "height", 10.0);
    entityOptions.ellipsoid = new EllipsoidGraphics(ellipsoidGraphicsOptions);
    sphereEntity = csVPanel.getViewer().entities().add(entityOptions);
    setLocation(locations.get(0));
    setEntity(cesiumAir);
    ListBox locationLBox = new ListBox();
    for (int i = 0; i < locations.size(); i++) {
        Location location = locations.get(i);
        locationLBox.addItem(location.name, i + "");
    }
    locationLBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent changeEvent) {
            ListBox source = (ListBox) changeEvent.getSource();
            setLocation(locations.get(Integer.parseInt(source.getSelectedValue())));
        }
    });
    ListBox entitiList = new ListBox();
    entitiList.addItem("Cesium Air");
    entitiList.addItem("Ground Vehicle");
    entitiList.addItem("Cesium Man");
    entitiList.addItem("Wood Tower");
    entitiList.addItem("Simple City");
    entitiList.addItem("Box");
    entitiList.addItem("Checkered Box");
    entitiList.addItem("Sphere");
    entitiList.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent changeEvent) {
            ListBox source = (ListBox) changeEvent.getSource();
            switch(source.getSelectedIndex()) {
                case 0:
                    setEntity(cesiumAir);
                    break;
                case 1:
                    setEntity(groundVehicle);
                    break;
                case 2:
                    setEntity(cesiumMan);
                    break;
                case 3:
                    setEntity(woodTower);
                    break;
                case 4:
                    setEntity(simpleCity);
                    break;
                case 5:
                    setEntity(boxEntity);
                    break;
                case 6:
                    setEntity(checkerEntity);
                    break;
                case 7:
                    setEntity(sphereEntity);
                    break;
                default:
                    break;
            }
        }
    });
    CheckBox shadowsCBox = new CheckBox("Shadows");
    shadowsCBox.getElement().getStyle().setColor("white");
    shadowsCBox.setValue(true);
    shadowsCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
            csVPanel.getViewer().shadows = !csVPanel.getViewer().shadows;
        }
    });
    CheckBox entitiShadowsCBox = new CheckBox("Entity Shadows");
    entitiShadowsCBox.getElement().getStyle().setColor("white");
    entitiShadowsCBox.setValue(true);
    entitiShadowsCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
            Number entityShadows = valueChangeEvent.getValue() ? ShadowMode.ENABLED() : ShadowMode.DISABLED();
            for (int i = 0; i < csVPanel.getViewer().entities().values().length; i++) {
                Entity entity = csVPanel.getViewer().entities().values()[i];
                if (entity.model != null) {
                    entity.model.shadows = new ConstantProperty<>(entityShadows);
                } else if (entity.box != null) {
                    entity.box.shadows = new ConstantProperty<>(entityShadows);
                } else if (entity.ellipsoid != null) {
                    entity.ellipsoid.shadows = new ConstantProperty<>(entityShadows);
                }
            }
        }
    });
    CheckBox terrainShadowsCBox = new CheckBox("Terrain Shadows");
    terrainShadowsCBox.getElement().getStyle().setColor("white");
    terrainShadowsCBox.setValue(true);
    terrainShadowsCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
            csVPanel.getViewer().terrainShadows = valueChangeEvent.getValue() ? ShadowMode.ENABLED() : ShadowMode.DISABLED();
        }
    });
    CheckBox softShadowsCBox = new CheckBox("Soft Shadows");
    softShadowsCBox.getElement().getStyle().setColor("white");
    softShadowsCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
            shadowMap.softShadows = valueChangeEvent.getValue();
        }
    });
    ListBox sizeLBox = new ListBox();
    sizeLBox.addItem("Size: 2048", "2048");
    sizeLBox.addItem("Size: 1024", "1024");
    sizeLBox.addItem("Size: 512", "512");
    sizeLBox.addItem("Size: 256", "256");
    sizeLBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent changeEvent) {
            ListBox source = (ListBox) changeEvent.getSource();
            shadowMap.size = Integer.parseInt(source.getSelectedValue());
        }
    });
    VerticalPanel vPanel = new VerticalPanel();
    vPanel.add(locationLBox);
    vPanel.add(entitiList);
    vPanel.add(shadowsCBox);
    vPanel.add(entitiShadowsCBox);
    vPanel.add(terrainShadowsCBox);
    vPanel.add(softShadowsCBox);
    vPanel.add(sizeLBox);
    FlowPanel fPanel = new FlowPanel();
    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(csVPanel);
    aPanel.add(vPanel, 20, 20);
    fPanel.add(aPanel);
    contentPanel.add(new HTML("<p>Shadow maps.</p>"));
    contentPanel.add(fPanel);
    initWidget(contentPanel);
}
Also used : CesiumTerrainProviderOptions(org.cesiumjs.cs.core.providers.options.CesiumTerrainProviderOptions) Entity(org.cesiumjs.cs.datasources.Entity) ViewerOptions(org.cesiumjs.cs.widgets.options.ViewerOptions) CheckerboardMaterialProperty(org.cesiumjs.cs.datasources.properties.CheckerboardMaterialProperty) ColorMaterialProperty(org.cesiumjs.cs.datasources.properties.ColorMaterialProperty) ModelGraphics(org.cesiumjs.cs.datasources.graphics.ModelGraphics) EntityOptions(org.cesiumjs.cs.datasources.options.EntityOptions) EllipsoidGraphicsOptions(org.cesiumjs.cs.datasources.graphics.options.EllipsoidGraphicsOptions) Cartesian2(org.cesiumjs.cs.core.Cartesian2) EllipsoidGraphics(org.cesiumjs.cs.datasources.graphics.EllipsoidGraphics) Cartesian3(org.cesiumjs.cs.core.Cartesian3) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) CesiumTerrainProvider(org.cesiumjs.cs.core.providers.CesiumTerrainProvider) ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) ConstantProperty(org.cesiumjs.cs.datasources.properties.ConstantProperty) BoxGraphics(org.cesiumjs.cs.datasources.graphics.BoxGraphics) BoxGraphicsOptions(org.cesiumjs.cs.datasources.graphics.options.BoxGraphicsOptions) CheckerboardMaterialPropertyOptions(org.cesiumjs.cs.datasources.properties.options.CheckerboardMaterialPropertyOptions) ModelGraphicsOptions(org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent)

Example 40 with ChangeHandler

use of com.google.gwt.event.dom.client.ChangeHandler in project gwt-cs by iSergio.

the class Terrain method buildPanel.

@Override
public void buildPanel() {
    csVPanel = new ViewerPanel();
    CesiumTerrainProviderOptions cesiumTerrainProviderOptions = new CesiumTerrainProviderOptions();
    cesiumTerrainProviderOptions.url = "https://assets.agi.com/stk-terrain/world";
    cesiumTerrainProviderOptions.requestWaterMask = true;
    cesiumTerrainProviderOptions.requestVertexNormals = true;
    cesiumTerrainProviderMeshes = new CesiumTerrainProvider(cesiumTerrainProviderOptions);
    csVPanel.getViewer().terrainProvider = cesiumTerrainProviderMeshes;
    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());
    ListBox terrainsLBox = new ListBox();
    terrainsLBox.setWidth("130px");
    terrainsLBox.addItem("CesiumTerrainProvider - STK World Terrain", "0");
    terrainsLBox.addItem("CesiumTerrainProvider - STK World Terrain - no effects", "1");
    terrainsLBox.addItem("CesiumTerrainProvider - STK World Terrain w/ Lighting", "2");
    terrainsLBox.addItem("CesiumTerrainProvider - STK World Terrain w/ Water", "3");
    terrainsLBox.addItem("EllipsoidTerrainProvider", "4");
    terrainsLBox.addItem("VRTheWorldTerrainProvider", "5");
    terrainsLBox.addItem("GeoserverTerrainProvider", "6");
    terrainsLBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent changeEvent) {
            ListBox source = (ListBox) changeEvent.getSource();
            switch(source.getSelectedValue()) {
                case "0":
                    {
                        csVPanel.getViewer().terrainProvider = cesiumTerrainProviderMeshes;
                        csVPanel.getViewer().scene().globe.enableLighting = true;
                    }
                    break;
                case "1":
                    {
                        CesiumTerrainProviderOptions options = new CesiumTerrainProviderOptions();
                        options.url = "https://assets.agi.com/stk-terrain/world";
                        csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(options);
                    }
                    break;
                case "2":
                    {
                        CesiumTerrainProviderOptions options = new CesiumTerrainProviderOptions();
                        options.url = "https://assets.agi.com/stk-terrain/world";
                        options.requestVertexNormals = true;
                        csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(options);
                        csVPanel.getViewer().scene().globe.enableLighting = true;
                    }
                    break;
                case "3":
                    {
                        CesiumTerrainProviderOptions options = new CesiumTerrainProviderOptions();
                        options.url = "https://assets.agi.com/stk-terrain/world";
                        options.requestWaterMask = true;
                        csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(options);
                        csVPanel.getViewer().scene().globe.enableLighting = true;
                    }
                    break;
                case "4":
                    {
                        csVPanel.getViewer().terrainProvider = new EllipsoidTerrainProvider();
                    }
                    break;
                case "5":
                    {
                        VRTheWorldTerrainProviderOptions options = new VRTheWorldTerrainProviderOptions();
                        options.url = "http://www.vr-theworld.com/vr-theworld/tiles1.0.0/73/";
                        csVPanel.getViewer().terrainProvider = new VRTheWorldTerrainProvider(options);
                    }
                    break;
                case "6":
                    {
                        GeoserverTerrainProviderOptions options = new GeoserverTerrainProviderOptions();
                        options.url = "http://sergeserver.noip.me/geobase-portal/ows";
                        options.layerName = "geoserver:geobase:SRTM90";
                        options.styleName = "geobase:grayToColor";
                        csVPanel.getViewer().terrainProvider = new GeoserverTerrainProvider(options);
                    }
                    break;
                default:
                    break;
            }
        }
    });
    ListBox targetsLBox = new ListBox();
    targetsLBox.addItem("Mount Everest", "0");
    targetsLBox.addItem("Half Dome", "1");
    targetsLBox.addItem("San Francisco Bay", "2");
    targetsLBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent changeEvent) {
            ListBox source = (ListBox) changeEvent.getSource();
            switch(source.getSelectedValue()) {
                case "0":
                    {
                        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());
                    }
                    break;
                case "1":
                    {
                        Cartesian3 target = new Cartesian3(-2489625.0836225147, -4393941.44443024, 3882535.9454173897);
                        Cartesian3 offset = new Cartesian3(-6857.40902037546, 412.3284835694358, 2147.5545426812023);
                        csVPanel.getViewer().camera.lookAt(target, offset);
                        csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
                    }
                    break;
                case "2":
                    {
                        Cartesian3 target = new Cartesian3(-2708814.85583248, -4254159.450845907, 3891403.9457429945);
                        Cartesian3 offset = new Cartesian3(70642.66030209465, -31661.517948317807, 35505.179997143336);
                        csVPanel.getViewer().camera.lookAt(target, offset);
                        csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
                    }
                default:
                    break;
            }
        }
    });
    ToggleButton lightingTBtn = new ToggleButton("Toggle Lighting");
    lightingTBtn.setWidth("130px");
    lightingTBtn.setValue(true);
    lightingTBtn.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
            csVPanel.getViewer().scene().globe.enableLighting = !csVPanel.getViewer().scene().globe.enableLighting;
        }
    });
    ToggleButton fogTBtn = new ToggleButton("Toggle Fog");
    fogTBtn.setWidth("130px");
    fogTBtn.setValue(true);
    fogTBtn.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
            csVPanel.getViewer().scene().fog.enabled = !csVPanel.getViewer().scene().fog.enabled;
        }
    });
    Button sampleBtn = new Button("Sample Everest Terrain");
    sampleBtn.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            int gridWidth = 41;
            int gridHeight = 41;
            double everestLatitude = Math.toRadians(27.988257);
            double everestLongitude = Math.toRadians(86.925145);
            double rectangleHalfSize = 0.005;
            Rectangle e = new Rectangle(everestLongitude - rectangleHalfSize, everestLatitude - rectangleHalfSize, everestLongitude + rectangleHalfSize, everestLatitude + rectangleHalfSize);
            terrainSamplePositions = new ArrayList<>();
            for (int y = 0; y < gridHeight; ++y) {
                for (int x = 0; x < gridWidth; ++x) {
                    double lon = Math.lerp(e.west, e.east, (double) x / (gridWidth - 1.));
                    double lat = Math.lerp(e.south, e.north, (double) y / (gridHeight - 1.));
                    Cartographic position = new Cartographic(lon, lat);
                    terrainSamplePositions.add(position);
                }
            }
            Promise<Cartographic[], Void> promise = Cesium.sampleTerrain(csVPanel.getViewer().terrainProvider, 9, terrainSamplePositions.toArray(new Cartographic[terrainSamplePositions.size()]));
            promise.then(new Fulfill<Cartographic[]>() {

                @Override
                public void onFulfilled(Cartographic[] value) {
                    sampleTerrainSuccess();
                }
            });
        }
    });
    VerticalPanel vPanel = new VerticalPanel();
    vPanel.add(targetsLBox);
    vPanel.add(terrainsLBox);
    vPanel.add(lightingTBtn);
    vPanel.add(fogTBtn);
    vPanel.add(sampleBtn);
    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(csVPanel);
    aPanel.add(vPanel, 20, 20);
    contentPanel.add(new HTML("<p>Visualize worldwide, high-resolution terrain.</p>"));
    contentPanel.add(aPanel);
    initWidget(contentPanel);
}
Also used : VRTheWorldTerrainProvider(org.cesiumjs.cs.core.providers.VRTheWorldTerrainProvider) CesiumTerrainProviderOptions(org.cesiumjs.cs.core.providers.options.CesiumTerrainProviderOptions) EllipsoidTerrainProvider(org.cesiumjs.cs.core.providers.EllipsoidTerrainProvider) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) GeoserverTerrainProviderOptions(org.cesiumjs.cs.core.providers.options.GeoserverTerrainProviderOptions) VRTheWorldTerrainProviderOptions(org.cesiumjs.cs.core.providers.options.VRTheWorldTerrainProviderOptions) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) CesiumTerrainProvider(org.cesiumjs.cs.core.providers.CesiumTerrainProvider) Fulfill(org.cesiumjs.cs.promise.Fulfill) ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) Promise(org.cesiumjs.cs.promise.Promise) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) GeoserverTerrainProvider(org.cesiumjs.cs.core.providers.GeoserverTerrainProvider)

Aggregations

ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)123 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)123 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)48 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)48 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)34 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)31 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)31 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)31 ListBox (org.gwtbootstrap3.client.ui.ListBox)31 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)29 ArrayList (java.util.ArrayList)26 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)21 PerunError (cz.metacentrum.perun.webgui.model.PerunError)17 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)16 HTML (com.google.gwt.user.client.ui.HTML)14 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)14 HashMap (java.util.HashMap)13 ListBox (com.google.gwt.user.client.ui.ListBox)12 FormStylePopup (org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup)12 Map (java.util.Map)11