/// <summary> /// Creates a Node instance /// </summary> /// <param name="id">node name</param> public Node(string id) { Label = new Label(); Label.GeometryLabel = null; Label.Owner = this; Attr = new NodeAttr(); attr.Id = id; Label.Text = id; //one can change the label later }
/// <summary> /// Creates a Node instance /// </summary> /// <param name="id">node name</param> public Node(string id) { this.DefaultStyleKey = typeof(Node); Label = new Label(); Label.GeometryLabel = null; Label.Owner = this; Label.Text = id; // one can change the label text later - TJT: Huh??? Attr = new NodeAttr(); attr.Id = id; }
internal static void DragLabel(GeomLabel label, Point delta) { label.Center += delta; var edge = label.GeometryParent as GeomEdge; if (edge != null) { CalculateAttachedSegmentEnd(label, edge); if (!ApproximateComparer.Close(label.AttachmentSegmentEnd, label.Center)) { IntersectionInfo x = Curve.CurveCurveIntersectionOne(label.BoundingBox.Perimeter(), new LineSegment( label.AttachmentSegmentEnd, label.Center), false); label.AttachmentSegmentStart = x != null ? x.IntersectionPoint : label.Center; } else { label.AttachmentSegmentStart = label.Center; } } }
static void CalculateAttachedSegmentEnd(GeomLabel label, GeomEdge edge) { label.AttachmentSegmentEnd = edge.Curve[edge.Curve.ClosestParameter(label.Center)]; }
string LabelToString(Label label) { return String.Format("{0} {1} {2}", PointToString(label.Center), DoubleToString(label.Width), DoubleToString(label.Height)); }
void WriteLabel(Label label) { WriteAttribute(GeometryToken.Label, LabelToString(label)); }
private static IEnumerable<double> GetPossibleSides(Label.PlacementSide side, Point derivative) { MethodInfo methodInfo = typeof(EdgeLabelPlacement).GetMethod("GetPossibleSides", BindingFlags.Static | BindingFlags.NonPublic); return (IEnumerable<double>)methodInfo.Invoke(null, new object[] { side, derivative }); }
/// <summary> /// Edge constructor /// </summary> /// <param name="source"></param> /// <param name="target"></param> /// <param name="labelWidth"></param> /// <param name="labelHeight"></param> /// <param name="edgeThickness"></param> public Edge(Node source, Node target, double labelWidth, double labelHeight, double edgeThickness) { this.source = source; this.target = target; if (labelWidth > 0) Label = new Label(labelWidth, labelHeight, this); LineWidth = edgeThickness; }
internal static void DragLabel(GeomLabel label, Point delta) { label.Center += delta; var edge = label.GeometryParent as GeomEdge; if (edge != null) { CalculateAttachedSegmentEnd(label, edge); if (!ApproximateComparer.Close(label.AttachmentSegmentEnd, label.Center)) { IntersectionInfo x = Curve.CurveCurveIntersectionOne(label.BoundingBox.Perimeter(), new LineSegment( label.AttachmentSegmentEnd, label.Center), false); label.AttachmentSegmentStart = x != null ? x.IntersectionPoint : label.Center; } else label.AttachmentSegmentStart = label.Center; } }
void ReadLabelFromAttribute(GeometryObject geomObj) { string str; if (!TryGetAttribute(GeometryToken.Label, out str)) return; var label = new Label(geomObj); Point center; double width, height; ParseLabel(str, out center, out width, out height); label.Center = center; label.Width = width; label.Height = height; var edge = geomObj as Edge; if (edge != null) { edge.Label = label; } }
void RouteEdgeWithLabel(IntEdge intEdge, Label label) { //we allow here for the edge to cross its own label Node sourceNode = routing.IntGraph.Nodes[intEdge.Source]; Node targetNode = routing.IntGraph.Nodes[intEdge.Target]; var sourcePort = new FloatingPort(sourceNode.BoundaryCurve, sourceNode.Center); var targetPort = new FloatingPort(targetNode.BoundaryCurve, targetNode.Center); ICurve labelObstacle = labelsToLabelObstacles[label]; var labelPort = new FloatingPort(labelObstacle, label.Center); SmoothedPolyline poly0; interactiveEdgeRouter.RouteSplineFromPortToPortWhenTheWholeGraphIsReady(sourcePort, labelPort, true, out poly0); SmoothedPolyline poly1; interactiveEdgeRouter.RouteSplineFromPortToPortWhenTheWholeGraphIsReady(labelPort, targetPort, true, out poly1); Site site = poly1.HeadSite.Next; Site lastSite = poly0.LastSite; lastSite.Next = site; site.Previous = lastSite; var eg = intEdge.Edge.EdgeGeometry; eg.SetSmoothedPolylineAndCurve(poly0); Arrowheads.TrimSplineAndCalculateArrowheads(eg, intEdge.Edge.Source.BoundaryCurve, intEdge.Edge.Target.BoundaryCurve, eg.Curve, false, settings.EdgeRoutingSettings.KeepOriginalSpline); }
static ICurve CreatObstaceOnLabel(Label label) { var c = new Curve(); double obstacleBottom = label.Center.Y - label.Height/4; c.AddSegment(new LineSegment(new Point(label.BoundingBox.Left, obstacleBottom), new Point(label.BoundingBox.Right, obstacleBottom))); Curve.ContinueWithLineSegment(c, label.BoundingBox.RightTop); Curve.ContinueWithLineSegment(c, label.BoundingBox.LeftTop); Curve.CloseCurve(c); return c; }
/// <summary> /// creates label restore data /// </summary> /// <returns></returns> public static RestoreData GetRestoreData(Label label) { return new LabelRestoreData(label.Center); }