Search in sources :

Example 11 with FloatValidator

use of gaiasky.util.validator.FloatValidator in project gaiasky by langurmonkey.

the class LandAtWindow method build.

@Override
protected void build() {
    latlonCb = new OwnCheckBox(I18n.txt("context.lonlat"), skin, "radio", pad10);
    latlonCb.setChecked(false);
    latlonCb.addListener(new EventListener() {

        @Override
        public boolean handle(com.badlogic.gdx.scenes.scene2d.Event event) {
            if (event instanceof ChangeEvent) {
                if (latlonCb.isChecked()) {
                    enableComponents(false, location);
                    enableComponents(true, longitude, latitude);
                    stage.setKeyboardFocus(longitude);
                }
                return true;
            }
            return false;
        }
    });
    longitude = new OwnTextField("", skin, new FloatValidator(0, 360));
    latitude = new OwnTextField("", skin, new FloatValidator(-90, 90));
    locationCb = new OwnCheckBox(I18n.txt("context.location"), skin, "radio", pad10);
    locationCb.setChecked(true);
    locationCb.addListener(new EventListener() {

        @Override
        public boolean handle(com.badlogic.gdx.scenes.scene2d.Event event) {
            if (event instanceof ChangeEvent) {
                if (locationCb.isChecked()) {
                    enableComponents(true, location);
                    enableComponents(false, longitude, latitude);
                    stage.setKeyboardFocus(location);
                }
                return true;
            }
            return false;
        }
    });
    location = new OwnTextField("", skin, new ExistingLocationValidator(target));
    new ButtonGroup<CheckBox>(latlonCb, locationCb);
    content.add(locationCb).left().top().padBottom(pad10).colspan(4).row();
    content.add(new OwnLabel(I18n.txt("context.location"), skin)).left().top().padRight(pad10);
    content.add(location).left().top().padBottom(pad10 * 2).row();
    content.add(latlonCb).left().top().padBottom(pad10).colspan(4).row();
    content.add(new OwnLabel(I18n.txt("context.longitude"), skin)).left().top().padRight(pad10);
    content.add(longitude).left().top().padRight(pad10 * 2);
    content.add(new OwnLabel(I18n.txt("context.latitude"), skin)).left().top().padRight(pad10);
    content.add(latitude).left().top();
}
Also used : ExistingLocationValidator(gaiasky.util.validator.ExistingLocationValidator) OwnTextField(gaiasky.util.scene2d.OwnTextField) ChangeEvent(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent) ButtonGroup(com.badlogic.gdx.scenes.scene2d.ui.ButtonGroup) OwnCheckBox(gaiasky.util.scene2d.OwnCheckBox) OwnLabel(gaiasky.util.scene2d.OwnLabel) EventListener(com.badlogic.gdx.scenes.scene2d.EventListener) FloatValidator(gaiasky.util.validator.FloatValidator)

Example 12 with FloatValidator

use of gaiasky.util.validator.FloatValidator in project gaiasky by langurmonkey.

the class AddShapeDialog method build.

@Override
protected void build() {
    content.clear();
    OwnLabel info = new OwnLabel(I18n.txt("gui.shape.info", object.getName()), skin, "hud-subheader");
    content.add(info).left().padBottom(pad15).row();
    // Name
    addName(content, "1 AU from " + objectName);
    // Size
    FloatValidator val = new FloatValidator(0f, Float.MAX_VALUE);
    size = new OwnTextField("1.0", skin, val);
    size.setWidth(fieldWidth * 0.6f);
    size.addListener((event) -> {
        if (event instanceof ChangeEvent) {
            recomputeObjectName();
        }
        return true;
    });
    units = new OwnSelectBox<>(skin);
    units.setWidth(fieldWidth * 0.3f);
    units.setItems(Units.values());
    units.setSelected(Units.AU);
    units.addListener((event) -> {
        if (event instanceof ChangeEvent) {
            recomputeObjectName();
        }
        return true;
    });
    HorizontalGroup sizeGroup = new HorizontalGroup();
    sizeGroup.space(15f);
    sizeGroup.addActor(size);
    sizeGroup.addActor(units);
    content.add(new OwnLabel(I18n.txt("gui.shape.size"), skin, titleWidth)).left().padRight(pad10).padBottom(pad10);
    content.add(sizeGroup).left().padBottom(pad10).row();
    // Show label
    showLabel = new OwnCheckBox(I18n.txt("gui.shape.label"), skin, pad5);
    showLabel.setChecked(true);
    content.add(showLabel).left().colspan(2).padRight(pad10).padBottom(pad10).row();
    // Track
    track = new OwnCheckBox(I18n.txt("gui.shape.track"), skin, pad5);
    track.setChecked(true);
    content.add(track).left().colspan(2).padRight(pad10).padBottom(pad5);
    // Separator
    addSeparator(2);
    // Shape
    shape = new OwnSelectBox<>(skin);
    shape.setWidth(fieldWidth);
    shape.setItems(Shape.values());
    shape.setSelected(Shape.SPHERE);
    content.add(new OwnLabel(I18n.txt("gui.shape.shape"), skin, titleWidth)).left().padRight(pad10).padBottom(pad10);
    content.add(shape).left().padBottom(pad10).row();
    // Color
    addColor(content);
    // Primitive
    primitive = new OwnSelectBox<>(skin);
    primitive.setWidth(fieldWidth);
    primitive.setItems(Primitive.values());
    primitive.setSelected(Primitive.LINES);
    content.add(new OwnLabel(I18n.txt("gui.shape.primitive"), skin, titleWidth)).left().padRight(pad10).padBottom(pad10);
    content.add(primitive).left().padBottom(pad10).row();
}
Also used : OwnTextField(gaiasky.util.scene2d.OwnTextField) ChangeEvent(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent) OwnLabel(gaiasky.util.scene2d.OwnLabel) HorizontalGroup(com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup) OwnCheckBox(gaiasky.util.scene2d.OwnCheckBox) FloatValidator(gaiasky.util.validator.FloatValidator)

Aggregations

FloatValidator (gaiasky.util.validator.FloatValidator)12 ChangeEvent (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent)8 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)3 OwnLabel (gaiasky.util.scene2d.OwnLabel)3 OwnTextField (gaiasky.util.scene2d.OwnTextField)3 IValidator (gaiasky.util.validator.IValidator)3 Actor (com.badlogic.gdx.scenes.scene2d.Actor)2 HorizontalGroup (com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup)2 OwnCheckBox (gaiasky.util.scene2d.OwnCheckBox)2 TextFieldComparatorValidator (gaiasky.util.validator.TextFieldComparatorValidator)2 EventListener (com.badlogic.gdx.scenes.scene2d.EventListener)1 ButtonGroup (com.badlogic.gdx.scenes.scene2d.ui.ButtonGroup)1 TextArea (com.badlogic.gdx.scenes.scene2d.ui.TextArea)1 Array (com.badlogic.gdx.utils.Array)1 Keyframe (gaiasky.desktop.util.camera.Keyframe)1 AttributeComboBoxBean (gaiasky.interafce.beans.AttributeComboBoxBean)1 ComponentType (gaiasky.render.ComponentTypes.ComponentType)1 ParticleGroup (gaiasky.scenegraph.ParticleGroup)1 StarGroup (gaiasky.scenegraph.StarGroup)1 OctreeWrapper (gaiasky.scenegraph.octreewrapper.OctreeWrapper)1