Search in sources :

Example 6 with ViewerOptions

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

the class CustomBaseLayerPicker method buildPanel.

@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<ProviderViewModel> imageryViewModels = 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() {
            return new ImageryProvider[] { 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 ImageryProvider[] { 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() {
            return new ImageryProvider[] { Cesium.createTileMapServiceImageryProvider(GWT.getModuleBaseURL() + "cs/CesiumUnminified/Assets/Textures/NaturalEarthII") };
        }
    };
    imageryViewModels.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[imageryViewModels.size()]);
    baseLayerPickerOptions.selectedImageryProviderViewModel = imageryViewModels.get(0);
    BaseLayerPicker baseLayerPicker = new BaseLayerPicker(divElement, baseLayerPickerOptions);
    contentPanel.add(new HTML("<p>Configure custom BaseLayerPicker widget.</p>"));
    contentPanel.add(csVPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) ArrayList(java.util.ArrayList) ViewerOptions(org.cesiumjs.cs.widgets.options.ViewerOptions) HTML(com.google.gwt.user.client.ui.HTML) ProviderViewModelOptions(org.cesiumjs.cs.widgets.options.ProviderViewModelOptions) DivElement(com.google.gwt.dom.client.DivElement) IonImageryProvider(org.cesiumjs.cs.scene.providers.IonImageryProvider) ProviderViewModel(org.cesiumjs.cs.widgets.ProviderViewModel) BaseLayerPickerViewModelOptions(org.cesiumjs.cs.widgets.options.BaseLayerPickerViewModelOptions) BaseLayerPicker(org.cesiumjs.cs.widgets.BaseLayerPicker)

Example 7 with ViewerOptions

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

the class CustomHomeButton method buildPanel.

@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("<div>Click the home button to fly to New York.</div>"));
    contentPanel.add(viewer);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) Entity(org.cesiumjs.cs.datasources.Entity) PointGraphicsOptions(org.cesiumjs.cs.datasources.graphics.options.PointGraphicsOptions) ViewerOptions(org.cesiumjs.cs.widgets.options.ViewerOptions) PointGraphics(org.cesiumjs.cs.datasources.graphics.PointGraphics) HTML(com.google.gwt.user.client.ui.HTML) ConstantPositionProperty(org.cesiumjs.cs.datasources.properties.ConstantPositionProperty) EntityOptions(org.cesiumjs.cs.datasources.options.EntityOptions) Event(org.cesiumjs.cs.core.Event)

Example 8 with ViewerOptions

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

the class ImageryLayersManipulation method buildPanel.

@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();
            selectedLayer = baseLayer;
        }
    });
    Callback<Void, Void> cesiumCreated = new Callback<Void, Void>() {

        @Override
        public void onFailure(Void aVoid) {
        // 
        }

        @Override
        public void onSuccess(Void aVoid) {
            for (Map.Entry<String, ImageryLayer> entry : baseLayers.entrySet()) {
                baseLayersLBox.addItem(entry.getKey(), entry.getKey());
            }
        }
    };
    addCallback(cesiumCreated);
    contentPanel.add(new HTML("<p>Layer imagery from multiple sources, including WMS servers, Bing Maps, ArcGIS Online, OpenStreetMaps, and more, and adjust the alpha of each independently.</p>"));
    contentPanel.add(baseLayersHPanel);
    contentPanel.add(csVPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) Slider(org.cleanlogic.showcase.client.examples.slider.Slider) ViewerOptions(org.cesiumjs.cs.widgets.options.ViewerOptions) Callback(com.google.gwt.core.client.Callback) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ImageryLayer(org.cesiumjs.cs.scene.ImageryLayer) HashMap(java.util.HashMap) Map(java.util.Map)

Example 9 with ViewerOptions

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

the class ViewerPanelTest method testRequestRenderMode.

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);
            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();
        }
    });
}
Also used : DivElement(com.google.gwt.dom.client.DivElement) LinkElement(com.google.gwt.dom.client.LinkElement) LinkElement(com.google.gwt.dom.client.LinkElement) Element(com.google.gwt.dom.client.Element) DivElement(com.google.gwt.dom.client.DivElement) ViewerOptions(org.cesiumjs.cs.widgets.options.ViewerOptions)

Example 10 with ViewerOptions

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

the class TerrainClippingPlanes method buildPanel.

@Override
public void buildPanel() {
    ViewerOptions viewerOptions = new ViewerOptions();
    viewerOptions.skyAtmosphere = null;
    final ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
    CesiumTerrainProviderOptions terrainProviderOptions = new CesiumTerrainProviderOptions();
    terrainProviderOptions.url = "https://assets.agi.com/stk-terrain/v1/tilesets/world/tiles";
    terrainProviderOptions.requestWaterMask = true;
    terrainProviderOptions.requestVertexNormals = true;
    csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(terrainProviderOptions);
    Cartesian3 position = Cartesian3.fromRadians(-2.0862979473351286, 0.6586620013036164, 1400.0);
    BoxGraphicsOptions boxGraphicsOptions = new BoxGraphicsOptions();
    boxGraphicsOptions.dimensions = new ConstantProperty<>(new Cartesian3(1400.0, 1400.0, 2800.0));
    boxGraphicsOptions.material = new ColorMaterialProperty(Color.WHITE().withAlpha(0.3f));
    boxGraphicsOptions.outline = new ConstantProperty<>(true);
    boxGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
    EntityOptions entityOptions = new EntityOptions();
    entityOptions.position = new ConstantPositionProperty(position);
    entityOptions.box = new BoxGraphics(boxGraphicsOptions);
    Entity entity = csVPanel.getViewer().entities().add(entityOptions);
    ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
    modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb");
    modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(128);
    modelGraphicsOptions.maximumScale = new ConstantProperty<>(800);
    entityOptions = new EntityOptions();
    entityOptions.position = new ConstantPositionProperty(position);
    entityOptions.model = new ModelGraphics(modelGraphicsOptions);
    csVPanel.getViewer().entities().add(entityOptions);
    ClippingPlaneCollectionOptions clippingPlaneCollectionOptions = new ClippingPlaneCollectionOptions();
    clippingPlaneCollectionOptions.modelMatrix = entity.computeModelMatrix(JulianDate.now());
    clippingPlaneCollectionOptions.planes = new ClippingPlane[] { new ClippingPlane(new Cartesian3(1.0, 0.0, 0.0), -700.0), new ClippingPlane(new Cartesian3(-1.0, 0.0, 0.0), -700.0), new ClippingPlane(new Cartesian3(0.0, 1.0, 0.0), -700.0), new ClippingPlane(new Cartesian3(0.0, -1.0, 0.0), -700.0) };
    clippingPlaneCollectionOptions.edgeWidth = 1.0;
    clippingPlaneCollectionOptions.edgeColor = Color.WHITE();
    final Globe globe = csVPanel.getViewer().scene().globe;
    globe.depthTestAgainstTerrain = true;
    globe.clippingPlanes = new ClippingPlaneCollection(clippingPlaneCollectionOptions);
    csVPanel.getViewer().trackedEntity = entity;
    CheckBox globeClippingCBox = new CheckBox("Globe clipping planes enabled");
    globeClippingCBox.setValue(true);
    globeClippingCBox.getElement().getStyle().setColor("white");
    globeClippingCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            globe.clippingPlanes.enabled = event.getValue();
        }
    });
    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(csVPanel);
    aPanel.add(globeClippingCBox, 20, 20);
    contentPanel.add(new HTML("<p>User-defined clipping planes applied to terrain.</p>"));
    contentPanel.add(aPanel);
    initWidget(contentPanel);
}
Also used : CesiumTerrainProviderOptions(org.cesiumjs.cs.core.providers.options.CesiumTerrainProviderOptions) Entity(org.cesiumjs.cs.datasources.Entity) ClippingPlaneCollection(org.cesiumjs.cs.collections.ClippingPlaneCollection) ViewerOptions(org.cesiumjs.cs.widgets.options.ViewerOptions) AbsolutePanel(com.google.gwt.user.client.ui.AbsolutePanel) ClippingPlaneCollectionOptions(org.cesiumjs.cs.collections.options.ClippingPlaneCollectionOptions) HTML(com.google.gwt.user.client.ui.HTML) ColorMaterialProperty(org.cesiumjs.cs.datasources.properties.ColorMaterialProperty) ModelGraphics(org.cesiumjs.cs.datasources.graphics.ModelGraphics) EntityOptions(org.cesiumjs.cs.datasources.options.EntityOptions) CesiumTerrainProvider(org.cesiumjs.cs.core.providers.CesiumTerrainProvider) ClippingPlane(org.cesiumjs.cs.scene.ClippingPlane) ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) BoxGraphics(org.cesiumjs.cs.datasources.graphics.BoxGraphics) BoxGraphicsOptions(org.cesiumjs.cs.datasources.graphics.options.BoxGraphicsOptions) ConstantPositionProperty(org.cesiumjs.cs.datasources.properties.ConstantPositionProperty) ModelGraphicsOptions(org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions) CheckBox(com.google.gwt.user.client.ui.CheckBox)

Aggregations

ViewerOptions (org.cesiumjs.cs.widgets.options.ViewerOptions)15 ViewerPanel (org.cesiumjs.cs.widgets.ViewerPanel)14 HTML (com.google.gwt.user.client.ui.HTML)11 EntityOptions (org.cesiumjs.cs.datasources.options.EntityOptions)6 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)5 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)5 Entity (org.cesiumjs.cs.datasources.Entity)5 ModelGraphics (org.cesiumjs.cs.datasources.graphics.ModelGraphics)5 ModelGraphicsOptions (org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions)5 AbsolutePanel (com.google.gwt.user.client.ui.AbsolutePanel)4 ConstantPositionProperty (org.cesiumjs.cs.datasources.properties.ConstantPositionProperty)4 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)3 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)3 CesiumTerrainProvider (org.cesiumjs.cs.core.providers.CesiumTerrainProvider)3 CesiumTerrainProviderOptions (org.cesiumjs.cs.core.providers.options.CesiumTerrainProviderOptions)3 ConstantProperty (org.cesiumjs.cs.datasources.properties.ConstantProperty)3 ImageryLayer (org.cesiumjs.cs.scene.ImageryLayer)3 Slider (org.cleanlogic.showcase.client.examples.slider.Slider)3 DivElement (com.google.gwt.dom.client.DivElement)2 CheckBox (com.google.gwt.user.client.ui.CheckBox)2