diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CloudParameters.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CloudParameters.java index ff2ef5e4521f10cd1dd3de4145214ed7918d268f..55d1c1bc922f971da56d5f57f70f454bd66bb494 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CloudParameters.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CloudParameters.java @@ -1,3 +1,19 @@ +/* + * Copyright 2021 iserge. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.cleanlogic.cesiumjs4gwt.showcase.examples; import com.google.gwt.core.client.GWT; @@ -40,6 +56,8 @@ public class CloudParameters extends AbstractExample { CumulusCloud cloud = null; CheckBox maxScaleCBox; + HorizontalPanel scaleXHPanel; + HorizontalPanel scaleYHPanel; Slider scaleXSlider; TextBox scaleXTBox; Slider scaleYSlider; @@ -56,6 +74,8 @@ public class CloudParameters extends AbstractExample { Slider brightnessSlider; TextBox brightnessTBox; + FlexTable flexTable; + @Inject public CloudParameters(ShowcaseExampleStore store) { super("Cloud Parameters", @@ -100,8 +120,15 @@ public class CloudParameters extends AbstractExample { maxScaleCBox = new CheckBox(); maxScaleCBox.setWidth("100px"); maxScaleCBox.setValue(true); + maxScaleCBox.addValueChangeHandler(value -> { + if (value.getValue()) { + cloudParameters.scaleX = cloudParameters.maximumSizeX; + cloudParameters.scaleY = cloudParameters.maximumSizeY; + } + visibleScaleXY(!value.getValue()); + }); - HorizontalPanel scaleXHPanel = new HorizontalPanel(); + scaleXHPanel = new HorizontalPanel(); scaleXHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); scaleXHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); scaleXHPanel.setSpacing(10); @@ -116,7 +143,7 @@ public class CloudParameters extends AbstractExample { scaleXHPanel.add(scaleXSlider); scaleXHPanel.add(scaleXTBox); - HorizontalPanel scaleYHPanel = new HorizontalPanel(); + scaleYHPanel = new HorizontalPanel(); scaleYHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); scaleYHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); scaleYHPanel.setSpacing(10); @@ -179,6 +206,10 @@ public class CloudParameters extends AbstractExample { renderSliceCBox = new CheckBox(); renderSliceCBox.setWidth("100px"); renderSliceCBox.setValue(true); + renderSliceCBox.addValueChangeHandler(value -> { + flexTable.getWidget(8, 0).setVisible(value.getValue()); + flexTable.getWidget(8, 1).setVisible(value.getValue()); + }); HorizontalPanel sliceHPanel = new HorizontalPanel(); sliceHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); @@ -210,12 +241,12 @@ public class CloudParameters extends AbstractExample { brightnessHPanel.add(brightnessSlider); brightnessHPanel.add(brightnessTBox); - FlexTable flexTable = new FlexTable(); + flexTable = new FlexTable(); flexTable.setHTML(1, 0, "Scale with Max Size"); flexTable.setWidget(1, 1, maxScaleCBox); - flexTable.setHTML(2, 0, "Scale X"); + flexTable.setWidget(2, 0, new HTML("Scale X")); flexTable.setWidget(2, 1, scaleXHPanel); - flexTable.setHTML(3, 0, "Scale Y"); + flexTable.setWidget(3, 0, new HTML("Scale Y")); flexTable.setWidget(3, 1, scaleYHPanel); flexTable.setHTML(4, 0, "Maximum Size X"); flexTable.setWidget(4, 1, maxSizeXHPanel); @@ -225,11 +256,13 @@ public class CloudParameters extends AbstractExample { flexTable.setWidget(6, 1, maxSizeZHPanel); flexTable.setHTML(7, 0, "Render Slice"); flexTable.setWidget(7, 1, renderSliceCBox); - flexTable.setHTML(8, 0, "Slice"); + flexTable.setWidget(8, 0, new HTML("Slice")); flexTable.setWidget(8, 1, sliceHPanel); flexTable.setHTML(9, 0, "Brightness"); flexTable.setWidget(9, 1, brightnessHPanel); + visibleScaleXY(false); + AbsolutePanel aPanel = new AbsolutePanel(); aPanel.add(csVPanel); aPanel.add(flexTable, 20, 20); @@ -241,6 +274,13 @@ public class CloudParameters extends AbstractExample { initWidget(contentPanel); } + private void visibleScaleXY(boolean visible) { + flexTable.getWidget(2, 0).setVisible(visible); + flexTable.getWidget(2, 1).setVisible(visible); + flexTable.getWidget(3, 0).setVisible(visible); + flexTable.getWidget(3, 1).setVisible(visible); + } + private class MSliderListener implements SliderListener { @Override diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Clouds.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Clouds.java index 17df595e5bed48191f1334bb0037e0b42720adbc..abd735bf1b27c9324ccc7cdfb796abbf36e2d97d 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Clouds.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Clouds.java @@ -21,9 +21,9 @@ import com.google.gwt.user.client.ui.HTML; import org.cesiumjs.cs.Cesium; import org.cesiumjs.cs.collections.CloudCollection; import org.cesiumjs.cs.collections.options.CumulusCloudAddOptions; -import org.cesiumjs.cs.core.*; import org.cesiumjs.cs.core.HeadingPitchRoll; import org.cesiumjs.cs.core.Math; +import org.cesiumjs.cs.core.*; import org.cesiumjs.cs.core.enums.ClockRange; import org.cesiumjs.cs.core.interpolation.HermitePolynomialApproximation; import org.cesiumjs.cs.datasources.Entity; diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ElevationBandMaterial.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ElevationBandMaterial.java index 86824481b4fe77e87c7adf26d2cfa57815a2b71f..611487412dab6fd54ddef939d14440aa6e34634d 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ElevationBandMaterial.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ElevationBandMaterial.java @@ -21,9 +21,9 @@ import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.FlexTable; import com.google.gwt.user.client.ui.HTML; import org.cesiumjs.cs.Cesium; -import org.cesiumjs.cs.core.*; import org.cesiumjs.cs.core.HeadingPitchRoll; import org.cesiumjs.cs.core.Math; +import org.cesiumjs.cs.core.*; import org.cesiumjs.cs.scene.options.ViewOptions; import org.cesiumjs.cs.widgets.ViewerPanel; import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample; diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GeoJSONAndTopoJSON.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GeoJSONAndTopoJSON.java index c3eb03d09c8dbf8825e42f141cb4b7e6e4cfb1fc..5c591930c9ca3eb9ee97bcf550ddacc74e736bf2 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GeoJSONAndTopoJSON.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GeoJSONAndTopoJSON.java @@ -22,8 +22,10 @@ import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.*; import org.cesiumjs.cs.Cesium; -import org.cesiumjs.cs.core.*; +import org.cesiumjs.cs.core.Cartesian3; +import org.cesiumjs.cs.core.Color; import org.cesiumjs.cs.core.Math; +import org.cesiumjs.cs.core.Matrix4; import org.cesiumjs.cs.core.options.ColorRandomOptions; import org.cesiumjs.cs.datasources.Entity; import org.cesiumjs.cs.datasources.GeoJsonDataSource; @@ -31,9 +33,6 @@ import org.cesiumjs.cs.datasources.options.GeoJsonDataSourceOptions; import org.cesiumjs.cs.datasources.properties.ColorMaterialProperty; import org.cesiumjs.cs.datasources.properties.ConstantProperty; import org.cesiumjs.cs.js.JsObject; -import org.cesiumjs.cs.promise.Fulfill; -import org.cesiumjs.cs.promise.Promise; -import org.cesiumjs.cs.promise.Reject; import org.cesiumjs.cs.widgets.ViewerPanel; import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample; import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore; diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryLayersSplit.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryLayersSplit.java index 4742a2127a690f5d3a7c615d58d6e000ac694c49..61e481809d35f72e80c94c2a3b4c149b8ce88590 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryLayersSplit.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryLayersSplit.java @@ -16,12 +16,9 @@ package org.cleanlogic.cesiumjs4gwt.showcase.examples; -import javax.inject.Inject; - import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.ui.AbsolutePanel; import com.google.gwt.user.client.ui.HTML; - import org.cesiumjs.cs.collections.ImageryLayerCollection; import org.cesiumjs.cs.core.Credit; import org.cesiumjs.cs.scene.ImageryLayer; @@ -37,6 +34,8 @@ import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider; import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent; import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener; +import javax.inject.Inject; + /** * @author Serge Silaev aka iSergio */ diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/PerFeaturePostProcessing.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/PerFeaturePostProcessing.java index f5cabe38e433b9f07b1571dfcb4f174942416474..f633cc95f297d058e9a560a3a60005f8e99dba7f 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/PerFeaturePostProcessing.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/PerFeaturePostProcessing.java @@ -16,15 +16,12 @@ package org.cleanlogic.cesiumjs4gwt.showcase.examples; -import javax.inject.Inject; - import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.user.client.ui.AbsolutePanel; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.ListBox; - import org.cesiumjs.cs.Cesium; import org.cesiumjs.cs.core.Cartesian3; import org.cesiumjs.cs.core.Color; @@ -38,17 +35,14 @@ import org.cesiumjs.cs.datasources.options.EntityOptions; import org.cesiumjs.cs.datasources.properties.ConstantPositionProperty; import org.cesiumjs.cs.datasources.properties.ConstantProperty; import org.cesiumjs.cs.js.JsObject; -import org.cesiumjs.cs.scene.PostProcess; -import org.cesiumjs.cs.scene.PostProcessStage; -import org.cesiumjs.cs.scene.PostProcessStageCollection; -import org.cesiumjs.cs.scene.PostProcessStageComposite; -import org.cesiumjs.cs.scene.PostProcessStageLibrary; -import org.cesiumjs.cs.scene.Primitive; +import org.cesiumjs.cs.scene.*; import org.cesiumjs.cs.widgets.ViewerPanel; import org.cesiumjs.cs.widgets.options.ViewerOptions; import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample; import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore; +import javax.inject.Inject; + /** * @author Serge Silaev aka iSergio */ diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/SampleHeightFrom3DTiles.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/SampleHeightFrom3DTiles.java index 722e15a80e319a5f1b7682517e5a215ff46a908b..40567e75336979f30378f2db3752ab963215e712 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/SampleHeightFrom3DTiles.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/SampleHeightFrom3DTiles.java @@ -16,15 +16,12 @@ package org.cleanlogic.cesiumjs4gwt.showcase.examples; -import javax.inject.Inject; - import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.ui.AbsolutePanel; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.PushButton; - import org.cesiumjs.cs.Cesium; import org.cesiumjs.cs.core.Cartesian3; import org.cesiumjs.cs.core.Color; @@ -51,6 +48,8 @@ import org.cesiumjs.cs.widgets.options.ViewerOptions; import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample; import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore; +import javax.inject.Inject; + /** * @author Serge Silaev aka iSergio */ diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DInspector.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DInspector.java index 30c4fb50b948bef66ba49e495a27ae19b73f01a8..ebf02451b8788c1cb734a4604387bbd73603c385 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DInspector.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DInspector.java @@ -16,11 +16,8 @@ package org.cleanlogic.cesiumjs4gwt.showcase.examples; -import javax.inject.Inject; - import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.ui.HTML; - import org.cesiumjs.cs.core.BoundingSphere; import org.cesiumjs.cs.core.Matrix4; import org.cesiumjs.cs.promise.Fulfill; @@ -30,6 +27,8 @@ import org.cesiumjs.cs.widgets.viewerCesium3DTilesInspectorMixin; import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample; import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore; +import javax.inject.Inject; + /** * @author Serge Silaev aka iSergio */ diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CloudParameters.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CloudParameters.txt new file mode 100644 index 0000000000000000000000000000000000000000..4aecb701b810deeb3f7cff9d888d4a0fff574ccf --- /dev/null +++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CloudParameters.txt @@ -0,0 +1,329 @@ +package org.cleanlogic.cesiumjs4gwt.showcase.examples; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.ChangeHandler; +import com.google.gwt.user.client.ui.*; +import org.cesiumjs.cs.Cesium; +import org.cesiumjs.cs.collections.CloudCollection; +import org.cesiumjs.cs.collections.options.CloudCollectionOptions; +import org.cesiumjs.cs.collections.options.CumulusCloudAddOptions; +import org.cesiumjs.cs.core.Cartesian2; +import org.cesiumjs.cs.core.Cartesian3; +import org.cesiumjs.cs.js.JsObject; +import org.cesiumjs.cs.scene.CumulusCloud; +import org.cesiumjs.cs.scene.Scene; +import org.cesiumjs.cs.widgets.Viewer; +import org.cesiumjs.cs.widgets.ViewerPanel; +import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample; +import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore; +import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider; +import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent; +import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener; + +import javax.inject.Inject; + +public class CloudParameters extends AbstractExample { + static final class ICloudParameters { + boolean scaleWithMaximumSize = true; + double scaleX = 25; + double scaleY = 12; + double maximumSizeX = 25; + double maximumSizeY = 12; + double maximumSizeZ = 15; + boolean renderSlice = true; // if false, renders the entire surface of the ellipsoid + double slice = 0.36; + double brightness = 1.0; + } + + ICloudParameters cloudParameters = new ICloudParameters(); + + CumulusCloud cloud = null; + + CheckBox maxScaleCBox; + HorizontalPanel scaleXHPanel; + HorizontalPanel scaleYHPanel; + Slider scaleXSlider; + TextBox scaleXTBox; + Slider scaleYSlider; + TextBox scaleYTBox; + Slider maxSizeXSlider; + TextBox maxSizeXTBox; + Slider maxSizeYSlider; + TextBox maxSizeYTBox; + Slider maxSizeZSlider; + TextBox maxSizeZTBox; + CheckBox renderSliceCBox; + Slider sliceSlider; + TextBox sliceTBox; + Slider brightnessSlider; + TextBox brightnessTBox; + + FlexTable flexTable; + + @Inject + public CloudParameters(ShowcaseExampleStore store) { + super("Cloud Parameters", + "Modify the appearance of a procedural cumulus cloud", + new String[]{"Showcase", "Cesium", "3d", "Clouds", "Params"}, store); + } + + @Override + public void buildPanel() { + ViewerPanel csVPanel = new ViewerPanel(); + + Viewer viewer = csVPanel.getViewer(); + Scene scene = viewer.scene(); + Cartesian3 position = Cartesian3.fromDegrees(-123.0744619, 44.0503706, 50); + + // These noise parameters are set to default, but can be changed + // to produce different cloud results. However, the noise is precomputed, + // so this cannot be changed dynamically. + CloudCollectionOptions cloudCollectionOptions = new CloudCollectionOptions(); + cloudCollectionOptions.noiseDetail = 16.0; + cloudCollectionOptions.noiseOffset = Cartesian3.ZERO(); + CloudCollection clouds = (CloudCollection) scene.primitives().add(new CloudCollection(cloudCollectionOptions)); + // Fix texture size + // TODO: remove this fix after Cesium fixed them in core + ((JsObject) (Object) clouds).setProperty("_noiseTextureLength", 64.0); + Cesium.log(((JsObject) (Object) clouds).getNumber("_noiseTextureLength")); + + CumulusCloudAddOptions options = new CumulusCloudAddOptions(); + options.position = position; + options.scale = new Cartesian2(cloudParameters.scaleX, cloudParameters.scaleY); + options.maximumSize = new Cartesian3(cloudParameters.maximumSizeX, cloudParameters.maximumSizeY, cloudParameters.maximumSizeZ); + options.slice = cloudParameters.renderSlice ? cloudParameters.slice : -1.0; + options.brightness = cloudParameters.brightness; + cloud = clouds.add(options); + + viewer.camera.lookAt(position, new Cartesian3(30, 30, -10)); + + ChangeHandler handler = (event) -> { + + }; + + maxScaleCBox = new CheckBox(); + maxScaleCBox.setWidth("100px"); + maxScaleCBox.setValue(true); + maxScaleCBox.addValueChangeHandler(value -> { + if (value.getValue()) { + cloudParameters.scaleX = cloudParameters.maximumSizeX; + cloudParameters.scaleY = cloudParameters.maximumSizeY; + } + visibleScaleXY(!value.getValue()); + }); + + scaleXHPanel = new HorizontalPanel(); + scaleXHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); + scaleXHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); + scaleXHPanel.setSpacing(10); + scaleXSlider = new Slider("scaleX", 5, 50, (int) cloudParameters.scaleX); + scaleXSlider.setStep(1); + scaleXSlider.setWidth("150px"); + scaleXSlider.addListener(new MSliderListener()); + scaleXTBox = new TextBox(); + scaleXTBox.addChangeHandler(handler); + scaleXTBox.setText(cloudParameters.scaleX + ""); + scaleXTBox.setSize("30px", "12px"); + scaleXHPanel.add(scaleXSlider); + scaleXHPanel.add(scaleXTBox); + + scaleYHPanel = new HorizontalPanel(); + scaleYHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); + scaleYHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); + scaleYHPanel.setSpacing(10); + scaleYSlider = new Slider("scaleY", 5, 50, (int) cloudParameters.scaleY); + scaleYSlider.setStep(1); + scaleYSlider.setWidth("150px"); + scaleYSlider.addListener(new MSliderListener()); + scaleYTBox = new TextBox(); + scaleXTBox.addChangeHandler(handler); + scaleYTBox.setText(cloudParameters.scaleY + ""); + scaleYTBox.setSize("30px", "12px"); + scaleYHPanel.add(scaleYSlider); + scaleYHPanel.add(scaleYTBox); + + HorizontalPanel maxSizeXHPanel = new HorizontalPanel(); + maxSizeXHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); + maxSizeXHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); + maxSizeXHPanel.setSpacing(10); + maxSizeXSlider = new Slider("maxSizeX", 5, 50, (int) cloudParameters.maximumSizeX); + maxSizeXSlider.setStep(1); + maxSizeXSlider.setWidth("150px"); + maxSizeXSlider.addListener(new MSliderListener()); + maxSizeXTBox = new TextBox(); + maxSizeXTBox.addChangeHandler(handler); + maxSizeXTBox.setText(cloudParameters.maximumSizeX + ""); + maxSizeXTBox.setSize("30px", "12px"); + maxSizeXHPanel.add(maxSizeXSlider); + maxSizeXHPanel.add(maxSizeXTBox); + + HorizontalPanel maxSizeYHPanel = new HorizontalPanel(); + maxSizeYHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); + maxSizeYHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); + maxSizeYHPanel.setSpacing(10); + maxSizeYSlider = new Slider("maxSizeY", 5, 50, (int) cloudParameters.maximumSizeY); + maxSizeYSlider.setStep(1); + maxSizeYSlider.setWidth("150px"); + maxSizeYSlider.addListener(new MSliderListener()); + maxSizeYTBox = new TextBox(); + maxSizeYTBox.addChangeHandler(handler); + maxSizeYTBox.setText(cloudParameters.maximumSizeY + ""); + maxSizeYTBox.setSize("30px", "12px"); + maxSizeYHPanel.add(maxSizeYSlider); + maxSizeYHPanel.add(maxSizeYTBox); + + HorizontalPanel maxSizeZHPanel = new HorizontalPanel(); + maxSizeZHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); + maxSizeZHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); + maxSizeZHPanel.setSpacing(10); + maxSizeZSlider = new Slider("maxSizeZ", 5, 50, (int) cloudParameters.maximumSizeZ); + maxSizeZSlider.setStep(1); + maxSizeZSlider.setWidth("150px"); + maxSizeZSlider.addListener(new MSliderListener()); + maxSizeZTBox = new TextBox(); + maxSizeZTBox.addChangeHandler(handler); + maxSizeZTBox.setText(cloudParameters.maximumSizeZ + ""); + maxSizeZTBox.setSize("30px", "12px"); + maxSizeZHPanel.add(maxSizeZSlider); + maxSizeZHPanel.add(maxSizeZTBox); + + renderSliceCBox = new CheckBox(); + renderSliceCBox.setWidth("100px"); + renderSliceCBox.setValue(true); + renderSliceCBox.addValueChangeHandler(value -> { + flexTable.getWidget(8, 0).setVisible(value.getValue()); + flexTable.getWidget(8, 1).setVisible(value.getValue()); + }); + + HorizontalPanel sliceHPanel = new HorizontalPanel(); + sliceHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); + sliceHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); + sliceHPanel.setSpacing(10); + sliceSlider = new Slider("slice", 0, 100, (int) (cloudParameters.slice * 100)); + sliceSlider.setStep(1); + sliceSlider.setWidth("150px"); + sliceSlider.addListener(new MSliderListener()); + sliceTBox = new TextBox(); + sliceTBox.addChangeHandler(handler); + sliceTBox.setText(cloudParameters.slice + ""); + sliceTBox.setSize("30px", "12px"); + sliceHPanel.add(sliceSlider); + sliceHPanel.add(sliceTBox); + + HorizontalPanel brightnessHPanel = new HorizontalPanel(); + brightnessHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); + brightnessHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); + brightnessHPanel.setSpacing(10); + brightnessSlider = new Slider("brightness", 0, 100, (int) (cloudParameters.brightness * 100)); + brightnessSlider.setStep(1); + brightnessSlider.setWidth("150px"); + brightnessSlider.addListener(new MSliderListener()); + brightnessTBox = new TextBox(); + brightnessTBox.addChangeHandler(handler); + brightnessTBox.setText(cloudParameters.brightness + ""); + brightnessTBox.setSize("30px", "12px"); + brightnessHPanel.add(brightnessSlider); + brightnessHPanel.add(brightnessTBox); + + flexTable = new FlexTable(); + flexTable.setHTML(1, 0, "Scale with Max Size"); + flexTable.setWidget(1, 1, maxScaleCBox); + flexTable.setWidget(2, 0, new HTML("Scale X")); + flexTable.setWidget(2, 1, scaleXHPanel); + flexTable.setWidget(3, 0, new HTML("Scale Y")); + flexTable.setWidget(3, 1, scaleYHPanel); + flexTable.setHTML(4, 0, "Maximum Size X"); + flexTable.setWidget(4, 1, maxSizeXHPanel); + flexTable.setHTML(5, 0, "Maximum Size Y"); + flexTable.setWidget(5, 1, maxSizeYHPanel); + flexTable.setHTML(6, 0, "Maximum Size Z"); + flexTable.setWidget(6, 1, maxSizeZHPanel); + flexTable.setHTML(7, 0, "Render Slice"); + flexTable.setWidget(7, 1, renderSliceCBox); + flexTable.setWidget(8, 0, new HTML("Slice")); + flexTable.setWidget(8, 1, sliceHPanel); + flexTable.setHTML(9, 0, "Brightness"); + flexTable.setWidget(9, 1, brightnessHPanel); + + visibleScaleXY(false); + + AbsolutePanel aPanel = new AbsolutePanel(); + aPanel.add(csVPanel); + aPanel.add(flexTable, 20, 20); + + contentPanel.add(new HTML( + "

Modify the appearance of a procedural cumulus cloud.

")); + contentPanel.add(aPanel); + + initWidget(contentPanel); + } + + private void visibleScaleXY(boolean visible) { + flexTable.getWidget(2, 0).setVisible(visible); + flexTable.getWidget(2, 1).setVisible(visible); + flexTable.getWidget(3, 0).setVisible(visible); + flexTable.getWidget(3, 1).setVisible(visible); + } + + private class MSliderListener implements SliderListener { + + @Override + public void onStart(SliderEvent e) { + // + } + + @Override + public boolean onSlide(SliderEvent e) { + Slider source = e.getSource(); + double value = source.getValue(); + if (source.equals(scaleXSlider)) { + scaleXTBox.setText(String.valueOf(value)); + cloud.scale = new Cartesian2(value, cloud.scale.y); + } else if (source.equals(scaleYSlider)) { + scaleYTBox.setText(String.valueOf(value)); + cloud.scale = new Cartesian2(cloud.scale.x, value); + } else if (source.equals(maxSizeXSlider)) { + maxSizeXTBox.setText(String.valueOf(value)); + cloud.maximumSize = new Cartesian3(value, cloud.maximumSize.y, cloud.maximumSize.z); + if (cloudParameters.scaleWithMaximumSize) { + cloud.scale = new Cartesian2(value, cloud.scale.y); + } + } else if (source.equals(maxSizeYSlider)) { + maxSizeYTBox.setText(String.valueOf(value)); + cloud.maximumSize = new Cartesian3(cloud.maximumSize.x, value, cloud.maximumSize.z); + if (cloudParameters.scaleWithMaximumSize) { + cloud.scale = new Cartesian2(cloud.scale.x, value); + } + } else if (source.equals(maxSizeZSlider)) { + maxSizeZTBox.setText(String.valueOf(value)); + cloud.maximumSize = new Cartesian3(cloud.maximumSize.x, cloud.maximumSize.y, value); + } else if (source.equals(sliceSlider)) { + value /= 100; + sliceTBox.setText(String.valueOf(value)); + cloud.slice = (float) value; + } else if (source.equals(brightnessSlider)) { + value /= 100; + brightnessTBox.setText(String.valueOf(value)); + cloud.brightness = (float) value; + } + return true; + } + + @Override + public void onChange(SliderEvent e) { + // + } + + @Override + public void onStop(SliderEvent e) { + // + } + } + + @Override + public String[] getSourceCodeURLs() { + String[] sourceCodeURLs = new String[1]; + sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "CloudParameters.txt"; + return sourceCodeURLs; + } +}