changeset 3178:59b14bc676ec

Fitting: Link the functions to there inverses via getInverse(). flys-artifacts/trunk@4793 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 26 Jun 2012 09:29:37 +0000
parents 585c0b49e696
children 436ab826e82b
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/FunctionFactory.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/InvLogLinear.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/InvPow.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/InvQuad.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/InvSQPow.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/LogLinear.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/Pow.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/Quad.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/SQPow.java
diffstat 10 files changed, 34 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Jun 26 06:33:37 2012 +0000
+++ b/flys-artifacts/ChangeLog	Tue Jun 26 09:29:37 2012 +0000
@@ -1,3 +1,18 @@
+2012-06-26	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/math/fitting/FunctionFactory.java:
+	  Register the singletons instead of new objects.
+	  
+	* src/main/java/de/intevation/flys/artifacts/math/fitting/Pow.java,
+	  src/main/java/de/intevation/flys/artifacts/math/fitting/InvQuad.java,
+	  src/main/java/de/intevation/flys/artifacts/math/fitting/SQPow.java,
+	  src/main/java/de/intevation/flys/artifacts/math/fitting/LogLinear.java,
+	  src/main/java/de/intevation/flys/artifacts/math/fitting/InvPow.java,
+	  src/main/java/de/intevation/flys/artifacts/math/fitting/InvSQPow.java,
+	  src/main/java/de/intevation/flys/artifacts/math/fitting/InvLogLinear.java,
+	  src/main/java/de/intevation/flys/artifacts/math/fitting/Quad.java:
+	  Link the functions to there inverses via getInverse().
+
 2012-06-26	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	Implemenation of the inverses of the fitting functions. Needed
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/FunctionFactory.java	Tue Jun 26 06:33:37 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/FunctionFactory.java	Tue Jun 26 09:29:37 2012 +0000
@@ -13,13 +13,13 @@
     private FunctionFactory() {
         functions = new LinkedHashMap<String, Function>();
 
-        registerFunction(new Log());
-        registerFunction(new Linear());
-        registerFunction(new LogLinear());
-        registerFunction(new Exp());
-        registerFunction(new Quad());
-        registerFunction(new Pow());
-        registerFunction(new SQPow());
+        registerFunction(Log.INSTANCE);
+        registerFunction(Linear.INSTANCE);
+        registerFunction(LogLinear.INSTANCE);
+        registerFunction(Exp.INSTANCE);
+        registerFunction(Quad.INSTANCE);
+        registerFunction(Pow.INSTANCE);
+        registerFunction(SQPow.INSTANCE);
     }
 
     public static synchronized FunctionFactory getInstance() {
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/InvLogLinear.java	Tue Jun 26 06:33:37 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/InvLogLinear.java	Tue Jun 26 09:29:37 2012 +0000
@@ -29,8 +29,7 @@
 
     @Override
     public Function getInverse() {
-        // TODO: Implement me!
-        return null;
+        return LogLinear.INSTANCE;
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/InvPow.java	Tue Jun 26 06:33:37 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/InvPow.java	Tue Jun 26 09:29:37 2012 +0000
@@ -29,8 +29,7 @@
 
     @Override
     public Function getInverse() {
-        // TODO: Implement me!
-        return null;
+        return Pow.INSTANCE;
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/InvQuad.java	Tue Jun 26 06:33:37 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/InvQuad.java	Tue Jun 26 09:29:37 2012 +0000
@@ -29,8 +29,7 @@
 
     @Override
     public Function getInverse() {
-        // TODO: Implement me!
-        return null;
+        return Quad.INSTANCE;
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/InvSQPow.java	Tue Jun 26 06:33:37 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/InvSQPow.java	Tue Jun 26 09:29:37 2012 +0000
@@ -29,8 +29,7 @@
 
     @Override
     public Function getInverse() {
-        // TODO: Implement me!
-        return null;
+        return SQPow.INSTANCE;
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/LogLinear.java	Tue Jun 26 06:33:37 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/LogLinear.java	Tue Jun 26 09:29:37 2012 +0000
@@ -23,6 +23,8 @@
         }
     };
 
+    public static final Function INSTANCE = new LogLinear();
+
     public LogLinear() {
         super(
             "log-linear",
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/Pow.java	Tue Jun 26 06:33:37 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/Pow.java	Tue Jun 26 09:29:37 2012 +0000
@@ -22,6 +22,8 @@
         }
     };
 
+    public static final Function INSTANCE = new Pow();
+
     public Pow() {
         super(
             "pow",
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/Quad.java	Tue Jun 26 06:33:37 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/Quad.java	Tue Jun 26 09:29:37 2012 +0000
@@ -22,6 +22,8 @@
         }
     };
 
+    public static final Function INSTANCE = new Quad();
+
     public Quad() {
         super(
             "quad",
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/SQPow.java	Tue Jun 26 06:33:37 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/SQPow.java	Tue Jun 26 09:29:37 2012 +0000
@@ -22,6 +22,8 @@
         }
     };
 
+    public static final Function INSTANCE = new SQPow();
+
     public SQPow() {
         super(
             "sq-pow",

http://dive4elements.wald.intevation.org