protected GraphSceneContextVisualizer <IVisual, IVisualEdge> SceneWorkerWithTestData(int exampleNr, AlignerOptions options, int count = 1) { var scene = SceneWithTestData(exampleNr, count); var worker = new GraphSceneContextVisualizer <IVisual, IVisualEdge> (); worker.Compose(scene, new VisualsRenderer()); worker.StyleSheet.BackColor = Colors.WhiteSmoke; worker.Layout.SetOptions(options); worker.Folder.ShowAllData(); worker.Modeller.Perform(); worker.Modeller.Finish(); scene.Focused = scene.Graph.FindRoots(null).First(); return(worker); }
Size PaintScene(Context ctx, double x, double y, int example) { var scene = SceneWithTestData(example); var styleSheets = Registry.Pooled <StyleSheets>(); var styleSheet = styleSheets[styleSheets.StyleSheetNames[(DateTime.Now.Millisecond % 2) + 1]]; //errror here: wrong fontdata! styleSheet.EdgeStyle.DefaultStyle.PaintData = true; var worker = new GraphSceneContextVisualizer <IVisual, IVisualEdge> { StyleSheet = styleSheet }; worker.Compose(scene, new VisualsRenderer()); worker.Folder.ShowAllData(); worker.Modeller.Perform(); worker.Modeller.Finish(); worker.Painter.Paint(ctx); return(scene.Shape.Size); }
public void BlockAlgin() { var options = new AlignerOptions { AlignX = Alignment.Start, AlignY = Alignment.Start, Dimension = Dimension.X, PointOrder = PointOrder.XY, Collisions = Collisions.None, }; var scene = SceneWithTestData(3, 1); var worker = new GraphSceneContextVisualizer <IVisual, IVisualEdge> (); worker.Compose(scene, new VisualsRenderer()); worker.StyleSheet.BackColor = Colors.WhiteSmoke; worker.Layout.SetOptions(options); worker.Folder.AddRaw(scene.Graph.RootSource()?.Source); worker.Modeller.Perform(); worker.Modeller.Finish(); var origins = scene.Graph.FindRoots(null); scene.Focused = origins.First(); options.Distance = worker.Layout.Distance; var visualComparer = new VisualComparer(); var aligner = new Aligner <IVisual, IVisualEdge> (worker.Scene, worker.Layout); var graphView = worker.Scene.Graph as SubGraph <IVisual, IVisualEdge>; graphView.Edges().ForEach(e => e.Data = ""); // var roots = new IVisual [] { worker.Scene.Focused }; var walk = new Walker1 <IVisual, IVisualEdge> (graphView); //walk.Trace = true; walk.Comparer = visualComparer; var startPoint = (Point)worker.Layout.Border; foreach (var origin in origins) { ReportDetail($"-> {origin}\t{startPoint}"); var bounds = AlignByPath(walk.DeepWalk(origin, 1, null, false), options, aligner, startPoint); startPoint.Y += bounds.Height + options.Distance.Height; } aligner.Commit(); worker.Modeller.Perform(); worker.Modeller.Finish(); ReportPainter.PushPaint(ctx => worker.Painter.Paint(ctx)); foreach (var r in TrackBounds.Where(r => !r.IsEmpty)) { ReportPainter.PushPaint(ctx => { var translate = worker.Painter.Viewport.ClipOrigin; ctx.Save(); ctx.Translate(-translate.X, -translate.Y); ctx.SetColor(Colors.Red); ctx.SetLineWidth(0.5); ctx.SetLineDash(0, 2, 5); ctx.Rectangle(r); ctx.ClosePath(); ctx.Stroke(); ctx.Restore(); }); } WritePainter(); }
public void TestShowAllData() { var options = new AlignerOptions { AlignX = Alignment.Center, AlignY = Alignment.Start, Dimension = Dimension.X, PointOrder = PointOrder.XY, //Collisions = Collisions.NextFree }; var scene = SceneWithTestData(0); var graphView = scene.Graph as SubGraph <IVisual, IVisualEdge>; var graph = graphView.Source; for (int i = 1; i < 6; i++) { (SceneWithTestData(i).Graph as SubGraph <IVisual, IVisualEdge>) .Source.ForEach(item => graph.Add(item)); } var worker = new GraphSceneContextVisualizer <IVisual, IVisualEdge> (); worker.Compose(scene, new VisualsRenderer()); worker.StyleSheet.BackColor = Colors.WhiteSmoke; worker.Layout.SetOptions(options); options.Distance = worker.Layout.Distance; Action allData = () => { var roots = new Queue <IVisual> (graph.FindRoots(null)); var walk = graph.Walk(); roots.ForEach(root => walk.DeepWalk(root, 0).ForEach(item => graphView.Sink.Add(item.Node))); walk = graphView.Walk(); var aligner = new Aligner <IVisual, IVisualEdge> (scene, worker.Layout); //var bounds = new Rectangle(worker.Layout.Border.Width, worker.Layout.Border.Height, 0, 0); var pos = new Point(worker.Layout.Border.Width, worker.Layout.Border.Height); roots.ForEach(root => { var steps = walk.DeepWalk(root, 1).Where(l => !(l.Node is IVisualEdge)).ToArray(); var bounds = new Rectangle(pos, Size.Zero); var cols = aligner.MeasureWalk(steps, ref bounds, options); //bounds = aligner.NextFreeSpace(bounds.Location, bounds.Size, walk.Select(t => t.Node), Dimension.Y, options.Distance); pos = new Point(pos.X, pos.Y + bounds.Size.Height + options.Distance.Height); aligner.LocateColumns(cols, bounds, options); //bounds.Top = bounds.Bottom + options.Distance.Height; }); aligner.Commit(); worker.Modeller.Perform(); worker.Modeller.Finish(); }; allData(); allData(); ReportPainter.PushPaint(ctx => worker.Painter.Paint(ctx)); WritePainter(); }