Isis-fish-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
June 2011
- 3 participants
- 85 discussions
r3350 - in isis-fish/branches/3.3.1/src/main: java/fr/ifremer/isisfish java/fr/ifremer/isisfish/mexico/xml java/fr/ifremer/isisfish/simulator/launcher java/fr/ifremer/isisfish/simulator/sensitivity java/fr/ifremer/isisfish/simulator/sensitivity/domain java/fr/ifremer/isisfish/ui/sensitivity java/fr/ifremer/isisfish/ui/simulator resources/i18n
by jcouteau@users.labs.libre-entreprise.org 06 Jun '11
by jcouteau@users.labs.libre-entreprise.org 06 Jun '11
06 Jun '11
Author: jcouteau
Date: 2011-06-06 15:12:08 +0000 (Mon, 06 Jun 2011)
New Revision: 3350
Log:
- Remove autocomplete
- Clean factors and domains and everything that comes with it
- Clean some code
Modified:
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/IsisFish.java
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/DomXMLParser.java
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/EquationContinuousDomainXMLVisitor.java
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/FactorXMLVisitor.java
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/MatrixContinuousDomainXMLVisitor.java
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationService.java
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/AbstractSensitivityCalculator.java
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/Factor.java
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/SensitivityCalculator.java
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/domain/ContinuousDomain.java
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/domain/EquationContinuousDomain.java
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/domain/MatrixContinuousDomain.java
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/EquationContinuousPanelUI.jaxx
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
isis-fish/branches/3.3.1/src/main/resources/i18n/isis-fish_en_GB.properties
isis-fish/branches/3.3.1/src/main/resources/i18n/isis-fish_fr_FR.properties
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/IsisFish.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/IsisFish.java 2011-06-06 14:14:32 UTC (rev 3349)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/IsisFish.java 2011-06-06 15:12:08 UTC (rev 3350)
@@ -36,7 +36,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
@@ -53,11 +52,6 @@
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.fife.rsta.ac.LanguageSupport;
-import org.fife.rsta.ac.LanguageSupportFactory;
-import org.fife.rsta.ac.java.JarInfo;
-import org.fife.rsta.ac.java.JavaLanguageSupport;
-import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
import org.nuiton.i18n.I18n;
import org.nuiton.i18n.init.ClassPathI18nInitializer;
import org.nuiton.math.matrix.DoubleBigVector;
@@ -86,7 +80,6 @@
import fr.ifremer.isisfish.types.TimeUnit;
import fr.ifremer.isisfish.ui.WelcomeUI;
import fr.ifremer.isisfish.ui.util.ErrorHelper;
-import fr.ifremer.isisfish.util.CompileHelper;
import fr.ifremer.isisfish.util.ConverterUtil;
import fr.ifremer.isisfish.util.DateConverter;
import fr.ifremer.isisfish.util.MonthConverter;
@@ -206,7 +199,7 @@
filesToMigrate.putAll(FileUtil.grep("org\\.codelutin\\.", folder, ".*\\.java", "ISO-8859-1"));
}
- if (filesToMigrate != null && !filesToMigrate.isEmpty()) {
+ if (!filesToMigrate.isEmpty()) {
// yes by defaut (for tests)
// but ask user if UI launch
@@ -383,12 +376,11 @@
* @return true if user confirm question
*/
protected static boolean ask(Object msg) {
- boolean result = true;
int value = JOptionPane.showConfirmDialog(null, msg);
if (value == JOptionPane.CANCEL_OPTION) {
quit();
}
- result = value == JOptionPane.YES_OPTION;
+ boolean result = value == JOptionPane.YES_OPTION;
return result;
}
@@ -508,7 +500,7 @@
// il est possiblement obligatoire de ne plus etre sur le trunk, ou
// de migrer sur un autre tag
- List<File> filesInClonflict = null;
+ List<File> filesInClonflict;
// si on est sur une branche, on est en developpement, on ne fait donc rien
if (vcs.getTag().startsWith("branches")) {
@@ -703,44 +695,5 @@
// par defaut on utilise des doubles pour les matrices
MatrixFactory.setDefaultVectorClass(DoubleBigVector.class);
}
-
- /**
- * Ajout les bons jar et sources au support de language
- * de rSyntaxTextArea pour avoir un meilleur support.
- *
- * Doit être fait avant l'instanciation de l'editor rSyntaxTextArea.
- *
- * @param config config
- */
- protected static void initRSyntaxJavaSupport(IsisConfig config) {
- // TODO: This API will change! It will be easier to do per-editor
- // changes to the build path.
- LanguageSupportFactory lsf = LanguageSupportFactory.get();
- LanguageSupport support = lsf.getSupportFor(SyntaxConstants.SYNTAX_STYLE_JAVA);
- JavaLanguageSupport jls = (JavaLanguageSupport)support;
- try {
- // system JRE
- jls.getJarManager().addJar(null);
-
- // ajout des scripts utilisateur dans le lots
- JarInfo ji = new JarInfo(config.getCompileDirectory());
- ji.setSourceLocation(config.getDatabaseDirectory());
- jls.getJarManager().addJar(ji);
-
- // Ajout des jars
- String paths = CompileHelper.getClassPathAsString(Collections.EMPTY_LIST);
- for (String path : paths.split(File.pathSeparator)) {
- File filePath = new File(path);
- if (filePath.isFile()) { // bug avec les directory
- JarInfo ji2 = new JarInfo(filePath);
- jls.getJarManager().addJar(ji2);
- }
- }
- } catch (Exception ex) {
- if (log.isWarnEnabled()) {
- log.warn("Can't install Java support", ex);
- }
- }
- }
} // IsisFish
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/DomXMLParser.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/DomXMLParser.java 2011-06-06 14:14:32 UTC (rev 3349)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/DomXMLParser.java 2011-06-06 15:12:08 UTC (rev 3350)
@@ -57,6 +57,33 @@
*/
public class DomXMLParser {
+ public static final String DISCRETE = "discrete";
+ public static final String ENUMERATION = "enumeration";
+ public static final String DOMAIN = "domain";
+ public static final String FIXED = "fixed";
+ public static final String VALUE = "value";
+ public static final String RULE = "rule";
+ public static final String RULES = "rules";
+ public static final String VERSION = "version";
+ public static final String NAME = "name";
+ public static final String TYPE = "type";
+ public static final String PROPERTY = "property";
+ public static final String TARGET = "target";
+ public static final String CONTINUOUS = "continuous";
+ public static final String MATRIXCONTINUOUS = "matrixcontinuous";
+ public static final String COEFFICIENT = "coefficient";
+ public static final String EQUATIONCONTINUOUS = "equationcontinuous";
+ public static final String EQUATION = "equation";
+ public static final String VARIABLE = "variable";
+ public static final String PERCENTAGE = "percentage";
+ public static final String REFERENCE = "reference";
+ public static final String RANGE = "range";
+ public static final String MIN = "min";
+ public static final String MAX = "max";
+ public static final String CARDINALITY = "cardinality";
+ public static final String INTEGER = "integer";
+ public static final String MX = "mx";
+
/**
* Parse element root node as Design plan.
*
@@ -69,7 +96,7 @@
DesignPlan plan = new DesignPlan();
// could return "2" or null
- String version = rootElement.attributeValue("version");
+ String version = rootElement.attributeValue(VERSION);
List<Element> factorGroupElements = rootElement.selectNodes("child::factors");
FactorGroup factorGroup = null;
@@ -91,11 +118,8 @@
*
* @param fgElement factor group element (>factors<)
* @param topiaContext context
- * @param mixed {@code true} if create factor group need to be mixed
* @return factor group
- *
- * @see FactorGroup#isMixed()
- *
+ *
* @deprecated since 3.4.0.0, this parsing method parse experimentalDesign
* in version "0" or "null" version, don't remove for
* data reading purpose, but could be removed in a future version
@@ -103,7 +127,7 @@
@Deprecated
protected static FactorGroup parseFactorGroup(Element fgElement, TopiaContext topiaContext) {
- String factorGroupName = fgElement.attributeValue("name");
+ String factorGroupName = fgElement.attributeValue(NAME);
FactorGroup factorGroup = new FactorGroup(factorGroupName);
// sub factor group
@@ -117,43 +141,43 @@
List<Element> factorElements = fgElement.selectNodes("child::factor");
for (Element factorElement : factorElements) {
- String type = factorElement.attributeValue("type");
- String name = factorElement.attributeValue("name");
- String property = factorElement.attributeValue("property");
- String path = factorElement.element("target").getText().trim();
+ String type = factorElement.attributeValue(TYPE);
+ String name = factorElement.attributeValue(NAME);
+ String property = factorElement.attributeValue(PROPERTY);
+ String path = factorElement.element(TARGET).getText().trim();
// double
if ("real".equals(type)) {
Factor factor = new Factor(name);
factor.setPath(path);
- Element fixedElement = factorElement.element("domain").element("fixed");
+ Element fixedElement = factorElement.element(DOMAIN).element(FIXED);
// tous les domaines continues
- if (property.endsWith("continuous")) {
+ if (property.endsWith(CONTINUOUS)) {
ContinuousDomain domain;
- if(property.equals("matrixcontinuous")) {
+ if(property.equals(MATRIXCONTINUOUS)) {
// matrix specific
// <coefficient operator="-" value="0.799"/>
MatrixContinuousDomain mdomain = new MatrixContinuousDomain();
- Element coefficientElement = fixedElement.element("coefficient");
- mdomain.setCoefficient(Double.valueOf(coefficientElement.attributeValue("value")));
+ Element coefficientElement = fixedElement.element(COEFFICIENT);
+ mdomain.setCoefficient(Double.valueOf(coefficientElement.attributeValue(VALUE)));
// <mx name="test1" step="0">...
- Element matrixElement = fixedElement.element("mx");
+ Element matrixElement = fixedElement.element(MX);
MatrixND matrix = MexicoHelper.getMatrixFromXml(matrixElement, topiaContext);
- mdomain.setMatrix(matrix);
+ mdomain.setReferenceValue(matrix);
domain = mdomain;
}
- else if (property.equals("equationcontinuous")) {
+ else if (property.equals(EQUATIONCONTINUOUS)) {
// equation specific
EquationContinuousDomain edomain = new EquationContinuousDomain();
- Element coefficientElement = fixedElement.element("coefficient");
- edomain.setCoefficient(Double.valueOf(coefficientElement.attributeValue("value")));
+ Element coefficientElement = fixedElement.element(COEFFICIENT);
+ edomain.setCoefficient(Double.valueOf(coefficientElement.attributeValue(VALUE)));
- Element equationElement = fixedElement.element("equation");
- edomain.setReferenceValue(Double.valueOf(equationElement.attributeValue("reference")));
- edomain.setVariableName(equationElement.attributeValue("variable"));
+ Element equationElement = fixedElement.element(EQUATION);
+ edomain.setReferenceValue(Double.valueOf(equationElement.attributeValue(REFERENCE)));
+ edomain.setVariableName(equationElement.attributeValue(VARIABLE));
domain = edomain;
}
@@ -161,67 +185,67 @@
// continous domain
domain = new ContinuousDomain();
- Element percentageElement = fixedElement.element("percentage");
+ Element percentageElement = fixedElement.element(PERCENTAGE);
if (percentageElement != null) {
- domain.setCoefficient(Double.valueOf(percentageElement.attributeValue("coefficient")));
- domain.setReferenceValue(Double.valueOf(percentageElement.attributeValue("reference")));
+ domain.setCoefficient(Double.valueOf(percentageElement.attributeValue(COEFFICIENT)));
+ domain.setReferenceValue(Double.valueOf(percentageElement.attributeValue(REFERENCE)));
}
else {
// <range max="1.0" min="0.0"/>
- Element rangeElement = fixedElement.element("range");
- domain.setMinBound(Double.valueOf(rangeElement.attributeValue("min")));
- domain.setMaxBound(Double.valueOf(rangeElement.attributeValue("max")));
+ Element rangeElement = fixedElement.element(RANGE);
+ domain.setMinBound(Double.valueOf(rangeElement.attributeValue(MIN)));
+ domain.setMaxBound(Double.valueOf(rangeElement.attributeValue(MAX)));
}
}
- domain.setCardinality(Integer.valueOf(fixedElement.attributeValue("cardinality")));
+ domain.setCardinality(Integer.valueOf(fixedElement.attributeValue(CARDINALITY)));
factor.setDomain(domain);
- } else if ("discrete".equals(property)) {
+ } else if (DISCRETE.equals(property)) {
DiscreteDomain domain = new DiscreteDomain();
List<Element> valueElements = fixedElement.element(
- "enumeration").elements("value");
+ ENUMERATION).elements(VALUE);
int label = 0;
for (Element valueElement : valueElements) {
- domain.getValues().put(Integer.valueOf(label),
+ domain.getValues().put(label,
Double.valueOf(valueElement.getTextTrim()));
++label;
}
factor.setDomain(domain);
}
factorGroup.addFactor(factor);
- } else if ("integer".equals(type)) {
+ } else if (INTEGER.equals(type)) {
Factor factor = new Factor(name);
factor.setPath(path);
- Element fixedElement = factorElement.element("domain").element("fixed");
- if ("continuous".equals(property)) {
- ContinuousDomain domain = null;
+ Element fixedElement = factorElement.element(DOMAIN).element(FIXED);
+ if (CONTINUOUS.equals(property)) {
+ ContinuousDomain domain;
- if(property.equals("matrixcontinuous")) {
+ if(property.equals(MATRIXCONTINUOUS)) {
// matrix specific
MatrixContinuousDomain mdomain = new MatrixContinuousDomain();
- Element coefficientElement = fixedElement.element("coefficient");
- mdomain.setCoefficient(Double.valueOf(coefficientElement.attributeValue("value")));
+ Element coefficientElement = fixedElement.element(COEFFICIENT);
+ mdomain.setCoefficient(Double.valueOf(coefficientElement.attributeValue(VALUE)));
// matrix specific
- Element matrixElement = fixedElement.element("mx");
+ Element matrixElement = fixedElement.element(MX);
MatrixND matrix = MexicoHelper.getMatrixFromXml(matrixElement, topiaContext);
- mdomain.setMatrix(matrix);
+ mdomain.setReferenceValue(matrix);
domain = mdomain;
}
- else if (property.equals("equationcontinuous")) {
+ else if (property.equals(EQUATIONCONTINUOUS)) {
// equation specific
EquationContinuousDomain edomain = new EquationContinuousDomain();
- Element coefficientElement = fixedElement.element("coefficient");
- edomain.setCoefficient(Double.valueOf(coefficientElement.attributeValue("value")));
+ Element coefficientElement = fixedElement.element(COEFFICIENT);
+ edomain.setCoefficient(Double.valueOf(coefficientElement.attributeValue(VALUE)));
- Element equationElement = fixedElement.element("equation");
- edomain.setReferenceValue(Double.valueOf(equationElement.attributeValue("reference")));
- edomain.setVariableName(equationElement.attributeValue("variable"));
+ Element equationElement = fixedElement.element(EQUATION);
+ edomain.setReferenceValue(Double.valueOf(equationElement.attributeValue(REFERENCE)));
+ edomain.setVariableName(equationElement.attributeValue(VARIABLE));
domain = edomain;
}
@@ -229,48 +253,48 @@
// continous domain
domain = new ContinuousDomain();
- Element percentageElement = fixedElement.element("percentage");
+ Element percentageElement = fixedElement.element(PERCENTAGE);
if (percentageElement != null) {
- domain.setCoefficient(Double.valueOf(percentageElement.attributeValue("coefficient")));
- domain.setReferenceValue(Double.valueOf(percentageElement.attributeValue("reference")));
+ domain.setCoefficient(Double.valueOf(percentageElement.attributeValue(COEFFICIENT)));
+ domain.setReferenceValue(Double.valueOf(percentageElement.attributeValue(REFERENCE)));
}
else {
// <range max="1" min="3"/>
- Element rangeElement = fixedElement.element("range");
- domain.setMinBound(Integer.valueOf(rangeElement.attributeValue("min")));
- domain.setMaxBound(Integer.valueOf(rangeElement.attributeValue("max")));
+ Element rangeElement = fixedElement.element(RANGE);
+ domain.setMinBound(Integer.valueOf(rangeElement.attributeValue(MIN)));
+ domain.setMaxBound(Integer.valueOf(rangeElement.attributeValue(MAX)));
}
}
- domain.setCardinality(Integer.valueOf(fixedElement.attributeValue("cardinality")));
+ domain.setCardinality(Integer.valueOf(fixedElement.attributeValue(CARDINALITY)));
factor.setDomain(domain);
- } else if ("discrete".equals(property)) {
+ } else if (DISCRETE.equals(property)) {
DiscreteDomain domain = new DiscreteDomain();
List<Element> valueElements = fixedElement.element(
- "enumeration").elements("value");
+ ENUMERATION).elements(VALUE);
int label = 0;
for (Element valueElement : valueElements) {
- domain.getValues().put(Integer.valueOf(label),
+ domain.getValues().put(label,
Integer.valueOf(valueElement.getTextTrim()));
++label;
}
factor.setDomain(domain);
}
factorGroup.addFactor(factor);
- } else if ("rule".equals(type)) {
+ } else if (RULE.equals(type)) {
Factor factor = new Factor(name);
factor.setPath(path);
- Element fixedElement = factorElement.element("domain").element("fixed");
- if ("discrete".equals(property)) {
+ Element fixedElement = factorElement.element(DOMAIN).element(FIXED);
+ if (DISCRETE.equals(property)) {
RuleDiscreteDomain domain = new RuleDiscreteDomain();
- List<Element> valueElements = fixedElement.element("enumeration").elements("value");
+ List<Element> valueElements = fixedElement.element(ENUMERATION).elements(VALUE);
int label = 0;
for (Element valueElement : valueElements) {
- Element rulesElement = valueElement.element("rules");
+ Element rulesElement = valueElement.element(RULES);
List<Rule> rulesValue = MexicoHelper.getRulesFromXml(rulesElement, topiaContext);
- domain.getValues().put(Integer.valueOf(label), rulesValue);
+ domain.getValues().put(label, rulesValue);
++label;
}
factor.setDomain(domain);
@@ -290,14 +314,11 @@
*
* @param fgElement factor group element (>factors<)
* @param topiaContext context
- * @param mixed {@code true} if create factor group need to be mixed
* @return factor group
- *
- * @see FactorGroup#isMixed()
*/
protected static FactorGroup parseFactorGroupV2(Element fgElement, TopiaContext topiaContext) {
- String factorGroupName = fgElement.attributeValue("name");
+ String factorGroupName = fgElement.attributeValue(NAME);
FactorGroup factorGroup = new FactorGroup(factorGroupName);
// sub factor group
@@ -311,58 +332,58 @@
List<Element> factorElements = fgElement.selectNodes("child::factor");
for (Element factorElement : factorElements) {
- String type = factorElement.attributeValue("type");
- String name = factorElement.attributeValue("name");
- String property = factorElement.attributeValue("property");
- String path = factorElement.element("target").getText().trim();
+ String type = factorElement.attributeValue(TYPE);
+ String name = factorElement.attributeValue(NAME);
+ String property = factorElement.attributeValue(PROPERTY);
+ String path = factorElement.element(TARGET).getText().trim();
// double
if ("real".equals(type)) {
Factor factor = new Factor(name);
factor.setPath(path);
- Element fixedElement = factorElement.element("domain").element("fixed");
+ Element fixedElement = factorElement.element(DOMAIN).element(FIXED);
// tous les domaines continues
- if (property.endsWith("continuous")) {
+ if (property.endsWith(CONTINUOUS)) {
ContinuousDomain domain;
- if(property.equals("matrixcontinuous")) {
+ if(property.equals(MATRIXCONTINUOUS)) {
MatrixContinuousDomain mdomain = new MatrixContinuousDomain();
- Element referenceElement = fixedElement.element("reference");
+ Element referenceElement = fixedElement.element(REFERENCE);
if (referenceElement != null) {
// matrix specific
// <coefficient operator="-" value="0.799"/>
- mdomain.setCoefficient(Double.valueOf(referenceElement.attributeValue("coefficient")));
+ mdomain.setCoefficient(Double.valueOf(referenceElement.attributeValue(COEFFICIENT)));
// <mx name="test1" step="0">...
- Element matrixElement = referenceElement.element("mx");
+ Element matrixElement = referenceElement.element(MX);
MatrixND matrix = MexicoHelper.getMatrixFromXml(matrixElement, topiaContext);
- mdomain.setMatrix(matrix);
+ mdomain.setReferenceValue(matrix);
}
else {
- Element rangeElement = fixedElement.element("range");
- Element minElement = rangeElement.element("min");
- Element maxElement = rangeElement.element("max");
- MatrixND minMatrix = MexicoHelper.getMatrixFromXml(minElement.element("mx"), topiaContext);
- MatrixND maxMatrix = MexicoHelper.getMatrixFromXml(maxElement.element("mx"), topiaContext);
+ Element rangeElement = fixedElement.element(RANGE);
+ Element minElement = rangeElement.element(MIN);
+ Element maxElement = rangeElement.element(MAX);
+ MatrixND minMatrix = MexicoHelper.getMatrixFromXml(minElement.element(MX), topiaContext);
+ MatrixND maxMatrix = MexicoHelper.getMatrixFromXml(maxElement.element(MX), topiaContext);
mdomain.setMinBound(minMatrix);
mdomain.setMaxBound(maxMatrix);
}
domain = mdomain;
}
- else if (property.equals("equationcontinuous")) {
+ else if (property.equals(EQUATIONCONTINUOUS)) {
// equation specific
EquationContinuousDomain edomain = new EquationContinuousDomain();
- edomain.setVariableName(fixedElement.attributeValue("variable"));
- Element referenceElement = fixedElement.element("reference");
+ edomain.setVariableName(fixedElement.attributeValue(VARIABLE));
+ Element referenceElement = fixedElement.element(REFERENCE);
if (referenceElement != null) {
- edomain.setCoefficient(Double.valueOf(referenceElement.attributeValue("coefficient")));
+ edomain.setCoefficient(Double.valueOf(referenceElement.attributeValue(COEFFICIENT)));
edomain.setReferenceValue(Double.valueOf(referenceElement.getTextTrim()));
}
else {
- Element rangeElement = fixedElement.element("range");
- Element minElement = rangeElement.element("min");
- Element maxElement = rangeElement.element("max");
+ Element rangeElement = fixedElement.element(RANGE);
+ Element minElement = rangeElement.element(MIN);
+ Element maxElement = rangeElement.element(MAX);
edomain.setMinBound(Double.valueOf(minElement.getTextTrim()));
edomain.setMaxBound(Double.valueOf(maxElement.getTextTrim()));
}
@@ -373,82 +394,82 @@
// continous domain
domain = new ContinuousDomain();
- Element referenceElement = fixedElement.element("reference");
+ Element referenceElement = fixedElement.element(REFERENCE);
if (referenceElement != null) {
- domain.setCoefficient(Double.valueOf(referenceElement.attributeValue("coefficient")));
+ domain.setCoefficient(Double.valueOf(referenceElement.attributeValue(COEFFICIENT)));
domain.setReferenceValue(Double.valueOf(referenceElement.getTextTrim()));
}
else {
// <range max="1.0" min="0.0"/>
- Element rangeElement = fixedElement.element("range");
- Element minElement = rangeElement.element("min");
- Element maxElement = rangeElement.element("max");
+ Element rangeElement = fixedElement.element(RANGE);
+ Element minElement = rangeElement.element(MIN);
+ Element maxElement = rangeElement.element(MAX);
domain.setMinBound(Double.valueOf(minElement.getTextTrim()));
domain.setMaxBound(Double.valueOf(maxElement.getTextTrim()));
}
}
- domain.setCardinality(Integer.valueOf(fixedElement.attributeValue("cardinality")));
+ domain.setCardinality(Integer.valueOf(fixedElement.attributeValue(CARDINALITY)));
factor.setDomain(domain);
- } else if ("discrete".equals(property)) {
+ } else if (DISCRETE.equals(property)) {
DiscreteDomain domain = new DiscreteDomain();
List<Element> valueElements = fixedElement.element(
- "enumeration").elements("value");
+ ENUMERATION).elements(VALUE);
int label = 0;
for (Element valueElement : valueElements) {
- domain.getValues().put(Integer.valueOf(label),
+ domain.getValues().put(label,
Double.valueOf(valueElement.getTextTrim()));
++label;
}
factor.setDomain(domain);
}
factorGroup.addFactor(factor);
- } else if ("integer".equals(type)) {
+ } else if (INTEGER.equals(type)) {
Factor factor = new Factor(name);
factor.setPath(path);
- Element fixedElement = factorElement.element("domain").element("fixed");
- if ("continuous".equals(property)) {
+ Element fixedElement = factorElement.element(DOMAIN).element(FIXED);
+ if (CONTINUOUS.equals(property)) {
ContinuousDomain domain = null;
- if(property.equals("matrixcontinuous")) {
+ if(property.equals(MATRIXCONTINUOUS)) {
MatrixContinuousDomain mdomain = new MatrixContinuousDomain();
- Element referenceElement = fixedElement.element("reference");
+ Element referenceElement = fixedElement.element(REFERENCE);
if (referenceElement != null) {
// matrix specific
// <coefficient operator="-" value="0.799"/>
- mdomain.setCoefficient(Double.valueOf(referenceElement.attributeValue("coefficient")));
+ mdomain.setCoefficient(Double.valueOf(referenceElement.attributeValue(COEFFICIENT)));
// <mx name="test1" step="0">...
- Element matrixElement = referenceElement.element("mx");
+ Element matrixElement = referenceElement.element(MX);
MatrixND matrix = MexicoHelper.getMatrixFromXml(matrixElement, topiaContext);
- mdomain.setMatrix(matrix);
+ mdomain.setReferenceValue(matrix);
}
else {
- Element rangeElement = fixedElement.element("range");
- Element minElement = rangeElement.element("min");
- Element maxElement = rangeElement.element("max");
- MatrixND minMatrix = MexicoHelper.getMatrixFromXml(minElement.element("mx"), topiaContext);
- MatrixND maxMatrix = MexicoHelper.getMatrixFromXml(maxElement.element("mx"), topiaContext);
+ Element rangeElement = fixedElement.element(RANGE);
+ Element minElement = rangeElement.element(MIN);
+ Element maxElement = rangeElement.element(MAX);
+ MatrixND minMatrix = MexicoHelper.getMatrixFromXml(minElement.element(MX), topiaContext);
+ MatrixND maxMatrix = MexicoHelper.getMatrixFromXml(maxElement.element(MX), topiaContext);
mdomain.setMinBound(minMatrix);
mdomain.setMaxBound(maxMatrix);
}
domain = mdomain;
}
- else if (property.equals("equationcontinuous")) {
+ else if (property.equals(EQUATIONCONTINUOUS)) {
// equation specific
EquationContinuousDomain edomain = new EquationContinuousDomain();
- edomain.setVariableName(fixedElement.attributeValue("variable"));
- Element referenceElement = fixedElement.element("reference");
+ edomain.setVariableName(fixedElement.attributeValue(VARIABLE));
+ Element referenceElement = fixedElement.element(REFERENCE);
if (referenceElement != null) {
- edomain.setCoefficient(Double.valueOf(referenceElement.attributeValue("coefficient")));
+ edomain.setCoefficient(Double.valueOf(referenceElement.attributeValue(COEFFICIENT)));
edomain.setReferenceValue(Double.valueOf(referenceElement.getTextTrim()));
}
else {
- Element rangeElement = fixedElement.element("range");
- Element minElement = rangeElement.element("min");
- Element maxElement = rangeElement.element("max");
+ Element rangeElement = fixedElement.element(RANGE);
+ Element minElement = rangeElement.element(MIN);
+ Element maxElement = rangeElement.element(MAX);
edomain.setMinBound(Double.valueOf(minElement.getTextTrim()));
edomain.setMaxBound(Double.valueOf(maxElement.getTextTrim()));
}
@@ -459,65 +480,65 @@
// continous domain
domain = new ContinuousDomain();
- Element referenceElement = fixedElement.element("reference");
+ Element referenceElement = fixedElement.element(REFERENCE);
if (referenceElement != null) {
- domain.setCoefficient(Double.valueOf(referenceElement.attributeValue("coefficient")));
+ domain.setCoefficient(Double.valueOf(referenceElement.attributeValue(COEFFICIENT)));
domain.setReferenceValue(Double.valueOf(referenceElement.getTextTrim()));
}
else {
// <range max="1.0" min="0.0"/>
- Element rangeElement = fixedElement.element("range");
- Element minElement = rangeElement.element("min");
- Element maxElement = rangeElement.element("max");
+ Element rangeElement = fixedElement.element(RANGE);
+ Element minElement = rangeElement.element(MIN);
+ Element maxElement = rangeElement.element(MAX);
domain.setMinBound(Integer.valueOf(minElement.getTextTrim()));
domain.setMaxBound(Integer.valueOf(maxElement.getTextTrim()));
}
}
- domain.setCardinality(Integer.valueOf(fixedElement.attributeValue("cardinality")));
+ domain.setCardinality(Integer.valueOf(fixedElement.attributeValue(CARDINALITY)));
factor.setDomain(domain);
- } else if ("discrete".equals(property)) {
+ } else if (DISCRETE.equals(property)) {
DiscreteDomain domain = new DiscreteDomain();
List<Element> valueElements = fixedElement.element(
- "enumeration").elements("value");
+ ENUMERATION).elements(VALUE);
int label = 0;
for (Element valueElement : valueElements) {
- domain.getValues().put(Integer.valueOf(label),
+ domain.getValues().put(label,
Integer.valueOf(valueElement.getTextTrim()));
++label;
}
factor.setDomain(domain);
}
factorGroup.addFactor(factor);
- } else if ("rule".equals(type)) {
+ } else if (RULE.equals(type)) {
Factor factor = new Factor(name);
factor.setPath(path);
- Element fixedElement = factorElement.element("domain").element("fixed");
- if ("discrete".equals(property)) {
+ Element fixedElement = factorElement.element(DOMAIN).element(FIXED);
+ if (DISCRETE.equals(property)) {
RuleDiscreteDomain domain = new RuleDiscreteDomain();
- List<Element> valueElements = fixedElement.element("enumeration").elements("value");
+ List<Element> valueElements = fixedElement.element(ENUMERATION).elements(VALUE);
int label = 0;
for (Element valueElement : valueElements) {
- Element rulesElement = valueElement.element("rules");
+ Element rulesElement = valueElement.element(RULES);
List<Rule> rulesValue = MexicoHelper.getRulesFromXml(rulesElement, topiaContext);
- domain.getValues().put(Integer.valueOf(label), rulesValue);
+ domain.getValues().put(label, rulesValue);
++label;
}
factor.setDomain(domain);
}
factorGroup.addFactor(factor);
- } else if ("equation".equals(type)) {
+ } else if (EQUATION.equals(type)) {
Factor factor = new Factor(name);
factor.setPath(path);
- Element fixedElement = factorElement.element("domain").element("fixed");
- if ("discrete".equals(property)) {
+ Element fixedElement = factorElement.element(DOMAIN).element(FIXED);
+ if (DISCRETE.equals(property)) {
EquationDiscreteDomain domain = new EquationDiscreteDomain();
- List<Element> valueElements = fixedElement.element("enumeration").elements("value");
+ List<Element> valueElements = fixedElement.element(ENUMERATION).elements(VALUE);
int label = 0;
for (Element valueElement : valueElements) {
String content = StringEscapeUtils.unescapeXml(valueElement.getText());
- domain.getValues().put(Integer.valueOf(label), content);
+ domain.getValues().put(label, content);
++label;
}
factor.setDomain(domain);
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/EquationContinuousDomainXMLVisitor.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/EquationContinuousDomainXMLVisitor.java 2011-06-06 14:14:32 UTC (rev 3349)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/EquationContinuousDomainXMLVisitor.java 2011-06-06 15:12:08 UTC (rev 3350)
@@ -50,7 +50,11 @@
EquationContinuousDomain eDomain = (EquationContinuousDomain)domain;
// this version add variable name
- xmlBuffer.append(" cardinality=\"" + eDomain.getCardinality() + "\" variable=\"" + eDomain.getVariableName()+ "\">");
+ xmlBuffer.append(" cardinality=\"")
+ .append(eDomain.getCardinality())
+ .append("\" variable=\"")
+ .append(eDomain.getVariableName())
+ .append("\">");
appendDomain(eDomain);
}
@@ -65,15 +69,21 @@
// facteur continue pourcentage
if (domain.getCoefficient() != null || domain.getReferenceValue() != null) {
- xmlBuffer.append("<reference coefficient=\"" + eDomain.getCoefficient() + "\">");
+ xmlBuffer.append("<reference coefficient=\"")
+ .append(eDomain.getCoefficient())
+ .append( "\">");
xmlBuffer.append(eDomain.getReferenceValue());
xmlBuffer.append("</reference>");
}
else {
// facteur continue min/max
xmlBuffer.append("<range>");
- xmlBuffer.append("<min>" + domain.getOriginalMinBound() + "</min>");
- xmlBuffer.append("<max>" + domain.getOriginalMaxBound() + "</max>");
+ xmlBuffer.append("<min>")
+ .append(domain.getMinBound())
+ .append("</min>");
+ xmlBuffer.append("<max>")
+ .append(domain.getMaxBound())
+ .append("</max>");
xmlBuffer.append("</range>");
}
}
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/FactorXMLVisitor.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/FactorXMLVisitor.java 2011-06-06 14:14:32 UTC (rev 3349)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/FactorXMLVisitor.java 2011-06-06 15:12:08 UTC (rev 3350)
@@ -54,34 +54,28 @@
@Override
public void start(Factor factor) {
xmlBuffer.append("<factor");
- xmlBuffer.append(" name=\"" + factor.getName() + "\"");
+ xmlBuffer.append(" name=\"").append(factor.getName()).append("\"");
Object referenceValueForType = null;
// property attribute
- if (factor.getDomain() instanceof MatrixContinuousDomain) {
- xmlBuffer.append(" property=\"matrixcontinuous\"");
- referenceValueForType = ((ContinuousDomain)factor.getDomain()).getReferenceValue();
- if (referenceValueForType == null) {
- referenceValueForType = ((ContinuousDomain)factor.getDomain()).getOriginalMinBound();
+
+ Domain domain = factor.getDomain();
+
+ if (domain instanceof ContinuousDomain) {
+ if (domain instanceof MatrixContinuousDomain) {
+ xmlBuffer.append(" property=\"matrixcontinuous\"");
+ } else if (domain instanceof EquationContinuousDomain) {
+ xmlBuffer.append(" property=\"equationcontinuous\"");
+ } else {
+ xmlBuffer.append(" property=\"continuous\"");
}
- }
- else if (factor.getDomain() instanceof EquationContinuousDomain) {
- xmlBuffer.append(" property=\"equationcontinuous\"");
- referenceValueForType = ((ContinuousDomain)factor.getDomain()).getReferenceValue();
+ referenceValueForType = ((ContinuousDomain) domain).getReferenceValue();
if (referenceValueForType == null) {
- referenceValueForType = ((ContinuousDomain)factor.getDomain()).getOriginalMinBound();
+ referenceValueForType = ((ContinuousDomain) domain).getMinBound();
}
- }
- else if (factor.getDomain() instanceof ContinuousDomain) {
- xmlBuffer.append(" property=\"continuous\"");
- referenceValueForType = ((ContinuousDomain)factor.getDomain()).getReferenceValue();
- if (referenceValueForType == null) {
- referenceValueForType = ((ContinuousDomain)factor.getDomain()).getOriginalMinBound();
- }
- }
- else if (factor.getDomain() instanceof DiscreteDomain) {
+ } else if (domain instanceof DiscreteDomain) {
xmlBuffer.append(" property=\"discrete\"");
- Object firstKey = ((DiscreteDomain)factor.getDomain()).getValues().firstKey();
- referenceValueForType = ((DiscreteDomain)factor.getDomain()).getValues().get(firstKey);
+ Object firstKey = ((DiscreteDomain) domain).getValues().firstKey();
+ referenceValueForType = ((DiscreteDomain) domain).getValues().get(firstKey);
}
// type attribute
if (referenceValueForType instanceof Double || referenceValueForType instanceof Float
@@ -91,15 +85,15 @@
else if (referenceValueForType instanceof Integer) {
xmlBuffer.append(" type=\"integer\"");
}
- else if (factor.getDomain() instanceof RuleDiscreteDomain) {
+ else if (domain instanceof RuleDiscreteDomain) {
xmlBuffer.append(" type=\"rule\"");
}
- else if (factor.getDomain() instanceof EquationDiscreteDomain) {
+ else if (domain instanceof EquationDiscreteDomain) {
xmlBuffer.append(" type=\"equation\"");
}
xmlBuffer.append(">");
// target element
- xmlBuffer.append("<target>" + factor.getPath() + "</target>");
+ xmlBuffer.append("<target>").append(factor.getPath()).append("</target>");
// value element
/* TODO value should be only in simulation export,
not in design plan export
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/MatrixContinuousDomainXMLVisitor.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/MatrixContinuousDomainXMLVisitor.java 2011-06-06 14:14:32 UTC (rev 3349)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/MatrixContinuousDomainXMLVisitor.java 2011-06-06 15:12:08 UTC (rev 3350)
@@ -51,16 +51,22 @@
MatrixContinuousDomain mDomain = (MatrixContinuousDomain)domain;
// facteur continue pourcentage
- if (domain.getCoefficient() != null || domain.getReferenceValue() != null) {
- xmlBuffer.append("<reference coefficient=\"" + mDomain.getCoefficient() + "\">");
- xmlBuffer.append(MexicoHelper.getMatrixAsXML(mDomain.getMatrix()));
+ if (domain.isPercentageType()) {
+ xmlBuffer.append("<reference coefficient=\"")
+ .append(mDomain.getCoefficient())
+ .append("\">");
+ xmlBuffer.append(MexicoHelper.getMatrixAsXML((MatrixND)mDomain.getReferenceValue()));
xmlBuffer.append("</reference>");
}
else {
// facteur continue min/max
xmlBuffer.append("<range>");
- xmlBuffer.append("<min>" + MexicoHelper.getMatrixAsXML((MatrixND)mDomain.getOriginalMaxBound()) + "</min>");
- xmlBuffer.append("<max>" + MexicoHelper.getMatrixAsXML((MatrixND)mDomain.getOriginalMaxBound()) + "</max>");
+ xmlBuffer.append("<min>")
+ .append(MexicoHelper.getMatrixAsXML((MatrixND)mDomain.getMinBound()))
+ .append("</min>");
+ xmlBuffer.append("<max>")
+ .append(MexicoHelper.getMatrixAsXML((MatrixND)mDomain.getMaxBound()))
+ .append("</max>");
xmlBuffer.append("</range>");
}
}
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationService.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationService.java 2011-06-06 14:14:32 UTC (rev 3349)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationService.java 2011-06-06 15:12:08 UTC (rev 3350)
@@ -94,7 +94,7 @@
/**
* Cette classe est responsable de conservation de toutes les simulations faites
- * ou a faire. Pour ajouter une nouvelle simulation on appelle la methode
+ * ou a faire. Pour ajouter une nouvelle simulation on appelle une des méthodes
* {@link #submit}.
* <p>
* Cette classe sert aussi de modele pour le moniteur de queue
@@ -268,7 +268,8 @@
/**
* Ajoute le job au job en cours previent s'il n'etait pas deja present
- * les listener {@link SimulationServiceListener#simulationStart}.
+ * les listeners
+ * {@link SimulationServiceListener#simulationStart(SimulationService, SimulationJob)}.
* @param job
*/
protected synchronized void fireStartEvent(SimulationJob job) {
@@ -285,8 +286,8 @@
* Supprime le job de la liste des jobs en cours et l'ajoute le job si
* besoin a la liste des jobs faits (s'il y a une erreur ou qu'il ne sagit
* pas d'une simulation lancer par un plan d'analyse).
- * Les listener sont prevenu par la methode
- * {@link SimulationServiceListener#simulationStop}.
+ * Les listener sont prevenu par la méthode
+ * {@link SimulationServiceListener#simulationStop(SimulationService, SimulationJob)}.
* @param job
*/
protected synchronized void fireStopEvent(SimulationJob job) {
@@ -445,9 +446,6 @@
SensitivityScenarios sensitivityScenarios = sensitivitycalculator
.compute(designPlan, masterExportDirectory);
- // close context opened for nominal values
- context.closeContext();
-
// ajout des parametres de simulation
localParameters.setSensitivityCalculator(sensitivitycalculator);
localParameters.setNumberOfSensitivitySimulation(sensitivityScenarios.getScenarios().size());
@@ -585,7 +583,7 @@
*
* @param beanUtils beanUtils converter
* @param buffer buffer to fill
- * @param level call level used to avoid variables name collision
+ * @param counter call counter used to avoid variables name collision
* @param factors factor list to manage
*/
protected void generatePreScript(ConvertUtilsBean beanUtils, StringBuffer buffer, Counter counter, Collection<Factor> factors) {
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/AbstractSensitivityCalculator.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/AbstractSensitivityCalculator.java 2011-06-06 14:14:32 UTC (rev 3349)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/AbstractSensitivityCalculator.java 2011-06-06 15:12:08 UTC (rev 3350)
@@ -36,22 +36,17 @@
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
-import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.j2r.REngine;
import org.nuiton.j2r.RException;
import org.nuiton.j2r.RProxy;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.util.FileUtil;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.export.SensitivityExport;
import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain;
-import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationContinuousDomain;
-import fr.ifremer.isisfish.simulator.sensitivity.domain.MatrixContinuousDomain;
public abstract class AbstractSensitivityCalculator implements
SensitivityCalculator {
@@ -59,19 +54,6 @@
/** to use log facility, just put in your code: log.info("..."); */
private static Log log = LogFactory
.getLog(AbstractSensitivityCalculator.class);
-
- /** Topia context used for discrete domain nominal value compute. */
- protected TopiaContext context;
-
- /**
- * Set topia context on current region to nominal value compute.
- *
- * @param context context
- */
- @Override
- public void setTopiaContext(TopiaContext context) {
- this.context = context;
- }
/**
* Method to create the isis.factors dataframe in R.
@@ -81,7 +63,7 @@
* destination RData file. The RData file will be named directory.RData and
* saved in the directory parent.
*
- * @throws SensitivityException
+ * @throws SensitivityException if an error occur while talking to R
*/
public void setIsisFactorsR(DesignPlan plan, File outputdirectory)
throws SensitivityException {
@@ -119,58 +101,25 @@
//Factor names
factorNames += "\"" + factor.getName() + "\"";
- if (factor.getDomain() instanceof MatrixContinuousDomain) {
+ if (factor.getDomain() instanceof ContinuousDomain) {
//Continu values, binf values, bsup values and discrete factors attributes
- nominalValues += getNominalValue(factor);
+ nominalValues += factor.getNominalValue();
//Continu values
continuValues += "TRUE";
//Binf values
- binfValues += ((MatrixContinuousDomain) factor.getDomain())
- .getRealMinBound();
-
- //Bsup values
- bsupValues += ((MatrixContinuousDomain) factor.getDomain())
- .getRealMaxBound();
-
- } else if (factor.getDomain() instanceof EquationContinuousDomain) {
- //Continu values, binf values, bsup values and discrete factors attributes
-
- nominalValues += ((EquationContinuousDomain) factor.getDomain())
- .getReferenceValue();
-
- //Continu values
- continuValues += "TRUE";
-
- //Binf values
- binfValues += ((EquationContinuousDomain) factor.getDomain())
- .getValueForIdentifier(0.0);
-
- //Bsup values
- bsupValues += ((EquationContinuousDomain) factor.getDomain())
- .getValueForIdentifier(1.0);
- } else if (factor.getDomain() instanceof ContinuousDomain) {
- //Continu values, binf values, bsup values and discrete factors attributes
-
- nominalValues += getNominalValue(factor);
-
- //Continu values
- continuValues += "TRUE";
-
- //Binf values
-
binfValues += ((ContinuousDomain) factor.getDomain())
- .getMinBound();
+ .getCalculatorMinBound();
//Bsup values
bsupValues += ((ContinuousDomain) factor.getDomain())
- .getMaxBound();
+ .getCalculatorMaxBound();
} else {
- nominalValues += getNominalValue(factor);
+ nominalValues += factor.getNominalValue();
//Continu values
continuValues += "FALSE";
@@ -245,33 +194,6 @@
}
- protected String getNominalValue(Factor factor) {
- String result = null;
-
- Domain domain = factor.getDomain();
- if (domain instanceof MatrixContinuousDomain) {
- result = "1.0";
- }
- else {
- String path = factor.getPath();
- String topiaId = path.substring(0, path.lastIndexOf("#"));
- String propertyName=path.substring(path.lastIndexOf("#") + 1);
-
- try {
- TopiaEntity entity = context.findByTopiaId(topiaId);
- result = BeanUtils.getProperty(entity, propertyName);
- } catch (Exception ex) {
- if (log.isErrorEnabled()) {
- log.error("An error occurred while trying to get nominal value", ex);
- }
- }
- }
- if (log.isDebugEnabled()) {
- log.debug("Nominal value :" + result);
- }
- return result;
- }
-
protected String editRInstruction(String rCall){
JLabel label = new JLabel(
"Modifier le code R envoyé si vous le souhaitez");
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/Factor.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/Factor.java 2011-06-06 14:14:32 UTC (rev 3349)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/Factor.java 2011-06-06 15:12:08 UTC (rev 3350)
@@ -75,6 +75,11 @@
protected Domain domain;
/**
+ * Value that this factor got in the database
+ */
+ protected Object nominalValue;
+
+ /**
* Factor value.
*/
protected Object value;
@@ -201,6 +206,15 @@
this.path = path;
}
+ public Object getNominalValue() {
+ return nominalValue;
+ }
+
+ public void setNominalValue(Object nominalValue) {
+ this.nominalValue = nominalValue;
+ }
+
+
/**
* Accept a new visitor.
*
@@ -218,7 +232,7 @@
@Override
public Object clone() {
- Factor f = null;
+ Factor f;
try {
f = (Factor)super.clone();
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/SensitivityCalculator.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/SensitivityCalculator.java 2011-06-06 14:14:32 UTC (rev 3349)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/SensitivityCalculator.java 2011-06-06 15:12:08 UTC (rev 3350)
@@ -28,8 +28,6 @@
import java.io.File;
import java.util.List;
-import org.nuiton.topia.TopiaContext;
-
import fr.ifremer.isisfish.datastore.SimulationStorage;
/**
@@ -46,13 +44,6 @@
public interface SensitivityCalculator {
/**
- * Set topia context on current region to nominal value compute.
- *
- * @param context context
- */
- void setTopiaContext(TopiaContext context);
-
- /**
* Return calculator description.
*
* @return calculator description
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/domain/ContinuousDomain.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/domain/ContinuousDomain.java 2011-06-06 14:14:32 UTC (rev 3349)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/domain/ContinuousDomain.java 2011-06-06 15:12:08 UTC (rev 3350)
@@ -27,17 +27,25 @@
import fr.ifremer.isisfish.simulator.sensitivity.Domain;
import fr.ifremer.isisfish.simulator.sensitivity.visitor.DomainVisitor;
+import org.nuiton.math.matrix.MapFunction;
+import org.nuiton.math.matrix.MatrixND;
/**
- * Tous les domaines continues sont de deux formes (min/max ou pourcentage).
+ *
+ * All the continuous domains can be of 2 different types (min/max or
+ * percentage).
+ *
+ * A min/max domain can take 2 values : {@link #minBound} and {@link #maxBound}.
+ * A percentage domain got 2 values {@link #coefficient} and
+ * {@link #referenceValue} that are the basis to calculate the {@link #minBound}
+ * and {@link #maxBound} values.
+ *
+ * A continuous domain also got a cardinality, either filled in by the user or
+ * the sensitivity method if it manages it.
+ *
+ * To do sensitivity calculations, you MUST use {@link #getCalculatorMinBound()},
+ * {@link #getCalculatorMaxBound()}.
*
- * Un domaine min/max a deux valeurs : {@link #minBound} et {@link #maxBound}.
- * Un domaine pourcentage a deux autres valeurs {@link #coefficient} et
- * {@link #referenceValue}.
- *
- * Un domain continue a également une cardialité, soit renseigné directement
- * par l'utilisateur, soit par la methode d'AS (si elle le gere).
- *
* @author chatellier
* @version $Revision: 1.0 $
*
@@ -64,6 +72,9 @@
/** Cardinality */
protected int cardinality;
+ /** Flag to know the type of the domain **/
+ protected boolean percentageType;
+
/**
* Empty constructor.
*/
@@ -82,52 +93,85 @@
this.minBound = minBound;
this.maxBound = maxBound;
}
+
+ public boolean isPercentageType() {
+ return percentageType;
+ }
+
+ public void setPercentageType(boolean percentageType) {
+ this.percentageType = percentageType;
+ }
/**
- * Return minBound to use for sensitivity. This method can be overridden
- * and can return another value than {@link #minBound}.
+ * Return the minimum bound of the domain. Do not use this value for
+ * sensitivity calculation, prefer using {@link #getCalculatorMinBound}.
*
- * @return the minBound
+ * @return the minimum bound
*/
public Object getMinBound() {
- return getOriginalMinBound();
+ if (isPercentageType()) {
+ MatrixND temp = ((MatrixND) getReferenceValue()).copy();
+
+ // since 3.4.0.0, operator is always *
+ temp.map(new MapFunction() {
+ public double apply(double val) {
+ return (val + ((val * coefficient) * ((2 * getCalculatorMinBound() - 1))));
+ }
+ });
+ return temp;
+ } else {
+ return minBound;
+ }
}
/**
- * Return original domain min bound.
+ * Return the minimum bound for sensitivity calculators. It always returns 0.
*
- * @return the minBound
+ * @return the minimum bound for sensitivity analysis.
*/
- public final Object getOriginalMinBound() {
- return minBound;
+ public double getCalculatorMinBound() {
+ return 0;
}
/**
- * Set min value.
+ * Set the minimum bound of the domain.
*
- * @param minBound the minBound to set
+ * @param minBound the minimum bound.
*/
public void setMinBound(Object minBound) {
this.minBound = minBound;
}
/**
- * Return maxBound to use for sensitivity. This method can be overridden
- * and can return another value than {@link #maxBound}.
+ * Return the maximum bound of the domain. Do not use this value for
+ * sensitivity calculation, prefer using {@link #getCalculatorMaxBound}.
*
- * @return the maxBound
+ * @return the maximum bound
*/
public Object getMaxBound() {
- return getOriginalMaxBound();
+ if (isPercentageType()) {
+ MatrixND temp = ((MatrixND) getReferenceValue()).copy();
+
+ // since 3.4.0.0, operator is always *
+ temp.map(new MapFunction() {
+ public double apply(double val) {
+ return (val + ((val * coefficient) *
+ ((2 * getCalculatorMaxBound() - 1))));
+ }
+ });
+ return temp;
+ } else {
+ return maxBound;
+ }
}
/**
- * Return original domain max bound.
+ * Return the minimum bound for sensitivity calculators. It always returns 1.
*
- * @return the maxBound
+ * @return the maximum bound for sensitivity analysis.
*/
- public final Object getOriginalMaxBound() {
- return maxBound;
+ public double getCalculatorMaxBound() {
+ return 1;
}
/**
@@ -178,17 +222,18 @@
/**
* {@inheritDoc}.
- *
- * In continuous domain, just return identifier
*/
public Object getValueForIdentifier(Object identifier) {
- return identifier;
+ // since 3.4.0.0, operator is always *
+ Double result = ((Double)referenceValue + (((Double)referenceValue * coefficient)
+ * ((2 * (Double)identifier - 1))));
+ return result;
}
/**
* Accept a new visitor.
*
- * @param visitor
+ * @param visitor the visitor
*/
public void accept(DomainVisitor visitor) {
visitor.start(this);
@@ -207,7 +252,7 @@
/**
* Set cardinality
*
- * @param cardinality
+ * @param cardinality the domain cardinality
*/
public void setCardinality(int cardinality) {
this.cardinality = cardinality;
@@ -215,7 +260,7 @@
@Override
public ContinuousDomain clone() {
- ContinuousDomain cloned = null;
+ ContinuousDomain cloned;
try {
cloned = (ContinuousDomain)super.clone();
} catch (CloneNotSupportedException e) {
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/domain/EquationContinuousDomain.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/domain/EquationContinuousDomain.java 2011-06-06 14:14:32 UTC (rev 3349)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/domain/EquationContinuousDomain.java 2011-06-06 15:12:08 UTC (rev 3350)
@@ -43,13 +43,6 @@
/** Variable name (must be java valid identifier) */
protected String variableName;
-
- /**
- * Value used to create the factor.
- *
- * Only used by sensitivity analysis scripts.
- */
- protected Double value;
/**
* Get variable name.
@@ -69,74 +62,13 @@
this.variableName = variableName;
}
- /**
- * {@inheritDoc}.
- *
- * In equation continuous domain, always return 0
- */
@Override
- public Object getMinBound() {
- return 0.0;
- }
-
- /**
- * {@inheritDoc}.
- *
- * In equation continuous domain, always return 1
- */
- @Override
- public Object getMaxBound() {
- return 1.0;
- }
-
- @Override
- public Object getValueForIdentifier(Object identifier) {
- return getValueForIdentifier((Double)identifier);
- }
-
- /**
- * In equation continuous domain, value appear in continuous domain values
- * only. Here : return identifier.
- *
- * @param identifier identifier
- * @return ?
- */
- public Double getValueForIdentifier(Double identifier) {
-
- this.value = identifier;
-
- Double doubleReference = (Double)referenceValue;
- // since 3.4.0.0, operator is always *
- Double result = ((Double) (doubleReference + ((doubleReference * coefficient) * ((2 * value - 1)))));
- return result;
- }
-
- /**
- * Get value used to create the equation.
- *
- * @return the value
- */
- public Double getValue() {
- return this.value;
- }
-
- /**
- * Set value used to create the equation.
- *
- * @param value the value to set
- */
- public void setValue(Double value) {
- this.value = value;
- }
-
- @Override
public EquationContinuousDomain clone() {
EquationContinuousDomain cloned = (EquationContinuousDomain)super.clone();
cloned.setCardinality(this.cardinality);
cloned.setMaxBound(this.maxBound);
cloned.setMinBound(this.minBound);
cloned.setCoefficient(this.coefficient);
- cloned.setValue(this.value);
cloned.setReferenceValue(this.referenceValue);
cloned.setVariableName(this.variableName);
return cloned;
@@ -146,7 +78,7 @@
public String toString() {
String result = "variableName=" + variableName +
" coefficient=" + coefficient + " referenceValue=" + referenceValue +
- " value=" + value;
+ " min=" + minBound + "max=" + maxBound;
return result;
}
}
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/domain/MatrixContinuousDomain.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/domain/MatrixContinuousDomain.java 2011-06-06 14:14:32 UTC (rev 3349)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/domain/MatrixContinuousDomain.java 2011-06-06 15:12:08 UTC (rev 3350)
@@ -41,52 +41,7 @@
/** serialVersionUID. */
private static final long serialVersionUID = -2037768174807839046L;
- /**
- * Value used to create the matrix
- *
- * Only used by sensitivity analysis scripts.
- */
- protected double value;
-
- /**
- * Get matrix.
- *
- * @return the matrix
- */
- public MatrixND getMatrix() {
- return (MatrixND)referenceValue;
- }
-
- /**
- * Set matrix.
- *
- * @param matrix the matrix to set
- */
- public void setMatrix(MatrixND matrix) {
- this.referenceValue = matrix;
- }
-
- /**
- * {@inheritDoc}.
- *
- * In matrix continuous domain, always return 0.0
- */
@Override
- public Object getMinBound() {
- return 0.0;
- }
-
- /**
- * {@inheritDoc}.
- *
- * In matrix continuous domain, always return 1.0
- */
- @Override
- public Object getMaxBound() {
- return 1.0;
- }
-
- @Override
public Object getValueForIdentifier(Object identifier) {
return getValueForIdentifier((Double)identifier);
}
@@ -97,38 +52,18 @@
* @param identifier identifier
* @return a new computed matrix
*/
- public MatrixND getValueForIdentifier(Double identifier) {
+ public MatrixND getValueForIdentifier(final Double identifier) {
+ MatrixND temp = ((MatrixND)getReferenceValue()).copy();
- this.value = (Double)identifier;
- MatrixND temp = getMatrix().copy();
-
// since 3.4.0.0, operator is always *
temp.map(new MapFunction() {
public double apply(double val) {
- return (val + ((val * coefficient) * ((2 * value - 1))));
+ return (val + ((val * coefficient) * ((2 * identifier - 1))));
}
});
return temp;
}
- /**
- * Get value used to create the matrix.
- *
- * @return the value
- */
- public Double getValue() {
- return this.value;
- }
-
- /**
- * Set value used to create the matrix.
- *
- * @param value the value to set
- */
- public void setValue(Double value) {
- this.value = value;
- }
-
@Override
public MatrixContinuousDomain clone() {
MatrixContinuousDomain cloned = (MatrixContinuousDomain)super.clone();
@@ -136,27 +71,46 @@
}
/**
- * Get the minimum bound of the coefficient used to create the matrix. As
- * the {@link #getMinBound()} for use in R always return 0.
+ * {@inheritDoc}
*
- * @return the real minimum bound
+ * @return the minimum bound
*/
- public Double getRealMinBound() {
- // since 3.4.0.0, operator is always *
- Double result = (1.0 + ((1.0 * coefficient) * ((2 * 0.0 - 1))));
- return result;
+ public Object getMinBound() {
+
+ if (minBound == null) {
+ MatrixND temp = ((MatrixND) getReferenceValue()).copy();
+
+ // since 3.4.0.0, operator is always *
+ temp.map(new MapFunction() {
+ public double apply(double val) {
+ return (val + ((val * coefficient) * ((2 * getCalculatorMinBound() - 1))));
+ }
+ });
+ return temp;
+ } else {
+ return minBound;
+ }
}
/**
- * Get the maximal bound of the coefficient used to create the matrix. As
- * the {@link #getMaxBound()} for use in R always return 1.
+ * {@inheritDoc}
*
- * @return the real maximum bound
+ * @return the maximum bound
*/
- public Double getRealMaxBound() {
- // since 3.4.0.0, operator is always *
- Double result = (1.0 + ((1.0 * coefficient) * ((2 * 1.0 - 1))));
- return result;
-
+ public Object getMaxBound() {
+
+ if (maxBound == null) {
+ MatrixND temp = ((MatrixND) getReferenceValue()).copy();
+
+ // since 3.4.0.0, operator is always *
+ temp.map(new MapFunction() {
+ public double apply(double val) {
+ return (val + ((val * coefficient) * ((2 * getCalculatorMaxBound() - 1))));
+ }
+ });
+ return temp;
+ } else {
+ return maxBound;
+ }
}
}
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/EquationContinuousPanelUI.jaxx
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/EquationContinuousPanelUI.jaxx 2011-06-06 14:14:32 UTC (rev 3349)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/EquationContinuousPanelUI.jaxx 2011-06-06 15:12:08 UTC (rev 3350)
@@ -32,15 +32,15 @@
java.util.List
java.util.regex.Matcher
java.util.regex.Pattern
- javax.swing.table.AbstractTableModel
- javax.swing.table.DefaultTableModel
+ javax.swing.table.AbstractTableModel
+ javax.swing.table.DefaultTableModel
javax.swing.table.TableCellEditor
javax.swing.table.TableModel
javax.swing.JComboBox
javax.swing.DefaultCellEditor
javax.swing.event.CellEditorListener
- fr.ifremer.isisfish.simulator.sensitivity.domain.EquationContinuousDomain
- org.apache.commons.lang.StringUtils
+ fr.ifremer.isisfish.simulator.sensitivity.domain.EquationContinuousDomain
+ org.apache.commons.lang.StringUtils
</import>
<String id='text' javaBean='null'/>
@@ -138,13 +138,13 @@
} else {
referenceValueField.setText("");
}
- if (selectedDomain.getOriginalMinBound() != null) {
- minBoundField.setText(selectedDomain.getOriginalMinBound().toString());
+ if (selectedDomain.getMinBound() != null) {
+ minBoundField.setText(selectedDomain.getMinBound().toString());
} else {
minBoundField.setText("");
}
- if (selectedDomain.getOriginalMaxBound() != null) {
- maxBoundField.setText(selectedDomain.getOriginalMaxBound().toString());
+ if (selectedDomain.getMaxBound() != null) {
+ maxBoundField.setText(selectedDomain.getMaxBound().toString());
} else {
maxBoundField.setText("");
}
@@ -171,7 +171,7 @@
valid = false;
}
else if (domain.getCoefficient() == null) {
- valid = domain.getOriginalMinBound() != null && domain.getOriginalMaxBound() != null;
+ valid = domain.getMinBound() != null && domain.getMaxBound() != null;
}
else {
valid = domain.getReferenceValue() != null;
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java 2011-06-06 14:14:32 UTC (rev 3349)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java 2011-06-06 15:12:08 UTC (rev 3350)
@@ -618,7 +618,7 @@
* @return component copy
*/
public ContinuousPanelContainerUI getContinuousPanel(Object value, TopiaEntityContextable bean, String property) {
- ContinuousPanelContainerUI result = null;
+ ContinuousPanelContainerUI result;
if (value instanceof RangeOfValues) {
RangeOfValues rangeOfValues = (RangeOfValues)value;
@@ -627,11 +627,7 @@
String min = "0";
String max = "0";
if (values.matches("^\\ *[0-9]*\\ *\\-\\ *[0-9]*\\ *$")) {
- int first = 0;
- if (values.startsWith("-")) {
- first = 1;
- }
- first = values.indexOf("-");
+ int first = values.indexOf("-");
if (first != -1) {
min = values.substring(0, first);
max = values.substring(first + 1);
@@ -728,8 +724,8 @@
else {
// factor numerique continue (min/max)
// pas d'erreur sur 2 fois domain.getMinBound()
- MatrixND matrixMin = (MatrixND)domain.getOriginalMinBound();
- MatrixND matrixMax = (MatrixND)domain.getOriginalMaxBound();
+ MatrixND matrixMin = (MatrixND)domain.getMinBound();
+ MatrixND matrixMax = (MatrixND)domain.getMaxBound();
continuousPanel.initExisting(
matrixMin.clone(),
matrixMax.clone(),
@@ -752,10 +748,11 @@
else {
// factor numerique continue (min/max)
// pas d'erreur sur 2 fois domain.getMinBound()
+ // on initialise avec minBound comme valeur de référence.
continuousPanel.initExisting(
- String.valueOf(domain.getOriginalMinBound()),
- String.valueOf(domain.getOriginalMaxBound()),
- String.valueOf(domain.getOriginalMinBound()),
+ String.valueOf(domain.getMinBound()),
+ String.valueOf(domain.getMaxBound()),
+ String.valueOf(domain.getMinBound()),
"");
}
result = continuousPanel;
@@ -769,8 +766,8 @@
*
* @param factorWizardUI context for context value (RegionStorage)
* @param value type to get editor
- * @param factorPath for equation
- * @param context for equation
+ * @param factor
+ * @param domain
* @return component
*/
protected JComponent getEditorWithValue(FactorWizardUI factorWizardUI, Factor factor, Domain domain, Object value) {
@@ -991,7 +988,7 @@
try {
EquationContinuousPanelUI equationPanel = (EquationContinuousPanelUI) panel;
- TopiaEntityContextable bean = (TopiaEntityContextable)equationPanel.getBean();
+ TopiaEntityContextable bean = equationPanel.getBean();
TopiaContext topiaContext = bean.getTopiaContext();
String property = equationPanel.getBeanProperty();
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2011-06-06 14:14:32 UTC (rev 3349)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2011-06-06 15:12:08 UTC (rev 3350)
@@ -997,7 +997,7 @@
MatrixND referenceValue, Double coef, boolean exist) {
Factor f = new Factor(name);
MatrixContinuousDomain domain = new MatrixContinuousDomain();
- domain.setMatrix(referenceValue);
+ domain.setReferenceValue(referenceValue);
domain.setCoefficient(coef);
f.setComment(comment);
f.setDomain(domain);
@@ -1304,7 +1304,7 @@
selectedFactor.setPath(factorName);
MatrixContinuousDomain factorDomain = new MatrixContinuousDomain();
MatrixND populationEffectives = getSimulationParameter().getNumberOf(population);
- factorDomain.setMatrix(populationEffectives.copy());
+ factorDomain.setReferenceValue(populationEffectives.copy());
factorDomain.setCoefficient(0.0);
selectedFactor.setDomain(factorDomain);
}
Modified: isis-fish/branches/3.3.1/src/main/resources/i18n/isis-fish_en_GB.properties
===================================================================
--- isis-fish/branches/3.3.1/src/main/resources/i18n/isis-fish_en_GB.properties 2011-06-06 14:14:32 UTC (rev 3349)
+++ isis-fish/branches/3.3.1/src/main/resources/i18n/isis-fish_en_GB.properties 2011-06-06 15:12:08 UTC (rev 3350)
@@ -141,6 +141,8 @@
isisfish.config.category.misc.description=Miscealenous
isisfish.config.category.officialvcs=Official VCS
isisfish.config.category.officialvcs.description=Official VCS repository
+isisfish.config.category.versioning=
+isisfish.config.category.versioning.description=
isisfish.config.database.lockmode.description=Database lock mode
isisfish.config.main.compileDirectory.description=Script compilation directory
isisfish.config.main.configFileName.description=Configuration filename
@@ -200,9 +202,12 @@
isisfish.config.vcs.hostName.description=Official VCS host name
isisfish.config.vcs.localCommunityDatabasePath.description=Community VCS local storage directory
isisfish.config.vcs.localDatabasePath.description=Official VCS local storage directory
+isisfish.config.vcs.noPassPhrase.description=
+isisfish.config.vcs.passphrase.description=
isisfish.config.vcs.protocol.description=Official VCS protocol
isisfish.config.vcs.remotePath.description=Official VCS remote path
isisfish.config.vcs.type.description=Official VCS type
+isisfish.config.vcs.useSshConnexion.description=
isisfish.config.vcs.userName.description=Official VCS user name
isisfish.config.vcs.userPassword.description=Official VCS password
isisfish.date.toString=%1$s %2$s
Modified: isis-fish/branches/3.3.1/src/main/resources/i18n/isis-fish_fr_FR.properties
===================================================================
--- isis-fish/branches/3.3.1/src/main/resources/i18n/isis-fish_fr_FR.properties 2011-06-06 14:14:32 UTC (rev 3349)
+++ isis-fish/branches/3.3.1/src/main/resources/i18n/isis-fish_fr_FR.properties 2011-06-06 15:12:08 UTC (rev 3350)
@@ -141,6 +141,8 @@
isisfish.config.category.misc.description=Divers
isisfish.config.category.officialvcs=VCS Officiel
isisfish.config.category.officialvcs.description=Dépôt contenant les scripts officiels
+isisfish.config.category.versioning=
+isisfish.config.category.versioning.description=
isisfish.config.database.lockmode.description=Méthode de vérouillage à utiliser pour la base de données
isisfish.config.main.compileDirectory.description=le répertoire où sont compilés les scripts
isisfish.config.main.configFileName.description=le fichier de configuration à utiliser
@@ -200,9 +202,12 @@
isisfish.config.vcs.hostName.description=le nom du serveur vcs à utiliser
isisfish.config.vcs.localCommunityDatabasePath.description=Dossier de stockage local du dépôt communauté
isisfish.config.vcs.localDatabasePath.description=Dossier de stockage local du dépôt officiel
+isisfish.config.vcs.noPassPhrase.description=
+isisfish.config.vcs.passphrase.description=
isisfish.config.vcs.protocol.description=le protocol pour acceder au serveur vcs
isisfish.config.vcs.remotePath.description=le chemin jusqu'au parent du module de données sur le serveur vcs
isisfish.config.vcs.type.description=le type de communication vcs utilisé
+isisfish.config.vcs.useSshConnexion.description=
isisfish.config.vcs.userName.description=le login de l'utilisateur sur le serveur vcs
isisfish.config.vcs.userPassword.description=le mot de passe de l'utilsateur sur le serveur vcs
isisfish.date.toString=%1$s %2$s
1
0
r3349 - isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/launcher
by chatellier@users.labs.libre-entreprise.org 06 Jun '11
by chatellier@users.labs.libre-entreprise.org 06 Jun '11
06 Jun '11
Author: chatellier
Date: 2011-06-06 14:14:32 +0000 (Mon, 06 Jun 2011)
New Revision: 3349
Log:
Fill factor nominal values before calling sensitivity calculator.
Modified:
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationService.java
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationService.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationService.java 2011-06-05 14:34:08 UTC (rev 3348)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationService.java 2011-06-06 14:14:32 UTC (rev 3349)
@@ -47,6 +47,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.ConvertUtilsBean;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.mutable.MutableInt;
@@ -56,6 +57,7 @@
import org.nuiton.math.matrix.MatrixND;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.util.FileUtil;
import org.nuiton.util.ListenerSet;
import org.nuiton.util.ObjectUtil;
@@ -436,7 +438,7 @@
// to get original database value (Nominal value)
RegionStorage regionStorage = RegionStorage.getRegion(param.getRegionName());
TopiaContext context = regionStorage.getStorage().beginTransaction();
- sensitivitycalculator.setTopiaContext(context);
+ fillDesignPlanNominalValue(context, designPlan);
// Sensitivity scenario returned contains same factor references
// as input design plan. Factor group are still present
@@ -510,6 +512,34 @@
}
}
+ /**
+ * Explore design plan factor tree, and set factor nominal value
+ * for each factor.
+ *
+ * @param context opened database context
+ * @param designPlan design plan
+ */
+ protected void fillDesignPlanNominalValue(TopiaContext context, DesignPlan designPlan) {
+ // take care only on first level of factor tree
+ for (Factor factor : designPlan.getFactors()) {
+ // get nominal value
+ String path = factor.getPath();
+ if (StringUtils.contains(path, "#")) {
+ String topiaId = path.substring(0, path.lastIndexOf("#"));
+ String propertyName=path.substring(path.lastIndexOf("#") + 1);
+ try {
+ TopiaEntity entity = context.findByTopiaId(topiaId);
+ Object result = BeanUtils.getProperty(entity, propertyName);
+ factor.setNominalValue(result);
+ } catch (Exception ex) {
+ if (log.isErrorEnabled()) {
+ log.error("An error occurred while trying to get nominal value", ex);
+ }
+ }
+ }
+ }
+ }
+
/** Permet de manipuler un int entre plusieurs appele de methodes recursive. */
public static class Counter {
protected int counter = 0;
1
0
r3348 - in isis-fish/branches/3.3.1: . src/license src/main/assembly src/main/java/fr/ifremer/isisfish/ui/input src/main/java/fr/ifremer/isisfish/ui/input/tree/loadors src/main/java/fr/ifremer/isisfish/ui/sensitivity src/main/java/fr/ifremer/isisfish/ui/sensitivity/equation src/test/resources/mexico
by chatellier@users.labs.libre-entreprise.org 05 Jun '11
by chatellier@users.labs.libre-entreprise.org 05 Jun '11
05 Jun '11
Author: chatellier
Date: 2011-06-05 14:34:08 +0000 (Sun, 05 Jun 2011)
New Revision: 3348
Log:
Fix dependencies, licences, header.
Modified:
isis-fish/branches/3.3.1/pom.xml
isis-fish/branches/3.3.1/src/license/THIRD-PARTY.properties
isis-fish/branches/3.3.1/src/main/assembly/isisfish-log4j.properties
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/ChangeModel.java
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/tree/loadors/FisheryTreeNodeLoador.java
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySaveVerifier.java
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/equation/EquationDomainRenderer.java
isis-fish/branches/3.3.1/src/test/resources/mexico/mexicohelper_designplanV2.xml
Modified: isis-fish/branches/3.3.1/pom.xml
===================================================================
--- isis-fish/branches/3.3.1/pom.xml 2011-06-01 12:32:08 UTC (rev 3347)
+++ isis-fish/branches/3.3.1/pom.xml 2011-06-05 14:34:08 UTC (rev 3348)
@@ -25,6 +25,21 @@
</dependency>
<dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-validator</artifactId>
+ <version>${nuitonUtilsVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- Unused, but make mavenpom happy -->
+ <dependency>
+ <groupId>org.apache.struts.xwork</groupId>
+ <artifactId>xwork-core</artifactId>
+ <version>2.2.1.1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.nuiton.i18n</groupId>
<artifactId>nuiton-i18n</artifactId>
<version>${nuitonI18nVersion}</version>
@@ -45,12 +60,12 @@
<scope>compile</scope>
</dependency>
- <!-- <dependency>
+ <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.4.Final</version>
<scope>compile</scope>
- </dependency> -->
+ </dependency>
<dependency>
<groupId>org.nuiton.matrix</groupId>
@@ -187,15 +202,14 @@
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
<scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>xml-apis</artifactId>
+ <groupId>xml-apis</groupId>
+ </exclusion>
+ </exclusions>
</dependency>
- <dependency>
- <groupId>jfree</groupId>
- <artifactId>jfreechart</artifactId>
- <version>1.0.12</version>
- <scope>compile</scope>
- </dependency>
-
<!-- encore utilise pour les pre-scripts -->
<dependency>
<groupId>org.beanshell</groupId>
@@ -211,7 +225,7 @@
<scope>compile</scope>
</dependency>
- <dependency>
+ <!-- <dependency>
<groupId>com.fifesoft</groupId>
<artifactId>rsyntaxtextarea</artifactId>
<version>1.5.0</version>
@@ -221,7 +235,7 @@
<groupId>com.fifesoft</groupId>
<artifactId>languagesupport</artifactId>
<version>0.7</version>
- </dependency>
+ </dependency> -->
<dependency>
<groupId>com.jcraft</groupId>
@@ -237,12 +251,12 @@
<scope>compile</scope>
</dependency>
- <dependency>
+ <!-- <dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.9.1</version>
<scope>compile</scope>
- </dependency>
+ </dependency> -->
<!-- Utilisé lors de l'import xml v2 (entre autre) -->
<dependency>
@@ -250,6 +264,16 @@
<artifactId>jaxen</artifactId>
<version>1.1.1</version>
<scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>xml-apis</artifactId>
+ <groupId>xml-apis</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>xmlParserAPIs</artifactId>
+ <groupId>xerces</groupId>
+ </exclusion>
+ </exclusions>
</dependency>
<!-- Change this dependence if you change database -->
@@ -502,7 +526,7 @@
<!-- Dependencies version -->
<jaxxVersion>2.4.2</jaxxVersion>
<eugeneVersion>2.3.4</eugeneVersion>
- <topiaVersion>2.5.4-SNAPSHOT</topiaVersion>
+ <topiaVersion>2.6-SNAPSHOT</topiaVersion>
<nuitonUtilsVersion>2.2</nuitonUtilsVersion>
<nuitonI18nVersion>2.4</nuitonI18nVersion>
<nuitonWidgetsVersion>1.1.2-SNAPSHOT</nuitonWidgetsVersion>
Modified: isis-fish/branches/3.3.1/src/license/THIRD-PARTY.properties
===================================================================
--- isis-fish/branches/3.3.1/src/license/THIRD-PARTY.properties 2011-06-01 12:32:08 UTC (rev 3347)
+++ isis-fish/branches/3.3.1/src/license/THIRD-PARTY.properties 2011-06-05 14:34:08 UTC (rev 3348)
@@ -24,6 +24,7 @@
# - Java Transaction API (JTA) License
# - Jaxen license
# - LGPL
+# - Lesser General Public License (LGPL v. 2.1)
# - Lesser General Public License (LGPL)
# - Lesser General Public License (LGPL) v 3.0
# - License Agreement for JavaMail(TM) API
@@ -32,14 +33,16 @@
# - Sun's Binary Code License
# - The Apache Software License, Version 2.0
# - The H2 License, Version 1.0
+# - The OpenSymphony Software License, Version 1.1
# - http://sqljet.com/
# - http://svnkit.com/license.html
# - http://www.trilead.com/Products/Trilead_SSH_for_Java/License/
+# - license.txt
#-------------------------------------------------------------------------------
# Please fill the missing licenses for dependencies :
#
#
-#Tue Mar 22 15:45:15 CET 2011
+#Sun Jun 05 16:28:53 CEST 2011
antlr--antlr--2.7.6--jar=BSD License
aspectwerkz--aspectwerkz--2.0--jar=GNU Lesser General Public License
aspectwerkz--aspectwerkz-core--2.0--jar=GNU Lesser General Public License
@@ -49,7 +52,7 @@
commons-jxpath--commons-jxpath--1.3--jar=The Apache Software License, Version 2.0
commons-primitives--commons-primitives--1.0--jar=The Apache Software License, Version 2.0
dom4j--dom4j--1.6.1--jar=BSD License
-javassist--javassist--3.8.0.GA--jar=GNU Lesser General Public License
+javassist--javassist--3.8.0.GA--jar=Lesser General Public License (LGPL v. 2.1)
javax.activation--activation--1.1.1--jar=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
javax.mail--mail--1.4.1--jar=License Agreement for JavaMail(TM) API
javax.transaction--jta--1.1--jar=Java Transaction API (JTA) License
@@ -68,4 +71,4 @@
qdox--qdox--1.4--jar=Apache Software License, Version 2.0
trove--trove--1.0.2--jar=Lesser General Public License (LGPL)
xalan--xalan--2.6.0--jar=Apache Software License Version 2.0
-xerces--xmlParserAPIs--2.6.2--jar=Apache Software License, Version 1.1
+xerces--xercesImpl--2.6.2--jar=Apache Software License, Version 1.1
Modified: isis-fish/branches/3.3.1/src/main/assembly/isisfish-log4j.properties
===================================================================
--- isis-fish/branches/3.3.1/src/main/assembly/isisfish-log4j.properties 2011-06-01 12:32:08 UTC (rev 3347)
+++ isis-fish/branches/3.3.1/src/main/assembly/isisfish-log4j.properties 2011-06-05 14:34:08 UTC (rev 3348)
@@ -1,3 +1,27 @@
+###
+# #%L
+# IsisFish
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2011 CodeLutin, Chatellier Eric
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 2 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/gpl-2.0.html>.
+# #L%
+###
# Global logging configuration
log4j.rootLogger=ERROR, stdout
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/ChangeModel.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/ChangeModel.java 2011-06-01 12:32:08 UTC (rev 3347)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/ChangeModel.java 2011-06-05 14:34:08 UTC (rev 3348)
@@ -1,25 +1,23 @@
/*
* #%L
- *
- *
* $Id$
* $HeadURL$
* %%
* Copyright (C) 2011 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
+ * You should have received a copy of the GNU General Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/tree/loadors/FisheryTreeNodeLoador.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/tree/loadors/FisheryTreeNodeLoador.java 2011-06-01 12:32:08 UTC (rev 3347)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/tree/loadors/FisheryTreeNodeLoador.java 2011-06-05 14:34:08 UTC (rev 3348)
@@ -1,25 +1,23 @@
/*
* #%L
- *
- *
* $Id$
* $HeadURL$
* %%
* Copyright (C) 2011 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
+ * You should have received a copy of the GNU General Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySaveVerifier.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySaveVerifier.java 2011-06-01 12:32:08 UTC (rev 3347)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivitySaveVerifier.java 2011-06-05 14:34:08 UTC (rev 3348)
@@ -1,25 +1,23 @@
/*
* #%L
- *
- *
* $Id$
* $HeadURL$
* %%
* Copyright (C) 2011 Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
+ * You should have received a copy of the GNU General Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/equation/EquationDomainRenderer.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/equation/EquationDomainRenderer.java 2011-06-01 12:32:08 UTC (rev 3347)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/equation/EquationDomainRenderer.java 2011-06-05 14:34:08 UTC (rev 3348)
@@ -1,25 +1,23 @@
/*
* #%L
- *
- *
* $Id$
* $HeadURL$
* %%
* Copyright (C) 2011 Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
+ * You should have received a copy of the GNU General Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/
Modified: isis-fish/branches/3.3.1/src/test/resources/mexico/mexicohelper_designplanV2.xml
===================================================================
--- isis-fish/branches/3.3.1/src/test/resources/mexico/mexicohelper_designplanV2.xml 2011-06-01 12:32:08 UTC (rev 3347)
+++ isis-fish/branches/3.3.1/src/test/resources/mexico/mexicohelper_designplanV2.xml 2011-06-05 14:34:08 UTC (rev 3348)
@@ -1,4 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ IsisFish
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 1999 - 2011 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-2.0.html>.
+ #L%
+ -->
+
<experimentalDesign version="2">
<factors>
<factor name="factor 1 (double continuous)" property="continuous" type="real">
1
0
r3347 - in isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui: input sensitivity
by chatellier@users.labs.libre-entreprise.org 01 Jun '11
by chatellier@users.labs.libre-entreprise.org 01 Jun '11
01 Jun '11
Author: chatellier
Date: 2011-06-01 12:32:08 +0000 (Wed, 01 Jun 2011)
New Revision: 3347
Log:
Add support for discrete equation domain
Modified:
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/EquationContinuousPanelUI.jaxx
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx 2011-06-01 08:58:32 UTC (rev 3346)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx 2011-06-01 12:32:08 UTC (rev 3347)
@@ -40,6 +40,8 @@
<!-- Selected equation -->
<fr.ifremer.isisfish.entities.Equation id='selectedEquation' javaBean='null'/>
+ <Boolean id="autoSaveModification" javaBean="true" />
+
<import>
java.lang.reflect.Method;
java.io.File;
@@ -172,7 +174,13 @@
setFormule((Formule)formuleComboBox.getSelectedItem());
setEditorText();
}
- editor.getCurrentEditor().addDocumentListener(listener);
+
+ // utilisee lors de l'edition des equations dans l'interface de sensibilité
+ // le contenu de l'equation ne doit pas automatiquement
+ // etre sauvé dans l'entité (pas de sens pour un facteur discret de type equation)
+ if (autoSaveModification) {
+ editor.getCurrentEditor().addDocumentListener(listener);
+ }
}
protected void setComboModel() {
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/EquationContinuousPanelUI.jaxx
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/EquationContinuousPanelUI.jaxx 2011-06-01 08:58:32 UTC (rev 3346)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/EquationContinuousPanelUI.jaxx 2011-06-01 12:32:08 UTC (rev 3347)
@@ -185,7 +185,8 @@
}
]]></script>
<JPanel id='content'>
- <Table constraints='BorderLayout.CENTER'>
+ <JScrollPane constraints='BorderLayout.CENTER'>
+ <Table>
<row>
<cell fill='both' weightx='1' weighty='1'>
<JScrollPane preferredSize="{new Dimension(200, 150)}">
@@ -297,12 +298,14 @@
</row>
<row>
<cell fill='both' columns='2' weightx='1' weighty='1'>
- <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='editor' formule='{getFormule()}' text='{getText()}'
- constructorParams='this' bean='{getBean()}' clazz='{getClazz()}' beanProperty='{getBeanProperty()}' active='{isContinueSelected()}'
+ <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='editor' constructorParams='this'
+ autoSaveModification="false" formule='{getFormule()}' text='{getText()}'
+ bean='{getBean()}' clazz='{getClazz()}' beanProperty='{getBeanProperty()}' active='{isContinueSelected()}'
formuleCategory='{getFormuleCategory()}' selectedEquation='{getSelectedEquation()}'
visible='{isContinuePossible()}' enabled='{isContinueSelected()}'/>
</cell>
</row>
</Table>
+ </JScrollPane>
</JPanel>
</ContinuousPanelContainerUI>
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java 2011-06-01 08:58:32 UTC (rev 3346)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityInputHandler.java 2011-06-01 12:32:08 UTC (rev 3347)
@@ -67,6 +67,7 @@
import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationDiscreteDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.MatrixContinuousDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.RuleDiscreteDomain;
import fr.ifremer.isisfish.types.RangeOfValues;
@@ -74,6 +75,7 @@
import fr.ifremer.isisfish.ui.input.InputAction;
import fr.ifremer.isisfish.ui.input.InputContentUI;
import fr.ifremer.isisfish.ui.input.InputHandler;
+import fr.ifremer.isisfish.ui.input.InputOneEquationUI;
import fr.ifremer.isisfish.ui.input.tree.FisheryDataProvider;
import fr.ifremer.isisfish.ui.input.tree.FisheryTreeHelper;
import fr.ifremer.isisfish.ui.input.tree.FisheryTreeNode;
@@ -432,7 +434,7 @@
i++;
JComponent c = null;
if (o != null) {
- c = getEditorWithValue(factorWizardUI, dDomain, o);
+ c = getEditorWithValue(factorWizardUI, factor, dDomain, o);
}
else {
if (log.isWarnEnabled()) {
@@ -557,7 +559,7 @@
*
* Il serait plus interessant de le faire sur les types et non sur les
* valeur mais pour {@link RangeOfValues} par exemple, seule la valeur
- * a un typ Float... donc pas evident.
+ * a un type Float... donc pas evident.
*
* @param value value
* @return continuous enabled
@@ -707,7 +709,7 @@
result = ui;
} catch (Exception ex) {
- throw new IsisFishRuntimeException("Can't restore intial factor database property", ex);
+ throw new IsisFishRuntimeException("Can't restore initial factor database property", ex);
}
}
// TODO path with no # (normalement pas possible pour les equations)
@@ -771,7 +773,7 @@
* @param context for equation
* @return component
*/
- protected JComponent getEditorWithValue(FactorWizardUI factorWizardUI, Domain domain, Object value) {
+ protected JComponent getEditorWithValue(FactorWizardUI factorWizardUI, Factor factor, Domain domain, Object value) {
JComponent result = null;
@@ -791,6 +793,39 @@
result = new RuleChooser(factorWizardUI);
((RuleChooser)result).setRulesList((List<Rule>)value);
}
+ else if (domain instanceof EquationDiscreteDomain) {
+ String factorPath = factor.getPath();
+ if (factor.getPath().indexOf('#') != -1) {
+ String topiaId = factorPath.substring(0, factorPath.lastIndexOf('#'));
+ String property = factorPath.substring(factorPath.lastIndexOf('#') + 1);
+
+ // get bean in database
+ try {
+ TopiaContext topiaContext = factorWizardUI.getContextValue(TopiaContext.class);
+ TopiaEntityContextable entity = (TopiaEntityContextable)topiaContext.findByTopiaId(topiaId);
+
+ String getter = "get" + StringUtils.capitalize(property);
+ Method m = entity.getClass().getMethod(getter);
+ Equation equation = (Equation)m.invoke(entity);
+
+ // fill component
+ InputOneEquationUI ui = new InputOneEquationUI(factorWizardUI);
+ ui.setAutoSaveModification(false);
+ ui.setFormuleCategory(equation.getCategory());
+ ui.setText(_("isisfish.common.equation")); // can't get real name
+ ui.setClazz(value.getClass());
+ ui.setBeanProperty(property);
+ ui.setBean(entity); // set bean fire content modification event
+ ui.getEditor().setText((String)value);
+ ui.setActive(true);
+
+ result = ui;
+ } catch (Exception ex) {
+ throw new IsisFishRuntimeException("Can't restore initial factor database property", ex);
+ }
+ }
+ // TODO path with no # (normalement pas possible pour les equations)
+ }
else if (value instanceof String) {
// valeur nom typées ???
result = new JTextField();
@@ -812,7 +847,7 @@
* @return component copy
*/
public JComponent getNewDiscreteComponent(FactorWizardUI factorWizardUI) {
-
+
JComponent result = null;
String factorPath = factorWizardUI.getFactorPath();
@@ -821,7 +856,6 @@
String property = factorPath.substring(factorPath.lastIndexOf('#') + 1);
TopiaContext topiaContext = factorWizardUI.getContextValue(TopiaContext.class);
-
try {
// get bean in database
TopiaEntityContextable entity = (TopiaEntityContextable)topiaContext.findByTopiaId(topiaId);
@@ -839,7 +873,21 @@
} else if (value instanceof RangeOfValues) {
RangeOfValues rangeOfValues = (RangeOfValues)value;
result = new JTextField(rangeOfValues.getValues());
+ } else if (value instanceof Equation) {
+ Equation equation = (Equation)value;
+ // fill component
+ InputOneEquationUI ui = new InputOneEquationUI(factorWizardUI);
+ ui.setAutoSaveModification(false);
+ ui.setText(equation.getContent());
+ ui.setFormuleCategory(equation.getCategory());
+ ui.setText(_("isisfish.common.equation")); // can't get real name
+ ui.setClazz(value.getClass());
+ ui.setBeanProperty(property);
+ ui.setBean(entity);
+ ui.setActive(true);
+ result = ui;
}
+
} catch (Exception ex) {
throw new IsisFishRuntimeException("Can't restore intial factor database property", ex);
}
@@ -866,7 +914,11 @@
}
}
}
-
+
+ if (log.isDebugEnabled()) {
+ log.debug("Component for path " + factorPath + " is " + result);
+ }
+
return result;
}
@@ -910,12 +962,12 @@
/**
* Save a continous factor.
*
- * @param name
- * @param comment
- * @param path
- * @param panel
- * @param action
- * @param exist
+ * @param name factor name
+ * @param comment comment
+ * @param path factor path
+ * @param panel panel
+ * @param action action
+ * @param exist exist
*/
protected void saveContinue(String name,
String comment, String path, ContinuousPanelContainerUI panel,
@@ -992,14 +1044,40 @@
String comment, String path, List<JComponent> components,
SimulAction action, boolean exist) {
List<Object> values = new ArrayList<Object>();
- for (JComponent c : components) {
- values.add(getComponentValue(c));
+
+ boolean ruleFactor = false;
+ boolean equationFactor = false;
+ for (JComponent component : components) {
+
+ // get internat component value
+ Object result = null;
+ if (component instanceof JTextComponent) {
+ result = ((JTextComponent) component).getText();
+ } else if (component instanceof MatrixPanelEditor) {
+ result = ((MatrixPanelEditor) component).getMatrix();
+ } else if (component instanceof InputOneEquationUI) {
+ result = ((InputOneEquationUI) component).getEditor().getText();
+ equationFactor = true;
+ } else if (component instanceof RuleChooser) {
+ result = ((RuleChooser)component).getRulesList();
+ ruleFactor = true;
+ }
+
+ values.add(result);
}
- action.addDiscreteFactor(name, comment, path, values, exist);
+
+ if (ruleFactor) {
+ action.addDiscreteRuleFactor(name, comment, path, values, exist);
+ } else if (equationFactor) {
+ action.addDiscreteEquationFactor(name, comment, path, values, exist);
+ } else {
+ action.addDiscreteFactor(name, comment, path, values, exist);
+ }
}
/**
- * Return value in swing component that could be next used into factor.
+ * Return value in swing component that could be next used into factor
+ * for discrete factor values.
*
* @param component component
* @return factor value
@@ -1010,9 +1088,9 @@
result = ((JTextComponent) component).getText();
} else if (component instanceof MatrixPanelEditor) {
result = ((MatrixPanelEditor) component).getMatrix();
- } /*else if (component instanceof InputOneEquationUI) {
- result = ((InputOneEquationUI) component).getEditor().getText();*/
- else if (component instanceof RuleChooser) {
+ } else if (component instanceof InputOneEquationUI) {
+ result = ((InputOneEquationUI) component).getEditor().getText();
+ } else if (component instanceof RuleChooser) {
result = ((RuleChooser)component).getRulesList();
}
if (log.isDebugEnabled()) {
1
0
r3346 - in isis-fish/branches/3.3.1/src: main/java/fr/ifremer/isisfish/mexico/xml main/java/fr/ifremer/isisfish/simulator/sensitivity/domain main/java/fr/ifremer/isisfish/ui/simulator test/java/fr/ifremer/isisfish/mexico
by chatellier@users.labs.libre-entreprise.org 01 Jun '11
by chatellier@users.labs.libre-entreprise.org 01 Jun '11
01 Jun '11
Author: chatellier
Date: 2011-06-01 08:58:32 +0000 (Wed, 01 Jun 2011)
New Revision: 3346
Log:
Add support for discrete equation domain
Added:
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/EquationDiscreteDomainXMLVisitor.java
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/domain/EquationDiscreteDomain.java
Modified:
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/DomXMLParser.java
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/FactorXMLVisitor.java
isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
isis-fish/branches/3.3.1/src/test/java/fr/ifremer/isisfish/mexico/MexicoHelperTest.java
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/DomXMLParser.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/DomXMLParser.java 2011-05-31 15:54:57 UTC (rev 3345)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/DomXMLParser.java 2011-06-01 08:58:32 UTC (rev 3346)
@@ -27,6 +27,7 @@
import java.util.List;
+import org.apache.commons.lang.StringEscapeUtils;
import org.dom4j.Element;
import org.nuiton.math.matrix.MatrixND;
import org.nuiton.topia.TopiaContext;
@@ -39,6 +40,7 @@
import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationDiscreteDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.MatrixContinuousDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.RuleDiscreteDomain;
@@ -505,6 +507,22 @@
factor.setDomain(domain);
}
factorGroup.addFactor(factor);
+ } else if ("equation".equals(type)) {
+ Factor factor = new Factor(name);
+ factor.setPath(path);
+ Element fixedElement = factorElement.element("domain").element("fixed");
+ if ("discrete".equals(property)) {
+ EquationDiscreteDomain domain = new EquationDiscreteDomain();
+ List<Element> valueElements = fixedElement.element("enumeration").elements("value");
+ int label = 0;
+ for (Element valueElement : valueElements) {
+ String content = StringEscapeUtils.unescapeXml(valueElement.getText());
+ domain.getValues().put(Integer.valueOf(label), content);
+ ++label;
+ }
+ factor.setDomain(domain);
+ }
+ factorGroup.addFactor(factor);
}
}
Added: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/EquationDiscreteDomainXMLVisitor.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/EquationDiscreteDomainXMLVisitor.java (rev 0)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/EquationDiscreteDomainXMLVisitor.java 2011-06-01 08:58:32 UTC (rev 3346)
@@ -0,0 +1,53 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, CodeLutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-2.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.mexico.xml;
+
+import org.apache.commons.lang.StringEscapeUtils;
+
+import fr.ifremer.isisfish.simulator.sensitivity.Domain;
+
+/**
+ * XML equation discrete domain visitor.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class EquationDiscreteDomainXMLVisitor extends DiscreteDomainXMLVisitor {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void visit(Domain domain, Object label, Object value) {
+ String content = (String)value;
+ xmlBuffer.append("<value>");
+ xmlBuffer.append(StringEscapeUtils.escapeXml(content));
+ xmlBuffer.append("</value>");
+ }
+}
Property changes on: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/EquationDiscreteDomainXMLVisitor.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/FactorXMLVisitor.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/FactorXMLVisitor.java 2011-05-31 15:54:57 UTC (rev 3345)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/mexico/xml/FactorXMLVisitor.java 2011-06-01 08:58:32 UTC (rev 3346)
@@ -32,6 +32,7 @@
import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationDiscreteDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.MatrixContinuousDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.RuleDiscreteDomain;
import fr.ifremer.isisfish.simulator.sensitivity.visitor.FactorVisitor;
@@ -93,6 +94,9 @@
else if (factor.getDomain() instanceof RuleDiscreteDomain) {
xmlBuffer.append(" type=\"rule\"");
}
+ else if (factor.getDomain() instanceof EquationDiscreteDomain) {
+ xmlBuffer.append(" type=\"equation\"");
+ }
xmlBuffer.append(">");
// target element
xmlBuffer.append("<target>" + factor.getPath() + "</target>");
@@ -112,17 +116,15 @@
DomainXMLVisitor visitor = null;
if (factor.getDomain() instanceof MatrixContinuousDomain) {
visitor = new MatrixContinuousDomainXMLVisitor();
- }
- else if (factor.getDomain() instanceof EquationContinuousDomain) {
+ } else if (factor.getDomain() instanceof EquationContinuousDomain) {
visitor = new EquationContinuousDomainXMLVisitor();
- }
- else if (factor.getDomain() instanceof ContinuousDomain) {
+ } else if (factor.getDomain() instanceof ContinuousDomain) {
visitor = new ContinuousDomainXMLVisitor();
- }
- else if (factor.getDomain() instanceof RuleDiscreteDomain) {
+ } else if (factor.getDomain() instanceof RuleDiscreteDomain) {
visitor = new RuleDiscreteDomainXMLVisitor();
- }
- else if (factor.getDomain() instanceof DiscreteDomain) {
+ } else if (factor.getDomain() instanceof EquationDiscreteDomain) {
+ visitor = new EquationDiscreteDomainXMLVisitor();
+ } else if (factor.getDomain() instanceof DiscreteDomain) {
visitor = new DiscreteDomainXMLVisitor();
}
domain.accept(visitor);
Added: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/domain/EquationDiscreteDomain.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/domain/EquationDiscreteDomain.java (rev 0)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/domain/EquationDiscreteDomain.java 2011-06-01 08:58:32 UTC (rev 3346)
@@ -0,0 +1,46 @@
+/*
+ * #%L
+ * IsisFish
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, CodeLutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-2.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.simulator.sensitivity.domain;
+
+import fr.ifremer.isisfish.entities.Equation;
+
+/**
+ * Factor domain for {@link Equation}s.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * @since 3.4.0.0
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class EquationDiscreteDomain extends DiscreteDomain {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -5611785362638191719L;
+
+}
Property changes on: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/domain/EquationDiscreteDomain.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
===================================================================
--- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2011-05-31 15:54:57 UTC (rev 3345)
+++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2011-06-01 08:58:32 UTC (rev 3346)
@@ -92,6 +92,7 @@
import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationDiscreteDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.MatrixContinuousDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.RuleDiscreteDomain;
import fr.ifremer.isisfish.ui.SimulationUI;
@@ -942,16 +943,22 @@
public void addDiscreteFactor(String name, String comment, String path,
List<Object> values, boolean exist) {
+ addDiscreteFactor(new DiscreteDomain(), name, comment, path, values, exist);
+ }
+
+ public void addDiscreteRuleFactor(String name, String comment, String path,
+ List<Object> values, boolean exist) {
+ addDiscreteFactor(new RuleDiscreteDomain(), name, comment, path, values, exist);
+ }
+
+ public void addDiscreteEquationFactor(String name, String comment, String path,
+ List<Object> values, boolean exist) {
+ addDiscreteFactor(new EquationDiscreteDomain(), name, comment, path, values, exist);
+ }
+
+ protected void addDiscreteFactor(DiscreteDomain domain, String name, String comment, String path,
+ List<Object> values, boolean exist) {
Factor f = new Factor(name);
- DiscreteDomain domain = null;
- // FIXME echatellier gere le path mieux que ca
- if ("parameters.rules".equals(path)) {
- domain = new RuleDiscreteDomain();
- }
- else {
- domain = new DiscreteDomain();
- }
-
SortedMap<Object, Object> domainValues = new TreeMap<Object, Object>();
int label = 0;
for (Object value : values) {
Modified: isis-fish/branches/3.3.1/src/test/java/fr/ifremer/isisfish/mexico/MexicoHelperTest.java
===================================================================
--- isis-fish/branches/3.3.1/src/test/java/fr/ifremer/isisfish/mexico/MexicoHelperTest.java 2011-05-31 15:54:57 UTC (rev 3345)
+++ isis-fish/branches/3.3.1/src/test/java/fr/ifremer/isisfish/mexico/MexicoHelperTest.java 2011-06-01 08:58:32 UTC (rev 3346)
@@ -56,6 +56,7 @@
import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationDiscreteDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.MatrixContinuousDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.RuleDiscreteDomain;
@@ -417,6 +418,43 @@
}
/**
+ * Test l'ajout des nouveaux type de facteurs equation discrete.
+ *
+ * @throws IOException
+ * @throws IsisFishException
+ */
+ @Test
+ public void testDiscreteEquationFactor() throws IOException, IsisFishException {
+
+ // get test plan and add some STRANGES factors
+ DesignPlan testDesignPlan = getTestDesignPlan(false);
+
+ // factor x6
+ Factor factorEquationDiscrete = new Factor("factor x6");
+ EquationDiscreteDomain domain6 = new EquationDiscreteDomain();
+ domain6.getValues().put("1", "if ( context.getValue() < 1.0) {\n\treturn 1.0;\n} else {\treturn context.getValue();\n}");
+ domain6.getValues().put("2", "if ( context.getValue() < 1.666) {\n\treturn 1.666;\n} else {\treturn context.getValue();\n}");
+ factorEquationDiscrete.setDomain(domain6);
+ factorEquationDiscrete.setPath("fr.ifremer.isisfish.entities.PopulationGroup#1156461521076#0.6526656643346673#maxLength");
+
+ testDesignPlan.addFactor(factorEquationDiscrete);
+
+ // test write
+ String content = MexicoHelper.getDesignPlanAsXML(testDesignPlan);
+ Assert.assertTrue(content.contains("context.getValue() < 1.0"));
+
+ File tempFile = File.createTempFile("testdesignplan", ".xml");
+ tempFile.deleteOnExit();
+ FileUtils.writeStringToFile(tempFile, content);
+
+ // test to read it and get content
+ DesignPlan plan = MexicoHelper.getDesignPlanFromXML(tempFile, null);
+ String reReadContent = MexicoHelper.getDesignPlanAsXML(plan);
+
+ Assert.assertEquals(content, reReadContent);
+ }
+
+ /**
* Test que l'export XML de l'import XML produise le meme xml.
* Pareil, mais pour une version v2 du schema xml.
*
1
0