/// <summary> /// Gets an <see cref="IBoundsProvider"/> implementation that can yield /// this arrow's bounds if painted at the given location using the /// given direction for the given edge. /// </summary> /// <param name="edge">the edge this arrow belongs to</param> /// <param name="atSource">whether this will be the source arrow</param> /// <param name="anchor">the anchor point for the tip of the arrow</param> /// <param name="directionVector">the direction the arrow is pointing in</param> /// <returns> /// an implementation of the <see cref="IBoundsProvider"/> interface that can /// subsequently be used to query the bounds. Clients will always call /// this method before using the implementation and may not cache the instance returned. /// This allows for applying the flyweight design pattern to implementations. /// </returns> public IBoundsProvider GetBoundsProvider(IEdge edge, bool atSource, PointD anchor, PointD directionVector) { // Get the edge's thickness MySimpleEdgeStyle style = edge.Style as MySimpleEdgeStyle; if (style != null) { thickness = style.PathThickness; } else { thickness = Thickness; } this.anchor = anchor; this.direction = directionVector; return(this); }
/// <summary> /// Gets an <see cref="IVisualCreator"/> implementation that will paint /// this arrow at the given location using the given direction /// for the given edge. /// </summary> /// <param name="edge">the edge this arrow belongs to</param> /// <param name="atSource">whether this will be the source arrow</param> /// <param name="anchor">the anchor point for the tip of the arrow</param> /// <param name="direction">the direction the arrow is pointing in</param> /// <returns> /// Itself as a flyweight. /// </returns> public IVisualCreator GetVisualCreator(IEdge edge, bool atSource, PointD anchor, PointD direction) { // Get the edge's thickness MySimpleEdgeStyle style = edge.Style as MySimpleEdgeStyle; if (style != null) { thickness = style.PathThickness; } else { thickness = Thickness; } this.anchor = anchor; this.direction = direction; return(this); }
/// <summary> /// Configures the thickness to use for the next visual creation. /// </summary> /// <param name="edge">The edge to read the thickness from.</param> private void ConfigureThickness(IEdge edge) { // Get the edge's thickness MySimpleEdgeStyle style = edge.Style as MySimpleEdgeStyle; double oldThickness = thickness; if (style != null) { thickness = style.PathThickness; } else { thickness = Thickness; } // see if the old arrow figure needs to be invalidated... if (thickness != oldThickness) { arrowFigure = null; } }