# HG changeset patch # User gernotbelger # Date 1547050405 -3600 # Node ID 1a7cfeb1ff8926d4ffe252e657aea5265f527a87 # Parent 2a67d05a1af084f70da76d09b47719b8096685b1 Punkt 10.8 WQ-Vorschau diff -r 2a67d05a1af0 -r 1a7cfeb1ff89 artifacts/src/main/java/org/dive4elements/river/artifacts/states/LocationSelect.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/LocationSelect.java Wed Jan 09 14:48:53 2019 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/LocationSelect.java Wed Jan 09 17:13:25 2019 +0100 @@ -8,21 +8,15 @@ package org.dive4elements.river.artifacts.states; -import gnu.trove.TDoubleArrayList; - import org.apache.log4j.Logger; - +import org.dive4elements.artifactdatabase.data.StateData; +import org.dive4elements.artifacts.Artifact; +import org.dive4elements.artifacts.CallContext; +import org.dive4elements.artifacts.common.utils.XMLUtils; +import org.dive4elements.river.artifacts.D4EArtifact; import org.w3c.dom.Element; -import org.dive4elements.artifacts.Artifact; -import org.dive4elements.artifacts.CallContext; - -import org.dive4elements.artifacts.common.utils.XMLUtils; - -import org.dive4elements.artifactdatabase.data.StateData; - -import org.dive4elements.river.artifacts.D4EArtifact; - +import gnu.trove.TDoubleArrayList; /** * This state is used to realize the input of multiple locations as string. @@ -34,29 +28,22 @@ */ public class LocationSelect extends LocationDistanceSelect { - /** The log used in this class.*/ + private static final long serialVersionUID = 1L; + /** The log used in this class. */ private static Logger log = Logger.getLogger(LocationSelect.class); - public LocationSelect() { } - /** UI Provider (which input method should the client provide to user. */ @Override protected String getUIProvider() { return "location_panel"; } - @Override - protected Element[] createItems( - XMLUtils.ElementCreator cr, - Artifact artifact, - String name, - CallContext context) - { - double[] minmax = getMinMax(artifact); + protected Element[] createItems(final XMLUtils.ElementCreator cr, final Artifact artifact, final String name, final CallContext context) { + final double[] minmax = getMinMax(artifact); double minVal = Double.MIN_VALUE; double maxVal = Double.MAX_VALUE; @@ -64,19 +51,14 @@ if (minmax != null) { minVal = minmax[0]; maxVal = minmax[1]; - } - else { + } else { log.warn("Could not read min/max distance values!"); } if (name.equals(LOCATIONS)) { - Element min = createItem( - cr, - new String[] {"min", new Double(minVal).toString()}); + final Element min = createItem(cr, new String[] { "min", new Double(minVal).toString() }); - Element max = createItem( - cr, - new String[] {"max", new Double(maxVal).toString()}); + final Element max = createItem(cr, new String[] { "max", new Double(maxVal).toString() }); return new Element[] { min, max }; } @@ -84,53 +66,48 @@ return null; } - /** Validates data from artifact. */ @Override - public boolean validate(Artifact artifact) - throws IllegalArgumentException - { + public boolean validate(final Artifact artifact) throws IllegalArgumentException { log.debug("LocationSelect.validate"); - D4EArtifact flys = (D4EArtifact) artifact; - StateData data = getData(flys, LOCATIONS); + final D4EArtifact flys = (D4EArtifact) artifact; + final StateData data = getData(flys, LOCATIONS); - String locationStr = data != null - ? (String) data.getValue() - : null; + final String locationStr = data != null ? (String) data.getValue() : null; if (locationStr == null || locationStr.length() == 0) { log.error("No locations given."); throw new IllegalArgumentException("error_empty_state"); } - double[] minmax = getMinMax(artifact); - double[] mm = extractLocations(locationStr); + final double[] minmax = getMinMax(artifact); + final double[] mm = extractLocations(locationStr); log.debug("Inserted min location: " + mm[0]); - log.debug("Inserted max location: " + mm[mm.length-1]); + log.debug("Inserted max location: " + mm[mm.length - 1]); - return validateBounds(minmax[0], minmax[1], mm[0], mm[mm.length-1], 0d); + return validateBounds(minmax[0], minmax[1], mm[0], mm[mm.length - 1], 0d); } - /** * This method takes a string that consist of whitespace separated double * values and returns the double values as array. * - * @param locationStr The locations inserted in this state. + * @param locationStr + * The locations inserted in this state. * * @return the locations as array. */ - protected double[] extractLocations(String locationStr) { - String[] tmp = locationStr.split(" "); - TDoubleArrayList locations = new TDoubleArrayList(); + protected double[] extractLocations(final String locationStr) { + final String[] tmp = locationStr.split(" "); + final TDoubleArrayList locations = new TDoubleArrayList(); - for (String l: tmp) { + for (final String l : tmp) { try { locations.add(Double.parseDouble(l)); } - catch (NumberFormatException nfe) { + catch (final NumberFormatException nfe) { log.warn(nfe, nfe); } } diff -r 2a67d05a1af0 -r 1a7cfeb1ff89 artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/LocationSelect.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/LocationSelect.java Wed Jan 09 14:48:53 2019 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/LocationSelect.java Wed Jan 09 17:13:25 2019 +0100 @@ -9,20 +9,18 @@ package org.dive4elements.river.artifacts.states.fixation; import org.apache.log4j.Logger; - import org.dive4elements.artifacts.Artifact; - import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.model.fixings.FixingsOverview; import org.dive4elements.river.artifacts.model.fixings.FixingsOverviewFactory; import org.dive4elements.river.artifacts.states.RangeState; - /** * @author Raimund Renkert */ public class LocationSelect extends RangeState { + private static final long serialVersionUID = 1L; /** The log used in this class. */ private static Logger log = Logger.getLogger(LocationSelect.class); @@ -38,23 +36,17 @@ } @Override - protected double[] getMinMax(Artifact artifact) { - D4EArtifact flysArtifact = (D4EArtifact) artifact; - String riverName = flysArtifact.getDataAsString("river"); - FixingsOverview overview = FixingsOverviewFactory - .getOverview(riverName); + protected double[] getMinMax(final Artifact artifact) { + final D4EArtifact flysArtifact = (D4EArtifact) artifact; + final String riverName = flysArtifact.getDataAsString("river"); + final FixingsOverview overview = FixingsOverviewFactory.getOverview(riverName); - return new double[]{ - overview.getExtent().getStart(), - overview.getExtent().getEnd()}; + return new double[] { overview.getExtent().getStart(), overview.getExtent().getEnd() }; } - /** Misuse to set location mode. */ @Override - public boolean validate(Artifact artifact) - throws IllegalArgumentException - { + public boolean validate(final Artifact artifact) throws IllegalArgumentException { ((D4EArtifact) artifact).addStringData("ld_mode", "distance"); return super.validate(artifact); } diff -r 2a67d05a1af0 -r 1a7cfeb1ff89 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/FixLocationPanel.java --- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/FixLocationPanel.java Wed Jan 09 14:48:53 2019 +0100 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/FixLocationPanel.java Wed Jan 09 17:13:25 2019 +0100 @@ -35,6 +35,8 @@ * @author Raimund Renkert */ public class FixLocationPanel extends FixationPanel implements BlurHandler { + private static final long serialVersionUID = 1L; + /** The message class that provides i18n strings. */ protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class); diff -r 2a67d05a1af0 -r 1a7cfeb1ff89 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/FixationPanel.java --- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/FixationPanel.java Wed Jan 09 14:48:53 2019 +0100 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/FixationPanel.java Wed Jan 09 17:13:25 2019 +0100 @@ -130,8 +130,8 @@ final AbstractFixBunduArtifact art = (AbstractFixBunduArtifact) this.artifact; - this.overviewService.generateOverview(locale, this.artifact.getUuid(), getOverviewFilter(art.getFilter()), - renderCheckboxes(), callBack, new AsyncCallback() { + this.overviewService.generateOverview(locale, this.artifact.getUuid(), getOverviewFilter(art.getFilter()), renderCheckboxes(), callBack, + new AsyncCallback() { @Override public void onFailure(final Throwable caught) { GWT.log("Could not receive overview."); @@ -141,14 +141,17 @@ @Override public void onSuccess(final FixingsOverviewInfo info) { GWT.log("Successfully loaded overview."); + FixationPanel.this.fixInfo = info; FixationPanel.this.htmlOverview = info.getHTML(); final AbstractFixBunduArtifact art = (AbstractFixBunduArtifact) FixationPanel.this.artifact; final FixFilter filter = art.getFilter(); filter.setRiver(info.getRiver()); - if (filter.getCurrentKm() == -Double.MAX_VALUE || filter.getCurrentKm() == -1d) { - filter.setCurrentKm(filter.getLowerKm()); - filter.setToKm(filter.getUpperKm()); + if (filter.getCurrentKm() == -Double.MAX_VALUE || filter.getCurrentKm() == -1d) { // do not compare doubles (works, because it is set in + // the same way) + + filter.setCurrentKm(info.getLowerKm()); + filter.setToKm(info.getUpperKm()); } if (FixationPanel.this.kmText != null) { final NumberFormat nf = NumberFormat.getDecimalFormat(); @@ -160,6 +163,17 @@ FixationPanel.this.kmText.setValue(filter.getCurrentKm()); } } + + if (FixationPanel.this.kmText != null) { + final NumberFormat nf = NumberFormat.getDecimalFormat(); + try { + final double d = Double.valueOf(filter.getCurrentKm()); + FixationPanel.this.kmText.setValue(nf.format(d)); + } + catch (final NumberFormatException e) { + FixationPanel.this.kmText.setValue(filter.getCurrentKm()); + } + } eventPane.setContents(FixationPanel.this.htmlOverview); updateChartTab(FixationPanel.this.fixInfo.getLowerKm()); FixationPanel.this.events.setPane(eventPane); @@ -273,10 +287,8 @@ hHeight = (int) (hWidth * 3f / 4); } - final String imgUrl = URL.encode(GWT.getModuleBaseURL() - + "fixings-km-chart" - + "?locale=" + locale - + "&filter=" + getChartFilter(filter, hWidth, hHeight)); + final String imgUrl = URL + .encode(GWT.getModuleBaseURL() + "fixings-km-chart" + "?locale=" + locale + "&filter=" + getChartFilter(filter, hWidth, hHeight)); if (this.chartContainer.hasMember(this.chartImg)) { this.chartImg.setWidth(hWidth);