From b45dc59d86607db5be93d0e906778b9be0f2c458 Mon Sep 17 00:00:00 2001 From: Rainer Koschke Date: Mon, 18 Sep 2023 12:36:06 +0200 Subject: [PATCH] #563 Minor code improvements. --- .../Game/City/IncrementalTreeMapSetting.cs | 39 +++++++++++++------ Assets/SEE/Game/City/NodeLayoutAttributes.cs | 22 +++++++---- .../Game/Evolution/EvolutionRendererLayout.cs | 2 +- Assets/SEE/Game/GraphRenderer.cs | 2 +- .../SEE/Layout/NodeLayouts/Cose/CoseHelper.cs | 2 +- .../NodeLayouts/IIncrementalNodeLayout.cs | 3 +- .../IncrementalTreeMap/CorrectArea.cs | 35 +++++++++-------- .../IncrementalTreeMap/Direction.cs | 2 +- .../NodeLayouts/IncrementalTreeMap/Dissect.cs | 6 +-- .../IncrementalTreeMap/FlipMove.cs | 14 +++---- .../IncrementalTreeMap/LocalMove.cs | 12 +++--- .../IncrementalTreeMap/LocalMoves.cs | 12 +++--- .../NodeLayouts/IncrementalTreeMap/Node.cs | 12 +++--- .../IncrementalTreeMap/Rectangle.cs | 14 +++---- .../NodeLayouts/IncrementalTreeMap/Segment.cs | 10 ++--- .../IncrementalTreeMap/StretchMove.cs | 2 +- .../NodeLayouts/IncrementalTreeMap/Utils.cs | 5 ++- .../NodeLayouts/IncrementalTreeMapLayout.cs | 12 +++--- 18 files changed, 115 insertions(+), 91 deletions(-) diff --git a/Assets/SEE/Game/City/IncrementalTreeMapSetting.cs b/Assets/SEE/Game/City/IncrementalTreeMapSetting.cs index 7c7fdd8a9d..f366553d98 100644 --- a/Assets/SEE/Game/City/IncrementalTreeMapSetting.cs +++ b/Assets/SEE/Game/City/IncrementalTreeMapSetting.cs @@ -20,7 +20,7 @@ public class IncrementalTreeMapSetting : ConfigIO.PersistentConfigItem [Range(0, 5)] [Tooltip("The maximal depth for local moves algorithm. Increase for higher visual quality, " + "decrease for higher stability and to save runtime")] - public int localMovesDepth = 3; + public int LocalMovesDepth = 3; /// /// The maximal branching factor of the local moves search. @@ -29,7 +29,7 @@ public class IncrementalTreeMapSetting : ConfigIO.PersistentConfigItem [Range(1, 10)] [Tooltip("The maximal branching factor for local moves algorithm. Increase for higher visual quality, " + "decrease for higher stability and to save runtime")] - public int localMovesBranchingLimit = 4; + public int LocalMovesBranchingLimit = 4; /// /// Defines the specific p norm used in the local moves algorithm. See here: @@ -57,7 +57,7 @@ public class IncrementalTreeMapSetting : ConfigIO.PersistentConfigItem [Range(0.1f, 100f)] [LabelText("Padding (mm)")] [Tooltip("The distance between two neighbour nodes in mm")] - public float paddingMm = 5f; + public float PaddingMm = 5f; /// /// The maximal error for the method @@ -67,7 +67,7 @@ public class IncrementalTreeMapSetting : ConfigIO.PersistentConfigItem [Range(-7, -2)] [LabelText("Gradient Descent Precision (10^n)")] [Tooltip("The maximal error for the gradient descent method as power of 10")] - public int gradientDescentPrecisionExponent = -4; + public int GradientDescentPrecisionExponent = -4; /// /// Maps to a double. @@ -85,11 +85,11 @@ public class IncrementalTreeMapSetting : ConfigIO.PersistentConfigItem public void Save(ConfigWriter writer, string label) { writer.BeginGroup(label); - writer.Save(localMovesDepth, LocalMovesDepthLabel); - writer.Save(localMovesBranchingLimit, LocalMovesBranchingLimitLabel); + writer.Save(LocalMovesDepth, LocalMovesDepthLabel); + writer.Save(LocalMovesBranchingLimit, LocalMovesBranchingLimitLabel); writer.Save(pNorm.ToString(), PNormLabel); - writer.Save(gradientDescentPrecisionExponent, GradientDescentPrecisionLabel); - writer.Save(paddingMm, PaddingLabel); + writer.Save(GradientDescentPrecisionExponent, GradientDescentPrecisionLabel); + writer.Save(PaddingMm, PaddingLabel); writer.EndGroup(); } @@ -100,18 +100,33 @@ public bool Restore(Dictionary attributes, string label) return false; } Dictionary values = dictionary as Dictionary; - bool result = ConfigIO.Restore(values, LocalMovesDepthLabel, ref localMovesDepth); - result |= ConfigIO.Restore(values, LocalMovesBranchingLimitLabel, ref localMovesBranchingLimit); + bool result = ConfigIO.Restore(values, LocalMovesDepthLabel, ref LocalMovesDepth); + result |= ConfigIO.Restore(values, LocalMovesBranchingLimitLabel, ref LocalMovesBranchingLimit); result |= ConfigIO.RestoreEnum(values, PNormLabel, ref pNorm); - result |= ConfigIO.Restore(values, GradientDescentPrecisionLabel, ref gradientDescentPrecisionExponent); - result |= ConfigIO.Restore(values, PaddingLabel, ref paddingMm); + result |= ConfigIO.Restore(values, GradientDescentPrecisionLabel, ref GradientDescentPrecisionExponent); + result |= ConfigIO.Restore(values, PaddingLabel, ref PaddingMm); return result; } + /// + /// Configuration label for . + /// private const string LocalMovesDepthLabel = "LocalMovesDepth"; + /// + /// Configuration label for . + /// private const string LocalMovesBranchingLimitLabel = "LocalMovesBranchingLimit"; + /// + /// Configuration label for . + /// private const string PNormLabel = "PNorm"; + /// + /// Configuration label for . + /// private const string GradientDescentPrecisionLabel = "GradientDescentPrecision"; + /// + /// Configuration label for . + /// private const string PaddingLabel = "Padding"; } diff --git a/Assets/SEE/Game/City/NodeLayoutAttributes.cs b/Assets/SEE/Game/City/NodeLayoutAttributes.cs index 321fac5f1f..76ee8917fa 100644 --- a/Assets/SEE/Game/City/NodeLayoutAttributes.cs +++ b/Assets/SEE/Game/City/NodeLayoutAttributes.cs @@ -19,7 +19,7 @@ public class NodeLayoutAttributes : LayoutSettings /// /// Settings for the . /// - public IncrementalTreeMapSetting incrementalTreeMapSetting = new(); + public IncrementalTreeMapSetting IncrementalTreeMapSetting = new(); /// /// The path for the layout file containing the node layout information. @@ -29,16 +29,14 @@ public class NodeLayoutAttributes : LayoutSettings /// data of a game object. /// [OdinSerialize] - public FilePath LayoutPath = new FilePath(); - - private const string LayoutPathLabel = "LayoutPath"; - + public FilePath LayoutPath = new(); + public override void Save(ConfigWriter writer, string label) { writer.BeginGroup(label); writer.Save(Kind.ToString(), NodeLayoutLabel); LayoutPath.Save(writer, LayoutPathLabel); - incrementalTreeMapSetting.Save(writer,IncrementalTreeMapLabel); + IncrementalTreeMapSetting.Save(writer, IncrementalTreeMapLabel); writer.EndGroup(); } @@ -50,11 +48,21 @@ public override void Restore(Dictionary attributes, string label ConfigIO.RestoreEnum(values, NodeLayoutLabel, ref Kind); LayoutPath.Restore(values, LayoutPathLabel); - incrementalTreeMapSetting.Restore(values, IncrementalTreeMapLabel); + IncrementalTreeMapSetting.Restore(values, IncrementalTreeMapLabel); } } + /// + /// Configuration label for . + /// + private const string LayoutPathLabel = "LayoutPath"; + /// + /// Configuration label for . + /// private const string IncrementalTreeMapLabel = "IncrementalTreeMap"; + /// + /// Configuration label for . + /// private const string NodeLayoutLabel = "NodeLayout"; } } diff --git a/Assets/SEE/Game/Evolution/EvolutionRendererLayout.cs b/Assets/SEE/Game/Evolution/EvolutionRendererLayout.cs index 809dde190e..c63fb12b41 100644 --- a/Assets/SEE/Game/Evolution/EvolutionRendererLayout.cs +++ b/Assets/SEE/Game/Evolution/EvolutionRendererLayout.cs @@ -113,7 +113,7 @@ private void CalculateLayout(Graph graph) // Since incremental layouts must know the layout of the last revision // but are also bound to the function calls of NodeLayout // we must hand over this argument here separately - if(nodeLayout is IIncrementalNodeLayout iNodeLayout && oldLayout is IIncrementalNodeLayout iOldLayout) + if (nodeLayout is IIncrementalNodeLayout iNodeLayout && oldLayout is IIncrementalNodeLayout iOldLayout) { iNodeLayout.OldLayout = iOldLayout; } diff --git a/Assets/SEE/Game/GraphRenderer.cs b/Assets/SEE/Game/GraphRenderer.cs index d3866e1512..0e9fcaea16 100644 --- a/Assets/SEE/Game/GraphRenderer.cs +++ b/Assets/SEE/Game/GraphRenderer.cs @@ -629,7 +629,7 @@ public NodeLayout GetLayout(GameObject parent) => GroundLevel, parent.transform.lossyScale.x, parent.transform.lossyScale.z, - Settings.NodeLayoutSettings.incrementalTreeMapSetting), + Settings.NodeLayoutSettings.IncrementalTreeMapSetting), NodeLayoutKind.Balloon => new BalloonNodeLayout(GroundLevel), NodeLayoutKind.CirclePacking => new CirclePackingNodeLayout(GroundLevel), NodeLayoutKind.CompoundSpringEmbedder => new CoseLayout(GroundLevel, Settings), diff --git a/Assets/SEE/Layout/NodeLayouts/Cose/CoseHelper.cs b/Assets/SEE/Layout/NodeLayouts/Cose/CoseHelper.cs index e8d7e4cfd5..dcf16978e4 100644 --- a/Assets/SEE/Layout/NodeLayouts/Cose/CoseHelper.cs +++ b/Assets/SEE/Layout/NodeLayouts/Cose/CoseHelper.cs @@ -127,7 +127,7 @@ public static NodeLayout GetNodelayout(NodeLayoutKind nodeLayout, float groundLe groundLevel, 1000.0f, 1000.0f, - settings.NodeLayoutSettings.incrementalTreeMapSetting); + settings.NodeLayoutSettings.IncrementalTreeMapSetting); case NodeLayoutKind.Balloon: return new BalloonNodeLayout(groundLevel); case NodeLayoutKind.CirclePacking: diff --git a/Assets/SEE/Layout/NodeLayouts/IIncrementalNodeLayout.cs b/Assets/SEE/Layout/NodeLayouts/IIncrementalNodeLayout.cs index 106dde546e..7aa693ec91 100644 --- a/Assets/SEE/Layout/NodeLayouts/IIncrementalNodeLayout.cs +++ b/Assets/SEE/Layout/NodeLayouts/IIncrementalNodeLayout.cs @@ -3,7 +3,7 @@ /// /// Defines the interface for incremental node layouts. /// - /// Incremental node layouts are designed for evolution setting + /// Incremental node layouts are designed for the animation of evolution /// and each layout depends on the layout of the last revision. /// /// This interface extends a layout by @@ -15,6 +15,5 @@ public interface IIncrementalNodeLayout /// Setter for the layout of the last revision. /// IIncrementalNodeLayout OldLayout { set; } - } } diff --git a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/CorrectArea.cs b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/CorrectArea.cs index 8ba071c2a4..ef3add0ce1 100644 --- a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/CorrectArea.cs +++ b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/CorrectArea.cs @@ -35,7 +35,7 @@ public static bool Correct(IList nodes, IncrementalTreeMapSetting settings // adjust the position of slicingSegments AdjustSliced(nodes, partition1, partition2, slicingSegment); - // recursively adjust the two sub layouts + // recursively adjust the two sublayouts // since both sublayouts are temporally independent from each other // the segment that separates these must be considered as a border (IsConst = true) slicingSegment.IsConst = true; @@ -49,7 +49,7 @@ public static bool Correct(IList nodes, IncrementalTreeMapSetting settings Vector.Build.DenseOfArray(nodes.Select(node => node.Rectangle.Area()).ToArray()); double error = (nodesSizesWanted - nodesSizesCurrent).Norm(p: 1); - return error <= Math.Pow(10, settings.gradientDescentPrecisionExponent) && CheckPositiveLength(nodes); + return error <= Math.Pow(10, settings.GradientDescentPrecisionExponent) && CheckPositiveLength(nodes); } else { @@ -58,11 +58,11 @@ public static bool Correct(IList nodes, IncrementalTreeMapSetting settings } /// - /// Checks if the layout of can be divided into two disjoint sub layouts. + /// Checks if the layout of can be divided into two disjoint sublayouts. /// /// nodes with layout - /// a segment that would separate the sub layouts - /// true if nodes are sliceable else false + /// a segment that would separate the sublayouts + /// true if nodes are sliceable, else false private static bool IsSliceAble(IList nodes, out Segment slicingSegment) { slicingSegment = null; @@ -106,8 +106,8 @@ private static bool IsSliceAble(IList nodes, out Segment slicingSegment) /// /// nodes with layout /// the segment that divides both layouts - /// the / sub layout - /// the / sub layout + /// the / sublayout + /// the / sublayout private static void Split(IList nodes, Segment slicingSegment, out IList partition1, out IList partition2) { @@ -146,15 +146,15 @@ private static void Split(IList nodes, Segment slicingSegment, } /// - /// This method recalibrates a layout that is sliced in 2 sublayouts, + /// This method recalibrates a layout that is sliced in two sublayouts, /// so the sublayouts get the size they should have. - /// A sub layout can still have internal wrong node sizes. + /// A sublayout can still have internal wrong node sizes. /// - /// nodes of a slice able layout + /// nodes of a sliceable layout /// partition of , - /// the / sub layout + /// the / sublayout /// partition of , - /// the / sub layout + /// the / sublayout /// the segment that slices the layout private static void AdjustSliced( IList nodes, @@ -222,8 +222,9 @@ Dictionary mapSegmentIndex = segments.ToDictionary(s => s, _ => i++); double distance = 0; - double maximalError = Math.Pow(10, settings.gradientDescentPrecisionExponent); - for (int j = 0; j < 50; j++) + double maximalError = Math.Pow(10, settings.GradientDescentPrecisionExponent); + const int NumberOfIterations = 50; + for (int j = 0; j < NumberOfIterations; j++) { distance = CalculateOneStep(nodes, mapSegmentIndex); if (distance <= maximalError) @@ -232,11 +233,11 @@ Dictionary mapSegmentIndex } } - return (CheckPositiveLength(nodes) && distance < maximalError); + return CheckPositiveLength(nodes) && distance < maximalError; } /// - /// Calculates the jacobian matrix, a derivative for the function that maps + /// Calculates the Jacobian matrix, a derivative for the function that maps /// the position of the segments to the area of each node (its rectangle). /// /// the nodes of the layout @@ -344,7 +345,7 @@ private static void ApplyShift( } /// - /// Checks that the result has no rectangles with non-positive width or depth + /// Verifies that the result has no rectangles with non-positive width or depth. /// /// nodes of the layout /// true if all rectangles have positive lengths, else false diff --git a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Direction.cs b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Direction.cs index a6186c1980..4eed92b158 100644 --- a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Direction.cs +++ b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Direction.cs @@ -1,7 +1,7 @@ namespace SEE.Layout.NodeLayouts.IncrementalTreeMap { /// - /// Direction in in the plane containing the x-axis and z-axis + /// Direction in the plane containing the x-axis and z-axis /// internal enum Direction { diff --git a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Dissect.cs b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Dissect.cs index 7569dd487b..219fded913 100644 --- a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Dissect.cs +++ b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Dissect.cs @@ -11,11 +11,11 @@ namespace SEE.Layout.NodeLayouts.IncrementalTreeMap internal static class Dissect { /// - /// Calculates new Layout for . + /// Calculates new layout for . /// Assigns rectangles and segments to each node in . /// /// nodes to be laid out - /// rectangle in that the nodes should be placed + /// rectangle in which the nodes should be placed public static void Apply(IEnumerable nodes, Rectangle rectangle) { Node[] nodesArray = nodes.ToArray(); @@ -115,7 +115,7 @@ private static void Apply(Rectangle rectangle, /// Calculates the index that separates the array into two /// partitions. The specific split should result in good visual quality. /// - /// sorted list + /// sorted list /// index private static int GetSplitIndex(Node[] nodes) { diff --git a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/FlipMove.cs b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/FlipMove.cs index 6d8d656d2e..65bde52c81 100644 --- a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/FlipMove.cs +++ b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/FlipMove.cs @@ -6,22 +6,22 @@ namespace SEE.Layout.NodeLayouts.IncrementalTreeMap { /// /// A flip move is a kind of . - /// It rotates two nodes 90 degrees. + /// It rotates two nodes by 90 degrees. /// [DebuggerDisplay("{DebuggerDisplay,nq}")] internal class FlipMove : LocalMove { /// - /// if the rotation is clockwise + /// Whether the rotation is clockwise. /// private readonly bool clockwise; /// - /// Constructor + /// Constructor. /// /// one affected node /// other affected node - /// if the rotation is clockwise + /// whether the rotation is clockwise public FlipMove(Node node1, Node node2, bool clockwise) { this.Node1 = node1; @@ -58,7 +58,7 @@ override public void Apply() } else { - throw new ArgumentException("Can't apply flip move"); + throw new ArgumentException("Can't apply flip move."); } } @@ -68,7 +68,7 @@ override public LocalMove Clone(IDictionary cloneMap) } /// - /// Applies the local move for the case that the nodes are separated vertically + /// Applies the local move for the case that the nodes are separated vertically. /// /// the node on the side /// the node on the side @@ -170,7 +170,7 @@ private void FlipOnHorizontalSegment(Node lowerNode, Node upperNode) } /// - /// Method for better overview in debugger + /// Method for better overview in debugger. /// private string DebuggerDisplay => "flip " + Node1.ID + " " + Node2.ID + " {clockwise}"; } diff --git a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/LocalMove.cs b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/LocalMove.cs index 06fb9d242e..802c90fe5e 100644 --- a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/LocalMove.cs +++ b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/LocalMove.cs @@ -9,25 +9,25 @@ namespace SEE.Layout.NodeLayouts.IncrementalTreeMap internal abstract class LocalMove { /// - /// one affected node + /// One affected node. /// public Node Node1; /// - /// the other affected node + /// The other affected node. /// public Node Node2; /// - /// Execute the local move transformation on the layout of and . + /// Executes the local move transformation on the layout of and . /// public abstract void Apply(); /// - /// Creates a new local move, that can be applied on the layout of the node clones. + /// Creates a new local move that can be applied to the layout of the node clones. /// - /// dictionary that maps id to node, assuming that the cloneMap represents a clone - /// of the node layout of of and . + /// dictionary that maps id to node, assuming that the cloneMap represents a clone + /// of the node layout of and . /// a new local move public abstract LocalMove Clone(IDictionary cloneMap); } diff --git a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/LocalMoves.cs b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/LocalMoves.cs index 58c37c2adb..9989a87560 100644 --- a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/LocalMoves.cs +++ b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/LocalMoves.cs @@ -22,7 +22,7 @@ internal static class LocalMoves /// List of s private static IList FindLocalMoves(Segment segment) { - List result = new List(); + List result = new(); if (segment.IsConst) { return result; @@ -194,7 +194,7 @@ public static void DeleteNode(Node obsoleteNode) /// /// Searches the space of layouts that are similar to the layout of /// (in terms of distance in local moves). - /// Apply the layout with the best visual quality to + /// Applies the layout with the best visual quality to /// /// nodes that represent a layout /// settings for search @@ -206,7 +206,7 @@ public static void LocalMovesSearch(List nodes, IncrementalTreeMapSetting settings); allResults.Add((nodes, AspectRatiosPNorm(nodes, settings.PNorm), new List())); List bestResult = Utils.ArgMin(allResults, - x => x.Item2 * 10 + x.Item3.Count).Item1; + x => x.visualQuality * 10 + x.movesList.Count).nodes; IDictionary nodesDictionary = nodes.ToDictionary(n => n.ID, n => n); foreach (Node resultNode in bestResult) @@ -218,7 +218,7 @@ public static void LocalMovesSearch(List nodes, IncrementalTreeMapSetting } /// - /// Makes recursively local moves on clones of the layout to find similar layouts with good visual quality. + /// Recursively makes local moves on clones of the layout to find similar layouts with good visual quality. /// /// nodes that represent a layout /// moves that are done before in recursion @@ -231,7 +231,7 @@ public static void LocalMovesSearch(List nodes, IncrementalTreeMapSetting IncrementalTreeMapSetting settings) { List<(List nodes, double visualQuality, List movesList)> resultThisRecursion = new(); - if (movesUntilNow.Count >= settings.localMovesDepth) + if (movesUntilNow.Count >= settings.LocalMovesDepth) { return resultThisRecursion; } @@ -269,7 +269,7 @@ public static void LocalMovesSearch(List nodes, IncrementalTreeMapSetting } resultThisRecursion.Sort((x, y) => x.Item2.CompareTo(y.Item2)); - resultThisRecursion = resultThisRecursion.Take(settings.localMovesBranchingLimit).ToList(); + resultThisRecursion = resultThisRecursion.Take(settings.LocalMovesBranchingLimit).ToList(); List<(List nodes, double visualQuality, List movesList)> resultsNextRecursions = new(); foreach ((List resultNodes, double _, List resultMoves) in resultThisRecursion) diff --git a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Node.cs b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Node.cs index 29c2fa55ae..a71d21f95c 100644 --- a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Node.cs +++ b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Node.cs @@ -13,7 +13,7 @@ namespace SEE.Layout.NodeLayouts.IncrementalTreeMap internal class Node { /// - /// Constructor + /// Constructor. /// /// the ID of the new node public Node(string id) @@ -32,7 +32,7 @@ public Node(string id) public float DesiredSize { get; set; } /// - /// the ID + /// The ID. /// public string ID { get; } @@ -84,12 +84,12 @@ public void RegisterSegment(Segment segment, Direction dir) segment.Side1Nodes.Add(this); break; default: - throw new ArgumentOutOfRangeException(nameof(dir), dir, "We should never arrive here"); + throw new ArgumentOutOfRangeException(nameof(dir), dir, "We should never arrive here."); } } /// - /// Remove node from a current adjacent segment + /// Removes the node from a current adjacent segment. /// /// The side of the adjacent segment public void DeregisterSegment(Direction dir) @@ -114,7 +114,7 @@ public void DeregisterSegment(Direction dir) } /// - /// Get all adjacent segments + /// Returns all adjacent segments. /// /// dictionary where the direction maps the segment in this direction public IDictionary SegmentsDictionary() @@ -129,7 +129,7 @@ public IDictionary SegmentsDictionary() } /// - /// Method for better overview in debugger + /// Method for better overview in debugger. /// private string DebuggerDisplay => string.Format( diff --git a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Rectangle.cs b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Rectangle.cs index 86bb433dd7..639fa8a2fa 100644 --- a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Rectangle.cs +++ b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Rectangle.cs @@ -1,7 +1,7 @@ namespace SEE.Layout.NodeLayouts.IncrementalTreeMap { /// - /// A class that represents a rectangle shape as part of a layout + /// A class that represents a rectangle shape as part of an incremental tree-map layout. /// internal class Rectangle { @@ -21,22 +21,22 @@ public Rectangle(double x, double z, double width, double depth) } /// - /// The position of the edge + /// The position of the edge. /// public double X; /// - /// the position of the edge + /// The position of the edge. /// public double Z; /// - /// The lenght of x axis + /// The length of x axis. /// public double Width; /// - /// The lenght of z axis + /// The length of z axis. /// public double Depth; @@ -51,7 +51,7 @@ public double AspectRatio() } /// - /// the area of the rectangle + /// The area of the rectangle. /// /// * public double Area() @@ -60,7 +60,7 @@ public double Area() } /// - /// Creates a new identical Rectangle + /// Returns a new identical Rectangle. /// /// the clone public Rectangle Clone() diff --git a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Segment.cs b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Segment.cs index 4584756305..0f4f31871a 100644 --- a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Segment.cs +++ b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Segment.cs @@ -5,8 +5,8 @@ namespace SEE.Layout.NodeLayouts.IncrementalTreeMap { /// - /// A segment is a core element in the layout algorithm, - /// Segments representing lines separating/slicing the layout in rectangles. + /// A segment is a core element in the layout algorithm. + /// Segments are representing lines separating/slicing the layout in rectangles. /// The specific position of a segment in the layout is actually not relevant, /// but the relation to adjacent nodes is relevant. /// @@ -14,7 +14,7 @@ namespace SEE.Layout.NodeLayouts.IncrementalTreeMap internal class Segment { /// - /// Constructor + /// Constructor. /// /// /// @@ -27,7 +27,7 @@ public Segment(bool isConst, bool isVertical) /// /// Is true if the segment is a border of the layout. /// In most cases that means that or are empty - /// and layout has e.g. 4 const segments. + /// and layout has e.g. four const segments. /// public bool IsConst { get; set; } @@ -49,7 +49,7 @@ public Segment(bool isConst, bool isVertical) public IList Side2Nodes { get; } = new List(); /// - /// Method for better overview in debugger + /// Method for better overview in debugger. /// private string DebuggerDisplay { diff --git a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/StretchMove.cs b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/StretchMove.cs index d42a6bcd08..197005ca68 100644 --- a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/StretchMove.cs +++ b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/StretchMove.cs @@ -211,7 +211,7 @@ private void StretchUpperOverHorizontal(Node lowerNode, Node upperNode) } /// - /// Method for better overview in debugger + /// Method for better overview in debugger. /// private string DebuggerDisplay => "stretch " + Node1.ID + " " + Node2.ID; } diff --git a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Utils.cs b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Utils.cs index de22a2891b..40a1a96c59 100644 --- a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Utils.cs +++ b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMap/Utils.cs @@ -23,6 +23,7 @@ public static T ArgMax(ICollection collection, Func eval) return collection.First(x => eval(x).CompareTo(bestVal) == 0); } + /// /// Returns the item of the given collection that minimizes the given function. /// /// The collection whose minimum with respect to @@ -36,7 +37,7 @@ public static T ArgMin(ICollection collection, Func eval) } /// - /// Creates a new rectangle that includes all rectangles of . + /// Returns a new rectangle that includes all rectangles of . /// /// nodes with set rectangles /// new parent rectangle @@ -52,7 +53,7 @@ public static Rectangle CreateParentRectangle(IList nodes) /// /// A list of with rectangles that are laid out /// in an will be transformed (linearly), so that they fit - /// in + /// in . /// /// nodes with rectangles that should be transformed /// new parent rectangle diff --git a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMapLayout.cs b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMapLayout.cs index f2e09161b6..89933b8632 100644 --- a/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMapLayout.cs +++ b/Assets/SEE/Layout/NodeLayouts/IncrementalTreeMapLayout.cs @@ -89,7 +89,7 @@ public IIncrementalNodeLayout OldLayout else { throw new ArgumentException( - "Predecessor of IncrementalTreeMapLayout was not a IncrementalTreeMapLayout"); + "Predecessor of IncrementalTreeMapLayout was not a IncrementalTreeMapLayout."); } } } @@ -128,14 +128,14 @@ private void InitNodes() /// /// Creates a for the given - /// and continue recursively with the children of the ILayoutNode . - /// Extend both and by the node. + /// and continues recursively with the children of the ILayoutNode . + /// Extends both and by the node. /// /// node of the layout /// the absolute size of the node private float InitNode(ILayoutNode node) { - Node newNode = new Node(node.ID); + Node newNode = new(node.ID); nodeMap.Add(node.ID, newNode); iLayoutNodeMap.Add(node.ID, node); @@ -195,7 +195,7 @@ private void CalculateLayout(ICollection siblings, Rectangle rectan /// Calculates a stable layout for . /// /// nodes to be laid out - /// rectangle in that the nodes should be laid out + /// rectangle in which the nodes should be laid out private void ApplyIncrementalLayout(List nodes, Rectangle rectangle) { // oldNodes are not only the siblings that are in the old graph and in the new one, @@ -325,7 +325,7 @@ private void AddToLayout(IEnumerable nodes) { foreach (Node node in nodes) { - float absolutePadding = settings.paddingMm / 1000; + float absolutePadding = settings.PaddingMm / 1000; Rectangle rectangle = node.Rectangle; ILayoutNode layoutNode = iLayoutNodeMap[node.ID];