예제 #1
0
        public override void Reset()
        {
            var scene = Data;

            if (scene != null)
            {
                scene.SpatialIndex.Query(Rectangle.Zero);
                var graph = scene.Graph;

                foreach (var item in graph)
                {
                    Perform(item);
                    if (!(item is TEdge))
                    {
                        Justify(item);
                    }
                }

                PerformEdges();

                if (AlignOnReset)
                {
                    var aligner = new Aligner <TItem, TEdge>(scene, this);
                    aligner.FullLayout(scene.Focused, new Point(Border.Width, Border.Height), this.Options(), this.Comparer);
                    aligner.Commit();
                }
            }
        }
예제 #2
0
        public static void AffectedEdges <TItem, TEdge> (this Aligner <TItem, TEdge> aligner, IEnumerable <TItem> items) where TEdge : IEdge <TItem>, TItem
        {
            Action <TItem> visit = null;

            aligner.AffectedEdges(ref visit);
            aligner.VisitItems(items, visit);
        }
예제 #3
0
 public static void OneColumn <TItem, TEdge> (this Aligner <TItem, TEdge> aligner, IEnumerable <TItem> items, AlignerOptions options) where TEdge : IEdge <TItem>, TItem
 {
     if (items.Count() < 2)
     {
         return;
     }
     aligner.OneColumn(items, aligner.Locator.GetLocation(items.First()), options);
 }
예제 #4
0
        public static void FullLayout <TItem, TEdge> (this Aligner <TItem, TEdge> aligner, TItem focused, Point pos, AlignerOptions options, IComparer <TItem> comparer)
            where TEdge : IEdge <TItem>, TItem
        {
            var data   = aligner.GraphScene;
            var shaper = aligner.Shaper;

            var roots = data.Graph.FindRoots(focused);

            if (comparer == null)
            {
                roots = roots
                        .OrderBy(e => shaper.GetShape(e).Location, new PointComparer {
                    Order = options.Dimension == Dimension.X ? PointOrder.Y : PointOrder.X
                });
            }
            else
            {
                roots = roots.OrderBy(e => e, comparer);
            }

            var walk = data.Graph.Walk();

            roots.ForEach(root => {
                var steps = new List <LevelItem <TItem> > ();
                walk.DeepWalk(root, 1)
                .ForEach(l => {
                    if (l.Node is TEdge)
                    {
                        // no need; should be done in aligner.Colomns
                        aligner.Locator.AffectedEdges.Add((TEdge)l.Node);
                    }
                    else
                    {
                        steps.Add(l);
                    }
                });
                var bounds = new Rectangle(pos, Size.Zero);
                aligner.Columns(steps, ref bounds, options);
                pos = options.Dimension == Dimension.X ?
                      new Point(pos.X, pos.Y + bounds.Size.Height + options.Distance.Height) :
                      new Point(pos.X + bounds.Size.Width + options.Distance.Width, pos.Y);
            });
        }
예제 #5
0
 public static void OneColumn <TItem, TEdge> (this Aligner <TItem, TEdge> aligner, IEnumerable <TItem> items, Point at, AlignerOptions options) where TEdge : IEdge <TItem>, TItem
 {
     aligner.OneColumn(items, at, options);
 }