|
From: <jan...@us...> - 2007-01-21 16:35:14
|
Revision: 514
http://svn.sourceforge.net/magicmap/?rev=514&view=rev
Author: jan_fride
Date: 2007-01-21 08:35:03 -0800 (Sun, 21 Jan 2007)
Log Message:
-----------
nodemodel and measurementmodel verbessert?... hoffe ich
Modified Paths:
--------------
trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/MapView.java
trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/JungNodePlacer.java
trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/handler/NotSeeAccessPointHandler.java
trunk/magicmapclient/src/net/sf/magicmap/client/model/measurement/MeasurementModel.java
trunk/magicmapclient/src/net/sf/magicmap/client/model/node/AccessPointSeerNode.java
trunk/magicmapclient/src/net/sf/magicmap/client/model/node/NodeModel.java
trunk/magicmapclient/src/net/sf/magicmap/client/plugin/PluginManager.java
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/MapView.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/MapView.java 2007-01-21 12:01:13 UTC (rev 513)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/MapView.java 2007-01-21 16:35:03 UTC (rev 514)
@@ -242,8 +242,7 @@
MagicMetric magicMetric = new MagicMetric();
NodeMetricManager metrics = new NodeMetricManager(magicMetric);
metrics.addMetric(InfoObjectNode.class, InfoObjectNode.class, new InfoNodeMetric());
- layoutModel = new JungNodePlacer();
- getModel().setNodePlacer(layoutModel);
+ layoutModel = (JungNodePlacer) getModel().getNodePlacer();
graph = layoutModel;// new DirectedSparseGraph();
graphdraw = new PACWGraphDraw(layoutModel);
graphdraw.setVisible(false);
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/JungNodePlacer.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/JungNodePlacer.java 2007-01-21 12:01:13 UTC (rev 513)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/JungNodePlacer.java 2007-01-21 16:35:03 UTC (rev 514)
@@ -31,387 +31,390 @@
*/
public class JungNodePlacer extends DirectedSparseGraph implements INodePlacer, NodeModelConstants {
- /**
- * Logger
- */
- private static final Log log = LogFactory.getLog(JungNodePlacer.class);
+ /**
+ * Logger
+ */
+ private static final Log log = LogFactory.getLog(JungNodePlacer.class);
- /**
- *
- */
- private static final class DefaultSettings extends LayoutSettings {
+ /**
+ *
+ */
+ private static final class DefaultSettings extends LayoutSettings {
- }
+ }
- /**
- *
- */
- public static final LayoutSettings DEFAULT_SETTINGS = new DefaultSettings();
+ /**
+ *
+ */
+ public static final LayoutSettings DEFAULT_SETTINGS = new DefaultSettings();
- /**
- * Used to find the Vertex representing a node.
- */
- private final Map<Node, Vertex> nodeVertexMapping = new HashMap<Node, Vertex>();
+ /**
+ * Used to find the Vertex representing a node.
+ */
+ private final Map<Node, Vertex> nodeVertexMapping = new HashMap<Node, Vertex>();
- /**
- *
- */
- private final SpringLayout layout;
+ /**
+ *
+ */
+ private final SpringLayout layout;
- /**
- * Calculates the layout in a background thread.
- */
- private final LayoutWorker worker;
+ /**
+ * Calculates the layout in a background thread.
+ */
+ private final LayoutWorker worker;
- private boolean workerPaused;
+ private boolean workerPaused;
- private boolean workerRunning;
+ private boolean workerRunning;
- /**
- * Werden f\xFCr die Handler ben\xF6tigt
- */
- private HashMap<ClientNode, HashSet<LocationNode>> clientLocationMap;
+ /**
+ * Werden f\xFCr die Handler ben\xF6tigt
+ */
+ private HashMap<ClientNode, HashSet<LocationNode>> clientLocationMap;
- /**
- * Werden f\xFCr die Handler ben\xF6tigt
- */
- private HashMap<LocationNode, HashSet<LocationNode>> locationLocationMap;
+ /**
+ * Werden f\xFCr die Handler ben\xF6tigt
+ */
+ private HashMap<LocationNode, HashSet<LocationNode>> locationLocationMap;
- /**
- * Werden f\xFCr die Handler ben\xF6tigt
- */
- private StringLabeller labeller;
+ /**
+ * Werden f\xFCr die Handler ben\xF6tigt
+ */
+ private StringLabeller labeller;
- /**
- * A Factory for the NodeUpdateHandler.
- * @see NodeUpdateHandler
- */
- private final NodeHandlerFactory nodeHandler = new NodeHandlerFactory();
+ /**
+ * A Factory for the NodeUpdateHandler.
+ * @see NodeUpdateHandler
+ */
+ private final NodeHandlerFactory nodeHandler = new NodeHandlerFactory();
- /**
- * Dieser Konstruktor ist der Standart.
- *
- * @param model
- * das Knotenmodel.
- */
- public JungNodePlacer() {
- this(JungNodePlacer.DEFAULT_SETTINGS, new MagicMetric());
- }
- /**
- *
- * @param settings
- * @param metric
- */
- public JungNodePlacer(LayoutSettings settings, NodeModelMetric metric) {
- super();
+ public JungNodePlacer() {
+ this(JungNodePlacer.DEFAULT_SETTINGS, new MagicMetric());
+ }
- this.clientLocationMap = new HashMap<ClientNode, HashSet<LocationNode>>();
- this.locationLocationMap = new HashMap<LocationNode, HashSet<LocationNode>>();
- this.layout = new MagicLayout(this, metric, settings);
- this.worker = new LayoutWorker(this.layout, new Dimension(800, 600));
- this.workerRunning = false;
- this.workerPaused = false;
+ /**
+ *
+ * @param settings
+ * @param metric
+ */
+ public JungNodePlacer(LayoutSettings settings, NodeModelMetric metric) {
+ super();
- this.labeller = StringLabeller.getLabeller(this);
+ this.clientLocationMap = new HashMap<ClientNode, HashSet<LocationNode>>();
+ this.locationLocationMap = new HashMap<LocationNode, HashSet<LocationNode>>();
+ this.layout = new MagicLayout(this, metric, settings);
+ this.worker = new LayoutWorker(this.layout, new Dimension(800, 600));
+ this.workerRunning = false;
+ this.workerPaused = false;
- initNodeHandler();
- }
+ this.labeller = StringLabeller.getLabeller(this);
- /**
- * Initilisiert die Handler
- *
- */
- private void initNodeHandler(){
- addNodeUpdateHandler(new FixStateHandler(this.nodeVertexMapping, this.layout));
- addNodeUpdateHandler(new LabelChangeHandler(this.labeller, this.nodeVertexMapping));
- addNodeUpdateHandler(new PositionUpdateHandler(this.nodeVertexMapping, this.layout));
- addNodeUpdateHandler(new SeeAccessPointHandler(this.clientLocationMap, this.locationLocationMap));
- addNodeUpdateHandler(new NotSeeAccessPointHandler(this.clientLocationMap, this.locationLocationMap));
- addNodeUpdateHandler(new InfoNodeHandler());
- addNodeUpdateHandler(new AccessPointHiddenStateHandler());
- }
+ initNodeHandler();
+ }
- /**
- * Den Hintergrundthread zum Berechnen der Positionen starten! ;-)
- *
- */
- public void start(){
- this.worker.init();
- this.workerRunning = true;
- this.workerPaused = false;
- }
+ /**
+ * Initilisiert die Handler
+ *
+ */
+ private void initNodeHandler(){
+ addNodeUpdateHandler(new FixStateHandler(this.nodeVertexMapping, this.layout));
+ addNodeUpdateHandler(new LabelChangeHandler(this.labeller, this.nodeVertexMapping));
+ addNodeUpdateHandler(new PositionUpdateHandler(this.nodeVertexMapping, this.layout));
+ addNodeUpdateHandler(new SeeAccessPointHandler(this.clientLocationMap, this.locationLocationMap));
+ addNodeUpdateHandler(new NotSeeAccessPointHandler(this.clientLocationMap, this.locationLocationMap));
+ addNodeUpdateHandler(new InfoNodeHandler());
+ addNodeUpdateHandler(new AccessPointHiddenStateHandler());
+ }
- /**
- * Sets the size of our layout. should be the same as the current map.
- * @param width shoulde be the maps width.
- * @param height
- */
- public void setSize(int width, int height){
- this.layout.resize(new Dimension(width, height));
- }
+ /**
+ * Den Hintergrundthread zum Berechnen der Positionen starten! ;-)
+ *
+ */
+ public void start(){
+ this.worker.init();
+ this.workerRunning = true;
+ this.workerPaused = false;
+ }
- /**
- * F\xFCgt einen neuen Knoten ein.
- */
- public void insertNode(Node node){
- Vertex v = null;
- int type = node.getType();
- // TODO das hier ist wahrlich haesslich....
+ /**
+ * Sets the size of our layout. should be the same as the current map.
+ * @param width shoulde be the maps width.
+ * @param height
+ */
+ public void setSize(int width, int height){
+ this.layout.resize(new Dimension(width, height));
+ }
- if (type == NodeModelConstants.NODETYPE_CLIENT || type == NodeModelConstants.NODETYPE_LOCATION
- || type == NodeModelConstants.NODETYPE_ACCESSPOINT || type == NodeModelConstants.NODETYPE_GEOPOS
- || type == NodeModelConstants.NODETYPE_INFO || type == NodeModelConstants.NODETYPE_RFID_ANTENNA)
- v = addVertex(node);
- if (v != null) if (node.isFix())
- this.layout.setFix(v);
- else
- this.layout.unsetFix(v);
- }
+ /**
+ * F\xFCgt einen neuen Knoten ein.
+ */
+ public void insertNode(Node node){
+ Vertex v = null;
+ int type = node.getType();
+ // TODO das hier ist wahrlich haesslich....
- public void deleteNode(Node node){
- Vertex v = findVertex(node);
- removeVertex(v);
- }
+ if (type == NodeModelConstants.NODETYPE_CLIENT || type == NodeModelConstants.NODETYPE_LOCATION
+ || type == NodeModelConstants.NODETYPE_ACCESSPOINT || type == NodeModelConstants.NODETYPE_GEOPOS
+ || type == NodeModelConstants.NODETYPE_INFO || type == NodeModelConstants.NODETYPE_RFID_ANTENNA)
+ v = addVertex(node);
+ if (v != null) if (node.isFix())
+ this.layout.setFix(v);
+ else
+ this.layout.unsetFix(v);
+ }
- public SpringLayout getLayout(){
- return this.layout;
- }
+ public void deleteNode(Node node){
+ Vertex v = findVertex(node);
+ if (v != null){
- /**
- * F\xFCgt den Knoten ein um seine Position etc zu berechnen.
- *
- * @param node der neue Knoten.
- * @see NodeModelListener
- */
- public void nodeAddedEvent(Node node){
- insertNode(node);
- }
+ }
+ super.removeVertex(v);
+ this.nodeVertexMapping.remove(node);
+ }
- /**
- * Reagiert auf ver\xE4nderungen in den Knoten oder im Model.
- * Leitet die Anfragen an einen nodeHandler weiter. Wird vom NodeModel aufgerufen.
- *
- * @param node der neue oder ge\xE4nderte Knoten
- * @param type der Typ des Events. (Enum nutzen)?
- * @param data ---?
- * @see NodeModelListener, INodeModel, NodeModel
- */
- public void updateNode(Node node, int type, Object data){
- // first try if we have a handler for this event.
- if (!this.nodeHandler.handleNodeUpdated(node, type, data, this)) if (type == NodeModelConstants.UPDATE_CLEAR) {
- this.worker.suspend(); // stopGraph();
- // this.CALIBRATION_FACTOR_AP = 1.0;
- // this.CALIBRATION_FACTOR_LC = 1.0;
- this.clientLocationMap.clear();
- this.removeAllEdges();
- this.removeAllVertices();
- this.layout.update();
- this.nodeVertexMapping.clear();
- this.worker.unsuspend();
- } else if (type == NodeModelConstants.UPDATE_RESCAN)
- this.layout.update();
- else
- JungNodePlacer.log.debug("Event von typ: " + type + " ist unbekannt");
- }
+ public SpringLayout getLayout(){
+ return this.layout;
+ }
- public void nodeRemovedEvent(Node node){
- removeVertex(node);
- this.nodeVertexMapping.remove(node);
- }
+ /**
+ * F\xFCgt den Knoten ein um seine Position etc zu berechnen.
+ *
+ * @param node der neue Knoten.
+ * @see NodeModelListener
+ */
+ public void nodeAddedEvent(Node node){
+ insertNode(node);
+ }
- public Vertex findVertex(Node node){
- return this.nodeVertexMapping.get(node);
- }
+ /**
+ * Reagiert auf ver\xE4nderungen in den Knoten oder im Model.
+ * Leitet die Anfragen an einen nodeHandler weiter. Wird vom NodeModel aufgerufen.
+ *
+ * @param node der neue oder ge\xE4nderte Knoten
+ * @param type der Typ des Events. (Enum nutzen)?
+ * @param data ---?
+ * @see NodeModelListener, INodeModel, NodeModel
+ */
+ public void updateNode(Node node, int type, Object data){
+ // first try if we have a handler for this event.
+ if (!this.nodeHandler.handleNodeUpdated(node, type, data, this)) {
+ if (type == NodeModelConstants.UPDATE_CLEAR) {
+ this.worker.suspend(); // stopGraph();
+ // this.CALIBRATION_FACTOR_AP = 1.0;
+ // this.CALIBRATION_FACTOR_LC = 1.0;
+ this.clientLocationMap.clear();
+ this.removeAllEdges();
+ this.removeAllVertices();
+ this.layout.update();
+ this.nodeVertexMapping.clear();
+ this.worker.unsuspend();
+ } else if (type == NodeModelConstants.UPDATE_RESCAN)
+ this.layout.update();
+ else
+ JungNodePlacer.log.debug("Event von typ: " + type + " ist unbekannt");
+ }
+ }
- /**
- * Verwandelt Node in Vertex und fuegt diesen in den Graphen ein. Es wird
- * keine Ruecksicht auf den Typ des Knotens genommen. Eventuelle implizite
- * Kanten muss der Aufrufer erstellen.
- *
- * @param node
- * @return
- */
- public Vertex addVertex(Node node){
- if (findVertex(node) == null) {
+ public void nodeRemovedEvent(Node node){
+ removeVertex(node);
+ this.nodeVertexMapping.remove(node);
+ }
- System.out.println("Adding " + node.getDisplayName());
+ public Vertex findVertex(Node node){
+ return this.nodeVertexMapping.get(node);
+ }
- Vertex v = new DirectedSparseVertex();
- synchronized (this) {
- this.worker.suspend();
- this.nodeVertexMapping.put(node, v);
- v.addUserDatum(LayoutSettings.NODE_KEY, node, UserData.SHARED);
+ /**
+ * Verwandelt Node in Vertex und fuegt diesen in den Graphen ein. Es wird
+ * keine Ruecksicht auf den Typ des Knotens genommen. Eventuelle implizite
+ * Kanten muss der Aufrufer erstellen.
+ *
+ * @param node
+ * @return
+ */
+ public Vertex addVertex(Node node){
+ if (findVertex(node) == null) {
- addVertex(v);
+ System.out.println("Adding " + node.getDisplayName());
- ((SpringLayout) this.worker.getGraphLayout()).update();
- if (node.getX() >= 0 && node.getY() >= 0) this.layout.forceMove(v, node.getX(), node.getY());
- this.worker.unsuspend();
+ Vertex v = new DirectedSparseVertex();
+ synchronized (this) {
+ this.worker.suspend();
+ this.nodeVertexMapping.put(node, v);
+ v.addUserDatum(LayoutSettings.NODE_KEY, node, UserData.SHARED);
- }
- return v;
- } else {
- System.err.print("Vertex exists:");
- return null;
- }
+ addVertex(v);
- }
+ ((SpringLayout) this.worker.getGraphLayout()).update();
+ if (node.getX() >= 0 && node.getY() >= 0) this.layout.forceMove(v, node.getX(), node.getY());
+ this.worker.unsuspend();
- /**
- *
- */
- public void startNodePlacer(){
- start();
- }
+ }
+ return v;
+ } else {
+ System.err.print("Vertex exists:");
+ return null;
+ }
- /**
- *
- */
- public void stopNodePlacer(){
- this.worker.stop();
+ }
- }
+ /**
+ *
+ */
+ public void startNodePlacer(){
+ start();
+ }
- /**
- *
- */
- public void pauseNodePlacer(boolean pause){
- if (pause && !isPaused()) {
- this.worker.suspend();
- this.workerPaused = true;
- } else if (!pause && isPaused()) {
- this.worker.unsuspend();
- this.workerPaused = false;
+ /**
+ *
+ */
+ public void stopNodePlacer(){
+ this.worker.stop();
- }
- }
+ }
- public boolean isPaused(){
- return this.workerRunning && this.workerPaused;
- }
+ /**
+ *
+ */
+ public void pauseNodePlacer(boolean pause){
+ if (pause && !isPaused()) {
+ this.worker.suspend();
+ this.workerPaused = true;
+ } else if (!pause && isPaused()) {
+ this.worker.unsuspend();
+ this.workerPaused = false;
- /**
- * F\xFCgt eine gerichtete Kante von Knoten node1 zu node2 hinzu.
- *
- * Das Gewicht der Kante
- * @param node1
- * @param node2
- * @return
- */
- public IMagicEdge addEdge(Node node1, Node node2){
- if (node1 == node2) return null;
- Vertex v = findVertex(node1);
- Vertex w = findVertex(node2);
+ }
+ }
- Edge e = v.findEdge(w);
- if (e != null)
- return (IMagicEdge) e;
- else {
- JungEdge edge = new JungEdge(v,w);
- this.worker.suspend(); // stopGraph();
- addEdge(edge);
- this.layout.update();
- this.worker.unsuspend(); // resumeGraph();
- return edge;
- }
- }
+ public boolean isPaused(){
+ return this.workerRunning && this.workerPaused;
+ }
- /**
- * F\xFCgt eine Jungkante hinzu. wird intern verwendet.
- *
- * @param v1
- * @param v2
- * @return
- */
- private Edge addEdge(Vertex v1, Vertex v2){
- if (v1 == v2) return null;
- Edge e = v1.findEdge(v2);
- if (e != null)
- return e;
- else {
- DirectedSparseEdge edge = new DirectedSparseEdge(v1, v2);
- this.worker.suspend(); // stopGraph();
- addEdge(edge);
- this.layout.update();
- this.worker.unsuspend(); // resumeGraph();
- return edge;
- }
- }
+ /**
+ * F\xFCgt eine gerichtete Kante von Knoten node1 zu node2 hinzu.
+ *
+ * Das Gewicht der Kante
+ * @param node1
+ * @param node2
+ * @return
+ */
+ public IMagicEdge addEdge(Node node1, Node node2){
+ if (node1 == node2) return null;
+ Vertex v = findVertex(node1);
+ Vertex w = findVertex(node2);
- /**
- * L\xF6scht eine Kantew zwischen den beiden Knoten.
- * @param node1 Quelle der Kante.
- * @param node2 Ziel der Kante.
- */
- public void removeEdge(Node node1, Node node2){
- Vertex v = findVertex(node1);
- Vertex w = findVertex(node2);
- if (v != null && w != null) {
- this.worker.suspend();
- Set edges = getEdges();
- for (Object edge : edges) {
- Edge e = (Edge) edge;
- if (e.getIncidentVertices().contains(v) && e.getIncidentVertices().contains(w)) {
- removeEdge(e);
- break;
- }
- }
- this.layout.update();
- this.worker.unsuspend(); // resumeGraph();
- }
- }
+ Edge e = v.findEdge(w);
+ if (e != null)
+ return (IMagicEdge) e;
+ else {
+ JungEdge edge = new JungEdge(v,w);
+ this.worker.suspend(); // stopGraph();
+ addEdge(edge);
+ this.layout.update();
+ this.worker.unsuspend(); // resumeGraph();
+ return edge;
+ }
+ }
- /**
- * Entfernt alle Kanten an denen der Knoten beteiligt ist.
- *
- * @param node
- */
- @SuppressWarnings("unchecked")
- public void removeEdges(Node node){
- Vertex v = findVertex(node);
- if (v != null) {
- this.worker.suspend();
- Set edges = getEdges();
- // Kein Iterator direkt auf die Sets des
- // Graphen => Concurrent modification!
- ArrayList list = new ArrayList(edges);
- for (Object aList : list) {
- Edge e = (Edge) aList;
- if (e.getIncidentVertices().contains(v)) removeEdge(e);
- }
- this.layout.update();
- this.worker.unsuspend();
- }
- }
+ /**
+ * F\xFCgt eine Jungkante hinzu. wird intern verwendet.
+ *
+ * @param v1
+ * @param v2
+ * @return
+ */
+ private Edge addEdge(Vertex v1, Vertex v2){
+ if (v1 == v2) return null;
+ Edge e = v1.findEdge(v2);
+ if (e != null)
+ return e;
+ else {
+ DirectedSparseEdge edge = new DirectedSparseEdge(v1, v2);
+ this.worker.suspend(); // stopGraph();
+ addEdge(edge);
+ this.layout.update();
+ this.worker.unsuspend(); // resumeGraph();
+ return edge;
+ }
+ }
- /**
- * Entfernt Knoten aus dem Graph und eventuelle Kanten
- *
- * @param node
- */
- public void removeVertex(Node node){
- removeEdges(node);
- Vertex v = findVertex(node);
- if (v != null) {
- // Finde alle Kanten die beteiligt sind
- this.worker.suspend();
- this.labeller.removeLabel(node.getDisplayName());
- removeVertex(v);
- this.layout.update();
- this.worker.unsuspend();
+ /**
+ * L\xF6scht eine Kantew zwischen den beiden Knoten.
+ * @param node1 Quelle der Kante.
+ * @param node2 Ziel der Kante.
+ */
+ public void removeEdge(Node node1, Node node2){
+ Vertex v = findVertex(node1);
+ Vertex w = findVertex(node2);
+ if (v != null && w != null) {
+ this.worker.suspend();
+ Set edges = getEdges();
+ for (Object edge : edges) {
+ Edge e = (Edge) edge;
+ if (e.getIncidentVertices().contains(v) && e.getIncidentVertices().contains(w)) {
+ removeEdge(e);
+ break;
+ }
+ }
+ this.layout.update();
+ this.worker.unsuspend(); // resumeGraph();
+ }
+ }
- }
- }
+ /**
+ * Entfernt alle Kanten an denen der Knoten beteiligt ist.
+ *
+ * @param node
+ */
+ @SuppressWarnings("unchecked")
+ public void removeEdges(Node node){
+ Vertex v = findVertex(node);
+ if (v != null) {
+ this.worker.suspend();
+ Set edges = getEdges();
+ // Kein Iterator direkt auf die Sets des
+ // Graphen => Concurrent modification!
+ ArrayList list = new ArrayList(edges);
+ for (Object aList : list) {
+ Edge e = (Edge) aList;
+ if (e.getIncidentVertices().contains(v)){
+ super.removeEdge(e);
+ }
+ }
+ this.layout.update();
+ this.worker.unsuspend();
+ }
+ }
- /**
- *
- * @param handler
- */
+ /**
+ * Entfernt Knoten aus dem Graph und eventuelle Kanten
+ *
+ * @param node
+ */
+ public void removeVertex(Node node){
+ removeEdges(node);
+ Vertex v = findVertex(node);
+ if (v != null) {
+ nodeVertexMapping.remove(node);
+ this.worker.suspend();
+ this.labeller.removeLabel(node.getDisplayName());
+ super.removeVertex(v);
+ this.layout.update();
+ this.worker.unsuspend();
- public void addNodeUpdateHandler(NodeUpdateHandler handler){
- this.nodeHandler.addNodeUpdateHandler(handler);
+ }
+ }
- }
+ /**
+ *
+ * @param handler
+ */
+ public void addNodeUpdateHandler(NodeUpdateHandler handler){
+ this.nodeHandler.addNodeUpdateHandler(handler);
+
+ }
+
}
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/handler/NotSeeAccessPointHandler.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/handler/NotSeeAccessPointHandler.java 2007-01-21 12:01:13 UTC (rev 513)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/handler/NotSeeAccessPointHandler.java 2007-01-21 16:35:03 UTC (rev 514)
@@ -1,18 +1,14 @@
package net.sf.magicmap.client.model.location.jung.handler;
+import net.sf.magicmap.client.model.location.INodePlacer;
+import net.sf.magicmap.client.model.node.*;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import net.sf.magicmap.client.model.location.INodePlacer;
-import net.sf.magicmap.client.model.node.AccessPointNode;
-import net.sf.magicmap.client.model.node.ClientNode;
-import net.sf.magicmap.client.model.node.LocationNode;
-import net.sf.magicmap.client.model.node.Node;
-import net.sf.magicmap.client.model.node.NodeModelConstants;
-
public class NotSeeAccessPointHandler extends NodeWithLocationHandler {
public NotSeeAccessPointHandler(HashMap<ClientNode, HashSet<LocationNode>> clientLocationMap,
@@ -39,14 +35,14 @@
HashSet locations = getLocationsForClient(client);
Iterator it = locations.iterator();
// F\xFCr alle mit dem Client verbundenen Orte tue....
- while (it.hasNext()) {
- LocationNode l = (LocationNode) it.next();
- ArrayList intersection = getIntersection(l.getSeenAccessPoints(), client.getSeenAccessPoints());
- if (intersection.isEmpty()) // Keine gemeinsamen AccessPoints mehr.... l\xF6schen der
- // entsprechenden Kanten
- nodePlacer.removeEdge(client, l);
- }
- }
+ for (Object location : locations) {
+ LocationNode l = (LocationNode) location;
+ ArrayList intersection = getIntersection(l.getSeenAccessPoints(), client.getSeenAccessPoints());
+ if (intersection.isEmpty()) // Keine gemeinsamen AccessPoints mehr.... l\xF6schen der
+ // entsprechenden Kanten
+ nodePlacer.removeEdge(client, l);
+ }
+ }
}
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/model/measurement/MeasurementModel.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/model/measurement/MeasurementModel.java 2007-01-21 12:01:13 UTC (rev 513)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/model/measurement/MeasurementModel.java 2007-01-21 16:35:03 UTC (rev 514)
@@ -1,6 +1,7 @@
package net.sf.magicmap.client.model.measurement;
import net.sf.magicmap.client.interfaces.MeasurementModelListener;
+import net.sf.magicmap.client.measurement.Constants;
import net.sf.magicmap.client.model.node.AccessPointNode;
import net.sf.magicmap.client.model.node.AccessPointSeerNode;
import net.sf.magicmap.client.model.node.INodeModel;
@@ -35,28 +36,35 @@
if (apMap.put(client, ap)){
fireAccessPointAdded(client,ap);
}
- client.getModel().updateNode(client, 1, null);
+ //client.getModel().updateNode(client, NodeModelConstants.UPDATE_SEESACCESSPOINT, null);
}
public void updateScanResult(AccessPointSeerNode client, String apMac, double signalLevel){
SeenAccessPoint accessPoint = getAccessPoint(client, apMac);
final INodeModel nodeModel = client.getModel();
+
+
+
if (accessPoint == null) {
+ // ein toter ap.....
+ if (signalLevel <= -Constants.MIN_SIGNALLEVEL) return;
+
accessPoint = new SeenAccessPoint(apMac, signalLevel);
addAccessPoint(client, accessPoint);
AccessPointNode apNode = nodeModel.findAccessPoint(apMac);
- if (apNode == null){
+ if (apNode == null ){
nodeModel.addNode(new AccessPointNode(apMac, nodeModel));
apNode = nodeModel.findAccessPoint(apMac);
}
client.setSignalLevelForAcessPoint(apNode, signalLevel);
}else{
- if (signalLevel != 0){
+ if (signalLevel > -Constants.MIN_SIGNALLEVEL){
accessPoint.addSignalLevel(signalLevel);
}else{
accessPoint.addDeadSignal();
}
if (accessPoint.isTotallyDead()){
+ removeAccessPoint(client, accessPoint);
client.notSeesAccessPoint(nodeModel.findAccessPoint(apMac));
}
else{
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/model/node/AccessPointSeerNode.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/model/node/AccessPointSeerNode.java 2007-01-21 12:01:13 UTC (rev 513)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/model/node/AccessPointSeerNode.java 2007-01-21 16:35:03 UTC (rev 514)
@@ -89,6 +89,7 @@
if (apEdges.containsKey(ap.getMacAddress())){
apEdges.remove(ap.getMacAddress());
getModel().updateNode(this, NodeModelConstants.UPDATE_NOTSEESACCESSPOINT, ap);
+ getModel().removeNode(ap);
}
}
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/model/node/NodeModel.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/model/node/NodeModel.java 2007-01-21 12:01:13 UTC (rev 513)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/model/node/NodeModel.java 2007-01-21 16:35:03 UTC (rev 514)
@@ -77,13 +77,15 @@
public void removeNode(Node node){
if (!this.nodes.containsKey(node.getName())) return;
this.nodes.remove(node.getName());
+
+ if (node.getType() == NodeModelConstants.NODETYPE_ACCESSPOINT){
+ this.accesspoints.remove(((AccessPointNode) node).getMacAddress());
+ }
+ // aus dem layout entfernen!
this.placer.deleteNode(node);
- if (node.getType() == NodeModelConstants.NODETYPE_ACCESSPOINT) // Wenn AccessPoint, dann nach MAC-Adresse extra hashen
- this.accesspoints.remove(((AccessPointNode) node).getMacAddress());
for (NodeModelListener listener : this.listeners) {
- NodeModelListener l = (NodeModelListener) listener;
- l.nodeRemovedEvent(node);
+ listener.nodeRemovedEvent(node);
}
}
@@ -96,6 +98,7 @@
*/
public void updateNode(Node node, int type, Object data){
this.placer.updateNode(node, type, data);
+
for (NodeModelListener listener : this.listeners) {
NodeModelListener l = (NodeModelListener) listener;
l.nodeUpdatedEvent(node, type, data);
@@ -251,6 +254,9 @@
}
public void setNodePlacer(INodePlacer placer) {
+ if (this.placer != null){
+ this.placer.stopNodePlacer();
+ }
this.placer = placer;
}
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/plugin/PluginManager.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/plugin/PluginManager.java 2007-01-21 12:01:13 UTC (rev 513)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/plugin/PluginManager.java 2007-01-21 16:35:03 UTC (rev 514)
@@ -22,6 +22,7 @@
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import java.awt.*;
+import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.*;
@@ -109,11 +110,25 @@
controller.getMapView().addAncestorListener(new AncestorAdaptor() {
@Override
public void ancestorAdded(AncestorEvent event){
- MainGUI mainGUI = MainGUI.getInstance();
- JMenuBar bar = mainGUI.getJMenuBar();
- JMenu jMenu = bar.getMenu(2);
+ final MainGUI mainGUI = MainGUI.getInstance();
+ final JMenuBar bar = mainGUI.getJMenuBar();
+ final JMenu jMenu = bar.getMenu(2);
jMenu.addSeparator();
jMenu.add(new ShowPluginsAction(mainGUI, PluginManager.this));
+ jMenu.addSeparator();
+ for (IPlugin plugin: plugins.values()){
+ if (plugin instanceof UserInterface){
+ final UserInterface ui = (UserInterface)plugin;
+ jMenu.add(new AbstractAction(plugin.getPluginInfos().getName()){
+ public void actionPerformed(ActionEvent e) {
+ JDialog d = new JDialog(mainGUI);
+ d.setContentPane(ui.visualProxy("",null));
+ d.pack();
+ d.setVisible(true);
+ }
+ });
+ }
+ }
}
});
@@ -160,6 +175,7 @@
plugin.getPluginInfos().getName(),
plugin.getVersion(), plugin.getPluginInfos()}
);
+
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|