コード例 #1
0
        /// <summary>
        /// Returns possible parameters for the given label and model.
        /// </summary>
        /// <param name="label">The label for which to retrieve the parameters</param>
        /// <param name="model"> must be <c>this</c> or at least of this type.</param>
        public virtual IEnumerable <ILabelModelParameter> GetParameters(ILabel label, ILabelModel model)
        {
            RotatingEdgeLabelModel      rotatingEdgeLabelModel = (RotatingEdgeLabelModel)model;
            List <ILabelModelParameter> candidates             = new List <ILabelModelParameter>();

            for (int i = 0; i <= 10; i++)
            {
                candidates.Add(new RatioParameter(rotatingEdgeLabelModel, i * 0.1));
            }
            return(candidates);
        }
コード例 #2
0
            public void SetGeometry(RotatingEdgeLabelModel model, ILabel label, IMutableOrientedRectangle rect)
            {
                IEdge  edge = (IEdge)label.Owner;
                double upX;
                double upY;
                double cx;
                double cy;

                if (edge != null && FindAnchorTangent(edge, out upX, out upY, out cx, out cy))
                {
                    double newAngle = Math.Atan2(upX, -upY) + model.Angle;

                    double distance = model.Distance;
                    if (distance != 0)
                    {
                        double l = Math.Sqrt(upX * upX + upY * upY);
                        if (l > 0)
                        {
                            upX /= l;
                            upY /= l;

                            if (!model.EdgeRelativeDistance && upY > 0)
                            {
                                distance = -distance;
                            }

                            cx += upX * distance;
                            cy += upY * distance;
                        }
                    }

                    double sin = Math.Sin(newAngle);
                    double cos = -Math.Cos(newAngle);
                    rect.SetUpVector(sin, cos);

                    double w = label.PreferredSize.Width;
                    double h = label.PreferredSize.Height;
                    rect.Width  = w;
                    rect.Height = h;
                    rect.SetCenter(new PointD(cx, cy));
                }
                else
                {
                    rect.Width  = -1;
                    rect.Height = -1;
                }
            }
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            RotatingEdgeLabelModel exModel = (RotatingEdgeLabelModel)Model;

            return(exModel.CreateRatio(Ratio));
        }
コード例 #4
0
 public RatioParameter(RotatingEdgeLabelModel model, double r)
 {
     this.ratio = r;
     this.model = model;
 }