|
From: <fle...@us...> - 2007-03-28 14:35:09
|
Revision: 623
http://svn.sourceforge.net/magicmap/?rev=623&view=rev
Author: flederohr
Date: 2007-03-28 07:35:06 -0700 (Wed, 28 Mar 2007)
Log Message:
-----------
changed access of LayoutSettings to a static way
Modified Paths:
--------------
trunk/magicmapclient/src/net/sf/magicmap/client/algorithms/MagicMetric.java
trunk/magicmapclient/src/net/sf/magicmap/client/algorithms/NodeMetricManager.java
trunk/magicmapclient/src/net/sf/magicmap/client/algorithms/NodeModelMetric.java
trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/JungNodePlacer.java
trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/LayoutSettings.java
trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/MagicLayout.java
trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/MagicLengthFunction.java
trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/MagicRepulsionFunction.java
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/algorithms/MagicMetric.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/algorithms/MagicMetric.java 2007-03-28 12:57:03 UTC (rev 622)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/algorithms/MagicMetric.java 2007-03-28 14:35:06 UTC (rev 623)
@@ -86,7 +86,7 @@
*
* @see net.sf.magicmap.client.algorithms.NodeModelMetric#metric(net.sf.magicmap.client.model.node.Node, net.sf.magicmap.client.model.node.Node)
*/
- public double metric(LayoutSettings settings, Node node1, Node node2){
+ public double metric(Node node1, Node node2){
boolean a1 = (node1.getType() == NodeModelConstants.NODETYPE_ACCESSPOINT);
boolean a2 = (node2.getType() == NodeModelConstants.NODETYPE_ACCESSPOINT);
@@ -98,7 +98,7 @@
boolean rc2 = (c2 || r2);
// Calibreirung auf AP oder LC.
- double calibration = (rc1 && rc2) ? settings.getCalibrationFactorLocation() : settings
+ double calibration = (rc1 && rc2) ? LayoutSettings.getCalibrationFactorLocation() : LayoutSettings
.getCalibrationFactorAccessPoint();
if (a1 && a2) // Zwei AccessPoints
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/algorithms/NodeMetricManager.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/algorithms/NodeMetricManager.java 2007-03-28 12:57:03 UTC (rev 622)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/algorithms/NodeMetricManager.java 2007-03-28 14:35:06 UTC (rev 623)
@@ -4,7 +4,6 @@
import java.util.HashMap;
import java.util.Map;
-import net.sf.magicmap.client.model.location.jung.LayoutSettings;
import net.sf.magicmap.client.model.node.Node;
import org.apache.commons.collections.map.MultiKeyMap;
@@ -19,10 +18,10 @@
*/
public class NodeMetricManager implements NodeModelMetric {
- private NodeModelMetric defaultMetric;
- private final MultiKeyMap metricMap = new MultiKeyMap();
- private final Map<Class<? extends Node>,NodeModelMetric> genericMetricMap = new HashMap<Class<? extends Node>, NodeModelMetric>();
-
+ private NodeModelMetric defaultMetric;
+ private final MultiKeyMap metricMap = new MultiKeyMap();
+ private final Map<Class<? extends Node>, NodeModelMetric> genericMetricMap = new HashMap<Class<? extends Node>, NodeModelMetric>();
+
public NodeMetricManager(NodeModelMetric defaultMetric) {
this.defaultMetric = defaultMetric;
}
@@ -42,20 +41,20 @@
}
/**
- * F\xFCgt eine Metric zu einem Tupel von Knoten hinzu. Diese Metric ist generischer als eine
- * welche zwei Knotentypen ben\xF6tigt. Daher werden zuerst die speziellen mit zwei Knotentypen
- * befragt.
- *
- * @param clazz1 der 1. Knotentyp
- * @param metric die Metric die auf die beiden Knotentypen angewant werden soll.
- */
- public final void addMetric(Class<? extends Node> clazz1, NodeModelMetric metric){
- if (genericMetricMap.containsKey(clazz1)) {
- throw new IllegalArgumentException("Mapping for " + clazz1 + " exists");
- }
- genericMetricMap.put(clazz1, metric);
- }
-
+ * F\xFCgt eine Metric zu einem Tupel von Knoten hinzu. Diese Metric ist generischer als eine
+ * welche zwei Knotentypen ben\xF6tigt. Daher werden zuerst die speziellen mit zwei Knotentypen
+ * befragt.
+ *
+ * @param clazz1 der 1. Knotentyp
+ * @param metric die Metric die auf die beiden Knotentypen angewant werden soll.
+ */
+ public final void addMetric(Class<? extends Node> clazz1, NodeModelMetric metric){
+ if (genericMetricMap.containsKey(clazz1)) {
+ throw new IllegalArgumentException("Mapping for " + clazz1 + " exists");
+ }
+ genericMetricMap.put(clazz1, metric);
+ }
+
/**
* entfernt eine Metrci
* @param clazz1
@@ -68,14 +67,14 @@
/**
*
*/
- public double metric(LayoutSettings settings, Node node1, Node node2){
+ public double metric(Node node1, Node node2){
NodeModelMetric delegate = (NodeModelMetric) metricMap.get(node1.getClass(), node2.getClass());
-
- if (delegate != null) return delegate.metric(settings, node1, node2);
+
+ if (delegate != null) return delegate.metric(node1, node2);
delegate = genericMetricMap.get(node1.getClass());
-
- if (delegate != null)return delegate.metric(settings, node1, node2);
- return defaultMetric.metric(settings, node1, node2);
+
+ if (delegate != null) return delegate.metric(node1, node2);
+ return defaultMetric.metric(node1, node2);
}
}
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/algorithms/NodeModelMetric.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/algorithms/NodeModelMetric.java 2007-03-28 12:57:03 UTC (rev 622)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/algorithms/NodeModelMetric.java 2007-03-28 14:35:06 UTC (rev 623)
@@ -4,7 +4,6 @@
package net.sf.magicmap.client.algorithms;
-import net.sf.magicmap.client.model.location.jung.LayoutSettings;
import net.sf.magicmap.client.model.node.Node;
/**
@@ -22,6 +21,6 @@
* @param node2 zweiter Knoten.
* @return den Abstand zwischen den beiden Knoten.
*/
- public abstract double metric(LayoutSettings settings, Node node1, Node node2);
+ public abstract double metric(Node node1, Node node2);
}
\ No newline at end of file
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-03-28 12:57:03 UTC (rev 622)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/JungNodePlacer.java 2007-03-28 14:35:06 UTC (rev 623)
@@ -1,4 +1,4 @@
-
+
package net.sf.magicmap.client.model.location.jung;
import java.awt.Dimension;
@@ -49,21 +49,9 @@
/**
* Logger
*/
- private static final Log log = LogFactory.getLog(JungNodePlacer.class);
+ private static final Log log = LogFactory.getLog(JungNodePlacer.class);
/**
- *
- */
- private static final class DefaultSettings extends LayoutSettings {
-
- }
-
- /**
- *
- */
- 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>();
@@ -105,12 +93,11 @@
private final NodeMetricManager metricManager;
- private final Object edgeLock = new Object();
- private final Object vertexLock = new Object();
+ private final Object edgeLock = new Object();
+ private final Object vertexLock = new Object();
-
public JungNodePlacer() {
- this(JungNodePlacer.DEFAULT_SETTINGS, new MagicMetric());
+ this(new MagicMetric());
}
/**
@@ -126,12 +113,12 @@
* @param settings
* @param metric
*/
- public JungNodePlacer(LayoutSettings settings, NodeModelMetric metric) {
+ public JungNodePlacer(NodeModelMetric metric) {
super();
this.metricManager = new NodeMetricManager(metric);
this.clientLocationMap = new HashMap<ClientNode, HashSet<LocationNode>>();
this.locationLocationMap = new HashMap<LocationNode, HashSet<LocationNode>>();
- this.layout = new MagicLayout(this, metricManager, settings);
+ this.layout = new MagicLayout(this, metricManager);
this.worker = new LayoutWorker(this.layout, new Dimension(800, 600));
this.workerRunning = false;
this.workerPaused = false;
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/LayoutSettings.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/LayoutSettings.java 2007-03-28 12:57:03 UTC (rev 622)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/LayoutSettings.java 2007-03-28 14:35:06 UTC (rev 623)
@@ -1,5 +1,6 @@
package net.sf.magicmap.client.model.location.jung;
+
/**
* Contains the calibration settings for ur layout.
*
@@ -8,7 +9,6 @@
*/
public class LayoutSettings {
-
/**
* Um die Knoten in den Kanten zu finden.
*/
@@ -19,61 +19,55 @@
*/
public static final String NODE_DISTANCE_KEY = "NODE.distance";
- private double CALIBRATION_FACTOR_LC = 1.0; // Kanten zu Referenzpunkten
+ private static double CALIBRATION_FACTOR_LC = 1.0; // Kanten zu Referenzpunkten
- private double CALIBRATION_FACTOR_AP = 1.0; // Kanten zu APs kalibrieren
+ private static double CALIBRATION_FACTOR_AP = 1.0; // Kanten zu APs kalibrieren
- private boolean calculateHeight = false;
+ private static boolean calculateHeight = false;
- /**
- *
- *
- */
- public LayoutSettings() {
-
- }
-
- public double adjustLocationCalibration(double adjustValue){
+ public static double adjustLocationCalibration(double adjustValue){
// CF must NOT be negativ
- if ((this.CALIBRATION_FACTOR_LC + adjustValue) <= 0) {
- this.CALIBRATION_FACTOR_LC /= 10;
+ if ((CALIBRATION_FACTOR_LC + adjustValue) <= 0) {
+ CALIBRATION_FACTOR_LC /= 10;
} else {
- this.CALIBRATION_FACTOR_LC += adjustValue;
+ CALIBRATION_FACTOR_LC += adjustValue;
}
return adjustValue;
}
- public double adjustAccessPointCalibration(double adjustValue){
- if ((this.CALIBRATION_FACTOR_AP + adjustValue) <= 0) {
- this.CALIBRATION_FACTOR_AP /= 10;
+ private LayoutSettings() {};
+
+ public static double adjustAccessPointCalibration(double adjustValue){
+ if ((CALIBRATION_FACTOR_AP + adjustValue) <= 0) {
+ CALIBRATION_FACTOR_AP /= 10;
} else {
- this.CALIBRATION_FACTOR_AP += adjustValue;
+ CALIBRATION_FACTOR_AP += adjustValue;
}
return adjustValue;
}
- public boolean isCalculateHeight(){
- return this.calculateHeight;
+ public static boolean isCalculateHeight(){
+ return calculateHeight;
}
- public void setCalculateHeight(boolean calcHeight){
- this.calculateHeight = calcHeight;
+ public static void setCalculateHeight(boolean calcHeight){
+ calculateHeight = calcHeight;
}
- public double getCalibrationFactorAccessPoint(){
- return this.CALIBRATION_FACTOR_AP;
+ public static double getCalibrationFactorAccessPoint(){
+ return CALIBRATION_FACTOR_AP;
}
- public void setCalibrationFactorAccessPoint(double calibration_factor_ap){
- this.CALIBRATION_FACTOR_AP = calibration_factor_ap;
+ public static void setCalibrationFactorAccessPoint(double calibration_factor_ap){
+ CALIBRATION_FACTOR_AP = calibration_factor_ap;
}
- public double getCalibrationFactorLocation(){
- return this.CALIBRATION_FACTOR_LC;
+ public static double getCalibrationFactorLocation(){
+ return CALIBRATION_FACTOR_LC;
}
- public void setCalibrationFactorLocation(double calibration_factor_lc){
- this.CALIBRATION_FACTOR_LC = calibration_factor_lc;
+ public static void setCalibrationFactorLocation(double calibration_factor_lc){
+ CALIBRATION_FACTOR_LC = calibration_factor_lc;
}
}
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/MagicLayout.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/MagicLayout.java 2007-03-28 12:57:03 UTC (rev 622)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/MagicLayout.java 2007-03-28 14:35:06 UTC (rev 623)
@@ -21,9 +21,8 @@
*/
public class MagicLayout extends SpringLayout {
- NodeModelMetric metric;
- private final LayoutSettings settings;
- private final Graph graph;
+ NodeModelMetric metric;
+ private final Graph graph;
/**
*
@@ -31,13 +30,12 @@
* @param metric
* @param settings
*/
- public MagicLayout(Graph g, NodeModelMetric metric, LayoutSettings settings) {
- super(g, new MagicLengthFunction(settings, metric));
+ public MagicLayout(Graph g, NodeModelMetric metric) {
+ super(g, new MagicLengthFunction(metric));
this.graph = g;
this.metric = metric;
- this.settings = settings;
setLeaveFunction(new LeaveFunction());
- setRepulsionFunction(new MagicRepulsionFunction(settings));
+ setRepulsionFunction(new MagicRepulsionFunction());
setForceFunction(new MagicForceFunction(this.lengthFunction));
((MagicLengthFunction) getLengthFunction()).setBaseKey(getBaseKey());
}
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/MagicLengthFunction.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/MagicLengthFunction.java 2007-03-28 12:57:03 UTC (rev 622)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/MagicLengthFunction.java 2007-03-28 14:35:06 UTC (rev 623)
@@ -19,7 +19,6 @@
class MagicLengthFunction implements SpringLayout.LengthFunction {
- private final LayoutSettings settings;
private final NodeModelMetric metric;
private static final Logger log = Logger.getLogger(MagicLengthFunction.class);
@@ -28,8 +27,7 @@
*/
private Object baseKey;
- public MagicLengthFunction(LayoutSettings setings, NodeModelMetric metric) {
- this.settings = setings;
+ public MagicLengthFunction(NodeModelMetric metric) {
this.metric = metric;
}
@@ -45,7 +43,7 @@
* @return
*/
private double calculateLength(Node n1, Node n2){
- if (settings.isCalculateHeight() && Controller.getInstance().getCurrentMap().realwidth > 0
+ if (LayoutSettings.isCalculateHeight() && Controller.getInstance().getCurrentMap().realwidth > 0
&& Controller.getInstance().getCurrentMap().realwidth > 0) {
int diff = n1.getZ() - n2.getZ();
if (diff != 0) {
@@ -61,7 +59,7 @@
// b in pixel umrechnen
b = b * scale;
// System.out.println(b);
- double a = metric.metric(settings, n1, n2);
+ double a = metric.metric(n1, n2);
// System.out.println("Unangepasster Wert: " + a + "
// angepasster
// Wert: " + Math.sqrt(a*a - b*b));
@@ -78,10 +76,10 @@
// System.out.println("Wert angepasst!");
return Math.sqrt(a * a - b * b);
} else {
- return metric.metric(settings, n1, n2);
+ return metric.metric(n1, n2);
}
} else {
- return metric.metric(settings, n1, n2);
+ return metric.metric(n1, n2);
}
}
@@ -121,17 +119,17 @@
if (clientOrLocation) {
if (d < 0.95) {
- settings.adjustLocationCalibration(-Math.max(Math.abs(len - desiredLen) / 200, 0.001));
+ LayoutSettings.adjustLocationCalibration(-Math.max(Math.abs(len - desiredLen) / 200, 0.001));
} else if (d > 1.05) {
- settings.adjustLocationCalibration(Math.max(Math.abs(len - desiredLen) / 200, 0.001));
+ LayoutSettings.adjustLocationCalibration(Math.max(Math.abs(len - desiredLen) / 200, 0.001));
}
} else {
if (d < 0.95) {
- settings.adjustAccessPointCalibration(-Math.max(Math.abs(len - desiredLen) / 200, 0.001));
+ LayoutSettings.adjustAccessPointCalibration(-Math.max(Math.abs(len - desiredLen) / 200, 0.001));
} else if (d > 1.05) {
- settings.adjustAccessPointCalibration(Math.max(Math.abs(len - desiredLen) / 200, 0.001));
+ LayoutSettings.adjustAccessPointCalibration(Math.max(Math.abs(len - desiredLen) / 200, 0.001));
}
}
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/MagicRepulsionFunction.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/MagicRepulsionFunction.java 2007-03-28 12:57:03 UTC (rev 622)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/MagicRepulsionFunction.java 2007-03-28 14:35:06 UTC (rev 623)
@@ -13,18 +13,6 @@
public class MagicRepulsionFunction implements SpringLayout.RepulsionFunction {
- /**
- *
- */
- private final LayoutSettings setings;
-
- /**
-
- */
- MagicRepulsionFunction(LayoutSettings setings) {
- this.setings = setings;
- }
-
public double getRepulsion(Vertex v1, Vertex v2){
Node node1 = this.findNode(v1);
Node node2 = this.findNode(v2);
@@ -32,7 +20,7 @@
if (node1 instanceof AccessPointNode && ((AccessPointNode) node1).isHidden()) return 0;
if (node2 instanceof AccessPointNode && ((AccessPointNode) node2).isHidden()) return 0;
if (node1 instanceof AccessPointNode && node2 instanceof AccessPointNode)
- return 20 * setings.getCalibrationFactorAccessPoint();
+ return 20 * LayoutSettings.getCalibrationFactorAccessPoint();
// Orte und Clients stossen sich nicht ab
if ((node1 instanceof ClientNode || node1 instanceof LocationNode)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|