private void SeriesUpdate() { if (RenderableSeries != null) { RenderableSeries.Clear(); RenderableSeries.Add(new ColumnRenderableSeriesViewModel() { DataPointWidth = 1, Stroke = System.Windows.Media.Color.FromRgb(186, 187, 190), DataSeries = Series }); } if (Data != null && Series != null) { XList.Clear(); YList.Clear(); XList = Data.Keys.ToList(); YList = Data.Values.ToList(); try { Series.Clear(); Series.InsertRange(0, XList, YList); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
//public OrbitSpec(OrbitsCollection orbits, PlanetId id, OrbitInfoType kind) //{ // YList = orbits[id, kind]; // XList = (kind < OrbitInfoType.Ascending) ? orbits.DayByDay : orbits.MonthByMonth; // if (Count != YList.Count) // throw new Exception(); // Label = LableOf(id, kind); // if (kind == OrbitInfoType.Longitude) // DisplayColor = Planet.ColorOf(id); // else if (kind.ToString().Contains("Distance") || kind.ToString().Contains("Velocities")) // { // DisplayColor = Color.DarkCyan; // } // else if (kind.ToString().Contains("Latitude")) // { // DisplayColor = Color.DarkGray; // } // else // { // Color baseColor = Planet.ColorOf(id); // int g = (baseColor.G == 0) ? 0 : (int)(baseColor.G * (1 - (int)kind / 16.0)); // int b = (baseColor.B == 0) ? 0 : (int)(baseColor.B * (1 - (int)kind / 16.0)); // int r = (baseColor.R == 0) ? 0 : (int)(baseColor.R * (1 - (int)kind / 16.0)); // int a = (baseColor.A == 0) ? 0 : (int)(baseColor.A * (1 - (int)kind / 16.0)); // DisplayColor = Color.FromArgb(a, r, g, b); // } // Symbol = SymbolType.None; // OriginalCurve = new LineItem(Label, XList.ToArray(), YList.ToArray(), DisplayColor, Symbol); //} public OrbitSpec(PlanetId id, OrbitInfoType kind, List <double> xList, List <double> yList) { Id = id; Kind = kind; XList = xList; if (kind == OrbitInfoType.Distance) { Double averageDistance = Planet.AverageDistances[id]; YList = (from y in yList select y - averageDistance).ToList(); } else { YList = yList; } if (Count != YList.Count) { throw new Exception(); } DisplayColor = Planet.ColorOf(id, kind); //if (kind == OrbitInfoType.Longitude || kind == OrbitInfoType.LongVelocityAndLatitude || kind == OrbitInfoType.LongitudeAcceleration) //{ // DisplayColor = Planet.ColorOf(id); //} //else if (kind.ToString().EndsWith("Latitude")) //{ // DisplayColor = WeightedColor(Planet.ColorOf(id), 0.9f, true); //} //else if (kind.ToString().EndsWith("Distance")) //{ // DisplayColor = WeightedColor(Planet.ColorOf(id), 0.5f, true); //} //else if (kind.ToString().EndsWith("Velocities")) //{ // DisplayColor = WeightedColor(Planet.ColorOf(id), 0.8f, false); //} //else //{ // Color baseColor = Planet.ColorOf(id); // int g = (baseColor.G == 0) ? 0 : (int)(baseColor.G * (1 - (int)kind / 16.0)); // int b = (baseColor.B == 0) ? 0 : (int)(baseColor.B * (1 - (int)kind / 16.0)); // int r = (baseColor.R == 0) ? 0 : (int)(baseColor.R * (1 - (int)kind / 16.0)); // int a = (baseColor.A == 0) ? 0 : (int)(baseColor.A * (1 - (int)kind / 16.0)); // DisplayColor = Color.FromArgb(a, r, g, b); //} Symbol = SymbolType.None; OriginalCurve = new LineItem(Label, XList.ToArray(), YList.ToArray(), DisplayColor, Symbol); }
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 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(); }