Commit 1d981a24 authored by iSergio's avatar iSergio
Browse files

Now slider always is double value!

parent c2e89b84
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 iSergio, Gis4Fun.
 *
 * 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.slider;

import com.google.gwt.core.client.GWT;
import com.google.gwt.text.shared.Parser;

public class PassthroughParser implements Parser<Double> {

    private static PassthroughParser INSTANCE;

    /**
     * Returns the instance of the no-op renderer.
     */
    public static Parser<Double> instance() {
        if (INSTANCE == null) {
            INSTANCE = new PassthroughParser();
        }
        return INSTANCE;
    }

    protected PassthroughParser() {
    }

    public Double parse(CharSequence object) {
        return Double.valueOf(object.toString());
    }
}
+43 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 iSergio, Gis4Fun.
 *
 * 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.slider;

import com.google.gwt.core.client.GWT;
import com.google.gwt.text.shared.AbstractRenderer;
import com.google.gwt.text.shared.Renderer;

public class PassthroughRenderer extends AbstractRenderer<Double> {

    private static PassthroughRenderer INSTANCE;

    /**
     * Returns the instance of the no-op renderer.
     */
    public static Renderer<Double> instance() {
        if (INSTANCE == null) {
            INSTANCE = new PassthroughRenderer();
        }
        return INSTANCE;
    }

    protected PassthroughRenderer() {
    }

    public String render(Double object) {
        return String.valueOf(object);
    }
}
+10 −11
Original line number Diff line number Diff line
@@ -21,8 +21,8 @@ import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.InputElement;
import com.google.gwt.event.shared.HandlerRegistration;

import java.util.UUID;
import com.google.gwt.i18n.client.NumberFormat;
import org.cesiumjs.cs.Cesium;

public class SliderBox extends SliderBoxBase {
    public SliderBox() {
@@ -31,21 +31,20 @@ public class SliderBox extends SliderBoxBase {

    public SliderBox(double min, double value, double max, double step) {
        this();
        setMin(min);
        setValue(value);
        setMax(max);
        setStep(step);
        this.setMin(min);
        this.setValue(value);
        this.setMax(max);
        this.setStep(step);
        super.setText(String.valueOf(value));
    }

    protected SliderBox(Element element) {
        super(element);
        assert InputElement.as(element).getType().equalsIgnoreCase("range");
    }

    SliderBox(Element element, String styleName) {
        super(element);
        super.getElement().setAttribute("type", "range");
//        super.getElement().setId("gwt-rangebox-" + UUID.randomUUID());
    }

    public HandlerRegistration addInputHandler(InputHandler handler) {
@@ -53,12 +52,12 @@ public class SliderBox extends SliderBoxBase {
    }

    public void setValue(double value) {
        super.getElement().setPropertyString("value", String.valueOf(value));
        super.getElement().setPropertyDouble("value", value);
    }

    @Override
    public String getValue() {
        return super.getElement().getPropertyString("value");
    public Double getValue() {
        return super.getElement().getPropertyDouble("value");
    }

    public double getMin() {
+1 −4
Original line number Diff line number Diff line
@@ -17,12 +17,9 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples.slider;

import com.google.gwt.dom.client.Element;
import com.google.gwt.text.shared.testing.PassthroughParser;
import com.google.gwt.text.shared.testing.PassthroughRenderer;
import com.google.gwt.user.client.ui.ValueBoxBase;
import org.cesiumjs.cs.Cesium;

public class SliderBoxBase extends ValueBoxBase<String> {
public class SliderBoxBase extends ValueBoxBase<Double> {
    protected SliderBoxBase(Element elem) {
        super(elem, PassthroughRenderer.instance(), PassthroughParser.instance());
    }