|
From: Johannes Z. <jza...@us...> - 2006-02-26 11:38:07
|
Update of /cvsroot/magicmap/magicmapclient/src/net/sf/magicmap/client/model/node In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8830/src/net/sf/magicmap/client/model/node Modified Files: GeoPosNode.java Node.java MapNode.java NodeModel.java GeoPos.java Log Message: Bugfixes f. schnellen Kartenwechsel Geopositionen implementiert Index: MapNode.java =================================================================== RCS file: /cvsroot/magicmap/magicmapclient/src/net/sf/magicmap/client/model/node/MapNode.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MapNode.java 20 Feb 2006 08:50:09 -0000 1.3 --- MapNode.java 26 Feb 2006 10:20:57 -0000 1.4 *************** *** 6,9 **** --- 6,10 ---- import javax.swing.SwingUtilities; + import net.sf.magicmap.client.gui.MainGUI; import net.sf.magicmap.client.interfaces.MapCallback; import net.sf.magicmap.client.meta.MapInfo; *************** *** 40,43 **** --- 41,56 ---- return NodeModel.NODETYPE_MAP; } + + /** + * Sets the map info object + * @param mapDTO + */ + public void setMapInfo(MapDTO mapDTO) { + mapInfo = new MapInfo(); + mapInfo.height = mapDTO.getImageHeight().intValue(); + mapInfo.width = mapDTO.getImageWidth().intValue(); + mapInfo.name = mapDTO.getName(); + mapInfo.imageURL = mapDTO.getImageURL().toString(); + } /* (non-Javadoc) *************** *** 55,58 **** --- 68,72 ---- mapInfo.name = mapDTO.getName(); mapInfo.imageURL = mapDTO.getImageURL().toString(); + MainGUI.getInstance().loadMap(mapInfo); } }); Index: NodeModel.java =================================================================== RCS file: /cvsroot/magicmap/magicmapclient/src/net/sf/magicmap/client/model/node/NodeModel.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NodeModel.java 20 Feb 2006 08:50:20 -0000 1.3 --- NodeModel.java 26 Feb 2006 10:20:57 -0000 1.4 *************** *** 18,77 **** * * @author thuebner */ public class NodeModel { ! public static final int UPDATE_SEESACCESSPOINT = 0; ! public static final int UPDATE_NOTSEESACCESSPOINT = 1; ! public static final int UPDATE_LABELCHANGED = 2; ! public static final int UPDATE_FIXSTATE = 3; ! public static final int UPDATE_CLEAR = 4; ! public static final int UPDATE_POSITION = 5; ! public static final int UPDATE_RESCAN = 6; ! public static final int NODETYPE_ACCESSPOINT = 1; ! public static final int NODETYPE_CLIENT = 2; ! public static final int NODETYPE_LOCATION = 3; ! // TODO: this does not really fulfil the concept, has to extended later ! public static final int NODETYPE_MAP = 4; ! private HashMap nodes; ! private HashMap accesspoints; ! private ArrayList listeners; ! /** ! * Erzeugt neues leeres Model ! * ! */ ! public NodeModel() { ! this.nodes = new HashMap(); ! this.accesspoints = new HashMap(); ! this.listeners = new ArrayList(); ! } ! public void addNode(Node node){ ! this.nodes.put(node.getName(), node); ! if (node.getType() == NODETYPE_ACCESSPOINT){ ! // Wenn AccessPoint, dann nach MAC-Adresse extra hashen ! this.accesspoints.put(((AccessPointNode) node).getMacAddress(), node); ! } ! Iterator it = listeners.iterator(); ! while (it.hasNext()){ ! NodeModelListener l = (NodeModelListener) it.next(); ! l.nodeAddedEvent(node); ! } ! } ! public void removeNode(Node node){ ! this.nodes.remove(node.getName()); ! if (node.getType() == NODETYPE_ACCESSPOINT){ ! // Wenn AccessPoint, dann nach MAC-Adresse extra hashen ! this.accesspoints.remove(((AccessPointNode) node).getMacAddress()); ! } ! Iterator it = listeners.iterator(); ! while (it.hasNext()){ ! NodeModelListener l = (NodeModelListener) it.next(); ! l.nodeRemovedEvent(node); ! } ! } public void fireSeesAccessPoint(Node node, AccessPointNode ap){ --- 18,92 ---- * * @author thuebner + * + * Extended to be also able to handle other nodes + * (maps (as a special case), geopoints, info objects, rfid antennas, etc.) + * + * @author Johannes Zapotoczky (joh...@za...) + * */ public class NodeModel { ! public static final int UPDATE_SEESACCESSPOINT = 0; ! public static final int UPDATE_NOTSEESACCESSPOINT = 1; ! public static final int UPDATE_LABELCHANGED = 2; ! public static final int UPDATE_FIXSTATE = 3; ! public static final int UPDATE_CLEAR = 4; ! public static final int UPDATE_POSITION = 5; ! public static final int UPDATE_RESCAN = 6; ! public static final int NODETYPE_ACCESSPOINT = 1; ! public static final int NODETYPE_CLIENT = 2; ! public static final int NODETYPE_LOCATION = 3; ! public static final int NODETYPE_MAP = 4; ! public static final int NODETYPE_GEOPOS = 5; ! private HashMap nodes; ! private HashMap accesspoints; ! private ArrayList listeners; ! /** ! * Erzeugt neues leeres Model ! * ! */ ! public NodeModel() { ! this.nodes = new HashMap(); ! this.accesspoints = new HashMap(); ! this.listeners = new ArrayList(); ! } ! /** ! * Add a new node ! * @param node ! */ ! public void addNode(Node node) { ! this.nodes.put(node.getName(), node); ! // special handling for APs ! if (node.getType() == NODETYPE_ACCESSPOINT){ ! // Wenn AccessPoint, dann nach MAC-Adresse extra hashen ! this.accesspoints.put(((AccessPointNode) node).getMacAddress(), node); ! } ! Iterator it = listeners.iterator(); ! while (it.hasNext()){ ! NodeModelListener l = (NodeModelListener) it.next(); ! l.nodeAddedEvent(node); ! } ! } ! /** ! * Remove a node ! * @param node ! */ ! public void removeNode(Node node){ ! this.nodes.remove(node.getName()); ! if (node.getType() == NODETYPE_ACCESSPOINT){ ! // Wenn AccessPoint, dann nach MAC-Adresse extra hashen ! this.accesspoints.remove(((AccessPointNode) node).getMacAddress()); ! } ! Iterator it = listeners.iterator(); ! while (it.hasNext()) { ! NodeModelListener l = (NodeModelListener) it.next(); ! l.nodeRemovedEvent(node); ! } ! } public void fireSeesAccessPoint(Node node, AccessPointNode ap){ *************** *** 117,130 **** } ! public void addNodeModelListener(NodeModelListener l){ ! if (!listeners.contains(l)){ ! this.listeners.add(l); ! Iterator it = nodes.values().iterator(); ! while (it.hasNext()){ ! Node node = (Node) it.next(); ! l.nodeAddedEvent(node); ! } ! } ! } public void removeNodeModelListener(NodeModelListener l){ --- 132,146 ---- } ! ! public void addNodeModelListener(NodeModelListener nodeModelListener) { ! if (!listeners.contains(nodeModelListener)) { ! this.listeners.add(nodeModelListener); ! Iterator nodesIterator = nodes.values().iterator(); ! while (nodesIterator.hasNext()) { ! Node node = (Node) nodesIterator.next(); ! nodeModelListener.nodeAddedEvent(node); ! } ! } ! } public void removeNodeModelListener(NodeModelListener l){ Index: GeoPos.java =================================================================== RCS file: /cvsroot/magicmap/magicmapclient/src/net/sf/magicmap/client/model/node/GeoPos.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GeoPos.java 23 Feb 2006 18:34:38 -0000 1.1 --- GeoPos.java 26 Feb 2006 10:20:57 -0000 1.2 *************** *** 180,197 **** public Integer getLongitudeDegrees() { ! return new Integer(longitude % GEO_MS2DEGREES_FACTOR); } public Integer getLongitudeMinutes() { ! return new Integer(longitude % (GEO_MS2DEGREES_FACTOR / 60)); } public Integer getLongitudeSeconds() { ! return new Integer(0); } public String toString() { return "longitude: " + this.longitude + ", latitude: " + --- 180,223 ---- public Integer getLongitudeDegrees() { ! return new Integer(longitude / GEO_MS2DEGREES_FACTOR); } public Integer getLongitudeMinutes() { ! int minutes = longitude % GEO_MS2DEGREES_FACTOR; ! return new Integer(minutes / 60 / GEO_M2N_FACTOR); ! } public Integer getLongitudeSeconds() { ! int minutes = longitude % GEO_MS2DEGREES_FACTOR; ! int seconds = minutes % 60000; ! //TODO: vernünftige Rundung einbauen!! ! return new Integer(seconds / GEO_M2N_FACTOR); } + public Integer getLatitudeDegrees() { + return new Integer(latitude / GEO_MS2DEGREES_FACTOR); + } + + + public Integer getLatitudeMinutes() { + int minutes = latitude % GEO_MS2DEGREES_FACTOR; + return new Integer(minutes / 60 / GEO_M2N_FACTOR); + + } + + + public Integer getLatitudeSeconds() { + int minutes = latitude % GEO_MS2DEGREES_FACTOR; + int seconds = minutes % 60000; + //TODO: vernünftige Rundung einbauen!! + return new Integer(seconds / GEO_M2N_FACTOR); + } + + + public String toString() { return "longitude: " + this.longitude + ", latitude: " + *************** *** 199,202 **** --- 225,237 ---- ", exactitude: " + this.exactitude; } + + public String getStringRepresentation() { + return getLongitudeDegrees().intValue() + "° " + + getLongitudeMinutes().intValue() + "' " + + getLongitudeSeconds().intValue() + "'' :: " + + getLatitudeDegrees().intValue() + "° " + + getLatitudeMinutes().intValue() + "' " + + getLatitudeSeconds().intValue() + "''"; + } public int getLatitude() { Index: Node.java =================================================================== RCS file: /cvsroot/magicmap/magicmapclient/src/net/sf/magicmap/client/model/node/Node.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Node.java 8 Jul 2005 20:12:11 -0000 1.4 --- Node.java 26 Feb 2006 10:20:57 -0000 1.5 *************** *** 14,121 **** public abstract class Node { ! private static int counter = 0; ! private String name; // Beschreibung ! private String internal; ! protected boolean fix; // Fest oder beweglich ! protected boolean update = false; // wenn Referenzpunktupdate = true ! private int x; // Position (nur wenn fix = true) ! private int y; ! private long id; ! private NodeModel model; ! /** ! * Erzeugt leeren Knoten. Ein Knoten muß über sein ! * NodeModel bescheid wissen, damit er verschiedene ! * Dinge abfragen kann. Nur so können beliebige Knotentypen ohne ! * Änderungen an NodeModel hinzugefügt werden. Siehe Methode ! * getNeighbors, welche vom Knotentyp abhängig mit Hilfe von NodeModel ! * potenzielle Nachbarknoten des Knoten sucht. ! * @param model ! */ ! public Node(NodeModel model) { ! this.model = model; ! counter++; ! // Eindeutigen Defaultnamen setzen ! this.internal = this.getClass().getName(); ! this.internal = internal.substring(this.internal.lastIndexOf('.') + 1) + counter; ! this.name = this.internal; ! this.id = -1; ! } ! public String getDisplayName(){ ! return this.name; ! } ! public boolean isUpdate(){ ! return update; ! } ! public void setUpdate(boolean newupdate){ ! this.update = newupdate; ! this.model.updateNode(this,NodeModel.UPDATE_RESCAN,null); ! } ! public boolean isFix(){ ! return fix; ! } ! public void setFix(boolean fix){ ! this.fix = fix; ! this.model.updateNode(this, NodeModel.UPDATE_FIXSTATE, null); ! } ! public String getName(){ ! return name; ! } ! public final void setName(String name){ ! String oldname = this.name; ! this.name = name; ! if (model.nodeExists(oldname)) ! model.rehashNode(this, oldname); ! } ! public int getX(){ ! return x; ! } ! public int getY(){ ! return y; ! } ! public void setPositionSilent(int x, int y){ ! this.x = x; ! this.y = y; ! } ! public void setPosition(int x, int y){ ! setPositionSilent(x, y); ! model.updateNode(this, NodeModel.UPDATE_POSITION, null); ! } ! public abstract ArrayList getNeighbors(); ! public NodeModel getModel(){ ! return model; ! } ! public abstract int getType(); ! public int hashCode(){ ! return internal.hashCode(); ! } ! public String toString(){ ! return internal; ! } ! public long getId(){ ! return id; ! } ! public void setId(long id){ ! this.id = id; ! } } \ No newline at end of file --- 14,123 ---- public abstract class Node { ! private static int counter = 0; ! ! private String name; // Beschreibung ! private String internal; ! protected boolean fix; // Fest oder beweglich ! protected boolean update = false; // wenn Referenzpunktupdate = true ! private int x; // Position (nur wenn fix = true) ! private int y; ! private long id; ! private NodeModel model; ! ! /** ! * Erzeugt leeren Knoten. Ein Knoten muß über sein ! * NodeModel bescheid wissen, damit er verschiedene ! * Dinge abfragen kann. Nur so können beliebige Knotentypen ohne ! * Änderungen an NodeModel hinzugefügt werden. Siehe Methode ! * getNeighbors, welche vom Knotentyp abhängig mit Hilfe von NodeModel ! * potenzielle Nachbarknoten des Knoten sucht. ! * @param model ! */ ! public Node(NodeModel model) { ! this.model = model; ! counter++; ! // Eindeutigen Defaultnamen setzen ! this.internal = this.getClass().getName(); ! this.internal = internal.substring(this.internal.lastIndexOf('.') + 1) + counter; ! this.name = this.internal; ! this.id = -1; ! } ! public String getDisplayName(){ ! return this.name; ! } ! public boolean isUpdate(){ ! return update; ! } ! public void setUpdate(boolean newupdate){ ! this.update = newupdate; ! this.model.updateNode(this,NodeModel.UPDATE_RESCAN,null); ! } ! public boolean isFix(){ ! return fix; ! } ! public void setFix(boolean fix){ ! this.fix = fix; ! this.model.updateNode(this, NodeModel.UPDATE_FIXSTATE, null); ! } ! public String getName(){ ! return name; ! } ! public final void setName(String name){ ! String oldname = this.name; ! this.name = name; ! if (model.nodeExists(oldname)) ! model.rehashNode(this, oldname); ! } ! public int getX(){ ! return x; ! } ! public int getY(){ ! return y; ! } ! public void setPositionSilent(int x, int y){ ! this.x = x; ! this.y = y; ! } ! public void setPosition(int x, int y){ ! setPositionSilent(x, y); ! model.updateNode(this, NodeModel.UPDATE_POSITION, null); ! } ! public abstract ArrayList getNeighbors(); ! public NodeModel getModel(){ ! return model; ! } ! public abstract int getType(); ! public int hashCode(){ ! return internal.hashCode(); ! } ! public String toString(){ ! return internal; ! } ! public long getId(){ ! return id; ! } ! public void setId(long id){ ! this.id = id; ! } } \ No newline at end of file Index: GeoPosNode.java =================================================================== RCS file: /cvsroot/magicmap/magicmapclient/src/net/sf/magicmap/client/model/node/GeoPosNode.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GeoPosNode.java 23 Feb 2006 18:34:38 -0000 1.1 --- GeoPosNode.java 26 Feb 2006 10:20:57 -0000 1.2 *************** *** 11,14 **** --- 11,16 ---- */ public class GeoPosNode extends Node { + + private GeoPos geoPos; /** *************** *** 18,21 **** --- 20,41 ---- super(model); } + + public String getDisplayName() { + if (geoPos != null) { + return geoPos.getStringRepresentation(); + } else { + return super.getDisplayName(); + } + } + + + /** + * Set the internal geo pos object + * @param newGeoPos + */ + public void setGeoPos(GeoPos newGeoPos) { + this.geoPos = newGeoPos; + } + /* (non-Javadoc) *************** *** 33,38 **** @Override public int getType() { ! // TODO Auto-generated method stub ! return 0; } --- 53,57 ---- @Override public int getType() { ! return NodeModel.NODETYPE_GEOPOS; } |