changeset 9479:2b83d3a96703

i18n TODO "benutzerdefiniert" = "custom" fixed
author gernotbelger
date Mon, 10 Sep 2018 15:31:55 +0200
parents 7e2eebc14e1f
children 7228bd10a8cc
files artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/Calculation4.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixRealizingCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/states/DischargeLongitudinalSection.java artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixAnalysisCompute.java artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixRealizingCompute.java artifacts/src/main/resources/messages.properties artifacts/src/main/resources/messages_de.properties
diffstat 11 files changed, 188 insertions(+), 251 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java	Mon Sep 10 14:21:36 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java	Mon Sep 10 15:31:55 2018 +0200
@@ -18,6 +18,7 @@
 import org.dive4elements.artifactdatabase.state.FacetActivity;
 import org.dive4elements.artifacts.Artifact;
 import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.artifacts.CallMeta;
 import org.dive4elements.artifacts.common.utils.StringUtils;
 import org.dive4elements.river.artifacts.access.Calculation4Access;
 import org.dive4elements.river.artifacts.access.ComputationRangeAccess;
@@ -137,9 +138,9 @@
         return this.getWaterlevelData(null);
     }
 
-    private CalculationResult getDischargeLongitudinalSectionData() {
+    private CalculationResult getDischargeLongitudinalSectionData(final CallMeta meta) {
         // TODO: This caluclation should be cached as it is quite expensive.
-        return new Calculation4(new Calculation4Access(this)).calculate();
+        return new Calculation4(new Calculation4Access(this)).calculate(meta);
     }
 
     /**
@@ -155,7 +156,7 @@
         // If this WINFO-Artifact has a calculation trait.
         if (calculationMode != null) {
             if (calculationMode.equals("calc.discharge.longitudinal.section"))
-                return getDischargeLongitudinalSectionData();
+                return getDischargeLongitudinalSectionData(context.getMeta());
 
             if (calculationMode.equals("calc.extreme.curve"))
                 return (CalculationResult) this.compute(context, ComputeType.ADVANCE, false);
@@ -486,9 +487,9 @@
     /**
      * Get corrected waterline against surface/profile.
      */
-    private double waterLineC(final int idx, final double currentKm) {
+    private double waterLineC(final int idx, final double currentKm, final CallMeta meta) {
 
-        final WQKms[] wqckms = (WQKms[]) getDischargeLongitudinalSectionData().getData();
+        final WQKms[] wqckms = (WQKms[]) getDischargeLongitudinalSectionData(meta).getData();
 
         // Find index of km.
         final double wishKM = currentKm;
@@ -555,7 +556,7 @@
 
         if (wqkms.length <= idx) {
             log.error("getWaterLines() requested index (" + idx + " not found.");
-            return waterLineC(idx, currentKm);
+            return waterLineC(idx, currentKm, context.getMeta());
         }
 
         // Find W at km, linear naive approach.
@@ -645,16 +646,15 @@
 
             boolean generatedWs = false;
 
-            for (int i = 0; i < ws.length; ++i) {
-                final double w = ws[i];
+            for (final double w : ws) {
                 if (debug) {
                     log.debug("getQsForWs: lookup Q for W: " + w);
                 }
                 // There could be more than one Q per W.
                 final double[] qs = wst.findQsForW(km, w, report);
-                for (int j = 0; j < qs.length; ++j) {
-                    outWs.add(ws[i]);
-                    outQs.add(qs[j]);
+                for (final double element : qs) {
+                    outWs.add(w);
+                    outQs.add(element);
                 }
                 generatedWs |= qs.length != 1;
             }
@@ -694,18 +694,18 @@
 
         boolean generatedWs = false;
 
-        for (int i = 0; i < ws.length; i++) {
-            if (Double.isNaN(ws[i])) {
+        for (final double element : ws) {
+            if (Double.isNaN(element)) {
                 log.warn("W is NaN: ignored");
                 continue;
             }
-            final double[] qs = DischargeTables.getQsForW(values, ws[i]);
+            final double[] qs = DischargeTables.getQsForW(values, element);
 
             if (qs.length == 0) {
-                log.warn("No Qs found for W = " + ws[i]);
+                log.warn("No Qs found for W = " + element);
             } else {
                 for (final double q : qs) {
-                    wsOut.add(ws[i]);
+                    wsOut.add(element);
                     qsOut.add(q);
                 }
             }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculation.java	Mon Sep 10 14:21:36 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculation.java	Mon Sep 10 15:31:55 2018 +0200
@@ -161,7 +161,7 @@
         final FixRealizingAccess access = new FixRealizingAccess(bundu);
         final FixRealizingCalculation calc = new FixRealizingCalculation(access);
 
-        final CalculationResult res = calc.calculate();
+        final CalculationResult res = calc.calculate(this.context.getMeta());
 
         final FixRealizingResult fixRes = (FixRealizingResult) res.getData();
 
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/Calculation4.java	Mon Sep 10 14:21:36 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/Calculation4.java	Mon Sep 10 15:31:55 2018 +0200
@@ -8,28 +8,23 @@
 
 package org.dive4elements.river.artifacts.model;
 
-import org.dive4elements.river.artifacts.access.Calculation4Access;
-
-import org.dive4elements.river.artifacts.math.BackJumpCorrector;
-import org.dive4elements.river.artifacts.math.Function;
-import org.dive4elements.river.artifacts.math.Identity;
-import org.dive4elements.river.artifacts.math.Linear;
-
-import org.dive4elements.river.artifacts.model.WstValueTable.QPosition;
-
-import org.dive4elements.river.model.River;
-
-import org.dive4elements.river.utils.DoubleUtil;
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
 import org.apache.log4j.Logger;
+import org.dive4elements.artifacts.CallMeta;
+import org.dive4elements.river.artifacts.access.Calculation4Access;
+import org.dive4elements.river.artifacts.math.BackJumpCorrector;
+import org.dive4elements.river.artifacts.math.Function;
+import org.dive4elements.river.artifacts.math.Identity;
+import org.dive4elements.river.artifacts.math.Linear;
+import org.dive4elements.river.artifacts.model.WstValueTable.QPosition;
+import org.dive4elements.river.artifacts.resources.Resources;
+import org.dive4elements.river.model.River;
+import org.dive4elements.river.utils.DoubleUtil;
 
-public class Calculation4
-extends      Calculation
-{
+public class Calculation4 extends Calculation {
     private static Logger log = Logger.getLogger(Calculation4.class);
 
     public static final double MINIMAL_STEP_WIDTH = 1e-5;
@@ -37,20 +32,20 @@
     protected List<Segment> segments;
 
     protected boolean isQ;
-    protected double  from;
-    protected double  to;
-    protected double  step;
-    protected String  river;
+    protected double from;
+    protected double to;
+    protected double step;
+    protected String river;
 
     public Calculation4() {
     }
 
-    public Calculation4(Calculation4Access access) {
+    public Calculation4(final Calculation4Access access) {
         log.debug("Calculation4Access.cnst");
-        String        river    = access.getRiverName();
-        List<Segment> segments = access.getSegments();
-        double []     range    = access.getFromToStep();
-        boolean       isQ      = access.isQ();
+        final String river = access.getRiverName();
+        final List<Segment> segments = access.getSegments();
+        final double[] range = access.getFromToStep();
+        final boolean isQ = access.isQ();
 
         if (river == null) {
             addProblem("no.river.selected");
@@ -65,53 +60,48 @@
         }
 
         if (!hasProblems()) {
-            this.river    = river;
+            this.river = river;
             this.segments = segments;
-            this.from     = range[0];
-            this.to       = range[1];
-            this.step     = range[2];
-            this.isQ      = isQ;
+            this.from = range[0];
+            this.to = range[1];
+            this.step = range[2];
+            this.isQ = isQ;
         }
     }
 
-    public CalculationResult calculate() {
+    public CalculationResult calculate(final CallMeta meta) {
         if (hasProblems()) {
             return new CalculationResult(new WQKms[0], this);
         }
 
         WstValueTable table = null;
-        River r = RiverFactory.getRiver(river);
+        final River r = RiverFactory.getRiver(this.river);
         if (r == null) {
             addProblem("no.river.found");
-        }
-        else {
+        } else {
             table = WstValueTableFactory.getTable(r);
             if (table == null) {
                 addProblem("no.wst.for.river");
-            }
-            else {
-                Segment.setReferencePointConvertQ(segments, r, isQ, this);
+            } else {
+                Segment.setReferencePointConvertQ(this.segments, r, this.isQ, this);
             }
         }
 
-        return hasProblems()
-            ? new CalculationResult(new WQKms[0], this)
-            : innerCalculate(table);
+        return hasProblems() ? new CalculationResult(new WQKms[0], this) : innerCalculate(table, meta);
     }
 
-    protected CalculationResult innerCalculate(WstValueTable table) {
-        boolean debug = log.isDebugEnabled();
+    protected CalculationResult innerCalculate(final WstValueTable table, final CallMeta meta) {
+        final boolean debug = log.isDebugEnabled();
 
         if (debug) {
-            log.debug(
-                "calculate from " + from + " to " + to + " step " + step);
-            log.debug("# segments: " + segments.size());
-            for (Segment segment: segments) {
+            log.debug("calculate from " + this.from + " to " + this.to + " step " + this.step);
+            log.debug("# segments: " + this.segments.size());
+            for (final Segment segment : this.segments) {
                 log.debug("  " + segment);
             }
         }
 
-        int numResults = segments.get(0).values.length;
+        final int numResults = this.segments.get(0).values.length;
 
         if (numResults < 1) {
             log.debug("no values given");
@@ -119,90 +109,77 @@
             return new CalculationResult(new WQKms[0], this);
         }
 
-
-        WQKms [] results = new WQKms[numResults];
+        final WQKms[] results = new WQKms[numResults];
         for (int i = 0; i < results.length; ++i) {
             results[i] = new WQKms();
         }
 
-        if (Math.abs(step) < MINIMAL_STEP_WIDTH) {
-            step = MINIMAL_STEP_WIDTH;
-        }
-
-        if (from > to) {
-            step = -step;
+        if (Math.abs(this.step) < MINIMAL_STEP_WIDTH) {
+            this.step = MINIMAL_STEP_WIDTH;
         }
 
-        QPosition [] qPositions = new QPosition[numResults];
+        if (this.from > this.to) {
+            this.step = -this.step;
+        }
 
-        Function [] functions = new Function[numResults];
+        final QPosition[] qPositions = new QPosition[numResults];
 
-        double [] out = new double[2];
+        final Function[] functions = new Function[numResults];
 
-        Segment sentinel = new Segment(Double.MAX_VALUE);
+        final double[] out = new double[2];
+
+        final Segment sentinel = new Segment(Double.MAX_VALUE);
         Segment s1 = sentinel, s2 = sentinel;
 
-        for (double pos = from;
-             from < to ? pos <= to : pos >= to;
-             pos = DoubleUtil.round(pos + step)
-        ) {
+        for (double pos = this.from; this.from < this.to ? pos <= this.to : pos >= this.to; pos = DoubleUtil.round(pos + this.step)) {
             if (pos < s1.referencePoint || pos > s2.referencePoint) {
                 if (debug) {
                     log.debug("need to find new interval for " + pos);
                 }
                 // find new interval
-                if (pos <= segments.get(0).referencePoint) {
+                if (pos <= this.segments.get(0).referencePoint) {
                     // before first segment -> "gleichwertig"
                     if (debug) {
                         log.debug("before first segment -> gleichwertig");
                     }
-                    Segment   first  = segments.get(0);
-                    double [] values = first.values;
-                    double    refPos = first.referencePoint;
+                    final Segment first = this.segments.get(0);
+                    final double[] values = first.values;
+                    final double refPos = first.referencePoint;
                     for (int i = 0; i < qPositions.length; ++i) {
-                        qPositions[i] = table.getQPosition(
-                            refPos, values[i]);
+                        qPositions[i] = table.getQPosition(refPos, values[i]);
                     }
                     sentinel.setReferencePoint(-Double.MAX_VALUE);
                     s1 = sentinel;
-                    s2 = segments.get(0);
+                    s2 = this.segments.get(0);
                     Arrays.fill(functions, Identity.IDENTITY);
-                }
-                else if (
-                    pos >= segments.get(segments.size()-1).referencePoint
-                ) {
+                } else if (pos >= this.segments.get(this.segments.size() - 1).referencePoint) {
                     // after last segment -> "gleichwertig"
                     if (debug) {
                         log.debug("after last segment -> gleichwertig");
                     }
-                    Segment   last   = segments.get(segments.size()-1);
-                    double [] values = last.values;
-                    double    refPos = last.referencePoint;
+                    final Segment last = this.segments.get(this.segments.size() - 1);
+                    final double[] values = last.values;
+                    final double refPos = last.referencePoint;
                     for (int i = 0; i < qPositions.length; ++i) {
-                        qPositions[i] = table.getQPosition(
-                            refPos, values[i]);
+                        qPositions[i] = table.getQPosition(refPos, values[i]);
                     }
                     sentinel.setReferencePoint(Double.MAX_VALUE);
                     s1 = last;
                     s2 = sentinel;
                     Arrays.fill(functions, Identity.IDENTITY);
-                }
-                else { // "ungleichwertig"
-                    // find matching interval
+                } else { // "ungleichwertig"
+                         // find matching interval
                     if (debug) {
                         log.debug("in segments -> ungleichwertig");
                     }
                     s1 = s2 = null;
-                    for (int i = 1, N = segments.size(); i < N; ++i) {
-                        Segment si1 = segments.get(i-1);
-                        Segment si  = segments.get(i);
+                    for (int i = 1, N = this.segments.size(); i < N; ++i) {
+                        final Segment si1 = this.segments.get(i - 1);
+                        final Segment si = this.segments.get(i);
                         if (debug) {
-                            log.debug("check " + pos + " in "
-                                + si1.referencePoint + " - "
-                                + si.referencePoint);
+                            log.debug("check " + pos + " in " + si1.referencePoint + " - " + si.referencePoint);
                         }
-                        if (pos >= si1.referencePoint
-                        &&  pos <= si. referencePoint) {
+                        if (pos >= si1.referencePoint && pos <= si.referencePoint) {
                             s1 = si1;
                             s2 = si;
                             break;
@@ -215,35 +192,30 @@
 
                     Segment anchor, free;
 
-                    if (from > to) { anchor = s1; free = s2; }
-                    else           { anchor = s2; free = s1; }
+                    if (this.from > this.to) {
+                        anchor = s1;
+                        free = s2;
+                    } else {
+                        anchor = s2;
+                        free = s1;
+                    }
 
                     // build transforms based on "gleichwertiger" phase
                     for (int i = 0; i < qPositions.length; ++i) {
-                        QPosition qi = table.getQPosition(
-                            anchor.referencePoint,
-                            anchor.values[i]);
+                        final QPosition qi = table.getQPosition(anchor.referencePoint, anchor.values[i]);
 
                         if ((qPositions[i] = qi) == null) {
                             addProblem(pos, "cannot.find.q", anchor.values[i]);
                             functions[i] = Identity.IDENTITY;
-                        }
-                        else {
-                            double qA = table.getQ(qi, anchor.referencePoint);
-                            double qF = table.getQ(qi, free  .referencePoint);
+                        } else {
+                            final double qA = table.getQ(qi, anchor.referencePoint);
+                            final double qF = table.getQ(qi, free.referencePoint);
 
-                            functions[i] = Double.isNaN(qA) || Double.isNaN(qF)
-                                ? Identity.IDENTITY
-                                : new Linear(
-                                    qA, qF,
-                                    anchor.values[i], free.values[i]);
+                            functions[i] = Double.isNaN(qA) || Double.isNaN(qF) ? Identity.IDENTITY : new Linear(qA, qF, anchor.values[i], free.values[i]);
 
                             if (debug) {
-                                log.debug(
-                                    anchor.referencePoint + ": " +
-                                    qA + " -> " + functions[i].value(qA) +
-                                    " / " + free.referencePoint + ": " +
-                                    qF + " -> " + functions[i].value(qF));
+                                log.debug(anchor.referencePoint + ": " + qA + " -> " + functions[i].value(qA) + " / " + free.referencePoint + ": " + qF + " -> "
+                                        + functions[i].value(qF));
                             }
                         }
                     } // build transforms
@@ -251,7 +223,7 @@
             } // find matching interval
 
             for (int i = 0; i < qPositions.length; ++i) {
-                QPosition qPosition = qPositions[i];
+                final QPosition qPosition = qPositions[i];
 
                 if (qPosition == null) {
                     continue;
@@ -259,19 +231,19 @@
 
                 if (table.interpolate(pos, out, qPosition, functions[i])) {
                     results[i].add(out[0], out[1], pos);
-                }
-                else {
+                } else {
                     addProblem(pos, "cannot.interpolate.w.q");
                 }
             }
         }
+        final String custom = Resources.format(meta, "common.custom");
 
         // Backjump correction
         for (int i = 0; i < results.length; ++i) {
-            BackJumpCorrector bjc = new BackJumpCorrector();
+            final BackJumpCorrector bjc = new BackJumpCorrector();
 
-            double [] ws  = results[i].getWs();
-            double [] kms = results[i].getKms();
+            final double[] ws = results[i].getWs();
+            final double[] kms = results[i].getKms();
 
             if (bjc.doCorrection(kms, ws, this)) {
                 results[i] = new WQCKms(results[i], bjc.getCorrected());
@@ -280,41 +252,32 @@
 
         // Name the curves.
         for (int i = 0; i < results.length; ++i) {
-            results[i].setName(createName(i));
+            results[i].setName(createName(i, custom));
         }
 
         // Generate the "Umhuellende".
-        ConstantWQKms [] infoldings =
-            generateInfolding(table, results, from, to, step);
+        final ConstantWQKms[] infoldings = generateInfolding(table, results, this.from, this.to, this.step);
 
         // TODO: Use qkms in a new result type.
-        WQKms [] newResults = new WQKms[results.length + infoldings.length];
-        System.arraycopy(
-            results, 0, newResults, 0, results.length);
-        System.arraycopy(
-            infoldings, 0, newResults, results.length, infoldings.length);
+        final WQKms[] newResults = new WQKms[results.length + infoldings.length];
+        System.arraycopy(results, 0, newResults, 0, results.length);
+        System.arraycopy(infoldings, 0, newResults, results.length, infoldings.length);
 
         return new CalculationResult(newResults, this);
     }
 
-    protected ConstantWQKms [] generateInfolding(
-        WstValueTable wst,
-        WQKms []      results,
-        double        from,
-        double        to,
-        double        step
-    ) {
-        WstValueTable.Column [] columns = wst.getColumns();
+    protected ConstantWQKms[] generateInfolding(final WstValueTable wst, final WQKms[] results, final double from, final double to, final double step) {
+        final WstValueTable.Column[] columns = wst.getColumns();
 
-        InfoldingColumns ic = new InfoldingColumns(columns);
+        final InfoldingColumns ic = new InfoldingColumns(columns);
         ic.markInfoldingColumns(results);
 
-        List<ConstantWQKms> infoldings = new ArrayList<ConstantWQKms>();
+        final List<ConstantWQKms> infoldings = new ArrayList<>();
 
-        boolean [] infoldingColumns = ic.getInfoldingColumns();
+        final boolean[] infoldingColumns = ic.getInfoldingColumns();
 
-        double [] kms = null;
-        double [] ws  = null;
+        double[] kms = null;
+        double[] ws = null;
 
         for (int i = 0; i < infoldingColumns.length; ++i) {
             if (!infoldingColumns[i]) {
@@ -323,17 +286,16 @@
 
             if (kms == null) {
                 kms = DoubleUtil.explode(from, to, step);
-                ws  = new double[kms.length];
+                ws = new double[kms.length];
             }
 
-            QRangeTree.QuickQFinder qf =
-                columns[i].getQRangeTree().new QuickQFinder();
+            final QRangeTree.QuickQFinder qf = columns[i].getQRangeTree().new QuickQFinder();
 
-            int numProblemsBefore = numProblems();
-            double [] qs = qf.findQs(kms, this);
+            final int numProblemsBefore = numProblems();
+            final double[] qs = qf.findQs(kms, this);
 
-            String name = columns[i].getName();
-            ConstantWQKms infolding = new ConstantWQKms(kms, qs, ws, name);
+            final String name = columns[i].getName();
+            final ConstantWQKms infolding = new ConstantWQKms(kms, qs, ws, name);
 
             if (numProblems() > numProblemsBefore) {
                 infolding.removeNaNs();
@@ -343,16 +305,14 @@
         }
 
         for (int i = 0, I = infoldings.size(); i < I; i++) {
-            ConstantWQKms infolding = infoldings.get(i);
-            String name = infolding.getName();
+            final ConstantWQKms infolding = infoldings.get(i);
+            final String name = infolding.getName();
             // TODO: i18n
             if (i == 0) {
                 infolding.setName("untere Umh\u00fcllende " + name);
-            }
-            else if (i ==  I-1) {
+            } else if (i == I - 1) {
                 infolding.setName("obere Umh\u00fcllende " + name);
-            }
-            else {
+            } else {
                 infolding.setName("geschnitten " + name);
             }
         }
@@ -361,21 +321,18 @@
     }
 
     // TODO: issue1109/2, merge with FixRealizingCalculation
-    protected String createName(int index) {
-        // TODO: i18n
-        StringBuilder sb = new StringBuilder(isQ ? "Q" : "W");
-        sb.append(" benutzerdefiniert (");
-        for (int i = 0, N = segments.size(); i < N; ++i) {
+    protected String createName(final int index, final String custom) {
+
+        final StringBuilder sb = new StringBuilder(this.isQ ? "Q" : "W");
+        sb.append(" ").append(custom).append(" (");
+        for (int i = 0, N = this.segments.size(); i < N; ++i) {
             if (i > 0) {
                 sb.append("; ");
             }
-            Segment segment = segments.get(i);
-            sb.append((segment.backup != null
-                ? segment.backup
-                : segment.values)[index]);
+            final Segment segment = this.segments.get(i);
+            sb.append((segment.backup != null ? segment.backup : segment.values)[index]);
         }
         sb.append(')');
         return sb.toString();
     }
 }
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisCalculation.java	Mon Sep 10 14:21:36 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisCalculation.java	Mon Sep 10 15:31:55 2018 +0200
@@ -14,6 +14,7 @@
 
 import org.apache.commons.math.stat.descriptive.moment.StandardDeviation;
 import org.apache.log4j.Logger;
+import org.dive4elements.artifacts.CallMeta;
 import org.dive4elements.river.artifacts.access.FixAnalysisAccess;
 import org.dive4elements.river.artifacts.math.fitting.Function;
 import org.dive4elements.river.artifacts.model.CalculationResult;
@@ -65,10 +66,10 @@
     }
 
     @Override
-    public CalculationResult innerCalculate(final FixingsOverview overview, final Function func) {
+    protected CalculationResult innerCalculate(final FixingsOverview overview, final Function function, final CallMeta meta) {
         final ColumnCache cc = new ColumnCache();
 
-        final FitResult fitResult = doFitting(overview, cc, func);
+        final FitResult fitResult = doFitting(overview, cc, function);
 
         if (fitResult == null)
             return new CalculationResult(this);
@@ -78,7 +79,7 @@
         final AnalysisPeriodEventResults eventResults = new AnalysisPeriodEventResults();
         final KMIndex<AnalysisPeriod[]> kmResults = new KMIndex<>(parameters.size());
 
-        calculateAnalysisPeriods(func, parameters, overview, cc, eventResults, kmResults);
+        calculateAnalysisPeriods(function, parameters, overview, cc, eventResults, kmResults);
         eventResults.sortAll();
         kmResults.sort();
 
@@ -259,4 +260,5 @@
             kmResults.add(km, rap);
         }
     }
+
 }
\ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixCalculation.java	Mon Sep 10 14:21:36 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixCalculation.java	Mon Sep 10 15:31:55 2018 +0200
@@ -12,6 +12,7 @@
 import java.util.List;
 
 import org.apache.log4j.Logger;
+import org.dive4elements.artifacts.CallMeta;
 import org.dive4elements.artifacts.common.utils.StringUtils;
 import org.dive4elements.river.artifacts.access.FixAccess;
 import org.dive4elements.river.artifacts.math.fitting.Function;
@@ -234,7 +235,7 @@
         return new FitResult(results, resultColumns);
     }
 
-    public CalculationResult calculate() {
+    public CalculationResult calculate(final CallMeta meta) {
         final FixingsOverview overview = FixingsOverviewFactory.getOverview(this.river);
 
         if (overview == null) {
@@ -250,8 +251,8 @@
         if (hasProblems())
             return new CalculationResult(this);
 
-        return innerCalculate(overview, func);
+        return innerCalculate(overview, func, meta);
     }
 
-    protected abstract CalculationResult innerCalculate(FixingsOverview overview, Function function);
+    protected abstract CalculationResult innerCalculate(FixingsOverview overview, Function function, CallMeta meta);
 }
\ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixRealizingCalculation.java	Mon Sep 10 14:21:36 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixRealizingCalculation.java	Mon Sep 10 15:31:55 2018 +0200
@@ -10,6 +10,7 @@
 
 import java.util.List;
 
+import org.dive4elements.artifacts.CallMeta;
 import org.dive4elements.river.artifacts.access.FixRealizingAccess;
 import org.dive4elements.river.artifacts.math.fitting.Function;
 import org.dive4elements.river.artifacts.model.CalculationResult;
@@ -17,6 +18,7 @@
 import org.dive4elements.river.artifacts.model.RiverFactory;
 import org.dive4elements.river.artifacts.model.Segment;
 import org.dive4elements.river.artifacts.model.WQKms;
+import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.model.River;
 
 /** Calculation for FixRealize (german: ausgel. WSPL). */
@@ -60,7 +62,7 @@
     }
 
     @Override
-    protected CalculationResult innerCalculate(final FixingsOverview overview, final Function func) {
+    protected CalculationResult innerCalculate(final FixingsOverview overview, final Function func, final CallMeta meta) {
         final ColumnCache cc = new ColumnCache();
         final FitResult fitResult = doFitting(overview, cc, func);
 
@@ -119,8 +121,9 @@
         }
 
         // Name the curves.
+        final String custom = Resources.getMsg(meta, "common.custom");
         for (int i = 0; i < results.length; ++i)
-            results[i].setName(createName(i));
+            results[i].setName(createName(i, custom));
 
         final FixRealizingResult frr = new FixRealizingResult(parameters, fitResult.getResultColumns(), results);
 
@@ -128,10 +131,9 @@
     }
 
     // TODO: issue1109/2
-    protected String createName(final int index) {
-        // TODO: i18n
+    protected String createName(final int index, final String custom) {
         final StringBuilder sb = new StringBuilder(this.isQ ? "Q" : "W");
-        sb.append(" benutzerdefiniert (");
+        sb.append(" ").append(custom).append(" (");
         for (int i = 0, N = this.segments.size(); i < N; ++i) {
             if (i > 0) {
                 sb.append("; ");
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/DischargeLongitudinalSection.java	Mon Sep 10 14:21:36 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/DischargeLongitudinalSection.java	Mon Sep 10 15:31:55 2018 +0200
@@ -8,17 +8,16 @@
 
 package org.dive4elements.river.artifacts.states;
 
+import java.util.List;
+
+import org.apache.log4j.Logger;
 import org.dive4elements.artifactdatabase.state.Facet;
 import org.dive4elements.artifactdatabase.state.FacetActivity;
-
 import org.dive4elements.artifacts.Artifact;
 import org.dive4elements.artifacts.CallContext;
-
 import org.dive4elements.river.artifacts.ChartArtifact;
 import org.dive4elements.river.artifacts.D4EArtifact;
-
 import org.dive4elements.river.artifacts.access.Calculation4Access;
-
 import org.dive4elements.river.artifacts.model.Calculation4;
 import org.dive4elements.river.artifacts.model.CalculationResult;
 import org.dive4elements.river.artifacts.model.ConstantWQKms;
@@ -30,62 +29,41 @@
 import org.dive4elements.river.artifacts.model.WQCKms;
 import org.dive4elements.river.artifacts.model.WQKms;
 import org.dive4elements.river.artifacts.model.WaterlevelFacet;
-
-import java.util.List;
-
-import org.apache.log4j.Logger;
+import org.dive4elements.river.artifacts.resources.Resources;
 
-public class DischargeLongitudinalSection
-extends      DefaultState
-implements   FacetTypes
-{
-    private static Logger log =
-        Logger.getLogger(DischargeLongitudinalSection.class);
+public class DischargeLongitudinalSection extends DefaultState implements FacetTypes {
+    private static Logger log = Logger.getLogger(DischargeLongitudinalSection.class);
 
     static {
         // Active/deactivate facets.
-        FacetActivity.Registry.getInstance().register(
-            "winfo",
-            new FacetActivity() {
-                @Override
-                public Boolean isInitialActive(
-                    Artifact artifact,
-                    Facet    facet,
-                    String   output
-                ) {
-                    String name = facet.getName();
-                    if (name.equals(DISCHARGE_LONGITUDINAL_Q_INFOLD_CUT)) {
-                        return Boolean.FALSE;
-                    }
-                    return Boolean.TRUE;
+        FacetActivity.Registry.getInstance().register("winfo", new FacetActivity() {
+            @Override
+            public Boolean isInitialActive(final Artifact artifact, final Facet facet, final String output) {
+                final String name = facet.getName();
+                if (name.equals(DISCHARGE_LONGITUDINAL_Q_INFOLD_CUT)) {
+                    return Boolean.FALSE;
                 }
-            });
+                return Boolean.TRUE;
+            }
+        });
     }
 
     @Override
-    public Object computeAdvance(
-        D4EArtifact artifact,
-        String       hash,
-        CallContext  context,
-        List<Facet>  facets,
-        Object       old
-    ) {
+    public Object computeAdvance(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) {
         if (artifact instanceof ChartArtifact) {
             facets.add(new EmptyFacet());
             return null;
         }
 
-        Calculation4Access access = new Calculation4Access(artifact);
+        final Calculation4Access access = new Calculation4Access(artifact);
 
-        CalculationResult res = old instanceof CalculationResult
-            ? (CalculationResult)old
-            : new Calculation4(access).calculate();
+        final CalculationResult res = old instanceof CalculationResult ? (CalculationResult) old : new Calculation4(access).calculate(context.getMeta());
 
         if (facets == null) {
             return res;
         }
 
-        WQKms [] wqkms = (WQKms [])res.getData();
+        final WQKms[] wqkms = (WQKms[]) res.getData();
 
         for (int i = 0; i < wqkms.length; i++) {
             String nameW = null;
@@ -94,8 +72,7 @@
             if (access.isQ()) {
                 nameQ = wqkms[i].getName();
                 nameW = "W(" + nameQ + ")";
-            }
-            else {
+            } else {
                 nameW = wqkms[i].getName();
                 nameQ = "Q(" + nameW + ")";
             }
@@ -104,43 +81,35 @@
             // for Q only curves.
             if (!(wqkms[i] instanceof ConstantWQKms)) {
 
-                Facet w = new WaterlevelFacet(
-                    i, DISCHARGE_LONGITUDINAL_W, nameW);
+                final Facet w = new WaterlevelFacet(i, DISCHARGE_LONGITUDINAL_W, nameW);
 
-                Facet s = new CrossSectionWaterLineFacet(i, nameW, ComputeType.ADVANCE, hash, getID(), Integer.valueOf(i));
+                final Facet s = new CrossSectionWaterLineFacet(i, nameW, ComputeType.ADVANCE, hash, getID(), Integer.valueOf(i));
 
-                Facet q = new WaterlevelFacet(
-                    i, DISCHARGE_LONGITUDINAL_Q, nameQ);
+                final Facet q = new WaterlevelFacet(i, DISCHARGE_LONGITUDINAL_Q, nameQ);
                 facets.add(s);
                 facets.add(w);
                 facets.add(q);
-            }
-            else {
+            } else {
                 Facet q;
                 if (nameQ.contains("geschnitten")) {
-                    q = new WaterlevelFacet(
-                        i, DISCHARGE_LONGITUDINAL_Q_INFOLD_CUT, nameQ);
-                }
-                else {
-                    q = new WaterlevelFacet(
-                        i, DISCHARGE_LONGITUDINAL_Q_INFOLD, nameQ);
+                    q = new WaterlevelFacet(i, DISCHARGE_LONGITUDINAL_Q_INFOLD_CUT, nameQ);
+                } else {
+                    q = new WaterlevelFacet(i, DISCHARGE_LONGITUDINAL_Q_INFOLD, nameQ);
                 }
                 facets.add(q);
             }
 
+            final String custom = Resources.getMsg(context.getMeta(), "common.custom");
             if (wqkms[i] instanceof WQCKms) {
                 // TODO DO i18n
 
-                String nameC = nameW.replace(
-                    "benutzerdefiniert",
-                    "benutzerdefiniert [korrigiert]");
+                final String nameC = nameW.replace(custom, Resources.getMsg(context.getMeta(), "custom.corrected"));
 
-                Facet c = new WaterlevelFacet(
-                    i, DISCHARGE_LONGITUDINAL_C, nameC);
+                final Facet c = new WaterlevelFacet(i, DISCHARGE_LONGITUDINAL_C, nameC);
 
                 // Here, avoid index clash with Facet "s" above and
                 // signal the WINFO later that we want to access Cs.
-                Facet r = new CrossSectionWaterLineFacet(i + 1, nameC, ComputeType.ADVANCE, hash, getID(), Integer.valueOf(i + 1));
+                final Facet r = new CrossSectionWaterLineFacet(i + 1, nameC, ComputeType.ADVANCE, hash, getID(), Integer.valueOf(i + 1));
 
                 facets.add(c);
                 facets.add(r);
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixAnalysisCompute.java	Mon Sep 10 14:21:36 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixAnalysisCompute.java	Mon Sep 10 15:31:55 2018 +0200
@@ -115,7 +115,7 @@
             res = (CalculationResult) old;
         } else {
             final FixAnalysisCalculation calc = new FixAnalysisCalculation(access);
-            res = calc.calculate();
+            res = calc.calculate(context.getMeta());
         }
 
         if (facets == null) {
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixRealizingCompute.java	Mon Sep 10 14:21:36 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixRealizingCompute.java	Mon Sep 10 15:31:55 2018 +0200
@@ -69,7 +69,7 @@
             res = (CalculationResult) old;
         } else {
             final FixRealizingCalculation calc = new FixRealizingCalculation(access);
-            res = calc.calculate();
+            res = calc.calculate(context.getMeta());
         }
 
         if (facets == null) {
--- a/artifacts/src/main/resources/messages.properties	Mon Sep 10 14:21:36 2018 +0200
+++ b/artifacts/src/main/resources/messages.properties	Mon Sep 10 15:31:55 2018 +0200
@@ -1,6 +1,9 @@
 false=No
 true=Yes
 
+common.custom = custom
+custom.corrected =custom [corrected]
+
 state.winfo.river = River
 state.winfo.calculation_mode = Calculation Mode
 state.winfo.location_distance = Location or distance selection
--- a/artifacts/src/main/resources/messages_de.properties	Mon Sep 10 14:21:36 2018 +0200
+++ b/artifacts/src/main/resources/messages_de.properties	Mon Sep 10 15:31:55 2018 +0200
@@ -1,6 +1,9 @@
 false=Nein
 true=Ja
 
+common.custom = benutzerdefiniert
+custom.corrected =benutzerdefiniert [korrigiert]
+
 state.winfo.river = Gew\u00e4sser
 state.winfo.calculation_mode = Berechnungsart
 state.winfo.location_distance = Wahl des Berechnungsortes/strecke

http://dive4elements.wald.intevation.org