Sammoa-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
August 2012
- 4 participants
- 171 discussions
r370 - in trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing: campaign region
by tchemit@users.forge.codelutin.com 08 Aug '12
by tchemit@users.forge.codelutin.com 08 Aug '12
08 Aug '12
Author: tchemit
Date: 2012-08-08 18:00:02 +0200 (Wed, 08 Aug 2012)
New Revision: 370
Url: http://forge.codelutin.com/repositories/revision/sammoa/370
Log:
fixes 1384: Probl?\195?\168me de filtres sur les extensions de fichier dans les ?\195?\169diteurs (Windows)
Modified:
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/campaign/CampaignUI.css
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/region/RegionUI.css
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/campaign/CampaignUI.css
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/campaign/CampaignUI.css 2012-08-08 15:58:36 UTC (rev 369)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/campaign/CampaignUI.css 2012-08-08 16:00:02 UTC (rev 370)
@@ -22,6 +22,11 @@
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
+
+FileEditor {
+ acceptAllFileFilterUsed:false;
+}
+
#campaignRegionLabel {
text:"sammoa.label.campaign.region";
}
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/region/RegionUI.css
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/region/RegionUI.css 2012-08-08 15:58:36 UTC (rev 369)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/region/RegionUI.css 2012-08-08 16:00:02 UTC (rev 370)
@@ -22,6 +22,11 @@
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
+
+FileEditor {
+ acceptAllFileFilterUsed:false;
+}
+
#regionCodeLabel {
text:"sammoa.label.region.code";
}
1
0
Author: tchemit
Date: 2012-08-08 17:58:36 +0200 (Wed, 08 Aug 2012)
New Revision: 369
Url: http://forge.codelutin.com/repositories/revision/sammoa/369
Log:
add default goal on assembly profile
Modified:
trunk/sammoa-ui-swing/pom.xml
Modified: trunk/sammoa-ui-swing/pom.xml
===================================================================
--- trunk/sammoa-ui-swing/pom.xml 2012-08-08 12:39:52 UTC (rev 368)
+++ trunk/sammoa-ui-swing/pom.xml 2012-08-08 15:58:36 UTC (rev 369)
@@ -384,6 +384,7 @@
</property>
</activation>
<build>
+ <defaultGoal>package</defaultGoal>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
1
0
r368 - trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap
by tchemit@users.forge.codelutin.com 08 Aug '12
by tchemit@users.forge.codelutin.com 08 Aug '12
08 Aug '12
Author: tchemit
Date: 2012-08-08 14:39:52 +0200 (Wed, 08 Aug 2012)
New Revision: 368
Url: http://forge.codelutin.com/repositories/revision/sammoa/368
Log:
create ExportMapModel
Modified:
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIModel.java
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIHandler.java 2012-08-08 12:38:50 UTC (rev 367)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIHandler.java 2012-08-08 12:39:52 UTC (rev 368)
@@ -106,15 +106,9 @@
ExportMapUIModel model = new ExportMapUIModel();
List<Campaign> campaigns = getReferentialService().getCampaigns();
+ //TODO-tchemit-2012-08-03 add an null campaign (for test purpose, should be removed...)
campaigns.add(0, null);
model.setCampaigns(campaigns);
-
-// List<String> speciesTypes = getReferentialService().getAllSpeciesTypes();
-// model.setSpeciesTypes(StringRefs.toRefs(speciesTypes));
-//
-// List<Species> species = getReferentialService().getAllSpecies();
-// model.setSpecies(species);
-
model.setRouteTypes(Lists.newArrayList(RouteType.values()));
String campaignId = context.getCampaignId();
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIModel.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIModel.java 2012-08-08 12:38:50 UTC (rev 367)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIModel.java 2012-08-08 12:39:52 UTC (rev 368)
@@ -28,6 +28,7 @@
import fr.ulr.sammoa.persistence.Campaign;
import fr.ulr.sammoa.persistence.RouteType;
import fr.ulr.sammoa.persistence.Species;
+import fr.ulr.sammoa.persistence.Species2;
import fr.ulr.sammoa.persistence.Strate;
import fr.ulr.sammoa.persistence.StringRef;
import org.jdesktop.beans.AbstractSerializableBean;
@@ -312,6 +313,10 @@
}
public ExportMapModel toModel(String filename) {
+
+ List<Species> speciesToUse = Species2.getSelectedSpecies(
+ getSpecies(), getSelectedSpecies(), getSelectedSpeciesTypes());
+
ExportMapModel result = ExportMapModel.newModel(
getExportDirectory(),
filename,
@@ -320,8 +325,7 @@
getEndDate(),
getSelectedStrates(),
getSelectedRouteTypes(),
- getSelectedSpecies(),
- getSelectedSpeciesTypes()
+ speciesToUse
);
return result;
}
1
0
r367 - trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence
by tchemit@users.forge.codelutin.com 08 Aug '12
by tchemit@users.forge.codelutin.com 08 Aug '12
08 Aug '12
Author: tchemit
Date: 2012-08-08 14:38:50 +0200 (Wed, 08 Aug 2012)
New Revision: 367
Url: http://forge.codelutin.com/repositories/revision/sammoa/367
Log:
add revert method (StringRef to String
Modified:
trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/StringRefs.java
Modified: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/StringRefs.java
===================================================================
--- trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/StringRefs.java 2012-08-08 12:37:23 UTC (rev 366)
+++ trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/StringRefs.java 2012-08-08 12:38:50 UTC (rev 367)
@@ -37,7 +37,6 @@
*/
public class StringRefs {
-
public static List<StringRef> toRefs(List<String> strings) {
List<StringRef> result =
@@ -45,6 +44,13 @@
return result;
}
+ public static List<String> toStrings(List<StringRef> strings) {
+
+ List<String> result =
+ Lists.newArrayList(Iterables.transform(strings, TO_STRING_FUNCTION));
+ return result;
+ }
+
protected static Function<String, StringRef> TO_STRING_REF_FUNCTION =
new Function<String, StringRef>() {
1
0
r366 - trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence
by tchemit@users.forge.codelutin.com 08 Aug '12
by tchemit@users.forge.codelutin.com 08 Aug '12
08 Aug '12
Author: tchemit
Date: 2012-08-08 14:37:23 +0200 (Wed, 08 Aug 2012)
New Revision: 366
Url: http://forge.codelutin.com/repositories/revision/sammoa/366
Log:
add method to compute selected filter for Species and SpeciesTypes
Modified:
trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Species2.java
Modified: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Species2.java
===================================================================
--- trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Species2.java 2012-08-08 12:36:48 UTC (rev 365)
+++ trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Species2.java 2012-08-08 12:37:23 UTC (rev 366)
@@ -23,8 +23,12 @@
* #L%
*/
+import com.google.common.base.Function;
import com.google.common.collect.Lists;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.Multimaps;
import com.google.common.collect.Sets;
+import org.apache.commons.collections.CollectionUtils;
import java.util.Collection;
import java.util.List;
@@ -49,4 +53,61 @@
}
return Lists.newArrayList(types);
}
+
+ /**
+ * Given a universe of species ({@code allSpecies}, and selected
+ * species ({@code selectedSpecies}) and selected species
+ * types ({@code speciesTypeSelected}), get all selected species.
+ * <p/>
+ * <strong>Note:</strong> if no species types are selected, then selects
+ * all of them (means at the end selected all species).
+ * <p/>
+ * <strong>Note:</strong> if all species are selected, then returns an
+ * empty list (usage of empty selected filter).
+ *
+ * @param allSpecies universe of definied species
+ * @param selectedSpecies selected species
+ * @param speciesTypeSelected selected species types (if empty then all are selected).
+ * @return the list of selected species (empty if all species are selected).
+ */
+ public static List<Species> getSelectedSpecies(List<Species> allSpecies,
+ List<Species> selectedSpecies,
+ List<StringRef> speciesTypeSelected) {
+ Set<Species> result = Sets.newHashSet();
+
+ // add all selected species
+ result.addAll(selectedSpecies);
+
+ if (CollectionUtils.isEmpty(speciesTypeSelected)) {
+
+ // no sepecies type selected : means select all types --> all species
+
+ } else {
+
+ // there is some selected species types
+
+ Multimap<String, Species> speciesByType =
+ Multimaps.index(allSpecies, TO_SPECIES_TYPE);
+
+ for (StringRef typeRef : speciesTypeSelected) {
+ String type = typeRef.getValue();
+ Collection<Species> speciesForType = speciesByType.get(type);
+ result.addAll(speciesForType);
+ }
+ }
+
+ if (result.size() == allSpecies.size()) {
+
+ // all species selected, so use none
+ result.clear();
+ }
+ return Lists.newArrayList(result);
+ }
+
+ protected static Function<Species, String> TO_SPECIES_TYPE = new Function<Species, String>() {
+ @Override
+ public String apply(Species input) {
+ return input.getType();
+ }
+ };
}
1
0
r365 - trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map
by tchemit@users.forge.codelutin.com 08 Aug '12
by tchemit@users.forge.codelutin.com 08 Aug '12
08 Aug '12
Author: tchemit
Date: 2012-08-08 14:36:48 +0200 (Wed, 08 Aug 2012)
New Revision: 365
Url: http://forge.codelutin.com/repositories/revision/sammoa/365
Log:
remove speciesTypes from ExportMapModel
Modified:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java 2012-08-08 12:36:20 UTC (rev 364)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java 2012-08-08 12:36:48 UTC (rev 365)
@@ -28,7 +28,6 @@
import fr.ulr.sammoa.persistence.RouteType;
import fr.ulr.sammoa.persistence.Species;
import fr.ulr.sammoa.persistence.Strate;
-import fr.ulr.sammoa.persistence.StringRef;
import java.io.File;
import java.io.Serializable;
@@ -52,8 +51,7 @@
Date endDate,
List<Strate> strates,
List<RouteType> routeTypes,
- List<Species> species,
- List<StringRef> speciesTypes) {
+ List<Species> species) {
ExportMapModel result = new ExportMapModel();
result.exportDirectory=exportDirectory;
result.exportFilename=exportFilename;
@@ -63,8 +61,6 @@
result.strates = strates;
result.routeTypes = routeTypes;
result.species = species;
- result.speciesTypes = speciesTypes;
-
return result;
}
@@ -80,8 +76,6 @@
protected List<Species> species;
- protected List<StringRef> speciesTypes;
-
protected File exportDirectory;
protected String exportFilename;
@@ -127,11 +121,4 @@
return species;
}
- public List<StringRef> getSpeciesTypes() {
- if (speciesTypes == null) {
- speciesTypes = Lists.newArrayList();
- }
- return speciesTypes;
- }
-
}
1
0
r364 - trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application
by tchemit@users.forge.codelutin.com 08 Aug '12
by tchemit@users.forge.codelutin.com 08 Aug '12
08 Aug '12
Author: tchemit
Date: 2012-08-08 14:36:20 +0200 (Wed, 08 Aug 2012)
New Revision: 364
Url: http://forge.codelutin.com/repositories/revision/sammoa/364
Log:
remove unused method
Modified:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/ReferentialService.java
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/ReferentialService.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/ReferentialService.java 2012-08-08 12:35:34 UTC (rev 363)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/ReferentialService.java 2012-08-08 12:36:20 UTC (rev 364)
@@ -615,22 +615,6 @@
return result;
}
- public List<Species> getAllSpecies() {
- TopiaContext tx = persistence.beginTransaction();
- try {
-
- List<Species> result = SammoaDAOHelper.getSpeciesDAO(tx).findAll();
- return result;
-
- } catch (TopiaException e) {
- throw new TopiaRuntimeException(e);
-
- } finally {
- persistence.endTransaction(tx);
- }
-
- }
-
public int importObservers(String campaignId, Reader reader) {
TopiaContext transaction = persistence.beginTransaction();
1
0
r363 - in trunk: sammoa-application/src/main/java/fr/ulr/sammoa/application sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing
by tchemit@users.forge.codelutin.com 08 Aug '12
by tchemit@users.forge.codelutin.com 08 Aug '12
08 Aug '12
Author: tchemit
Date: 2012-08-08 14:35:34 +0200 (Wed, 08 Aug 2012)
New Revision: 363
Url: http://forge.codelutin.com/repositories/revision/sammoa/363
Log:
can edit gpsHandlerClass from config
Modified:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaConfig.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsConfig.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaConfig.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaConfig.java 2012-08-07 15:49:43 UTC (rev 362)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaConfig.java 2012-08-08 12:35:34 UTC (rev 363)
@@ -25,6 +25,7 @@
package fr.ulr.sammoa.application;
import com.google.common.base.Preconditions;
+import com.google.common.base.Supplier;
import com.google.common.base.Throwables;
import fr.ulr.sammoa.application.device.gps.GpsConfig;
import fr.ulr.sammoa.persistence.AutoSaveListener;
@@ -36,7 +37,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.swing.*;
+import javax.swing.KeyStroke;
import java.io.File;
import java.io.IOException;
import java.net.URL;
@@ -51,7 +52,7 @@
* @author sletellier <letellier(a)codelutin.com>
* @author fdesbois <fdesbois(a)codelutin.com>
*/
-public class SammoaConfig {
+public class SammoaConfig implements Supplier<ApplicationConfig> {
/**
* Logger.
@@ -78,10 +79,12 @@
public static final String PROPERTY_CIRCLE_BACK = "circleBack";
+ public static final String PROPERTY_GPS_CONFIG = "gpsConfig";
+
/**
* Delegate application config object containing configuration.
*/
- protected ApplicationConfig applicationConfig;
+ protected final ApplicationConfig applicationConfig;
protected GpsConfig gpsConfig;
@@ -109,6 +112,11 @@
logger.debug("parsed options in config file {}", applicationConfig.getOptions());
}
+ @Override
+ public ApplicationConfig get() {
+ return applicationConfig;
+ }
+
public ApplicationConfig getApplicationConfig() {
return applicationConfig;
}
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsConfig.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsConfig.java 2012-08-07 15:49:43 UTC (rev 362)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsConfig.java 2012-08-08 12:35:34 UTC (rev 363)
@@ -2,8 +2,8 @@
/*
* #%L
* SAMMOA :: Application
- * $Id:$
- * $HeadURL:$
+ * $Id$
+ * $HeadURL$
* %%
* Copyright (C) 2012 UMS 3462, Code Lutin
* %%
@@ -36,6 +36,8 @@
*/
public class GpsConfig {
+ public static final String PROPERTY_GPS_HNALDER_CLASS = "gpsHandlerClass";
+
protected ApplicationConfig applicationConfig;
public GpsConfig(ApplicationConfig applicationConfig) {
@@ -54,6 +56,16 @@
}
/**
+ * @param newValue new handler class to set in configuration
+ * @since 0.5
+ */
+ public void setGpsHandlerClass(Class<?> newValue) {
+ applicationConfig.setOption(
+ GpsConfig.GpsConfigOption.GPS_HANDLER.getKey(),
+ newValue.getName());
+ }
+
+ /**
* @return {@link GpsConfigOption#GPS_CHECK_PERIOD} value
*/
public int getCheckPeriod() {
@@ -90,7 +102,7 @@
/** Implementation class for GpsHandler */
GPS_HANDLER("gps.handler",
n_("sammoa.config.gps.handler"),
- "fr.ulr.sammoa.application.device.gps.GpsHandlerGpsylon",
+ GpsHandlerGpsylon.class.getName(),
Class.class
),
/** Period time in seconds for each check of the gps to update location */
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java 2012-08-07 15:49:43 UTC (rev 362)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java 2012-08-08 12:35:34 UTC (rev 363)
@@ -217,7 +217,7 @@
public void showConfig() {
SammoaConfig config = context.getConfig();
- ConfigUIHelper helper = new ConfigUIHelper(config.getApplicationConfig());
+ ConfigUIHelper helper = new ConfigUIHelper(config);
helper.registerCallBack(
"ui",
@@ -307,9 +307,10 @@
}
});
helper.addCategory(n_("sammoa.config.category.gps"),
- n_("sammoa.config.category.gps.description"));
-// helper.addOption(GpsConfig.GpsConfigOption.GPS_HANDLER);
-// helper.setOptionCallBack("gps");
+ n_("sammoa.config.category.gps.description"));
+ helper.addOption(GpsConfig.GpsConfigOption.GPS_HANDLER,
+ SammoaConfig.PROPERTY_GPS_CONFIG + "." + GpsConfig.PROPERTY_GPS_HNALDER_CLASS);
+ helper.setOptionCallBack("gps");
helper.addOption(GpsConfig.GpsConfigOption.GPS_DEVICE);
helper.setOptionCallBack("gps");
helper.addOption(GpsConfig.GpsConfigOption.GPS_SPEED);
1
0
07 Aug '12
Author: fdesbois
Date: 2012-08-07 17:49:43 +0200 (Tue, 07 Aug 2012)
New Revision: 362
Url: http://forge.codelutin.com/repositories/revision/sammoa/362
Log:
fixes #1193 :
- Improve FlightControllerListener
- Resolve little issue with audio on close
- Improve all layers
- Create GeoPointLayer for flight tracking and observation
Added:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerListener.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/ObservationEvent.java
trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/GeoPointDAOImpl.java
trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/GeoPoints.java
trunk/sammoa-persistence/src/test/java/fr/ulr/sammoa/persistence/GeoPointsTest.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/BaseGeoPointLayer.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/LineGeoPointLayer.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/SimpleGeoPointLayer.java
Removed:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerUpdateListener.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/BaseReferentialLayer.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/GpsTracingLayer.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/StrateLayer.java
Modified:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/audio/AudioRecorderDefault.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/BaseGpsHandler.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/FakeGpsHandler.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightController.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerDefault.java
trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Observations.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaColors.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBarHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIModel.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/TransectLayer.java
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java 2012-08-07 15:49:18 UTC (rev 361)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -32,6 +32,8 @@
import fr.ulr.sammoa.persistence.Campaign;
import fr.ulr.sammoa.persistence.Flight;
import fr.ulr.sammoa.persistence.FlightDAO;
+import fr.ulr.sammoa.persistence.GeoPoint;
+import fr.ulr.sammoa.persistence.GeoPointDAO;
import fr.ulr.sammoa.persistence.Observation;
import fr.ulr.sammoa.persistence.ObservationDAO;
import fr.ulr.sammoa.persistence.ObservationStatus;
@@ -220,6 +222,26 @@
return result;
}
+
+ public List<GeoPoint> getFlightGeoPoints(Flight flight) {
+
+ List<GeoPoint> result;
+
+ TopiaContext transaction = persistence.beginTransaction();
+ try {
+ GeoPointDAO dao = SammoaDAOHelper.getGeoPointDAO(transaction);
+
+ result = dao.findAllByFlightOrderedByRecordTime(flight);
+
+ } catch (TopiaException e) {
+ throw new TopiaRuntimeException(e);
+
+ } finally {
+ persistence.endTransaction(transaction);
+ }
+ return result;
+ }
+
//
// public void removeAllFlightObservers(Flight flight, List<Observer> observers) {
//
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/audio/AudioRecorderDefault.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/audio/AudioRecorderDefault.java 2012-08-07 15:49:18 UTC (rev 361)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/audio/AudioRecorderDefault.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -277,6 +277,8 @@
if (getState() != DeviceState.NO_DEVICE) {
+ logger.info("Stop audio line reading");
+
// Destroy the thread
if (lineReader != null) {
lineReader.interrupt();
@@ -290,7 +292,7 @@
stop();
- if (dataLine != null && dataLine.isRunning()) {
+ if (dataLine != null/* && dataLine.isRunning()*/) {
logger.info("Close the audio line");
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/BaseGpsHandler.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/BaseGpsHandler.java 2012-08-07 15:49:18 UTC (rev 361)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/BaseGpsHandler.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -74,6 +74,7 @@
public BaseGpsHandler(GpsConfig config) {
this.config = config;
this.state = DeviceState.NO_DEVICE;
+ this.deviceStateListeners = Sets.newHashSet();
this.gpsLocationListeners = Sets.newHashSet();
this.nbFailuresMax =
(int) Math.ceil(config.getTimeout() / config.getCheckPeriod());
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/FakeGpsHandler.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/FakeGpsHandler.java 2012-08-07 15:49:18 UTC (rev 361)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/FakeGpsHandler.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -24,6 +24,7 @@
*/
package fr.ulr.sammoa.application.device.gps;
+import fr.ulr.sammoa.application.device.DeviceState;
import fr.ulr.sammoa.application.device.DeviceTechnicalException;
import fr.ulr.sammoa.persistence.GeoPoint;
import fr.ulr.sammoa.persistence.GeoPointImpl;
@@ -93,7 +94,7 @@
@Override
public void open() throws DeviceTechnicalException {
- // nothing to do
+ setState(DeviceState.READY);
}
@Override
@@ -107,7 +108,7 @@
@Override
public void close() throws DeviceTechnicalException {
- // nothing to do
+ setState(DeviceState.NO_DEVICE);
}
@Override
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightController.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightController.java 2012-08-07 15:49:18 UTC (rev 361)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightController.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -274,12 +274,12 @@
boolean isRunning();
/**
- * @param listener FlightControllerUpdateListener to add
+ * @param listener FlightControllerListener to add
*/
- void addListener(FlightControllerUpdateListener listener);
+ void addListener(FlightControllerListener listener);
/**
- * @param listener FlightControllerUpdateListener to remove
+ * @param listener FlightControllerListener to remove
*/
- void removeListener(FlightControllerUpdateListener listener);
+ void removeListener(FlightControllerListener listener);
}
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerDefault.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerDefault.java 2012-08-07 15:49:18 UTC (rev 361)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerDefault.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -100,8 +100,10 @@
protected TransectFlight lastTransect;
- protected Set<FlightControllerUpdateListener> listeners;
+ protected Set<FlightControllerListener> listeners;
+ protected GeoPoint lastLocation;
+
public FlightControllerDefault(SammoaContext context,
Flight flight) {
@@ -117,12 +119,12 @@
}
@Override
- public void addListener(FlightControllerUpdateListener listener) {
+ public void addListener(FlightControllerListener listener) {
listeners.add(listener);
}
@Override
- public void removeListener(FlightControllerUpdateListener listener) {
+ public void removeListener(FlightControllerListener listener) {
listeners.remove(listener);
}
@@ -595,9 +597,7 @@
startTime = timeLog.log(startTime, "observation()", "Commited");
- for (FlightControllerUpdateListener listener : listeners) {
- listener.onObservationAdded(observation);
- }
+ fireObservationAdded(observation);
timeLog.log(startTime, "observation()", "Fired");
@@ -729,7 +729,7 @@
//
// if (fireEvents) {
// // Fire transect changed
-// for (FlightControllerUpdateListener listener : listeners) {
+// for (FlightControllerListener listener : listeners) {
// listener.onNextTransectChanged(nextTransect);
// }
// }
@@ -808,6 +808,8 @@
} else {
+ lastLocation = geoPoint;
+
if (logger.isTraceEnabled()) {
logger.trace("Create GPS Point : {}", geoPoint);
}
@@ -822,21 +824,27 @@
}
return result;
}
+
+ protected void fireObservationAdded(Observation observation) {
+ for (FlightControllerListener listener : listeners) {
+ listener.onObservationAdded(new ObservationEvent(this, observation, lastLocation));
+ }
+ }
protected void fireStateChanged(FlightState state) {
- for (FlightControllerUpdateListener listener : listeners) {
+ for (FlightControllerListener listener : listeners) {
listener.onStateChanged(state);
}
}
protected void fireRouteAdded(Route route) {
- for (FlightControllerUpdateListener listener : listeners) {
+ for (FlightControllerListener listener : listeners) {
listener.onRouteAdded(route);
}
}
protected void fireNextTransectChanged(TransectFlight nextTransect) {
- for (FlightControllerUpdateListener listener : listeners) {
+ for (FlightControllerListener listener : listeners) {
listener.onNextTransectChanged(nextTransect);
}
}
@@ -873,6 +881,7 @@
public void locationChanged(GpsLocationEvent event) {
GeoPoint newLocation = event.getNewValue();
if (newLocation != null/* && newLocation.getTopiaId() == null*/) {
+ lastLocation = newLocation;
newLocation.setFlight(flight);
persistence.delayEntityCreation(newLocation);
}
Copied: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerListener.java (from rev 361, trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerUpdateListener.java)
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerListener.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerListener.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -0,0 +1,68 @@
+package fr.ulr.sammoa.application.flightController;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ulr.sammoa.persistence.Route;
+import fr.ulr.sammoa.persistence.TransectFlight;
+
+/**
+ * Listener for all change of data in the {@link FlightController}
+ *
+ * Created: 12/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ * @see FlightController
+ */
+public interface FlightControllerListener {
+
+ /**
+ * Fired when a new {@code route} has been created and added to the flight
+ *
+ * @param route The new route added
+ */
+ void onRouteAdded(Route route);
+
+ /**
+ * Fired when the next transect has been updated.
+ *
+ * @param nextTransect The next transect that will be used on
+ * {@link FlightController#begin()} action
+ */
+ void onNextTransectChanged(TransectFlight nextTransect);
+
+ /**
+ * Fired when controller change the {@code state} of the flight after
+ * each action.
+ *
+ * @param state The new state
+ */
+ void onStateChanged(FlightState state);
+
+ /**
+ * Fired when controller add a new observation
+ *
+ * @param event The event containing Observation and its associated GeoPoint
+ */
+ void onObservationAdded(ObservationEvent event);
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerListener.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerUpdateListener.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerUpdateListener.java 2012-08-07 15:49:18 UTC (rev 361)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerUpdateListener.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -1,69 +0,0 @@
-package fr.ulr.sammoa.application.flightController;
-/*
- * #%L
- * SAMMOA :: Application
- * $Id:$
- * $HeadURL:$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * 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 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ulr.sammoa.persistence.Observation;
-import fr.ulr.sammoa.persistence.Route;
-import fr.ulr.sammoa.persistence.TransectFlight;
-
-/**
- * Listener for all change of data in the {@link FlightController}
- *
- * Created: 12/07/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- * @see FlightController
- */
-public interface FlightControllerUpdateListener {
-
- /**
- * Fired when a new {@code route} has been created and added to the flight
- *
- * @param route The new route added
- */
- void onRouteAdded(Route route);
-
- /**
- * Fired when the next transect has been updated.
- *
- * @param nextTransect The next transect that will be used on
- * {@link FlightController#begin()} action
- */
- void onNextTransectChanged(TransectFlight nextTransect);
-
- /**
- * Fired when controller change the {@code state} of the flight after
- * each action.
- *
- * @param state The new state
- */
- void onStateChanged(FlightState state);
-
- /**
- * Fired when controller add a new observation
- *
- * @param observation The new observation
- */
- void onObservationAdded(Observation observation);
-}
Added: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/ObservationEvent.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/ObservationEvent.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/ObservationEvent.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -0,0 +1,61 @@
+package fr.ulr.sammoa.application.flightController;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ulr.sammoa.persistence.GeoPoint;
+import fr.ulr.sammoa.persistence.Observation;
+
+/**
+ * Created: 06/08/12
+ *
+ * @author fdesbois <florian.desbois(a)codelutin.com>
+ */
+public class ObservationEvent {
+
+ protected FlightController source;
+
+ protected Observation observation;
+
+ protected GeoPoint geoPoint;
+
+ public ObservationEvent(FlightController source,
+ Observation observation,
+ GeoPoint geoPoint) {
+ this.source = source;
+ this.observation = observation;
+ this.geoPoint = geoPoint;
+ }
+
+ public FlightController getSource() {
+ return source;
+ }
+
+ public Observation getObservation() {
+ return observation;
+ }
+
+ public GeoPoint getGeoPoint() {
+ return geoPoint;
+ }
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/ObservationEvent.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/GeoPointDAOImpl.java
===================================================================
--- trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/GeoPointDAOImpl.java (rev 0)
+++ trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/GeoPointDAOImpl.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -0,0 +1,52 @@
+package fr.ulr.sammoa.persistence;
+/*
+ * #%L
+ * SAMMOA :: Persistence
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaRuntimeException;
+
+import java.util.List;
+
+public class GeoPointDAOImpl<E extends GeoPoint> extends GeoPointDAOAbstract<E> {
+
+ public List<GeoPoint> findAllByFlightOrderedByRecordTime(Flight flight) {
+
+ List<GeoPoint> result;
+
+ String ql = String.format("FROM %1$s WHERE %2$s = :flight ORDER BY %3$s",
+ GeoPointImpl.class.getSimpleName(),
+ GeoPoint.PROPERTY_FLIGHT,
+ GeoPoint.PROPERTY_RECORD_TIME
+ );
+
+ try {
+ result = context.findAll(ql, "flight", flight);
+
+ } catch (TopiaException e) {
+ throw new TopiaRuntimeException(e);
+ }
+ return result;
+ }
+
+} //GeoPointDAOImpl<E extends GeoPoint>
Property changes on: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/GeoPointDAOImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/GeoPoints.java
===================================================================
--- trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/GeoPoints.java (rev 0)
+++ trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/GeoPoints.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -0,0 +1,167 @@
+package fr.ulr.sammoa.persistence;
+/*
+ * #%L
+ * SAMMOA :: Persistence
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Function;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Ordering;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Created: 11/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public final class GeoPoints {
+
+ private GeoPoints() {
+ // static class do not have instanciation
+ }
+
+ public static List<GeoPoint> getClosestPoints(List<GeoPoint> geoPoints, Iterable<Date> dates) {
+
+ List<GeoPoint> result = Lists.newArrayList();
+
+ List<Date> geoPointDates = FluentIterable
+ .from(geoPoints)
+ .transform(toDate())
+ .toSortedImmutableList(Ordering.natural());
+
+ int index = 0;
+ for (Date date : dates) {
+
+ // We continue starting from the previous index to avoid loop on all the date list
+ index = getClosestDateIndex(index > 0 ? index - 1 : 0, geoPointDates, date);
+
+ result.add(geoPoints.get(index));
+ }
+ return result;
+ }
+
+ public static Function<GeoPoint, Date> toDate() {
+ return TO_DATE_FUNCTION;
+ }
+
+ protected static Function<GeoPoint, Date> TO_DATE_FUNCTION = new Function<GeoPoint, Date>() {
+
+ @Override
+ public Date apply(GeoPoint input) {
+ return input.getRecordTime();
+ }
+ };
+
+// protected static Date getClosestDate(List<Date> source, Date date) {
+// int index = getClosestDateIndex(0, source, date);
+// Date result = source.get(index);
+// return result;
+// }
+//
+// protected static Date getClosestDate(List<Date> source, Date date) {
+// int size = source.size();
+// for (int index = 0; index < size; index++) {
+//
+// int nextIndex = index + 1;
+// if (nextIndex < size) {
+//
+// Date before = source.get(index);
+// Date after = source.get(nextIndex);
+//
+// // If the date is equal or before we take the current index
+// if (date.equals(before) || date.before(before)) {
+// return before;
+//
+// // If the date is before the next date, we check which one
+// // of the before and after is the nearest value and we return
+// // its index
+// } else if (date.before(after)) {
+//
+// long diffBefore = date.getTime() - before.getTime();
+// long diffAfter = after.getTime() - date.getTime();
+//
+// if (diffBefore <= diffAfter) {
+// return before;
+//
+// } else {
+// return after;
+// }
+// }
+// }
+// }
+// // We loop over the whole list, so we return the last date
+// return source.get(size - 1);
+// }
+
+ protected static int getClosestDateIndex(int startIndex, List<Date> source, Date date) {
+ int size = source.size();
+ for (int index = startIndex; index < size; index++) {
+
+ int nextIndex = index + 1;
+ if (nextIndex < size) {
+
+ Date before = source.get(index);
+ Date after = source.get(nextIndex);
+
+ // If the date is equal or before we take the current index
+ if (date.equals(before) || date.before(before)) {
+ return index;
+
+ // If the date is before the next date, we check which one
+ // of the before and after is the nearest value and we return
+ // its index
+ } else if (date.before(after)) {
+
+ long diffBefore = date.getTime() - before.getTime();
+ long diffAfter = after.getTime() - date.getTime();
+
+ if (diffBefore <= diffAfter) {
+ return index;
+
+ } else {
+ return nextIndex;
+ }
+ }
+ }
+ }
+ // We loop over the whole list, we return the last index
+ return size - 1;
+ }
+
+// protected static Date getNearestDate(List<Date> dates, Date currentDate) {
+// long minDiff = -1;
+// long currentTime = currentDate.getTime();
+// Date minDate = null;
+// for (Date date : dates) {
+// long diff = Math.abs(currentTime - date.getTime());
+// if ((minDiff == -1) || (diff < minDiff)) {
+// minDiff = diff;
+// minDate = date;
+// }
+// }
+// return minDate;
+// }
+
+}
Property changes on: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/GeoPoints.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Observations.java
===================================================================
--- trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Observations.java 2012-08-07 15:49:18 UTC (rev 361)
+++ trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Observations.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -23,6 +23,7 @@
* #L%
*/
+import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import org.nuiton.util.DateUtil;
@@ -39,6 +40,10 @@
private Observations() {
// static class do not have instanciation
}
+
+ public static Function<Observation, Date> toDate() {
+ return TO_DATE_FUNCTION;
+ }
public static boolean inRoute(Observation observation, Route route, Route nextRoute) {
@@ -53,6 +58,14 @@
public static Predicate<Observation> inRoute(Route route, Route nextRoute) {
return new ObservationInRoutePredicate(route, nextRoute);
}
+
+ protected static Function<Observation, Date> TO_DATE_FUNCTION = new Function<Observation, Date>() {
+
+ @Override
+ public Date apply(Observation input) {
+ return input.getObservationTime();
+ }
+ };
protected static class ObservationInRoutePredicate implements Predicate<Observation> {
Added: trunk/sammoa-persistence/src/test/java/fr/ulr/sammoa/persistence/GeoPointsTest.java
===================================================================
--- trunk/sammoa-persistence/src/test/java/fr/ulr/sammoa/persistence/GeoPointsTest.java (rev 0)
+++ trunk/sammoa-persistence/src/test/java/fr/ulr/sammoa/persistence/GeoPointsTest.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -0,0 +1,86 @@
+package fr.ulr.sammoa.persistence;
+/*
+ * #%L
+ * SAMMOA :: Persistence
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.Lists;
+import junit.framework.Assert;
+import org.junit.Test;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Created: 06/08/12
+ *
+ * @author fdesbois <florian.desbois(a)codelutin.com>
+ */
+public class GeoPointsTest {
+
+ @Test
+ public void testGetClosestPoints() throws Exception {
+
+ List<GeoPoint> geoPoints = Lists.newArrayList();
+
+ for (int i = 0; i < 100; i++) {
+
+ GeoPoint geoPoint = new GeoPointImpl();
+ geoPoint.setRecordTime(new Date(i * 1000));
+ geoPoints.add(geoPoint);
+ }
+
+ List<Date> dates = Lists.newArrayList(new Date(4178), new Date(5824), new Date(85140));
+
+ List<GeoPoint> result = GeoPoints.getClosestPoints(geoPoints, dates);
+
+ Assert.assertEquals(3, result.size());
+ Assert.assertEquals(4000, result.get(0).getRecordTime().getTime());
+ Assert.assertEquals(6000, result.get(1).getRecordTime().getTime());
+ Assert.assertEquals(85000, result.get(2).getRecordTime().getTime());
+ }
+
+ @Test
+ public void testGetClosestPoints2() throws Exception {
+
+ List<GeoPoint> geoPoints = Lists.newArrayList();
+ {
+ GeoPoint geoPoint = new GeoPointImpl();
+ geoPoint.setRecordTime(new Date(8000));
+ geoPoints.add(geoPoint);
+ }
+ {
+ GeoPoint geoPoint = new GeoPointImpl();
+ geoPoint.setRecordTime(new Date(15000));
+ geoPoints.add(geoPoint);
+ }
+
+ List<Date> dates = Lists.newArrayList(new Date(4178), new Date(8000), new Date(85140));
+
+ List<GeoPoint> result = GeoPoints.getClosestPoints(geoPoints, dates);
+
+ Assert.assertEquals(3, result.size());
+ Assert.assertEquals(8000, result.get(0).getRecordTime().getTime());
+ Assert.assertEquals(8000, result.get(1).getRecordTime().getTime());
+ Assert.assertEquals(15000, result.get(2).getRecordTime().getTime());
+ }
+}
Property changes on: trunk/sammoa-persistence/src/test/java/fr/ulr/sammoa/persistence/GeoPointsTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaColors.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaColors.java 2012-08-07 15:49:18 UTC (rev 361)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaColors.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -54,8 +54,10 @@
public static final Color FLIGHT_TRACKING_LINE_COLOR = Color.RED;
- public static final Color TRANSECT_LINE_COLOR = new Color(102, 0, 255); // #6600ff
+ public static final Color TRANSECT_LINE_COLOR = new Color(102, 0, 255);
+ public static final Color TRANSECT_SELECT_LINE_COLOR = new Color(255, 126, 0);
+
public static final Color TRANSECT_WITHOUT_GRAPHIC_BACKGROUND_COLOR = new Color(255,233,233);
}
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBarHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBarHandler.java 2012-08-07 15:49:18 UTC (rev 361)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBarHandler.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -56,6 +56,9 @@
getFlightController().getAudioRecorder().addDeviceStateListener(view.getAudioLED());
getFlightController().getGpsHandler().addDeviceStateListener(view.getGpsLED());
getFlightController().getGpsHandler().addGpsLocationListener(getModel());
+ if (FlightState.OFF_EFFORT.equals(getFlightUIModel().getFlightState())) {
+ getModel().setEffortPanelColor(SammoaColors.ON_EFFORT_BACKGROUND_COLOR);
+ }
}
@Override
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java 2012-08-07 15:49:18 UTC (rev 361)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -37,7 +37,9 @@
import com.bbn.openmap.layer.shape.BufferedShapeLayer;
import com.bbn.openmap.layer.shape.ShapeLayer;
import com.bbn.openmap.omGraphics.DrawingAttributes;
+import com.bbn.openmap.plugin.esri.EsriPlugIn;
import com.bbn.openmap.proj.coords.LatLonPoint;
+import com.bbn.openmap.util.PropUtils;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
@@ -55,18 +57,22 @@
import fr.ulr.sammoa.application.device.gps.GpsLocationListener;
import fr.ulr.sammoa.application.flightController.FlightController;
import fr.ulr.sammoa.application.flightController.FlightControllerDefault;
-import fr.ulr.sammoa.application.flightController.FlightControllerUpdateListener;
+import fr.ulr.sammoa.application.flightController.FlightControllerListener;
import fr.ulr.sammoa.application.flightController.FlightState;
+import fr.ulr.sammoa.application.flightController.ObservationEvent;
import fr.ulr.sammoa.persistence.Campaign;
import fr.ulr.sammoa.persistence.Flight;
import fr.ulr.sammoa.persistence.GeoPoint;
+import fr.ulr.sammoa.persistence.GeoPoints;
import fr.ulr.sammoa.persistence.Observation;
+import fr.ulr.sammoa.persistence.Observations;
import fr.ulr.sammoa.persistence.Observer;
import fr.ulr.sammoa.persistence.Route;
import fr.ulr.sammoa.persistence.Strate;
import fr.ulr.sammoa.persistence.Transect;
import fr.ulr.sammoa.persistence.TransectFlight;
import fr.ulr.sammoa.persistence.TransectFlights;
+import fr.ulr.sammoa.ui.swing.SammoaColors;
import fr.ulr.sammoa.ui.swing.SammoaDecoratorProvider;
import fr.ulr.sammoa.ui.swing.SammoaUIContext;
import fr.ulr.sammoa.ui.swing.SammoaUIHandler;
@@ -81,8 +87,9 @@
import fr.ulr.sammoa.ui.swing.action.RightObservationAction;
import fr.ulr.sammoa.ui.swing.action.StartAction;
import fr.ulr.sammoa.ui.swing.action.StopAction;
-import fr.ulr.sammoa.ui.swing.flight.layer.GpsTracingLayer;
-import fr.ulr.sammoa.ui.swing.flight.layer.StrateLayer;
+import fr.ulr.sammoa.ui.swing.flight.layer.BaseGeoPointLayer;
+import fr.ulr.sammoa.ui.swing.flight.layer.LineGeoPointLayer;
+import fr.ulr.sammoa.ui.swing.flight.layer.SimpleGeoPointLayer;
import fr.ulr.sammoa.ui.swing.flight.layer.TransectLayer;
import fr.ulr.sammoa.ui.swing.transect.TransectUI;
import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
@@ -114,7 +121,7 @@
*
* @author fdesbois <desbois(a)codelutin.com>
*/
-public class FlightUIHandler implements SammoaUIHandler, FlightControllerUpdateListener {
+public class FlightUIHandler implements SammoaUIHandler, FlightControllerListener {
private static final Logger logger = LoggerFactory.getLogger(FlightUIHandler.class);
@@ -130,6 +137,10 @@
protected TransectUI transectUi;
+ protected BaseGeoPointLayer observationLayer;
+
+ protected BaseGeoPointLayer flightLayer;
+
public FlightUIHandler(SammoaUIContext context,
FlightUI ui) {
this.context = context;
@@ -195,6 +206,17 @@
List<Observer> observers = getFlightService().getFlightObserverForPositions(flight);
List<Observation> observations = getFlightService().getObservations(flight);
List<Route> routes = getFlightService().getRoutes(flight);
+ List<GeoPoint> geoPoints = getFlightService().getFlightGeoPoints(flight);
+
+ if (logger.isDebugEnabled()) {
+ for (GeoPoint geoPoint : geoPoints) {
+ logger.debug(String.format("GeoPoint={%1$tH:%1$tM:%1$tS,%2$f,%3$f}",
+ geoPoint.getRecordTime(),
+ geoPoint.getLatitude(),
+ geoPoint.getLongitude())
+ );
+ }
+ }
// List<Strate> strates = getReferentialService().getAllStrates(campaign);
List<Transect> transects = getReferentialService().getAllTransects(campaign);
@@ -225,6 +247,8 @@
}
flightController.addListener(this);
+ flightController.getGpsHandler().addGpsLocationListener(gpsLocationListener);
+
flightController.init();
FlightUIModel model = new FlightUIModel();
@@ -234,6 +258,7 @@
model.setFlightObserverForPositions(observers);
model.setObservations(observations);
model.setRoutes(routes);
+ model.setGeoPoints(geoPoints);
model.setStrates(prepareStrates(transects));
@@ -380,20 +405,6 @@
initMapHandler();
- getFlightController().getGpsHandler().addGpsLocationListener(
- new GpsLocationListener() {
-
- @Override
- public void locationChanged(GpsLocationEvent event) {
- GeoPoint newLocation = event.getNewValue();
- if (newLocation != null && getModel().isMapFollow()) {
- MapBean mapBean = getOverlayMapPanel().getMapBean();
- mapBean.setCenter(new LatLonPoint.Double(newLocation.getLatitude(),
- newLocation.getLongitude()));
- }
- }
- });
-
timeLog.log(startTime, "afterInitUI", "map is initialized");
}
@@ -431,8 +442,15 @@
}
@Override
- public void onObservationAdded(Observation observation) {
+ public void onObservationAdded(ObservationEvent event) {
+ Observation observation = event.getObservation();
getModel().addObservation(observation);
+
+ // Add the GeoPoint to the layer
+ GeoPoint geoPoint = event.getGeoPoint();
+ if (geoPoint != null) {
+ observationLayer.addGeoPoint(geoPoint);
+ }
}
public void selectStrate(StrateModel strate) {
@@ -702,65 +720,131 @@
mapHandler.add(new OMMouseMode());
mapHandler.add(new ToolPanel());
- // Ajout du fond : carte politique du monde stockée dans un fichier shapefile
-
- File backgroundShapeFile = getConfig().getBackgroundShapeFile();
- if (backgroundShapeFile != null && backgroundShapeFile.exists()) {
-
- ShapeLayer shapeLayer = new BufferedShapeLayer();
- Properties properties = new Properties();
- properties.put("prettyName", "Political Solid");
- properties.put(DrawingAttributes.linePaintProperty, "ff000000");
- properties.put(DrawingAttributes.fillPaintProperty, "ffbdde83");
- String path = backgroundShapeFile.getAbsolutePath();
-// String path = SammoaConfig.SammoaConfigOption.BACKGROUND_SHAPE_FILE.getDefaultValue();
- properties.put(ShapeLayer.shapeFileProperty, path);
- shapeLayer.setProperties(properties);
- mapHandler.add(shapeLayer);
+ // BackgroundLayer
+ {
+ File backgroundShapeFile = getConfig().getBackgroundShapeFile();
+ if (backgroundShapeFile != null && backgroundShapeFile.exists()) {
+
+ Properties properties = new Properties();
+ properties.put("prettyName", "Political Solid");
+ properties.put(DrawingAttributes.linePaintProperty, "ff000000");
+ properties.put(DrawingAttributes.fillPaintProperty, "ffbdde83");
+ String path = backgroundShapeFile.getAbsolutePath();
+ properties.put(ShapeLayer.shapeFileProperty, path);
+
+ ShapeLayer shapeLayer = new BufferedShapeLayer();
+ shapeLayer.setProperties(properties);
+
+ mapHandler.add(shapeLayer);
+ }
}
-// File strateFile = getConfig().getStrateShapeFile();
String campaignId = getModel().getFlight().getCampaign().getTopiaId();
File mapDirectory = new File(new File(new File(getConfig().getDataDirectory(), "campaign"), campaignId), "map");
- File strateFile = new File(mapDirectory, "strates.shp");
- if (strateFile.exists()) {
- mapHandler.add(new StrateLayer(strateFile, getModel()));
- } else {
- logger.warn("No strate file is defined, the file must be " +
- "defined here: {}", strateFile.getAbsolutePath());
- }
+ // StrateLayer
+ {
+ File file = new File(mapDirectory, "strates.shp");
+ if (file.exists()) {
-// File transectFile = getConfig().getTransectShapeFile();
- File transectFile = new File(mapDirectory, "transects.shp");
- if (transectFile.exists()) {
- mapHandler.add(new TransectLayer(transectFile, getModel()));
+ Properties properties = new Properties();
+ properties.put("prettyName", "Strates");
+ properties.put(ShapeLayer.shapeFileProperty, file.toURI().getPath());
+// properties.put(EsriPlugIn.PARAM_SHP, file.toURI().getPath());
- } else {
- logger.warn("No transect file is defined, the file must be " +
- "defined here: {}", transectFile.getAbsolutePath());
+ ShapeLayer strateLayer = new BufferedShapeLayer();
+ strateLayer.setProperties(properties);
+
+// EsriPlugIn esriPlugIn = new EsriPlugIn();
+// esriPlugIn.setProperties(properties);
+//
+// PlugInLayer strateLayer = new PlugInLayer();
+// strateLayer.setPlugIn(esriPlugIn);
+
+ mapHandler.add(strateLayer);
+
+ } else {
+ logger.warn("No strate file is defined, the file must be " +
+ "defined here: {}", file.getAbsolutePath());
+ }
}
- // Ajout d'un layer pour représenter les points relevés par le GPS
- GpsTracingLayer gpsTracingLayer = new GpsTracingLayer();
- getFlightController().getGpsHandler().addGpsLocationListener(gpsTracingLayer);
- mapHandler.add(gpsTracingLayer);
+ // TransectLayer
+ {
+ File file = new File(mapDirectory, "transects.shp");
+ if (file.exists()) {
- InformationDelegator informationDelegator = new InformationDelegator();
- informationDelegator.setShowLights(false);
+ Properties properties = new Properties();
+ properties.put("prettyName", "Transects");
+ properties.put(EsriPlugIn.PARAM_SHP, file.toURI().getPath());
+ String lineColor = PropUtils.getProperty(SammoaColors.TRANSECT_LINE_COLOR);
+ properties.put(DrawingAttributes.linePaintProperty, lineColor);
+ String selectColor = PropUtils.getProperty(SammoaColors.TRANSECT_SELECT_LINE_COLOR);
+ properties.put(DrawingAttributes.selectPaintProperty, selectColor);
- // add combo box to informationDelegator
- JCheckBox followMapCheckBox = new JCheckBox(_("sammoa.map.mapFollow"));
- followMapCheckBox.addItemListener(new ItemListener() {
+ EsriPlugIn esriPlugIn = new EsriPlugIn();
+ esriPlugIn.setProperties(properties);
- @Override
- public void itemStateChanged(ItemEvent e) {
- getModel().setMapFollow(e.getStateChange() == ItemEvent.SELECTED);
+ TransectLayer transectLayer = new TransectLayer();
+ transectLayer.setPlugIn(esriPlugIn);
+ transectLayer.init(getModel());
+
+ mapHandler.add(transectLayer);
+
+ } else {
+ logger.warn("No transect file is defined, the file must be " +
+ "defined here: {}", file.getAbsolutePath());
}
- });
- informationDelegator.add(followMapCheckBox);
+ }
- mapHandler.add(informationDelegator);
+ // FlightLayer (used also for GPS tracking)
+ {
+ Properties properties = new Properties();
+ String lineColor = PropUtils.getProperty(SammoaColors.FLIGHT_TRACKING_LINE_COLOR);
+ properties.put(DrawingAttributes.linePaintProperty, lineColor);
+
+ flightLayer = new LineGeoPointLayer();
+ flightLayer.setProperties(properties);
+ flightLayer.setGeoPoints(getModel().getGeoPoints());
+
+ mapHandler.add(flightLayer);
+ }
+
+ // ObservationLayer
+ {
+ Properties properties = new Properties();
+ properties.put(DrawingAttributes.PointOvalProperty, "true");
+
+ observationLayer = new SimpleGeoPointLayer();
+ observationLayer.setProperties(properties);
+
+ List<GeoPoint> geoPoints = GeoPoints.getClosestPoints(
+ getModel().getGeoPoints(),
+ Iterables.transform(getModel().getObservations(), Observations.toDate())
+ );
+ observationLayer.setGeoPoints(geoPoints);
+
+ mapHandler.add(observationLayer);
+ }
+
+ // InformationDelegator with JCheckBox for mapFollow property
+ {
+ InformationDelegator informationDelegator = new InformationDelegator();
+ informationDelegator.setShowLights(false);
+
+ // add combo box to informationDelegator
+ JCheckBox followMapCheckBox = new JCheckBox(_("sammoa.map.mapFollow"));
+ followMapCheckBox.addItemListener(new ItemListener() {
+
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ getModel().setMapFollow(e.getStateChange() == ItemEvent.SELECTED);
+ }
+ });
+ informationDelegator.add(followMapCheckBox);
+
+ mapHandler.add(informationDelegator);
+ }
}
protected PropertyChangeListener transectFlightListener = new PropertyChangeListener() {
@@ -788,6 +872,30 @@
}
};
+ protected GpsLocationListener gpsLocationListener = new GpsLocationListener() {
+
+ @Override
+ public void locationChanged(GpsLocationEvent event) {
+
+ GeoPoint location = event.getNewValue();
+ if (location != null) {
+
+ // Add the GeoPoint to the layer
+ if (flightLayer != null) {
+ flightLayer.addGeoPoint(location);
+ }
+
+ // Center the map on the location if mapFollow is activated
+ if (getModel().isMapFollow()) {
+ MapBean mapBean = getOverlayMapPanel().getMapBean();
+ LatLonPoint center = new LatLonPoint.Double(
+ location.getLatitude(), location.getLongitude());
+ mapBean.setCenter(center);
+ }
+ }
+ }
+ };
+
protected ComponentListener transectUIListener = new ComponentListener() {
@Override
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIModel.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIModel.java 2012-08-07 15:49:18 UTC (rev 361)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIModel.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -28,6 +28,7 @@
import com.google.common.collect.Lists;
import fr.ulr.sammoa.application.flightController.FlightState;
import fr.ulr.sammoa.persistence.Flight;
+import fr.ulr.sammoa.persistence.GeoPoint;
import fr.ulr.sammoa.persistence.Observation;
import fr.ulr.sammoa.persistence.Observations;
import fr.ulr.sammoa.persistence.Observer;
@@ -83,6 +84,8 @@
public static final String PROPERTY_TRANSECT_SELECTION_EXISTS = "transectSelectionExists";
+ public static final String PROPERTY_GEO_POINTS = "geoPoints";
+
protected Flight flight;
protected List<Observer> observers;
@@ -137,6 +140,8 @@
protected List<TransectFlightModel> transectFlights;
+ protected List<GeoPoint> geoPoints;
+
protected SwingValidatorMessageTableModel validatorTableModel
= new SwingValidatorMessageTableModel();
@@ -408,4 +413,17 @@
this.transectFlights = transectFlights;
firePropertyChange(PROPERTY_TRANSECT_FLIGHTS, oldValue, transectFlights);
}
+
+ public List<GeoPoint> getGeoPoints() {
+ if (geoPoints == null) {
+ geoPoints = Lists.newArrayList();
+ }
+ return geoPoints;
+ }
+
+ public void setGeoPoints(List<GeoPoint> geoPoints) {
+ List<GeoPoint> oldValue = Lists.newArrayList(getGeoPoints());
+ this.geoPoints = geoPoints;
+ firePropertyChange(PROPERTY_GEO_POINTS, oldValue, geoPoints);
+ }
}
Added: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/BaseGeoPointLayer.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/BaseGeoPointLayer.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/BaseGeoPointLayer.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -0,0 +1,91 @@
+package fr.ulr.sammoa.ui.swing.flight.layer;
+/*
+ * #%L
+ * SAMMOA :: UI Swing
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.bbn.openmap.layer.OMGraphicHandlerLayer;
+import com.bbn.openmap.omGraphics.DrawingAttributes;
+import com.bbn.openmap.omGraphics.OMGraphic;
+import com.bbn.openmap.omGraphics.OMGraphicList;
+import fr.ulr.sammoa.persistence.GeoPoint;
+
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * Created: 06/08/12
+ *
+ * @author fdesbois <florian.desbois(a)codelutin.com>
+ */
+public abstract class BaseGeoPointLayer extends OMGraphicHandlerLayer {
+
+ protected DrawingAttributes drawingAttributes = DrawingAttributes.getDefaultClone();
+
+ public void setGeoPoints(List<GeoPoint> geoPoints) {
+ setList(new OMGraphicList());
+
+ for (GeoPoint geoPoint : geoPoints) {
+ addGraphic(geoPoint);
+ }
+ }
+
+ public void addGeoPoint(GeoPoint geoPoint) {
+
+ addGraphic(geoPoint);
+
+ // Need to generate the projection to apply change
+ getList().generate(getProjection());
+
+ // Refresh the view
+ repaint();
+ }
+
+ @Override
+ public void setProperties(String prefix, Properties props) {
+ super.setProperties(prefix, props);
+ drawingAttributes.setProperties(prefix, props);
+ }
+
+ @Override
+ public Properties getProperties(Properties props) {
+ Properties result = super.getProperties(props);
+ drawingAttributes.getProperties(result);
+ return result;
+ }
+
+ @Override
+ public Properties getPropertyInfo(Properties list) {
+ Properties result = super.getPropertyInfo(list);
+ drawingAttributes.getPropertyInfo(list);
+ return result;
+ }
+
+ protected void addGraphic(GeoPoint geoPoint) {
+ OMGraphic graphic = newGraphic(geoPoint);
+ drawingAttributes.setTo(graphic);
+ graphic.setAppObject(geoPoint);
+ getList().add(graphic);
+ }
+
+ protected abstract OMGraphic newGraphic(GeoPoint geoPoint);
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/BaseGeoPointLayer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/BaseReferentialLayer.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/BaseReferentialLayer.java 2012-08-07 15:49:18 UTC (rev 361)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/BaseReferentialLayer.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -1,85 +0,0 @@
-/*
- * #%L
- * SAMMOA :: UI Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * 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 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-package fr.ulr.sammoa.ui.swing.flight.layer;
-
-import com.bbn.openmap.dataAccess.shape.EsriGraphicList;
-import com.bbn.openmap.plugin.PlugInLayer;
-import com.bbn.openmap.plugin.esri.EsriPlugIn;
-import com.google.common.base.Preconditions;
-import fr.ulr.sammoa.persistence.Campaign;
-import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
-
-import java.io.File;
-import java.util.Properties;
-
-/**
- * Created: 12/06/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- */
-public abstract class BaseReferentialLayer extends PlugInLayer {
-
- protected Campaign campaign;
-
- protected FlightUIModel model;
-
- public BaseReferentialLayer(String name, File shapeFile, FlightUIModel model) {
-
- Preconditions.checkNotNull(shapeFile);
- Preconditions.checkArgument(shapeFile.exists(),
- "Shape file " + shapeFile.getAbsolutePath() + " doesn't exist");
-
- this.model = model;
- this.campaign = model.getFlight().getCampaign();
-
- EsriPlugIn esriPlugIn = new EsriPlugIn();
- Properties properties = new Properties();
- properties.put("prettyName", name);
- String shapePath = shapeFile.toURI().getPath();
- properties.put(EsriPlugIn.PARAM_SHP, shapePath);
-
- onInitProperties(properties);
-
- esriPlugIn.setProperties(properties);
-
- setPlugIn(esriPlugIn);
- setVisible(true);
- }
-
- public FlightUIModel getModel() {
- return model;
- }
-
- @Override
- public EsriGraphicList getList() {
- return getEsriPlugin().getEsriGraphicList();
- }
- protected EsriPlugIn getEsriPlugin() {
- return (EsriPlugIn) getPlugIn();
- }
-
- protected abstract void onInitProperties(Properties properties);
-
-}
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/GpsTracingLayer.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/GpsTracingLayer.java 2012-08-07 15:49:18 UTC (rev 361)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/GpsTracingLayer.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -1,90 +0,0 @@
-/*
- * #%L
- * SAMMOA :: Application
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * 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 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-package fr.ulr.sammoa.ui.swing.flight.layer;
-
-import com.bbn.openmap.layer.OMGraphicHandlerLayer;
-import com.bbn.openmap.omGraphics.OMGraphic;
-import com.bbn.openmap.omGraphics.OMGraphicConstants;
-import com.bbn.openmap.omGraphics.OMGraphicList;
-import com.bbn.openmap.omGraphics.OMLine;
-import fr.ulr.sammoa.application.device.gps.GpsLocationEvent;
-import fr.ulr.sammoa.application.device.gps.GpsLocationListener;
-import fr.ulr.sammoa.persistence.GeoPoint;
-import fr.ulr.sammoa.persistence.GeoPointImpl;
-import fr.ulr.sammoa.ui.swing.SammoaColors;
-
-/**
- * Un layer OpenMap qui affiche les points envoyés par le GPS.
- */
-public class GpsTracingLayer extends OMGraphicHandlerLayer implements GpsLocationListener {
-
-// private static final Logger logger = LoggerFactory.getLogger(GpsTracingLayer.class);
-
- protected GeoPoint currentLocation;
-
- public GpsTracingLayer() {
-
- // Initialize the list
- setList(new OMGraphicList());
- }
-
- @Override
- public void locationChanged(GpsLocationEvent event) {
-// OMGraphic point = new OMPoint(newLocation.getLatitude(), newLocation.getLongitude());
-
- GeoPoint newLocation = event.getNewValue();
-
- if (currentLocation == null) {
-
- // do not display the first location point
-
- } else if (newLocation != null) {
-
- // Create the line between the currentLocation and the new one
- OMGraphic line = new OMLine(
- currentLocation.getLatitude(),
- currentLocation.getLongitude(),
- newLocation.getLatitude(),
- newLocation.getLongitude(),
- OMGraphicConstants.LINETYPE_GREATCIRCLE
- );
- line.setLinePaint(SammoaColors.FLIGHT_TRACKING_LINE_COLOR);
-
- // Add the new line to the GraphicList
- getList().add(line);
-
- // Need to generate the projection to apply change
- getList().generate(getProjection());
-// line.generate(getProjection());
-
- // Refresh the view
- repaint();
- }
-
- if (newLocation != null) {
- currentLocation = new GeoPointImpl(newLocation.getLatitude(), newLocation.getLongitude());
- }
- }
-}
Added: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/LineGeoPointLayer.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/LineGeoPointLayer.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/LineGeoPointLayer.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -0,0 +1,63 @@
+package fr.ulr.sammoa.ui.swing.flight.layer;
+/*
+ * #%L
+ * SAMMOA :: UI Swing
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.bbn.openmap.omGraphics.OMGraphic;
+import com.bbn.openmap.omGraphics.OMGraphicConstants;
+import com.bbn.openmap.omGraphics.OMLine;
+import com.bbn.openmap.omGraphics.OMPoint;
+import com.google.common.collect.Iterables;
+import fr.ulr.sammoa.persistence.GeoPoint;
+
+/**
+ * Created: 07/08/12
+ *
+ * @author fdesbois <florian.desbois(a)codelutin.com>
+ */
+public class LineGeoPointLayer extends BaseGeoPointLayer {
+
+ @Override
+ protected OMGraphic newGraphic(GeoPoint geoPoint) {
+
+ OMGraphic result;
+ if (!getList().isEmpty()) {
+
+ OMGraphic lastGraphic = Iterables.getLast(getList());
+
+ GeoPoint previousPoint = (GeoPoint) lastGraphic.getAppObject();
+
+ result = new OMLine(
+ previousPoint.getLatitude(),
+ previousPoint.getLongitude(),
+ geoPoint.getLatitude(),
+ geoPoint.getLongitude(),
+ OMGraphicConstants.LINETYPE_GREATCIRCLE
+ );
+
+ } else {
+ result = new OMPoint(geoPoint.getLatitude(), geoPoint.getLongitude());
+ }
+ return result;
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/LineGeoPointLayer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/SimpleGeoPointLayer.java (from rev 361, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/StrateLayer.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/SimpleGeoPointLayer.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/SimpleGeoPointLayer.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -0,0 +1,41 @@
+package fr.ulr.sammoa.ui.swing.flight.layer;
+/*
+ * #%L
+ * SAMMOA :: UI Swing
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.bbn.openmap.omGraphics.OMPoint;
+import fr.ulr.sammoa.persistence.GeoPoint;
+
+/**
+ * Created: 07/08/12
+ *
+ * @author fdesbois <florian.desbois(a)codelutin.com>
+ */
+public class SimpleGeoPointLayer extends BaseGeoPointLayer {
+
+ @Override
+ protected OMPoint newGraphic(GeoPoint geoPoint) {
+ OMPoint result = new OMPoint(geoPoint.getLatitude(), geoPoint.getLongitude());
+ return result;
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/SimpleGeoPointLayer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/StrateLayer.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/StrateLayer.java 2012-08-07 15:49:18 UTC (rev 361)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/StrateLayer.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -1,48 +0,0 @@
-/*
- * #%L
- * SAMMOA :: UI Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * 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 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-package fr.ulr.sammoa.ui.swing.flight.layer;
-
-import com.bbn.openmap.plugin.esri.EsriPlugIn;
-import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
-
-import java.io.File;
-import java.util.Properties;
-
-/**
- * Created: 12/06/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- */
-public class StrateLayer extends BaseReferentialLayer {
-
- public StrateLayer(File shapeFile, FlightUIModel model) {
- super("Strates", shapeFile, model);
- }
-
- @Override
- protected void onInitProperties(Properties properties) {
- properties.put(EsriPlugIn.SHAPE_DBF_LINECOLOR, "ff000000");
- }
-}
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/TransectLayer.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/TransectLayer.java 2012-08-07 15:49:18 UTC (rev 361)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/TransectLayer.java 2012-08-07 15:49:43 UTC (rev 362)
@@ -24,7 +24,9 @@
*/
package fr.ulr.sammoa.ui.swing.flight.layer;
+import com.bbn.openmap.dataAccess.shape.EsriGraphicList;
import com.bbn.openmap.omGraphics.OMGraphic;
+import com.bbn.openmap.plugin.PlugInLayer;
import com.bbn.openmap.plugin.esri.EsriPlugIn;
import fr.ulr.sammoa.application.flightController.FlightState;
import fr.ulr.sammoa.persistence.Route;
@@ -37,26 +39,26 @@
import java.awt.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.io.File;
-import java.util.Properties;
/**
* Created: 12/06/12
*
* @author fdesbois <desbois(a)codelutin.com>
*/
-public class TransectLayer extends BaseReferentialLayer implements PropertyChangeListener {
-
- public TransectLayer(File shapeFile,
- FlightUIModel model) {
+public class TransectLayer extends PlugInLayer implements PropertyChangeListener {
- super("Transects", shapeFile, model);
- for (TransectModel transect : model.getTransects()) {
+ protected FlightUIModel model;
+
+ public void init(FlightUIModel model) {
+
+ this.model = model;
+
+ for (TransectModel transect : getModel().getTransects()) {
transect.addPropertyChangeListener(this);
}
- model.addPropertyChangeListener(FlightUIModel.PROPERTY_FLIGHT_STATE, this);
- model.addPropertyChangeListener(FlightUIModel.PROPERTY_CURRENT_ROUTE, this);
- model.addPropertyChangeListener(FlightUIModel.PROPERTY_NEXT_TRANSECT, this);
+ getModel().addPropertyChangeListener(FlightUIModel.PROPERTY_FLIGHT_STATE, this);
+ getModel().addPropertyChangeListener(FlightUIModel.PROPERTY_CURRENT_ROUTE, this);
+ getModel().addPropertyChangeListener(FlightUIModel.PROPERTY_NEXT_TRANSECT, this);
// Visibility
ensureVisible();
@@ -74,12 +76,18 @@
}
}
- @Override
- protected void onInitProperties(Properties properties) {
- properties.put(EsriPlugIn.SHAPE_DBF_LINECOLOR, "6600ff");
- properties.put(EsriPlugIn.SHAPE_DBF_SELECTCOLOR, "ff7e00");
+ protected EsriGraphicList getEsriGraphicList() {
+ return getEsriPlugin().getEsriGraphicList();
}
+ protected EsriPlugIn getEsriPlugin() {
+ return (EsriPlugIn) getPlugIn();
+ }
+
+ protected FlightUIModel getModel() {
+ return model;
+ }
+
@Override
public void propertyChange(PropertyChangeEvent evt) {
@@ -94,7 +102,7 @@
if (graphicIndex != null) {
- OMGraphic graphic = getList().get(graphicIndex);
+ OMGraphic graphic = getEsriGraphicList().get(graphicIndex);
checkVisible(transect, getModel().getFlightState(), graphic);
@@ -110,7 +118,7 @@
if (graphicIndex != null) {
- OMGraphic graphic = getList().get(graphicIndex);
+ OMGraphic graphic = getEsriGraphicList().get(graphicIndex);
boolean visible = checkVisible(transect, getModel().getFlightState(), graphic);
@@ -138,7 +146,7 @@
if (graphicIndex != null) {
- OMGraphic graphic = getList().get(graphicIndex);
+ OMGraphic graphic = getEsriGraphicList().get(graphicIndex);
boolean value = (Boolean) evt.getNewValue();
graphic.setMatted(value);
@@ -202,7 +210,7 @@
if (graphicIndex != null) {
- OMGraphic graphic = getList().get(graphicIndex);
+ OMGraphic graphic = getEsriGraphicList().get(graphicIndex);
if (colorChanged != null) {
graphic.setLinePaint(colorChanged);
@@ -222,7 +230,7 @@
if (graphicIndex != null) {
- OMGraphic graphic = getList().get(graphicIndex);
+ OMGraphic graphic = getEsriGraphicList().get(graphicIndex);
checkVisible(transect, getModel().getFlightState(), graphic);
graphic.regenerate(getProjection());
1
0
07 Aug '12
Author: fdesbois
Date: 2012-08-07 17:49:18 +0200 (Tue, 07 Aug 2012)
New Revision: 361
Url: http://forge.codelutin.com/repositories/revision/sammoa/361
Log:
refs #1193 : move FlightController in proper package
Added:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightController.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerDefault.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerUpdateListener.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightState.java
Removed:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightController.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightControllerDefault.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightControllerUpdateListener.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightState.java
Modified:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/BaseHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaUIContext.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/AddAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/BeginAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/EndAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/NextAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ObservationAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/SammoaAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/StartAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/StopAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/campaign/CampaignUI.jaxx
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBar.jaxx
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBarHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUI.jaxx
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIModel.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/TransectLayer.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUI.jaxx
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/EffortPanelHandler.java
Deleted: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightController.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightController.java 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightController.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -1,285 +0,0 @@
-package fr.ulr.sammoa.application;
-/*
- * #%L
- * SAMMOA :: Application
- * $Id:$
- * $HeadURL:$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * 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 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ulr.sammoa.application.device.DeviceTechnicalException;
-import fr.ulr.sammoa.application.device.audio.AudioRecorder;
-import fr.ulr.sammoa.application.device.audio.AudioRecorderDefault;
-import fr.ulr.sammoa.application.device.gps.GpsConfig;
-import fr.ulr.sammoa.application.device.gps.GpsHandler;
-import fr.ulr.sammoa.persistence.GeoPoint;
-import fr.ulr.sammoa.persistence.Observation;
-import fr.ulr.sammoa.persistence.ObservationStatus;
-import fr.ulr.sammoa.persistence.Position;
-import fr.ulr.sammoa.persistence.Route;
-import fr.ulr.sammoa.persistence.RouteType;
-import fr.ulr.sammoa.persistence.TransectFlight;
-
-/**
- * The FlightController is the main service used to do all actions during a
- * flight. It is synchronized with the audio and GPS devices. It can be
- * initialized with a flight that already started, the actions allowed depends on
- * flight state.
- * <p/>
- * Created: 12/07/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- * @see FlightState
- */
-public interface FlightController {
-
- /**
- * @return the {@link FlightState}
- */
- FlightState getState();
-
- /**
- * @return the {@link AudioRecorderDefault} used to save audio files
- */
- AudioRecorder getAudioRecorder();
-
- /**
- * @return the {@link GpsHandler} used to retrieve GPS {@link GeoPoint} and
- * save them.
- */
- GpsHandler getGpsHandler();
-
- /**
- * @param config GpsConfig to initialize the Gps
- * @exception fr.ulr.sammoa.application.device.DeviceTechnicalException if the gps device can't be opened properly
- */
- void openGpsDevice(GpsConfig config) throws DeviceTechnicalException;
-
- /**
- * @exception DeviceTechnicalException if the audio device can't be opened properly
- */
- void openAudioDevice() throws DeviceTechnicalException;
-
- /**
- * @return The current {@link Route}
- */
- Route getCurrentRoute();
-
- /**
- * @return The next {@link TransectFlight}
- */
- TransectFlight getNextTransect();
-
- /**
- * Initialize all data of FlightController depends on the current flight state.
- * If the flight is running ({@link #isRunning()}), the devices will be started and
- * recording if necessary.
- * <p/>
- * You must call init method to ensure the {@link FlightState}.
- */
- void init();
-
- /**
- * Start operation. This will set the {@code beginDate} of the flight, then
- * a new {@link RouteType#TRANSIT} route is created. The state is now
- * {@link FlightState#OFF_EFFORT}.
- * <p/>
- * This operation is called when the plane take off, for the moment no
- * observation is done and the audio is not recording. The GPS is enabled
- * and will send data to display the plane tracking.
- * <p/>
- * After a start(), you can call :
- * <ul>
- * <li>{@link #begin()}</li>
- * <li>{@link #observation(Position)}</li>
- * <li>{@link #stop()}</li>
- * </ul>
- */
- void start();
-
- /**
- * Select a {@code nextTransect} to use for the next {@link RouteType#LEG}
- * when {@link #begin()} method is called.
- *
- * @param nextTransect the TransectFlight to use as next one
- */
- void setNextTransect(TransectFlight nextTransect);
-
- /**
- * Begin operation. A new {@link RouteType#LEG} is created based on GPS
- * current date and next transect that becomes the current one. The state
- * is now {@link FlightState#ON_EFFORT}.
- * <p/>
- * This operation is called when the plane arrives on a transect and observation
- * need to begin. Conditions could be set on the currentRoute (TRANSIT) and
- * will be copied on the new LEG. This operation is also called when a
- * CIRCLE_BACK is finished to resume effort on the current transect.
- * <p/>
- * After a begin(), you can call :
- * <ul>
- * <li>{@link #add()}</li>
- * <li>{@link #circleBack(Observation)}</li>
- * <li>{@link #next()}</li>
- * <li>{@link #observation(Position)}</li>
- * <li>{@link #end()}</li>
- * <li>{@link #stop()}</li>
- * </ul>
- */
- void begin();
-
- /**
- * Circle Back operation. A new {@link RouteType#CIRCLE_BACK} is created
- * based on GPS current date and attached to the {@code observation}. The
- * next transect will be the current one to allow begin() to not change the
- * transect. The state is now {@link FlightState#OFF_EFFORT}.
- * <p/>
- * This operation is called when an observation need to be checked again,
- * the plane will do a circle back. In this case, we are not on effort
- * anymore, but we can continue creating observations with the appropriate
- * status. The {@code observation} is marked as {@link ObservationStatus#CIRCLE_BACK}.
- * After the circle back, we use {@link #begin()} operation to continue effort
- * with a new LEG.
- * <p/>
- * After a circleBack(), you can call :
- * <ul>
- * <li>circleBack(Observation)</li>
- * <li>{@link #begin()}</li>
- * <li>{@link #observation(Position)}</li>
- * <li>{@link #stop()}</li>
- * </ul>
- *
- * @param observation The observation cause of the circle back
- * @see ObservationStatus
- */
- void circleBack(Observation observation);
-
- /**
- * Add operation. A new {@link RouteType#LEG} is created based on GPS current
- * date and current transect. The next transect and state doesn't change.
- * <p/>
- * This operation is called when the observation conditions has changed,
- * to mark this, a LEG is created with a GPS point and a new audio file. *
- * <p/>
- * After a add(), you can call :
- * <ul>
- * <li>add()</li>
- * <li>{@link #circleBack(Observation)}</li>
- * <li>{@link #next()}</li>
- * <li>{@link #observation(Position)}</li>
- * <li>{@link #end()}</li>
- * <li>{@link #stop()}</li>
- * </ul>
- */
- void add();
-
- /**
- * Next operation. It's a shortcut to end the previous effort and begin the
- * next one on the next transect. This will call {@link #end()} if necessary
- * and then {@link #begin()}.
- * <p/>
- * After a next(), you can call :
- * <ul>
- * <li>add()</li>
- * <li>{@link #circleBack(Observation)}</li>
- * <li>{@link #next()}</li>
- * <li>{@link #observation(Position)}</li>
- * <li>{@link #end()}</li>
- * <li>{@link #stop()}</li>
- * </ul>
- */
- void next();
-
- /**
- * Observation operation. It's the creation of an observation for the
- * given {@code position}. The observer will be retrieved from the
- * current route and the time is synchronized with the GPS or with the
- * system if not responding.
- *
- * @param position Position of the observer that make the observation
- */
- void observation(Position position);
-
- /**
- * End operation. This will create a new {@link RouteType#TRANSIT} route and
- * put the next transect depends on the plane list. The audio is still
- * recording for a few minutes and the state becomes {@link FlightState#OFF_EFFORT}
- * <p/>
- * This operation is called when an effort/transect is finished.
- * <p/>
- * After a end(), you can call :
- * <ul>
- * <li>{@link #begin()}</li>
- * <li>{@link #observation(Position)}</li>
- * <li>{@link #stop()}</li>
- * </ul>
- */
- void end();
-
- /**
- * Stop operation. This will stop the flight (by creating the end date) and
- * stop all devices (GPS and Audio). Current route and next transect are
- * reset (set to null). The state becomes {@link FlightState#ENDED}
- * <p/>
- * This operation is called when the plane is landing.
- * <p/>
- * You can't do anything after a stop.
- */
- void stop();
-
- /**
- * Close operation. This is used to close properly the controller even if
- * the flight is not finished.
- */
- void close();
-
- /**
- * @return true if {@link FlightState#WAITING}
- */
- boolean isWaiting();
-
- /**
- * @return true if {@link FlightState#ENDED}
- */
- boolean isEnded();
-
- /**
- * @return true if {@link FlightState#ON_EFFORT}
- */
- boolean isOnEffort();
-
- /**
- * @return true if {@link FlightState#OFF_EFFORT}
- */
- boolean isOffEffort();
-
- /**
- * @return true if {@link FlightState#OFF_EFFORT} or {@link FlightState#ON_EFFORT}
- */
- boolean isRunning();
-
- /**
- * @param listener FlightControllerUpdateListener to add
- */
- void addListener(FlightControllerUpdateListener listener);
-
- /**
- * @param listener FlightControllerUpdateListener to remove
- */
- void removeListener(FlightControllerUpdateListener listener);
-}
Deleted: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightControllerDefault.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightControllerDefault.java 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightControllerDefault.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -1,879 +0,0 @@
-/*
- * #%L
- * SAMMOA :: Application
- * *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * 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 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-package fr.ulr.sammoa.application;
-
-import com.google.common.base.Preconditions;
-import com.google.common.base.Supplier;
-import com.google.common.base.Throwables;
-import com.google.common.collect.Sets;
-import fr.ulr.sammoa.application.device.DeviceManager;
-import fr.ulr.sammoa.application.device.DeviceStateListener;
-import fr.ulr.sammoa.application.device.DeviceTechnicalException;
-import fr.ulr.sammoa.application.device.audio.AudioRecorder;
-import fr.ulr.sammoa.application.device.audio.AudioRecorderDefault;
-import fr.ulr.sammoa.application.device.gps.GpsConfig;
-import fr.ulr.sammoa.application.device.gps.GpsHandler;
-import fr.ulr.sammoa.application.device.gps.GpsLocationEvent;
-import fr.ulr.sammoa.application.device.gps.GpsLocationListener;
-import fr.ulr.sammoa.persistence.Flight;
-import fr.ulr.sammoa.persistence.FlightDAO;
-import fr.ulr.sammoa.persistence.GeoPoint;
-import fr.ulr.sammoa.persistence.GeoPointDAO;
-import fr.ulr.sammoa.persistence.Observation;
-import fr.ulr.sammoa.persistence.ObservationDAO;
-import fr.ulr.sammoa.persistence.ObservationStatus;
-import fr.ulr.sammoa.persistence.ObserverPosition;
-import fr.ulr.sammoa.persistence.Position;
-import fr.ulr.sammoa.persistence.Route;
-import fr.ulr.sammoa.persistence.RouteType;
-import fr.ulr.sammoa.persistence.SammoaDAOHelper;
-import fr.ulr.sammoa.persistence.SammoaPersistence;
-import fr.ulr.sammoa.persistence.TransectFlight;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaRuntimeException;
-import org.nuiton.util.TimeLog;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Date;
-import java.util.Set;
-
-/**
- * Created: 11/06/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- */
-public class FlightControllerDefault implements GpsLocationListener, FlightController {
-
- private static final Logger logger = LoggerFactory.getLogger(FlightControllerDefault.class);
-
- private static final TimeLog timeLog = new TimeLog(FlightControllerDefault.class, 500, 1000);
-
- protected SammoaContext context;
-
- protected SammoaPersistence persistence;
-
- protected FlightService service;
-
- protected AudioRecorder audioRecorder;
-
- protected GpsHandler gpsHandler;
-
- protected boolean initialized;
-
- protected FlightState state;
-
- protected Flight flight;
-
- protected Route currentRoute;
-
- protected TransectFlight nextTransect;
-
- protected TransectFlight lastTransect;
-
- protected Set<FlightControllerUpdateListener> listeners;
-
- public FlightControllerDefault(SammoaContext context,
- Flight flight) {
-
- this.context = context;
- this.flight = flight;
-
- this.persistence = context.getPersistence();
- this.service = context.getFlightService();
-
- this.currentRoute = service.getLastRoute(flight);
- this.lastTransect = service.getLastTransectDone(flight);
- this.listeners = Sets.newHashSet();
- }
-
- @Override
- public void addListener(FlightControllerUpdateListener listener) {
- listeners.add(listener);
- }
-
- @Override
- public void removeListener(FlightControllerUpdateListener listener) {
- listeners.remove(listener);
- }
-
- @Override
- public FlightState getState() {
- return state;
- }
-
- @Override
- public AudioRecorder getAudioRecorder() {
- return audioRecorder;
- }
-
- @Override
- public Route getCurrentRoute() {
- return currentRoute;
- }
-
- @Override
- public TransectFlight getNextTransect() {
- return nextTransect;
- }
-
- @Override
- public GpsHandler getGpsHandler() {
- return gpsHandler;
- }
-
- @Override
- public void openGpsDevice(final GpsConfig config) throws DeviceTechnicalException {
-
- Set<GpsLocationListener> locationListeners;
- if (gpsHandler != null) {
-
- // Remove all existing listeners and keep them for the new instance
- locationListeners = Sets.newHashSet(gpsHandler.getGpsLocationListeners());
- for (GpsLocationListener listener : locationListeners) {
- gpsHandler.removeGpsLocationListener(listener);
- }
-
- } else {
- locationListeners = Sets.newHashSet();
- }
-
- gpsHandler = newDeviceManager(gpsHandler, new Supplier<GpsHandler>() {
-
- @Override
- public GpsHandler get() {
-
- // Instanciate the GpsHandler
- Class<? extends GpsHandler> gpsHandlerClass = config.getGpsHandlerClass();
- try {
-
- Constructor<? extends GpsHandler> constructor =
- gpsHandlerClass.getConstructor(GpsConfig.class);
-
- GpsHandler result = constructor.newInstance(config);
- result.addGpsLocationListener(FlightControllerDefault.this);
- return result;
-
- } catch (InstantiationException e) {
- throw Throwables.propagate(e);
- } catch (IllegalAccessException e) {
- throw Throwables.propagate(e);
- } catch (NoSuchMethodException e) {
- throw Throwables.propagate(e);
- } catch (InvocationTargetException e) {
- throw Throwables.propagate(e);
- }
- }
- });
-
- for (GpsLocationListener listener : locationListeners) {
- gpsHandler.addGpsLocationListener(listener);
- }
-
- if (initialized && isRunning()) {
- gpsHandler.start();
- } else {
- gpsHandler.open();
- }
- }
-
- @Override
- public void openAudioDevice() throws DeviceTechnicalException {
-
- audioRecorder = newDeviceManager(audioRecorder, new Supplier<AudioRecorder>() {
-
- @Override
- public AudioRecorder get() {
- return new AudioRecorderDefault();
- }
- });
-
- if (initialized && isRunning()) {
- audioRecorder.start();
- } else {
- audioRecorder.open();
- }
- }
-
- @Override
- public boolean isWaiting() {
- return state == FlightState.WAITING;
- }
-
- @Override
- public boolean isEnded() {
- return state == FlightState.ENDED;
- }
-
- @Override
- public boolean isOnEffort() {
- return state == FlightState.ON_EFFORT;
- }
-
- @Override
- public boolean isOffEffort() {
- return state == FlightState.OFF_EFFORT;
- }
-
- @Override
- public boolean isRunning() {
- return isOnEffort() || isOffEffort();
- }
-
- @Override
- public void init() {
-
- Preconditions.checkState(gpsHandler != null,
- "The GpsHandler must be created using #openGpsDevice");
-
- Preconditions.checkState(audioRecorder != null,
- "The AudioRecorder must be created using #openAudioDevice");
-
- if (initialized) {
- if (logger.isWarnEnabled()) {
- logger.warn("The FlightController is already initialized");
- }
- return;
- }
-
- if (logger.isInfoEnabled()) {
- logger.info("Initialize the FlightController for flight " + flight.getFlightNumber());
- }
-
- initialized = true;
-
- // Note that a flight can't finished by a leg, so effort not null
- // implies that the flight is started and not ended
- if (currentRoute != null
- && currentRoute.getRouteType() == RouteType.LEG) {
-
- state = FlightState.ON_EFFORT;
-
- } else if (currentRoute != null
- && flight.getBeginDate() != null
- && flight.getEndDate() == null) {
-
- state = FlightState.OFF_EFFORT;
-
- } else if (flight.getEndDate() != null) {
-
- state = FlightState.ENDED;
-
- } else {
- state = FlightState.WAITING;
- }
-
- if (isRunning()) {
-
- gpsHandler.start();
-
- audioRecorder.start();
-
- // Selection of the nextTransect, keep the last one for circleBack
- if (currentRoute.getRouteType() == RouteType.CIRCLE_BACK) {
- nextTransect = lastTransect;
-
- } else {
- nextTransect = flight.getNextTransectFlightFrom(lastTransect);
- }
-
- // Restart recording audio if onEffort or circleBack
- if (state == FlightState.ON_EFFORT
- || currentRoute.getRouteType() == RouteType.CIRCLE_BACK) {
-
- saveAudio(0);
- }
- }
- }
-
- @Override
- public void start() {
-
- long startTime = TimeLog.getTime();
-
- Preconditions.checkState(initialized,
- "The controller must be initialized before calling any action");
-
- Preconditions.checkState(
- isWaiting(), "You can call start() only if flight is waiting (not started, not ended)");
-
- gpsHandler.start();
-
- audioRecorder.start();
-
- TopiaContext transaction = persistence.beginTransaction();
- try {
-
- Date currentDate = saveGPS(transaction, gpsHandler.getCurrentLocation(), flight);
-
- setFlightBeginDate(transaction, flight, currentDate);
-
- if (logger.isInfoEnabled()) {
- logger.info("Start Flight {} at {}", flight.getFlightNumber(), flight.getBeginDate());
- }
-
- // Start with TRANSIT route
- if (logger.isInfoEnabled()) {
- logger.info(String.format("Create TRANSIT [START] at %1$tH:%1$tM:%1$tS", currentDate));
- }
- currentRoute = service.createTransit(transaction, flight, currentDate, currentRoute);
-
- // Auto selection of the next transect starting from the begining
- nextTransect = flight.getNextTransectFlightFrom(null);
-
- state = FlightState.OFF_EFFORT;
-
- transaction.commitTransaction();
-
- startTime = timeLog.log(startTime, "start()", "Commited");
-
- // Fire events after commit
- fireRouteAdded(currentRoute);
- fireNextTransectChanged(nextTransect);
- fireStateChanged(state);
-
- timeLog.log(startTime, "start()", "Fired");
-
- } catch (TopiaException e) {
- throw new TopiaRuntimeException(e);
-
- } finally {
- persistence.endTransaction(transaction);
- }
- }
-
- @Override
- public void setNextTransect(TransectFlight nextTransect) {
-
- long startTime = TimeLog.getTime();
-
- Preconditions.checkState(initialized,
- "The controller must be initialized before calling any action");
-
- Preconditions.checkState(
- nextTransect == null || !nextTransect.isDeleted(), "You can't use a deleted transect as next value");
-
- this.nextTransect = nextTransect;
-
- // Fire transect changed
- fireNextTransectChanged(nextTransect);
-
- timeLog.log(startTime, "setNextTransect()", "Fired");
- }
-
- @Override
- public void begin() {
-
- long startTime = TimeLog.getTime();
-
- Preconditions.checkState(initialized,
- "The controller must be initialized before calling any action");
-
- Preconditions.checkState(
- isOffEffort(), "You can call begin() only if flight is running (started, not ended, not on effort)");
-
- Preconditions.checkState(
- nextTransect != null, "You can't call begin() if no transect is selected. " +
- "Call setNextTransect() method first");
-
- TopiaContext transaction = persistence.beginTransaction();
- try {
-
- Date currentDate = saveGPS(transaction, gpsHandler.getCurrentLocation(), flight);
-
- // The next transect becomes the last one (or current in this case)
- lastTransect = nextTransect;
-
- // Create new LEG route
- if (logger.isInfoEnabled()) {
- logger.info(String.format("Create LEG [BEGIN] at %1$tH:%1$tM:%1$tS", currentDate));
- }
- currentRoute = service.createLeg(transaction, flight, currentDate, currentRoute, lastTransect);
-
- // automatic selection of the next transect
- nextTransect = flight.getNextTransectFlightFrom(lastTransect);
-
- state = FlightState.ON_EFFORT;
-
- // Record the audio for the current LEG
- saveAudio(3);
-
- transaction.commitTransaction();
-
- startTime = timeLog.log(startTime, "begin()", "Commited");
-
- // Fire events after commit
- fireRouteAdded(currentRoute);
- fireNextTransectChanged(nextTransect);
- fireStateChanged(state);
-
- timeLog.log(startTime, "begin()", "Fired");
-
- } catch (TopiaException e) {
- throw new TopiaRuntimeException(e);
-
- } finally {
- persistence.endTransaction(transaction);
- }
- }
-
- @Override
- public void circleBack(Observation observation) {
-
- long startTime = TimeLog.getTime();
-
- Preconditions.checkState(initialized,
- "The controller must be initialized before calling any action");
-
- Preconditions.checkState(
- currentRoute != null
- && currentRoute.getRouteType() != RouteType.TRANSIT,
- "You can't call circleBack() during TRANSIT");
-
-
- TopiaContext transaction = persistence.beginTransaction();
- try {
-
- Date currentDate = saveGPS(transaction, gpsHandler.getCurrentLocation(), flight);
-
- setObservationStatus(transaction, observation, ObservationStatus.CIRCLE_BACK);
-
- // Create CIRCLE_BACK
- if (logger.isInfoEnabled()) {
- logger.info(String.format("Create CIRCLE_BACK at %1$tH:%1$tM:%1$tS", currentDate));
- }
-
- currentRoute = service.createCircleBack(transaction, flight, currentDate, currentRoute, observation);
-
- nextTransect = lastTransect;
-
- state = FlightState.OFF_EFFORT;
-
- // Record the audio of the LEG in an other file
- saveAudio(3);
-
- transaction.commitTransaction();
-
- startTime = timeLog.log(startTime, "circleBack()", "Commited");
-
- // Fire events after commit
- fireRouteAdded(currentRoute);
- fireNextTransectChanged(nextTransect);
- fireStateChanged(state);
-
- timeLog.log(startTime, "circleBack()", "Fired");
-
- } catch (TopiaException e) {
- throw new TopiaRuntimeException(e);
-
- } finally {
- persistence.endTransaction(transaction);
- }
- }
-
- @Override
- public void add() {
-
- long startTime = TimeLog.getTime();
-
- Preconditions.checkState(initialized,
- "The controller must be initialized before calling any action");
-
- Preconditions.checkState(
- isOnEffort(), "You can call add() only if flight is on effort (started, not ended, on effort)");
-
- TopiaContext transaction = persistence.beginTransaction();
- try {
- Date currentDate = saveGPS(transaction, gpsHandler.getCurrentLocation(), flight);
-
- // Create new LEG route
- if (logger.isInfoEnabled()) {
- logger.info(String.format("Create LEG [ADD] at %1$tH:%1$tM:%1$tS", currentDate));
- }
- currentRoute = service.createLeg(transaction, flight, currentDate, currentRoute, lastTransect);
-
- // Record the audio of the LEG in an other file
- saveAudio(3);
-
- transaction.commitTransaction();
-
- startTime = timeLog.log(startTime, "add()", "Commited");
-
- // Fire events after commit
- fireRouteAdded(currentRoute);
-
- timeLog.log(startTime, "add()", "Fired");
-
- } catch (TopiaException e) {
- throw new TopiaRuntimeException(e);
-
- } finally {
- persistence.endTransaction(transaction);
- }
- }
-
- @Override
- public void next() {
-
- long startTime = TimeLog.getTime();
-
- if (isOnEffort()) {
- doEndWithAudioDelay(3);
- }
-
- begin();
-
- timeLog.log(startTime, "next()");
- }
-
- @Override
- public void observation(Position position) {
-
- long startTime = TimeLog.getTime();
-
- Preconditions.checkState(initialized,
- "The controller must be initialized before calling any action");
-
- Preconditions.checkState(
- isRunning(), "You can call observation() only if flight is running (started, not ended)");
-
- TopiaContext transaction = persistence.beginTransaction();
- try {
-
- Date currentDate = saveGPS(transaction, gpsHandler.getCurrentLocation(), flight);
-
- ObserverPosition observer;
- if (currentRoute == null) {
-
- // problem we don't have any observerPosition
- observer = null;
-
- } else {
- observer = currentRoute.getObserverPositionByPosition(position);
- }
-
- if (logger.isInfoEnabled()) {
- logger.info(String.format("Create Observation %2$s at %1$tH:%1$tM:%1$tS (observer = %3$s)",
- currentDate,
- position,
- observer != null && observer.getObserver() != null
- ? observer.getObserver().getInitials() : "")
- );
- }
- Observation observation = service.createObservation(transaction, flight, currentDate, observer);
-
- transaction.commitTransaction();
-
- startTime = timeLog.log(startTime, "observation()", "Commited");
-
- for (FlightControllerUpdateListener listener : listeners) {
- listener.onObservationAdded(observation);
- }
-
- timeLog.log(startTime, "observation()", "Fired");
-
- } catch (TopiaException e) {
- throw new TopiaRuntimeException(e);
-
- } finally {
- persistence.endTransaction(transaction);
- }
- }
-
- @Override
- public void end() {
-
- long startTime = TimeLog.getTime();
-
- // Stop recording after 2 minutes (120 seconds)
- doEndWithAudioDelay(120);
-
- timeLog.log(startTime, "end()");
- }
-
- @Override
- public void stop() {
-
- long startTime = TimeLog.getTime();
-
- Preconditions.checkState(initialized,
- "The controller must be initialized before calling any action");
-
- Preconditions.checkState(
- isOffEffort(), "You can call stop() only if flight is running (started, not ended, not on effort)");
-
- TopiaContext transaction = persistence.beginTransaction();
- try {
- Date currentDate = saveGPS(transaction, gpsHandler.getCurrentLocation(), flight);
-
- if (logger.isInfoEnabled()) {
- logger.info(String.format("Stop flight %2$d at %1$tH:%1$tM:%1$tS",
- currentDate,
- flight.getFlightNumber())
- );
- }
- setFlightEndDate(transaction, flight, currentDate);
-
- // Stop audio
- getAudioRecorder().stop();
-
- // Stop gps
- getGpsHandler().stop();
-
- currentRoute = null;
-
- nextTransect = null;
-
- state = FlightState.ENDED;
-
- transaction.commitTransaction();
-
- startTime = timeLog.log(startTime, "stop()", "Commited");
-
- // Fire events after commit
- fireRouteAdded(currentRoute);
- fireNextTransectChanged(nextTransect);
- fireStateChanged(state);
-
- timeLog.log(startTime, "stop()", "Fired");
-
- } catch (TopiaException e) {
- throw new TopiaRuntimeException(e);
-
- } finally {
- persistence.endTransaction(transaction);
- }
- }
-
- @Override
- public void close() {
-
- audioRecorder.close();
- audioRecorder = null;
-
- gpsHandler.close();
- gpsHandler = null;
-
- persistence.stopAutoSaveListener();
- }
-
- protected void doEndWithAudioDelay(long audioDelay) {
-
- Preconditions.checkState(initialized,
- "The controller must be initialized before calling any action");
-
- Preconditions.checkState(
- isOnEffort(), "You can call end() only if flight is on effort (started, not ended, on effort)");
-
- TopiaContext transaction = persistence.beginTransaction();
- try {
- Date currentDate = saveGPS(transaction, gpsHandler.getCurrentLocation(), flight);
-
- // Create new TRANSIT route
- if (logger.isInfoEnabled()) {
- logger.info(String.format("Create TRANSIT [END] at %1$tH:%1$tM:%1$tS", currentDate));
- }
- currentRoute = service.createTransit(transaction, flight, currentDate, currentRoute);
-
- audioRecorder.stopRecord(audioDelay);
-
- state = FlightState.OFF_EFFORT;
-
- transaction.commitTransaction();
-
- // Fire events after commit
- fireRouteAdded(currentRoute);
- fireNextTransectChanged(nextTransect);
- fireStateChanged(state);
-
- } catch (TopiaException e) {
- throw new TopiaRuntimeException(e);
-
- } finally {
- persistence.endTransaction(transaction);
- }
- }
-
-// protected void setNextTransect(TransectFlight nextTransect, boolean fireEvents) {
-//
-// this.nextTransect = nextTransect;
-//
-// if (fireEvents) {
-// // Fire transect changed
-// for (FlightControllerUpdateListener listener : listeners) {
-// listener.onNextTransectChanged(nextTransect);
-// }
-// }
-// }
-//
-// protected void setNextTransectFrom(TransectFlight transect, boolean fireEvents) {
-//
-// TransectFlight nextTransect =
-// flight.getNextTransectFlightFrom(transect);
-//
-// setNextTransect(nextTransect, fireEvents);
-// }
-
- protected void setFlightBeginDate(TopiaContext transaction,
- Flight flight,
- Date beginDate)
- throws TopiaException {
-
- FlightDAO flightDAO = SammoaDAOHelper.getFlightDAO(transaction);
- flight.setBeginDate(beginDate);
- flightDAO.update(flight);
- }
-
- protected void setFlightEndDate(TopiaContext transaction,
- Flight flight,
- Date endDate)
- throws TopiaException {
-
- FlightDAO flightDAO = SammoaDAOHelper.getFlightDAO(transaction);
- flight.setEndDate(endDate);
- flightDAO.update(flight);
- }
-
- protected void setObservationStatus(TopiaContext transaction,
- Observation observation,
- ObservationStatus status)
- throws TopiaException {
-
- ObservationDAO observationDAO =
- SammoaDAOHelper.getObservationDAO(transaction);
- observation.setObservationStatus(status);
- observationDAO.update(observation);
- }
-
- protected void saveAudio(long delay) {
-
- String fileName = String.format(
- "%1$tF-%1$tH-%1$tM-%1$tS.%2$s.%3$s",
- currentRoute.getBeginTime(),
- currentRoute.getTopiaId(),
- getAudioRecorder().getOutputType().getExtension()
- );
-
- File audioDir = context.getConfig().getAudioDirectory();
-
- File audioFile = new File(audioDir, fileName);
-
- try {
- getAudioRecorder().record(audioFile, delay);
- } catch (IOException e) {
- throw Throwables.propagate(e);
- }
- }
-
- protected Date saveGPS(TopiaContext transaction,
- GeoPoint geoPoint,
- Flight flight)
- throws TopiaException {
-
- Date result;
- if (geoPoint == null) {
- result = new Date();
- if (logger.isWarnEnabled()) {
- logger.warn("No GPS point at {}", result);
- }
-
- } else {
-
- if (logger.isTraceEnabled()) {
- logger.trace("Create GPS Point : {}", geoPoint);
- }
-
- result = geoPoint.getRecordTime();
-
- GeoPointDAO dao = SammoaDAOHelper.getGeoPointDAO(transaction);
-
- geoPoint.setFlight(flight);
-
- dao.create(geoPoint);
- }
- return result;
- }
-
- protected void fireStateChanged(FlightState state) {
- for (FlightControllerUpdateListener listener : listeners) {
- listener.onStateChanged(state);
- }
- }
-
- protected void fireRouteAdded(Route route) {
- for (FlightControllerUpdateListener listener : listeners) {
- listener.onRouteAdded(route);
- }
- }
-
- protected void fireNextTransectChanged(TransectFlight nextTransect) {
- for (FlightControllerUpdateListener listener : listeners) {
- listener.onNextTransectChanged(nextTransect);
- }
- }
-
- protected <T extends DeviceManager> T newDeviceManager(T oldInstance, Supplier<T> supplier)
- throws DeviceTechnicalException {
-
- Set<DeviceStateListener> stateListeners;
- if (oldInstance != null) {
-
- // Remove all existing listeners and keep them for the new instance
- stateListeners = Sets.newHashSet(oldInstance.getDeviceStateListeners());
- for (DeviceStateListener listener : stateListeners) {
- oldInstance.removeDeviceStateListener(listener);
- }
-
- oldInstance.close();
-
- } else {
- stateListeners = Sets.newHashSet();
- }
-
- T result = supplier.get();
-
- // Attach all updateListener
- for (DeviceStateListener listener : stateListeners) {
- result.addDeviceStateListener(listener);
- }
-
- return result;
- }
-
- @Override
- public void locationChanged(GpsLocationEvent event) {
- GeoPoint newLocation = event.getNewValue();
- if (newLocation != null/* && newLocation.getTopiaId() == null*/) {
- newLocation.setFlight(flight);
- persistence.delayEntityCreation(newLocation);
- }
- }
-
-}
Deleted: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightControllerUpdateListener.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightControllerUpdateListener.java 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightControllerUpdateListener.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -1,69 +0,0 @@
-package fr.ulr.sammoa.application;
-/*
- * #%L
- * SAMMOA :: Application
- * $Id:$
- * $HeadURL:$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * 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 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ulr.sammoa.persistence.Observation;
-import fr.ulr.sammoa.persistence.Route;
-import fr.ulr.sammoa.persistence.TransectFlight;
-
-/**
- * Listener for all change of data in the {@link FlightController}
- *
- * Created: 12/07/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- * @see FlightController
- */
-public interface FlightControllerUpdateListener {
-
- /**
- * Fired when a new {@code route} has been created and added to the flight
- *
- * @param route The new route added
- */
- void onRouteAdded(Route route);
-
- /**
- * Fired when the next transect has been updated.
- *
- * @param nextTransect The next transect that will be used on
- * {@link FlightController#begin()} action
- */
- void onNextTransectChanged(TransectFlight nextTransect);
-
- /**
- * Fired when controller change the {@code state} of the flight after
- * each action.
- *
- * @param state The new state
- */
- void onStateChanged(FlightState state);
-
- /**
- * Fired when controller add a new observation
- *
- * @param observation The new observation
- */
- void onObservationAdded(Observation observation);
-}
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -506,10 +506,10 @@
return result;
}
- protected Observation createObservation(TopiaContext transaction,
- Flight flight,
- Date beginTime,
- ObserverPosition observer)
+ public Observation createObservation(TopiaContext transaction,
+ Flight flight,
+ Date beginTime,
+ ObserverPosition observer)
throws TopiaException {
Observation result;
@@ -525,22 +525,22 @@
return result;
}
-
- protected Route createTransit(TopiaContext transaction,
- Flight flight,
- Date beginTime,
- Route previousRoute)
+
+ public Route createTransit(TopiaContext transaction,
+ Flight flight,
+ Date beginTime,
+ Route previousRoute)
throws TopiaException {
Route result = createRoute(transaction, flight, beginTime, RouteType.TRANSIT, previousRoute, null);
return result;
}
- protected Route createLeg(TopiaContext transaction,
- Flight flight,
- Date beginTime,
- Route previousRoute,
- TransectFlight transectFlight)
+ public Route createLeg(TopiaContext transaction,
+ Flight flight,
+ Date beginTime,
+ Route previousRoute,
+ TransectFlight transectFlight)
throws TopiaException {
Preconditions.checkArgument(transectFlight != null, "You can't create a leg without any transect");
@@ -557,11 +557,11 @@
return result;
}
- protected Route createCircleBack(TopiaContext transaction,
- Flight flight,
- Date beginTime,
- Route previousRoute,
- Observation circleBackCause)
+ public Route createCircleBack(TopiaContext transaction,
+ Flight flight,
+ Date beginTime,
+ Route previousRoute,
+ Observation circleBackCause)
throws TopiaException {
Preconditions.checkArgument(circleBackCause != null, "You can't create a route without any observation cause");
Deleted: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightState.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightState.java 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightState.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -1,57 +0,0 @@
-/*
- * #%L
- * SAMMOA :: Application
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * 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 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-package fr.ulr.sammoa.application;
-
-/**
- * Created: 20/06/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- */
-public enum FlightState {
- /**
- * The WAITING state is when the flight is not started and not ended.
- * It appends when the flight is not really in used.
- */
- WAITING,
-
- /**
- * The OFF_EFFORT state is when the flight is started but not ended,
- * and also if the current route is not an effort.
- * It appends generally when the flight is in TRANSIT or CIRCLE_BACK.
- */
- OFF_EFFORT,
-
- /**
- * The ON_EFFORT state is when the flight is started, not ended but in
- * current effort. It appends when a LEG is currently in progress.
- */
- ON_EFFORT,
-
- /**
- * The ENDED state is when the flight is ended.
- * It appends when the current effort is finished and when no more route
- * need to be registered.
- */
- ENDED
-}
Copied: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightController.java (from rev 360, trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightController.java)
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightController.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightController.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -0,0 +1,285 @@
+package fr.ulr.sammoa.application.flightController;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ulr.sammoa.application.device.DeviceTechnicalException;
+import fr.ulr.sammoa.application.device.audio.AudioRecorder;
+import fr.ulr.sammoa.application.device.audio.AudioRecorderDefault;
+import fr.ulr.sammoa.application.device.gps.GpsConfig;
+import fr.ulr.sammoa.application.device.gps.GpsHandler;
+import fr.ulr.sammoa.persistence.GeoPoint;
+import fr.ulr.sammoa.persistence.Observation;
+import fr.ulr.sammoa.persistence.ObservationStatus;
+import fr.ulr.sammoa.persistence.Position;
+import fr.ulr.sammoa.persistence.Route;
+import fr.ulr.sammoa.persistence.RouteType;
+import fr.ulr.sammoa.persistence.TransectFlight;
+
+/**
+ * The FlightController is the main service used to do all actions during a
+ * flight. It is synchronized with the audio and GPS devices. It can be
+ * initialized with a flight that already started, the actions allowed depends on
+ * flight state.
+ * <p/>
+ * Created: 12/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ * @see FlightState
+ */
+public interface FlightController {
+
+ /**
+ * @return the {@link FlightState}
+ */
+ FlightState getState();
+
+ /**
+ * @return the {@link AudioRecorderDefault} used to save audio files
+ */
+ AudioRecorder getAudioRecorder();
+
+ /**
+ * @return the {@link GpsHandler} used to retrieve GPS {@link GeoPoint} and
+ * save them.
+ */
+ GpsHandler getGpsHandler();
+
+ /**
+ * @param config GpsConfig to initialize the Gps
+ * @exception fr.ulr.sammoa.application.device.DeviceTechnicalException if the gps device can't be opened properly
+ */
+ void openGpsDevice(GpsConfig config) throws DeviceTechnicalException;
+
+ /**
+ * @exception DeviceTechnicalException if the audio device can't be opened properly
+ */
+ void openAudioDevice() throws DeviceTechnicalException;
+
+ /**
+ * @return The current {@link Route}
+ */
+ Route getCurrentRoute();
+
+ /**
+ * @return The next {@link TransectFlight}
+ */
+ TransectFlight getNextTransect();
+
+ /**
+ * Initialize all data of FlightController depends on the current flight state.
+ * If the flight is running ({@link #isRunning()}), the devices will be started and
+ * recording if necessary.
+ * <p/>
+ * You must call init method to ensure the {@link FlightState}.
+ */
+ void init();
+
+ /**
+ * Start operation. This will set the {@code beginDate} of the flight, then
+ * a new {@link RouteType#TRANSIT} route is created. The state is now
+ * {@link FlightState#OFF_EFFORT}.
+ * <p/>
+ * This operation is called when the plane take off, for the moment no
+ * observation is done and the audio is not recording. The GPS is enabled
+ * and will send data to display the plane tracking.
+ * <p/>
+ * After a start(), you can call :
+ * <ul>
+ * <li>{@link #begin()}</li>
+ * <li>{@link #observation(Position)}</li>
+ * <li>{@link #stop()}</li>
+ * </ul>
+ */
+ void start();
+
+ /**
+ * Select a {@code nextTransect} to use for the next {@link RouteType#LEG}
+ * when {@link #begin()} method is called.
+ *
+ * @param nextTransect the TransectFlight to use as next one
+ */
+ void setNextTransect(TransectFlight nextTransect);
+
+ /**
+ * Begin operation. A new {@link RouteType#LEG} is created based on GPS
+ * current date and next transect that becomes the current one. The state
+ * is now {@link FlightState#ON_EFFORT}.
+ * <p/>
+ * This operation is called when the plane arrives on a transect and observation
+ * need to begin. Conditions could be set on the currentRoute (TRANSIT) and
+ * will be copied on the new LEG. This operation is also called when a
+ * CIRCLE_BACK is finished to resume effort on the current transect.
+ * <p/>
+ * After a begin(), you can call :
+ * <ul>
+ * <li>{@link #add()}</li>
+ * <li>{@link #circleBack(Observation)}</li>
+ * <li>{@link #next()}</li>
+ * <li>{@link #observation(Position)}</li>
+ * <li>{@link #end()}</li>
+ * <li>{@link #stop()}</li>
+ * </ul>
+ */
+ void begin();
+
+ /**
+ * Circle Back operation. A new {@link RouteType#CIRCLE_BACK} is created
+ * based on GPS current date and attached to the {@code observation}. The
+ * next transect will be the current one to allow begin() to not change the
+ * transect. The state is now {@link FlightState#OFF_EFFORT}.
+ * <p/>
+ * This operation is called when an observation need to be checked again,
+ * the plane will do a circle back. In this case, we are not on effort
+ * anymore, but we can continue creating observations with the appropriate
+ * status. The {@code observation} is marked as {@link ObservationStatus#CIRCLE_BACK}.
+ * After the circle back, we use {@link #begin()} operation to continue effort
+ * with a new LEG.
+ * <p/>
+ * After a circleBack(), you can call :
+ * <ul>
+ * <li>circleBack(Observation)</li>
+ * <li>{@link #begin()}</li>
+ * <li>{@link #observation(Position)}</li>
+ * <li>{@link #stop()}</li>
+ * </ul>
+ *
+ * @param observation The observation cause of the circle back
+ * @see ObservationStatus
+ */
+ void circleBack(Observation observation);
+
+ /**
+ * Add operation. A new {@link RouteType#LEG} is created based on GPS current
+ * date and current transect. The next transect and state doesn't change.
+ * <p/>
+ * This operation is called when the observation conditions has changed,
+ * to mark this, a LEG is created with a GPS point and a new audio file. *
+ * <p/>
+ * After a add(), you can call :
+ * <ul>
+ * <li>add()</li>
+ * <li>{@link #circleBack(Observation)}</li>
+ * <li>{@link #next()}</li>
+ * <li>{@link #observation(Position)}</li>
+ * <li>{@link #end()}</li>
+ * <li>{@link #stop()}</li>
+ * </ul>
+ */
+ void add();
+
+ /**
+ * Next operation. It's a shortcut to end the previous effort and begin the
+ * next one on the next transect. This will call {@link #end()} if necessary
+ * and then {@link #begin()}.
+ * <p/>
+ * After a next(), you can call :
+ * <ul>
+ * <li>add()</li>
+ * <li>{@link #circleBack(Observation)}</li>
+ * <li>{@link #next()}</li>
+ * <li>{@link #observation(Position)}</li>
+ * <li>{@link #end()}</li>
+ * <li>{@link #stop()}</li>
+ * </ul>
+ */
+ void next();
+
+ /**
+ * Observation operation. It's the creation of an observation for the
+ * given {@code position}. The observer will be retrieved from the
+ * current route and the time is synchronized with the GPS or with the
+ * system if not responding.
+ *
+ * @param position Position of the observer that make the observation
+ */
+ void observation(Position position);
+
+ /**
+ * End operation. This will create a new {@link RouteType#TRANSIT} route and
+ * put the next transect depends on the plane list. The audio is still
+ * recording for a few minutes and the state becomes {@link FlightState#OFF_EFFORT}
+ * <p/>
+ * This operation is called when an effort/transect is finished.
+ * <p/>
+ * After a end(), you can call :
+ * <ul>
+ * <li>{@link #begin()}</li>
+ * <li>{@link #observation(Position)}</li>
+ * <li>{@link #stop()}</li>
+ * </ul>
+ */
+ void end();
+
+ /**
+ * Stop operation. This will stop the flight (by creating the end date) and
+ * stop all devices (GPS and Audio). Current route and next transect are
+ * reset (set to null). The state becomes {@link FlightState#ENDED}
+ * <p/>
+ * This operation is called when the plane is landing.
+ * <p/>
+ * You can't do anything after a stop.
+ */
+ void stop();
+
+ /**
+ * Close operation. This is used to close properly the controller even if
+ * the flight is not finished.
+ */
+ void close();
+
+ /**
+ * @return true if {@link FlightState#WAITING}
+ */
+ boolean isWaiting();
+
+ /**
+ * @return true if {@link FlightState#ENDED}
+ */
+ boolean isEnded();
+
+ /**
+ * @return true if {@link FlightState#ON_EFFORT}
+ */
+ boolean isOnEffort();
+
+ /**
+ * @return true if {@link FlightState#OFF_EFFORT}
+ */
+ boolean isOffEffort();
+
+ /**
+ * @return true if {@link FlightState#OFF_EFFORT} or {@link FlightState#ON_EFFORT}
+ */
+ boolean isRunning();
+
+ /**
+ * @param listener FlightControllerUpdateListener to add
+ */
+ void addListener(FlightControllerUpdateListener listener);
+
+ /**
+ * @param listener FlightControllerUpdateListener to remove
+ */
+ void removeListener(FlightControllerUpdateListener listener);
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightController.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerDefault.java (from rev 360, trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightControllerDefault.java)
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerDefault.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerDefault.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -0,0 +1,881 @@
+/*
+ * #%L
+ * SAMMOA :: Application
+ * *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+package fr.ulr.sammoa.application.flightController;
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Supplier;
+import com.google.common.base.Throwables;
+import com.google.common.collect.Sets;
+import fr.ulr.sammoa.application.FlightService;
+import fr.ulr.sammoa.application.SammoaContext;
+import fr.ulr.sammoa.application.device.DeviceManager;
+import fr.ulr.sammoa.application.device.DeviceStateListener;
+import fr.ulr.sammoa.application.device.DeviceTechnicalException;
+import fr.ulr.sammoa.application.device.audio.AudioRecorder;
+import fr.ulr.sammoa.application.device.audio.AudioRecorderDefault;
+import fr.ulr.sammoa.application.device.gps.GpsConfig;
+import fr.ulr.sammoa.application.device.gps.GpsHandler;
+import fr.ulr.sammoa.application.device.gps.GpsLocationEvent;
+import fr.ulr.sammoa.application.device.gps.GpsLocationListener;
+import fr.ulr.sammoa.persistence.Flight;
+import fr.ulr.sammoa.persistence.FlightDAO;
+import fr.ulr.sammoa.persistence.GeoPoint;
+import fr.ulr.sammoa.persistence.GeoPointDAO;
+import fr.ulr.sammoa.persistence.Observation;
+import fr.ulr.sammoa.persistence.ObservationDAO;
+import fr.ulr.sammoa.persistence.ObservationStatus;
+import fr.ulr.sammoa.persistence.ObserverPosition;
+import fr.ulr.sammoa.persistence.Position;
+import fr.ulr.sammoa.persistence.Route;
+import fr.ulr.sammoa.persistence.RouteType;
+import fr.ulr.sammoa.persistence.SammoaDAOHelper;
+import fr.ulr.sammoa.persistence.SammoaPersistence;
+import fr.ulr.sammoa.persistence.TransectFlight;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaRuntimeException;
+import org.nuiton.util.TimeLog;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Date;
+import java.util.Set;
+
+/**
+ * Created: 11/06/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class FlightControllerDefault implements GpsLocationListener, FlightController {
+
+ private static final Logger logger = LoggerFactory.getLogger(FlightControllerDefault.class);
+
+ private static final TimeLog timeLog = new TimeLog(FlightControllerDefault.class, 500, 1000);
+
+ protected SammoaContext context;
+
+ protected SammoaPersistence persistence;
+
+ protected FlightService service;
+
+ protected AudioRecorder audioRecorder;
+
+ protected GpsHandler gpsHandler;
+
+ protected boolean initialized;
+
+ protected FlightState state;
+
+ protected Flight flight;
+
+ protected Route currentRoute;
+
+ protected TransectFlight nextTransect;
+
+ protected TransectFlight lastTransect;
+
+ protected Set<FlightControllerUpdateListener> listeners;
+
+ public FlightControllerDefault(SammoaContext context,
+ Flight flight) {
+
+ this.context = context;
+ this.flight = flight;
+
+ this.persistence = context.getPersistence();
+ this.service = context.getFlightService();
+
+ this.currentRoute = service.getLastRoute(flight);
+ this.lastTransect = service.getLastTransectDone(flight);
+ this.listeners = Sets.newHashSet();
+ }
+
+ @Override
+ public void addListener(FlightControllerUpdateListener listener) {
+ listeners.add(listener);
+ }
+
+ @Override
+ public void removeListener(FlightControllerUpdateListener listener) {
+ listeners.remove(listener);
+ }
+
+ @Override
+ public FlightState getState() {
+ return state;
+ }
+
+ @Override
+ public AudioRecorder getAudioRecorder() {
+ return audioRecorder;
+ }
+
+ @Override
+ public Route getCurrentRoute() {
+ return currentRoute;
+ }
+
+ @Override
+ public TransectFlight getNextTransect() {
+ return nextTransect;
+ }
+
+ @Override
+ public GpsHandler getGpsHandler() {
+ return gpsHandler;
+ }
+
+ @Override
+ public void openGpsDevice(final GpsConfig config) throws DeviceTechnicalException {
+
+ Set<GpsLocationListener> locationListeners;
+ if (gpsHandler != null) {
+
+ // Remove all existing listeners and keep them for the new instance
+ locationListeners = Sets.newHashSet(gpsHandler.getGpsLocationListeners());
+ for (GpsLocationListener listener : locationListeners) {
+ gpsHandler.removeGpsLocationListener(listener);
+ }
+
+ } else {
+ locationListeners = Sets.newHashSet();
+ }
+
+ gpsHandler = newDeviceManager(gpsHandler, new Supplier<GpsHandler>() {
+
+ @Override
+ public GpsHandler get() {
+
+ // Instanciate the GpsHandler
+ Class<? extends GpsHandler> gpsHandlerClass = config.getGpsHandlerClass();
+ try {
+
+ Constructor<? extends GpsHandler> constructor =
+ gpsHandlerClass.getConstructor(GpsConfig.class);
+
+ GpsHandler result = constructor.newInstance(config);
+ result.addGpsLocationListener(FlightControllerDefault.this);
+ return result;
+
+ } catch (InstantiationException e) {
+ throw Throwables.propagate(e);
+ } catch (IllegalAccessException e) {
+ throw Throwables.propagate(e);
+ } catch (NoSuchMethodException e) {
+ throw Throwables.propagate(e);
+ } catch (InvocationTargetException e) {
+ throw Throwables.propagate(e);
+ }
+ }
+ });
+
+ for (GpsLocationListener listener : locationListeners) {
+ gpsHandler.addGpsLocationListener(listener);
+ }
+
+ if (initialized && isRunning()) {
+ gpsHandler.start();
+ } else {
+ gpsHandler.open();
+ }
+ }
+
+ @Override
+ public void openAudioDevice() throws DeviceTechnicalException {
+
+ audioRecorder = newDeviceManager(audioRecorder, new Supplier<AudioRecorder>() {
+
+ @Override
+ public AudioRecorder get() {
+ return new AudioRecorderDefault();
+ }
+ });
+
+ if (initialized && isRunning()) {
+ audioRecorder.start();
+ } else {
+ audioRecorder.open();
+ }
+ }
+
+ @Override
+ public boolean isWaiting() {
+ return state == FlightState.WAITING;
+ }
+
+ @Override
+ public boolean isEnded() {
+ return state == FlightState.ENDED;
+ }
+
+ @Override
+ public boolean isOnEffort() {
+ return state == FlightState.ON_EFFORT;
+ }
+
+ @Override
+ public boolean isOffEffort() {
+ return state == FlightState.OFF_EFFORT;
+ }
+
+ @Override
+ public boolean isRunning() {
+ return isOnEffort() || isOffEffort();
+ }
+
+ @Override
+ public void init() {
+
+ Preconditions.checkState(gpsHandler != null,
+ "The GpsHandler must be created using #openGpsDevice");
+
+ Preconditions.checkState(audioRecorder != null,
+ "The AudioRecorder must be created using #openAudioDevice");
+
+ if (initialized) {
+ if (logger.isWarnEnabled()) {
+ logger.warn("The FlightController is already initialized");
+ }
+ return;
+ }
+
+ if (logger.isInfoEnabled()) {
+ logger.info("Initialize the FlightController for flight " + flight.getFlightNumber());
+ }
+
+ initialized = true;
+
+ // Note that a flight can't finished by a leg, so effort not null
+ // implies that the flight is started and not ended
+ if (currentRoute != null
+ && currentRoute.getRouteType() == RouteType.LEG) {
+
+ state = FlightState.ON_EFFORT;
+
+ } else if (currentRoute != null
+ && flight.getBeginDate() != null
+ && flight.getEndDate() == null) {
+
+ state = FlightState.OFF_EFFORT;
+
+ } else if (flight.getEndDate() != null) {
+
+ state = FlightState.ENDED;
+
+ } else {
+ state = FlightState.WAITING;
+ }
+
+ if (isRunning()) {
+
+ gpsHandler.start();
+
+ audioRecorder.start();
+
+ // Selection of the nextTransect, keep the last one for circleBack
+ if (currentRoute.getRouteType() == RouteType.CIRCLE_BACK) {
+ nextTransect = lastTransect;
+
+ } else {
+ nextTransect = flight.getNextTransectFlightFrom(lastTransect);
+ }
+
+ // Restart recording audio if onEffort or circleBack
+ if (state == FlightState.ON_EFFORT
+ || currentRoute.getRouteType() == RouteType.CIRCLE_BACK) {
+
+ saveAudio(0);
+ }
+ }
+ }
+
+ @Override
+ public void start() {
+
+ long startTime = TimeLog.getTime();
+
+ Preconditions.checkState(initialized,
+ "The controller must be initialized before calling any action");
+
+ Preconditions.checkState(
+ isWaiting(), "You can call start() only if flight is waiting (not started, not ended)");
+
+ gpsHandler.start();
+
+ audioRecorder.start();
+
+ TopiaContext transaction = persistence.beginTransaction();
+ try {
+
+ Date currentDate = saveGPS(transaction, gpsHandler.getCurrentLocation(), flight);
+
+ setFlightBeginDate(transaction, flight, currentDate);
+
+ if (logger.isInfoEnabled()) {
+ logger.info("Start Flight {} at {}", flight.getFlightNumber(), flight.getBeginDate());
+ }
+
+ // Start with TRANSIT route
+ if (logger.isInfoEnabled()) {
+ logger.info(String.format("Create TRANSIT [START] at %1$tH:%1$tM:%1$tS", currentDate));
+ }
+ currentRoute = service.createTransit(transaction, flight, currentDate, currentRoute);
+
+ // Auto selection of the next transect starting from the begining
+ nextTransect = flight.getNextTransectFlightFrom(null);
+
+ state = FlightState.OFF_EFFORT;
+
+ transaction.commitTransaction();
+
+ startTime = timeLog.log(startTime, "start()", "Commited");
+
+ // Fire events after commit
+ fireRouteAdded(currentRoute);
+ fireNextTransectChanged(nextTransect);
+ fireStateChanged(state);
+
+ timeLog.log(startTime, "start()", "Fired");
+
+ } catch (TopiaException e) {
+ throw new TopiaRuntimeException(e);
+
+ } finally {
+ persistence.endTransaction(transaction);
+ }
+ }
+
+ @Override
+ public void setNextTransect(TransectFlight nextTransect) {
+
+ long startTime = TimeLog.getTime();
+
+ Preconditions.checkState(initialized,
+ "The controller must be initialized before calling any action");
+
+ Preconditions.checkState(
+ nextTransect == null || !nextTransect.isDeleted(), "You can't use a deleted transect as next value");
+
+ this.nextTransect = nextTransect;
+
+ // Fire transect changed
+ fireNextTransectChanged(nextTransect);
+
+ timeLog.log(startTime, "setNextTransect()", "Fired");
+ }
+
+ @Override
+ public void begin() {
+
+ long startTime = TimeLog.getTime();
+
+ Preconditions.checkState(initialized,
+ "The controller must be initialized before calling any action");
+
+ Preconditions.checkState(
+ isOffEffort(), "You can call begin() only if flight is running (started, not ended, not on effort)");
+
+ Preconditions.checkState(
+ nextTransect != null, "You can't call begin() if no transect is selected. " +
+ "Call setNextTransect() method first");
+
+ TopiaContext transaction = persistence.beginTransaction();
+ try {
+
+ Date currentDate = saveGPS(transaction, gpsHandler.getCurrentLocation(), flight);
+
+ // The next transect becomes the last one (or current in this case)
+ lastTransect = nextTransect;
+
+ // Create new LEG route
+ if (logger.isInfoEnabled()) {
+ logger.info(String.format("Create LEG [BEGIN] at %1$tH:%1$tM:%1$tS", currentDate));
+ }
+ currentRoute = service.createLeg(transaction, flight, currentDate, currentRoute, lastTransect);
+
+ // automatic selection of the next transect
+ nextTransect = flight.getNextTransectFlightFrom(lastTransect);
+
+ state = FlightState.ON_EFFORT;
+
+ // Record the audio for the current LEG
+ saveAudio(3);
+
+ transaction.commitTransaction();
+
+ startTime = timeLog.log(startTime, "begin()", "Commited");
+
+ // Fire events after commit
+ fireRouteAdded(currentRoute);
+ fireNextTransectChanged(nextTransect);
+ fireStateChanged(state);
+
+ timeLog.log(startTime, "begin()", "Fired");
+
+ } catch (TopiaException e) {
+ throw new TopiaRuntimeException(e);
+
+ } finally {
+ persistence.endTransaction(transaction);
+ }
+ }
+
+ @Override
+ public void circleBack(Observation observation) {
+
+ long startTime = TimeLog.getTime();
+
+ Preconditions.checkState(initialized,
+ "The controller must be initialized before calling any action");
+
+ Preconditions.checkState(
+ currentRoute != null
+ && currentRoute.getRouteType() != RouteType.TRANSIT,
+ "You can't call circleBack() during TRANSIT");
+
+
+ TopiaContext transaction = persistence.beginTransaction();
+ try {
+
+ Date currentDate = saveGPS(transaction, gpsHandler.getCurrentLocation(), flight);
+
+ setObservationStatus(transaction, observation, ObservationStatus.CIRCLE_BACK);
+
+ // Create CIRCLE_BACK
+ if (logger.isInfoEnabled()) {
+ logger.info(String.format("Create CIRCLE_BACK at %1$tH:%1$tM:%1$tS", currentDate));
+ }
+
+ currentRoute = service.createCircleBack(transaction, flight, currentDate, currentRoute, observation);
+
+ nextTransect = lastTransect;
+
+ state = FlightState.OFF_EFFORT;
+
+ // Record the audio of the LEG in an other file
+ saveAudio(3);
+
+ transaction.commitTransaction();
+
+ startTime = timeLog.log(startTime, "circleBack()", "Commited");
+
+ // Fire events after commit
+ fireRouteAdded(currentRoute);
+ fireNextTransectChanged(nextTransect);
+ fireStateChanged(state);
+
+ timeLog.log(startTime, "circleBack()", "Fired");
+
+ } catch (TopiaException e) {
+ throw new TopiaRuntimeException(e);
+
+ } finally {
+ persistence.endTransaction(transaction);
+ }
+ }
+
+ @Override
+ public void add() {
+
+ long startTime = TimeLog.getTime();
+
+ Preconditions.checkState(initialized,
+ "The controller must be initialized before calling any action");
+
+ Preconditions.checkState(
+ isOnEffort(), "You can call add() only if flight is on effort (started, not ended, on effort)");
+
+ TopiaContext transaction = persistence.beginTransaction();
+ try {
+ Date currentDate = saveGPS(transaction, gpsHandler.getCurrentLocation(), flight);
+
+ // Create new LEG route
+ if (logger.isInfoEnabled()) {
+ logger.info(String.format("Create LEG [ADD] at %1$tH:%1$tM:%1$tS", currentDate));
+ }
+ currentRoute = service.createLeg(transaction, flight, currentDate, currentRoute, lastTransect);
+
+ // Record the audio of the LEG in an other file
+ saveAudio(3);
+
+ transaction.commitTransaction();
+
+ startTime = timeLog.log(startTime, "add()", "Commited");
+
+ // Fire events after commit
+ fireRouteAdded(currentRoute);
+
+ timeLog.log(startTime, "add()", "Fired");
+
+ } catch (TopiaException e) {
+ throw new TopiaRuntimeException(e);
+
+ } finally {
+ persistence.endTransaction(transaction);
+ }
+ }
+
+ @Override
+ public void next() {
+
+ long startTime = TimeLog.getTime();
+
+ if (isOnEffort()) {
+ doEndWithAudioDelay(3);
+ }
+
+ begin();
+
+ timeLog.log(startTime, "next()");
+ }
+
+ @Override
+ public void observation(Position position) {
+
+ long startTime = TimeLog.getTime();
+
+ Preconditions.checkState(initialized,
+ "The controller must be initialized before calling any action");
+
+ Preconditions.checkState(
+ isRunning(), "You can call observation() only if flight is running (started, not ended)");
+
+ TopiaContext transaction = persistence.beginTransaction();
+ try {
+
+ Date currentDate = saveGPS(transaction, gpsHandler.getCurrentLocation(), flight);
+
+ ObserverPosition observer;
+ if (currentRoute == null) {
+
+ // problem we don't have any observerPosition
+ observer = null;
+
+ } else {
+ observer = currentRoute.getObserverPositionByPosition(position);
+ }
+
+ if (logger.isInfoEnabled()) {
+ logger.info(String.format("Create Observation %2$s at %1$tH:%1$tM:%1$tS (observer = %3$s)",
+ currentDate,
+ position,
+ observer != null && observer.getObserver() != null
+ ? observer.getObserver().getInitials() : "")
+ );
+ }
+ Observation observation = service.createObservation(transaction, flight, currentDate, observer);
+
+ transaction.commitTransaction();
+
+ startTime = timeLog.log(startTime, "observation()", "Commited");
+
+ for (FlightControllerUpdateListener listener : listeners) {
+ listener.onObservationAdded(observation);
+ }
+
+ timeLog.log(startTime, "observation()", "Fired");
+
+ } catch (TopiaException e) {
+ throw new TopiaRuntimeException(e);
+
+ } finally {
+ persistence.endTransaction(transaction);
+ }
+ }
+
+ @Override
+ public void end() {
+
+ long startTime = TimeLog.getTime();
+
+ // Stop recording after 2 minutes (120 seconds)
+ doEndWithAudioDelay(120);
+
+ timeLog.log(startTime, "end()");
+ }
+
+ @Override
+ public void stop() {
+
+ long startTime = TimeLog.getTime();
+
+ Preconditions.checkState(initialized,
+ "The controller must be initialized before calling any action");
+
+ Preconditions.checkState(
+ isOffEffort(), "You can call stop() only if flight is running (started, not ended, not on effort)");
+
+ TopiaContext transaction = persistence.beginTransaction();
+ try {
+ Date currentDate = saveGPS(transaction, gpsHandler.getCurrentLocation(), flight);
+
+ if (logger.isInfoEnabled()) {
+ logger.info(String.format("Stop flight %2$d at %1$tH:%1$tM:%1$tS",
+ currentDate,
+ flight.getFlightNumber())
+ );
+ }
+ setFlightEndDate(transaction, flight, currentDate);
+
+ // Stop audio
+ getAudioRecorder().stop();
+
+ // Stop gps
+ getGpsHandler().stop();
+
+ currentRoute = null;
+
+ nextTransect = null;
+
+ state = FlightState.ENDED;
+
+ transaction.commitTransaction();
+
+ startTime = timeLog.log(startTime, "stop()", "Commited");
+
+ // Fire events after commit
+ fireRouteAdded(currentRoute);
+ fireNextTransectChanged(nextTransect);
+ fireStateChanged(state);
+
+ timeLog.log(startTime, "stop()", "Fired");
+
+ } catch (TopiaException e) {
+ throw new TopiaRuntimeException(e);
+
+ } finally {
+ persistence.endTransaction(transaction);
+ }
+ }
+
+ @Override
+ public void close() {
+
+ audioRecorder.close();
+ audioRecorder = null;
+
+ gpsHandler.close();
+ gpsHandler = null;
+
+ persistence.stopAutoSaveListener();
+ }
+
+ protected void doEndWithAudioDelay(long audioDelay) {
+
+ Preconditions.checkState(initialized,
+ "The controller must be initialized before calling any action");
+
+ Preconditions.checkState(
+ isOnEffort(), "You can call end() only if flight is on effort (started, not ended, on effort)");
+
+ TopiaContext transaction = persistence.beginTransaction();
+ try {
+ Date currentDate = saveGPS(transaction, gpsHandler.getCurrentLocation(), flight);
+
+ // Create new TRANSIT route
+ if (logger.isInfoEnabled()) {
+ logger.info(String.format("Create TRANSIT [END] at %1$tH:%1$tM:%1$tS", currentDate));
+ }
+ currentRoute = service.createTransit(transaction, flight, currentDate, currentRoute);
+
+ audioRecorder.stopRecord(audioDelay);
+
+ state = FlightState.OFF_EFFORT;
+
+ transaction.commitTransaction();
+
+ // Fire events after commit
+ fireRouteAdded(currentRoute);
+ fireNextTransectChanged(nextTransect);
+ fireStateChanged(state);
+
+ } catch (TopiaException e) {
+ throw new TopiaRuntimeException(e);
+
+ } finally {
+ persistence.endTransaction(transaction);
+ }
+ }
+
+// protected void setNextTransect(TransectFlight nextTransect, boolean fireEvents) {
+//
+// this.nextTransect = nextTransect;
+//
+// if (fireEvents) {
+// // Fire transect changed
+// for (FlightControllerUpdateListener listener : listeners) {
+// listener.onNextTransectChanged(nextTransect);
+// }
+// }
+// }
+//
+// protected void setNextTransectFrom(TransectFlight transect, boolean fireEvents) {
+//
+// TransectFlight nextTransect =
+// flight.getNextTransectFlightFrom(transect);
+//
+// setNextTransect(nextTransect, fireEvents);
+// }
+
+ protected void setFlightBeginDate(TopiaContext transaction,
+ Flight flight,
+ Date beginDate)
+ throws TopiaException {
+
+ FlightDAO flightDAO = SammoaDAOHelper.getFlightDAO(transaction);
+ flight.setBeginDate(beginDate);
+ flightDAO.update(flight);
+ }
+
+ protected void setFlightEndDate(TopiaContext transaction,
+ Flight flight,
+ Date endDate)
+ throws TopiaException {
+
+ FlightDAO flightDAO = SammoaDAOHelper.getFlightDAO(transaction);
+ flight.setEndDate(endDate);
+ flightDAO.update(flight);
+ }
+
+ protected void setObservationStatus(TopiaContext transaction,
+ Observation observation,
+ ObservationStatus status)
+ throws TopiaException {
+
+ ObservationDAO observationDAO =
+ SammoaDAOHelper.getObservationDAO(transaction);
+ observation.setObservationStatus(status);
+ observationDAO.update(observation);
+ }
+
+ protected void saveAudio(long delay) {
+
+ String fileName = String.format(
+ "%1$tF-%1$tH-%1$tM-%1$tS.%2$s.%3$s",
+ currentRoute.getBeginTime(),
+ currentRoute.getTopiaId(),
+ getAudioRecorder().getOutputType().getExtension()
+ );
+
+ File audioDir = context.getConfig().getAudioDirectory();
+
+ File audioFile = new File(audioDir, fileName);
+
+ try {
+ getAudioRecorder().record(audioFile, delay);
+ } catch (IOException e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ protected Date saveGPS(TopiaContext transaction,
+ GeoPoint geoPoint,
+ Flight flight)
+ throws TopiaException {
+
+ Date result;
+ if (geoPoint == null) {
+ result = new Date();
+ if (logger.isWarnEnabled()) {
+ logger.warn("No GPS point at {}", result);
+ }
+
+ } else {
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("Create GPS Point : {}", geoPoint);
+ }
+
+ result = geoPoint.getRecordTime();
+
+ GeoPointDAO dao = SammoaDAOHelper.getGeoPointDAO(transaction);
+
+ geoPoint.setFlight(flight);
+
+ dao.create(geoPoint);
+ }
+ return result;
+ }
+
+ protected void fireStateChanged(FlightState state) {
+ for (FlightControllerUpdateListener listener : listeners) {
+ listener.onStateChanged(state);
+ }
+ }
+
+ protected void fireRouteAdded(Route route) {
+ for (FlightControllerUpdateListener listener : listeners) {
+ listener.onRouteAdded(route);
+ }
+ }
+
+ protected void fireNextTransectChanged(TransectFlight nextTransect) {
+ for (FlightControllerUpdateListener listener : listeners) {
+ listener.onNextTransectChanged(nextTransect);
+ }
+ }
+
+ protected <T extends DeviceManager> T newDeviceManager(T oldInstance, Supplier<T> supplier)
+ throws DeviceTechnicalException {
+
+ Set<DeviceStateListener> stateListeners;
+ if (oldInstance != null) {
+
+ // Remove all existing listeners and keep them for the new instance
+ stateListeners = Sets.newHashSet(oldInstance.getDeviceStateListeners());
+ for (DeviceStateListener listener : stateListeners) {
+ oldInstance.removeDeviceStateListener(listener);
+ }
+
+ oldInstance.close();
+
+ } else {
+ stateListeners = Sets.newHashSet();
+ }
+
+ T result = supplier.get();
+
+ // Attach all updateListener
+ for (DeviceStateListener listener : stateListeners) {
+ result.addDeviceStateListener(listener);
+ }
+
+ return result;
+ }
+
+ @Override
+ public void locationChanged(GpsLocationEvent event) {
+ GeoPoint newLocation = event.getNewValue();
+ if (newLocation != null/* && newLocation.getTopiaId() == null*/) {
+ newLocation.setFlight(flight);
+ persistence.delayEntityCreation(newLocation);
+ }
+ }
+
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerDefault.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerUpdateListener.java (from rev 360, trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightControllerUpdateListener.java)
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerUpdateListener.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerUpdateListener.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -0,0 +1,69 @@
+package fr.ulr.sammoa.application.flightController;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ulr.sammoa.persistence.Observation;
+import fr.ulr.sammoa.persistence.Route;
+import fr.ulr.sammoa.persistence.TransectFlight;
+
+/**
+ * Listener for all change of data in the {@link FlightController}
+ *
+ * Created: 12/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ * @see FlightController
+ */
+public interface FlightControllerUpdateListener {
+
+ /**
+ * Fired when a new {@code route} has been created and added to the flight
+ *
+ * @param route The new route added
+ */
+ void onRouteAdded(Route route);
+
+ /**
+ * Fired when the next transect has been updated.
+ *
+ * @param nextTransect The next transect that will be used on
+ * {@link FlightController#begin()} action
+ */
+ void onNextTransectChanged(TransectFlight nextTransect);
+
+ /**
+ * Fired when controller change the {@code state} of the flight after
+ * each action.
+ *
+ * @param state The new state
+ */
+ void onStateChanged(FlightState state);
+
+ /**
+ * Fired when controller add a new observation
+ *
+ * @param observation The new observation
+ */
+ void onObservationAdded(Observation observation);
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerUpdateListener.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightState.java (from rev 360, trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightState.java)
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightState.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightState.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -0,0 +1,57 @@
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+package fr.ulr.sammoa.application.flightController;
+
+/**
+ * Created: 20/06/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public enum FlightState {
+ /**
+ * The WAITING state is when the flight is not started and not ended.
+ * It appends when the flight is not really in used.
+ */
+ WAITING,
+
+ /**
+ * The OFF_EFFORT state is when the flight is started but not ended,
+ * and also if the current route is not an effort.
+ * It appends generally when the flight is in TRANSIT or CIRCLE_BACK.
+ */
+ OFF_EFFORT,
+
+ /**
+ * The ON_EFFORT state is when the flight is started, not ended but in
+ * current effort. It appends when a LEG is currently in progress.
+ */
+ ON_EFFORT,
+
+ /**
+ * The ENDED state is when the flight is ended.
+ * It appends when the current effort is finished and when no more route
+ * need to be registered.
+ */
+ ENDED
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightState.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/BaseHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/BaseHandler.java 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/BaseHandler.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -24,8 +24,8 @@
*/
package fr.ulr.sammoa.ui.swing;
-import fr.ulr.sammoa.application.FlightController;
import fr.ulr.sammoa.application.SammoaContext;
+import fr.ulr.sammoa.application.flightController.FlightController;
import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
/**
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -24,11 +24,11 @@
*/
package fr.ulr.sammoa.ui.swing;
-import fr.ulr.sammoa.application.FlightState;
import fr.ulr.sammoa.application.SammoaConfig;
import fr.ulr.sammoa.application.SammoaContext;
import fr.ulr.sammoa.application.device.DeviceTechnicalException;
import fr.ulr.sammoa.application.device.gps.GpsConfig;
+import fr.ulr.sammoa.application.flightController.FlightState;
import fr.ulr.sammoa.persistence.Campaign;
import fr.ulr.sammoa.persistence.Flight;
import fr.ulr.sammoa.ui.swing.campaign.CampaignUI;
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaUIContext.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaUIContext.java 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaUIContext.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -25,9 +25,9 @@
package fr.ulr.sammoa.ui.swing;
import com.google.common.base.Preconditions;
-import fr.ulr.sammoa.application.FlightController;
import fr.ulr.sammoa.application.SammoaConfig;
import fr.ulr.sammoa.application.SammoaContext;
+import fr.ulr.sammoa.application.flightController.FlightController;
import fr.ulr.sammoa.ui.swing.flight.FlightUIHandler;
import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
import org.nuiton.widget.SwingSession;
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/AddAction.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/AddAction.java 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/AddAction.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -23,7 +23,7 @@
*/
package fr.ulr.sammoa.ui.swing.action;
-import fr.ulr.sammoa.application.FlightState;
+import fr.ulr.sammoa.application.flightController.FlightState;
import fr.ulr.sammoa.ui.swing.SammoaUIContext;
import org.nuiton.util.Resource;
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/BeginAction.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/BeginAction.java 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/BeginAction.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -23,7 +23,7 @@
*/
package fr.ulr.sammoa.ui.swing.action;
-import fr.ulr.sammoa.application.FlightState;
+import fr.ulr.sammoa.application.flightController.FlightState;
import fr.ulr.sammoa.persistence.RouteType;
import fr.ulr.sammoa.ui.swing.SammoaUIContext;
import org.nuiton.util.Resource;
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/EndAction.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/EndAction.java 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/EndAction.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -23,7 +23,7 @@
*/
package fr.ulr.sammoa.ui.swing.action;
-import fr.ulr.sammoa.application.FlightState;
+import fr.ulr.sammoa.application.flightController.FlightState;
import fr.ulr.sammoa.ui.swing.SammoaUIContext;
import org.nuiton.util.Resource;
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/NextAction.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/NextAction.java 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/NextAction.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -23,7 +23,7 @@
*/
package fr.ulr.sammoa.ui.swing.action;
-import fr.ulr.sammoa.application.FlightState;
+import fr.ulr.sammoa.application.flightController.FlightState;
import fr.ulr.sammoa.ui.swing.SammoaUIContext;
import org.nuiton.util.Resource;
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ObservationAction.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ObservationAction.java 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ObservationAction.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -23,7 +23,7 @@
*/
package fr.ulr.sammoa.ui.swing.action;
-import fr.ulr.sammoa.application.FlightState;
+import fr.ulr.sammoa.application.flightController.FlightState;
import fr.ulr.sammoa.persistence.Position;
import fr.ulr.sammoa.ui.swing.SammoaUIContext;
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/SammoaAction.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/SammoaAction.java 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/SammoaAction.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -23,8 +23,8 @@
*/
package fr.ulr.sammoa.ui.swing.action;
-import fr.ulr.sammoa.application.FlightController;
-import fr.ulr.sammoa.application.FlightState;
+import fr.ulr.sammoa.application.flightController.FlightController;
+import fr.ulr.sammoa.application.flightController.FlightState;
import fr.ulr.sammoa.persistence.Flight;
import fr.ulr.sammoa.persistence.Route;
import fr.ulr.sammoa.persistence.TransectFlight;
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/StartAction.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/StartAction.java 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/StartAction.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -23,7 +23,7 @@
*/
package fr.ulr.sammoa.ui.swing.action;
-import fr.ulr.sammoa.application.FlightState;
+import fr.ulr.sammoa.application.flightController.FlightState;
import fr.ulr.sammoa.ui.swing.SammoaUIContext;
import org.nuiton.util.Resource;
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/StopAction.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/StopAction.java 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/StopAction.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -23,7 +23,7 @@
*/
package fr.ulr.sammoa.ui.swing.action;
-import fr.ulr.sammoa.application.FlightState;
+import fr.ulr.sammoa.application.flightController.FlightState;
import fr.ulr.sammoa.ui.swing.SammoaUIContext;
import org.nuiton.util.Resource;
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/campaign/CampaignUI.jaxx
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/campaign/CampaignUI.jaxx 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/campaign/CampaignUI.jaxx 2012-08-07 15:49:18 UTC (rev 361)
@@ -26,7 +26,7 @@
implements='fr.ulr.sammoa.ui.swing.SammoaUI<CampaignUIHandler>'>
<import>
- fr.ulr.sammoa.application.FlightState
+ fr.ulr.sammoa.application.flightController.FlightState
fr.ulr.sammoa.persistence.Region
fr.ulr.sammoa.persistence.Campaign
fr.ulr.sammoa.ui.swing.SammoaUIContext
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBar.jaxx
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBar.jaxx 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBar.jaxx 2012-08-07 15:49:18 UTC (rev 361)
@@ -28,7 +28,7 @@
javax.swing.BoxLayout
javax.swing.SwingConstants
jaxx.runtime.swing.ClockWidget
- fr.ulr.sammoa.application.FlightState
+ fr.ulr.sammoa.application.flightController.FlightState
</import>
<script><![CDATA[
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBarHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBarHandler.java 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBarHandler.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -24,7 +24,7 @@
*/
package fr.ulr.sammoa.ui.swing.flight;
-import fr.ulr.sammoa.application.FlightState;
+import fr.ulr.sammoa.application.flightController.FlightState;
import fr.ulr.sammoa.persistence.Route;
import fr.ulr.sammoa.ui.swing.BaseHandler;
import fr.ulr.sammoa.ui.swing.SammoaColors;
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUI.jaxx
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUI.jaxx 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUI.jaxx 2012-08-07 15:49:18 UTC (rev 361)
@@ -40,7 +40,7 @@
fr.ulr.sammoa.persistence.Flight
fr.ulr.sammoa.persistence.Observer
fr.ulr.sammoa.persistence.Strate
- fr.ulr.sammoa.application.FlightState
+ fr.ulr.sammoa.application.flightController.FlightState
fr.ulr.sammoa.ui.swing.SammoaUIContext
fr.ulr.sammoa.ui.swing.ValidationTable
fr.ulr.sammoa.ui.swing.observations.EffortPanel
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -46,17 +46,17 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Ordering;
-import fr.ulr.sammoa.application.FlightController;
-import fr.ulr.sammoa.application.FlightControllerDefault;
-import fr.ulr.sammoa.application.FlightControllerUpdateListener;
import fr.ulr.sammoa.application.FlightService;
-import fr.ulr.sammoa.application.FlightState;
import fr.ulr.sammoa.application.ReferentialService;
import fr.ulr.sammoa.application.SammoaConfig;
import fr.ulr.sammoa.application.SammoaContext;
import fr.ulr.sammoa.application.device.DeviceTechnicalException;
import fr.ulr.sammoa.application.device.gps.GpsLocationEvent;
import fr.ulr.sammoa.application.device.gps.GpsLocationListener;
+import fr.ulr.sammoa.application.flightController.FlightController;
+import fr.ulr.sammoa.application.flightController.FlightControllerDefault;
+import fr.ulr.sammoa.application.flightController.FlightControllerUpdateListener;
+import fr.ulr.sammoa.application.flightController.FlightState;
import fr.ulr.sammoa.persistence.Campaign;
import fr.ulr.sammoa.persistence.Flight;
import fr.ulr.sammoa.persistence.GeoPoint;
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIModel.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIModel.java 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIModel.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -26,7 +26,7 @@
import com.google.common.collect.FluentIterable;
import com.google.common.collect.Lists;
-import fr.ulr.sammoa.application.FlightState;
+import fr.ulr.sammoa.application.flightController.FlightState;
import fr.ulr.sammoa.persistence.Flight;
import fr.ulr.sammoa.persistence.Observation;
import fr.ulr.sammoa.persistence.Observations;
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/TransectLayer.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/TransectLayer.java 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/layer/TransectLayer.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -26,7 +26,7 @@
import com.bbn.openmap.omGraphics.OMGraphic;
import com.bbn.openmap.plugin.esri.EsriPlugIn;
-import fr.ulr.sammoa.application.FlightState;
+import fr.ulr.sammoa.application.flightController.FlightState;
import fr.ulr.sammoa.persistence.Route;
import fr.ulr.sammoa.persistence.Transect;
import fr.ulr.sammoa.persistence.TransectFlight;
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUI.jaxx
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUI.jaxx 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUI.jaxx 2012-08-07 15:49:18 UTC (rev 361)
@@ -25,7 +25,7 @@
implements='fr.ulr.sammoa.ui.swing.SammoaUI<ExportMapUIHandler>'>
<import>
- fr.ulr.sammoa.application.FlightState
+ fr.ulr.sammoa.application.flightController.FlightState
fr.ulr.sammoa.persistence.Campaign
fr.ulr.sammoa.persistence.RouteType
fr.ulr.sammoa.persistence.Strate
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/EffortPanelHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/EffortPanelHandler.java 2012-08-07 15:48:54 UTC (rev 360)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/EffortPanelHandler.java 2012-08-07 15:49:18 UTC (rev 361)
@@ -23,11 +23,11 @@
* #L%
*/
-import fr.ulr.sammoa.application.FlightController;
import fr.ulr.sammoa.application.FlightService;
import fr.ulr.sammoa.application.device.DeviceState;
import fr.ulr.sammoa.application.device.DeviceStateEvent;
import fr.ulr.sammoa.application.device.DeviceStateListener;
+import fr.ulr.sammoa.application.flightController.FlightController;
import fr.ulr.sammoa.persistence.Observation;
import fr.ulr.sammoa.persistence.ObservationStatus;
import fr.ulr.sammoa.persistence.Observations;
1
0