ShouldCalculateReadabilityMetrics() public method

public ShouldCalculateReadabilityMetrics ( ReadabilityMetrics readabilityMetrics ) : System.Boolean
readabilityMetrics ReadabilityMetrics
return System.Boolean
コード例 #1
0
    TryCalculatePerEdgeAndPerVertexMetrics
    (
        IGraph oGraphClone,
        IGraph oGraph,
        ReadabilityMetricUserSettings oReadabilityMetricUserSettings,
        BackgroundWorker oBackgroundWorker,
        Dictionary<IEdge, Int32> oEdgeInformation,
        Dictionary<IVertex, VertexInformation> oVertexInformations,
        LinkedList<GraphMetricColumn> oGraphMetricColumns
    )
    {
        Debug.Assert(oGraphClone != null);
        Debug.Assert(oGraph != null);
        Debug.Assert(oReadabilityMetricUserSettings != null);
        Debug.Assert(oBackgroundWorker != null);
        Debug.Assert(oEdgeInformation != null);
        Debug.Assert(oVertexInformations != null);
        Debug.Assert(oGraphMetricColumns != null);
        AssertValid();

        ICollection<GraphMetricValueWithID> oGraphMetricValuesWithID;

        if ( oReadabilityMetricUserSettings.ShouldCalculateReadabilityMetrics(
                ReadabilityMetrics.PerEdgeEdgeCrossings) )
        {
            if ( !TryCalculatePerEdgeEdgeCrossings(oGraphClone, oGraph,
                oBackgroundWorker, oEdgeInformation,
                out oGraphMetricValuesWithID) )
            {
                return (false);
            }

            oGraphMetricColumns.AddLast(
                new GraphMetricColumnWithID( WorksheetNames.Edges,
                    TableNames.Edges, EdgeTableColumnNames.EdgeCrossings,
                    ExcelTableUtil.AutoColumnWidth, NumericFormat,
                    CellStyleNames.GraphMetricGood,
                    oGraphMetricValuesWithID.ToArray() ) );
        }

        if ( oReadabilityMetricUserSettings.ShouldCalculateReadabilityMetrics(
                ReadabilityMetrics.PerVertexEdgeCrossings) )
        {
            if ( !TryCalculatePerVertexEdgeCrossings(oGraphClone,
                oBackgroundWorker, oEdgeInformation, oVertexInformations,
                out oGraphMetricValuesWithID) )
            {
                return (false);
            }

            oGraphMetricColumns.AddLast(
                new GraphMetricColumnWithID( WorksheetNames.Vertices,
                    TableNames.Vertices, VertexTableColumnNames.EdgeCrossings,
                    ExcelTableUtil.AutoColumnWidth, NumericFormat,
                    CellStyleNames.GraphMetricGood,
                    oGraphMetricValuesWithID.ToArray() ) );
        }

        if ( oReadabilityMetricUserSettings.ShouldCalculateReadabilityMetrics(
                ReadabilityMetrics.PerVertexVertexOverlap) )
        {
            if ( !TryCalculatePerVertexVertexOverlap(oGraphClone,
                oBackgroundWorker, oVertexInformations,
                out oGraphMetricValuesWithID) )
            {
                return (false);
            }

            oGraphMetricColumns.AddLast(
                new GraphMetricColumnWithID( WorksheetNames.Vertices,
                    TableNames.Vertices, VertexTableColumnNames.VertexOverlap,
                    ExcelTableUtil.AutoColumnWidth, NumericFormat,
                    CellStyleNames.GraphMetricGood,
                    oGraphMetricValuesWithID.ToArray() ) );
        }

        return (true);
    }
コード例 #2
0
    TryCalculateOverallMetrics
    (
        IGraph oGraphClone,
        ReadabilityMetricUserSettings oReadabilityMetricUserSettings,
        BackgroundWorker oBackgroundWorker,
        Dictionary<IEdge, Int32> oEdgeInformation,
        Dictionary<IVertex, VertexInformation> oVertexInformations,
        LinkedList<GraphMetricColumn> oGraphMetricColumns
    )
    {
        AssertValid();

        Boolean bCalculateOverallEdgeCrossings =
            oReadabilityMetricUserSettings.ShouldCalculateReadabilityMetrics(
                ReadabilityMetrics.OverallEdgeCrossings);

        Boolean bCalculateOverallVertexOverlap =
            oReadabilityMetricUserSettings.ShouldCalculateReadabilityMetrics(
                ReadabilityMetrics.OverallVertexOverlap);

        Boolean bCalculateGraphRectangleCoverage =
            oReadabilityMetricUserSettings.ShouldCalculateReadabilityMetrics(
                ReadabilityMetrics.GraphRectangleCoverage);

        if (!bCalculateOverallEdgeCrossings && !bCalculateOverallVertexOverlap 
            && !bCalculateGraphRectangleCoverage)
        {
            return (true);
        }

        Nullable<Double> dOverallEdgeCrossings = null;
        Nullable<Double> dOverallVertexOverlap = null;
        Nullable<Double> dGraphRectangleCoverage = null;

        if (
            ( bCalculateOverallEdgeCrossings &&
                !TryCalculateOverallEdgeCrossings(oGraphClone,
                oBackgroundWorker, oEdgeInformation, oVertexInformations,
                out dOverallEdgeCrossings)
            )
            ||
            ( bCalculateOverallVertexOverlap &&
                !TryCalculateOverallVertexOverlap(oGraphClone,
                oBackgroundWorker, oVertexInformations,
                out dOverallVertexOverlap)
            )
            ||
            ( bCalculateGraphRectangleCoverage &&
                !TryCalculateGraphRectangleCoverage(oGraphClone,
                oBackgroundWorker, oVertexInformations,
                out dGraphRectangleCoverage)
            )
            )
        {
            // The user cancelled.

            return (false);
        }

        // Known problem: 
        //
        // The following code will calculate either or both of the two overall
        // readability metrics, depending on the user's settings.  If it
        // doesn't calculate one of them, it writes an empty string to the
        // corresponding value cell in the OverallReadabilityMetrics table
        // instead of leaving any existing value untouched.
        //
        // This differs from what occurs when other readability metrics don't
        // get calculated.  In the other cases, any metrics that have already
        // been calculated do not get overwritten.
        //
        // Fixing this will require modifying the way that
        // GraphMetricColumnOrdered objects get written to the workbook by
        // GraphMetricWriter.WriteGraphMetricColumnOrderedToWorkbook().

        oGraphMetricColumns.AddLast(

            new GraphMetricColumnOrdered( WorksheetNames.OverallMetrics,
                TableNames.OverallReadabilityMetrics,
                OverallReadabilityMetricsTableColumnNames.Name,
                ExcelTableUtil.AutoColumnWidth, null,
                CellStyleNames.GraphMetricGood,

                new GraphMetricValueOrdered [] {

                    new GraphMetricValueOrdered("Edge Crossing Readability"),
                    new GraphMetricValueOrdered("Vertex Overlap Readability"),
                    new GraphMetricValueOrdered("Graph Pane Coverage"),
                } ) );

        oGraphMetricColumns.AddLast(

            new GraphMetricColumnOrdered(WorksheetNames.OverallMetrics,
                TableNames.OverallReadabilityMetrics,
                OverallReadabilityMetricsTableColumnNames.Value,
                ExcelTableUtil.AutoColumnWidth, NumericFormat,
                CellStyleNames.GraphMetricGood,

                new GraphMetricValueOrdered [] {

                    new GraphMetricValueOrdered(
                        bCalculateOverallEdgeCrossings ?
                        NullableToGraphMetricValue<Double>(
                            dOverallEdgeCrossings) : String.Empty),

                    new GraphMetricValueOrdered(
                        bCalculateOverallVertexOverlap ?
                        NullableToGraphMetricValue<Double>(
                            dOverallVertexOverlap) : String.Empty),

                    new GraphMetricValueOrdered(
                        bCalculateGraphRectangleCoverage ?
                        NullableToGraphMetricValue<Double>(
                            dGraphRectangleCoverage) : String.Empty),
                    } ) );

        return (true);
    }