コード例 #1
0
        public void SetUp()
        {
            m_oGraph = new Graph();

            Rectangle oRectangle = new Rectangle(21, 34, 56, 78);

            m_oLayoutContext = new LayoutContext(oRectangle);

            m_oLayOutGraphAsyncArguments =
            new LayOutGraphAsyncArguments(m_oGraph, m_oLayoutContext);
        }
コード例 #2
0
ファイル: AsyncLayoutBase.cs プロジェクト: yesbb12/NetMap
        LayOutGraphOnBackgroundWorker
        (
            BackgroundWorker oBackgroundWorker,
            DoWorkEventArgs oDoWorkEventArgs
        )
        {
            Debug.Assert(oBackgroundWorker != null);
            Debug.Assert(oDoWorkEventArgs != null);
            AssertValid();

            Debug.Assert(oDoWorkEventArgs.Argument is LayOutGraphAsyncArguments);

            LayOutGraphAsyncArguments oLayOutGraphAsyncArguments =
                (LayOutGraphAsyncArguments)oDoWorkEventArgs.Argument;

            IGraph oGraph = oLayOutGraphAsyncArguments.Graph;

            LayoutContext oLayoutContext =
                oLayOutGraphAsyncArguments.LayoutContext;

            LayoutContext oAdjustedLayoutContext;

            if (!GetAdjustedLayoutContext(oGraph, oLayoutContext,
                                          out oAdjustedLayoutContext))
            {
                return;
            }

            // Honor the optional LayOutTheseVerticesOnly key on the graph.

            ICollection <IVertex> oVerticesToLayOut = GetVerticesToLayOut(oGraph);
            Int32 iVerticesToLayOut = oVerticesToLayOut.Count;

            if (iVerticesToLayOut == 0)
            {
                return;
            }

            // Binning is supported only if the entire graph is being laid out.

            if (this.SupportsBinning && m_bUseBinning &&
                iVerticesToLayOut == oGraph.Vertices.Count)
            {
                // Lay out the graph's smaller components in bins.

                GraphBinner oGraphBinner = new GraphBinner();
                oGraphBinner.MaximumVerticesPerBin = m_iMaximumVerticesPerBin;
                oGraphBinner.BinLength             = m_iBinLength;

                ICollection <IVertex> oRemainingVertices;
                Rectangle             oRemainingRectangle;

                if (oGraphBinner.LayOutSmallerComponentsInBins(oGraph,
                                                               oVerticesToLayOut, oAdjustedLayoutContext,
                                                               out oRemainingVertices, out oRemainingRectangle))
                {
                    // The remaining vertices need to be laid out in the remaining
                    // rectangle.

                    oVerticesToLayOut = oRemainingVertices;

                    oAdjustedLayoutContext =
                        new LayoutContext(oRemainingRectangle);
                }
                else
                {
                    // There are no remaining vertices, or there is no space
                    // left.

                    oVerticesToLayOut = new IVertex[0];
                }
            }

            if (oVerticesToLayOut.Count > 0)
            {
                // Let the derived class do the work.

                if (!LayOutGraphCore(oGraph, oVerticesToLayOut,
                                     oAdjustedLayoutContext, oBackgroundWorker))
                {
                    // LayOutGraphAsyncCancel() was called.

                    oDoWorkEventArgs.Cancel = true;
                    return;
                }

                LayoutMetadataUtil.MarkGraphAsLaidOut(oGraph);
            }
        }
コード例 #3
0
 public void TearDown()
 {
     m_oLayOutGraphAsyncArguments = null;
     m_oGraph = null;
     m_oLayoutContext = null;
 }
コード例 #4
0
 //*************************************************************************
 //  Constructor: LayOutGraphAsyncArgumentsTest()
 //
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="LayOutGraphAsyncArgumentsTest" /> class.
 /// </summary>
 //*************************************************************************
 public LayOutGraphAsyncArgumentsTest()
 {
     m_oLayOutGraphAsyncArguments = null;
     m_oGraph = null;
     m_oLayoutContext = null;
 }