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