private void PaintNodeAndChildren(Graphics g, LayoutGraph graph, Node node) { PaintNode(g, graph, node); INodeLabelLayout[] labels = layoutGraph.GetLabelLayout(node); if (labels != null && labels.Length > 0) { foreach (INodeLabelLayout label in labels) { PaintNodeLabel(g, layoutGraph, node, label); } } if (grouping.IsGroupNode(node)) { SolidBrush oldBrush = this.nodeFillBrush; Color color = Color.FromArgb(Math.Min(255, (int)(oldBrush.Color.R * 0.9f)), Math.Min(255, (int)(oldBrush.Color.G * 0.9f)), Math.Min(255, (int)(oldBrush.Color.B * 0.9f))); this.nodeFillBrush = new SolidBrush(color); for (ListCell cell = this.grouping.GetChildren(node).FirstCell; cell != null; cell = cell.Succ()) { Node child = (Node)cell.Info; PaintNodeAndChildren(g, layoutGraph, child); } this.nodeFillBrush.Dispose(); this.nodeFillBrush = oldBrush; } }
public override void ApplyLayout(LayoutGraph graph) { ApplyLayoutCore(graph); foreach (Node n in graph.Nodes) { foreach (Edge e in n.OutEdges) { bool lastSegmentOverlap = false; IEdgeLayout er = graph.GetLayout(e); if (er.PointCount() > 0) { // last bend point YPoint bendPoint = er.GetPoint(er.PointCount() - 1); IEnumerator <Edge> ecc = n.OutEdges.GetEnumerator(); loop : while (ecc.MoveNext()) { Edge eccEdge = ecc.Current; if (eccEdge != e) { YPointPath path = graph.GetPath(eccEdge); for (ILineSegmentCursor lc = path.LineSegments(); lc.Ok; lc.Next()) { LineSegment seg = lc.LineSegment; if (seg.Contains(bendPoint)) { lastSegmentOverlap = true; goto loop; } } } } } YList points = graph.GetPointList(e); for (ListCell c = points.FirstCell; c != null; c = c.Succ()) { YPoint p = (YPoint)c.Info; if (c.Succ() == null && !lastSegmentOverlap) { break; } YPoint p0 = (YPoint)(c.Pred() == null ? graph.GetSourcePointAbs(e) : c.Pred().Info); YPoint p2; if (Math.Abs(p0.X - p.X) < 0.01) { p2 = new YPoint(p.X, p.Y - 0.001); } else { p2 = new YPoint(p.X - 0.001, p.Y); } points.InsertBefore(p2, c); } graph.SetPoints(e, points); } } }
public void PaintGraph(Graphics g) { if (this.grouping != null) { for (ListCell cell = this.grouping.GetChildren(this.grouping.Root).FirstCell; cell != null; cell = cell.Succ()) { Node node = (Node)cell.Info; PaintNodeAndChildren(g, layoutGraph, node); } } else { foreach (Node node in layoutGraph.Nodes) { PaintNode(g, layoutGraph, node); INodeLabelLayout[] labels = layoutGraph.GetLabelLayout(node); if (labels != null && labels.Length > 0) { foreach (INodeLabelLayout label in labels) { PaintNodeLabel(g, layoutGraph, node, label); } } } } foreach (Edge edge in layoutGraph.Edges) { PaintEdge(g, layoutGraph, edge); IEdgeLabelLayout[] labels = layoutGraph.GetLabelLayout(edge); if (labels != null && labels.Length > 0) { foreach (IEdgeLabelLayout label in labels) { PaintEdgeLabel(g, layoutGraph, edge, label); } } } }
public static void Main() { //create new YList instance YList list = new YList(); //add numbered String elements to list for (int i = 0; i < 20; i++) { list.AddLast("" + i); } //iterate over list from first to last Console.WriteLine("List elements from front to back"); for (ICursor c = list.Cursor(); c.Ok; c.Next()) { //output element at cursor position Console.WriteLine(c.Current); } //iterate over list from last to first Console.WriteLine("List elements from back to front"); ICursor rc = list.Cursor(); for (rc.ToLast(); rc.Ok; rc.Prev()) { //output element at cursor position Console.WriteLine(rc.Current); } //sort list lexicografically list.Sort(new LexicographicComparer()); //iterate over list from first to last Console.WriteLine("Lexicographically sorted list"); for (ICursor c = list.Cursor(); c.Ok; c.Next()) { //output element at cursor position Console.WriteLine(c.Current); } //low level iteration on list cells (non-const iteration) for (ListCell cell = list.FirstCell; cell != null; cell = cell.Succ()) { String s = (String)cell.Info; //remove all Strings from list that have length == 1 if (s.Length == 1) { list.RemoveCell(cell); //note that cell is still half-valid, i.e it's Succ() and Pred() //pointers are still unchanged. therefore cell = cell.Succ() is //valid in the for-statement } } Console.WriteLine("list after element removal"); Console.WriteLine(list); //initialize list2 with the elements from list YList list2 = new YList(list.Cursor()); Console.WriteLine("list2 after creation"); Console.WriteLine(list2); //reverse element order in list2 list2.Reverse(); Console.WriteLine("list2 after reversal"); Console.WriteLine(list2); //move all elements of list2 to the end of list list.Splice(list2); Console.WriteLine("list after splicing"); Console.WriteLine(list); Console.WriteLine("list2 after splicing"); Console.WriteLine(list2); Console.WriteLine("\nPress key to end demo."); Console.ReadKey(); }