Manages the creation of FormattedText objects.
Call CreateFormattedText(String, Color, Double) to create a FormattedText object. The typeface and font used for creating FormattedText objects can be set using the SetFont method.
Inheritance: VisualizationBase
    //*************************************************************************
    //  Constructor: GroupDrawer()
    //
    /// <summary>
    /// Initializes a new instance of the <see cref="GroupDrawer" /> class.
    /// </summary>
    //*************************************************************************

    public GroupDrawer()
    {
        m_oLabelTextColor = SystemColors.WindowTextColor;
        m_eLabelPosition = VertexLabelPosition.MiddleCenter;
        m_dLabelScale = 1.0;
        m_oFormattedTextManager = new FormattedTextManager();

        AssertValid();
    }
Exemple #2
0
        //*************************************************************************
        //  Constructor: GroupDrawer()
        //
        /// <summary>
        /// Initializes a new instance of the <see cref="GroupDrawer" /> class.
        /// </summary>
        //*************************************************************************

        public GroupDrawer()
        {
            m_oLabelTextColor       = SystemColors.WindowTextColor;
            m_eLabelPosition        = VertexLabelPosition.MiddleCenter;
            m_dLabelScale           = 1.0;
            m_oFormattedTextManager = new FormattedTextManager();

            AssertValid();
        }
Exemple #3
0
        //*************************************************************************
        //  Constructor: VertexAndEdgeDrawerBase()
        //
        /// <summary>
        /// Initializes a new instance of the <see
        /// cref="VertexAndEdgeDrawerBase" /> class.
        /// </summary>
        //*************************************************************************

        public VertexAndEdgeDrawerBase()
        {
            m_bUseSelection         = true;
            m_oColor                = SystemColors.WindowTextColor;
            m_oSelectedColor        = SystemColors.HighlightColor;
            m_btFilteredAlpha       = 10;
            m_oFormattedTextManager = new FormattedTextManager();
            m_iMaximumLabelLength   = Int32.MaxValue;

            CreateDrawingObjects();

            // AssertValid();
        }
    //*************************************************************************
    //  Constructor: VertexAndEdgeDrawerBase()
    //
    /// <summary>
    /// Initializes a new instance of the <see
    /// cref="VertexAndEdgeDrawerBase" /> class.
    /// </summary>
    //*************************************************************************

    public VertexAndEdgeDrawerBase()
    {
        m_bUseSelection = true;
        m_oColor = SystemColors.WindowTextColor;
        m_oSelectedColor = SystemColors.HighlightColor;
        m_btFilteredAlpha = 10;
        m_oFormattedTextManager = new FormattedTextManager();
        m_iMaximumLabelLength = Int32.MaxValue;

        CreateDrawingObjects();

        // AssertValid();
    }
    PostDrawVertex
    (
        VertexShape vertexShape,
        Color vertexColor,
        GraphDrawingContext graphDrawingContext,
        DrawingContext drawingContext,
        Boolean drawAsSelected,
        Double graphScale,
        VertexLabelDrawer vertexLabelDrawer,
        FormattedTextManager formattedTextManager,
        VertexDrawingHistory vertexDrawingHistory
    )
    {
        Debug.Assert(graphDrawingContext != null);
        Debug.Assert(drawingContext != null);
        Debug.Assert(graphScale >= GraphDrawer.MinimumGraphScale);
        Debug.Assert(graphScale <= GraphDrawer.MaximumGraphScale);
        Debug.Assert(vertexLabelDrawer != null);
        Debug.Assert(formattedTextManager != null);
        Debug.Assert(vertexDrawingHistory != null);
        AssertValid();

        if (m_oCollapsedGroupVertex == null)
        {
            // The vertex that was drawn is not a collapsed group vertex.  Do
            // nothing.

            return;
        }

        if (m_oCollapsedGroupAttributes.Count == 0)
        {
            // The vertex that was drawn represents a collapsed group, but no
            // attributes were specified for it.  By default, such a vertex
            // gets a plus sign drawn on top of it.

            DrawPlusSign(vertexShape, vertexColor, graphDrawingContext,
                drawingContext, graphScale, vertexLabelDrawer,
                formattedTextManager, vertexDrawingHistory);
        }
        else
        {
            // Check whether this this is a collapsed motif.

            switch ( m_oCollapsedGroupAttributes.GetGroupType() )
            {
                case CollapsedGroupAttributeValues.FanMotifType:

                    DrawFanMotifFan(vertexColor, drawingContext,
                        drawAsSelected, graphScale, vertexDrawingHistory);

                    break;

                default:

                    // Do nothing.  This includes the D-connector motif case,
                    // which requires no post-drawing action.

                    break;
            }
        }
    }
    DrawPlusSign
    (
        VertexShape eVertexShape,
        Color oVertexColor,
        GraphDrawingContext oGraphDrawingContext,
        DrawingContext oDrawingContext,
        Double dGraphScale,
        VertexLabelDrawer oVertexLabelDrawer,
        FormattedTextManager oFormattedTextManager,
        VertexDrawingHistory oVertexDrawingHistory
    )
    {
        Debug.Assert(oGraphDrawingContext != null);
        Debug.Assert(oDrawingContext != null);
        Debug.Assert(dGraphScale >= GraphDrawer.MinimumGraphScale);
        Debug.Assert(dGraphScale <= GraphDrawer.MaximumGraphScale);
        Debug.Assert(oVertexLabelDrawer != null);
        Debug.Assert(oFormattedTextManager != null);
        Debug.Assert(oVertexDrawingHistory != null);
        AssertValid();

        Color oFillColor;

        switch (eVertexShape)
        {
            case VertexShape.Circle:
            case VertexShape.Square:
            case VertexShape.Diamond:
            case VertexShape.Triangle:

                // The fill color is the color of the background.  Adjust the
                // fill color for the opacity of the vertex.

                oFillColor = WpfGraphicsUtil.SetWpfColorAlpha(
                    oGraphDrawingContext.BackColor, oVertexColor.A);

                break;

            default:

                oFillColor = oVertexColor;
                break;
        }

        Color oContrastingColor =
            WpfGraphicsUtil.GetContrastingColor(oFillColor);

        // The font size used below was chosen so that it is large enough to be
        // easily readable, but small enough to fit within the smallest
        // collapsed group vertex created by this class.

        oVertexLabelDrawer.DrawLabel(oDrawingContext, oGraphDrawingContext,
            oVertexDrawingHistory, VertexLabelPosition.MiddleCenter,

            oFormattedTextManager.CreateFormattedText("+", oContrastingColor,
                15.0, dGraphScale),

            oContrastingColor, false);
    }