Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java @ 520:9e2b151770bd
Bugfix in the range/location panel - avoid NullPointerExceptions in getData().
flys-client/trunk@1999 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 25 May 2011 07:05:22 +0000 |
parents | ec965bf8dfef |
children | 9f16ac843dda |
line wrap: on
line source
package de.intevation.flys.client.client.ui; import java.util.ArrayList; 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); public static final String FIELD_MODE = "mode"; /** 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 locations.*/ public static final String FIELD_VALUE_LOCATION = "location"; /** The constant name of the input field to enter distance.*/ public static final String FIELD_VALUE_DISTANCE = "distance"; /** 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(); locationDistanceTable.setShowHeaderContextMenu(false); distanceTable.setShowHeaderContextMenu(false); locationsTable.setShowHeaderContextMenu(false); } /** * 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); Label label = new Label(MESSAGES.location_distance_state()); Canvas widget = createWidget(data); Canvas submit = getNextButton(); createDistanceInputPanel(); initDefaults(data); 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(); distanceTable.setEmptyMessage(MESSAGES.empty_table()); 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(); locationsTable.setEmptyMessage(MESSAGES.empty_table()); 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(); locationDistanceTable.setEmptyMessage(MESSAGES.empty_table()); 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 dMode = getData(items, "ld_mode"); DataItem[] dItems = dMode.getItems(); boolean rangeMode = true; if (dItems != null && dItems[0] != null) { rangeMode = FIELD_VALUE_DISTANCE.equals(dItems[0].getStringValue()); } HLayout layout = new HLayout(); layout.setWidth("400px"); Label label = new Label(dataList.getLabel()); label.setWidth("200px"); Canvas back = getBackButton(dataList.getState()); layout.addMember(label); if (rangeMode) { layout.addMember(getOldRangeSelection(dataList)); } else { layout.addMember(getOldLocationSelection(dataList)); } layout.addMember(back); return layout; } /** * Creates a label for the selected range. * * @param dataList The DataList containing all values for this state. * * @return A label displaying the selected values. */ protected Label getOldRangeSelection(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(); 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()); Label selected = new Label(sb.toString()); selected.setWidth("130px"); return selected; } /** * Creates a label for the selected locations. * * @param dataList The DataList containing all values for this state. * * @return A label displaying the selected values. */ protected Label getOldLocationSelection(DataList dataList) { List<Data> items = dataList.getAll(); Data dLocations = getData(items, "ld_locations"); DataItem[] lItems = dLocations.getItems(); String value = lItems[0].getStringValue(); Label selected = new Label(value); selected.setWidth(130); return selected; } /** * 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 m = getData(list.getAll(), "ld_mode"); Data l = getData(list.getAll(), "ld_locations"); 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()); DataItem mDef = m.getDefault(); DataItem lDef = l.getDefault(); DataItem fDef = f.getDefault(); DataItem tDef = t.getDefault(); DataItem sDef = s.getDefault(); String mDefValue = mDef != null ? mDef.getStringValue() : null; String theMode = mDefValue != null && mDefValue.length() > 0 ? mDef.getStringValue() : FIELD_VALUE_LOCATION; mode.setValue(FIELD_MODE, theMode); String fDefValue = fDef != null ? fDef.getStringValue() : null; setFrom(fDefValue != null && fDefValue.length() > 0 ? Double.valueOf(fDef.getStringValue()) : min); String tDefValue = tDef != null ? tDef.getStringValue() : null; setTo(tDefValue != null && tDefValue.length() > 0 ? Double.valueOf(tDef.getStringValue()) : max); String sDefValue = sDef != null ? sDef.getStringValue() : null; setStep(sDefValue != null && sDefValue.length() > 0 ? Double.valueOf(sDef.getStringValue()) : step); if (lDef != null) { String lDefValue = lDef != null ? lDef.getStringValue() : null; if (lDefValue != null && lDefValue.length() > 0) { setLocationValues(lDef.getStringValue()); } } if (theMode.equals(FIELD_VALUE_DISTANCE)) { enableDistancePanel(); } } 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.setWidth100(); inputTables.setHeight100(); locations.setPane(locationsTable); distances.setPane(distanceTable); inputTables.addTab(locations); inputTables.addTab(distances); helperContainer.addChild(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); } } Data dMode = getDataMode(); Data dLocations = getDataLocations(); Data dFrom = getDataFrom(); Data dTo = getDataTo(); Data dStep = getDataStep(); List<Data> data = new ArrayList<Data>(); if (dMode != null) { data.add(dMode); } if (dLocations != null) { data.add(dLocations); } if (dFrom != null) { data.add(dFrom); } if (dTo != null) { data.add(dTo); } if (dStep != null) { data.add(dStep); } return (Data[]) data.toArray(new Data[data.size()]); } /** * Returns the Data object for the 'mode' attribute. * * @return the Data object for the 'mode' attribute. */ protected Data getDataMode() { String value = mode.getValueAsString(FIELD_MODE); DataItem item = new DefaultDataItem("ld_mode", "ld_mode", value); return new DefaultData("ld_mode", null, null, new DataItem[] { item }); } protected Data getDataLocations() { double[] locations = getLocationValues(); boolean first = true; if (locations == null) { return null; } StringBuilder sb = new StringBuilder(); for (double l: locations) { if (!first) { sb.append(" "); } sb.append(l); first = false; } DataItem item = new DefaultDataItem( "ld_locations", "ld_locations", sb.toString()); return new DefaultData( "ld_locations", null, null, new DataItem[] { item }); } /** * Returns the Data object for the 'from' attribute. * * @return the Data object for the 'from' attribute. */ protected Data getDataFrom() { String value = Double.valueOf(getFrom()).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(getTo()).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(getStep()).toString(); DataItem item = new DefaultDataItem("ld_step","ld_step", value); return new DefaultData( "ld_step", null, null, new DataItem[] { item }); } /** * Determines the current input mode. * * @return true, if 'location' is the current input mode, otherwise false. */ public boolean isLocationMode() { String inputMode = mode.getValueAsString(FIELD_MODE); return inputMode.equals(FIELD_VALUE_LOCATION) ? true : false; } /** * Activates the location panel. */ protected void enableLocationPanel() { locationPanel = new DoubleArrayPanel( MESSAGES.unitLocation(), getLocationValues(), this); container.removeMembers(container.getMembers()); container.addMember(locationPanel); } /** * Activates the distance panel. */ protected void enableDistancePanel() { distancePanel = new DoubleRangePanel( MESSAGES.unitFrom(), MESSAGES.unitTo(), MESSAGES.unitWidth(), getFrom(), getTo(), getStep(), 250, this); container.removeMembers(container.getMembers()); container.addMember(distancePanel); } /** * 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_VALUE_LOCATION)) { enableLocationPanel(); 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); helperContainer.addChild(inputTables); inputTables.selectTab(0); } else { enableDistancePanel(); 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); } helperContainer.addChild(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(FIELD_MODE); radio.setShowTitle(false); radio.setVertical(false); LinkedHashMap values = new LinkedHashMap(); values.put(FIELD_VALUE_LOCATION, MESSAGES.location()); values.put(FIELD_VALUE_DISTANCE, MESSAGES.distance()); LinkedHashMap initial = new LinkedHashMap(); initial.put(FIELD_MODE, FIELD_VALUE_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 setLocationValues(String values) { String[] vs = values.split(" "); if (vs == null) { return; } double[] ds = new double[vs.length]; int idx = 0; for (String s: vs) { try { ds[idx++] = Double.valueOf(s); } catch (NumberFormatException nfe) { // do nothing } } setLocationValues(ds); } 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 :