From: <fle...@us...> - 2007-03-27 14:51:18
|
Revision: 621 http://svn.sourceforge.net/magicmap/?rev=621&view=rev Author: flederohr Date: 2007-03-27 07:50:51 -0700 (Tue, 27 Mar 2007) Log Message: ----------- moved calibrationfactor into MagicMetric 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/MagicLengthFunction.java Modified: trunk/magicmapclient/src/net/sf/magicmap/client/algorithms/MagicMetric.java =================================================================== --- trunk/magicmapclient/src/net/sf/magicmap/client/algorithms/MagicMetric.java 2007-03-26 14:55:19 UTC (rev 620) +++ trunk/magicmapclient/src/net/sf/magicmap/client/algorithms/MagicMetric.java 2007-03-27 14:50:51 UTC (rev 621) @@ -12,6 +12,7 @@ import net.sf.magicmap.client.algorithms.distance.MagicDistanceAlgorithm; import net.sf.magicmap.client.measurement.Constants; import net.sf.magicmap.client.measurement.MeasurementUtils; +import net.sf.magicmap.client.model.location.jung.LayoutSettings; import net.sf.magicmap.client.model.node.AccessPointNode; import net.sf.magicmap.client.model.node.AccessPointSeerNode; import net.sf.magicmap.client.model.node.Node; @@ -85,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(Node node1, Node node2){ + public double metric(LayoutSettings settings, Node node1, Node node2){ boolean a1 = (node1.getType() == NodeModelConstants.NODETYPE_ACCESSPOINT); boolean a2 = (node2.getType() == NodeModelConstants.NODETYPE_ACCESSPOINT); @@ -96,6 +97,10 @@ boolean rc1 = (c1 || r1); boolean rc2 = (c2 || r2); + // Calibreirung auf AP oder LC. + double calibration = (rc1 && rc2) ? settings.getCalibrationFactorLocation() : settings + .getCalibrationFactorAccessPoint(); + if (a1 && a2) // Zwei AccessPoints return Double.POSITIVE_INFINITY; @@ -108,11 +113,11 @@ findAccessPoints(ap1, ap2, same, diff); // Kein gemeinsamer Access Point - if (same.size() == 0) return 1000.0; + if (same.size() == 0) return 1000.0 * calibration; if (same.size() == 1) { if (diff.size() == 0) return 0.0; - return 1000.0; + return 1000.0 * calibration; } // Basteln von Vektoren f\xFCr die Distance-Funktion @@ -154,7 +159,7 @@ penalty += (Constants.MIN_SIGNALLEVEL + ap1.getSignalLevelForAccessPoint(ap)); // 0.0 wenn ap1 nicht ap sieht penalty += (Constants.MIN_SIGNALLEVEL + ap2.getSignalLevelForAccessPoint(ap)); // 0.0 wenn ap2 nicht ap sieht } - return (distance + penalty * Constants.PENALTY_FACTOR) * 10.0; + return (distance + penalty * Constants.PENALTY_FACTOR) * 10.0 * calibration; } else if ((rc1 && a2) || (a1 && rc2)) { // Zwischen Ort/Client und AccessPoint AccessPointSeerNode seer; @@ -167,7 +172,8 @@ ap = (AccessPointNode) node2; } // TODO: Logarithmische Skalierung - return Math.abs(MeasurementUtils.signalLevelToStrength(seer.getSignalLevelForAccessPoint(ap))); + return Math.abs(MeasurementUtils.signalLevelToStrength(seer.getSignalLevelForAccessPoint(ap))) + * calibration; //return Math.abs(0.3 * Math.pow(10,(-0.026 * seer.getSignalLevelForAccessPoint(ap)))-0.5); } else //Wir berechnen nur Abst\xE4nde zwischen APs, Clients und Referenzpunkten Modified: trunk/magicmapclient/src/net/sf/magicmap/client/algorithms/NodeMetricManager.java =================================================================== --- trunk/magicmapclient/src/net/sf/magicmap/client/algorithms/NodeMetricManager.java 2007-03-26 14:55:19 UTC (rev 620) +++ trunk/magicmapclient/src/net/sf/magicmap/client/algorithms/NodeMetricManager.java 2007-03-27 14:50:51 UTC (rev 621) @@ -4,6 +4,7 @@ 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; @@ -67,14 +68,14 @@ /** * */ - public double metric(Node node1, Node node2){ + public double metric(LayoutSettings settings, Node node1, Node node2){ NodeModelMetric delegate = (NodeModelMetric) metricMap.get(node1.getClass(), node2.getClass()); - if (delegate != null) return delegate.metric(node1, node2); + if (delegate != null) return delegate.metric(settings, node1, node2); delegate = genericMetrciMap.get(node1.getClass()); - if (delegate != null)return delegate.metric(node1, node2); - return defaultMetric.metric(node1, node2); + if (delegate != null)return delegate.metric(settings, node1, node2); + return defaultMetric.metric(settings, 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-26 14:55:19 UTC (rev 620) +++ trunk/magicmapclient/src/net/sf/magicmap/client/algorithms/NodeModelMetric.java 2007-03-27 14:50:51 UTC (rev 621) @@ -4,6 +4,7 @@ package net.sf.magicmap.client.algorithms; +import net.sf.magicmap.client.model.location.jung.LayoutSettings; import net.sf.magicmap.client.model.node.Node; /** @@ -21,6 +22,6 @@ * @param node2 zweiter Knoten. * @return den Abstand zwischen den beiden Knoten. */ - public abstract double metric(Node node1, Node node2); + public abstract double metric(LayoutSettings settings, Node node1, Node node2); } \ No newline at end of file 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-26 14:55:19 UTC (rev 620) +++ trunk/magicmapclient/src/net/sf/magicmap/client/model/location/jung/MagicLengthFunction.java 2007-03-27 14:50:51 UTC (rev 621) @@ -44,10 +44,7 @@ * @param n2 * @return */ - private double calculateLength(Node n1, Node n2, boolean c1, boolean c2){ - // Calibreirung auf AP oder LC. - double c = (c1 && c2) ? settings.getCalibrationFactorLocation() : settings.getCalibrationFactorAccessPoint(); - + private double calculateLength(Node n1, Node n2){ if (settings.isCalculateHeight() && Controller.getInstance().getCurrentMap().realwidth > 0 && Controller.getInstance().getCurrentMap().realwidth > 0) { int diff = n1.getZ() - n2.getZ(); @@ -64,7 +61,7 @@ // b in pixel umrechnen b = b * scale; // System.out.println(b); - double a = metric.metric(n1, n2) * c; + double a = metric.metric(settings, n1, n2); // System.out.println("Unangepasster Wert: " + a + " // angepasster // Wert: " + Math.sqrt(a*a - b*b)); @@ -81,10 +78,10 @@ // System.out.println("Wert angepasst!"); return Math.sqrt(a * a - b * b); } else { - return metric.metric(n1, n2) * c; + return metric.metric(settings, n1, n2); } } else { - return metric.metric(n1, n2) * c; + return metric.metric(settings, n1, n2); } } @@ -103,7 +100,7 @@ boolean c2 = (t2 == INodeModel.NODETYPE_CLIENT || t2 == INodeModel.NODETYPE_LOCATION); boolean clientOrLocation = (c1 && c2); - double desiredLength = calculateLength(n1, n2, c1, c2); + double desiredLength = calculateLength(n1, n2); double vx = getX(v1) - getX(v2); double vy = getY(v1) - getY(v2); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |