/// <summary> /// Method that populates the <see cref="IPropertyMap"/> for edge styles in a given context. /// </summary> /// <remarks> /// This implementation uses <see cref="GetStylePropertyMapBuilder"/> to retrieve the builder for the style. /// </remarks> /// <param name="context">The context to use for queries.</param> protected virtual void BuildStyleProperties(IPropertyBuildContext <IEdge> context) { IEdge edge = context.CurrentInstance; if (edge != null) { IEdgeStyle style = edge.Style; if (style != null) { IPropertyMapBuilder propertyBuilder = GetStylePropertyMapBuilder(context, style); if (propertyBuilder != null) { GetInstanceDelegate <IEdgeStyle> styleGetter = delegate { return(context.CurrentInstance.Style); }; SetInstanceDelegate <IEdgeStyle> styleSetter = delegate(IEdgeStyle newInstance) { IGraph graph = context.Lookup(typeof(IGraph)) as IGraph; IEdge currentEdge = context.CurrentInstance; if (graph != null) { graph.SetStyle(currentEdge, newInstance); } }; propertyBuilder.BuildPropertyMap(context.CreateChildContext(DefaultEdgeOptionBuilder.StylePropertyName, styleGetter, styleSetter, styleAssignmentPolicy)); } } } }
public IVisualCreator GetVisualCreator(IEdge edge, IEdgeStyle style) { this.style = (BpmnEdgeStyle)style; this.edge = edge; delegateRenderer.GetVisualCreator(this.edge, this.style.delegateStyle); return(this); }
/// <summary> /// Builds the options for the style of the edge instance. /// </summary> /// <param name="context">The context to use for building.</param> /// <param name="edge">The current edge instance.</param> protected virtual void BuildStyleOptions(IOptionBuilderContext context, IEdge edge) { context = context.CreateChildContext(StylePropertyName); //style group... //retrieve current style... IEdgeStyle style = edge.Style; if (style != null) { //retrieve OptionBuilder from style IOptionBuilder builder = GetStyleOptionBuilder(context, style); if (builder != null) { builder.AddItems(context, style.GetType(), style); } } }
/// <summary> /// Called by the various edge creation callbacks to create an edge in the resulting graph view /// that corresponds to the provided <paramref name="layoutEdge"/>. /// </summary> /// <remarks> /// If a model edge is provided, the edge will be created between the copies of the corresponding /// source/target ports. /// </remarks> ///<param name="pageLayoutGraph">The layout graph representing the current page.</param> ///<param name="pageView">The <see cref="IGraph"/> that is built to show the multi-page layout in a graph canvas.</param> ///<param name="layoutEdge">The edge of the layout graph that should be copied.</param> ///<param name="modelEdge">The edge of the original input graph that corresponds to the <paramref name="layoutEdge"/> (may be <see langword="null"/>).</param> ///<param name="edgeDefaults"></param> ///<returns>The created edge</returns> /// <seealso cref="CreateConnectorEdge"/> /// <seealso cref="CreateNormalEdge"/> /// <seealso cref="CreateProxyEdge"/> /// <seealso cref="CreateProxyReferenceEdge"/> protected IEdge CreateEdgeCore(LayoutGraph pageLayoutGraph, IGraph pageView, Edge layoutEdge, IEdge modelEdge, IEdgeDefaults edgeDefaults) { IEdge viewEdge; if (modelEdge != null) { // if the edge has a model edge: create the copied edge between // the copies of its source and target ports IPort modelSourcePort = modelEdge.SourcePort; IPort modelTargetPort = modelEdge.TargetPort; IPort viewSourcePort = GetViewPort(modelSourcePort); IPort viewTargetPort = GetViewPort(modelTargetPort); IEdgeStyle style = (IEdgeStyle)(edgeDefaults.Style != NullEdgeStyle ? edgeDefaults.GetStyleInstance() : modelEdge.Style.Clone()); viewEdge = pageView.CreateEdge(viewSourcePort, viewTargetPort, style, modelEdge.Tag); } else { // otherwise create it between the copies of its source and target nodes INode viewSource = GetViewNode(layoutEdge.Source); INode viewTarget = GetViewNode(layoutEdge.Target); viewEdge = pageView.CreateEdge(viewSource, viewTarget); } // adjust the port location YPoint newSourcePortLocation = pageLayoutGraph.GetSourcePointAbs(layoutEdge); YPoint newTargetPortLocation = pageLayoutGraph.GetTargetPointAbs(layoutEdge); pageView.SetPortLocation(viewEdge.SourcePort, newSourcePortLocation.ToPointD()); pageView.SetPortLocation(viewEdge.TargetPort, newTargetPortLocation.ToPointD()); // and copy the bends IEdgeLayout edgeLayout = pageLayoutGraph.GetLayout(layoutEdge); for (int i = 0; i < edgeLayout.PointCount(); i++) { YPoint bendLocation = edgeLayout.GetPoint(i); pageView.AddBend(viewEdge, new PointD(bendLocation.X, bendLocation.Y), i); } return(viewEdge); }
public IBoundsProvider GetBoundsProvider(IEdge edge, IEdgeStyle style) { var delegateStyle = ((DynamicArrowEdgeStyleBase)style).GetDelegateStyle(); return(delegateStyle.Renderer.GetBoundsProvider(edge, delegateStyle)); }
/// <inheritdoc /> public IHitTestable GetHitTestable(IEdge edge, IEdgeStyle style) { return(Style.Renderer.GetHitTestable(edge, Style)); }
/// <inheritdoc /> public IBoundsProvider GetBoundsProvider(IEdge edge, IEdgeStyle style) { return(Style.Renderer.GetBoundsProvider(edge, Style)); }
/// <summary> /// Initializes a new instance of the <see cref="WrapperEdgeStyle" /> class, wrapping the given /// <see cref="IEdgeStyle" />. /// </summary> /// <param name="style">The style to wrap.</param> public WrapperEdgeStyle(IEdgeStyle style) { Style = style; }
/// <inheritdoc /> public ILookup GetContext(IEdge edge, IEdgeStyle style) { return(Style.Renderer.GetContext(edge, Style)); }
public IHitTestable GetHitTestable(IEdge edge, IEdgeStyle style) { var delegateStyle = ((DynamicArrowEdgeStyleBase)style).GetDelegateStyle(); return(delegateStyle.Renderer.GetHitTestable(edge, delegateStyle)); }
public IVisibilityTestable GetVisibilityTestable(IEdge edge, IEdgeStyle style) { this.style = (BpmnEdgeStyle)style; return(delegateRenderer.GetVisibilityTestable(edge, this.style.delegateStyle)); }
public IPathGeometry GetPathGeometry(IEdge edge, IEdgeStyle style) { this.style = (BpmnEdgeStyle)style; return(delegateRenderer.GetPathGeometry(edge, this.style.delegateStyle)); }
public IBoundsProvider GetBoundsProvider(IEdge edge, IEdgeStyle style) { this.style = (BpmnEdgeStyle)style; return(delegateRenderer.GetBoundsProvider(edge, this.style.delegateStyle)); }
/// <summary> /// Method that retrieves the <see cref="IPropertyMapBuilder"/> for the provided style instance. /// </summary> /// <remarks> /// This implementation simply delegates to <see cref="IPropertyBuildContext{TSubject}.GetPropertyMapBuilder(object)"/>. /// </remarks> /// <param name="context">The context to use for queries.</param> /// <param name="style">The style instance currently associated with the edge.</param> /// <returns>A builder or <see langword="null"/></returns> protected virtual IPropertyMapBuilder GetStylePropertyMapBuilder(IPropertyBuildContext <IEdge> context, IEdgeStyle style) { return(context.GetPropertyMapBuilder(style)); }
public ILookup GetContext(IEdge edge, IEdgeStyle style) { var delegateStyle = ((DynamicArrowEdgeStyleBase)style).GetDelegateStyle(); return(delegateStyle.Renderer.GetContext(edge, delegateStyle)); }
public IPathGeometry GetPathGeometry(IEdge edge, IEdgeStyle style) { var delegateStyle = ((DynamicArrowEdgeStyleBase)style).GetDelegateStyle(); return(delegateStyle.Renderer.GetPathGeometry(edge, delegateStyle)); }
public IMarqueeTestable GetMarqueeTestable(IEdge edge, IEdgeStyle style) { this.style = (BpmnEdgeStyle)style; return(delegateRenderer.GetMarqueeTestable(edge, this.style.delegateStyle)); }
/// <inheritdoc /> public IMarqueeTestable GetMarqueeTestable(IEdge edge, IEdgeStyle style) { return(Style.Renderer.GetMarqueeTestable(edge, Style)); }
public ILookup GetContext(IEdge edge, IEdgeStyle style) { this.style = (BpmnEdgeStyle)style; return(delegateRenderer.GetContext(edge, this.style.delegateStyle)); }
/// <inheritdoc /> public IPathGeometry GetPathGeometry(IEdge edge, IEdgeStyle style) { return(Style.Renderer.GetPathGeometry(edge, Style)); }
/// <summary> /// Implementation that always returns a path geometry. /// </summary> private static IPathGeometry GetPathGeometry(IEdge edge) { IEdgeStyle style = edge.Style; return(style.Renderer.GetPathGeometry(edge, style)); }
/// <inheritdoc /> public IVisualCreator GetVisualCreator(IEdge edge, IEdgeStyle style) { return(Style.Renderer.GetVisualCreator(edge, Style)); }
private bool FindAnchorTangent(IEdge edge, out double upX, out double upY, out double cx, out double cy) { IEdgeStyle style = edge.Style; if (style != null) { IEdgeStyleRenderer renderer = style.Renderer; IPathGeometry geometry = renderer.GetPathGeometry(edge, style); if (geometry != null) { var t = geometry.GetTangent(ratio); if (t != null) { var tangent = t.Value; upX = -tangent.Vector.Y; upY = tangent.Vector.X; cx = tangent.Point.X; cy = tangent.Point.Y; return(true); } } } double l = 0; var spl = edge.SourcePort.GetLocation(); double x1 = spl.X; double y1 = spl.Y; var tpl = edge.TargetPort.GetLocation(); double x2 = tpl.X; double y2 = tpl.Y; { double lx = x1; double ly = y1; var bends = edge.Bends; for (int i = 0; i < bends.Count; i++) { IBend bend = bends[i]; double bx = bend.Location.X; double by = bend.Location.Y; double dx = bx - lx; double dy = by - ly; l += Math.Sqrt(dx * dx + dy * dy); lx = bx; ly = by; } { double dx = x2 - lx; double dy = y2 - ly; l += Math.Sqrt(dx * dx + dy * dy); } } double tl = ratio * l; if (l == 0) { // no length, no path, no label upX = 0; upY = -1; cx = x1; cy = y1; return(false); } l = 0; { double lx = x1; double ly = y1; var bends = edge.Bends; for (int i = 0; i < bends.Count; i++) { IBend bend = bends[i]; double bx = bend.Location.X; double by = bend.Location.Y; double dx = bx - lx; double dy = by - ly; double sl = Math.Sqrt(dx * dx + dy * dy); if (sl > 0 && l + sl >= tl) { tl -= l; cx = lx + tl * dx / sl; cy = ly + tl * dy / sl; upX = -dy; upY = dx; return(true); } l += sl; lx = bx; ly = by; } { double dx = x2 - lx; double dy = y2 - ly; double sl = Math.Sqrt(dx * dx + dy * dy); if (sl > 0) { tl -= l; cx = lx + tl * dx / sl; cy = ly + tl * dy / sl; upX = -dy; upY = dx; return(true); } else { upX = 0; upY = -1; cx = x1; cy = y1; return(false); } } } }
/// <inheritdoc /> public IVisibilityTestable GetVisibilityTestable(IEdge edge, IEdgeStyle style) { return(Style.Renderer.GetVisibilityTestable(edge, Style)); }
public IVisualCreator GetVisualCreator(IEdge edge, IEdgeStyle style) { var delegateStyle = ((DynamicArrowEdgeStyleBase)style).GetDelegateStyle(); return(delegateStyle.Renderer.GetVisualCreator(edge, delegateStyle)); }
/// <summary> /// Initializes a new instance of the <see cref="VirtualizationEdgeStyleDecorator" /> class with the given virtualization /// threshold and wrapped style. /// </summary> /// <param name="threshold">The zoom level below which virtualization is turned off.</param> /// <param name="style">The wrapped style.</param> public VirtualizationEdgeStyleDecorator(double threshold, IEdgeStyle style) { Style = style; Threshold = threshold; }
/// <summary> /// Method that retrieves an <see cref="IOptionBuilder"/> instance for the given style and context. /// </summary> /// <remarks> /// This implementation simply delegates to <see cref="IOptionBuilderContext.GetOptionBuilder(object)"/>. /// </remarks> /// <param name="context">The context to use.</param> /// <param name="style">The current style instance.</param> /// <returns>The builder to use or <see langword="null"/>.</returns> protected virtual IOptionBuilder GetStyleOptionBuilder(IOptionBuilderContext context, IEdgeStyle style) { return(context.GetOptionBuilder(style)); }