/// <summary>
 /// Copy all labels of the given edge.
 /// </summary>
 private void CopyEdgeLabels(LayoutGraph pageLayoutGraph, IGraph pageView, Edge layoutEdge, IEdge copiedEdge, IEdge modelEdge, ILabelDefaults labelDefaults)
 {
     IEdgeLabelLayout[] edgeLabels = pageLayoutGraph.GetLabelLayout(layoutEdge);
     for (int i = 0; i < edgeLabels.Length; i++)
     {
         // get the label layout from the layout graph
         IEdgeLabelLayout edgeLabelLayout = edgeLabels[i];
         // get the original label from the model graph
         ILabel edgeModelLabel = modelEdge.Labels[i];
         CopyEdgeLabel(pageView, edgeLabelLayout, edgeModelLabel, copiedEdge, labelDefaults);
     }
 }
Exemple #2
0
        /// <summary>
        /// Returns the calculated location of the edge label. Note that the labeling
        /// machinery returns the edge labels positions as a parameter
        /// of the model that belongs to the label. This model parameter can be used
        /// to retrieve the actual location of the label as shown in this method.
        /// </summary>
        private static YPoint GetEdgeLabelLocation(LayoutGraph graph, Edge e, IEdgeLabelLayout ell)
        {
            var placement = ell.LabelModel.GetLabelPlacement(
                ell.BoundingBox,
                graph.GetLayout(e),
                graph.GetLayout(e.Source),
                graph.GetLayout(e.Target),
                ell.ModelParameter);
            YPoint ellp = new YPoint(placement.Anchor.X, placement.Anchor.Y - placement.Height);

            return(ellp);
        }
        /// <summary>
        /// Copy one edge label.
        /// </summary>
        /// <param name="pageView">The view (i.e. target) graph.</param>
        /// <param name="edgeLabelLayout">The layout of the label.</param>
        /// <param name="modelLabel">The original label.</param>
        /// <param name="viewEdge">The copied edge (from the view graph).</param>
        /// <param name="labelDefaults"></param>
        /// <returns>The copied label.</returns>
        private ILabel CopyEdgeLabel(IGraph pageView, IEdgeLabelLayout edgeLabelLayout, ILabel modelLabel, IEdge viewEdge, ILabelDefaults labelDefaults)
        {
            // get the style from edgeLabelStyle property. If none is set get it from the original (model) label.
            ILabelStyle style = (ILabelStyle)(labelDefaults.Style != NullLabelStyle ?
                                              labelDefaults.GetStyleInstance(viewEdge) :
                                              modelLabel.Style.Clone());
            ILabelModelParameter parameter = labelDefaults.LayoutParameter != NullLabelModelParameter
                            ? labelDefaults.GetLayoutParameterInstance(viewEdge)
                            : (ILabelModelParameter)edgeLabelLayout.ModelParameter;

            // create a new label in the view graph using the style,
            // the text from the original label and the layout from the layout graph
            ILabel viewLabel = pageView.AddLabel(viewEdge, modelLabel.Text, parameter, style);

            viewLabel.Tag = modelLabel.Tag;
            return(viewLabel);
        }
Exemple #4
0
        private static YOrientedRectangle GetEdgeLabelLocation(LayoutGraph graph, Edge e, IEdgeLabelLayout ell)
        {
            YOrientedRectangle ellp = ell.LabelModel.GetLabelPlacement(
                ell.BoundingBox,
                graph.GetLayout(e),
                graph.GetLayout(e.Source),
                graph.GetLayout(e.Target),
                ell.ModelParameter);

            return(ellp);
        }
Exemple #5
0
        protected void PaintEdgeLabel(Graphics g, LayoutGraph graph, Edge edge, IEdgeLabelLayout label)
        {
            YOrientedRectangle pos = GetEdgeLabelLocation(graph, edge, label);

            DrawOrientedRect(pos, g);
        }