Draws a NodeXL graph onto a collection of Visual objects.
This is used to draw a NodeXL graph in a WPF application. It contains a collection of Visual objects that represent the graph's vertices and edges. Call DrawGraph to draw a laid-out NodeXL graph onto the contained GraphDrawer.VisualCollection.

GraphDrawer does not lay out the graph. You should lay out the graph using one of the provided layout classes before calling .

A GraphDrawer cannot be directly rendered and is typically not used directly by an application. Applications typically use one of two other NodeXL graph-drawing classes:

NodeXLControl, which is a FrameworkElement that wraps a and hosts its . NodeXLControl is meant for use in WPF desktop applications. It automatically lays out the graph before drawing it. NodeXLVisual, which is a Visual that wraps a and hosts its . This is a lower-level alternative to NodeXLControl and can be used anywhere a Visual is more appropriate than a FrameworkElement. Like GraphDrawer, does not lay out the graph before drawing it.

If you do use GraphDrawer directly, rendering the graph requires a custom wrapper that hosts the GraphDrawer. object.

Inheritance: DrawerBase
Ejemplo n.º 1
0
    CreateGraphDrawer()
    {
        m_oGraphDrawer = new GraphDrawer(this);

        m_oGraphDrawer.EdgeDrawer.CurveStyleChanged +=
            new EventHandler(EdgeDrawer_CurveStyleChanged);

        // AssertValid();
    }
    TransferToGraphDrawer
    (
        GraphDrawer graphDrawer
    )
    {
        Debug.Assert(graphDrawer != null);
        AssertValid();

        Font oFont = this.Font;

        System.Windows.Media.Typeface oTypeface =
            WpfGraphicsUtil.FontToTypeface(oFont);

        Double dFontSize = WpfGraphicsUtil.SystemDrawingFontSizeToWpfFontSize(
            oFont.Size);

        VertexDrawer oVertexDrawer = graphDrawer.VertexDrawer;

        oVertexDrawer.SetFont(oTypeface, dFontSize);

        oVertexDrawer.LabelFillColor =
            WpfGraphicsUtil.ColorToWpfColor(this.VertexLabelFillColor);

        oVertexDrawer.LabelPosition = this.VertexLabelPosition;
        oVertexDrawer.MaximumLabelLength = this.VertexLabelMaximumLength;
        oVertexDrawer.LabelWrapText = this.VertexLabelWrapText;

        oVertexDrawer.LabelWrapMaxTextWidth =
            this.VertexLabelWrapMaxTextWidth;

        EdgeDrawer oEdgeDrawer = graphDrawer.EdgeDrawer;

        oEdgeDrawer.SetFont(oTypeface, dFontSize);

        oEdgeDrawer.LabelTextColor =
            WpfGraphicsUtil.ColorToWpfColor(this.EdgeLabelTextColor);

        oEdgeDrawer.MaximumLabelLength = this.EdgeLabelMaximumLength;

        GroupDrawer oGroupDrawer = graphDrawer.GroupDrawer;

        oGroupDrawer.SetFont(oTypeface, GroupLabelFontSize);

        oGroupDrawer.LabelTextColor = WpfGraphicsUtil.ColorToWpfColor(

            Color.FromArgb( (new AlphaConverter() ).WorkbookToGraphAsByte(
                this.GroupLabelTextAlpha),

                this.GroupLabelTextColor)
            );

        oGroupDrawer.LabelPosition = this.GroupLabelPosition;
    }
Ejemplo n.º 3
0
    //*************************************************************************
    //  Constructor: NodeXLVisual()
    //
    /// <summary>
    /// Initializes a new instance of the <see cref="NodeXLVisual" /> class.
    /// </summary>
    //*************************************************************************

    public NodeXLVisual()
    {
        m_oGraphDrawer = new GraphDrawer(this);

        AssertValid();
    }
    TransferToGraphDrawer
    (
        GraphDrawer graphDrawer
    )
    {
        Debug.Assert(graphDrawer != null);
        AssertValid();

        this.LabelUserSettings.TransferToGraphDrawer(graphDrawer);

        graphDrawer.BackColor =
            WpfGraphicsUtil.ColorToWpfColor(this.BackColor);

        if ( !String.IsNullOrEmpty(this.BackgroundImageUri) )
        {
            graphDrawer.BackgroundImage = 
                ( new WpfImageUtil() ).GetImageSynchronousIgnoreDpi(
                    this.BackgroundImageUri);
        }
        else
        {
            graphDrawer.BackgroundImage = null;
        }

        EdgeDrawer oEdgeDrawer = graphDrawer.EdgeDrawer;
        VertexDrawer oVertexDrawer = graphDrawer.VertexDrawer;

        EdgeWidthConverter oEdgeWidthConverter = new EdgeWidthConverter();
        AlphaConverter oAlphaConverter = new AlphaConverter();

        oEdgeDrawer.Width =
            oEdgeWidthConverter.WorkbookToGraph(this.EdgeWidth);

        oEdgeDrawer.Color = WpfGraphicsUtil.ColorToWpfColor(

            Color.FromArgb(oAlphaConverter.WorkbookToGraphAsByte(
                this.EdgeAlpha),

            this.EdgeColor)
            );

        oEdgeDrawer.CurveStyle = this.EdgeCurveStyle;

        oEdgeDrawer.BezierDisplacementFactor =
            this.EdgeBezierDisplacementFactor;

        oEdgeDrawer.SelectedColor = WpfGraphicsUtil.ColorToWpfColor(
            this.SelectedEdgeColor);

        oEdgeDrawer.RelativeArrowSize = this.RelativeArrowSize;

        oVertexDrawer.Shape = this.VertexShape;

        oVertexDrawer.Radius = ( new VertexRadiusConverter() ).WorkbookToGraph(
            this.VertexRadius);

        oVertexDrawer.Effect = this.VertexEffect;
        oVertexDrawer.RelativeOuterGlowSize = this.VertexRelativeOuterGlowSize;

        oVertexDrawer.Color = WpfGraphicsUtil.ColorToWpfColor(

            Color.FromArgb(oAlphaConverter.WorkbookToGraphAsByte(
                this.VertexAlpha),

            this.VertexColor)
            );

        oVertexDrawer.SelectedColor = WpfGraphicsUtil.ColorToWpfColor(
            this.SelectedVertexColor);
    }