Example usage for com.google.gwt.user.client.ui CheckBox addValueChangeHandler

List of usage examples for com.google.gwt.user.client.ui CheckBox addValueChangeHandler

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui CheckBox addValueChangeHandler.

Prototype

@Override
    public HandlerRegistration addValueChangeHandler(ValueChangeHandler<Boolean> handler) 

Source Link

Usage

From source file:org.cleanlogic.cesiumjs4gwt.showcase.examples.CartographicLimitRectangle.java

License:Apache License

@Override
public void buildPanel() {
    ViewerOptions viewerOptions = new ViewerOptions();
    viewerOptions.terrainProvider = Cesium.createWorldTerrain();
    csVPanel = new ViewerPanel(viewerOptions);

    // Tropics of Cancer and Capricorn
    final Rectangle coffeeBeltRectangle = Rectangle.fromDegrees(-180.0, -23.43687, 180.0, 23.43687);

    csVPanel.getViewer().scene().globe.cartographicLimitRectangle = coffeeBeltRectangle;
    csVPanel.getViewer().scene().skyAtmosphere.show = false;

    // Add rectangles to show bounds
    final List<Entity> rectangles = new ArrayList<>();

    for (int i = 0; i < 10; i++) {
        RectangleGraphicsOptions rectangleGraphicsOptions = new RectangleGraphicsOptions();
        rectangleGraphicsOptions.coordinates = new ConstantProperty<>(coffeeBeltRectangle);
        rectangleGraphicsOptions.material = new ColorMaterialProperty(Color.WHITE().withAlpha(0.0f));
        rectangleGraphicsOptions.height = new ConstantProperty<>(i * 5000.0);
        rectangleGraphicsOptions.outline = new ConstantProperty<>(true);
        rectangleGraphicsOptions.outlineWidth = new ConstantProperty<>(4.0);
        rectangleGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());

        EntityOptions entityOptions = new EntityOptions();
        entityOptions.rectangle = new RectangleGraphics(rectangleGraphicsOptions);

        rectangles.add(csVPanel.getViewer().entities().add(entityOptions));
    }//ww w. java2 s  . c o m

    CheckBox enableLimitCBox = new CheckBox();
    enableLimitCBox.setWidth("100px");
    enableLimitCBox.setValue(true);
    enableLimitCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            csVPanel.getViewer().scene().globe.cartographicLimitRectangle = event.getValue()
                    ? coffeeBeltRectangle
                    : Rectangle.MAX_VALUE();
        }
    });

    CheckBox showBoundsBox = new CheckBox();
    showBoundsBox.setWidth("100px");
    showBoundsBox.setValue(true);
    showBoundsBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            for (Entity rectangle : rectangles) {
                rectangle.show = event.getValue();
            }
        }
    });

    FlexTable flexTable = new FlexTable();
    flexTable.setHTML(1, 0, "<font color=\"white\">Limit Enabled</font>");
    flexTable.setWidget(1, 1, enableLimitCBox);
    flexTable.setHTML(2, 0, "<font color=\"white\">Show Bounds</font>");
    flexTable.setWidget(2, 1, showBoundsBox);

    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(csVPanel);
    aPanel.add(flexTable, 20, 20);

    contentPanel.add(new HTML("<p>Limit terrain and imagery to a cartographic Rectangle area.</p>"));
    contentPanel.add(aPanel);

    initWidget(contentPanel);
}

From source file:org.cleanlogic.cesiumjs4gwt.showcase.examples.Clustering.java

License:Apache License

@Override
public void buildPanel() {
    csVPanel = new ViewerPanel();
    KmlDataSourceLoadStaticOptions kmlDataSourceOptions = KmlDataSourceLoadStaticOptions
            .create(csVPanel.getViewer().camera, csVPanel.getViewer().canvas());
    Promise<KmlDataSource, Void> dataSourcePromise = csVPanel.getViewer().dataSources().add(KmlDataSource
            .load(GWT.getModuleBaseURL() + "SampleData/kml/facilities/facilities.kml", kmlDataSourceOptions));
    dataSourcePromise.then(new Fulfill<KmlDataSource>() {
        @Override// www  . j  a  va 2  s. c om
        public void onFulfilled(KmlDataSource dataSource) {
            int pixelRange = 25;
            int minimumClusterSize = 3;
            boolean enabled = true;

            dataSource.clustering.enabled = enabled;
            dataSource.clustering.pixelRange = pixelRange;
            dataSource.clustering.minimumClusterSize = minimumClusterSize;

            PinBuilder pinBuilder = new PinBuilder();
            pin50 = pinBuilder.fromText("50+", Color.RED(), 48).toDataUrl();
            pin40 = pinBuilder.fromText("40+", Color.ORANGE(), 48).toDataUrl();
            pin30 = pinBuilder.fromText("30+", Color.YELLOW(), 48).toDataUrl();
            pin20 = pinBuilder.fromText("20+", Color.GREEN(), 48).toDataUrl();
            pin10 = pinBuilder.fromText("10+", Color.BLUE(), 48).toDataUrl();

            singleDigitPins = new String[8];
            for (int i = 0; i < singleDigitPins.length; ++i) {
                singleDigitPins[i] = pinBuilder.fromText("" + (i + 2), Color.VIOLET(), 48).toDataUrl();
            }
            // start with custom style
            customStyle(dataSource);

            _dataSource = dataSource;
        }
    });

    pixelRangeSlider = new Slider("pixelRange", 1, 200, 15);
    pixelRangeSlider.setStep(1);
    pixelRangeSlider.setWidth("150px");
    pixelRangeSlider.addListener(new MSliderListener());
    pixelRangeTBox = new TextBox();
    pixelRangeTBox.addChangeHandler(new MChangeHandler());
    pixelRangeTBox.setText("" + 15);
    pixelRangeTBox.setSize("30px", "12px");

    HorizontalPanel pixelRangeHPanel = new HorizontalPanel();
    pixelRangeHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    pixelRangeHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    pixelRangeHPanel.setSpacing(10);
    pixelRangeHPanel.add(pixelRangeSlider);
    pixelRangeHPanel.add(pixelRangeTBox);

    minimumClusterSizeSlider = new Slider("minimumClusterSize", 1, 20, 3);
    minimumClusterSizeSlider.setStep(1);
    minimumClusterSizeSlider.setWidth("150px");
    minimumClusterSizeSlider.addListener(new MSliderListener());
    minimumClusterSizeTBox = new TextBox();
    pixelRangeTBox.addChangeHandler(new MChangeHandler());
    minimumClusterSizeTBox.setText("" + 3);
    minimumClusterSizeTBox.setSize("30px", "12px");

    HorizontalPanel minimumClusterSizeHPanel = new HorizontalPanel();
    minimumClusterSizeHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    minimumClusterSizeHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    minimumClusterSizeHPanel.setSpacing(10);
    minimumClusterSizeHPanel.add(minimumClusterSizeSlider);
    minimumClusterSizeHPanel.add(minimumClusterSizeTBox);

    CheckBox enabledCBox = new CheckBox();
    enabledCBox.setValue(true);
    enabledCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
            _dataSource.clustering.enabled = valueChangeEvent.getValue();
        }
    });

    CheckBox customStyleCBox = new CheckBox();
    customStyleCBox.setValue(true);
    customStyleCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
            customStyle(_dataSource);
        }
    });

    FlexTable flexTable = new FlexTable();
    flexTable.setHTML(1, 0, "<font color=\"white\">Pixel Range</font>");
    flexTable.setWidget(1, 1, pixelRangeHPanel);
    flexTable.setHTML(2, 0, "<font color=\"white\">Minimum Cluster Size</font>");
    flexTable.setWidget(2, 1, minimumClusterSizeHPanel);
    flexTable.setHTML(3, 0, "<font color=\"white\">Enabled</font>");
    flexTable.setWidget(3, 1, enabledCBox);
    flexTable.setHTML(4, 0, "<font color=\"white\">Custom Style</font>");
    flexTable.setWidget(4, 1, customStyleCBox);

    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(csVPanel);
    aPanel.add(flexTable, 20, 20);

    contentPanel.add(new HTML("<p>Cluster labels, billboards and points.</p>"));
    contentPanel.add(aPanel);

    initWidget(contentPanel);
}

From source file:org.cleanlogic.cesiumjs4gwt.showcase.examples.GroundAtmosphere.java

License:Apache License

@Override
public void buildPanel() {
    ViewerOptions viewerOptions = new ViewerOptions();
    viewerOptions.sceneModePicker = false;
    csVPanel = new ViewerPanel(viewerOptions);

    scene = csVPanel.getViewer().scene();
    globe = scene.globe;// w  ww. j  a  v  a 2  s .c  om

    lightingFadeOutDistance = globe.lightingFadeOutDistance;
    lightingFadeInDistance = globe.lightingFadeInDistance;
    nightFadeOutDistance = globe.nightFadeOutDistance;
    nightFadeInDistance = globe.nightFadeInDistance;

    HorizontalPanel lightingFadeOutDistanceHPanel = new HorizontalPanel();
    lightingFadeOutDistanceHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    lightingFadeOutDistanceHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    lightingFadeOutDistanceHPanel.setSpacing(10);
    lightingFadeOutDistanceSlider = new Slider("lightingFadeOutDistance", 1, 100, 10);
    lightingFadeOutDistanceSlider.setStep(1);
    lightingFadeOutDistanceSlider.setWidth("150px");
    lightingFadeOutDistanceSlider.addListener(new MSliderListener());
    lightingFadeOutDistanceTBox = new TextBox();
    lightingFadeOutDistanceTBox.addChangeHandler(new MChangeHandler());
    lightingFadeOutDistanceTBox.setText("" + 10 * 1e6);
    lightingFadeOutDistanceTBox.setSize("100px", "12px");
    lightingFadeOutDistanceHPanel.add(lightingFadeOutDistanceSlider);
    lightingFadeOutDistanceHPanel.add(lightingFadeOutDistanceTBox);

    HorizontalPanel lightingFadeInDistanceHPanel = new HorizontalPanel();
    lightingFadeInDistanceHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    lightingFadeInDistanceHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    lightingFadeInDistanceHPanel.setSpacing(10);
    lightingFadeInDistanceSlider = new Slider("lightingFadeInDistance", 1, 100, 20);
    lightingFadeInDistanceSlider.setStep(1);
    lightingFadeInDistanceSlider.setWidth("150px");
    lightingFadeInDistanceSlider.addListener(new MSliderListener());
    lightingFadeInDistanceTBox = new TextBox();
    lightingFadeInDistanceTBox.addChangeHandler(new MChangeHandler());
    lightingFadeInDistanceTBox.setText("" + 20 * 1e6);
    lightingFadeInDistanceTBox.setSize("100px", "12px");
    lightingFadeInDistanceHPanel.add(lightingFadeInDistanceSlider);
    lightingFadeInDistanceHPanel.add(lightingFadeInDistanceTBox);

    HorizontalPanel nightFadeOutDistanceHPanel = new HorizontalPanel();
    nightFadeOutDistanceHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    nightFadeOutDistanceHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    nightFadeOutDistanceHPanel.setSpacing(10);
    nightFadeOutDistanceSlider = new Slider("nightFadeOutDistance", 1, 100, 10);
    nightFadeOutDistanceSlider.setStep(1);
    nightFadeOutDistanceSlider.setWidth("150px");
    nightFadeOutDistanceSlider.addListener(new MSliderListener());
    nightFadeOutDistanceTBox = new TextBox();
    nightFadeOutDistanceTBox.addChangeHandler(new MChangeHandler());
    nightFadeOutDistanceTBox.setText("" + 10 * 1e6);
    nightFadeOutDistanceTBox.setSize("100px", "12px");
    nightFadeOutDistanceHPanel.add(nightFadeOutDistanceSlider);
    nightFadeOutDistanceHPanel.add(nightFadeOutDistanceTBox);

    HorizontalPanel nightFadeInDistanceHPanel = new HorizontalPanel();
    nightFadeInDistanceHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    nightFadeInDistanceHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    nightFadeInDistanceHPanel.setSpacing(10);
    nightFadeInDistanceSlider = new Slider("nightFadeInDistance", 1, 100, 50);
    nightFadeInDistanceSlider.setStep(1);
    nightFadeInDistanceSlider.setWidth("150px");
    nightFadeInDistanceSlider.addListener(new MSliderListener());
    nightFadeInDistanceTBox = new TextBox();
    nightFadeInDistanceTBox.addChangeHandler(new MChangeHandler());
    nightFadeInDistanceTBox.setText("" + 50 * 1e6);
    nightFadeInDistanceTBox.setSize("100px", "12px");
    nightFadeInDistanceHPanel.add(nightFadeInDistanceSlider);
    nightFadeInDistanceHPanel.add(nightFadeInDistanceTBox);

    CheckBox groundAtmosphereCBox = new CheckBox();
    groundAtmosphereCBox.setWidth("100px");
    groundAtmosphereCBox.setValue(true);
    groundAtmosphereCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            globe.showGroundAtmosphere = event.getValue();
        }
    });

    CheckBox lightingBox = new CheckBox();
    lightingBox.setWidth("100px");
    lightingBox.setValue(false);
    lightingBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            globe.enableLighting = event.getValue();
        }
    });

    ListBox terrainsLBox = new ListBox();
    terrainsLBox.setWidth("160px");
    terrainsLBox.addItem("Cesium World Terrain - no effects", "0");
    terrainsLBox.addItem("Cesium World Terrain w/ Vertex Normals", "1");
    terrainsLBox.addItem("Cesium World Terrain w/ Water", "2");
    terrainsLBox.addItem("Cesium World Terrain w/ Vertex Normals and Water", "3");
    terrainsLBox.addItem("EllipsoidTerrainProvider", "4");
    terrainsLBox.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent changeEvent) {
            ListBox source = (ListBox) changeEvent.getSource();
            switch (source.getSelectedValue()) {
            case "0": {
                csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain();
            }
                break;
            case "1": {
                Cesium.CreateWorldTerrainOptions options = new Cesium.CreateWorldTerrainOptions();
                options.requestVertexNormals = true;
                csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain(options);
            }
                break;
            case "2": {
                Cesium.CreateWorldTerrainOptions options = new Cesium.CreateWorldTerrainOptions();
                options.requestWaterMask = true;
                csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain(options);
            }
                break;
            case "3": {
                Cesium.CreateWorldTerrainOptions options = new Cesium.CreateWorldTerrainOptions();
                options.requestVertexNormals = true;
                options.requestWaterMask = true;
                csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain(options);
            }
                break;
            case "4": {
                csVPanel.getViewer().terrainProvider = new EllipsoidTerrainProvider();
            }
                break;
            default:
                break;
            }
        }
    });

    PushButton resetFadeDistancesPBtn = new PushButton();
    resetFadeDistancesPBtn.setText("Reset Fade Distances");
    resetFadeDistancesPBtn.setWidth("160px");
    resetFadeDistancesPBtn.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {
            globe.lightingFadeOutDistance = lightingFadeOutDistance;
            globe.lightingFadeInDistance = lightingFadeInDistance;
            globe.nightFadeOutDistance = nightFadeOutDistance;
            globe.nightFadeInDistance = nightFadeInDistance;

            lightingFadeOutDistanceSlider.setValue((int) (lightingFadeOutDistance / 1e6));
            lightingFadeInDistanceSlider.setValue((int) (lightingFadeInDistance / 1e6));
            nightFadeOutDistanceSlider.setValue((int) (nightFadeOutDistance / 1e6));
            nightFadeInDistanceSlider.setValue((int) (nightFadeInDistance / 1e6));

            lightingFadeOutDistanceTBox.setValue(String.valueOf(lightingFadeOutDistance), true);
            lightingFadeInDistanceTBox.setValue(String.valueOf(lightingFadeInDistance), true);
            nightFadeOutDistanceTBox.setValue(String.valueOf(nightFadeOutDistance), true);
            nightFadeInDistanceTBox.setValue(String.valueOf(nightFadeInDistance), true);
        }
    });

    FlexTable flexTable = new FlexTable();
    flexTable.setHTML(1, 0, "<font color=\"white\">Lighting Fade Out Distance</font>");
    flexTable.setWidget(1, 1, lightingFadeOutDistanceHPanel);
    flexTable.setHTML(2, 0, "<font color=\"white\">Lighting Fade In Distance</font>");
    flexTable.setWidget(2, 1, lightingFadeInDistanceHPanel);
    flexTable.setHTML(3, 0, "<font color=\"white\">Night Fade Out Distance</font>");
    flexTable.setWidget(3, 1, nightFadeOutDistanceHPanel);
    flexTable.setHTML(4, 0, "<font color=\"white\">Night Fade In Distance</font>");
    flexTable.setWidget(4, 1, nightFadeInDistanceHPanel);
    flexTable.setHTML(5, 0, "<font color=\"white\">Ground atmosphere</font>");
    flexTable.setWidget(5, 1, groundAtmosphereCBox);
    flexTable.setHTML(6, 0, "<font color=\"white\">Lighting</font>");
    flexTable.setWidget(6, 1, lightingBox);
    flexTable.setWidget(7, 1, terrainsLBox);
    flexTable.setWidget(8, 1, resetFadeDistancesPBtn);

    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(csVPanel);
    aPanel.add(flexTable, 20, 20);

    contentPanel.add(new HTML("<p>Adjust hue, saturation, and brightness of the sky/atmosphere.</p>"));
    contentPanel.add(aPanel);

    initWidget(contentPanel);
}

From source file:org.cleanlogic.cesiumjs4gwt.showcase.examples.ImageBasedLighting.java

License:Apache License

@Override
public void buildPanel() {
    ViewerPanel csVPanel = new ViewerPanel();
    viewer = csVPanel.getViewer();/*w  w w .  j a va 2  s.co m*/

    environmentMapURL = GWT.getModuleBaseURL() + "SampleData/EnvironmentMap/kiara_6_afternoon_2k_ibl.ktx";
    String modelURL = GWT.getModuleBaseURL() + "SampleData/models/Pawns/Pawns.glb";

    // This environment map was processed using Google's Filament project. To process your own:
    // 1 - Download the Filament release (https://github.com/google/filament/releases).
    // 2 - Run `cmgen --type=ktx --deploy=/path/to/output /path/to/image.hdr`. Other formats are also supported. Run `cmgen --help` for all options.
    // 3 - Take the generated coefficients and the KTX file and load them in CesiumJS as shown below.

    Cartesian3 L00 = new Cartesian3(0.170455150831422, 0.163151083190219, 0.196966760289763);
    Cartesian3 L1_1 = new Cartesian3(-0.066550267689383, -0.022088055746048, 0.078835009246127);
    Cartesian3 L10 = new Cartesian3(0.038364097478591, 0.045714300098753, 0.063498904606215);
    Cartesian3 L11 = new Cartesian3(-0.014365363312810, -0.026490613715151, -0.050189404066020);
    Cartesian3 L2_2 = new Cartesian3(-0.051532786917890, -0.050777795729986, -0.056449044453032);
    Cartesian3 L2_1 = new Cartesian3(0.043454596136534, 0.046672590104157, 0.057530107646610);
    Cartesian3 L20 = new Cartesian3(-0.001640466274110, 0.001286638231156, 0.007228908989616);
    Cartesian3 L21 = new Cartesian3(-0.042260855700641, -0.046394335094707, -0.057562936365585);
    Cartesian3 L22 = new Cartesian3(-0.004953478914091, -0.000479681664876, 0.008508150106928);
    coefficients = new Cartesian3[] { L00, L1_1, L10, L11, L2_2, L2_1, L20, L21, L22 };

    double height = 0.0;
    org.cesiumjs.cs.core.HeadingPitchRoll hpr = new org.cesiumjs.cs.core.HeadingPitchRoll(0.0, 0.0, 0.0);
    Cartesian3 origin = Cartesian3.fromDegrees(-123.0744619, 44.0503706, height);
    Matrix4 modelMatrix = Transforms.headingPitchRollToFixedFrame(origin, hpr);

    FromGltfOptions fromGltfOptions = new FromGltfOptions();
    fromGltfOptions.url = modelURL;
    fromGltfOptions.modelMatrix = modelMatrix;
    fromGltfOptions.minimumPixelSize = 128.0;
    model = (Model) csVPanel.getViewer().scene().primitives().add(Model.fromGltf(fromGltfOptions));
    model.readyPromise().then(new Fulfill<Model>() {
        @Override
        public void onFulfilled(Model value) {
            Camera camera = viewer.camera;

            // Zoom to model
            ScreenSpaceCameraController controller = viewer.scene().screenSpaceCameraController();
            double r = 2.0 * Math.max(model.boundingSphere().radius, camera.frustum.near);
            controller.minimumZoomDistance = r * 0.5;

            Cartesian3 center = Matrix4.multiplyByPoint(model.modelMatrix, model.boundingSphere().center,
                    new Cartesian3());
            double heading = Math.toRadians(230.0);
            double pitch = Math.toRadians(-20.0);
            camera.lookAt(center, new org.cesiumjs.cs.core.HeadingPitchRange(heading, pitch, r * 2.0));
            camera.lookAtTransform(Matrix4.IDENTITY());

            model.sphericalHarmonicCoefficients = coefficients;
            model.specularEnvironmentMaps = environmentMapURL;
        }
    }, new Reject<Void>() {
        @Override
        public void onRejected(Void value) {
            Window.alert("Error");
        }
    });

    luminanceAtZenithSlider = new Slider("LuminanceAtZenith", 0, 200, 50);
    luminanceAtZenithSlider.setStep(1);
    luminanceAtZenithSlider.addListener(new SliderListener() {
        @Override
        public void onStart(SliderEvent e) {
            //
        }

        @Override
        public boolean onSlide(SliderEvent e) {
            Slider source = e.getSource();
            double value = source.getValue() / 100.0;
            model.luminanceAtZenith = value;
            luminanceAtZenithTBox.setValue(value + "");
            return true;
        }

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

        @Override
        public void onStop(SliderEvent e) {
            //
        }
    });
    luminanceAtZenithTBox = new TextBox();
    luminanceAtZenithTBox.setSize("30px", "12px");
    luminanceAtZenithTBox.setValue("" + 0.5);
    luminanceAtZenithTBox.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            TextBox source = (TextBox) event.getSource();
            float value = Float.parseFloat(source.getValue());
            luminanceAtZenithSlider.setValue((int) (value * 100));
            model.luminanceAtZenith = value;
        }
    });

    CheckBox useProceduralImageCBox = new CheckBox("Use procedural image");
    useProceduralImageCBox.getElement().getStyle().setColor("white");
    useProceduralImageCBox.setWidth("100px");
    useProceduralImageCBox.setValue(false);
    useProceduralImageCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            if (!event.getValue()) {
                model.sphericalHarmonicCoefficients = coefficients;
                model.specularEnvironmentMaps = environmentMapURL;
            } else {
                model.sphericalHarmonicCoefficients = (Cartesian3[]) JsObject.undefined();
                model.specularEnvironmentMaps = (String) JsObject.undefined();
            }
        }
    });

    FlexTable flexTable = new FlexTable();
    flexTable.setHTML(1, 0, "<font color=\"white\">Luminance at Zenith</font>");
    flexTable.setWidget(1, 1, luminanceAtZenithSlider);
    flexTable.setWidget(1, 2, luminanceAtZenithTBox);
    flexTable.setWidget(2, 1, useProceduralImageCBox);

    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(csVPanel);
    aPanel.add(flexTable, 20, 20);

    contentPanel.add(new HTML("<p>Use image-based lighting to light a model.</p>"));
    contentPanel.add(aPanel);

    initWidget(contentPanel);
}

From source file:org.cleanlogic.cesiumjs4gwt.showcase.examples.Models3DColoring.java

License:Apache License

@Override
public void buildPanel() {
    ViewerOptions csViewerOptions = new ViewerOptions();
    csViewerOptions.infoBox = false;//from   w w  w .  j av a2  s  . c o m
    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);
    modelGraphicsOptions.color = new ConstantProperty<>(getColor("red", alpha));
    modelGraphicsOptions.colorBlendMode = new ConstantProperty<>(ColorBlendMode.HIGHLIGHT());
    modelGraphicsOptions.colorBlendAmount = new ConstantProperty<>(colorBlendAmount);
    modelGraphicsOptions.silhouetteColor = new ConstantProperty<>(getColor("red", alpha));
    modelGraphicsOptions.silhouetteSize = new ConstantProperty<>(silhouetteSize);

    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;
    org.cesiumjs.cs.core.HeadingPitchRoll hpr = new org.cesiumjs.cs.core.HeadingPitchRoll(heading, pitch, roll);
    Quaternion orientation = Transforms.headingPitchRollQuaternion(position, hpr);
    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);

    ListBox modeLBox = new ListBox();
    modeLBox.addItem("Hightlight", "0");
    modeLBox.addItem("Replace", "1");
    modeLBox.addItem("Mix", "2");
    modeLBox.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            ListBox source = (ListBox) event.getSource();
            mixSlider.setVisible(false);
            mixTBox.setVisible(false);
            if (source.getSelectedValue().equalsIgnoreCase("0")) {
                colorBlendMode = ColorBlendMode.HIGHLIGHT();
            } else if (source.getSelectedValue().equalsIgnoreCase("1")) {
                colorBlendMode = ColorBlendMode.REPLACE();
            } else if (source.getSelectedValue().equalsIgnoreCase("2")) {
                colorBlendMode = ColorBlendMode.MIX();
                mixSlider.setVisible(true);
                mixTBox.setVisible(true);
            }

            csVPanel.getViewer().trackedEntity.model.colorBlendMode = new ConstantProperty<>(colorBlendMode);
        }
    });

    ListBox colorLBox = new ListBox();
    colorLBox.addItem("White", "White");
    colorLBox.addItem("Red", "Red");
    colorLBox.addItem("Green", "Green");
    colorLBox.addItem("Blue", "Blue");
    colorLBox.addItem("Yellow", "Yellow");
    colorLBox.addItem("Gray", "Gray");
    colorLBox.setSelectedIndex(1);
    colorLBox.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            ListBox source = (ListBox) event.getSource();
            colorStr = source.getSelectedValue();
            csVPanel.getViewer().trackedEntity.model.color = new ConstantProperty<>(
                    getColor(source.getSelectedValue(), alpha));
        }
    });

    alphaSlider = new Slider("Alpha", 0, 100, 100);
    alphaSlider.setWidth("100px");
    alphaSlider.setStep(1);
    alphaSlider.addListener(new MSliderListener());
    alphaTBox = new TextBox();
    alphaTBox.setSize("30px", "12px");
    alphaTBox.setValue("" + 1);
    alphaTBox.addChangeHandler(new MChangeHandler());

    mixSlider = new Slider("Mix", 0, 100, 50);
    mixSlider.setStep(1);
    mixSlider.setVisible(false);
    mixSlider.addListener(new MSliderListener());
    mixTBox = new TextBox();
    mixTBox.setSize("30px", "12px");
    mixTBox.setValue("0.5");
    mixTBox.setVisible(false);
    mixTBox.addChangeHandler(new MChangeHandler());

    ListBox silhouetteColorLBox = new ListBox();
    silhouetteColorLBox.addItem("Red", "Red");
    silhouetteColorLBox.addItem("Green", "Green");
    silhouetteColorLBox.addItem("Blue", "Blue");
    silhouetteColorLBox.addItem("Yellow", "Yellow");
    silhouetteColorLBox.addItem("Gray", "Gray");
    silhouetteColorLBox.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            ListBox source = (ListBox) event.getSource();
            silhouetteColorStr = source.getSelectedValue();
            silhouetteColor = getColor(source.getSelectedValue(), alpha);
            csVPanel.getViewer().trackedEntity.model.silhouetteColor = new ConstantProperty<>(
                    getColor(silhouetteColorStr, silhouetteAlpha));
        }
    });

    silhouetteAlphaSlider = new Slider("SilhouetteAlpha", 0, 100, 100);
    silhouetteAlphaSlider.setStep(1);
    silhouetteAlphaSlider.addListener(new MSliderListener());
    silhouetteAlphaTBox = new TextBox();
    silhouetteAlphaTBox.setSize("30px", "12px");
    silhouetteAlphaTBox.setValue("" + 1);
    silhouetteAlphaTBox.addChangeHandler(new MChangeHandler());

    silhouetteSizeSlider = new Slider("SizeAlpha", 0, 1000, 20);
    silhouetteSizeSlider.setStep(1);
    silhouetteSizeSlider.addListener(new MSliderListener());
    silhouetteSizeTBox = new TextBox();
    silhouetteSizeTBox.setSize("30px", "12px");
    silhouetteSizeTBox.setValue("" + 2);
    silhouetteSizeTBox.addChangeHandler(new MChangeHandler());

    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;
            }
        }
    });

    CheckBox shadowsCBox = new CheckBox("Shadows");
    shadowsCBox.getElement().getStyle().setColor("white");
    shadowsCBox.setWidth("100px");
    shadowsCBox.setValue(true);
    shadowsCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            csVPanel.getViewer().shadows = event.getValue();
        }
    });

    FlexTable flexTable = new FlexTable();
    flexTable.setHTML(1, 0, "<font color=\"white\">Model Color</font>");
    flexTable.setHTML(2, 0, "<font color=\"white\">Mode</font>");
    flexTable.setWidget(2, 1, modeLBox);
    flexTable.setHTML(3, 0, "<font color=\"white\">Color</font>");
    flexTable.setWidget(3, 1, colorLBox);
    flexTable.setHTML(4, 0, "<font color=\"white\">Alpha</font>");
    flexTable.setWidget(4, 1, alphaSlider);
    flexTable.setWidget(4, 2, alphaTBox);
    flexTable.setHTML(5, 0, "<font color=\"white\">Mix</font>");
    flexTable.setWidget(5, 1, mixSlider);
    flexTable.setWidget(5, 2, mixTBox);
    flexTable.setHTML(6, 0, "<font color=\"white\">Model Silhouette</font>");
    flexTable.setHTML(7, 0, "<font color=\"white\">Color</font>");
    flexTable.setWidget(7, 1, silhouetteColorLBox);
    flexTable.setHTML(8, 0, "<font color=\"white\">Alpha</font>");
    flexTable.setWidget(8, 1, silhouetteAlphaSlider);
    flexTable.setWidget(8, 2, silhouetteAlphaTBox);
    flexTable.setHTML(9, 0, "<font color=\"white\">Size</font>");
    flexTable.setWidget(9, 1, silhouetteSizeSlider);
    flexTable.setWidget(9, 2, silhouetteSizeTBox);

    flexTable.setWidget(10, 0, modelsLBox);
    flexTable.setWidget(10, 1, shadowsCBox);

    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(csVPanel);
    aPanel.add(flexTable, 20, 20);

    contentPanel.add(new HTML("<p>Create 3D coloring models.</p>"));
    contentPanel.add(aPanel);

    initWidget(contentPanel);
}

From source file:org.cleanlogic.cesiumjs4gwt.showcase.examples.Shadows.java

License:Apache License

@Override
public void buildPanel() {
    ViewerOptions viewerOptions = new ViewerOptions();
    viewerOptions.infoBox = false;/*from  w  w w.  j a v a 2  s . c  om*/
    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);
}

From source file:org.cleanlogic.cesiumjs4gwt.showcase.examples.SkyAtmosphere.java

License:Apache License

@Override
public void buildPanel() {
    _csVPanel = new ViewerPanel();
    Camera camera = _csVPanel.getViewer().camera;
    ViewOptions viewOptions = new ViewOptions();
    viewOptions.destinationPos = Cartesian3.fromDegrees(-75.5847, 40.0397, 1000.0);
    viewOptions.orientation = new HeadingPitchRoll(-Math.PI_OVER_TWO(), 0.2, 0.0);
    camera.setView(viewOptions);/* w ww.  j a  v a2 s.  c o  m*/

    HorizontalPanel hueShiftHPanel = new HorizontalPanel();
    hueShiftHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    hueShiftHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    hueShiftHPanel.setSpacing(10);
    _hueShiftSlider = new Slider("hueShift", -100, 100, 0);
    _hueShiftSlider.setStep(1);
    _hueShiftSlider.setWidth("150px");
    _hueShiftSlider.addListener(new MSliderListener());
    _hueShiftTBox = new TextBox();
    _hueShiftTBox.addChangeHandler(new MChangeHandler());
    _hueShiftTBox.setText("0");
    _hueShiftTBox.setSize("30px", "12px");
    hueShiftHPanel.add(_hueShiftSlider);
    hueShiftHPanel.add(_hueShiftTBox);

    HorizontalPanel saturationShiftHPanel = new HorizontalPanel();
    saturationShiftHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    saturationShiftHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    saturationShiftHPanel.setSpacing(10);
    _saturationShiftSlider = new Slider("saturationShift", -100, 100, 0);
    _saturationShiftSlider.setStep(1);
    _saturationShiftSlider.setWidth("150px");
    _saturationShiftSlider.addListener(new MSliderListener());
    _saturationShiftTBox = new TextBox();
    _saturationShiftTBox.addChangeHandler(new MChangeHandler());
    _saturationShiftTBox.setText("0");
    _saturationShiftTBox.setSize("30px", "12px");
    saturationShiftHPanel.add(_saturationShiftSlider);
    saturationShiftHPanel.add(_saturationShiftTBox);

    HorizontalPanel brightnessShiftHPanel = new HorizontalPanel();
    brightnessShiftHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    brightnessShiftHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    brightnessShiftHPanel.setSpacing(10);
    _brightnessShiftSlider = new Slider("brightnessShift", -100, 100, 0);
    _brightnessShiftSlider.setStep(1);
    _brightnessShiftSlider.setWidth("150px");
    _brightnessShiftSlider.addListener(new MSliderListener());
    _brightnessShiftTBox = new TextBox();
    _brightnessShiftTBox.addChangeHandler(new MChangeHandler());
    _brightnessShiftTBox.setText("0");
    _brightnessShiftTBox.setSize("30px", "12px");
    brightnessShiftHPanel.add(_brightnessShiftSlider);
    brightnessShiftHPanel.add(_brightnessShiftTBox);

    CheckBox lightingCBox = new CheckBox();
    lightingCBox.setWidth("100px");
    lightingCBox.setValue(true);
    lightingCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
            _csVPanel.getViewer()
                    .scene().globe.enableLighting = !_csVPanel.getViewer().scene().globe.enableLighting;
        }
    });

    CheckBox fogCBox = new CheckBox();
    fogCBox.setWidth("100px");
    fogCBox.setValue(true);
    fogCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
            _csVPanel.getViewer().scene().fog.enabled = !_csVPanel.getViewer().scene().fog.enabled;
        }
    });

    FlexTable flexTable = new FlexTable();
    flexTable.setHTML(1, 0, "<font color=\"white\">hueShift</font>");
    flexTable.setWidget(1, 1, hueShiftHPanel);
    flexTable.setHTML(2, 0, "<font color=\"white\">saturationShift</font>");
    flexTable.setWidget(2, 1, saturationShiftHPanel);
    flexTable.setHTML(3, 0, "<font color=\"white\">brightnessShift</font>");
    flexTable.setWidget(3, 1, brightnessShiftHPanel);
    flexTable.setHTML(4, 0, "<font color=\"white\">Toggle Lighting</font>");
    flexTable.setWidget(4, 1, lightingCBox);
    flexTable.setHTML(5, 0, "<font color=\"white\">Toggle Fog</font>");
    flexTable.setWidget(5, 1, fogCBox);

    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(_csVPanel);
    aPanel.add(flexTable, 20, 20);

    contentPanel.add(new HTML("<p>Adjust hue, saturation, and brightness of the sky/atmosphere.</p>"));
    contentPanel.add(aPanel);

    initWidget(contentPanel);
}

From source file:org.cleanlogic.cesiumjs4gwt.showcase.examples.TerrainClippingPlanes.java

License:Apache License

@Override
public void buildPanel() {
    ViewerOptions viewerOptions = new ViewerOptions();
    viewerOptions.skyAtmosphere = null;//from  www.ja v  a2s .co  m
    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);
}

From source file:org.daxplore.presenter.client.ui.PerspectiveCheckboxPanel.java

License:Open Source License

private PerspectiveCheckboxPanel(DaxploreConfig config, QuestionMetadata questions, UITexts uiTexts,
        String questionID, List<Integer> checked, boolean checkTotal) {

    Label header = new Label(uiTexts.pickSelectionAlternativesHeader());
    header.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    header.addStyleName("daxplore-PerspectiveCheckboxes-header");
    this.add(header);

    List<String> options = questions.getOptionTexts(questionID);

    FlexTable grid = new FlexTable();
    CellFormatter formatter = grid.getCellFormatter();

    for (int i = 0; i < options.size(); i++) {
        CheckBox chkbox = new CheckBox(options.get(i));
        chkbox.addValueChangeHandler(this);
        chkbox.setFormValue(String.valueOf(i));
        chkbox.setValue(checked.contains(i), false);
        if (!checkTotal && checked.size() == 0 && i < config.defaultSelectedPerspectiveOptions()) {
            chkbox.setValue(true, false);
        }//  ww  w  .  jav a 2  s.  c o m
        checkboxList.add(chkbox);
        if (options.size() <= 6) {
            formatter.setWordWrap(i % options.size(), i / options.size(), false);
            grid.setWidget(i % options.size(), i / options.size(), chkbox);
        } else {
            formatter.setWordWrap(i % 7, i / 7, false);
            grid.setWidget(i % 7, i / 7, chkbox);
        }
    }
    this.add(grid);

    total = new CheckBox(uiTexts.compareWithAll());
    total.addValueChangeHandler(this);
    total.setFormValue("all");
    total.setValue(checkTotal, false);
    this.add(total);

}

From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.RuleModellerActionSelectorPopup.java

License:Apache License

@Override
public Widget getContent() {
    if (position == null) {
        positionCbo.addItem(Constants.INSTANCE.Bottom(), String.valueOf(this.model.rhs.length));
        positionCbo.addItem(Constants.INSTANCE.Top(), "0");
        for (int i = 1; i < model.rhs.length; i++) {
            positionCbo.addItem(Constants.INSTANCE.Line0(i), String.valueOf(i));
        }// w w w.  java  2s . c  om
    } else {
        //if position is fixed, we just add one element to the drop down.
        positionCbo.addItem(String.valueOf(position));
        positionCbo.setSelectedIndex(0);
    }

    if (completions.getDSLConditions().length == 0 && completions.getFactTypes().length == 0) {
        layoutPanel.addRow(new HTML("<div class='highlight'>" + Constants.INSTANCE.NoModelTip() + "</div>"));
    }

    //only show the drop down if we are not using fixed position.
    if (position == null) {
        HorizontalPanel hp0 = new HorizontalPanel();
        hp0.add(new HTML(Constants.INSTANCE.PositionColon()));
        hp0.add(positionCbo);
        hp0.add(new InfoPopup(Constants.INSTANCE.PositionColon(),
                Constants.INSTANCE.ActionPositionExplanation()));
        layoutPanel.addRow(hp0);
    }

    choices = makeChoicesListBox();
    choicesPanel.add(choices);
    layoutPanel.addRow(choicesPanel);

    HorizontalPanel hp = new HorizontalPanel();
    Button ok = new Button(Constants.INSTANCE.OK());
    hp.add(ok);
    ok.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            selectSomething();
        }
    });

    Button cancel = new Button(Constants.INSTANCE.Cancel());
    hp.add(cancel);
    cancel.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            hide();
        }
    });

    CheckBox chkOnlyDisplayDSLConditions = new CheckBox();
    chkOnlyDisplayDSLConditions.setText(Constants.INSTANCE.OnlyDisplayDSLActions());
    chkOnlyDisplayDSLConditions.setValue(bOnlyShowDSLConditions);
    chkOnlyDisplayDSLConditions.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        public void onValueChange(ValueChangeEvent<Boolean> event) {
            bOnlyShowDSLConditions = event.getValue();
            choicesPanel.setWidget(makeChoicesListBox());
        }

    });

    layoutPanel.addRow(chkOnlyDisplayDSLConditions);

    layoutPanel.addRow(hp);

    this.setAfterShow(new Command() {

        public void execute() {
            choices.setFocus(true);
        }
    });

    return layoutPanel;
}