Search in sources :

Example 1 with SliderListener

use of org.cleanlogic.showcase.client.examples.slider.SliderListener in project gwt-cs by iSergio.

the class ImageryLayersSplit method buildPanel.

@Override
public void buildPanel() {
    ViewerOptions viewerOptions = new ViewerOptions();
    viewerOptions.imageryProvider = ArcGisMapServerImageryProvider.create("https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
    viewerOptions.baseLayerPicker = false;
    final ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
    ImageryLayerCollection layers = csVPanel.getViewer().imageryLayers();
    TileMapServiceImageryProviderOptions tileMapServiceImageryProviderOptions = new TileMapServiceImageryProviderOptions();
    tileMapServiceImageryProviderOptions.url = "https://cesiumjs.org/blackmarble";
    tileMapServiceImageryProviderOptions.credit = Credit.create("Black Marble imagery courtesy NASA Earth Observatory");
    tileMapServiceImageryProviderOptions.flipXY = true;
    ImageryLayer blackMarble = layers.addImageryProvider(Cesium.createTileMapServiceImageryProvider(tileMapServiceImageryProviderOptions));
    blackMarble.splitDirection = ImagerySplitDirection.LEFT();
    csVPanel.getViewer().scene().imagerySplitPosition = 0.5;
    Slider slider = new Slider("Slider", 0, 100, 50);
    slider.setStep(1);
    slider.setWidth("100%");
    slider.addListener(new SliderListener() {

        @Override
        public void onStart(SliderEvent e) {
        // 
        }

        @Override
        public boolean onSlide(SliderEvent e) {
            Slider source = e.getSource();
            double value = source.getValue() / 100.;
            csVPanel.getViewer().scene().imagerySplitPosition = value;
            return true;
        }

        @Override
        public void onChange(SliderEvent e) {
        // 
        }

        @Override
        public void onStop(SliderEvent e) {
        // 
        }
    });
    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(csVPanel);
    aPanel.add(slider, 0, 5);
    contentPanel.add(aPanel);
    contentPanel.add(new HTML("<p>Use the split property to only show layers on one side of a slider.</p>"));
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) SliderEvent(org.cleanlogic.showcase.client.examples.slider.SliderEvent) Slider(org.cleanlogic.showcase.client.examples.slider.Slider) ImageryLayer(org.cesiumjs.cs.scene.ImageryLayer) ViewerOptions(org.cesiumjs.cs.widgets.options.ViewerOptions) TileMapServiceImageryProviderOptions(org.cesiumjs.cs.scene.providers.options.TileMapServiceImageryProviderOptions) AbsolutePanel(com.google.gwt.user.client.ui.AbsolutePanel) ImageryLayerCollection(org.cesiumjs.cs.collections.ImageryLayerCollection) HTML(com.google.gwt.user.client.ui.HTML) SliderListener(org.cleanlogic.showcase.client.examples.slider.SliderListener)

Aggregations

AbsolutePanel (com.google.gwt.user.client.ui.AbsolutePanel)1 HTML (com.google.gwt.user.client.ui.HTML)1 ImageryLayerCollection (org.cesiumjs.cs.collections.ImageryLayerCollection)1 ImageryLayer (org.cesiumjs.cs.scene.ImageryLayer)1 TileMapServiceImageryProviderOptions (org.cesiumjs.cs.scene.providers.options.TileMapServiceImageryProviderOptions)1 ViewerPanel (org.cesiumjs.cs.widgets.ViewerPanel)1 ViewerOptions (org.cesiumjs.cs.widgets.options.ViewerOptions)1 Slider (org.cleanlogic.showcase.client.examples.slider.Slider)1 SliderEvent (org.cleanlogic.showcase.client.examples.slider.SliderEvent)1 SliderListener (org.cleanlogic.showcase.client.examples.slider.SliderListener)1