Search in sources :

Example 6 with Slider

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

the class ParticleSystem method createWidget.

public FlexTable createWidget() {
    MSliderListener sliderListener = new MSliderListener();
    MChangeHandler tboxListener = new MChangeHandler();
    rateSlider = new Slider("rate", 0, 100, (int) viewModel.rate);
    rateSlider.setStep(1);
    rateSlider.setWidth("150px");
    rateSlider.addListener(sliderListener);
    rateTBox = new TextBox();
    rateTBox.setValue("" + (int) viewModel.rate);
    rateTBox.setSize("30px", "12px");
    rateTBox.addChangeHandler(tboxListener);
    sizeSlider = new Slider("size", 2, 60, (int) viewModel.particleSize);
    sizeSlider.setStep(1);
    sizeSlider.setWidth("150px");
    sizeSlider.addListener(sliderListener);
    sizeTBox = new TextBox();
    sizeTBox.setValue("" + (int) viewModel.particleSize);
    sizeTBox.setSize("30px", "12px");
    sizeTBox.addChangeHandler(tboxListener);
    minLifeSlider = new Slider("minLife", 1, 30, (int) viewModel.minimumLife);
    minLifeSlider.setStep(1);
    minLifeSlider.setWidth("150px");
    minLifeSlider.addListener(sliderListener);
    minLifeTBox = new TextBox();
    minLifeTBox.setValue("" + (int) viewModel.minimumLife);
    minLifeTBox.setSize("30px", "12px");
    minLifeTBox.addChangeHandler(tboxListener);
    maxLifeSlider = new Slider("maxLife", 1, 30, (int) viewModel.maximumLife);
    maxLifeSlider.setStep(1);
    maxLifeSlider.setWidth("150px");
    maxLifeSlider.addListener(sliderListener);
    maxLifeTBox = new TextBox();
    maxLifeTBox.setValue("" + (int) viewModel.maximumLife);
    maxLifeTBox.setSize("30px", "12px");
    maxLifeTBox.addChangeHandler(tboxListener);
    minSpeedSlider = new Slider("minSpeed", 0, 30, (int) viewModel.minimumSpeed);
    minSpeedSlider.setStep(1);
    minSpeedSlider.setWidth("150px");
    minSpeedSlider.addListener(sliderListener);
    minSpeedTBox = new TextBox();
    minSpeedTBox.setValue("" + (int) viewModel.minimumSpeed);
    minSpeedTBox.setSize("30px", "12px");
    minSpeedTBox.addChangeHandler(tboxListener);
    maxSpeedSlider = new Slider("maxSpeed", 0, 30, (int) viewModel.maximumSpeed);
    maxSpeedSlider.setStep(1);
    maxSpeedSlider.setWidth("150px");
    maxSpeedSlider.addListener(sliderListener);
    maxSpeedTBox = new TextBox();
    maxSpeedTBox.setValue("" + (int) viewModel.maximumSpeed);
    maxSpeedTBox.setSize("30px", "12px");
    maxSpeedTBox.addChangeHandler(tboxListener);
    startScaleSlider = new Slider("startScale", 0, 10, (int) viewModel.startScale);
    startScaleSlider.setStep(1);
    startScaleSlider.setWidth("150px");
    startScaleSlider.addListener(sliderListener);
    startScaleTBox = new TextBox();
    startScaleTBox.setValue("" + (int) viewModel.startScale);
    startScaleTBox.setSize("30px", "12px");
    startScaleTBox.addChangeHandler(tboxListener);
    endScaleSlider = new Slider("endScale", 0, 10, (int) viewModel.endScale);
    endScaleSlider.setStep(1);
    endScaleSlider.setWidth("150px");
    endScaleSlider.addListener(sliderListener);
    endScaleTBox = new TextBox();
    endScaleTBox.setValue("" + (int) viewModel.endScale);
    endScaleTBox.setSize("30px", "12px");
    endScaleTBox.addChangeHandler(tboxListener);
    gravitySlider = new Slider("gravity", -20, 20, (int) viewModel.gravity);
    gravitySlider.setStep(1);
    gravitySlider.setWidth("150px");
    gravitySlider.addListener(sliderListener);
    gravityTBox = new TextBox();
    gravityTBox.setValue("" + (int) viewModel.gravity);
    gravityTBox.setSize("30px", "12px");
    gravityTBox.addChangeHandler(tboxListener);
    translationXTBox = new TextBox();
    translationXTBox.setSize("30px", "12px");
    translationXTBox.setValue(viewModel.transX + "");
    translationXTBox.addChangeHandler(tboxListener);
    translationYTBox = new TextBox();
    translationYTBox.setSize("30px", "12px");
    translationYTBox.setValue(viewModel.transY + "");
    translationYTBox.addChangeHandler(tboxListener);
    translationZTBox = new TextBox();
    translationZTBox.setSize("30px", "12px");
    translationZTBox.setValue(viewModel.transZ + "");
    translationZTBox.addChangeHandler(tboxListener);
    rotationHTBox = new TextBox();
    rotationHTBox.setSize("30px", "12px");
    rotationHTBox.setValue(viewModel.heading + "");
    rotationHTBox.addChangeHandler(tboxListener);
    rotationPTBox = new TextBox();
    rotationPTBox.setSize("30px", "12px");
    rotationPTBox.setValue(viewModel.pitch + "");
    rotationPTBox.addChangeHandler(tboxListener);
    rotationRTBox = new TextBox();
    rotationRTBox.setSize("30px", "12px");
    rotationRTBox.setValue(viewModel.roll + "");
    rotationRTBox.addChangeHandler(tboxListener);
    spinCBox = new CheckBox();
    spinCBox.setHTML("<font color=\"white\">Spin</font>");
    spinCBox.addValueChangeHandler(new MValueChangeHandler());
    flyCBox = new CheckBox();
    flyCBox.setHTML("<font color=\"white\">Fly</font>");
    flyCBox.addValueChangeHandler(new MValueChangeHandler());
    showCBox = new CheckBox();
    showCBox.setHTML("<font color=\"white\">Show</font>");
    showCBox.setValue(true);
    showCBox.addValueChangeHandler(new MValueChangeHandler());
    ListBox emitterLBox = new ListBox();
    emitterLBox.addItem("Circle", "Circle");
    emitterLBox.addItem("Cone", "Cone");
    emitterLBox.addItem("Box", "Box");
    emitterLBox.addItem("Sphere", "Sphere");
    emitterLBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent changeEvent) {
            ListBox source = (ListBox) changeEvent.getSource();
            switch(source.getSelectedValue()) {
                case "Circle":
                    particleSystem.emitter = new CircleEmitter(0.5);
                    break;
                case "Cone":
                    particleSystem.emitter = new ConeEmitter(Math.toRadians(45.0));
                    break;
                case "Box":
                    particleSystem.emitter = new BoxEmitter(new Cartesian3(10.0, 10.0, 10.0));
                    break;
                case "Sphere":
                    particleSystem.emitter = new SphereEmitter(5.0);
                    break;
                default:
                    break;
            }
        }
    });
    FlexTable flexTable = new FlexTable();
    flexTable.getElement().getStyle().setBackgroundColor("rgba(0, 0, 0, 0.5)");
    flexTable.setCellSpacing(2);
    flexTable.setCellPadding(2);
    flexTable.setHTML(0, 0, "<font color=\"white\">Rate</font>");
    flexTable.setWidget(0, 1, rateSlider);
    flexTable.setWidget(0, 2, rateTBox);
    flexTable.setHTML(1, 0, "<font color=\"white\">Size</font>");
    flexTable.setWidget(1, 1, sizeSlider);
    flexTable.setWidget(1, 2, sizeTBox);
    flexTable.setHTML(2, 0, "<font color=\"white\">Min Life</font>");
    flexTable.setWidget(2, 1, minLifeSlider);
    flexTable.setWidget(2, 2, minLifeTBox);
    flexTable.setHTML(3, 0, "<font color=\"white\">Max Life</font>");
    flexTable.setWidget(3, 1, maxLifeSlider);
    flexTable.setWidget(3, 2, maxLifeTBox);
    flexTable.setHTML(4, 0, "<font color=\"white\">Min Speed</font>");
    flexTable.setWidget(4, 1, minSpeedSlider);
    flexTable.setWidget(4, 2, minSpeedTBox);
    flexTable.setHTML(5, 0, "<font color=\"white\">Max Speed</font>");
    flexTable.setWidget(5, 1, maxSpeedSlider);
    flexTable.setWidget(5, 2, maxSpeedTBox);
    flexTable.setHTML(6, 0, "<font color=\"white\">Start Scale</font>");
    flexTable.setWidget(6, 1, startScaleSlider);
    flexTable.setWidget(6, 2, startScaleTBox);
    flexTable.setHTML(7, 0, "<font color=\"white\">End Scale</font>");
    flexTable.setWidget(7, 1, endScaleSlider);
    flexTable.setWidget(7, 2, endScaleTBox);
    flexTable.setHTML(8, 0, "<font color=\"white\">Gravity</font>");
    flexTable.setWidget(8, 1, gravitySlider);
    flexTable.setWidget(8, 2, gravityTBox);
    FlexTable transactionFTable = new FlexTable();
    transactionFTable.setHTML(0, 0, "<font color=\"white\">X</font>");
    transactionFTable.setWidget(0, 1, translationXTBox);
    transactionFTable.setHTML(0, 2, "<font color=\"white\">Y</font>");
    transactionFTable.setWidget(0, 3, translationYTBox);
    transactionFTable.setHTML(0, 4, "<font color=\"white\">Z</font>");
    transactionFTable.setWidget(0, 5, translationZTBox);
    flexTable.setHTML(9, 0, "<font color=\"white\">Translation</font>");
    flexTable.setWidget(9, 1, transactionFTable);
    FlexTable rotationFTable = new FlexTable();
    rotationFTable.setHTML(0, 0, "<font color=\"white\">H</font>");
    rotationFTable.setWidget(0, 1, rotationHTBox);
    rotationFTable.setHTML(0, 2, "<font color=\"white\">P</font>");
    rotationFTable.setWidget(0, 3, rotationPTBox);
    rotationFTable.setHTML(0, 4, "<font color=\"white\">R</font>");
    rotationFTable.setWidget(0, 5, rotationRTBox);
    flexTable.setHTML(10, 0, "<font color=\"white\">Rotation</font>");
    flexTable.setWidget(10, 1, rotationFTable);
    FlexTable btnFTable = new FlexTable();
    btnFTable.setWidget(0, 0, spinCBox);
    btnFTable.setWidget(0, 1, flyCBox);
    btnFTable.setWidget(0, 2, showCBox);
    btnFTable.setWidget(0, 3, emitterLBox);
    flexTable.setWidget(11, 1, btnFTable);
    return flexTable;
}
Also used : Slider(org.cleanlogic.showcase.client.examples.slider.Slider) SphereEmitter(org.cesiumjs.cs.scene.emitters.SphereEmitter) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ConeEmitter(org.cesiumjs.cs.scene.emitters.ConeEmitter) BoxEmitter(org.cesiumjs.cs.scene.emitters.BoxEmitter) CircleEmitter(org.cesiumjs.cs.scene.emitters.CircleEmitter)

Example 7 with Slider

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

the class AtmosphereColor method buildPanel.

@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);
    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);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) Slider(org.cleanlogic.showcase.client.examples.slider.Slider) HeadingPitchRoll(org.cesiumjs.cs.core.HeadingPitchRoll) ViewOptions(org.cesiumjs.cs.scene.options.ViewOptions) Camera(org.cesiumjs.cs.scene.Camera)

Aggregations

Slider (org.cleanlogic.showcase.client.examples.slider.Slider)7 ViewerPanel (org.cesiumjs.cs.widgets.ViewerPanel)6 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)3 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)3 ViewerOptions (org.cesiumjs.cs.widgets.options.ViewerOptions)3 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)2 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)2 ImageryLayer (org.cesiumjs.cs.scene.ImageryLayer)2 Callback (com.google.gwt.core.client.Callback)1 AbsolutePanel (com.google.gwt.user.client.ui.AbsolutePanel)1 HTML (com.google.gwt.user.client.ui.HTML)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ImageryLayerCollection (org.cesiumjs.cs.collections.ImageryLayerCollection)1 org.cesiumjs.cs.core (org.cesiumjs.cs.core)1 HeadingPitchRoll (org.cesiumjs.cs.core.HeadingPitchRoll)1 PinBuilder (org.cesiumjs.cs.core.PinBuilder)1 KmlDataSource (org.cesiumjs.cs.datasources.KmlDataSource)1 ModelGraphics (org.cesiumjs.cs.datasources.graphics.ModelGraphics)1 ModelGraphicsOptions (org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions)1