|
From: <jan...@us...> - 2007-01-14 19:10:00
|
Revision: 503
http://svn.sourceforge.net/magicmap/?rev=503&view=rev
Author: jan_fride
Date: 2007-01-14 11:09:55 -0800 (Sun, 14 Jan 2007)
Log Message:
-----------
changed MeasurementModel as there should be only one ;-)
Modified Paths:
--------------
trunk/magicmapclient/src/net/sf/magicmap/client/controller/Controller.java
trunk/magicmapclient/src/net/sf/magicmap/client/controller/IController.java
trunk/magicmapclient/src/net/sf/magicmap/client/controller/ServerManager.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/MeasurementTable.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/MeasurementView.java
trunk/magicmapclient/src/net/sf/magicmap/client/plugin/udpscanner/WifiHandler.java
Removed Paths:
-------------
trunk/magicmapclient/src/net/sf/magicmap/client/model/measurement/NMeasurementModel.java
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/controller/Controller.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/controller/Controller.java 2007-01-14 19:08:30 UTC (rev 502)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/controller/Controller.java 2007-01-14 19:09:55 UTC (rev 503)
@@ -28,9 +28,9 @@
import net.sf.magicmap.client.measurement.interfaces.AbstractScannerHandler;
import net.sf.magicmap.client.meta.MapInfo;
import net.sf.magicmap.client.model.info.InfoObjectProviderRegistry;
+
+import net.sf.magicmap.client.model.measurement.IMeasurementModel;
import net.sf.magicmap.client.model.measurement.MeasurementModel;
-import net.sf.magicmap.client.model.measurement.SeenAccessPoint;
-import net.sf.magicmap.client.model.node.AccessPointEdge;
import net.sf.magicmap.client.model.node.AccessPointSeerNode;
import net.sf.magicmap.client.model.node.ClientNode;
import net.sf.magicmap.client.model.node.GeoPos;
@@ -45,8 +45,6 @@
import org.apache.log4j.xml.DOMConfigurator;
-import javax.swing.*;
-
/**
* Kann \xC4nderungen an View und am Modell vornehmen und zieht alle F\xE4den
* der Anwendung.
@@ -67,10 +65,8 @@
*/
private INodeModel nodeModel; // Model f\xFCr Graphen
- private MeasurementModel measurementModel; // Model f\xFCr Messungen
+ private IMeasurementModel measurementModel; // Model f\xFCr Messungen
- private MeasurementModel measurementModelOther; // Messungen anderen Clients / Orte
-
private ClientNode client; // Ausgezeichneter Knoten
private ServerPoller poller; // Server st\xE4ndig nach \xC4nderungen fragen
@@ -116,10 +112,6 @@
*/
this.measurementModel = new MeasurementModel();
- /**
- * Messungen f\xFCr alle anderen?
- */
- this.measurementModelOther = new MeasurementModel();
this.scannerAllocator = new ScannerAllocator();
this.currentMap = null;
@@ -231,14 +223,14 @@
* the access point seer node
*/
public void buildOtherMeasurement(AccessPointSeerNode ap){
- System.out.println("Building measurement model...");
- this.measurementModelOther.clear();
- ArrayList aes = ap.getApEdges();
- for (int i = 0; i < aes.size(); i++) {
- AccessPointEdge ae = (AccessPointEdge) aes.get(i);
- SeenAccessPoint sp = new SeenAccessPoint(ae.getAccessPoint().getMacAddress(), ae.getSignalLevel());
- this.measurementModelOther.addAccessPoint(sp);
- }
+// System.out.println("Building measurement model...");
+// this.measurementModelOther.clear();
+// ArrayList aes = ap.getApEdges();
+// for (int i = 0; i < aes.size(); i++) {
+// AccessPointEdge ae = (AccessPointEdge) aes.get(i);
+// SeenAccessPoint sp = new SeenAccessPoint(ae.getAccessPoint().getMacAddress(), ae.getSignalLevel());
+// this.measurementModelOther.addAccessPoint(sp);
+// }
}
/**
@@ -264,7 +256,7 @@
*
* @return the measurement model
*/
- public MeasurementModel getMeasurementModel(){
+ public IMeasurementModel getMeasurementModel(){
return this.measurementModel;
}
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/controller/IController.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/controller/IController.java 2007-01-14 19:08:30 UTC (rev 502)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/controller/IController.java 2007-01-14 19:09:55 UTC (rev 503)
@@ -21,7 +21,7 @@
import net.sf.magicmap.client.measurement.interfaces.AbstractScannerHandler;
import net.sf.magicmap.client.meta.MapInfo;
import net.sf.magicmap.client.model.info.InfoObjectProviderRegistry;
-import net.sf.magicmap.client.model.measurement.MeasurementModel;
+import net.sf.magicmap.client.model.measurement.IMeasurementModel;
import net.sf.magicmap.client.model.node.AccessPointSeerNode;
import net.sf.magicmap.client.model.node.ClientNode;
import net.sf.magicmap.client.model.node.GeoPos;
@@ -96,7 +96,7 @@
*
* @return the measurement model
*/
- MeasurementModel getMeasurementModel();
+ IMeasurementModel getMeasurementModel();
/**
* Gibt an ob verbunden oder nicht verbunden
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/controller/ServerManager.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/controller/ServerManager.java 2007-01-14 19:08:30 UTC (rev 502)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/controller/ServerManager.java 2007-01-14 19:09:55 UTC (rev 503)
@@ -30,6 +30,7 @@
import net.sf.magicmap.client.model.measurement.SeenAccessPoint;
import net.sf.magicmap.client.model.node.GeoPos;
import net.sf.magicmap.client.model.node.InfoObject;
+import net.sf.magicmap.client.model.node.ClientNode;
import net.sf.magicmap.server.dto.PositionDTO;
import net.sf.magicmap.server.dto.SignalCharacterDTO;
import net.sf.magicmap.server.dto.SimpleScanResultDTO;
@@ -69,7 +70,8 @@
*/
protected SignalCharacterDTO currentSignalCharacter(){
SignalCharacterDTO signalCharacter = new SignalCharacterDTO();
- Collection accessPoints = controller.getMeasurementModel().getAccessPoints();
+ ClientNode clientNode = controller.getClient();
+ Collection accessPoints = controller.getMeasurementModel().get(clientNode);
Iterator it = accessPoints.iterator();
while (it.hasNext()) {
SeenAccessPoint ap = (SeenAccessPoint) it.next();
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/MeasurementTable.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/MeasurementTable.java 2007-01-14 19:08:30 UTC (rev 502)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/MeasurementTable.java 2007-01-14 19:09:55 UTC (rev 503)
@@ -16,9 +16,9 @@
import net.sf.magicmap.client.measurement.Constants;
import net.sf.magicmap.client.measurement.MeasurementUtils;
-import net.sf.magicmap.client.model.measurement.MeasurementModel;
import net.sf.magicmap.client.model.measurement.MeasurementTableModel;
import net.sf.magicmap.client.model.measurement.SeenAccessPoint;
+import net.sf.magicmap.client.model.measurement.IMeasurementModel;
public class MeasurementTable extends JTable {
@@ -30,9 +30,8 @@
/**
*
* @param model
- * @param otherModel
*/
- public MeasurementTable(MeasurementModel model) {
+ public MeasurementTable(IMeasurementModel model) {
this(new MeasurementTableModel(model));
}
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/MeasurementView.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/MeasurementView.java 2007-01-14 19:08:30 UTC (rev 502)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/MeasurementView.java 2007-01-14 19:09:55 UTC (rev 503)
@@ -15,8 +15,8 @@
import net.sf.magicmap.client.gui.utils.GUIBuilder;
import net.sf.magicmap.client.gui.utils.GUIConstants;
import net.sf.magicmap.client.gui.utils.GUIUtils;
-import net.sf.magicmap.client.model.measurement.MeasurementModel;
import net.sf.magicmap.client.model.measurement.MeasurementTableModel;
+import net.sf.magicmap.client.model.measurement.IMeasurementModel;
import net.sf.magicmap.client.model.node.AccessPointSeerNode;
import net.sf.magicmap.client.model.node.INodeModel;
import net.sf.magicmap.client.model.node.Node;
@@ -37,13 +37,12 @@
private MeasurementTableModel tableModel;
private MeasurementTableModel tableModelOther;
- public MeasurementView(MeasurementModel model, INodeModel nodeModel) {
+ public MeasurementView(IMeasurementModel model, INodeModel nodeModel) {
super(GUIUtils.i18n("measurement"));
this.setFrameIcon(GUIBuilder.getToolIcon(GUIConstants.ICON_MEASUREMENT));
- this.table = new MeasurementTable(model);
+ this.table = new MeasurementTable(new MeasurementTableModel(model));
this.tableModel = (MeasurementTableModel) this.table.getModel();
- this.tableModelOther = new MeasurementTableModel(new MeasurementModel());
nodeModel.addNodeModelSelectionListener((MeasurementTableModel) this.table.getModel());
setContent(buildViewComponent());
Deleted: trunk/magicmapclient/src/net/sf/magicmap/client/model/measurement/NMeasurementModel.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/model/measurement/NMeasurementModel.java 2007-01-14 19:08:30 UTC (rev 502)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/model/measurement/NMeasurementModel.java 2007-01-14 19:09:55 UTC (rev 503)
@@ -1,123 +0,0 @@
-package net.sf.magicmap.client.model.measurement;
-
-import net.sf.magicmap.client.model.node.ClientNode;
-import net.sf.magicmap.client.model.node.AccessPointSeerNode;
-import net.sf.magicmap.client.interfaces.MeasurementModelListener;
-
-import javax.swing.event.EventListenerList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.Map;
-
-/**
- * New Model for measurements. contains all measurement made.
- *
- */
-public class NMeasurementModel implements IMeasurementModel {
-
- private final EventListenerList listeners = new EventListenerList();
- private final MeasurementMap apMap = new MeasurementMap();
- public NMeasurementModel(){
-
- }
-
- /**
- * Adds an access point to the list of seen ap for a
- * given client.
- *
- * @param client the client seeing the ap
- * @param ap the seen access point.
- */
- public void addAccessPoint(AccessPointSeerNode client, SeenAccessPoint ap) {
- if (apMap.put(client, ap)){
- fireAccessPointAdded(client,ap);
- }
- }
-
- /**
- * Returns a list of seen access points for a given client.
- * @param forNode
- * @return
- */
- public Collection<SeenAccessPoint> get(AccessPointSeerNode forNode){
- return apMap.get(forNode).values();
- }
-
- public void updateAccessPoint(AccessPointSeerNode client, SeenAccessPoint ap) {
- fireAccessPointChanged(client, ap);
- }
-
- public void removeAccessPoint(AccessPointSeerNode client, SeenAccessPoint ap) {
- if (apMap.remove(client, ap)){
- fireAccessPointRemoved(client, ap);
- }
- }
- public void addMeasurementModelListener(MeasurementModelListener l){
- listeners.add(MeasurementModelListener.class, l);
- }
-
- public void removeMeasurementModelListener(MeasurementModelListener l){
- listeners.remove(MeasurementModelListener.class, l);
- }
-
- protected final void fireAccessPointAdded(AccessPointSeerNode node, SeenAccessPoint ap){
- MeasurementModelListener[] modelListeners = listeners.getListeners(MeasurementModelListener.class);
- for (MeasurementModelListener l: modelListeners){
- l.seesAccessPoint(ap);
- }
- }
- protected final void fireAccessPointRemoved(AccessPointSeerNode node, SeenAccessPoint ap){
- MeasurementModelListener[] modelListeners = listeners.getListeners(MeasurementModelListener.class);
- for (MeasurementModelListener l: modelListeners){
- l.notseesAccessPoint(ap);
- }
- }
- protected final void fireAccessPointChanged(AccessPointSeerNode node, SeenAccessPoint ap){
- MeasurementModelListener[] modelListeners = listeners.getListeners(MeasurementModelListener.class);
- for (MeasurementModelListener l: modelListeners){
- l.updateAccessPoint(ap);
- }
- }
-
- public SeenAccessPoint getAccessPoint(ClientNode client, String mac){
- return apMap.get(client,mac);
- }
-
- private static class MeasurementMap extends HashMap<AccessPointSeerNode, Map<String, SeenAccessPoint>>{
-
- public boolean put(AccessPointSeerNode node, SeenAccessPoint ap){
- if (containsKey(node)){
-
- Map<String, SeenAccessPoint> map = get(node);
- boolean isNew =map.containsKey(ap.getMac());
- map.put(ap.getMac(), ap);
- return isNew;
- }
- else{
- HashMap<String, SeenAccessPoint> list = new HashMap<String, SeenAccessPoint>();
- list.put(ap.getMac(), ap);
- super.put(node, list);
- return true;
- }
- }
- public boolean remove(AccessPointSeerNode node, SeenAccessPoint ap){
- if (containsKey(node)){
- return get(node).remove(ap.getMac()) != null;
- }
- return false;
- }
-
-
- public Map<String, SeenAccessPoint> get(Object key) {
- Map<String, SeenAccessPoint> map = super.get(key);
- if (map == null) return new HashMap<String, SeenAccessPoint>();
- return map;
- }
- public SeenAccessPoint get(AccessPointSeerNode seer, String apMac) {
- return get(seer).get(apMac);
- }
- }
-
-
-}
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/plugin/udpscanner/WifiHandler.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/plugin/udpscanner/WifiHandler.java 2007-01-14 19:08:30 UTC (rev 502)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/plugin/udpscanner/WifiHandler.java 2007-01-14 19:09:55 UTC (rev 503)
@@ -13,8 +13,8 @@
import net.sf.magicmap.client.measurement.interfaces.AbstractScanResult;
import net.sf.magicmap.client.measurement.interfaces.AbstractScanner;
import net.sf.magicmap.client.measurement.interfaces.AbstractScannerHandler;
-import net.sf.magicmap.client.model.measurement.MeasurementModel;
import net.sf.magicmap.client.model.measurement.SeenAccessPoint;
+import net.sf.magicmap.client.model.measurement.IMeasurementModel;
import net.sf.magicmap.client.model.node.AccessPointNode;
import net.sf.magicmap.client.model.node.ClientNode;
import net.sf.magicmap.client.model.node.INodeModel;
@@ -30,7 +30,7 @@
*/
public class WifiHandler extends AbstractScannerHandler {
- private MeasurementModel measurementModel;
+ private IMeasurementModel measurementModel;
private INodeModel nodeModel;
@@ -48,7 +48,7 @@
* @param client
* ClientNode
*/
- public WifiHandler(AbstractScanner canHandle, MeasurementModel mmodel, INodeModel nmodel, ClientNode client) {
+ public WifiHandler(AbstractScanner canHandle, IMeasurementModel mmodel, INodeModel nmodel, ClientNode client) {
super(canHandle);
this.measurementModel = mmodel;
this.nodeModel = nmodel;
@@ -65,7 +65,7 @@
*
* @return
*/
- public MeasurementModel getMeasurementModel(){
+ public IMeasurementModel getMeasurementModel(){
return this.measurementModel;
}
@@ -74,7 +74,7 @@
*
* @param model
*/
- public void setMeasurementModel(MeasurementModel model){
+ public void setMeasurementModel(IMeasurementModel model){
this.measurementModel = model;
}
@@ -92,7 +92,7 @@
public void run(){
String mac = result.getIdentifier();
double signalLevel = result.signalLevel;
- SeenAccessPoint ap = WifiHandler.this.measurementModel.getAccessPoint(mac);
+ SeenAccessPoint ap = WifiHandler.this.measurementModel.getAccessPoint(client, mac);
if (ap != null) {
WifiHandler.this.previous.remove(ap);
AccessPointNode node = WifiHandler.this.nodeModel.findAccessPoint(mac);
@@ -113,14 +113,14 @@
ap.addSignalLevel(signalLevel);
// Die St\xE4rke aber aus dem
// Durchschnittssignalableiten
- WifiHandler.this.measurementModel.updateAccessPoint(ap);
+ WifiHandler.this.measurementModel.updateAccessPoint(client, ap);
// AccessPoint ist aus der Berechnung ausgeschlossen
WifiHandler.this.client.setSignalLevelForAcessPoint(node, ap.getAverageSignalLevel());
}
} else {
// AccessPoint ist noch nicht im Model.
ap = new SeenAccessPoint(mac, signalLevel);
- WifiHandler.this.measurementModel.addAccessPoint(ap);
+ WifiHandler.this.measurementModel.addAccessPoint(client, ap);
// Schauen ob der Access Point dann evtl. im NodeModel
// schon vorhanden ist
AccessPointNode node = WifiHandler.this.nodeModel.findAccessPoint(mac);
@@ -165,7 +165,7 @@
SeenAccessPoint ap = (SeenAccessPoint) it.next();
// Den Durchschnitt dr\xFCcken...
ap.addDeadSignal();
- WifiHandler.this.measurementModel.updateAccessPoint(ap);
+ WifiHandler.this.measurementModel.updateAccessPoint(client, ap);
/*
* AccessPointNode node =
* nodeModel.findAccessPoint(ap.getMac()); if (node !=
@@ -175,7 +175,7 @@
if (ap.isTotallyDead()) {
// AP nur entfernen, wenn l\xE4ngere Zeit kein Signal
// mehr
- WifiHandler.this.measurementModel.removeAccessPoint(ap);
+ WifiHandler.this.measurementModel.removeAccessPoint(client, ap);
// NodeModel aktualisieren
AccessPointNode node = WifiHandler.this.nodeModel.findAccessPoint(ap.getMac());
if (node != null) // Kante zum Access Point vom eigenen Client
@@ -195,7 +195,7 @@
// Botschaften
// die beschreiben was sich ge\xE4ndert hat.
WifiHandler.this.previous = new HashSet<SeenAccessPoint>(WifiHandler.this.measurementModel
- .getAccessPoints());
+ .get(client));
}
});
} catch (InterruptedException e) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|