|
From: <jan...@us...> - 2006-12-11 19:44:59
|
Revision: 491
http://svn.sourceforge.net/magicmap/?rev=491&view=rev
Author: jan_fride
Date: 2006-12-11 11:44:28 -0800 (Mon, 11 Dec 2006)
Log Message:
-----------
1) Edges, just an idea.
2) made the MapDialog nicer. maps with invalid image urls are marked as invalid.
Modified Paths:
--------------
trunk/magicmapclient/src/net/sf/magicmap/client/controller/SOAPServerManager.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/MainGUI.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/dialogs/LoadMapDialog.java
trunk/magicmapclient/src/net/sf/magicmap/client/model/location/INodePlacer.java
trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/JungNodePlacer.java
Added Paths:
-----------
trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/JungEdge.java
trunk/magicmapclient/src/net/sf/magicmap/client/model/node/IMagicEdge.java
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/controller/SOAPServerManager.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/controller/SOAPServerManager.java 2006-12-04 19:12:56 UTC (rev 490)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/controller/SOAPServerManager.java 2006-12-11 19:44:28 UTC (rev 491)
@@ -39,7 +39,7 @@
/**
* Managet die Client-Server-Kommunikation sowie die Verbindung selbst.
- *
+ *
* @author thuebner
*/
public class SOAPServerManager extends ServerManager {
@@ -62,7 +62,7 @@
/**
* Stellt Verbindung zum Server her
- *
+ *
*/
@Override
public void connect(final ServerConnectCallback callback){
@@ -93,7 +93,7 @@
}
/**
- *
+ *
* @param callback
*/
@Override
@@ -123,7 +123,7 @@
}
/**
- *
+ *
* @param name
* @param URL
* @param width
@@ -164,10 +164,12 @@
/**
* Liefert die eindeutigen Namen der auf dem Server angelegten Karten
* zur\xFCck.
- *
+ *
* @param callback
* MapNamesCallback Objekt welches das MapNamesCallback
* implementiert um die Kartennamen bzw. die
+ * @param openDialog
+ * momentan unbenutzt
*/
@Override
public void retrieveMapNames(final MapNamesCallback callback, final boolean openDialog){
@@ -197,7 +199,7 @@
/**
* L\xE4dt Daten zu einer Karte vom Server. Das Ergebniss wird \xFCber eine
* Callback Funktionen geliefert.
- *
+ *
* @param name
* @param callback
*/
@@ -247,7 +249,7 @@
/**
* Erzeugt einen Referenzpunkt auf dem Server
- *
+ *
* @param node
* @param callback
*/
@@ -282,7 +284,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see net.sf.magicmap.client.controller.ServerManager#createGeoPos(int,
* int, boolean, net.sf.magicmap.client.model.node.GeoPos,
* java.lang.String,
@@ -321,7 +323,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see net.sf.magicmap.client.controller.ServerManager#createInfoObject(int,
* int, boolean, net.sf.magicmap.client.model.node.InfoObject,
* java.lang.String,
@@ -340,12 +342,12 @@
synchronized (SOAPServerManager.mutex) {
try {
// SOAPServerManager.this.mapDelegate.createInfoObject(
- // sessionId,
- // mapName,
- // x,
- // y,
- // z,
- // infoObject.getName(),
+ // sessionId,
+ // mapName,
+ // x,
+ // y,
+ // z,
+ // infoObject.getName(),
// infoObject.getUrl(),
// infoObject.getType()
// );
@@ -364,7 +366,7 @@
/**
* Entfernt einen Referenzpunkt oder die Positionierung eines AccessPoints
* oder Clients mit gegebener Id vom Server
- *
+ *
* @param node
* @param callback
*/
@@ -394,7 +396,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see net.sf.magicmap.client.controller.ServerManager#deleteGeoPoint(long,
* java.lang.String,
* net.sf.magicmap.client.interfaces.DeletePositionCallback)
@@ -424,7 +426,7 @@
/**
* Bewegt einen Referenzpunkt oder die Positionierung eines AccessPoints
* oder Clients mit gegebener Id vom Server
- *
+ *
* @param node
* @param callback
*/
@@ -467,7 +469,7 @@
* Eine Position von (-1,-1) bedeutet, dass der Client nicht fixiert ist
* sondern frei beweglich ist. Es werden dann nur seine Signalst\xE4rken
* geupdatet.
- *
+ *
* @param x
* X-Koordinate bzgl. Map
* @param y
@@ -507,7 +509,7 @@
* Eine Position von (-1,-1) bedeutet, dass der Client nicht fixiert ist
* sondern frei beweglich ist. Es werden dann nur seine Signalst\xE4rken
* geupdatet.
- *
+ *
* @param x
* X-Koordinate bzgl. Map
* @param y
@@ -545,7 +547,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see net.sf.magicmap.client.controller.ServerManager#setAccessPointHiddenStatus(long,
* java.lang.String, java.lang.String, boolean,
* net.sf.magicmap.client.interfaces.PositionCallback)
@@ -576,7 +578,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see net.sf.magicmap.client.controller.ServerManager#fetchPositionsFromServer(net.sf.magicmap.client.interfaces.FetchPositionsCallback)
*/
@Override
@@ -618,7 +620,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see net.sf.magicmap.client.interfaces.ServerPollerListener#positionCreatedOrUpdatedOrDeleted(java.lang.String,
* long, net.sf.magicmap.client.delegate.dto.PositionDTO)
*/
@@ -674,7 +676,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see net.sf.magicmap.client.controller.ServerManager#reloadMap()
*/
@Override
@@ -689,7 +691,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see net.sf.magicmap.client.controller.ServerManager#closeMap()
*/
@Override
@@ -703,7 +705,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see net.sf.magicmap.client.controller.ServerManager#fetchGeoPointsFromServer(net.sf.magicmap.client.interfaces.FetchGeoPointsCallback)
*/
@Override
@@ -734,7 +736,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see net.sf.magicmap.client.controller.ServerManager#fetchMapsFromServer(net.sf.magicmap.client.interfaces.FetchMapsCallback)
*/
@Override
@@ -766,7 +768,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see net.sf.magicmap.client.controller.ServerManager#fetchInfoPointsFromServer(net.sf.magicmap.client.interfaces.FetchInfoPointsCallback)
*/
@Override
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/gui/MainGUI.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/MainGUI.java 2006-12-04 19:12:56 UTC (rev 490)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/MainGUI.java 2006-12-11 19:44:28 UTC (rev 491)
@@ -810,7 +810,8 @@
/* (non-Javadoc)
* @see net.sf.magicmap.client.interfaces.MapNamesCallback#mapNamesReceived(java.lang.String[])
*/
- public void addMapNamesToOutline(String[] names){
+ @Deprecated
+ public void addMapNamesToOutline(String[] names){
for (String element : names) {
MapNode node = new MapNode(new NodeModel());
Controller.getInstance().retrieveMap(element, node);
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/gui/dialogs/LoadMapDialog.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/dialogs/LoadMapDialog.java 2006-12-04 19:12:56 UTC (rev 490)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/dialogs/LoadMapDialog.java 2006-12-11 19:44:28 UTC (rev 491)
@@ -4,6 +4,7 @@
package net.sf.magicmap.client.gui.dialogs;
+import java.awt.Component;
import java.awt.Cursor;
import java.awt.Frame;
import java.awt.event.ActionEvent;
@@ -11,6 +12,9 @@
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
+import javax.swing.ComboBoxModel;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.DefaultListCellRenderer;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JList;
@@ -20,6 +24,7 @@
import javax.swing.border.EtchedBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
+import javax.swing.tree.DefaultMutableTreeNode;
import net.sf.magicmap.client.controller.Controller;
import net.sf.magicmap.client.gui.utils.GUIUtils;
@@ -28,6 +33,8 @@
import net.sf.magicmap.client.interfaces.LoadMapDialogListener;
import net.sf.magicmap.client.interfaces.MapCallback;
import net.sf.magicmap.client.meta.MapInfo;
+import net.sf.magicmap.client.model.node.INodeModel;
+import net.sf.magicmap.client.model.node.MapNode;
import net.sf.magicmap.server.dto.MapDTO;
import com.brunchboy.util.swing.relativelayout.RelativeLayout;
@@ -35,7 +42,7 @@
/**
* Ein Dialog zum Laden einer vorhandenen Karte
* @author thuebner
- *
+ *
* Refactored on 1.3.2006
* @author Johannes Zapotoczky <joh...@za...>
*/
@@ -54,6 +61,15 @@
private Cursor cursor;
private JButton ok;
+ private DefaultComboBoxModel mapModel;
+
+ /**
+ *
+ * @param owner used for Model Dialogs.
+ * @param maps th list of all maps on the server.
+ * @param listener ??
+ * @return the selected map.
+ */
public static MapInfo showDialog(Frame owner, String[] maps, LoadMapDialogListener listener){
LoadMapDialog d = new LoadMapDialog(owner, maps);
GUIUtils.locateOnScreen(d);
@@ -83,7 +99,32 @@
builder.setLeft("mapslabel", 10);
builder.setTop("mapslabel", 10);
- this.list = new JList(maps);
+ mapModel = new DefaultComboBoxModel();
+ for (String map: maps){
+ mapModel.addElement(new MapEntry(map));
+ }
+ this.list = new JList(mapModel);
+ list.setCellRenderer(new DefaultListCellRenderer(){
+
+ @Override
+ public Component getListCellRendererComponent(JList list, Object value, int arg2, boolean arg3, boolean arg4){
+ Component cellRenderer = super.getListCellRendererComponent(list, value, arg2, arg3, arg4);
+ MapEntry entry = (MapEntry)value;
+ switch (entry.status){
+ case 1:
+ setText("<html><strike>"+entry.name + "</strike></html>");
+ break;
+ case 2:
+ setText("<html><b>"+entry.name + "</b></html>");
+ break;
+ default:
+ setText(entry.name);
+ break;
+ }
+ return cellRenderer;
+ }
+
+ });
JScrollPane pane = new JScrollPane(this.list);
builder.add(pane, "list");
builder.setLeft("list", 10);
@@ -135,8 +176,9 @@
}
}
- /* (non-Javadoc)
- * @see net.sf.magicmap.client.interfaces.MapCallback#mapReceived(net.sf.magicmap.client.delegate.dto.MapDTO)
+ /**
+ * Callback. Tries to load the images map and if successfull enables th ok button and ads the
+ * map to the model.
*/
public void mapReceived(final MapDTO mapDTO){
try {
@@ -152,10 +194,25 @@
LoadMapDialog.this.info.imageURL = mapDTO.getImageURL().toString();
setCursor(new Cursor(Cursor.WAIT_CURSOR));
LoadMapDialog.this.preview.loadImage(LoadMapDialog.this.info.imageURL);
- if (LoadMapDialog.this.preview.getImageHeight() > -1)
+ if (LoadMapDialog.this.preview.getImageHeight() > -1){
LoadMapDialog.this.ok.setEnabled(true);
- else
+ INodeModel nodeModel = Controller.getInstance().getNodeModel();
+ MapNode node = new MapNode(nodeModel);
+ node.setDisplayName(mapDTO.getName());
+ node.setMapInfo(mapDTO);
+ nodeModel.addNode(node);
+ int selectedIndex = list.getSelectedIndex();
+ MapEntry defectMap = (MapEntry) mapModel.getElementAt(selectedIndex);
+ defectMap.status = 2;
+ }
+ else{
LoadMapDialog.this.ok.setEnabled(false);
+ int selectedIndex = list.getSelectedIndex();
+ MapEntry defectMap = (MapEntry) mapModel.getElementAt(selectedIndex);
+ defectMap.status = 1;
+ list.repaint();
+ }
+
setCursor(LoadMapDialog.this.cursor);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
@@ -185,8 +242,16 @@
*/
public void valueChanged(ListSelectionEvent e){
if (!e.getValueIsAdjusting()) {
- String map = (String) this.list.getSelectedValue();
+ String map = ((MapEntry) this.list.getSelectedValue()).name;
Controller.getInstance().retrieveMap(map, this);
}
}
+ private static final class MapEntry{
+ public MapEntry(String map){
+ name = map;
+ status = 0;
+ }
+ public final String name;
+ public int status;
+ }
}
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/model/location/INodePlacer.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/model/location/INodePlacer.java 2006-12-04 19:12:56 UTC (rev 490)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/model/location/INodePlacer.java 2006-12-11 19:44:28 UTC (rev 491)
@@ -3,6 +3,7 @@
import java.util.HashMap;
+import net.sf.magicmap.client.model.node.IMagicEdge;
import net.sf.magicmap.client.model.node.Node;
/**
@@ -38,7 +39,7 @@
* @param n2 das Ziel der Kante
* @return
*/
- public Object addEdge(Node n1, Node n2);
+ public IMagicEdge addEdge(Node n1, Node n2);
/**
* Löscht eine gerichtete Kante. (also nur eine Richtung).
@@ -99,7 +100,7 @@
}
/**
- *
+ *
* @param node
* @param type
* @param data
Added: trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/JungEdge.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/JungEdge.java (rev 0)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/JungEdge.java 2006-12-11 19:44:28 UTC (rev 491)
@@ -0,0 +1,22 @@
+package net.sf.magicmap.client.model.location.jung;
+
+import edu.uci.ics.jung.graph.Vertex;
+import edu.uci.ics.jung.graph.impl.DirectedSparseEdge;
+import net.sf.magicmap.client.model.node.IMagicEdge;
+import net.sf.magicmap.client.model.node.Node;
+
+
+public class JungEdge extends DirectedSparseEdge implements IMagicEdge{
+
+ public JungEdge(Vertex arg0, Vertex arg1) {
+ super(arg0, arg1);
+ }
+
+ public Node getSourceNode(){
+ return (Node) getSource().getUserDatum(LayoutSettings.NODE_KEY);
+ }
+
+ public Node getTargetNode(){
+ return (Node) getDest().getUserDatum(LayoutSettings.NODE_KEY);
+ }
+}
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 2006-12-04 19:12:56 UTC (rev 490)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/JungNodePlacer.java 2006-12-11 19:44:28 UTC (rev 491)
@@ -21,6 +21,7 @@
import net.sf.magicmap.client.model.location.jung.handler.PositionUpdateHandler;
import net.sf.magicmap.client.model.location.jung.handler.SeeAccessPointHandler;
import net.sf.magicmap.client.model.node.ClientNode;
+import net.sf.magicmap.client.model.node.IMagicEdge;
import net.sf.magicmap.client.model.node.INodeModel;
import net.sf.magicmap.client.model.node.LocationNode;
import net.sf.magicmap.client.model.node.Node;
@@ -41,9 +42,9 @@
/**
* Dieses Model benutzt die Layoutfunktionen von Jung und einige Angepasste
* Layoutalgorithmen um die Knotenposition zu berechnen.
- *
+ *
* @author Jan
- *
+ *
*/
public class JungNodePlacer extends DirectedSparseGraph implements INodePlacer, NodeModelListener, NodeModelConstants {
@@ -316,13 +317,22 @@
* @param node2
* @return
*/
- public Edge addEdge(Node node1, Node node2){
+ public IMagicEdge addEdge(Node node1, Node node2){
if (node1 == node2) return null;
Vertex v = findVertex(node1);
Vertex w = findVertex(node2);
- if (v == null || w == null) return null;
- return addEdge(v, w);
+ 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;
+ }
}
/**
Added: trunk/magicmapclient/src/net/sf/magicmap/client/model/node/IMagicEdge.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/model/node/IMagicEdge.java (rev 0)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/model/node/IMagicEdge.java 2006-12-11 19:44:28 UTC (rev 491)
@@ -0,0 +1,13 @@
+package net.sf.magicmap.client.model.node;
+
+
+/**
+ * An edge connects two Nodes. Used to hide the implementation (eg jung)
+ *
+ * @author jan
+ *
+ */
+public interface IMagicEdge {
+ public Node getSourceNode();
+ public Node getTargetNode();
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|