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
November 2009
- 1 participants
- 65 discussions
r2776 - in isis-fish/trunk/src: main/java/fr/ifremer/isisfish/simulator/launcher main/resources/templates/ssh test/java/fr/ifremer/isisfish/simulator/launcher
by chatellier@users.labs.libre-entreprise.org 27 Nov '09
by chatellier@users.labs.libre-entreprise.org 27 Nov '09
27 Nov '09
Author: chatellier
Date: 2009-11-27 10:12:49 +0000 (Fri, 27 Nov 2009)
New Revision: 2776
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SSHSimulatorLauncher.java
isis-fish/trunk/src/main/resources/templates/ssh/qsub-script.ftl
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SshSimulatorLauncherTest.java
Log:
Fix pbs multijob script (missing index, bad small id)
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SSHSimulatorLauncher.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SSHSimulatorLauncher.java 2009-11-24 10:29:06 UTC (rev 2775)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SSHSimulatorLauncher.java 2009-11-27 10:12:49 UTC (rev 2776)
@@ -878,7 +878,7 @@
if (simulationItem.isLastSimulation()) {
- String shortSimulationId = simulationid.substring(simulationid.lastIndexOf('_') + 1);
+ String shortSimulationId = simulationid.substring(0, simulationid.lastIndexOf('_'));
if (log.isDebugEnabled()) {
log.debug("Last simulation start requested, send multijob start request for " + shortSimulationId);
Modified: isis-fish/trunk/src/main/resources/templates/ssh/qsub-script.ftl
===================================================================
--- isis-fish/trunk/src/main/resources/templates/ssh/qsub-script.ftl 2009-11-24 10:29:06 UTC (rev 2775)
+++ isis-fish/trunk/src/main/resources/templates/ssh/qsub-script.ftl 2009-11-27 10:12:49 UTC (rev 2776)
@@ -8,7 +8,7 @@
<#assign commonCommand="/home3/caparmor/poussin/jdk/bin/java -Xmx2500M -jar isis-fish*.jar --option launch.ui false" />
<#if qsubmutiplejob>
<#-- localsimulationid is short simulation id version -->
- <#assign localsimulationid='${simulationid}' />
+ <#assign localsimulationid='${simulationid}_$PBS_ARRAY_INDEX' />
<#assign localsimulationzip='${simulationzip?replace("${simulationid}_[0-9]+", "${simulationid}_\\\\$PBS_ARRAY_INDEX","ri")}' />
<#assign localsimulationresultzip='${simulationresultzip?replace("${simulationid}_[0-9]+", "${simulationid}_\\\\$PBS_ARRAY_INDEX","ri")}' />
<#assign localsimulationprescript='${simulationprescript?replace("${simulationid}_[0-9]+", "${simulationid}_\\\\$PBS_ARRAY_INDEX","ri")}' />
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SshSimulatorLauncherTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SshSimulatorLauncherTest.java 2009-11-24 10:29:06 UTC (rev 2775)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SshSimulatorLauncherTest.java 2009-11-27 10:12:49 UTC (rev 2776)
@@ -186,7 +186,7 @@
public void testFreemarkerTemplateMultiJobsAndScript() throws IOException,
TemplateException {
- String shortSimulationId = "sim_test1_2009-11-10-18-08";
+ String shortSimulationId = "as_blah_2009-11-27-10-39";
String simulationId = shortSimulationId + "_122";
String simulationZip = "simulation-" + simulationId + "-preparation.zip";
String simulationResultZip = "/tmp/simulation-" + simulationId + "-result.zip";
@@ -204,7 +204,7 @@
}
// simulation parameters
- Assert.assertTrue("String \"" + shortSimulationId + "\" not found in template", content.indexOf(shortSimulationId) > 0);
+ Assert.assertTrue("String \"" + shortSimulationId + "\" not found in template", content.indexOf(shortSimulationId + "_$PBS_ARRAY_INDEX\"") > 0);
Assert.assertTrue(content.indexOf("simulation-" + shortSimulationId + "_$PBS_ARRAY_INDEX-preparation.zip") > 0);
Assert.assertTrue(content.indexOf("/tmp/simulation-" + shortSimulationId + "_$PBS_ARRAY_INDEX-result.zip") > 0);
Assert.assertTrue(content.indexOf("simulation-" + shortSimulationId + "_$PBS_ARRAY_INDEX-prescript.bsh") > 0);
1
0
24 Nov '09
Author: chatellier
Date: 2009-11-24 10:29:06 +0000 (Tue, 24 Nov 2009)
New Revision: 2775
Removed:
isis-fish/trunk/src/main/resources/lutintrace.xml
Log:
Not used anymore
Deleted: isis-fish/trunk/src/main/resources/lutintrace.xml
===================================================================
--- isis-fish/trunk/src/main/resources/lutintrace.xml 2009-11-24 10:08:23 UTC (rev 2774)
+++ isis-fish/trunk/src/main/resources/lutintrace.xml 2009-11-24 10:29:06 UTC (rev 2775)
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<!DOCTYPE aspectwerkz PUBLIC
- "-//AspectWerkz//DTD//EN"
- "http://aspectwerkz.codehaus.org/dtd/aspectwerkz2.dtd">
-
-<aspectwerkz>
- <system id="trace">
- <aspect class="org.codelutin.util.LutinTrace">
- <pointcut name="executeMethod">
- execution(* fr.ifremer.isisfish.datastore..*(..))
- || execution(* fr.ifremer.isisfish.simulator..*(..))
- || execution(* fr.ifremer.isisfish.types..*(..))
- || execution(* org.codelutin.util..*(..))
- || execution(* org.codelutin.xml..*(..))
- || execution(* org.codelutin.topia..*(..))
- || execution(* org.codelutin.math.matrix..*(..))
- || execution(* org.swixat..*(..))
- </pointcut>
- </aspect>
- </system>
-</aspectwerkz>
1
0
r2774 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator
by chatellier@users.labs.libre-entreprise.org 24 Nov '09
by chatellier@users.labs.libre-entreprise.org 24 Nov '09
24 Nov '09
Author: chatellier
Date: 2009-11-24 10:08:23 +0000 (Tue, 24 Nov 2009)
New Revision: 2774
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx
Log:
Jaxx, Jaxx, Jaxx... :)
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx 2009-11-24 09:01:23 UTC (rev 2773)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx 2009-11-24 10:08:23 UTC (rev 2774)
@@ -22,6 +22,7 @@
<script><![CDATA[
import javax.swing.table.DefaultTableModel;
+ import fr.ifremer.isisfish.datastore.AnalysePlanStorage;
import fr.ifremer.isisfish.datastore.StorageChangeEvent;
import fr.ifremer.isisfish.datastore.StorageChangeListener;
import fr.ifremer.isisfish.simulator.AnalysePlan;
1
0
r2773 - in isis-fish/trunk: . src/main/java/fr/ifremer/isisfish/simulator src/main/java/fr/ifremer/isisfish/simulator/launcher src/main/java/fr/ifremer/isisfish/ui/simulator src/main/resources/i18n
by chatellier@users.labs.libre-entreprise.org 24 Nov '09
by chatellier@users.labs.libre-entreprise.org 24 Nov '09
24 Nov '09
Author: chatellier
Date: 2009-11-24 09:01:23 +0000 (Tue, 24 Nov 2009)
New Revision: 2773
Modified:
isis-fish/trunk/changelog.txt
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationService.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties
Log:
#1585 : Analyze plans are now reloaded before each simulation
Modified: isis-fish/trunk/changelog.txt
===================================================================
--- isis-fish/trunk/changelog.txt 2009-11-23 17:22:54 UTC (rev 2772)
+++ isis-fish/trunk/changelog.txt 2009-11-24 09:01:23 UTC (rev 2773)
@@ -1,8 +1,9 @@
isis-fish (3.3.0.0) stable; urgency=low
+ * #1585 : Analyze plans are now reloaded before each simulation
* Editing sensitivity factors after simulation reload now works
* Add confirmation message before launching groups creation wizard
- * Fix metierSeasonInfo deletion (#1914)
+ * #1914 : Fix metierSeasonInfo deletion
* Remove some deprecated unused UI classes
* Remove all GenericCell reference (now model based implementation)
* Add missing log category in simulation filter appender
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java 2009-11-23 17:22:54 UTC (rev 2772)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java 2009-11-24 09:01:23 UTC (rev 2773)
@@ -1583,6 +1583,9 @@
/**
* A copy instance of SimulationParameter.
*
+ * Warning, this is not a deep copy, already instancied objects are
+ * not duplicated.
+ *
* @return a copy of this instance
*/
public SimulationParameter copy() {
@@ -1648,6 +1651,21 @@
}
/**
+ * Make a deep copy of current parameters.
+ *
+ * Bump all current parameters to properties and make a new one with
+ * those propeties.
+ *
+ * @return new parameters instance
+ */
+ public SimulationParameter deepCopy() {
+ Properties props = toProperties();
+ SimulationParameter newInstance = new SimulationParameter();
+ newInstance.fromProperties(null, props);
+ return newInstance;
+ }
+
+ /**
* The toString() methode call getters.
*
* So make instances of rules/export/plans...
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationService.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationService.java 2009-11-23 17:22:54 UTC (rev 2772)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationService.java 2009-11-24 09:01:23 UTC (rev 2773)
@@ -366,9 +366,14 @@
*/
public void submit(String id, SimulationParameter param,
SimulatorLauncher launcher, int priority) {
+
+ // make deep copy, ui, still work with
+ // copy need to be deep for analyze plan to reload
+ SimulationParameter localParameters = param.deepCopy();
+
// on l'ajoute tout de suite a la liste des simulations demandee
SimulationControl control = new SimulationControl(id);
- SimulationItem item = new SimulationItem(control, param);
+ SimulationItem item = new SimulationItem(control, localParameters);
SimulationJob job = new SimulationJob(this, item, priority);
job.setLauncher(launcher);
fireStartEvent(job);
@@ -377,15 +382,15 @@
// doit etre fait AVANT de faire le prepareSimulationZipFile
// car, il est possible que l'init des plans ajoute des regles !!!
PrepareSimulationJob task = null;
- if (param.getUseAnalysePlan()) {
+ if (localParameters.getUseAnalysePlan()) {
task = new PrepareSimulationJob(this, job);
}
// on construit le zip de la simulation
- File zip = prepareSimulationZipFile(control, param, null, true);
+ File zip = prepareSimulationZipFile(control, localParameters, null, true);
item.setSimulationZip(zip);
- if (param.getUseAnalysePlan() && param.isIndependentPlan()) {
+ if (localParameters.getUseAnalysePlan() && localParameters.isIndependentPlan()) {
// c un plan d'analyse independant, on construit toute les sous simu
subSimulationComputationExecutor.execute(task);
} else {
@@ -411,6 +416,10 @@
SimulatorLauncher launcher, int priority,
SensitivityCalculator sensitivitycalculator, DesignPlan designPlan) {
+ // make deep copy, ui, still work with
+ // copy need to be deep for analyse plan to reload
+ SimulationParameter localParameters = param.deepCopy();
+
try {
// build master sensitivity export directory
@@ -428,8 +437,8 @@
.compute(designPlan, masterExportDirectory);
// ajout des parametres de simulation
- param.setSensitivityCalculator(sensitivitycalculator);
- param.setNumberOfSensitivitySimulation(sensitivityScenarios.getScenarios().size());
+ localParameters.setSensitivityCalculator(sensitivitycalculator);
+ localParameters.setNumberOfSensitivitySimulation(sensitivityScenarios.getScenarios().size());
// on l'ajoute tout de suite a la liste des simulations demandee
// init with default "id" must been changed for designPlan
@@ -438,7 +447,7 @@
// on construit le zip de la simulation
// in zip, there will be param "without" prescript
- File zip = prepareSimulationZipFile(controlJustForZip, param, xmlDesignPlan, true);
+ File zip = prepareSimulationZipFile(controlJustForZip, localParameters, xmlDesignPlan, true);
// for each simulation, we neeed to launch a specific simulation
// new simulation ids will be id + "_" + x
@@ -449,7 +458,7 @@
// modify modification parameter
// subParam only convenient for add pre script
// for launcher
- SimulationParameter subParam = param.copy();
+ SimulationParameter subParam = localParameters.copy();
String preScriptContent = generatePreScript(scenario);
// usefull next two line ?
subParam.setUsePreScript(true);
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx 2009-11-23 17:22:54 UTC (rev 2772)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SensUI.jaxx 2009-11-24 09:01:23 UTC (rev 2773)
@@ -22,6 +22,8 @@
<script><![CDATA[
import javax.swing.table.DefaultTableModel;
+ import fr.ifremer.isisfish.datastore.StorageChangeEvent;
+ import fr.ifremer.isisfish.datastore.StorageChangeListener;
import fr.ifremer.isisfish.simulator.AnalysePlan;
import fr.ifremer.isisfish.ui.models.analyzeplan.AnalyzePlanComboModel;
import fr.ifremer.isisfish.ui.models.analyzeplan.AnalyzePlanComboRenderer;
@@ -31,6 +33,16 @@
import fr.ifremer.isisfish.ui.models.analyzeplan.AnalyzePlanParametersTableCellEditor;
import fr.ifremer.isisfish.ui.models.analyzeplan.AnalyzePlanParametersTableCellRenderer;
+ // to be notified of storage change event
+ StorageChangeListener analyzePlanStorageListener;
+ analyzePlanStorageListener = new StorageChangeListener() {
+ @Override
+ public void versionDataChanged(StorageChangeEvent e) {
+ refresh();
+ }
+ };
+ AnalysePlanStorage.addStorageChangeListener(analyzePlanStorageListener);
+
public void refresh() {
// analyse plans names list
fieldSimulParamsAnalysePlansSelect.setModel(getAnalyzePlansComboModel());
@@ -44,8 +56,6 @@
protected AnalyzePlanComboModel getAnalyzePlansComboModel() {
java.util.List<String> analyzePlanNames = simulAction.getAnalysePlanNames();
AnalyzePlanComboModel model = new AnalyzePlanComboModel(analyzePlanNames);
- /*fieldSimulParamsAnalysePlansSelect.setModel(model);
- fieldSimulParamsAnalysePlansSelect.setRenderer(new AnalyzePlanComboRenderer());*/
return model;
}
@@ -55,8 +65,6 @@
protected AnalyzePlanListModel getSimulationAnalyzePlansListModel() {
java.util.List<AnalysePlan> analyzePlans = simulAction.getParamAnalysePlans();
AnalyzePlanListModel model = new AnalyzePlanListModel(analyzePlans);
- /*listSimulParamsAnalysePlansList.setModel(model);
- listSimulParamsAnalysePlansList.setCellRenderer(new AnalyzePlanListRenderer());*/
return model;
}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2009-11-23 17:22:54 UTC (rev 2772)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2009-11-24 09:01:23 UTC (rev 2773)
@@ -201,7 +201,7 @@
FileOutputStream fos = null;
try {
fos = new FileOutputStream(f);
- param.copy().toProperties().store(fos, simulName);
+ param.toProperties().store(fos, simulName);
} catch (Exception e) {
if (log.isErrorEnabled()) {
log.error("Can't save simulation", e);
@@ -967,9 +967,7 @@
ErrorHelper.showErrorDialog(_("isisfish.simulator.simulaction.badid",
fullSimulationId), null);
} else {
- SimulationParameter p = param.copy();
-
- SimulationService.getService().submit(fullSimulationId, p,
+ SimulationService.getService().submit(fullSimulationId, param,
launcher, 0);
}
} catch (Exception eee) {
@@ -1014,8 +1012,7 @@
ErrorHelper.showErrorDialog(_("isisfish.simulator.simulaction.badid",
fullSimulationId), null);
} else {
- SimulationParameter p = param.copy();
- SimulationService.getService().submit(fullSimulationId, p,
+ SimulationService.getService().submit(fullSimulationId, param,
launcher, 0, sensitivityCalculator, designPlan);
}
} catch (Exception eee) {
Modified: isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties
===================================================================
--- isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties 2009-11-23 17:22:54 UTC (rev 2772)
+++ isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties 2009-11-24 09:01:23 UTC (rev 2773)
@@ -389,7 +389,7 @@
isisfish.error.undefined.correspondence.zones.reproduction.recruitment=pas de correspondance entre les zones de reproduction et les zones de recrutement
isisfish.error.undefined.gear=The engin is not defined
isisfish.error.undefined.mesh=No mesh defined
-isisfish.error.undefined.mesh.sector=No maille defined in sector
+isisfish.error.undefined.mesh.sector=No mesh defined in sector
isisfish.error.undefined.meta.population=No population defined
isisfish.error.undefined.natural.death=No natural mortality on classes naissantes
isisfish.error.undefined.sector=No sector defined
1
0
r2772 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator
by chatellier@users.labs.libre-entreprise.org 23 Nov '09
by chatellier@users.labs.libre-entreprise.org 23 Nov '09
23 Nov '09
Author: chatellier
Date: 2009-11-23 17:22:54 +0000 (Mon, 23 Nov 2009)
New Revision: 2772
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java
Log:
Remove deprecated "analyzePlan" parameter.
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java 2009-11-23 15:03:22 UTC (rev 2771)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java 2009-11-23 17:22:54 UTC (rev 2772)
@@ -152,12 +152,6 @@
/** Utilisation du plan d'analyse. */
protected Boolean useAnalysePlan;
- /**
- * Le script de plan d'analyse.
- * @deprecated since 3.2.0.7 unused
- */
- protected String analysePlan;
-
/**
* Le numero de sequence de la liste des plans d'analyse. Le premier
* élement du plan doit etre 0. Si la simulation ne fait pas partie d'un
@@ -1146,39 +1140,6 @@
}
/**
- * Return analyse plan content.
- *
- * Default to "".
- *
- * @return Returns the analysePlan.
- *
- * @deprecated since 3.2.0.7 unused
- */
- public String getAnalysePlan() {
-
- if (analysePlan == null) {
-
- if (propertiesParameters != null) {
- analysePlan = propertiesParameters.getProperty("analysePlan", "");
- } else {
- analysePlan = "";
- }
- }
-
- return this.analysePlan;
- }
-
- /**
- * Set analyse plan content.
- *
- * @param analysePlan The analysePlan to set.
- * @deprecated since 3.2.0.7 unused
- */
- public void setAnalysePlan(String analysePlan) {
- this.analysePlan = analysePlan;
- }
-
- /**
* Get simulation number in analyse plan.
*
* @return simulation number in analyse plan
@@ -1647,7 +1608,6 @@
result.usePreScript = getUsePreScript();
result.preScript = getPreScript();
result.useAnalysePlan = getUseAnalysePlan();
- result.analysePlan = getAnalysePlan();
result.analysePlanNumber = getAnalysePlanNumber();
result.onlyExport = getOnlyExport();
if (exportNames != null) {
@@ -1960,7 +1920,6 @@
result.setProperty("usePreScript", String.valueOf(getUsePreScript()));
result.setProperty("preScript", getPreScript());
result.setProperty("useAnalysePlan", String.valueOf(getUseAnalysePlan()));
- result.setProperty("analysePlan", getAnalysePlan());
result.setProperty("analysePlanNumber", String.valueOf(getAnalysePlanNumber()));
String resultList = "";
1
0
r2771 - in isis-fish/trunk/src/main: java/fr/ifremer/isisfish/map java/fr/ifremer/isisfish/ui/input resources/i18n
by chatellier@users.labs.libre-entreprise.org 23 Nov '09
by chatellier@users.labs.libre-entreprise.org 23 Nov '09
23 Nov '09
Author: chatellier
Date: 2009-11-23 15:03:22 +0000 (Mon, 23 Nov 2009)
New Revision: 2771
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/CellSelectionLayer.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Coordinate.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/CopyMapToClipboardListener.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMap.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMapInfo.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMapList.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DefaultDataMap.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DefaultScale.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/IsisMapBean.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Motif.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/ResultatLayer.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Scale.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/ZoneDelimiterLayer.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java
isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties
isis-fish/trunk/src/main/resources/i18n/isis-fish-fr_FR.properties
Log:
Add new maps file formats management.
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/CellSelectionLayer.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/CellSelectionLayer.java 2009-11-23 11:04:14 UTC (rev 2770)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/CellSelectionLayer.java 2009-11-23 15:03:22 UTC (rev 2771)
@@ -219,9 +219,9 @@
* receiving events in "select" mode.
* <code>
* <pre>
- * return new String[1] {
+ * return new String[1] {
* SelectMouseMode.modeID
- * };
+ * };
* </pre>
* <code>
* @see NavMouseMode#modeID
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Coordinate.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Coordinate.java 2009-11-23 11:04:14 UTC (rev 2770)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Coordinate.java 2009-11-23 15:03:22 UTC (rev 2771)
@@ -18,17 +18,22 @@
package fr.ifremer.isisfish.map;
+import java.awt.geom.Point2D;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
/**
- * Coordinate.
+ * Coordinate extends Float point to add serialisation implementation.
*
* Created: Mon Apr 22 16:49:52 2002
*
* @author <a href="mailto:seb.regnier at free.fr"></a>
* @version $Revision$
*/
-public class Coordinate extends java.awt.geom.Point2D.Float implements java.io.Serializable {
-
- /** serialVersionUID */
+public class Coordinate extends Point2D.Float implements Serializable {
+
+ /** serialVersionUID. */
private static final long serialVersionUID = 1L;
public Coordinate() {
@@ -39,15 +44,15 @@
super(latitude, longitude);
}
- private void writeObject(java.io.ObjectOutputStream stream)
- throws java.io.IOException {
+ protected void writeObject(ObjectOutputStream stream)
+ throws java.io.IOException {
stream.writeFloat(x);
stream.writeFloat(y);
}
- private void readObject(java.io.ObjectInputStream stream)
- throws java.io.IOException {
+ protected void readObject(ObjectInputStream stream)
+ throws java.io.IOException {
x = stream.readFloat();
y = stream.readFloat();
}
-}// Coordinate
+} // Coordinate
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/CopyMapToClipboardListener.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/CopyMapToClipboardListener.java 2009-11-23 11:04:14 UTC (rev 2770)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/CopyMapToClipboardListener.java 2009-11-23 15:03:22 UTC (rev 2771)
@@ -43,7 +43,7 @@
import com.bbn.openmap.event.MapMouseListener;
/**
- * Listener for openmap map bean to display popop menu on rigth clic.
+ * Listener for openmap map bean to display popop menu on right click.
*
* Currently, this listener can :
* - copy current map to system clip board
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMap.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMap.java 2009-11-23 11:04:14 UTC (rev 2770)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMap.java 2009-11-23 15:03:22 UTC (rev 2771)
@@ -31,7 +31,7 @@
* @author <a href="mailto:seb.regnier at free.fr"></a>
* @version $Revision$
*/
-public interface DataMap extends Serializable{
+public interface DataMap extends Serializable {
/**
* Get the coordinates of the Cells position of the DataMap on the map.
@@ -51,4 +51,4 @@
*/
public DataMapInfo getInfo();
-}// DataMap
+} // DataMap
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMapInfo.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMapInfo.java 2009-11-23 11:04:14 UTC (rev 2770)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMapInfo.java 2009-11-23 15:03:22 UTC (rev 2771)
@@ -20,7 +20,6 @@
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
/**
@@ -33,7 +32,7 @@
*/
public class DataMapInfo implements Serializable {
- /** serialVersionUID */
+ /** serialVersionUID. */
private static final long serialVersionUID = -8530276186766231164L;
protected List<String> labels = new ArrayList<String>();
@@ -51,9 +50,9 @@
public String getLabels() {
String str = "";
- for (Iterator i = labels.iterator(); i.hasNext();) {
- str += (String) i.next();
+ for (String label : labels) {
+ str += label;
}
return str;
}
-}// DataMapInfo
+} // DataMapInfo
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMapList.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMapList.java 2009-11-23 11:04:14 UTC (rev 2770)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DataMapList.java 2009-11-23 15:03:22 UTC (rev 2771)
@@ -19,7 +19,9 @@
package fr.ifremer.isisfish.map;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.Enumeration;
+import java.util.List;
import java.util.Vector;
import org.apache.commons.logging.Log;
@@ -78,7 +80,7 @@
*
* @return Enumeration
*/
- public Enumeration getDataMaps() {
+ public Enumeration<DataMap> getDataMaps() {
return dataMap.elements();
}
@@ -87,8 +89,8 @@
* @param c ?
* @return Get all the data map of this list
*/
- public Vector getDataMaps(Coordinate c) {
- Vector<DataMap> v = new Vector<DataMap>();
+ public List<DataMap> getDataMaps(Coordinate c) {
+ List<DataMap> v = new ArrayList<DataMap>();
DataMap dm;
for (Object aDataMap : dataMap) {
dm = (DataMap) aDataMap;
@@ -171,8 +173,8 @@
*/
public double getMaxDataMapValue() {
double max = 0;
- for (Enumeration enu = dataMap.elements(); enu.hasMoreElements();) {
- max = Math.max(max, ((DataMap) enu.nextElement()).getValue());
+ for (Enumeration<DataMap> enu = dataMap.elements(); enu.hasMoreElements();) {
+ max = Math.max(max, enu.nextElement().getValue());
}
return max;
}
@@ -182,8 +184,8 @@
*/
public double getMinDataMapValue() {
double min = 0;
- for (Enumeration enu = dataMap.elements(); enu.hasMoreElements();) {
- min = Math.min(min, ((DataMap) enu.nextElement()).getValue());
+ for (Enumeration<DataMap> enu = dataMap.elements(); enu.hasMoreElements();) {
+ min = Math.min(min, enu.nextElement().getValue());
}
return min;
}
@@ -194,8 +196,8 @@
public double getPositiveMinDataMapValue() {
double min = 0;
double tmp;
- for (Enumeration enu = dataMap.elements(); enu.hasMoreElements();) {
- tmp = Math.min(min, ((DataMap) enu.nextElement()).getValue());
+ for (Enumeration<DataMap> enu = dataMap.elements(); enu.hasMoreElements();) {
+ tmp = Math.min(min, enu.nextElement().getValue());
if (tmp > 0) {
min = tmp;
}
@@ -223,11 +225,11 @@
scale = new DefaultScale(getMaxDataMapValue());
}
DataMap datamap;
- for (Enumeration enu = getDataMaps(); enu.hasMoreElements();) {
- datamap = (DataMap) enu.nextElement();
+ for (Enumeration<DataMap> enu = getDataMaps(); enu.hasMoreElements();) {
+ datamap = enu.nextElement();
motif.createOMDataMap(proj, omlist, scale, datamap);
}
}
return omlist;
}
-}// DataMapList
+} // DataMapList
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DefaultDataMap.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DefaultDataMap.java 2009-11-23 11:04:14 UTC (rev 2770)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DefaultDataMap.java 2009-11-23 15:03:22 UTC (rev 2771)
@@ -26,10 +26,9 @@
* @author <a href="mailto:seb.regnier at free.fr"></a>
* @version $Revision$
*/
-
public class DefaultDataMap implements DataMap {
- /** serialVersionUID */
+ /** serialVersionUID. */
private static final long serialVersionUID = 3277576798583867731L;
protected double value;
@@ -86,9 +85,10 @@
String[] lat = latitudes.trim().split(" ");
String[] lon = longitudes.trim().split(" ");
coordinates = new Coordinate[lat.length];
- for (int i = 0; i < lat.length; i++)
+ for (int i = 0; i < lat.length; i++) {
coordinates[i] = new Coordinate(Float.parseFloat(lat[i]), Float
.parseFloat(lon[i]));
+ }
}
/**
@@ -99,8 +99,9 @@
*/
public void setCoordinates(float[] latitudes, float[] longitudes) {
coordinates = new Coordinate[latitudes.length];
- for (int i = 0; i < latitudes.length; i++)
+ for (int i = 0; i < latitudes.length; i++) {
coordinates[i] = new Coordinate(latitudes[i], longitudes[i]);
+ }
}
/**
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DefaultScale.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DefaultScale.java 2009-11-23 11:04:14 UTC (rev 2770)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/DefaultScale.java 2009-11-23 15:03:22 UTC (rev 2771)
@@ -21,16 +21,14 @@
/**
* DefaultScale.java
*
- *
* Created: Mon Apr 22 16:52:17 2002
*
* @author <a href="mailto:seb.regnier at free.fr"></a>
* @version $Revision$
*/
-
public class DefaultScale implements Scale {
- /** serialVersionUID */
+ /** serialVersionUID. */
private static final long serialVersionUID = -3348731042237607596L;
public double min;
@@ -98,4 +96,4 @@
return Math.sqrt(scale);
}
-}// DefaultScale
+} // DefaultScale
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/IsisMapBean.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/IsisMapBean.java 2009-11-23 11:04:14 UTC (rev 2770)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/IsisMapBean.java 2009-11-23 15:03:22 UTC (rev 2771)
@@ -21,16 +21,17 @@
import static org.nuiton.i18n.I18n._;
+import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
-import org.nuiton.util.Resource;
import com.bbn.openmap.BufferedMapBean;
import com.bbn.openmap.LatLonPoint;
@@ -41,7 +42,12 @@
import com.bbn.openmap.event.MapMouseMode;
import com.bbn.openmap.event.NavMouseMode;
import com.bbn.openmap.layer.GraticuleLayer;
+import com.bbn.openmap.layer.dted.DTEDLayer;
+import com.bbn.openmap.layer.e00.E00Layer;
+import com.bbn.openmap.layer.mif.MIFLayer;
+import com.bbn.openmap.layer.rpf.RpfLayer;
import com.bbn.openmap.layer.shape.ShapeLayer;
+import com.bbn.openmap.layer.vpf.VPFLayer;
import com.bbn.openmap.omGraphics.DrawingAttributes;
import fr.ifremer.isisfish.IsisFish;
@@ -80,7 +86,7 @@
protected List<MapMouseListener> orderedListener = new ArrayList<MapMouseListener>();
protected LayerHandler layerHandler = new LayerHandler();
- protected MapMouseMode currentMouseMode;// = new SelectMouseMode(false);
+ protected MapMouseMode currentMouseMode;
protected MouseDelegator md;
protected CellSelectionLayer activeSelectionLayer = null;
@@ -88,39 +94,39 @@
protected static final float SCALE = 9500000f;
- public IsisMapBean (){
+ public IsisMapBean() {
init();
setActiveMouseMode(new NavMouseMode());
}
- protected void init(){
+ protected void init() {
setScale(SCALE);
// Let the LayerHandler know who is interested in Layers.
//MapBean is just one component
layerHandler.addLayerListener(this);
md = new MouseDelegator(this);
- // md.addMouseMode(selectMouseMode);
+ // md.addMouseMode(selectMouseMode);
// Tell the delegator to use the default modes: Navigation
// and Selection
md.setDefaultMouseModes();
}
- public void setActiveMouseMode(MapMouseMode mode){
+ public void setActiveMouseMode(MapMouseMode mode) {
md.setActiveMouseMode(mode);
currentMouseMode = mode;
// il faut remettre les listeners
- for(MapMouseListener l: orderedListener){
+ for (MapMouseListener l : orderedListener) {
currentMouseMode.addMapMouseListener(l);
}
}
- public void addMapMouseListener(MapMouseListener mml){
- if (mml instanceof CellSelectionLayer || mml instanceof ResultatLayer){
+ public void addMapMouseListener(MapMouseListener mml) {
+ if (mml instanceof CellSelectionLayer || mml instanceof ResultatLayer) {
// faut que certain listener soit toujours en premier
orderedListener.add(0, mml);
currentMouseMode.removeAllMapMouseListeners();
- for(MapMouseListener l: orderedListener){
+ for (MapMouseListener l : orderedListener) {
currentMouseMode.addMapMouseListener(l);
}
} else {
@@ -129,21 +135,22 @@
}
}
- public void removeMapMouseListener(MapMouseListener mml){
+ public void removeMapMouseListener(MapMouseListener mml) {
currentMouseMode.removeMapMouseListener(mml);
}
/**
- * Get the value of region.
- * @return value of region.
- */
+ * Get the value of region.
+ * @return value of region.
+ */
public FisheryRegion getFisheryRegion() {
return fisheryRegion;
}
public void setFisheryRegion(FisheryRegion fisheryRegion) {
- if(log.isDebugEnabled()){
- log.debug("current fishery is now: " + fisheryRegion + " old was: " + this.fisheryRegion);
+ if (log.isDebugEnabled()) {
+ log.debug("current fishery is now: " + fisheryRegion + " old was: "
+ + this.fisheryRegion);
}
try {
@@ -152,7 +159,7 @@
if (fisheryRegion == null) {
layerHandler.removeAll();
} else {
- if(!fisheryRegion.equals(oldFisheryRegion)){
+ if (!fisheryRegion.equals(oldFisheryRegion)) {
pasMailleLatitude = fisheryRegion.getCellLengthLatitude();
pasMailleLongitude = fisheryRegion.getCellLengthLongitude();
minLatitude = fisheryRegion.getMinLatitude();
@@ -162,17 +169,18 @@
initMap();
}
}
- } catch(Exception eee) {
+ } catch (Exception eee) {
if (log.isErrorEnabled()) {
log.error("Impossible d'initialiser la Region", eee);
}
}
}
-
+
protected TopiaContext getTopiaContext() {
TopiaContext result = getFisheryRegion().getTopiaContext();
if (result == null) {
- throw new IsisFishRuntimeException("Can't get topiaContext from FisheryRegion");
+ throw new IsisFishRuntimeException(
+ "Can't get topiaContext from FisheryRegion");
}
return result;
}
@@ -182,19 +190,20 @@
}
/**
- * Retourne la liste des mailles selectionnées
+ * Retourne la liste des mailles selectionnées.
+ *
+ * @return selected map list
*/
- public List<Cell> getSelectedCells(){
+ public List<Cell> getSelectedCells() {
try {
List<Cell> result = new ArrayList<Cell>();
List<LatLonPoint> pts = activeSelectionLayer.getSelected();
- for(LatLonPoint llp: pts){
+ for (LatLonPoint llp : pts) {
List<Cell> cells = null;
- try{
- cells = getCellDAO().findAllByProperties(
- "latitude", llp.getLatitude(),
- "longitude", llp.getLongitude());
- } catch (TopiaException eee){
+ try {
+ cells = getCellDAO().findAllByProperties("latitude",
+ llp.getLatitude(), "longitude", llp.getLongitude());
+ } catch (TopiaException eee) {
log.warn("Can't find cell for this point: " + llp, eee);
}
if (cells != null && cells.size() > 0) {
@@ -210,50 +219,52 @@
}
}
- public void setSelectedCells(List<Cell> cells){
- if (cells != null){
+ public void setSelectedCells(List<Cell> cells) {
+ if (cells != null) {
setSelectedCells(cells.toArray(new Cell[cells.size()]));
} else {
setSelectedCells();
}
}
- public void setSelectedCells(Cell ... cells) {
- if(log.isDebugEnabled()){
+ public void setSelectedCells(Cell... cells) {
+ if (log.isDebugEnabled()) {
log.debug("Select cells: " + Arrays.toString(cells));
}
activeSelectionLayer.unSelectAll();
addSelectedCells(cells);
}
- public void addSelectedCells(Cell ... cells) {
- if(log.isDebugEnabled()){
+ public void addSelectedCells(Cell... cells) {
+ if (log.isDebugEnabled()) {
log.debug("add select cells: " + Arrays.toString(cells));
}
- for(Cell cell: cells){
+ for (Cell cell : cells) {
if (cell != null) {
- activeSelectionLayer.select(
- (cell.getLatitude() + cell.getLatitude() + pasMailleLatitude) / 2f,
- (cell.getLongitude() + cell.getLongitude() + pasMailleLongitude) / 2f);
- }
+ activeSelectionLayer.select((cell.getLatitude()
+ + cell.getLatitude() + pasMailleLatitude) / 2f, (cell
+ .getLongitude()
+ + cell.getLongitude() + pasMailleLongitude) / 2f);
+ }
}
}
- public void removeSelectedCells(Cell ... cells) {
- if(log.isDebugEnabled()){
+ public void removeSelectedCells(Cell... cells) {
+ if (log.isDebugEnabled()) {
log.debug("remove select cells: " + Arrays.toString(cells));
}
- for(Cell cell: cells){
- activeSelectionLayer.unSelect(
- (cell.getLatitude() + cell.getLatitude() + pasMailleLatitude) / 2f,
- (cell.getLongitude() + cell.getLongitude() + pasMailleLongitude) / 2f);
+ for (Cell cell : cells) {
+ activeSelectionLayer.unSelect((cell.getLatitude()
+ + cell.getLatitude() + pasMailleLatitude) / 2f, (cell
+ .getLongitude()
+ + cell.getLongitude() + pasMailleLongitude) / 2f);
}
}
/**
- * Get the value of layerHandler.
- * @return value of layerHandler.
- */
+ * Get the value of layerHandler.
+ * @return value of layerHandler.
+ */
public LayerHandler getLayerHandler() {
return layerHandler;
}
@@ -266,60 +277,284 @@
public void removeAllResultatLayer() {
Layer[] layers = layerHandler.getLayers();
- for(int i = 0; i < layers.length; i++){
- if ( layers[i] instanceof ResultatLayer){
- removeMapMouseListener((MapMouseListener)layers[i]);
+ for (int i = 0; i < layers.length; i++) {
+ if (layers[i] instanceof ResultatLayer) {
+ removeMapMouseListener((MapMouseListener) layers[i]);
layerHandler.removeLayer(layers[i]);
}
}
}
+ /**
+ * Add a new layer to the map depending on mapFile extension.
+ *
+ * @param layerId layer id
+ * @param mapFile absolute map fail path
+ * @param lineColor line color
+ * @param fillColor fill color
+ */
+ protected void addLayer(String layerId, String mapFile, String lineColor,
+ String fillColor) {
+ Layer layer = null;
+ // get layer depending on type
+ if (mapFile.endsWith(".shp")) {
+ layer = getShapeLayer(layerId, mapFile, lineColor, fillColor);
+ }
+ else if (mapFile.endsWith(".e00")) {
+ layer = getE00Layer(layerId, mapFile, lineColor, fillColor);
+ }
+ else if (mapFile.endsWith(".mif")) {
+ layer = getMIFLayer(layerId, mapFile, lineColor, fillColor);
+ }
+ else if (mapFile.endsWith(".rpf") || mapFile.endsWith(".cadrg") || mapFile.endsWith(".cib")) {
+ layer = getRPFLayer(layerId, mapFile, lineColor, fillColor);
+ }
+ else if (mapFile.endsWith(".vmap") || mapFile.endsWith(".dcw") || mapFile.endsWith(".vpf")) {
+ layer = getVPFLayer(layerId, mapFile, lineColor, fillColor);
+ }
+ /*else if (mapFile.endsWith(".dt0")) {
+ layer = getDTEDLayer(layerId, mapFile, lineColor, fillColor);
+ }*/
+ else {
+ if (log.isErrorEnabled()) {
+ log.error("Can't find layer for " + mapFile + " (unknown type)");
+ }
+ }
+
+ // display layer
+ if (layer != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Add layer " + layer);
+ }
+ layerHandler.addLayer(layer);
+ }
+ }
+
/**
- * Add a ShapeLayer to the Map.
- */
- protected void addShapeLayer(String id,
- String shapeFile, String spatialIndex,
- String lineColor, String fillColor) {
+ * Manage shp layer display.
+ *
+ * @param layerId layer id
+ * @param mapFile absolute map fail path
+ * @param lineColor line color
+ * @param fillColor fill color
+ *
+ * @return shape layer
+ * @see ShapeLayer
+ */
+ protected Layer getShapeLayer(String layerId, String mapFile, String lineColor,
+ String fillColor) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Get ShapeLayer with filename : " + mapFile);
+ }
+
+ ShapeLayer shapeLayer = new ShapeLayer();
Properties p = new Properties();
- p.setProperty(id+"."+ShapeLayer.shapeFileProperty, shapeFile);
- // unneeded with openmap 4.6.5
- //p.setProperty(id+"."+ShapeLayer.spatialIndexProperty, spatialIndex);
- p.setProperty(id+"."+DrawingAttributes.linePaintProperty, lineColor);
- p.setProperty(id+"."+DrawingAttributes.fillPaintProperty, fillColor);
- ShapeLayer slayer = new ShapeLayer();
- slayer.setProperties(id, p);
- slayer.setName(id);
- layerHandler.addLayer(slayer);
+ p.setProperty(layerId + "." + ShapeLayer.shapeFileProperty, mapFile);
+ p.setProperty(layerId + "." + DrawingAttributes.linePaintProperty, lineColor);
+ p.setProperty(layerId + "." + DrawingAttributes.fillPaintProperty, fillColor);
+ shapeLayer.setProperties(layerId, p);
+ shapeLayer.setName(layerId);
+
+ return shapeLayer;
}
+ /**
+ * Manage E00 layer display.
+ *
+ * @param layerId layer id
+ * @param mapFile absolute map fail path
+ * @param lineColor line color
+ * @param fillColor fill color
+ *
+ * @return e00 layer
+ * @see E00Layer
+ */
+ protected Layer getE00Layer(String layerId, String mapFile, String lineColor,
+ String fillColor) {
+ if (log.isDebugEnabled()) {
+ log.debug("Get E00Layer with filename : " + mapFile);
+ }
+ E00Layer e00Layer = new E00Layer();
+ Properties p = new Properties();
+ p.setProperty(layerId + ".FileName", mapFile);
+ p.setProperty(layerId + "." + DrawingAttributes.linePaintProperty, lineColor);
+ p.setProperty(layerId + "." + DrawingAttributes.fillPaintProperty, fillColor);
+ e00Layer.setProperties(layerId, p);
+ e00Layer.setName(layerId);
+
+ return e00Layer;
+ }
+
+ /**
+ * Manage DTED layer display.
+ *
+ * @param layerId layer id
+ * @param mapFile absolute map fail path
+ * @param lineColor line color
+ * @param fillColor fill color
+ *
+ * @return dted layer
+ * @see DTEDLayer
+ */
+ protected Layer getDTEDLayer(String layerId, String mapFile, String lineColor,
+ String fillColor) {
+ if (log.isDebugEnabled()) {
+ log.debug("Get DTEDLayer with filename : " + mapFile);
+ }
+
+ // get current map parent file
+ File mapFileFile = new File(mapFile);
+ String parentFolder = mapFileFile.getParent();
+
+ DTEDLayer dtedLayer = new DTEDLayer();
+ Properties p = new Properties();
+ p.setProperty(layerId + ".dted.paths", parentFolder);
+ p.setProperty(layerId + "." + DrawingAttributes.linePaintProperty, lineColor);
+ p.setProperty(layerId + "." + DrawingAttributes.fillPaintProperty, fillColor);
+
+ dtedLayer.setProperties(layerId, p);
+ dtedLayer.setName(layerId);
+
+ return dtedLayer;
+ }
+
+ /**
+ * Manage MIF layer display.
+ *
+ * @param layerId layer id
+ * @param mapFile absolute map fail path
+ * @param lineColor line color
+ * @param fillColor fill color
+ *
+ * @return mif layer
+ * @see MIFLayer
+ */
+ protected Layer getMIFLayer(String layerId, String mapFile, String lineColor,
+ String fillColor) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Get MIFLayer with filename : " + mapFile);
+ }
+
+ MIFLayer mifLayer = new MIFLayer();
+ Properties p = new Properties();
+ p.setProperty(layerId + "." + MIFLayer.MIF_FileProperty, mapFile);
+ p.setProperty(layerId + "." + MIFLayer.pointVisibleProperty, "true");
+ p.setProperty(layerId + "." + DrawingAttributes.linePaintProperty, lineColor);
+ p.setProperty(layerId + "." + DrawingAttributes.fillPaintProperty, fillColor);
+
+ mifLayer.setProperties(layerId, p);
+ mifLayer.setName(layerId);
+
+ return mifLayer;
+
+ }
+
+ /**
+ * Manage RPF layer display.
+ *
+ * Seams to handle cadrg and cib files too.
+ *
+ * @param layerId layer id
+ * @param mapFile absolute map fail path
+ * @param lineColor line color
+ * @param fillColor fill color
+ *
+ * @return rpf layer
+ * @see RpfLayer
+ */
+ protected Layer getRPFLayer(String layerId, String mapFile, String lineColor,
+ String fillColor) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Get RpfLayer with filename : " + mapFile);
+ }
+
+ // get current map parent file
+ File mapFileFile = new File(mapFile);
+ String parentFolder = mapFileFile.getParent();
+
+ RpfLayer rpfLayer = new RpfLayer();
+ Properties p = new Properties();
+ // This property should reflect the paths to the RPF directories
+ p.setProperty(layerId + ".rpf.paths", parentFolder);
+ p.setProperty(layerId + "." + MIFLayer.pointVisibleProperty, "true");
+ p.setProperty(layerId + "." + DrawingAttributes.linePaintProperty, lineColor);
+ p.setProperty(layerId + "." + DrawingAttributes.fillPaintProperty, fillColor);
+
+ rpfLayer.setProperties(layerId, p);
+ rpfLayer.setName(layerId);
+
+ return rpfLayer;
+
+ }
+
+ /**
+ * Manage VPF layer display.
+ *
+ * Can manage .vmap, .dcw, .vpf files ?
+ *
+ * @param layerId layer id
+ * @param mapFile absolute map fail path
+ * @param lineColor line color
+ * @param fillColor fill color
+ *
+ * @return vpf layer
+ * @see vpfLayer
+ */
+ protected Layer getVPFLayer(String layerId, String mapFile, String lineColor,
+ String fillColor) {
+
+ // on presume que, dans le cas d'IsisFish, les cartes VMap ne
+ // sont pas politiques.
+
+ if (log.isDebugEnabled()) {
+ log.debug("Get vpfLayer with filename : " + mapFile);
+ }
+
+ VPFLayer vpfLayer = new VPFLayer();
+ Properties p = new Properties();
+ p.setProperty(layerId + "." + VPFLayer.pathProperty, mapFile);
+ p.setProperty(layerId + "." + VPFLayer.defaultLayerProperty, "vmapCoastline");
+ p.setProperty(layerId + "." + DrawingAttributes.linePaintProperty, lineColor);
+ p.setProperty(layerId + "." + DrawingAttributes.fillPaintProperty, fillColor);
+
+ vpfLayer.setProperties(layerId, p);
+ vpfLayer.setName(layerId);
+
+ return vpfLayer;
+
+ }
+
protected void addGraticuleLayer() {
GraticuleLayer layer = new GraticuleLayer();
Properties p = new Properties();
// Show lat / lon spacing labels
- p.setProperty(".showRuler","true");
- p.setProperty(".show1And5Lines","true");
+ p.setProperty("." + GraticuleLayer.ShowRulerProperty, "true");
+ p.setProperty("." + GraticuleLayer.ShowOneAndFiveProperty, "true");
// Controls when the five degree lines and one degree lines kick in
// - when there is less than the threshold of ten degree lat or lon
// lines, five degree lines are drawn. The same relationship is there
// for one to five degree lines.
- p.setProperty(".threshold","5");
+ p.setProperty("." + GraticuleLayer.ThresholdProperty, "5");
// the color of 10 degree spacing lines (Hex ARGB)
- p.setProperty(".10DegreeColor","FF000000");
+ p.setProperty("." + GraticuleLayer.TenDegreeColorProperty, "FF000000");
// the color of 5 degree spacing lines (Hex ARGB)
- p.setProperty(".5DegreeColo","C7009900");
- // the color of 1 degree spaing lines (ARGB)
- p.setProperty(".1DegreeColor","FF003300");
+ p.setProperty("." + GraticuleLayer.FiveDegreeColorProperty, "C7009900");
+ // the color of 1 degree spacing lines (ARGB)
+ p.setProperty("." + GraticuleLayer.OneDegreeColorProperty, "FF003300");
// the color of the equator (ARGB)
- p.setProperty(".equatorColor","FFFF0000");
+ p.setProperty("." + GraticuleLayer.EquatorColorProperty, "FFFF0000");
// the color of the international dateline (ARGB)
- p.setProperty(".dateLineColor","FF000099");
+ p.setProperty("." + GraticuleLayer.DateLineColorProperty, "FF000099");
// the color of the special lines (ARGB) (Tropic of Cancer, Capricorn)
- p.setProperty(".specialLineColor","FF000000");
+ p.setProperty("." + GraticuleLayer.SpecialLineColorProperty, "FF000000");
// the color of the labels (ARGB)
- p.setProperty(".textColor","FF000000");
+ p.setProperty("." + GraticuleLayer.TextColorProperty, "FF000000");
- layer.setProperties("",p);
+ layer.setProperties("", p);
layerHandler.addLayer(layer);
}
@@ -328,12 +563,14 @@
layerHandler.addLayer(layer);
}
- protected void addSpecificLayer(){
- try{
+ protected void addSpecificLayer() {
+ try {
addSelectionLayer();
addZoneDelimiterLayer();
- }catch(TopiaException eee){
- log.warn("Can't add specific layer", eee);
+ } catch (TopiaException eee) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't add specific layer", eee);
+ }
}
}
@@ -346,132 +583,72 @@
float centerLong = (maxLongitude + minLongitude) / 2f;
layerHandler.removeAll();
//setProjection( new Mercator(new LatLonPoint(centerLat, centerLong), SCALE, 480, 540));
+
+ //FIXME requiered for DTED datas
+ //setProjection(new LLXY(new LatLonPoint(centerLat, centerLong), SCALE, 480, 540));
+ // OR this one
+ //setProjection(new CADRG(new LatLonPoint(centerLat, centerLong), SCALE, 480, 540));
+
setCenter(new LatLonPoint(centerLat, centerLong));
//setScale(SCALE);
addSpecificLayer();
addGraticuleLayer();
- // ajout des shape
+ // ajout des shapes
boolean shapeLoaded = false;
- for(String filename:getFisheryRegion().getMapFilePath()){
- if(filename != null && !"".equals(filename)){
- String shp = filename + ".shp";
- String ssx = filename + ".ssx";
- try{
- //recherche l'url, si pas trouve leve une exception
- Resource.getURL(shp);
- log.info(_("isisfish.message.load.map", filename, shp, ssx));
- addShapeLayer(filename, shp, ssx, "ff000000", "ffbdde83");
- shapeLoaded = true;
- }catch(Exception eee){
- log.error(_("isisfish.error.load.map", filename), eee);
+ for (String filename : getFisheryRegion().getMapFilePath()) {
+ if (!StringUtils.isEmpty(filename)) {
+ if (log.isDebugEnabled()) {
+ log.debug(_("isisfish.message.load.map", filename));
}
+ addLayer(filename, filename, "ff000000", "ffbdde83");
+ shapeLoaded = true;
}
}
- if(!shapeLoaded){
+ if (!shapeLoaded) {
+ if (log.isDebugEnabled()) {
+ log.debug("Can't load custom map, load default one");
+ }
// a pas reussi a charger les fichiers demandés, on charge la
// carte du monde
String filename = IsisFish.config.getDefaultMapFilename();
- String shp = filename + ".shp";
- String ssx = filename + ".ssx";
- addShapeLayer(filename, shp, ssx, "ff000000", "ffbdde83");
+ addLayer(filename, filename, "ff000000", "ffbdde83");
}
- } catch(Exception eee) {
- log.error(_("isisfish.error.init.map"), eee);
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error(_("isisfish.error.init.map"), eee);
+ }
}
}
- /**
- * Get the value of selectionMode.
- * @return value of selectionMode.
- */
+ /**
+ * Get the value of selectionMode.
+ * @return value of selectionMode.
+ */
public int getSelectionMode() {
return selectionMode;
}
/**
- * Set the value of selectionMode.
- * @param v Value to assign to selectionMode.
- */
- public void setSelectionMode(int v) {
+ * Set the value of selectionMode.
+ * @param v value to assign to selectionMode.
+ */
+ public void setSelectionMode(int v) {
this.selectionMode = v;
}
- public void addSelectionLayer(){
- try{
- activeSelectionLayer = new CellSelectionLayer(fisheryRegion,
- getSelectionMode());
+ public void addSelectionLayer() {
+ try {
+ activeSelectionLayer = new CellSelectionLayer(fisheryRegion, getSelectionMode());
addMapMouseListener(activeSelectionLayer);
layerHandler.addLayer(activeSelectionLayer);
- }catch(TopiaException eee){
- log.warn("Can't add selection layer", eee);
+ } catch (TopiaException eee) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't add selection layer", eee);
+ }
}
}
- // /**
- // * Renvoie tous les carres selectionnes.
- // * @return le vecteur contenant des LatLonPoint des carres selectionnes.
- // * @deprecated
- // */
- // public Vector getSelectedCells_(){
- // return activeSelectionLayer.getSelectedCells();
- // }
-
- // /**
- // * Permet de selectionner le carre incluant le point donne.
- // * @param pt le point pour lequel on cherche le carre correspondant
- // * @return true si reussi sinon false.
- // * @deprecated
- // */
- // public boolean select(LatLonPoint pt){
- // return activeSelectionLayer.select(pt);
- // }
-
- // /**
- // * Permet de selectionner le carre incluant le point donne en latitude et longitude.
- // * @param latitude la latitude du point
- // * @param longitude la longitude du point
- // * @return true si reussi sinon false.
- // * @deprecated
- // */
- // public boolean select(float latitude,float longitude){
- // return activeSelectionLayer.select(latitude,longitude);
- // }
-
- // /**
- // * Permet de deselectionner le carre incluant le point donne.
- // * @param pt le point pour lequel on cherche le carre correspondant
- // * @return true si reussi sinon false.
- // * @deprecated
- // */
- // public boolean unSelect(LatLonPoint pt){
- // if (activeSelectionLayer != null)
- // return activeSelectionLayer.unSelect(pt);
- // return false;
- // }
-
- // /**
- // * Permet de deselectionner le carre incluant le point donne en latitude et longitude.
- // * @param latitude la latitude du point
- // * @param longitude la longitude du point
- // * @return true si reussi sinon false.
- // * @deprecated
- // */
- // public boolean unSelect(float latitude,float longitude){
- // if (activeSelectionLayer != null)
- // return activeSelectionLayer.unSelect(latitude,longitude);
- // return false;
- // }
-
- // /**
- // * Deselectionne tous les carres.
- // * @deprecated
- // */
- // public void unSelectAll(){
- // if (activeSelectionLayer != null)
- // activeSelectionLayer.unSelectAll();
- // }
-
-}// IsisMapBean
+} // IsisMapBean
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Motif.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Motif.java 2009-11-23 11:04:14 UTC (rev 2770)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Motif.java 2009-11-23 15:03:22 UTC (rev 2771)
@@ -27,7 +27,7 @@
import com.bbn.openmap.proj.Projection;
/**
- * Motif.java A Motif that represents how to draw a DataMap on the map. A factor
+ * A Motif that represents how to draw a DataMap on the map. A factor
* is applied to the graphic according to the DataMap value and the maximum
* DataMap value.
*
@@ -38,7 +38,7 @@
*/
public class Motif implements Serializable {
- /** serialVersionUID */
+ /** serialVersionUID. */
private static final long serialVersionUID = -2814583859271654759L;
public static final Color defaultLineColor = new Color(0, true);
@@ -208,4 +208,4 @@
}
}
}
-}// Motif
+} // Motif
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/ResultatLayer.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/ResultatLayer.java 2009-11-23 11:04:14 UTC (rev 2770)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/ResultatLayer.java 2009-11-23 15:03:22 UTC (rev 2771)
@@ -66,9 +66,6 @@
protected JPanel palette = null;
- // FIXME dans l'ancien mais pas dans le nouveau, voir ce que ca change
- // protected ResultatMapBean resultatMapBean = null;
-
protected Projection proj = null;
/* Contient tous les carres possibles */
@@ -77,15 +74,6 @@
public ResultatLayer() {
}
- // FIXME to be continue
- // public ResultatLayer(SimpleResultatMapBean aResultatMapBean){
- // resultatMapBean = null;
- // }
-
- // public ResultatLayer(ResultatMapBean aResultatMapBean){
- // resultatMapBean = aResultatMapBean;
- // }
-
/**
* Add a DataMap to this layer.
*
@@ -121,8 +109,8 @@
int position = -1;
// rechercher des zones dans la matrice
- for (int i = 0; i < matInfo.getNbDim(); i++) {
- List sem = matInfo.getSemantics(i);
+ for (int i = 0; i < matInfo.getDimCount(); i++) {
+ List sem = matInfo.getSemantic(i);
if (sem.size() > 0 && sem.get(0) instanceof Zone) {
position = i;
vzone = sem;
@@ -173,8 +161,8 @@
double elem = matInfo.getValue(i, j);
DefaultDataMap data = new DefaultDataMap();
data.setValue(elem);
- String itemx = matInfo.getSemantics(0).get(i).toString();
- String itemy = matInfo.getSemantics(1).get(j).toString();
+ String itemx = matInfo.getSemantic(0).get(i).toString();
+ String itemy = matInfo.getSemantic(1).get(j).toString();
if (position == 0) {
data.setCoordinates(latitude.get(i),
longitude.get(i));
@@ -345,48 +333,49 @@
/**
* Invoked when the mouse has been clicked on a component. The listener will
* receive this event if it successfully processed
- * <code>mousePressed()</code>, or if no other listener processes the
- * event. If the listener successfully processes mouseClicked(), then it
- * will receive the next mouseClicked() notifications that have a click
+ * {@code mousePressed()}, or if no other listener processes the
+ * event. If the listener successfully processes {@code mouseClicked()}, then it
+ * will receive the next {@code mouseClicked()} notifications that have a click
* count greater than one.
*
- * @param e MouseListener MouseEvent to handle.
+ * @param e MouseEvent to handle.
* @return true if the listener was able to process the event.
*/
public boolean mouseClicked(MouseEvent e) {
- // System.out.println("ResultatLayer
- // mouseClicked-------------------------"+e.getID());
+
// on recherche le datamap clique
LatLonPoint llp = getProjection().inverse(e.getX(), e.getY());
- Vector datamaps = getDataMapList().getDataMaps(
+ List<DataMap> datamaps = getDataMapList().getDataMaps(
new Coordinate(llp.getLatitude(), llp.getLongitude()));
if (datamaps != null && datamaps.size() != 0) {
String info = "";
for (Object datamap : datamaps) {
DefaultDataMap dataMap = (DefaultDataMap) datamap;
- if (dataMap.getInfo() != null)
+ if (dataMap.getInfo() != null) {
info += _("Info") + ": " + dataMap.getInfo().getLabels()
+ " " + _("isisfish.common.value") + ":" + dataMap.getValue() + "\n";
- else
+ }
+ else {
info += " " + _("isisfish.common.value") + ":" + dataMap.getValue() + "\n";
+ }
}
- // System.out.println(info);
+
// InfoDisplayEvent infoevt = new InfoDisplayEvent(this,info);
// fireRequestMessage(infoevt);
JOptionPane.showMessageDialog(this, info, this.getName(),
JOptionPane.INFORMATION_MESSAGE);
- // System.out.println("ResultatLayer
- // mouseClicked++++++++++++++++++++++++");
+
// e.consume();
return true;
- } else
+ } else {
return false;
+ }
}
/**
* Invoked when the mouse enters a component.
*
- * @param e MouseListener MouseEvent to handle.
+ * @param e MouseEvent to handle.
*/
public void mouseEntered(MouseEvent e) {
}
@@ -394,7 +383,7 @@
/**
* Invoked when the mouse exits a component.
*
- * @param e MouseListener MouseEvent to handle.
+ * @param e MouseEvent to handle.
*/
public void mouseExited(MouseEvent e) {
}
@@ -404,7 +393,7 @@
* The listener will receive these events if it successfully processes
* mousePressed(), or if no other listener processes the event.
*
- * @param e MouseMotionListener MouseEvent to handle.
+ * @param e MouseEvent to handle.
* @return true if the listener was able to process the event.
*/
public boolean mouseDragged(MouseEvent e) {
@@ -415,7 +404,7 @@
* Invoked when the mouse button has been moved on a component (with no
* buttons no down).
*
- * @param e MouseListener MouseEvent to handle.
+ * @param e MouseEvent to handle.
* @return true if the listener was able to process the event.
*/
public boolean mouseMoved(MouseEvent e) {
@@ -449,4 +438,4 @@
public void mouseMoved() {
}
-}// ResultatLayer
+} // ResultatLayer
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Scale.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Scale.java 2009-11-23 11:04:14 UTC (rev 2770)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/Scale.java 2009-11-23 15:03:22 UTC (rev 2771)
@@ -21,7 +21,6 @@
import java.io.Serializable;
/**
- * Scale.
* This interface allows the user to define a graduation between 0.0 and 1.0
* whose movement are proportionnal to a bounded value.
*
@@ -32,12 +31,22 @@
*/
public interface Scale extends Serializable{
- /** Get the corresponding value between 0.0 and 1.0 */
+ /**
+ * Get the corresponding value between 0.0 and 1.0.
+ *
+ * @param value value to get scale
+ * @return scale value
+ */
public double getValueAsScale(double value);
public int getValueAsRGB(double value);
- /** Get the corresponding square root value between 0.0 and 1.0 */
+ /**
+ * Get the corresponding square root value between 0.0 and 1.0.
+ *
+ * @param value value to get sqrt scale
+ * @return sqrt scale
+ */
public double getValueAsSqrtScale(double value);
-}// Scale
+} // Scale
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/ZoneDelimiterLayer.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/ZoneDelimiterLayer.java 2009-11-23 11:04:14 UTC (rev 2770)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/map/ZoneDelimiterLayer.java 2009-11-23 15:03:22 UTC (rev 2771)
@@ -51,7 +51,7 @@
public class ZoneDelimiterLayer extends Layer implements
TopiaTransactionListener { //ZoneDelimiterLayer
- /** serialVersionUID */
+ /** serialVersionUID. */
private static final long serialVersionUID = 1127201121371123690L;
/** to use log facility, just put in your code: log.info(\"...\"); */
@@ -59,10 +59,10 @@
protected Projection proj = null;
- /* Contient tous les carres possibles */
+ /** Contient tous les carres possibles. */
protected OMGraphicList graphics = new OMGraphicList();
- /* Caracteristiques du cadrillage */
+ /** Caracteristiques du cadrillage. */
protected float pasMailleLatitude;
protected float pasMailleLongitude;
@@ -150,30 +150,6 @@
graphics.generate(getProjection());
}
- // /**
- // * Appelé lorsqu'une ou plusieurs entités ont été créées
- // */
- // public void entityCreated(TopiaEntityEvent event){
- // refresh();
- // }
- // /**
- // * Appelé lorsqu'une ou plusieurs entités ont été chargées
- // */
- // public void entityLoaded(TopiaEntityEvent event){
- // }
- // /**
- // * Appelé lorsqu'une ou plusieurs entités ont été modifiées
- // */
- // public void entityUpdated(TopiaEntityEvent event){
- // refresh();
- // }
- // /**
- // * Appelé lorsqu'une ou plusieurs entités ont été supprimées
- // */
- // public void entityDeleted(TopiaEntityEvent event){
- // refresh();
- // }
-
protected void refresh() {
try {
cells = fisheryRegion.getCell();
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java 2009-11-23 11:04:14 UTC (rev 2770)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputAction.java 2009-11-23 15:03:22 UTC (rev 2771)
@@ -39,6 +39,7 @@
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.util.FileUtil;
+import org.nuiton.widget.SwingUtil;
import org.nuiton.widget.editor.Editor;
import fr.ifremer.isisfish.IsisFishDAOHelper;
@@ -1087,11 +1088,12 @@
return null;
}
- // FisheryRegion
-
/**
* Add new map in region.
*
+ * Since isis-fsih 3.3.0.0, this method supports a multiple file format :
+ * - http://openmap.bbn.com/cgi-bin/faqw.py?req=all#9.1
+ *
* @param fisheryRegion fishery region
*/
public void addMap(FisheryRegion fisheryRegion) {
@@ -1099,42 +1101,50 @@
log.trace("AddMap called");
}
- File shp = FileUtil.getFile(".*\\.shp", "shp file");
+ // Openmap suported fileformat
+ String[] fileFormats = {
+ // ESRI (http://www.esri.com) Shapefiles
+ ".*\\.shp", "ESRI Shapefiles (.shp)",
+
+ // NIMA (http://www.nima.mil)
+ ".*\\.dcw", "Digital Chart of the World (.dcw)",
+ ".*\\.vpf", "Vector Product Format (.vpf)",
+ ".*\\.vmap", "Vector Map (.vmap)",
+ ".*\\.cadrg", "Compressed ARC Digitized Raster Graphics (.cadrg)",
+ ".*\\.cib", "Controlled Image Base (.cib)",
+ ".*\\.rpf", "Raster Product Format (.rpf)",
+ // seams to be a special format with multiples files
+ //".*\\.dt[0-2]+", "Digital Terrain Elevation Data (levels 0, 1, 2) (.dt0, .dt0, .dt2)",
+
+ // MapInfo (http://www.mapinfo.com) files (.mif)
+ ".*\\.mif", "MapInfo (.mif)",
+
+ // ArcInfo (.e00) files.
+ ".*\\.e00", "ArcInfo (.e00)"
+ };
+
+ File inputMap = FileUtil.getFile(fileFormats);
try {
- if (shp != null) {
- // copy shp and ssx to region map directory
- String basename = FileUtil.basename(shp, ".shp");
+ if (inputMap != null) {
- String srcMap = shp.getPath();
- srcMap = srcMap.substring(0, srcMap.length() - ".shp".length());
- File ssx = new File(srcMap + ".ssx");
+ // copy inputMapFormat to region map directory
+ // since isis-fsih-3.3.0.0, we store maps with extension
+ String filename = inputMap.getName();
- RegionStorage regionStorage = RegionStorage
- .getRegion(fisheryRegion.getName());
+ RegionStorage regionStorage = RegionStorage.getRegion(fisheryRegion.getName());
File destDir = regionStorage.getMapRepository();
- // copy shp file
- File destShp = new File(destDir, basename + ".shp");
- FileUtil.copy(shp, destShp);
+ // copy map file
+ File destMap = new File(destDir, filename);
+ FileUtil.copy(inputMap, destMap);
- // copy ssx file (unneeded with openmap 4.6.5)
- /*File destSsx = new File(destDir, basename + ".ssx");
- if (ssx.exists()) {
- FileUtil.copy(ssx, destSsx);
- } else {
- if (log.isInfoEnabled()) {
- log.info("Ssx file don't exist, try to generate it");
- }
- SpatialIndex.createIndex(destShp.getPath(), destSsx.getPath());
- }*/
-
List<String> maps = fisheryRegion.getMapFileList();
- maps.add(basename);
+ maps.add(filename);
fisheryRegion.setMapFileList(maps);
}
} catch (Exception eee) {
if (log.isErrorEnabled()) {
- log.error("Can't copy .shp or .ssx file for: " + shp, eee);
+ log.error("Can't copy map file for : " + inputMap, eee);
}
ErrorHelper.showErrorDialog(_("isisfish.error.region.addmap"), eee);
}
@@ -1150,21 +1160,32 @@
if (log.isTraceEnabled()) {
log.trace("removeMap called");
}
+
try {
-
List<String> maps = fisheryRegion.getMapFileList();
- RegionStorage regionStorage = RegionStorage.getRegion(fisheryRegion
- .getName());
+ RegionStorage regionStorage = RegionStorage.getRegion(fisheryRegion.getName());
File mapDir = regionStorage.getMapRepository();
- for (Object map : selectedMaps) {
- maps.remove(map);
+ for (Object selectedMap : selectedMaps) {
+ String mapName = (String)selectedMap;
+ maps.remove(mapName);
// remove on disk too, if possible
- File shp = new File(mapDir, map + ".shp");
- shp.delete();
- File ssx = new File(mapDir, map + ".ssx");
- ssx.delete();
+ File mapFile = new File(mapDir, mapName);
+ mapFile.delete();
+ if (log.isDebugEnabled()) {
+ log.debug("Removing map file : " + mapFile);
+ }
+
+ // special case, for some format, an index is created
+ if (mapName.endsWith(".shp")) {
+ String indexName = mapName.replaceAll("\\.shp$", ".ssx");
+ File indexFile = new File(mapDir, indexName);
+ indexFile.delete();
+ if (log.isDebugEnabled()) {
+ log.debug("Removing index file : " + indexFile);
+ }
+ }
}
fisheryRegion.setMapFileList(maps);
@@ -1282,6 +1303,7 @@
CheckRegion.check(fisheryRegion, result);
CheckResultFrame dialog = new CheckResultFrame();
dialog.setCheckResult(result);
+ SwingUtil.center(dialog);
dialog.setVisible(true);
} catch (Exception eee) {
if (log.isErrorEnabled()) {
Modified: isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties
===================================================================
--- isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties 2009-11-23 11:04:14 UTC (rev 2770)
+++ isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties 2009-11-23 15:03:22 UTC (rev 2771)
@@ -614,7 +614,7 @@
isisfish.message.import.zip=Import zip file
isisfish.message.launchui.notlaunch=
isisfish.message.load.finished=load finished
-isisfish.message.load.map=Try to load map file\: %1$s (%2$s)
+isisfish.message.load.map=Try to load map file\: %1$s
isisfish.message.loading.old.simulation=Loading old simulation ...
isisfish.message.loading.region=Loading region ...
isisfish.message.name.imported.region=Enter name for imported region
Modified: isis-fish/trunk/src/main/resources/i18n/isis-fish-fr_FR.properties
===================================================================
--- isis-fish/trunk/src/main/resources/i18n/isis-fish-fr_FR.properties 2009-11-23 11:04:14 UTC (rev 2770)
+++ isis-fish/trunk/src/main/resources/i18n/isis-fish-fr_FR.properties 2009-11-23 15:03:22 UTC (rev 2771)
@@ -614,7 +614,7 @@
isisfish.message.import.zip=Import zip file
isisfish.message.launchui.notlaunch=Interface utilisateur non lanc\u00E9e
isisfish.message.load.finished=Chargement termin\u00E9
-isisfish.message.load.map=Chargement de la carte \: %1$s (%2$s)
+isisfish.message.load.map=Chargement de la carte \: %1$s
isisfish.message.loading.old.simulation=Chargement d'une ancienne simulation ...
isisfish.message.loading.region=Chargement de la r\u00E9gion
isisfish.message.name.imported.region=Entrez le nom de la r\u00E9gion \u00E0 importer
1
0
r2770 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish
by chatellier@users.labs.libre-entreprise.org 23 Nov '09
by chatellier@users.labs.libre-entreprise.org 23 Nov '09
23 Nov '09
Author: chatellier
Date: 2009-11-23 11:04:14 +0000 (Mon, 23 Nov 2009)
New Revision: 2770
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java
Log:
Add extension to default isis map.
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java 2009-11-23 09:43:11 UTC (rev 2769)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java 2009-11-23 11:04:14 UTC (rev 2770)
@@ -880,7 +880,7 @@
DEFAULT_EXPORT_DIRECTORY("default.export.directory", _("isisfish.config.main.defaultExportDirectory.description"), getUserHome() + File.separator + "isis-export"),
DEFAULT_EXPORT_NAMES("default.export.names", _("isisfish.config.main.defaultExportNames.description"), ""),
DEFAULT_RESULT_NAMES("default.result.names", _("isisfish.config.main.defaultResultNames.description"), ""),
- DEFAULT_MAP_FILENAME("default.map.filename", _("isisfish.config.main.defaultMapFile.description"), "maps/vmap_area_thin"),
+ DEFAULT_MAP_FILENAME("default.map.filename", _("isisfish.config.main.defaultMapFile.description"), "maps/vmap_area_thin.shp"),
DEFAULT_TAG_VALUE("default.tagvalue", _("isisfish.config.main.defaultTagValue.description"), ""),
ENCODING("encoding", _("isisfish.config.main.encoding.description"), "UTF-8"),
JAVADOC_URL("javadoc.url", _("isisfish.config.main.javadocURL.description"), "http://isis-fish.labs.libre-entreprise.org/isis-fish/apidocs/"),
1
0
Author: chatellier
Date: 2009-11-23 09:43:11 +0000 (Mon, 23 Nov 2009)
New Revision: 2769
Modified:
isis-fish/trunk/pom.xml
Log:
H2 (version bump)
Modified: isis-fish/trunk/pom.xml
===================================================================
--- isis-fish/trunk/pom.xml 2009-11-20 16:47:27 UTC (rev 2768)
+++ isis-fish/trunk/pom.xml 2009-11-23 09:43:11 UTC (rev 2769)
@@ -224,7 +224,7 @@
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
- <version>1.2.123</version>
+ <version>1.2.124</version>
<scope>compile</scope>
</dependency>
1
0
r2768 - in isis-fish/trunk: . src/main/java/fr/ifremer/isisfish/simulator/sensitivity src/main/java/fr/ifremer/isisfish/ui/sensitivity src/main/java/fr/ifremer/isisfish/ui/simulator src/test/java/fr/ifremer/isisfish/ui/sensitivity
by chatellier@users.labs.libre-entreprise.org 20 Nov '09
by chatellier@users.labs.libre-entreprise.org 20 Nov '09
20 Nov '09
Author: chatellier
Date: 2009-11-20 16:47:27 +0000 (Fri, 20 Nov 2009)
New Revision: 2768
Added:
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/ui/sensitivity/EditorHelperTest.java
Modified:
isis-fish/trunk/changelog.txt
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/Factor.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/EditorHelper.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/FactorWizardUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityTabUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUtils.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUtilsTest.java
Log:
Debut de possibilit?\195?\169 de rechargement des facteurs
Modified: isis-fish/trunk/changelog.txt
===================================================================
--- isis-fish/trunk/changelog.txt 2009-11-20 15:20:15 UTC (rev 2767)
+++ isis-fish/trunk/changelog.txt 2009-11-20 16:47:27 UTC (rev 2768)
@@ -1,5 +1,6 @@
isis-fish (3.3.0.0) stable; urgency=low
+ * Editing sensitivity factors after simulation reload now works
* Add confirmation message before launching groups creation wizard
* Fix metierSeasonInfo deletion (#1914)
* Remove some deprecated unused UI classes
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/Factor.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/Factor.java 2009-11-20 15:20:15 UTC (rev 2767)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/Factor.java 2009-11-20 16:47:27 UTC (rev 2768)
@@ -199,8 +199,9 @@
/**
* Set path.
*
- * @param path
- * the path to set
+ * Warning, path need to be always a valid entity property reference.
+ *
+ * @param path the path to set
*/
public void setPath(String path) {
this.path = path;
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/EditorHelper.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/EditorHelper.java 2009-11-20 15:20:15 UTC (rev 2767)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/EditorHelper.java 2009-11-20 16:47:27 UTC (rev 2768)
@@ -35,13 +35,17 @@
import jaxx.runtime.JAXXInitialContext;
import jaxx.runtime.swing.editor.NumberEditor;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.math.matrix.MatrixND;
import org.nuiton.math.matrix.gui.MatrixEditor;
import org.nuiton.math.matrix.gui.MatrixPanelEditor;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
import org.nuiton.topia.persistence.TopiaEntity;
+import fr.ifremer.isisfish.entities.Equation;
import fr.ifremer.isisfish.entities.Formule;
import fr.ifremer.isisfish.entities.Selectivity;
import fr.ifremer.isisfish.entities.TargetSpecies;
@@ -627,7 +631,7 @@
* @param entity entity
* @return continuous enabled
*/
- public static boolean canBeContinuous(JComponent component,
+ public static boolean canBeContinue(JComponent component,
TopiaEntity entity) {
String fieldName = (String) component.getClientProperty("method");
if (component instanceof JTextComponent) {
@@ -656,17 +660,27 @@
* @return continuous enabled
*/
public static boolean canBeContinue(JComponent component, Object value) {
+ boolean result = false;
+
if (component instanceof JTextComponent) {
if (value instanceof Double) {
- return true;
+ result = true;
} else if (value instanceof Long) {
- return true;
+ result = true;
}
}
else if (component instanceof InputOneEquationUI) {
- return true;
+ result = true;
}
- return false;
+ else if (component instanceof MatrixPanelEditor) {
+ result = true;
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Component " + component.getClass().getSimpleName() +
+ " with value " + value + "(" + value.getClass().getSimpleName() + ") can be continuous : " + result);
+ }
+ return result;
}
/**
@@ -743,4 +757,88 @@
}
return result;
}
+
+ /**
+ * Return the component to edit factor depending on factor path.
+ * (inspect the return type of entity denoted by path)
+ *
+ * Used to edit reloader factor from old simulation.
+ *
+ * @param factor factor
+ * @param context context
+ * @return component
+ */
+ public static JComponent getEditorForFactor(Factor<?, ?> factor, TopiaContext context) {
+ JComponent result = null;
+
+ // we can't do it only with path maybe ?
+ // need to check property type with introspection
+ String path = factor.getPath();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Try to find component for path " + path);
+ }
+
+ String topiaId = path.substring(0, path.lastIndexOf('#'));
+ String property = StringUtils.capitalize(path.substring(path.lastIndexOf('#') + 1));
+
+ Class<?> typeClazz = null;
+ try {
+ TopiaEntity entity = context.findByTopiaId(topiaId);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Factor " + factor.getName() + " denoted entity " + entity);
+ }
+
+ Method method = entity.getClass().getMethod("get" + property);
+ typeClazz = method.getReturnType();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Property " + property + " denoted type " + typeClazz.getSimpleName());
+ }
+
+ result = getEditorForType(typeClazz);
+
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't find entity for " + topiaId, ex);
+ }
+ } catch (SecurityException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't get type info for " + topiaId, ex);
+ }
+ } catch (NoSuchMethodException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't get type info for " + topiaId, ex);
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Get editor for type.
+ *
+ * @param typeClazz type to get editor
+ * @return component
+ */
+ protected static JComponent getEditorForType(Class<?> typeClazz) {
+
+ JComponent result = null;
+
+ if (Double.class.isAssignableFrom(typeClazz)) {
+ result = new JTextField();
+ }
+ else if (double.class.isAssignableFrom(typeClazz)) {
+ result = new JTextField();
+ }
+ else if (MatrixND.class.isAssignableFrom(typeClazz)) {
+ result = new MatrixPanelEditor();
+ }
+ else if (Equation.class.isAssignableFrom(typeClazz)) {
+ result = new InputOneEquationUI();
+ }
+
+ return result;
+ }
}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/FactorWizardUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/FactorWizardUI.jaxx 2009-11-20 15:20:15 UTC (rev 2767)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/FactorWizardUI.jaxx 2009-11-20 16:47:27 UTC (rev 2768)
@@ -34,6 +34,7 @@
import fr.ifremer.isisfish.simulator.sensitivity.Factor;
import fr.ifremer.isisfish.simulator.sensitivity.Domain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
+import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationContinuousDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain;
protected JComponent cOrigine = null;
@@ -106,12 +107,24 @@
setExistingValue(true);
this.cOrigine = cOrigine;
this.path = f.getPath();
- factorName.setText(f.getName());
comment.setText(f.getComment());
Domain domain = f.getDomain();
this.factor = f;
if (domain instanceof ContinuousDomain) {
+ if (domain instanceof EquationContinuousDomain) {
+ EquationContinuousDomain equationDomain = (EquationContinuousDomain)domain;
+ String factorName2 = f.getName();
+ String suffix = "." + equationDomain.getVariableName();
+ if (factorName2.endsWith(suffix)) {
+ factorName2 = factorName2.substring(0, factorName2.length()-suffix.length());
+ }
+ factorName.setText(factorName2);
+ }
+ else {
+ // for other ContinuousDomain name is the same
+ factorName.setText(f.getName());
+ }
ContinuousDomain cDomain = (ContinuousDomain) domain;
continuousPanel = EditorHelper.getContinuousPanelWithValue(cOrigine, cDomain, f);
@@ -121,6 +134,10 @@
setContinueSelected(true);
setContinuePossible(true);
} else {
+
+ // discret fator, name is the same
+ factorName.setText(f.getName());
+
DiscreteDomain dDomain = (DiscreteDomain)domain;
int nb = dDomain.getValues().size();
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityTabUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityTabUI.jaxx 2009-11-20 15:20:15 UTC (rev 2767)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityTabUI.jaxx 2009-11-20 16:47:27 UTC (rev 2768)
@@ -102,13 +102,23 @@
wizard.setVisible(true);
}
else {
-
- // factor path are :
- // fr.ifremer.isisfish.entities.Strategy#1190373398255#0.7889364141850967#proportionSetOfVessels
- if (log.isInfoEnabled()) {
- log.info("UI not found for factor " + selectedFactor.getName());
- log.info(" with path " + selectedFactor.getPath());
+
+ // method 2
+ JComponent component2 = EditorHelper.getEditorForFactor(selectedFactor, getRegion().getTopiaContext());
+ if (component2 != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Component found is " + component2);
+ }
+
+ wizard.initExisting(component2, selectedFactor);
+ wizard.pack();
+ wizard.setVisible(true);
}
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No component found, skip edition of factor " + selectedFactor.getName());
+ }
+ }
}
}
}
@@ -170,7 +180,6 @@
FactorTreeModel model = new FactorTreeModel(factors);
factorsTree.setModel(model);
factorsTree.setRootVisible(true);
- factorsTree.setCellRenderer(new FactorTreeCellRenderer());
getParentContainer(SensitivityUI.class).getSensitivityChooserUI().setFactorCardinalityTableModel();
}
@@ -208,7 +217,7 @@
<JPanel id="factorPanel" name="factorPanel" layout='{new BorderLayout()}'>
<JScrollPane constraints='BorderLayout.CENTER'>
<JTree id="factorsTree" rootVisible="true" selectionRow='0'
- model='{new DefaultTreeModel(null)}' />
+ model='{new DefaultTreeModel(null)}' cellRenderer='{new FactorTreeCellRenderer()}'/>
</JScrollPane>
</JPanel>
</JSplitPane>
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx 2009-11-20 15:20:15 UTC (rev 2767)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx 2009-11-20 16:47:27 UTC (rev 2768)
@@ -73,7 +73,7 @@
<ParamsUI id='paramsUI' sensitivity='{true}' constructorParams='this'/>
</tab>
<tab title='isisfish.sensitivity.title'>
- <SensitivityTabUI id="sensitivityTabUI" constructorParams='new JAXXInitialContext().add(new InputAction()).add(new InputSaveVerifier()).add(this)'/>
+ <SensitivityTabUI id="sensitivityTabUI" constructorParams='new JAXXInitialContext().add(new InputAction()).add(new SensitivityAction()).add(new InputSaveVerifier()).add(this)'/>
</tab>
<tab title='isisfish.sensitivityChooser.title'>
<SensitivityChooserUI id="sensitivityChooserUI" constructorParams='this'/>
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUtils.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUtils.java 2009-11-20 15:20:15 UTC (rev 2767)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUtils.java 2009-11-20 16:47:27 UTC (rev 2768)
@@ -19,11 +19,9 @@
package fr.ifremer.isisfish.ui.sensitivity;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.util.Properties;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -94,29 +92,4 @@
}
return sensitivityProperties;
}
-
- /**
- * Return factor name for topiaId composed path.
- *
- * For example :
- * fr.ifremer.isisfish.entities.Strategy#1190373398255#0.7889364141850967#proportionSetOfVessels
- * will return :
- * Strategy.proportionSetOfVessels
- *
- * @param path factor path
- * @return factor name
- */
- public static String getFactorNameForPath(String path) {
-
- Pattern pattern = Pattern.compile("^([^#]*\\.)?(\\w+).*#(\\w+)$");
- Matcher matcher = pattern.matcher(path);
-
- String result = null;
-
- if (matcher.find()) {
- result = matcher.group(2) + "." + matcher.group(3);
- }
-
- return result;
- }
}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2009-11-20 15:20:15 UTC (rev 2767)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2009-11-20 16:47:27 UTC (rev 2768)
@@ -827,19 +827,18 @@
}
public void addFactor(Factor<?, ?> f, JComponent c) {
+ if (log.isDebugEnabled()) {
+ log.debug("Add factor (" + f.getName() + ") : " +f.getPath());
+ }
factors.put(f.getPath() + f.getName(), f);
factorComponent.put(f.getPath() + f.getName(), c);
designPlan.setFactors(getFactors());
}
- public Factor getFactor(String name) {
- return factors.get(name);
- }
-
public void addContinuousFactor(String name, String comment, String path, Double min,
Double max, JComponent c, boolean exist) {
- Factor f = new Factor(name);
- ContinuousDomain domain = new ContinuousDomain();
+ Factor<Double, Double> f = new Factor<Double, Double>(name);
+ ContinuousDomain<Double, Double> domain = new ContinuousDomain<Double, Double>();
domain.setMinBound(min);
domain.setMaxBound(max);
f.setDomain(domain);
@@ -853,8 +852,8 @@
public void addDiscreteFactor(String name, String comment, String path,
List<Serializable> values, JComponent c, boolean exist) {
- Factor f = new Factor(name);
- DiscreteDomain domain = new DiscreteDomain();
+ Factor<Serializable, Serializable> f = new Factor<Serializable, Serializable>(name);
+ DiscreteDomain<Serializable, Serializable> domain = new DiscreteDomain<Serializable, Serializable>();
int i = 0;
for (Serializable value : values) {
// FIXME test when integer
@@ -875,10 +874,13 @@
public void addContinuousEquationFactor(String name, String comment, String path,
EquationContinuousDomain domain, JComponent c,
boolean exist) {
- Factor f = new Factor(name);
+ // factor name need to be composed
+ Factor<Double, Double> f = new Factor<Double, Double>(name + "." + domain.getVariableName());
f.setDomain(domain);
f.setComment(comment);
- f.setPath(path + domain.getVariableName());
+ // don't modify path, need to be valid identifier
+ //f.setPath(path + domain.getVariableName());
+ f.setPath(path);
if (exist) {
removeFactor(f);
}
@@ -888,7 +890,7 @@
public void addContinuousMatrixFactor(String name, String comment, String path,
Double coef, MatrixND matrix,
String operateur, JComponent c, boolean exist) {
- Factor f = new Factor(name);
+ Factor<MatrixND, Double> f = new Factor<MatrixND, Double>(name);
MatrixContinuousDomain domain = new MatrixContinuousDomain();
domain.setMatrix(matrix);
domain.setOperator(operateur);
@@ -902,11 +904,11 @@
addFactor(f, c);
}
- public JComponent getFactorComponent(Factor f) {
- return factorComponent.get(f.getPath() + f);
+ public JComponent getFactorComponent(Factor<?, ?> f) {
+ return factorComponent.get(f.getPath() + f.getName());
}
- public void removeFactor(Factor f) {
+ public void removeFactor(Factor<?, ?> f) {
factors.remove(f.getPath() + f.getName());
factorComponent.remove(f.getPath() + f.getName());
designPlan.setFactors(getFactors());
Added: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/ui/sensitivity/EditorHelperTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/ui/sensitivity/EditorHelperTest.java (rev 0)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/ui/sensitivity/EditorHelperTest.java 2009-11-20 16:47:27 UTC (rev 2768)
@@ -0,0 +1,69 @@
+/* *##%
+ * Copyright (C) 2009 Code Lutin, 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+package fr.ifremer.isisfish.ui.sensitivity;
+
+import javax.swing.JComponent;
+import javax.swing.JTextField;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.math.matrix.MatrixNDImpl;
+import org.nuiton.math.matrix.gui.MatrixPanelEditor;
+
+import fr.ifremer.isisfish.AbstractIsisFishTest;
+import fr.ifremer.isisfish.entities.Equation;
+import fr.ifremer.isisfish.ui.input.InputOneEquationUI;
+
+/**
+ * Test for {@link EditorHelper} class.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class EditorHelperTest extends AbstractIsisFishTest {
+
+ /**
+ * Test that editor for given type are those excepted.
+ */
+ @Test
+ public void testGetEditorForType() {
+
+ JComponent result = EditorHelper.getEditorForType(double.class);
+ Assert.assertTrue(result instanceof JTextField);
+
+ result = EditorHelper.getEditorForType(Double.class);
+ Assert.assertTrue(result instanceof JTextField);
+
+ result = EditorHelper.getEditorForType(MatrixND.class);
+ Assert.assertTrue(result instanceof MatrixPanelEditor);
+
+ result = EditorHelper.getEditorForType(MatrixNDImpl.class);
+ Assert.assertTrue(result instanceof MatrixPanelEditor);
+
+ result = EditorHelper.getEditorForType(Equation.class);
+ Assert.assertTrue(result instanceof InputOneEquationUI);
+
+ //result = EditorHelper.getEditorForType(PopulationReproductionEquation.class);
+ //Assert.assertTrue(result instanceof InputOneEquationUI);
+ }
+}
Property changes on: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/ui/sensitivity/EditorHelperTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUtilsTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUtilsTest.java 2009-11-20 15:20:15 UTC (rev 2767)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUtilsTest.java 2009-11-20 16:47:27 UTC (rev 2768)
@@ -25,18 +25,10 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.junit.Assert;
import org.junit.Test;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaNotFoundException;
-import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.topia.persistence.TopiaEntity;
import fr.ifremer.isisfish.AbstractIsisFishTest;
-import fr.ifremer.isisfish.IsisFishDAOHelper;
-import fr.ifremer.isisfish.datastore.IsisH2Config;
/**
* Test for {@link SensitivityUtils} class.
@@ -54,76 +46,28 @@
.getLog(SensitivityUtilsTest.class);
/**
- * Return a basic valid topia context.
- *
- * @throws TopiaNotFoundException
- */
- protected TopiaContext getTopiaContext() throws TopiaNotFoundException {
- Properties config = new Properties();
- IsisH2Config.addMemDatabaseConfig(config, "test");
- IsisH2Config.addHibernateMapping(config);
- TopiaContext context = TopiaContextFactory.getContext(config);
- return context;
- }
-
- /**
- * Test return of getFactorNameForPath().
- */
- @Test
- public void testGetFactorNameForPath() {
-
- String result = SensitivityUtils.getFactorNameForPath("fr.ifremer.isisfish.entities.Strategy#1190373398255#0.7889364141850967#proportionSetOfVessels");
- Assert.assertEquals("Strategy.proportionSetOfVessels", result);
-
- result = SensitivityUtils.getFactorNameForPath("fr.ifremer.isisfish.entities.Gear#1234#5678#name");
- Assert.assertEquals("Gear.name", result);
-
- result = SensitivityUtils.getFactorNameForPath("Gear#1234#5678#name");
- Assert.assertEquals("Gear.name", result);
-
- result = SensitivityUtils.getFactorNameForPath("fr.ifremer.isisfish.entities.Gear#name");
- Assert.assertEquals("Gear.name", result);
-
- result = SensitivityUtils.getFactorNameForPath("fr.ifremer.isisfish.entities.Gear");
- Assert.assertNull(result);
-
- result = SensitivityUtils.getFactorNameForPath("fr.ifremer.isisfish.entities.Gear.name");
- Assert.assertNull(result);
- }
-
- /**
* Test (par introspection) que tous les facteurs existent.
*
+ * @throws ClassNotFoundException
+ * @throws IllegalAccessException
+ * @throws InstantiationException
* @throws NoSuchMethodException
* @throws SecurityException
- * @throws TopiaException
* @throws InvocationTargetException
- * @throws IllegalAccessException
* @throws IllegalArgumentException
*/
@Test
- public void testFactorExistence() throws SecurityException,
- NoSuchMethodException, TopiaException, IllegalArgumentException,
- IllegalAccessException, InvocationTargetException {
+ public void testFactorExistence() throws InstantiationException, IllegalAccessException,
+ ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException,
+ InvocationTargetException {
Properties factors = SensitivityUtils.getProperties();
- TopiaContext testTC = getTopiaContext();
- TopiaContext context = testTC.beginTransaction();
for (String factorName : factors.stringPropertyNames()) {
String className = factorName.substring(0, factorName.indexOf("."));
String propertyName = StringUtils.capitalize(factorName.substring(factorName.indexOf(".") + 1));
+
+ TopiaEntity entity = (TopiaEntity)Class.forName("fr.ifremer.isisfish.entities." + className + "Impl").newInstance();
- // get proper DAO
- if (log.isDebugEnabled()) {
- log.debug("Call get" + className + "DAO() on " + IsisFishDAOHelper.class.getSimpleName());
- }
- Method mStatic = IsisFishDAOHelper.class.getMethod("get" + className + "DAO", TopiaContext.class);
- TopiaDAO<TopiaEntity> dao = (TopiaDAO<TopiaEntity>) mStatic.invoke(null, new Object[] { context });
- Assert.assertNotNull("No DOA found for factor " + factorName, dao);
-
- // create one instance
- TopiaEntity entity = dao.create();
-
// call proper property
if (log.isDebugEnabled()) {
log.debug(" and call get" + propertyName + "() on " + className);
@@ -131,6 +75,5 @@
Method m = entity.getClass().getMethod("get" + propertyName);
m.invoke(entity, (Object[]) null);
}
- context.closeContext();
}
}
1
0
r2767 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity
by chatellier@users.labs.libre-entreprise.org 20 Nov '09
by chatellier@users.labs.libre-entreprise.org 20 Nov '09
20 Nov '09
Author: chatellier
Date: 2009-11-20 15:20:15 +0000 (Fri, 20 Nov 2009)
New Revision: 2767
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/FactorTreeCellRenderer.java
Log:
Toujours afficher le nom du facteur, toujours toujours toujours !!!
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/FactorTreeCellRenderer.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/FactorTreeCellRenderer.java 2009-11-19 17:23:16 UTC (rev 2766)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/FactorTreeCellRenderer.java 2009-11-20 15:20:15 UTC (rev 2767)
@@ -19,6 +19,7 @@
package fr.ifremer.isisfish.ui.sensitivity;
import static org.nuiton.i18n.I18n._;
+
import java.awt.Component;
import java.util.List;
@@ -27,7 +28,6 @@
import javax.swing.tree.DefaultTreeCellRenderer;
import fr.ifremer.isisfish.simulator.sensitivity.Factor;
-import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationContinuousDomain;
/**
* Factor tree cell renderer.
@@ -52,23 +52,15 @@
boolean hasFocus) {
JLabel c = (JLabel)super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
-
+
if (value instanceof List<?>) {
c.setText(_("isisfish.sensitivity.factors") + " : ");
}
else if (value instanceof Factor<?, ?>) {
Factor<? ,?> factor = (Factor<?, ?>)value;
-
- if (factor.getDomain() instanceof EquationContinuousDomain) {
- EquationContinuousDomain domain = (EquationContinuousDomain)factor.getDomain();
- c.setText(factor.getName() + "." + domain.getVariableName());
- }
- else {
- c.setText(factor.getName());
- }
+ c.setText(factor.getName());
}
return c;
}
-
}
1
0