Author: tomithy
Date: 2010-07-10 10:18:13 -0700 (Sat, 10 Jul 2010)
New Revision: 20897

Modified:
   cytoscapeweb/branches/gsoc2010/demos/src/GBEB/Shape.as
Log:
/* Version control file 11/7/10

Version 0.3
- Mesh is able to merge shape; 
- DataDisplay shows different Shapes in Mesh;
- Able to calculate Mesh for different Layouts.

Version 0.4 
- cleanup function is written to free up resources
Mesh: - shapes no longer contain repeated edges
                         - Patch is used to reflect the gradient around the 
point, as there is some unknown bug causing the gradient to be reflected about 
the y-axis
                         - Functions implemented: 
                                                4a) generateMeshEdges; 
getNodesForMeshEdge; isSourceNodeAssigned, generateNonRedundantShapeIndexArray, 
findCentroid,
                                                                
generateLineFromPointAndGradient, intersectionWithVertical, 
intersectionWithHorizontal
                                                4b) mergeNodes_All(), 
mergeNodes_Pairwise, calculateDistanceBetweenNodes - disabled as there are some 
bugs
Class GeometryUtil is added to store lineIntersectline Math function
DataDisplay:  - displays the centroid of Shapes, 
                                        - displays the mesh itself, which is 
accurate except for occurance of vertical straight lines due to known issue (1)

Version 0.5
Shape/ DataDisplay: - control points are set up. Initially they are added via 
GBEB properties and mirrored in edge.points
                                                                                
- control points are successfully added to all dataEdges that intersects with 
meshEdges - the control point is the avg of the intersection points of 
the meshEdge with the dataEdges passing through it. 

Version 0.6
Bundler added - it extends from edge render. Used Shapes.BEZIER for rendering, 
the effect is only satisfactory in general, but sometimes confusing for lines 
with > 1 control points,
due to BEZIER's mathemathical property
Comments: It doesnt work very well on simple graphs and the curves thens to 
complicate.
                                        Messy graphs like circle or radial can 
be improved if the resolution is set higher at the expense of runtime. 

Next:
Version 0.7 - allow dynamic adjusting of resolution by merging Shapes by the 
factor of 2
                                                - include edge quality 
calculation
                                                - implement another renderer 
for meshEdges to obtain better graphical control that default Bezier does not 
offer. 

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 horizontal and it lies 
directly above the grid, its source/traget nodes cannot be retrieve. 
                                                                Eg. Edge 9 of 
"social network.xml" -
                                                                Function 
responsible: intersectsVertical and getNodesForMeshEdge
                                                        2) MergeNodes_All() - 
Is acting weirdly, so it is disabled for now. 
                                                        3) Edges cannot be 
added when nodes are not added
                                                        4) Indent Layout does 
not work. 
                                                        5) Sample 2 does not 
work as some nodes are not assigned any location, and are hence out of bounce. 

*/

Modified: cytoscapeweb/branches/gsoc2010/demos/src/GBEB/Shape.as
===================================================================
--- cytoscapeweb/branches/gsoc2010/demos/src/GBEB/Shape.as      2010-07-10 
17:17:52 UTC (rev 20896)
+++ cytoscapeweb/branches/gsoc2010/demos/src/GBEB/Shape.as      2010-07-10 
17:18:13 UTC (rev 20897)
@@ -1,6 +1,8 @@
 package GBEB
 {
        import flare.vis.data.EdgeSprite;
+       
+       import flash.geom.Point;
 
        public class Shape
        {
@@ -11,6 +13,8 @@
                public var storedDataEdges:Array;
                public var direction:Number = -1; //stores the main direction 
of edges that are inside the Shape. -1 if there is no main distance
                public var stronglyClustered:Boolean; //flag to indicate if the 
edges are strongly clustered within this Shape
+               public var centroid:Point; //Stores the "centre of area (mass) 
for a 2d shape
+               public var meshEdge:EdgeSprite;
                
                
                private const bandwidth:int = 3; //bandwidth of KDE
@@ -99,24 +103,85 @@
                        return -1;
                }
                
-               //return the polarCoor of an Edge Sprite with a max diff of 180 
degrees
-               private function getPolarCoor180(e:EdgeSprite):Number
-               { 
-                       var angle:Number = Math.atan2 ((e.y2 - e.y1), (e.x2 - 
e.x1) );
-                       angle = Math.round(angle / Math.PI * 180); //working in 
degrees 
-                       angle = (angle < 0 ? 0 - angle : 180 - angle);
-                       //trace("Shape: getPolar: " + e.source.data["name"] + " 
to " + e.target.data["name"] + " | angle = " + angle);
-                       return angle; 
+                               //return the polarCoor of an Edge Sprite with a 
max diff of 180 degrees
+                               private function 
getPolarCoor180(e:EdgeSprite):Number
+                               { 
+                                       var angle:Number = Math.atan2 ((e.y2 - 
e.y1), (e.x2 - e.x1) );
+                                       angle = Math.round(angle / Math.PI * 
180); //working in degrees 
+                                       angle = (angle < 0 ? 0 - angle : 180 - 
angle);
+                                       //trace("Shape: getPolar: " + 
e.source.data["name"] + " to " + e.target.data["name"] + " | angle = " + angle);
+                                       return angle; 
+                               }
+               
+                               //return the polarCoor of an Edge Sprite with a 
max diff of 90 degrees
+                               private function 
getPolarCoor90(e:EdgeSprite):Number
+                               { 
+                                       var angle:Number = Math.atan2 ((e.y2 - 
e.y1), (e.x2 - e.x1) );
+                                       angle = Math.round(angle / Math.PI * 
180); //working in degrees
+                                       angle = ( angle < 0 ? angle + 180 : 
angle); // inverts the direction for -ve regions
+                                       //angle = ( angle > 90 ? 180 - angle : 
angle); // gets the acute angle
+                                       return angle;
+                               }
+               
+               //adds controlPoint to meshEdge of a shape. This function is 
called x times if the dataEdge cuts across x number of shapes. 
+               public function addControlPoint():void
+               {
+                       var intersectionPointsArray:Array = new Array();
+                       var intersectionPoint:Point;
+                       var controlPoint:Point; 
+                       
+                       var a:Point, b:Point; //a,b stores the end points of 
the meshEdge of each shape
+                       var e:Point, f:Point; //e,f stores the end points of 
the each dataEdge                                  
+                       
+                       a = new Point(meshEdge.source.x, meshEdge.source.y);
+                       b = new Point(meshEdge.target.x, meshEdge.target.y);
+                       
+                       for each (var dataEdge:EdgeSprite in storedDataEdges)
+                       {
+                               e = new Point(dataEdge.source.x, 
dataEdge.source.y);
+                               f = new Point(dataEdge.target.x, 
dataEdge.target.y);
+                               
+                               intersectionPoint = 
GBEB.GeometryUtil.lineIntersectLine(a, b, e, f);
+                               
+                               if(intersectionPoint != null)
+                               {
+                                       
intersectionPointsArray.push(intersectionPoint);
+                               }
+                               
+                       }
+                       
+                       if(intersectionPointsArray.length != 0)
+                       {
+                               controlPoint = 
findControlPointFromIntersectionPoints(intersectionPointsArray)
+                       } else {
+                               trace("Shape: addControlPoints: " + 
(gridIndex[0] as Point).toString() + " has no controlPoint");
+                       }
+                       
+                       for each (var dataEdge:EdgeSprite in storedDataEdges)
+                       {
+                               var prop:* = dataEdge.props.GBEBProperty;       
        
+                               
+                               (prop as 
GBEBProperty).addControlPoint(controlPoint); 
+                       }
+                       
+                       return;
                }
                
-               //return the polarCoor of an Edge Sprite with a max diff of 90 
degrees
-               private function getPolarCoor90(e:EdgeSprite):Number
-               { 
-                       var angle:Number = Math.atan2 ((e.y2 - e.y1), (e.x2 - 
e.x1) );
-                       angle = Math.round(angle / Math.PI * 180); //working in 
degrees
-                       angle = ( angle < 0 ? angle + 180 : angle); // inverts 
the direction for -ve regions
-                       //angle = ( angle > 90 ? 180 - angle : angle); // gets 
the acute angle
-                       return angle;
+               private function 
findControlPointFromIntersectionPoints(intersectionPointsArray:Array):Point
+               {
+                       var avgX:Number = 0;
+                       var avgY:Number = 0;
+                       var numPoints:int = intersectionPointsArray.length;
+                       
+                       for each (var p:Point in intersectionPointsArray)
+                       {
+                               avgX += p.x;
+                               avgY += p.y;
+                       }
+                       
+                       return new Point( (avgX / numPoints), (avgY / 
numPoints));
                }
-       }
+               
+               
+       }//end of class
 }
\ No newline at end of file

-- 
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.

Reply via email to