Author: tomithy
Date: 2010-08-15 15:23:47 -0700 (Sun, 15 Aug 2010)
New Revision: 21392
Removed:
cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/view/operator/router/ControlPoint.as
Modified:
cytoscapeweb/branches/gsoc2010/gbeb/src/Annotations.as
cytoscapeweb/branches/gsoc2010/gbeb/src/CodeArchive.as
cytoscapeweb/branches/gsoc2010/gbeb/src/GBEBView.as
cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/util/GeometryUtil.as
cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/util/Pathfinder.as
cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/view/operator/router/GBEBRouter.as
cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/view/render/BundleRenderer.as
cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/view/render/EdgeRenderer.as
Log:
Modified: cytoscapeweb/branches/gsoc2010/gbeb/src/Annotations.as
===================================================================
--- cytoscapeweb/branches/gsoc2010/gbeb/src/Annotations.as 2010-08-15
15:51:26 UTC (rev 21391)
+++ cytoscapeweb/branches/gsoc2010/gbeb/src/Annotations.as 2010-08-15
22:23:47 UTC (rev 21392)
@@ -72,11 +72,21 @@
- removed direction check in
shape, as it is no longer necessary an asthetic adjustment in the bundling
process
- written Kmeans clustering
method from scratch, tested against randomly generated variable:works
+Version 0.9:
+Cleaned up GeomUtil and created new GeomUtilInterface class to abstract methods
+Version 0.95:
+Bundling Success~! - A Pathfinder class is written to bundle the edges.
Utilises kmeans to cluster and finds the centroids
+ of the clusters of CP and
thread the edges which have CP in the clusters through the CP.
+ - Fixed minor bug in pathfinder
which is causing loops
+GeomUtil: - Fixed NaN bug for Kmeans
+ - removed calculateDistanceBetween
points function as flash has already provided this method
+BundledRenderer: Redundant Class: Fixed Problem of running renderer twice
+
Comments: Indent layout is rather slow to compute. Perhaps because of the huge
centre shape.
Known issues: 1) If the mesh edge is vertical or has gradient = 1 and it
intersects with the corner of the grid, its nodes will not
Modified: cytoscapeweb/branches/gsoc2010/gbeb/src/CodeArchive.as
===================================================================
--- cytoscapeweb/branches/gsoc2010/gbeb/src/CodeArchive.as 2010-08-15
15:51:26 UTC (rev 21391)
+++ cytoscapeweb/branches/gsoc2010/gbeb/src/CodeArchive.as 2010-08-15
22:23:47 UTC (rev 21392)
@@ -47,7 +47,121 @@
}
+/****
+ * From Pathfinding
+ *
+ *
+ //Get the set of nodes in which the edge can transverse across,
WayPoints.
+ // WayPoints = {nodes that are
control points of the edge} + {nodes that are within the 'search zone'}
+ private function generateSearchSpace(CPset:Array,
edge:EdgeSprite):Array
+ {
+ var searchSpace:Array = [];
+ var CPArrayFromEdge:Array =
edge.props.$controlPointsArray;
+ var s:Point = new Point(edge.source.x, edge.source.y);
+ var t:Point = new Point(edge.target.x, edge.target.y);
+ var angle:Number = Math.PI / 6;
+ var maxSearchDist:int = getMaxSearchDist(s, t, angle);
//stores the maximum search distance for nodes that are not already on the
edgeSprite
+
+ //should i return here if there are no contol points?
+
+ //adds CP by inclusive addition
+ for each (var p:Point in CPset)
+ {
+ if(checkSearchSpace(p, t, s,
maxSearchDist)) searchSpace.push(p);
+ //trace("Pathfinder: Hi " +
CPset.length, maxSearchDist);
+ }
+
+ trace("Pathfinder: GSP: searchSpace.length: " +
searchSpace.length, "maxSearchDist: " + maxSearchDist, edge.name);
+ if(CPArrayFromEdge == null) return searchSpace;
+
+ for each(var p:Point in CPArrayFromEdge)
+ {
+ if(searchSpace.indexOf(p) == -1)
searchSpace.push(p);
+ }
+
+ trace("Pathfinder: GSP (After): searchSpace.length: " +
searchSpace.length, edge.name);
+
+ return searchSpace;
+ }
+
+ // Checks if a particular CP from the CPset should be included
in the search space base on its distance to the
+ // source and target node of the EdgeSprite: The search space
is a semi-circle in shape.
+ private function checkSearchSpace(currNode:Point, s:Point,
t:Point, maxDis:int):Boolean
+ {
+ var c:Point = new Point(currNode.x, currNode.y);
//current point
+ var dis:int =
Math.floor(GeometryUtil.calculateDistanceBetweenPoints(c, s) +
Math.floor(GeometryUtil.calculateDistanceBetweenPoints(c, t)));
+ //trace("Pathfinder: dis: " + dis + " | Max Dis: " +
maxDis);
+ return ( dis < maxDis ? true : false);
+ }
+
+ // Returns the boundary distance of the search space. The
further the source and target nodes are apart,
+ // the larger the boundary.
+ private function getMaxSearchDist(t:Point, s:Point,
angle:Number):int
+ {
+ return
Math.floor(GeometryUtil.calculateDistanceBetweenPoints(s, t) * Math.tan(angle)
* 2 );
+ }
+
+ // Astar is a pathfinding algorithm...
+ private function AStar_pathfindingAlgrithm(edge:EdgeSprite,
searchSpace:Array):void
+ {
+ var debugString:String = ""; //debug
+ var ctrl:Array = edge.props.$controlPointsArray;
+ var curr:Point = new Point(edge.source.x,
edge.source.y);
+ var end:Point = new Point(edge.target.x,
edge.target.y);
+ var selectedPoint:int = -1;
+ var wayPoints:Array = []; //stores in order the final
path of the edgeSprite
+
+
+ if(ctrl == null) return;
+ edge.props.$controlPointsArray = searchSpace;
+ sortCPByDistance(edge);
+
+ trace("Pathfinding: Test: " + (searchSpace.length ==
edge.props.$controlPointsArray.length) + " | ctrl.length: " + ctrl.length );
+ trace(edge.props.$controlPointsArray.length);
+
+ while(Math.abs(curr.x - end.x) > 0.1 || Math.abs(curr.y
- end.y) > 0.1) //Just in case there is some floating points mismatch
+ {
+ for(var i:int = 0; i < searchSpace.length; i++)
+ {
+
+ }
+
+ }
+
+ }
+
+
+ //private test2
+ //should i include start and end in kmeans?
+ private function kmeans_Pathfinding(edge:EdgeSprite,
searchSpace:Array):void
+ {
+ var ctrl:Array = edge.props.$controlPointsArray;
+ var curr:Point = new Point(edge.source.x,
edge.source.y);
+ var end:Point = new Point(edge.target.x, edge.target.y);
+ var wayPointsSet:Array; // Stores the sets of way point
path after kmeans.
+ var wayPoints:Array = []; //stores in order the final
path of the edgeSprite
+
+ if(searchSpace.length == 0) return;
+
+ wayPointsSet = GeometryUtil.kmeans(searchSpace);
+
+ for each (var cluster:Array in wayPointsSet)
+ {
+ if(cluster[0] != null)
wayPoints.push(cluster[0]);
+ //trace("Pathfinder: tracing clusters: " +
cluster[0]);
+ }
+
+ trace("Pathfinder: KmeansPF: WayPoints.length: " +
wayPoints.length);
+
+ edge.props.$controlPointsArray = wayPoints;
+ sortCPByDistance(edge);
+
+ }
+ */
+
+
+
/*
* Draw a quadratic Bezier curve through a set of control points
anchorPoints[], with the first point being the start and last points
* being static anchor points of the curve.
Modified: cytoscapeweb/branches/gsoc2010/gbeb/src/GBEBView.as
===================================================================
--- cytoscapeweb/branches/gsoc2010/gbeb/src/GBEBView.as 2010-08-15 15:51:26 UTC
(rev 21391)
+++ cytoscapeweb/branches/gsoc2010/gbeb/src/GBEBView.as 2010-08-15 22:23:47 UTC
(rev 21392)
@@ -35,8 +35,8 @@
public class GBEBView extends Sprite
{
//private var _url:String = "data/sample1.xml";
- private var _url:String =
"http://flare.prefuse.org/data/flare.json.txt";
- //private var _url:String
="/Users/Tomithy/Desktop/GSOC/Datasets/flare.json.txt";
+ //private var _url:String =
"http://flare.prefuse.org/data/flare.json.txt";
+ private var _url:String
="/Users/Tomithy/Desktop/GSOC/Datasets/flare.json.txt";
//private var _url:String
="/Users/Tomithy/Desktop/GSOC/Datasets/flare_reduced.json.txt";
//private var _url:String
="/Users/Tomithy/Desktop/GSOC/Datasets/socialnet.xml";
private var _vis:Visualization;
Modified: cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/util/GeometryUtil.as
===================================================================
--- cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/util/GeometryUtil.as
2010-08-15 15:51:26 UTC (rev 21391)
+++ cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/util/GeometryUtil.as
2010-08-15 22:23:47 UTC (rev 21392)
@@ -116,18 +116,6 @@
/**
- * This function uses Pythagoras' Theorm to calculate the
distance between p1 and p2;
- */
-
- public static function calculateDistanceBetweenPoints(p1:Point,
p2:Point):Number
- {
- var distance:Number = 0;
- distance = Math.sqrt( Math.pow((p1.x - p2.x), 2) +
Math.pow((p1.y - p2.y), 2));
- return distance;
- }
-
-
- /**
* This function derives the position of the anchor point based
of the location of the control point
* for a normal qradratic Bezier curve.
*
@@ -161,7 +149,22 @@
return new Point( (avgX / numPoints), (avgY /
numPoints));
}
+ /**
+ * This function takes in 2 lines segment as 4 points, Line1 -
AB | Line 2 ~ EF and returns the angle between them.
+ * Uses the idea of a dot product of vectors. Note the lines
are directed, meaning it starts from A and end at B
+ *
+ * Coded with reference to
http://www.kynd.info/library/mathandphysics/dotProduct_01/
+ */
+ public static function getAnglesFromLines(A:Point, B:Point,
E:Point, F:Point):Number
+ {
+ var dotProduct:Number = (B.x - A.x) * (F.x - E.x) +
(B.y - A.y) * (F.y - E.y);
+ var demoninator:Number = Point.distance(A, B) *
Point.distance(E, F); //This is a multiplication of magnitude
+ var angle:Number = Math.acos(dotProduct /demoninator);
+
+ return angle;
+ }
+
/**
* This function is a 2 dimensional k- means clutering
algorithm. It is a heuristic algorithm which
* takes in a array of 2D points [p1..pn], and creates k (k =
Ceil(n/2) ^ 0.5) number of clusters. It return
@@ -196,7 +199,7 @@
return clusters;
} else if (points.length == 2)
{
- if ( calculateDistanceBetweenPoints(points[0],
points[1]) < bundlingDist)
+ if ( Point.distance(points[0], points[1]) <
bundlingDist)
{
clusters.push(points);
return clusters;
@@ -212,19 +215,14 @@
clusters.push(new Array());
centroids.push(new Point( points[i].x,
points[i].y));
}
-
-
- // ========[ PRIVATE METHODS
]==============================================================
-
// The algorithm will loop between assigning the points
to the clusters that the points are nearest to
// and recalculating the centroids for each clusters
after all the points are assigned until the centroids
// does not shift any more.
do {
- prevCentroids = copyCentroids(centroids);
- assignPointsToClusters(points, centroids,
clusters);
- recalcuateCentroids(centroids, clusters);
+ prevCentroids = copyCentroids(centroids);
+ assignPointsToClusters(points, centroids,
clusters);
+ recalcuateCentroids(centroids, clusters);
} while(!clusteringComplete(centroids, prevCentroids))
-
return clusters;
}
@@ -244,17 +242,22 @@
//This function assign the points to the cluster which has the
closest centroid to the point.
private static function assignPointsToClusters(points:Array,
centroids:Array, clusters:Array):void
- {
+ {
var distanceToCentroid:Array = []; //stores the
distance between each point to the centroid at each round of iteration
for each( var p:Point in points)
{
- distanceToCentroid = [];
- for each( var c:Point in centroids)
+ distanceToCentroid = [];
+ if(isNaN(p.x) || isNaN(p.y))
{
-
distanceToCentroid.push(calculateDistanceBetweenPoints(c, p));
+ points.splice(p,1);
+ continue;
}
-
clusters[getMinDisIndex(distanceToCentroid)].push(p);
- }
+ for each( var c:Point in centroids)
+ {
+
distanceToCentroid.push(Point.distance(c, p));
+ }
+
clusters[getMinDisIndex(distanceToCentroid)].push(p);
+ }
}
//This function recalcuates the position of the centroid of
each clusters based on the clustering in each iteration
@@ -283,7 +286,7 @@
{
var minDis:Number = Number.MAX_VALUE;
var minDisIndex = -1;
-
+
for(var i:int=0; i < distances.length;i++)
{
if(distances[i] < minDis)
Modified: cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/util/Pathfinder.as
===================================================================
--- cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/util/Pathfinder.as
2010-08-15 15:51:26 UTC (rev 21391)
+++ cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/util/Pathfinder.as
2010-08-15 22:23:47 UTC (rev 21392)
@@ -47,9 +47,10 @@
//This public function is exposed to allow call only after all
the required steps are done.
public function pathfind(data:Data, mesh:*, bounds:Rectangle)
{
+ trace("Pathfinder: Starting...");
_data = data;
_mesh = mesh;
- _maxDis =
GeometryUtil.calculateDistanceBetweenPoints(bounds.topLeft, bounds.bottomRight);
+ _maxDis = Point.distance(bounds.topLeft,
bounds.bottomRight);
Kmeans_Pathfinding2_Preprocessing(_mesh.CP);
_data.edges.visit(_pathfind);
@@ -62,7 +63,7 @@
//to generate a path that fits the quality citeria for the
curve.
private function _pathfind(edge:EdgeSprite):void
{
- var searchSpace:Array = generateSearchSpace(_mesh.CP,
edge);
+ //var searchSpace:Array = generateSearchSpace(_mesh.CP,
edge);
var searchSpaceTrace:String = ""; //debug
@@ -80,123 +81,19 @@
}
trace(searchSpaceTrace); */
}
-
- //Get the set of nodes in which the edge can transverse across,
WayPoints.
- // WayPoints = {nodes that are
control points of the edge} + {nodes that are within the 'search zone'}
- private function generateSearchSpace(CPset:Array,
edge:EdgeSprite):Array
- {
- var searchSpace:Array = [];
- var CPArrayFromEdge:Array =
edge.props.$controlPointsArray;
- var s:Point = new Point(edge.source.x, edge.source.y);
- var t:Point = new Point(edge.target.x, edge.target.y);
- var angle:Number = Math.PI / 6;
- var maxSearchDist:int = getMaxSearchDist(s, t, angle);
//stores the maximum search distance for nodes that are not already on the
edgeSprite
-
- //should i return here if there are no contol points?
-
- //adds CP by inclusive addition
- for each (var p:Point in CPset)
- {
- if(checkSearchSpace(p, t, s,
maxSearchDist)) searchSpace.push(p);
- //trace("Pathfinder: Hi " +
CPset.length, maxSearchDist);
- }
-
- trace("Pathfinder: GSP: searchSpace.length: " +
searchSpace.length, "maxSearchDist: " + maxSearchDist, edge.name);
- if(CPArrayFromEdge == null) return searchSpace;
-
- for each(var p:Point in CPArrayFromEdge)
- {
- if(searchSpace.indexOf(p) == -1)
searchSpace.push(p);
- }
-
- trace("Pathfinder: GSP (After): searchSpace.length: " +
searchSpace.length, edge.name);
-
- return searchSpace;
- }
- // Checks if a particular CP from the CPset should be included
in the search space base on its distance to the
- // source and target node of the EdgeSprite: The search space
is a semi-circle in shape.
- private function checkSearchSpace(currNode:Point, s:Point,
t:Point, maxDis:int):Boolean
- {
- var c:Point = new Point(currNode.x, currNode.y);
//current point
- var dis:int =
Math.floor(GeometryUtil.calculateDistanceBetweenPoints(c, s) +
Math.floor(GeometryUtil.calculateDistanceBetweenPoints(c, t)));
- //trace("Pathfinder: dis: " + dis + " | Max Dis: " +
maxDis);
- return ( dis < maxDis ? true : false);
- }
-
- // Returns the boundary distance of the search space. The
further the source and target nodes are apart,
- // the larger the boundary.
- private function getMaxSearchDist(t:Point, s:Point,
angle:Number):int
- {
- return
Math.floor(GeometryUtil.calculateDistanceBetweenPoints(s, t) * Math.tan(angle)
* 2 );
- }
-
- // Astar is a pathfinding algorithm...
- private function AStar_pathfindingAlgrithm(edge:EdgeSprite,
searchSpace:Array):void
- {
- var debugString:String = ""; //debug
- var ctrl:Array = edge.props.$controlPointsArray;
- var curr:Point = new Point(edge.source.x,
edge.source.y);
- var end:Point = new Point(edge.target.x,
edge.target.y);
- var selectedPoint:int = -1;
- var wayPoints:Array = []; //stores in order the final
path of the edgeSprite
-
-
- if(ctrl == null) return;
- edge.props.$controlPointsArray = searchSpace;
- sortCPByDistance(edge);
-
- trace("Pathfinding: Test: " + (searchSpace.length ==
edge.props.$controlPointsArray.length) + " | ctrl.length: " + ctrl.length );
- trace(edge.props.$controlPointsArray.length);
-
- while(Math.abs(curr.x - end.x) > 0.1 || Math.abs(curr.y
- end.y) > 0.1) //Just in case there is some floating points mismatch
- {
- for(var i:int = 0; i < searchSpace.length; i++)
- {
-
- }
-
- }
-
- }
-
-
- //private test2
- //should i include start and end in kmeans?
- private function kmeans_Pathfinding(edge:EdgeSprite,
searchSpace:Array):void
- {
- var ctrl:Array = edge.props.$controlPointsArray;
- var curr:Point = new Point(edge.source.x,
edge.source.y);
- var end:Point = new Point(edge.target.x, edge.target.y);
- var wayPointsSet:Array; // Stores the sets of way point
path after kmeans.
- var wayPoints:Array = []; //stores in order the final
path of the edgeSprite
-
- if(searchSpace.length == 0) return;
-
- wayPointsSet = GeometryUtil.kmeans(searchSpace);
-
- for each (var cluster:Array in wayPointsSet)
- {
- if(cluster[0] != null)
wayPoints.push(cluster[0]);
- //trace("Pathfinder: tracing clusters: " +
cluster[0]);
- }
-
- trace("Pathfinder: KmeansPF: WayPoints.length: " +
wayPoints.length);
-
- edge.props.$controlPointsArray = wayPoints;
- sortCPByDistance(edge);
-
- }
-
//some pre-processing such that the CP forms clusters
private function
Kmeans_Pathfinding2_Preprocessing(CPSet:Array):void
{
+
_CPClusters = GeometryUtil.kmeans(CPSet);
+ trace("Pathfinder: KmeansPF: Pre starting");
for (var i:int = 0; i < _CPClusters.length; i++)
{
_centroidArray.push(GeometryUtil.findCentroidFromPoints(_CPClusters[i]));
+
}
trace("Pathfinding: _centroidArray.length: " +
_centroidArray.length);
}
@@ -217,7 +114,7 @@
//check which cluster is it nearest to
for each(var centroid:Point in _centroidArray)
{
- distToCentroid =
GeometryUtil.calculateDistanceBetweenPoints(p, centroid);
+ distToCentroid = Point.distance(p,
centroid);
if(distToCentroid == closetDist)
{
//search the array and find out
which cluster does the point belong to
@@ -232,22 +129,26 @@
if(tempCentroid != null &&
newCtrl.indexOf(tempCentroid) == -1) newCtrl.push(tempCentroid);
}
+
+ //trace("Pathfinder: " + edge.source.data["name"],
edge.target.data["name"], newCtrl);
edge.props.$controlPointsArray = newCtrl;
sortCPByDistance(edge);
+ //removeSharpEdges(edge);
+ //trace("Pathfinder: " + edge.source.data["name"],
edge.target.data["name"], edge.props.$controlPointsArray);
}
- public function sortCPByDistance(e:EdgeSprite):void
+ private function sortCPByDistance(edge:EdgeSprite):void
{
- var ctrl:Array = e.props.$controlPointsArray;
+ var ctrl:Array = edge.props.$controlPointsArray;
if(ctrl == null) return;
- var sourceNode:Point = new Point(e.source.x,
e.source.y); //casting source node as mesh modes
- var targetNode:Point = new Point(e.target.x,
e.target.y);
+ var sourceNode:Point = new Point(edge.source.x,
edge.source.y); //casting source node as mesh modes
+ var targetNode:Point = new Point(edge.target.x,
edge.target.y);
var swapArray:Array = [];
- var disSourceTarget:Number =
GeometryUtil.calculateDistanceBetweenPoints(sourceNode, targetNode);
+ var disSourceTarget:Number = Point.distance(sourceNode,
targetNode);
var distance:String = ""; //debug
-
+
//trace("GBEBRouter: Bubble sorting CP by Distance...",
e.name);
for each (var p:Point in ctrl)
{
@@ -257,7 +158,6 @@
}
ctrl = bubbleSortPointsArray(ctrl, sourceNode);
-
/*for each (var p:Point in ctrl) //debug
{
distance += " " +
GeometryUtil.calculateDistanceBetweenPoints(sourceNode, p);
@@ -268,11 +168,11 @@
for(var i:int = 0; i < ctrl.length; i++)
{
- var disTargetP:Number =
GeometryUtil.calculateDistanceBetweenPoints(targetNode, ctrl[i]);
+ var disTargetP:Number =
Point.distance(targetNode, ctrl[i]);
if(disTargetP > disSourceTarget)
{
- swapArray.push(ctrl[i]);
- ctrl.splice(ctrl.indexOf(i), 1);
+ swapArray.push(ctrl[i]);
+ ctrl.splice(ctrl.indexOf(ctrl[i]), 1);
}
}
@@ -281,7 +181,7 @@
for each (var p:Point in swapArray)
{
ctrl.unshift(swapArray.shift());
- distance += " " +
GeometryUtil.calculateDistanceBetweenPoints(sourceNode, p); //debug
+ distance += " " + Point.distance(sourceNode,
p); //debug
}
//trace("GBEBRouter: BubbleSort - Swap Array trace: " +
distance, e.source.data["name"], e.target.data["name"]);
@@ -295,8 +195,8 @@
{
for (var j:int = 0; j < a.length - i - 1; j++)
{
- currDist =
GeometryUtil.calculateDistanceBetweenPoints(targetPoint,a[j]);
- nextDist =
GeometryUtil.calculateDistanceBetweenPoints(targetPoint,a[j + 1]);
+ currDist =
Point.distance(targetPoint,a[j]);
+ nextDist =
Point.distance(targetPoint,a[j + 1]);
if(increasing)
{
if(currDist > nextDist)
@@ -317,6 +217,62 @@
}
return a;
}
+
+ private function removeSharpEdges(edge:EdgeSprite):void
+ {
+ var ctrl:Array = edge.props.$controlPointsArray;
+ var source:Point = new Point(edge.source.x,
edge.source.y);
+ var target:Point = new Point(edge.target.x,
edge.target.y);
+ const minAngle:Number = Math.PI / 2;
+
+ if(ctrl.length < 1 ) return;
+
+ do
+ {
+ var angles:Array = []; //stores the angle
between 2 lines.
+ var prev:Point = source, next:Point = (
ctrl.length == 1 ? target : ctrl[1]);
+ var p:Point;
+ var minAngleInArray:Number = Number.MAX_VALUE;
var minAngleIndex:int = -1;
+
+ for (var i:int = 0; i < ctrl.length; i++)
+ {
+ p = ctrl[i];
+ angles[i] =
GeometryUtil.getAnglesFromLines(prev, p, p, next);
+ prev = p;
+ if( i == ctrl.length - 1)
+ {
+ next = target;
+ } else {
+ next = ctrl[i+1];
+ }
+ }
+
+ for (var i:int = 0; i < angles.length; i++)
+ {
+ if(Math.abs(angles[i]) <
minAngleInArray)
+ {
+ minAngleInArray = angles[i];
+ minAngleIndex = i;
+ }
+ }
+
+ if( minAngleIndex != -1 &&
Math.abs(angles[minAngleIndex]) < minAngle){
+ trace("Pathfinder: removeSharpEdges: "
+ angles[minAngleIndex] + " spliced");
+ ctrl.splice(minAngleIndex, 1);
+ }
+ } while(checkAngles(angles, minAngle))
+ }
+
+ private function checkAngles(angles:Array,
minAngle:Number):Boolean
+ {
+ //if(angles.length == 0) return false;
+ for each (var angle:Number in angles)
+ {
+ if(angle < minAngle) return true;
+ }
+
+ return false;
+ }
} //end of class
}
\ No newline at end of file
Deleted:
cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/view/operator/router/ControlPoint.as
===================================================================
---
cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/view/operator/router/ControlPoint.as
2010-08-15 15:51:26 UTC (rev 21391)
+++
cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/view/operator/router/ControlPoint.as
2010-08-15 22:23:47 UTC (rev 21392)
@@ -1,15 +0,0 @@
-package gbeb.view.operator.router
-{
- import flash.geom.Point;
-
- public class ControlPoint
- {
- public var pos:Point = new Point(-1,11);
- public var associatedDataEdges:Array = [];
-
- public function ControlPoint()
- {
-
- }
- }
-}
\ No newline at end of file
Modified:
cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/view/operator/router/GBEBRouter.as
===================================================================
---
cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/view/operator/router/GBEBRouter.as
2010-08-15 15:51:26 UTC (rev 21391)
+++
cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/view/operator/router/GBEBRouter.as
2010-08-15 22:23:47 UTC (rev 21392)
@@ -891,8 +891,8 @@
//trace("GBEBRouter: mergeNodes_Pairwise: " + (edge2[s1 + "OriPos"] as
Point).toString(), "|", (edge2[s2] as MeshNode).x);
//if the edge
nodes has to be moved more than x = floor(gridSize/2) from its original
position, it will not be moved
-
if(
GeometryUtil.calculateDistanceBetweenPoints(ip, edge1[s1 + "OriPos"]) >
_meshNodesMaxDisplacementDistance ||
-
GeometryUtil.calculateDistanceBetweenPoints(ip, edge2[s2 + "OriPos"]) >
_meshNodesMaxDisplacementDistance)
+
if(
Point.distance(ip, edge1[s1 + "OriPos"]) > _meshNodesMaxDisplacementDistance ||
+
Point.distance(ip, edge2[s2 + "OriPos"]) > _meshNodesMaxDisplacementDistance)
{
//trace(edge1[s1 + "OriPos"].toString(), edge2[s2 + "OriPos"].toString());
//trace(GeometryUtil.calculateDistanceBetweenPoints(ip, edge1[s1 + "OriPos"]),
GeometryUtil.calculateDistanceBetweenPoints(ip, edge2[s2 + "OriPos"]),
_meshNodesMaxDisplacementDistance);
@@ -1074,7 +1074,7 @@
var sourceNode:Point = new
Point(e.source.x, e.source.y); //casting source node as mesh modes
var targetNode:Point = new
Point(e.target.x, e.target.y);
var swapArray:Array = [];
- var disSourceTarget:Number =
GeometryUtil.calculateDistanceBetweenPoints(sourceNode, targetNode);
+ var disSourceTarget:Number =
Point.distance(sourceNode, targetNode);
var distance:String = ""; //debug
//trace("GBEBRouter: Bubble sorting CP
by Distance...", e.name);
@@ -1089,7 +1089,7 @@
/*for each (var p:Point in ctrl) //debug
{
- distance += " " +
GeometryUtil.calculateDistanceBetweenPoints(sourceNode, p);
+ distance += " " +
Point.distance(sourceNode, p);
} */
//trace("GBEBRouter: BubbleSort - Array
trace: " + distance );//+ distance, e.source.data["name"],
e.target.data["name"]);
@@ -1097,7 +1097,7 @@
for(var i:int = 0; i < ctrl.length; i++)
{
- var disTargetP:Number =
GeometryUtil.calculateDistanceBetweenPoints(targetNode, ctrl[i]);
+ var disTargetP:Number =
Point.distance(targetNode, ctrl[i]);
if(disTargetP > disSourceTarget)
{
swapArray.push(ctrl[i]);
@@ -1110,7 +1110,7 @@
for each (var p:Point in swapArray)
{
ctrl.unshift(swapArray.shift());
- distance += " " +
GeometryUtil.calculateDistanceBetweenPoints(sourceNode, p); //debug
+ distance += " " +
Point.distance(sourceNode, p); //debug
}
//trace("GBEBRouter: BubbleSort - Swap
Array trace: " + distance, e.source.data["name"], e.target.data["name"]);
@@ -1124,8 +1124,8 @@
{
for (var j:int
= 0; j < a.length - i - 1; j++)
{
-
currDist = GeometryUtil.calculateDistanceBetweenPoints(targetPoint,a[j]);
-
nextDist = GeometryUtil.calculateDistanceBetweenPoints(targetPoint,a[j + 1]);
+
currDist = Point.distance(targetPoint,a[j]);
+
nextDist = Point.distance(targetPoint,a[j + 1]);
if(increasing)
{
if(currDist > nextDist)
Modified:
cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/view/render/BundleRenderer.as
===================================================================
--- cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/view/render/BundleRenderer.as
2010-08-15 15:51:26 UTC (rev 21391)
+++ cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/view/render/BundleRenderer.as
2010-08-15 22:23:47 UTC (rev 21392)
@@ -22,29 +22,17 @@
{
var e:EdgeSprite = d as EdgeSprite;
var ctrl:Array = e.props.$controlPointsArray;
- //var eCopy:EdgeSprite = cloneEdgeSprite(e);
+
if (e == null) return;
- //curveSegRenderer(e);
+
- //strightLineSegRenderer(e);
-
- addControlPoints(e);
- //super.render(e);
-
-
- //Test for Defagra BezierSpline
- //var BS
-
-
if(ctrl != null && ctrl.length > 0) //debug
{
super.render(e);
}
- //addControlPoints(eCopy, true);
- //super.render(eCopy); //debug
- //trace("Bundler: " + d.name + " has been rendered! " +
e.shape );
+
}
private function addControlPoints(e:EdgeSprite, isClone:Boolean
= false):void
@@ -71,7 +59,7 @@
var t:Point = new Point(e.target.x, e.target.y);
var tempPoint:Point;
var dPoint:Point; //derived point
- var stDist:Number =
GeometryUtil.calculateDistanceBetweenPoints(s,t); //Distance between the source
and target nodes
+ var stDist:Number = Point.distance(s,t); //Distance
between the source and target nodes
var ctrl:Array = e.props.$controlPointsArray;
var ctrlgradient:Array = e.props.$CPGradientArray;
//used to store the gradient of each control point
@@ -93,8 +81,8 @@
{
tempPoint = new Point(ctrl[i].x,
ctrl[i].y);
//if CP is too close to the source or
target nodes)
- if(
GeometryUtil.calculateDistanceBetweenPoints(tempPoint , s) < 3
- ||
GeometryUtil.calculateDistanceBetweenPoints(tempPoint, t) < 3 )
+ if( Point.distance(tempPoint , s) < 3
+ || Point.distance(tempPoint, t) < 3 )
{
g.lineTo(tempPoint.x,
tempPoint.y);
g.lineTo(t.x, t.y);
@@ -109,7 +97,7 @@
}
}
- var ratio:Number =
GeometryUtil.calculateDistanceBetweenPoints(s, ctrl[i]) /
GeometryUtil.calculateDistanceBetweenPoints(s, ctrl[i+1]);
+ var ratio:Number = Point.distance(s,
ctrl[i]) / Point.distance(s, ctrl[i+1]);
ratio = ( ratio < 0.3 ? 0.3 : ratio);
ratio = ( ratio > 0.7 ? 0.7 : ratio);
dPoint = GeometryUtil.derivePoint(s,
ctrl[i], t, ratio);
Modified:
cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/view/render/EdgeRenderer.as
===================================================================
--- cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/view/render/EdgeRenderer.as
2010-08-15 15:51:26 UTC (rev 21391)
+++ cytoscapeweb/branches/gsoc2010/gbeb/src/gbeb/view/render/EdgeRenderer.as
2010-08-15 22:23:47 UTC (rev 21392)
@@ -203,6 +203,11 @@
var b:BezierPoint = new
BezierPoint(p.x, p.y);
points.push(b);
}
+ /*trace("EdgeRenderer:
bezierPointArray.length: " + e.source.data["name"], e.target.data["name"],
points.length - 1)
+ for each (var ps:* in points)
+ {
+ trace(ps);
+ } */
points.push(new BezierPoint(x2, y2));
var path:Path = new Path();
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.