Example #1
0
        public void AddEdge(GraphEdge edge) {
            _edges.Add(edge);
            edge.FromNode.AddEdge(edge);
            edge.ToNode.AddEdge(edge);

            if (_updating == false) {
                RaiseChangedEvent();
            }
            else {
                _updated = true;
            }
        }
        public void AddEdge(GraphEdge edge)
        {
            _edges.Add(edge);
            edge.FromNode.AddEdge(edge);
            edge.ToNode.AddEdge(edge);

            if (_updating == false)
            {
                RaiseChangedEvent();
            }
            else
            {
                _updated = true;
            }
        }
        public void RemoveEdge(GraphEdge edge)
        {
            edge.FromNode.RemoveEdge(edge);
            edge.ToNode.RemoveEdge(edge);

            _edges.Remove(edge);
            if (_updating == false)
            {
                RaiseChangedEvent();
            }
            else
            {
                _updated = true;
            }
        }
Example #4
0
        private void RelaxEdge(GraphEdge edge) {
            // Pull nodes closes together by 'relaxing' each edge

            double vx = edge.ToNode.x - edge.FromNode.x;
            double vy = edge.ToNode.y - edge.FromNode.y;
            double distance = Math.Sqrt(vx * vx + vy * vy);

            // Rigidity makes edges tighter
            double dx = vx * _rigidity;
            double dy = vy * _rigidity;

            int div = edge.Length * 100;
            dx = dx / div;
            dy = dy / div;

            // Edges pull directly in proportion to the distance between the nodes. This is good,
            // because we want the edges to be stretchy.  The edges are ideal rubberbands.  They
            // They don't become springs when they are too short. That only causes the graph to
            // oscillate.

            edge.ToNode.dx = edge.ToNode.dx - dx * distance;
            edge.ToNode.dy = edge.ToNode.dy - dy * distance;
            edge.FromNode.dx = edge.FromNode.dx + dx * distance;
            edge.FromNode.dy = edge.FromNode.dy + dy * distance;
        }
 internal void RemoveEdge(GraphEdge edge)
 {
     _edges.Remove(edge);
 }
 internal void AddEdge(GraphEdge edge)
 {
     _edges.Add(edge);
 }
Example #7
0
 internal void RemoveEdge(GraphEdge edge) {
     _edges.Remove(edge);
 }
Example #8
0
 internal void AddEdge(GraphEdge edge) {
     _edges.Add(edge);
 }
Example #9
0
        private static void UpdatePhotos(bool newPhotos) {
            if (newPhotos) {
                if (_mapEntities != null) {
                    _map.Entities.Remove(_mapEntities);
                }

                _mapEntities = new MapEntityCollection();
                _map.Entities.Push(_mapEntities);

                _photoViews = new Dictionary<string, PhotoView>();
            }

            if (_model.Photos.Count == 0) {
                Document.Body.ClassName = MapModeClassName;
                return;
            }

            Document.Body.ClassName = PhotosModeClassName;

            _graph = new Graph();
            _model.Photos.ForEach(delegate(Photo photo) {
                MapLocation location = new MapLocation(photo.latitude, photo.longitude);
                MapPoint point = _map.TryLocationToPixel(location, MapPointReference.Control);

                PhotoView photoView;
                if (newPhotos) {
                    MapPolylineOptions connectorOptions = new MapPolylineOptions();
                    connectorOptions.StrokeColor = new MapColor(255, 0x4E, 0xD3, 0x4E);
                    connectorOptions.StrokeThickness = 2;

                    MapInfoboxOptions calloutOptions = new MapInfoboxOptions();
                    calloutOptions.Width = 50;
                    calloutOptions.Height = 50;
                    calloutOptions.ShowPointer = false;
                    calloutOptions.ShowCloseButton = false;
                    calloutOptions.Offset = new MapPoint(-25, -25);
                    calloutOptions.HtmlContent =
                        "<div class=\"photoInfobox\" style=\"background-image: url(" + photo.thumbnailUrl + ")\"" +
                        " title=\"" + photo.title.HtmlEncode() + "\"></div>";
                    calloutOptions.Visible = true;

                    MapPushpinOptions pushpinOptions = new MapPushpinOptions();
                    pushpinOptions.Icon = "Dot.png";
                    pushpinOptions.Width = 10;
                    pushpinOptions.Height = 10;
                    pushpinOptions.Anchor = new MapPoint(5, 5);
                    pushpinOptions.TypeName = "locationPushpin";

                    photoView = new PhotoView();
                    photoView.pushpin = new MapPushpin(location, pushpinOptions);
                    photoView.connector = new MapPolyline(new MapLocation[] { location, location }, connectorOptions);
                    photoView.callout = new MapInfobox(location, calloutOptions);
                    photoView.callout.Data = photo;
                    _photoViews[photo.id] = photoView;

                    _mapEntities.Insert(photoView.connector, 0);
                    _mapEntities.Insert(photoView.callout, 0);
                    _mapEntities.Insert(photoView.pushpin, 0);
                    MapEvents.AddHandler(photoView.callout, "click", delegate(MapEventArgs e) {
                        ShowPhoto(photo);
                    });
                }
                else {
                    photoView = _photoViews[photo.id];
                }

                photoView.pushpinNode = new GraphNode();
                photoView.pushpinNode.x = point.X;
                photoView.pushpinNode.y = point.Y;
                photoView.pushpinNode.moveable = false;

                photoView.calloutNode = new GraphNode();
                photoView.calloutNode.x = point.X;
                photoView.calloutNode.y = point.Y;

                GraphEdge connectorEdge = new GraphEdge(photoView.pushpinNode,
                                                        photoView.calloutNode,
                                                        10 + Math.Random() * 15);

                _graph.AddNode(photoView.pushpinNode);
                _graph.AddNode(photoView.calloutNode);
                _graph.AddEdge(connectorEdge);
            });

            Window.SetTimeout(UpdateLayout, 30);
        }
Example #10
0
        public void RemoveEdge(GraphEdge edge) {
            edge.FromNode.RemoveEdge(edge);
            edge.ToNode.RemoveEdge(edge);

            _edges.Remove(edge);
            if (_updating == false) {
                RaiseChangedEvent();
            }
            else {
                _updated = true;
            }
        }