Smrf.NodeXL.Layouts.RectangleBinner.TryGetRemainingRectangle C# (CSharp) Method

TryGetRemainingRectangle() public method

public TryGetRemainingRectangle ( Rectangle &remainingRectangle ) : System.Boolean
remainingRectangle System.Drawing.Rectangle
return System.Boolean
    TryGetRemainingRectangle
    (
        out Rectangle remainingRectangle
    )
    {
        AssertValid();

        if (!m_bBinReturned)
        {
            remainingRectangle = m_oParent;
        }
        else if (m_oLastBin.Top == m_oParent.Top)
        {
            // There is at least one bin in the top row, and there is no space
            // above them.  Return the space to the right of the last bin in
            // the top row.

            remainingRectangle = Rectangle.FromLTRB(
                m_oLastBin.Right,
                m_oParent.Top,
                m_oParent.Right,
                m_oLastBin.Bottom
                );
        }
        else
        {
            // Return the entire row above the last bin.

            remainingRectangle = Rectangle.FromLTRB(
                m_oParent.Left,
                m_oParent.Top,
                m_oParent.Right,
                m_oLastBin.Top
            );
        }

        // Note that Rectangle.Contains() returns true even if the rectangle
        // passed to it has zero height or width.

        return ( remainingRectangle.Width > 0 && remainingRectangle.Height >0
            && m_oParent.Contains(remainingRectangle) );
    }

Usage Example

コード例 #1
0
    LayOutSmallerComponentsInBins
    (
        IGraph graph,
        ICollection<IVertex> verticesToLayOut,
        LayoutContext layoutContext,
        out ICollection<IVertex> remainingVertices,
        out Rectangle remainingRectangle
    )
    {
        AssertValid();

        remainingVertices = null;
        remainingRectangle = Rectangle.Empty;

        // This method modifies some of the graph's metadata.  Save the
        // original metadata.

        Boolean bOriginalGraphHasBeenLaidOut =
            LayoutMetadataUtil.GraphHasBeenLaidOut(graph);

        ICollection<IVertex> oOriginalLayOutTheseVerticesOnly =
            ( ICollection<IVertex> )graph.GetValue(
                ReservedMetadataKeys.LayOutTheseVerticesOnly,
                typeof( ICollection<IVertex> ) );

        // Split the vertices into strongly connected components, sorted in
        // increasing order of vertex count.

        ConnectedComponentCalculator oConnectedComponentCalculator =
            new ConnectedComponentCalculator();

        IList< LinkedList<IVertex> > oComponents =
            oConnectedComponentCalculator.CalculateStronglyConnectedComponents(
                verticesToLayOut, graph, true);

        Int32 iComponents = oComponents.Count;

        // This object will split the graph rectangle into bin rectangles.

        RectangleBinner oRectangleBinner = new RectangleBinner(
            layoutContext.GraphRectangle, m_iBinLength);

        Int32 iComponent = 0;

        for (iComponent = 0; iComponent < iComponents; iComponent++)
        {
            LinkedList<IVertex> oComponent = oComponents[iComponent];
            Int32 iVerticesInComponent = oComponent.Count;

            if (iVerticesInComponent> m_iMaximumVerticesPerBin)
            {
                // The vertices in the remaining components should not be
                // binned.

                break;
            }

            Rectangle oBinRectangle;

            if ( !oRectangleBinner.TryGetNextBin(out oBinRectangle) )
            {
                // There is no room for an additional bin rectangle.

                break;
            }

            // Lay out the component within the bin rectangle.

            LayOutComponentInBin(graph, oComponent, oBinRectangle);
        }

        // Restore the original metadata on the graph.

        if (bOriginalGraphHasBeenLaidOut)
        {
            LayoutMetadataUtil.MarkGraphAsLaidOut(graph);
        }
        else
        {
            LayoutMetadataUtil.MarkGraphAsNotLaidOut(graph);
        }

        if (oOriginalLayOutTheseVerticesOnly != null)
        {
            graph.SetValue(ReservedMetadataKeys.LayOutTheseVerticesOnly,
                oOriginalLayOutTheseVerticesOnly);
        }
        else
        {
            graph.RemoveKey(ReservedMetadataKeys.LayOutTheseVerticesOnly);
        }

        if ( oRectangleBinner.TryGetRemainingRectangle(
            out remainingRectangle) )
        {
            remainingVertices = GetRemainingVertices(oComponents, iComponent);

            return (remainingVertices.Count > 0);
        }

        return (false);
    }
All Usage Examples Of Smrf.NodeXL.Layouts.RectangleBinner::TryGetRemainingRectangle