view flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java @ 261:f3ea644800c4

Fixed the location input. A range selection sets the correct location values now. flys-client/trunk@1876 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 10 May 2011 11:37:49 +0000
parents 385e9368ffcd
children f56523bf4c55
line wrap: on
line source
package de.intevation.flys.client.client.ui;

import java.util.LinkedHashMap;
import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;

import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.events.BlurHandler;
import com.smartgwt.client.widgets.form.fields.events.BlurEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
import com.smartgwt.client.widgets.grid.events.CellClickHandler;
import com.smartgwt.client.widgets.grid.events.CellClickEvent;

import com.smartgwt.client.widgets.tab.TabSet;
import com.smartgwt.client.widgets.tab.Tab;
import com.smartgwt.client.data.Record;

import com.smartgwt.client.types.ListGridFieldType;

import de.intevation.flys.client.shared.model.Data;
import de.intevation.flys.client.shared.model.DataItem;
import de.intevation.flys.client.shared.model.DataList;
import de.intevation.flys.client.shared.model.DefaultData;
import de.intevation.flys.client.shared.model.DefaultDataItem;
import de.intevation.flys.client.shared.model.DistanceInfoObject;
import de.intevation.flys.client.shared.model.DistanceInfoRecord;
import de.intevation.flys.client.shared.model.ArtifactDescription;

import de.intevation.flys.client.client.services.DistanceInfoService;
import de.intevation.flys.client.client.services.DistanceInfoServiceAsync;
import de.intevation.flys.client.client.FLYSConstants;
import de.intevation.flys.client.client.FLYSImages;
import de.intevation.flys.client.client.Config;


/**
 * This UIProvider creates a widget to enter locations or a distance.
 *
 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
 */
public class LocationDistancePanel
extends      AbstractUIProvider
implements   ChangeHandler, BlurHandler
{
    /** The message class that provides i18n strings.*/
    protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class);

    /** The interface that provides the image resources. */
    private FLYSImages IMAGES = GWT.create(FLYSImages.class);

    /** The DistanceInfoService used to retrieve locations about rivers.*/
    protected DistanceInfoServiceAsync distanceInfoService =
        GWT.create(DistanceInfoService.class);

    /** The constant name of the input field to enter locations.*/
    public static final String FIELD_LOCATION = "location";

    /** The constant name of the input field to enter distance.*/
    public static final String FIELD_DISTANCE = "distance";

    /** The constant name of the input field to enter the start of a distance.*/
    public static final String FIELD_FROM = "from";

    /** The constant name of the input field to enter the end of a distance.*/
    public static final String FIELD_TO = "to";

    /** The constant name of the input field to enter the step width of a
     * distance.*/
    public static final String FIELD_WIDTH = "width";

    public static final int WIDTH = 250;


    /** The radio group for input mode selection.*/
    protected DynamicForm mode;

    /** A container that will contain the location or the distance panel.*/
    protected HLayout container;

    /** The min value for a distance.*/
    protected double min;

    /** The max value for a distance.*/
    protected double max;

    /** The 'from' value entered in the distance mode.*/
    protected double from;

    /** The 'to' value entered in the distance mode.*/
    protected double to;

    /** The 'step' value entered in the distance mode.*/
    protected double step;

    /** The values entered in the location mode.*/
    protected double[] values;

    /** The input panel for locations */
    protected DoubleArrayPanel locationPanel;

    /** The input panel for distances */
    protected DoubleRangePanel distancePanel;

    /** The tab set containing the location and distance table*/
    protected TabSet inputTables;

    /** The distance table. */
    protected ListGrid distanceTable;

    /** The locations table */
    protected ListGrid locationsTable;

    /** The locations table for distance input. */
    protected ListGrid locationDistanceTable;

    /** The table data. */
    protected DistanceInfoObject[] tableData;

    /**
     * Creates a new LocationDistancePanel instance.
     */
    public LocationDistancePanel() {
        distanceTable  = new ListGrid();
        locationsTable = new ListGrid();
        locationDistanceTable = new ListGrid();
    }


    /**
     * This method creates a widget that contains a label, a panel with
     * checkboxes to switch the input mode between location and distance input,
     * and a the mode specific panel.
     *
     * @param data The data that might be inserted.
     *
     * @return a panel.
     */
    public Canvas create(DataList data) {
        VLayout layout = new VLayout();
        layout.setMembersMargin(10);

        initDefaults(data);

        Label label   = new Label(MESSAGES.location_distance_state());
        Canvas widget = createWidget(data);
        Canvas submit = getNextButton();
        createDistanceInputPanel();

        createDistanceTable();
        createLocationTable();
        createLocationTableDistance ();

        widget.setHeight(50);
        label.setHeight(25);

        layout.addMember(label);
        layout.addMember(widget);
        layout.addMember(submit);

        return layout;
    }


    /**
     * This method creates a table that contains the distance values.
     */
    protected void createDistanceTable() {
        distanceTable.setWidth100();
        distanceTable.setShowRecordComponents(true);
        distanceTable.setShowRecordComponentsByCell(true);
        distanceTable.setHeight100();

        ListGridField addDistance = new ListGridField ("", "");
        addDistance.setType (ListGridFieldType.ICON);
        addDistance.setWidth ("30");
        addDistance.addRecordClickHandler (new RecordClickHandler () {
            public void onRecordClick (RecordClickEvent e) {
                if (!isLocationMode ()) {
                    Record r = e.getRecord();
                    double min = r.getAttributeAsDouble("from");
                    double max = r.getAttributeAsDouble("to");
                    setDistanceValues(min, max);
                }
                else {
                    double[] selected;
                    Record r = e.getRecord();
                    double min = r.getAttributeAsDouble("from");
                    double max = r.getAttributeAsDouble("to");
                    if (getLocationValues() != null) {
                        double[] val = getLocationValues();
                        selected = new double[val.length + 2];
                        for(int i = 0; i < val.length; i++){
                            selected[i] = val[i];
                        }
                        selected[val.length] = min;
                        selected[val.length + 1] = max;
                    }
                    else {
                        selected = new double[2];
                        selected[0] = min;
                        selected[1] = max;
                    }
                setLocationValues(selected);
                }
            }
        });
        addDistance.setCellIcon (IMAGES.markerGreen ().getURL ());

        ListGridField ddescr = new ListGridField("description",
                MESSAGES.description());
        ddescr.setType(ListGridFieldType.TEXT);
        ddescr.setWidth("*");
        ListGridField from = new ListGridField("from", MESSAGES.from());
        from.setType(ListGridFieldType.TEXT);
        from.setWidth(75);
        ListGridField to = new ListGridField("to", MESSAGES.to());
        to.setType(ListGridFieldType.TEXT);
        to.setWidth(75);
        ListGridField dside = new ListGridField("riverside",
                MESSAGES.riverside());
        dside.setType(ListGridFieldType.TEXT);
        dside.setWidth(60);

        distanceTable.setFields(addDistance, ddescr, from, to, dside);
    }


    /**
     * This method creates a table that contains the location values.
     */
    protected void createLocationTable() {
        locationsTable.setWidth100();
        locationsTable.setShowRecordComponents(true);
        locationsTable.setShowRecordComponentsByCell(true);
        locationsTable.setHeight100();

        ListGridField addLocation = new ListGridField ("", "");
        addLocation.setType (ListGridFieldType.ICON);
        addLocation.setWidth ("30");
        addLocation.addRecordClickHandler (new RecordClickHandler () {
            public void onRecordClick (RecordClickEvent e) {
                ListGridRecord[] records = locationsTable.getSelection();
                double[] selected;
                if (getLocationValues() != null) {
                    double[] val = getLocationValues();
                    selected = new double[val.length + 1];
                    for(int i = 0; i < val.length; i++){
                        selected[i] = val[i];
                    }
                    selected[val.length] =
                        records[0].getAttributeAsDouble("from");
                }
                else {
                    selected = new double[1];
                    selected[0] = records[0].getAttributeAsDouble("from");
                }
                setLocationValues(selected);
            }
        });
        addLocation.setCellIcon (IMAGES.markerGreen ().getURL ());

        ListGridField ldescr = new ListGridField("description",
                MESSAGES.description());
        ldescr.setType(ListGridFieldType.TEXT);
        ldescr.setWidth("*");
        ListGridField lside = new ListGridField("riverside",
                MESSAGES.riverside());
        lside.setType(ListGridFieldType.TEXT);
        lside.setWidth(60);
        ListGridField loc = new ListGridField("from", MESSAGES.location());
        loc.setType(ListGridFieldType.TEXT);
        loc.setWidth(80);
        locationsTable.setFields(addLocation, ldescr, loc, lside);
    }


    /**
     * This method creates a table that contains the location values.
     */
    protected void createLocationTableDistance (){
        locationDistanceTable = null;
        locationDistanceTable = new ListGrid ();
        locationDistanceTable.setWidth100();
        locationDistanceTable.setShowRecordComponents(true);
        locationDistanceTable.setShowRecordComponentsByCell(true);
        locationDistanceTable.setHeight100();

        ListGridField addfrom = new ListGridField ("", "");
        addfrom.setType (ListGridFieldType.ICON);
        addfrom.setWidth ("30");
        addfrom.setCellIcon (IMAGES.markerGreen ().getURL ());

        ListGridField addto2 = new ListGridField ("", "");
        addto2.setType (ListGridFieldType.ICON);
        addto2.setWidth ("30");
        addto2.setCellIcon (IMAGES.markerRed ().getURL ());


        ListGridField ldescr = new ListGridField("description",
                MESSAGES.description());
        ldescr.setType(ListGridFieldType.TEXT);
        ldescr.setWidth("*");
        ListGridField lside = new ListGridField("riverside",
                MESSAGES.riverside());
        lside.setType(ListGridFieldType.TEXT);
        lside.setWidth(60);
        ListGridField loc = new ListGridField("from", MESSAGES.location());
        loc.setType(ListGridFieldType.TEXT);
        loc.setWidth(80);
        locationDistanceTable.addCellClickHandler (new CellClickHandler () {
            public void onCellClick (CellClickEvent e) {
                if (e.getColNum() == 0) {
                    Record r = e.getRecord ();
                    double fromvalue = r.getAttributeAsDouble ("from");
                    double tovalue = getTo ();
                    setDistanceValues (fromvalue, tovalue);
                }
                else if (e.getColNum() == 1) {
                    Record r = e.getRecord ();
                    double fromvalue = getFrom ();
                    double tovalue = r.getAttributeAsDouble ("to");
                    setDistanceValues (fromvalue, tovalue);
                }
            }
        });
        locationDistanceTable.setFields(addfrom, addto2, ldescr, loc, lside);
    }


    public Canvas createOld(DataList dataList) {
        List<Data> items = dataList.getAll();

        Data dFrom = getData(items, "ld_from");
        Data dTo   = getData(items, "ld_to");
        Data dStep = getData(items, "ld_step");

        DataItem[] from = dFrom.getItems();
        DataItem[] to   = dTo.getItems();
        DataItem[] step = dStep.getItems();

        HLayout layout = new HLayout();
        layout.setWidth("400px");

        Label   label  = new Label(dataList.getLabel());
        label.setWidth("200px");

        StringBuilder sb = new StringBuilder();
        sb.append(from[0].getLabel());
        sb.append(" " + MESSAGES.unitFrom() + " ");
        sb.append(to[0].getLabel());
        sb.append(" " + MESSAGES.unitTo() + " ");
        sb.append(step[0].getLabel());
        sb.append(" " + MESSAGES.unitWidth());

        Canvas back = getBackButton(dataList.getState());

        Label selected = new Label(sb.toString());
        selected.setWidth("130px");

        layout.addMember(label);
        layout.addMember(selected);
        layout.addMember(back);

        return layout;
    }


    /**
     * This method reads the default values defined in the DataItems of the Data
     * objects in <i>list</i>.
     *
     * @param list The DataList container that stores the Data objects.
     */
    protected void initDefaults(DataList list) {
        Data f = getData(list.getAll(), "ld_from");
        Data t = getData(list.getAll(), "ld_to");
        Data s = getData(list.getAll(), "ld_step");

        DataItem[] fItems = f.getItems();
        DataItem[] tItems = t.getItems();
        DataItem[] sItems = s.getItems();

        min  = Double.valueOf(fItems[0].getStringValue());
        max  = Double.valueOf(tItems[0].getStringValue());
        step = Double.valueOf(sItems[0].getStringValue());

        this.from = min;
        this.to   = max;
        this.step = step;
    }


    /**
     * This method greps the Data with name <i>name</i> from the list and
     * returns it.
     *
     * @param items A list of Data.
     * @param name The name of the Data that we are searching for.
     *
     * @return the Data with the name <i>name</i>.
     */
    protected Data getData(List<Data> data, String name) {
        for (Data d: data) {
            if (name.equals(d.getLabel())) {
                return d;
            }
        }

        return null;
    }


    protected Canvas createWidget(DataList data) {
        VLayout layout       = new VLayout();
        container            = new HLayout();
        Canvas checkboxPanel = createRadioButtonPanel();

        // the initial view will display the location input mode
        locationPanel = new DoubleArrayPanel(
                MESSAGES.unitLocation(),
                getLocationValues(),
                this);
        container.addMember(locationPanel);

        layout.addMember(checkboxPanel);
        layout.addMember(container);

        container.setMembersMargin(30);

        inputTables   = new TabSet();
        Tab locations = new Tab(MESSAGES.location());
        Tab distances = new Tab(MESSAGES.distance());

        inputTables.setWidth(500);
        inputTables.setHeight(350);

        locations.setPane(locationsTable);
        distances.setPane(distanceTable);

        inputTables.addTab(locations);
        inputTables.addTab(distances);

        container.addMember(inputTables);

        return layout;
    }


    /**
     * This method returns the selected data.
     *
     * @return the selected/inserted data.
     */
    public Data[] getData() {
        // XXX If we have entered a value and click right afterwards on the
        // 'next' button, the BlurEvent is not fired, and the values are not
        // saved. So, we gonna save those values explicitly.
        if (isLocationMode()) {
            Canvas member = container.getMember(0);
            if (member instanceof DoubleArrayPanel) {
                DoubleArrayPanel form = (DoubleArrayPanel) member;
                saveLocationValues(form);
            }
        }
        else {
            Canvas member = container.getMember(0);
            if (member instanceof DoubleRangePanel) {
                DoubleRangePanel form = (DoubleRangePanel) member;
                saveDistanceValues(form);
            }
        }

        return new Data[] { getDataFrom(), getDataTo(), getDataStep() };
    }


    /**
     * Returns the Data object for the 'from' attribute.
     *
     * @return the Data object for the 'from' attribute.
     */
    protected Data getDataFrom() {
        String value  = Double.valueOf(getFinalFrom()).toString();
        DataItem item = new DefaultDataItem("ld_from", "ld_from", value);
        return new DefaultData(
            "ld_from", null, null, new DataItem[] { item });
    }


    /**
     * Returns the Data object for the 'to' attribute.
     *
     * @return the Data object for the 'to' attribute.
     */
    protected Data getDataTo() {
        String value  = Double.valueOf(getFinalTo()).toString();
        DataItem item = new DefaultDataItem("ld_to", "ld_to", value);
        return new DefaultData(
            "ld_to", null, null, new DataItem[] { item });
    }


    /**
     * Returns the Data object for the 'step' attribute.
     *
     * @return the Data object for the 'step' attribute.
     */
    protected Data getDataStep() {
        String value  = Double.valueOf(getFinalStep()).toString();
        DataItem item = new DefaultDataItem("ld_step","ld_step", value);
        return new DefaultData(
            "ld_step", null, null, new DataItem[] { item });
    }


    /**
     * Returns the value of 'from' depending on the selected input mode.
     *
     * @return the value of 'from' depending on the selected input mode.
     */
    protected double getFinalFrom() {
        if (isLocationMode()) {
            double[] values = getLocationValues();
            double   value  = Double.MAX_VALUE;

            for (double v: values) {
                value = value < v ? value : v;
            }

            return value;
        }
        else {
            return getFrom();
        }
    }


    /**
     * Returns the value of 'to' depending on the selected input mode.
     *
     * @return the value of 'to' depending on the selected input mode.
     */
    protected double getFinalTo() {
        if (isLocationMode()) {
            double[] values = getLocationValues();
            double   value  = Double.MIN_VALUE;

            for (double v: values) {
                value = value > v ? value : v;
            }

            return value;
        }
        else {
            return getTo();
        }
    }


    /**
     * Returns the value of 'step' depending on the selected input mode.
     *
     * @return the value of 'step' depending on the selected input mode.
     */
    protected double getFinalStep() {
        if (isLocationMode()) {
            // we have no field to enter the 'step' attribute in the location
            // mode
            return 0.0;
        }
        else {
            return getStep();
        }
    }


    /**
     * Determines the current input mode.
     *
     * @return true, if 'location' is the current input mode, otherwise false.
     */
    public boolean isLocationMode() {
        String inputMode = mode.getValueAsString("mode");

        return inputMode.equals(FIELD_LOCATION) ? true : false;
    }


    /**
     * This method switches the input mode between location and distance input.
     *
     * @param event The click event fired by a RadioButtonGroupItem.
     */
    public void onChange(ChangeEvent event) {
        String value = (String) event.getValue();

        if (value == null) {
            return;
        }
        if (value.equals(FIELD_LOCATION)) {
            locationPanel = new DoubleArrayPanel(
                MESSAGES.unitLocation(),
                getLocationValues(),
                this);

            container.removeMembers(container.getMembers());
            container.addMember(locationPanel);
            while (inputTables.getNumTabs() > 0) {
                inputTables.removeTab(0);
            }
            Tab t1 = new Tab (MESSAGES.location());
            createLocationTable();
            t1.setPane(locationsTable);
            inputTables.addTab(t1);
            createDistanceTable();
            Tab t2 = new Tab (MESSAGES.distance());
            t2.setPane(distanceTable);
            inputTables.addTab(t2);
            updateDistanceInfo(tableData);

            container.addMember(inputTables);
            inputTables.selectTab(0);
        }
        else {
            distancePanel = new DoubleRangePanel(
                MESSAGES.unitFrom(), MESSAGES.unitTo(), MESSAGES.unitWidth(),
                getFrom(), getTo(), getStep(),
                250,
                this);

            container.removeMembers(container.getMembers());
            container.addMember(distancePanel);
            while (inputTables.getNumTabs () > 0) {
                inputTables.removeTab(0);
            }
            Tab t1 = new Tab(MESSAGES.location ());
            createLocationTableDistance ();
            t1.setPane(locationDistanceTable);
            inputTables.addTab(t1);
            createDistanceTable ();
            Tab t2 = new Tab(MESSAGES.distance ());
            t2.setPane(distanceTable);
            inputTables.addTab(t2);
            if (tableData != null) {
                updateDistanceInfo(tableData);
            }

            container.addMember(inputTables);
            inputTables.selectTab(1);
        }
    }


    /**
     * This method is used to validate the inserted data in the form fields.
     *
     * @param event The BlurEvent that gives information about the FormItem that
     * has been modified and its value.
     */
    public void onBlur(BlurEvent event) {
        FormItem item = event.getItem();
        String  field = item.getFieldName();

        if (field == null) {
            return;
        }

        if (field.equals(DoubleArrayPanel.FIELD_NAME)) {
            DoubleArrayPanel p = (DoubleArrayPanel) event.getForm();

            saveLocationValue(p, item);
        }
        else {
            DoubleRangePanel p = (DoubleRangePanel) event.getForm();

            saveDistanceValue(p, item);
        }
    }



    /**
     * Validates and stores all values entered in the location mode.
     *
     * @param p The DoubleArrayPanel.
     */
    protected void saveLocationValues(DoubleArrayPanel p) {
        FormItem[] formItems = p.getFields();

        for (FormItem item: formItems) {
            if (item.getFieldName().equals(DoubleArrayPanel.FIELD_NAME)) {
                saveLocationValue(p, item);
            }
        }
    }


    /**
     * Validates and stores all values entered in the distance mode.
     *
     * @param p The DoubleRangePanel.
     */
    protected void saveDistanceValues(DoubleRangePanel p) {
        FormItem[] formItems = p.getFields();

        for (FormItem item: formItems) {
            saveDistanceValue(p, item);
        }
    }


    /**
     * Validates and stores a value entered in the location mode.
     *
     * @param p The DoubleArrayPanel.
     * @param item The item that needs to be validated.
     */
    protected void saveLocationValue(DoubleArrayPanel p, FormItem item) {
        if (p.validateForm(item)) {
            setLocationValues(p.getInputValues(item));
        }
    }


    /**
     * Validates and stores value entered in the distance mode.
     *
     * @param p The DoubleRangePanel.
     * @param item The item that needs to be validated.
     */
    protected void saveDistanceValue(DoubleRangePanel p, FormItem item) {
        if (p.validateForm(item)) {
            setFrom(p.getFrom());
            setTo(p.getTo());
            setStep(p.getStep());
        }
    }


    /**
     * This method creates the panel that contains the checkboxes to switch
     * between the input mode 'location' and 'distance'.
     *
     * @return the checkbox panel.
     */
    protected Canvas createRadioButtonPanel() {
        mode = new DynamicForm();

        RadioGroupItem radio = new RadioGroupItem("mode");
        radio.setShowTitle(false);
        radio.setVertical(false);

        LinkedHashMap values = new LinkedHashMap();
        values.put(FIELD_LOCATION, MESSAGES.location());
        values.put(FIELD_DISTANCE, MESSAGES.distance());

        LinkedHashMap initial = new LinkedHashMap();
        initial.put("mode", FIELD_LOCATION);

        radio.setValueMap(values);
        radio.addChangeHandler(this);

        mode.setFields(radio);
        mode.setValues(initial);

        return mode;
    }


    protected void createDistanceInputPanel() {
        Config config = Config.getInstance();
        String url    = config.getServerUrl();
        String locale = config.getLocale ();
        String river  = "";

        ArtifactDescription adescr = artifact.getArtifactDescription();
        DataList[] data = adescr.getOldData();

        if (data != null && data.length > 0) {
            for (int i = 0; i < data.length; i++) {
                DataList dl = data[i];
                if (dl.getState().equals("state.winfo.river")) {
                    for (int j = 0; j < dl.size(); j++) {
                        Data d = dl.get(j);
                        DataItem[] di = d.getItems();
                        if (di != null && di.length == 1) {
                           river = d.getItems()[0].getStringValue();
                        }
                    }
                }
            }
        }

        distanceInfoService.getDistanceInfo(url, locale, river,
            new AsyncCallback<DistanceInfoObject[]>() {
                public void onFailure(Throwable caught) {
                    GWT.log("Could not recieve distance informations.");
                    GWT.log(caught.getMessage());
                }

                public void onSuccess(DistanceInfoObject[] di) {
                    int num = di != null ? di.length :0;
                    GWT.log("Recieved " + num + " distance informations.");

                    if (num == 0) {
                        return;
                    }
                    tableData = di;
                    updateDistanceInfo(di);
                }
            }
        );
    }


    protected void updateDistanceInfo(DistanceInfoObject[] di) {
        int i = 0;
        for (DistanceInfoObject dio: di) {
            if (dio.getTo() != null) {
                distanceTable.addData(new DistanceInfoRecord(dio));
            }
            else {
                locationsTable.addData(new DistanceInfoRecord(dio));
                locationDistanceTable.addData(new DistanceInfoRecord(dio));
            }
        }
        return;
    }


    protected double getFrom() {
        return from;
    }


    protected void setFrom(double from) {
        this.from = from;
    }


    protected double getTo() {
        return to;
    }


    protected void setTo(double to) {
        this.to = to;
    }


    protected double getStep() {
        return step;
    }


    protected void setStep(double step) {
        this.step = step;
    }


    protected double[] getLocationValues() {
        return values;
    }


    protected void setLocationValues(double[] values) {
        this.values = values;
        locationPanel.setValues(values);
    }


    protected void setDistanceValues (double from, double to) {
        setFrom(from);
        setTo(to);
        distancePanel.setValues(from, to, getStep());
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org