changeset 7792:6451970e0562 minfo-opt

Add the new difference facet and set facets active/inactive.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 06 Mar 2014 14:07:24 +0100
parents 8b95f9c4f341
children 3841303a9158
files artifacts/src/main/java/org/dive4elements/river/artifacts/states/WDifferencesState.java
diffstat 1 files changed, 54 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WDifferencesState.java	Thu Mar 06 14:04:46 2014 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WDifferencesState.java	Thu Mar 06 14:07:24 2014 +0100
@@ -14,6 +14,7 @@
 import org.apache.log4j.Logger;
 
 import org.dive4elements.artifactdatabase.state.Facet;
+import org.dive4elements.artifactdatabase.state.FacetActivity;
 import org.dive4elements.artifactdatabase.data.StateData;
 
 import org.dive4elements.artifacts.CallContext;
@@ -30,12 +31,14 @@
 import org.dive4elements.river.artifacts.model.CalculationResult;
 import org.dive4elements.river.artifacts.model.DataFacet;
 import org.dive4elements.river.artifacts.model.DifferenceCurveFacet;
+import org.dive4elements.river.artifacts.model.DifferenceCurveFilterFacet;
 import org.dive4elements.river.artifacts.model.EmptyFacet;
 import org.dive4elements.river.artifacts.model.FacetTypes;
 import org.dive4elements.river.artifacts.model.WKms;
 import org.dive4elements.river.artifacts.model.WQKms;
 
 import org.dive4elements.river.artifacts.model.fixings.FixRealizingResult;
+import org.dive4elements.river.artifacts.resources.Resources;
 
 import org.dive4elements.river.utils.RiverUtils;
 import org.dive4elements.river.utils.StringUtil;
@@ -48,6 +51,31 @@
     /** The logger that is used in this state. */
     private static Logger logger = Logger.getLogger(WDifferencesState.class);
 
+    private static final String I18N_DIFFERENCES_FACET_NAME =
+        "facet.w_differences";
+    private static final String I18N_DIFFERENCES_FACET_NAME_RAW =
+        "facet.w_differences.raw";
+
+    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(FacetTypes.W_DIFFERENCES)) {
+                        return Boolean.FALSE;
+                    }
+                    return Boolean.TRUE;
+                }
+            });
+    }
 
     /** Specify to display nothing (this is kind of a "final" state). */
     @Override
@@ -190,10 +218,13 @@
                 context);
 
             String facetName = "diff ()";
+            String minName = "min";
+            String subName = "sub";
 
             if (minuendWKms != null && subtrahendWKms != null) {
-                facetName = StringUtil.wWrap(minuendWKms.getName())
-                    + " - " + StringUtil.wWrap(subtrahendWKms.getName());
+                minName = StringUtil.wWrap(minuendWKms.getName());
+                subName = StringUtil.wWrap(subtrahendWKms.getName());
+                facetName = minName + " - " + subName;
                 WKms wkms = WKmsOperation.SUBTRACTION.operate(minuendWKms,
                      subtrahendWKms);
                 wkms.setName(facetName);
@@ -201,8 +232,27 @@
                 logger.debug("WKMSSubtraction happened");
             }
             if (facets != null) {
-                facets.add(new DifferenceCurveFacet(i/2, W_DIFFERENCES, facetName,
-                    ComputeType.ADVANCE, id, hash));
+                facets.add(new DifferenceCurveFacet(
+                    i/2,
+                    W_DIFFERENCES,
+                    Resources.getMsg(
+                        context.getMeta(),
+                        I18N_DIFFERENCES_FACET_NAME_RAW,
+                        facetName,
+                        new Object[] { minName, subName }),
+                    ComputeType.ADVANCE,
+                    id,
+                    hash));
+                facets.add(new DifferenceCurveFilterFacet(i/2,
+                    W_DIFFERENCES_FILTERED,
+                    Resources.getMsg(
+                        context.getMeta(),
+                        I18N_DIFFERENCES_FACET_NAME,
+                        facetName,
+                        new Object[] { minName, subName }),
+                    ComputeType.ADVANCE,
+                    id,
+                    hash));
             }
         }
 

http://dive4elements.wald.intevation.org