Skip to content

Commit

Permalink
Drop the unnecessary MatrixAtom properties (ForNeVeR#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Aug 4, 2019
1 parent 18b0851 commit 4b13316
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,6 @@
],
"CellBottomTopPadding": 0.35,
"CellLeftRightPadding": 0.35,
"RowCount": 3,
"ColumnCount": 3,
"CellVerticalAlignment": "Center",
"CellHorizontalAlignment": "Center",
"Type": "Ordinary",
Expand Down Expand Up @@ -767,8 +765,6 @@
],
"CellBottomTopPadding": 0.35,
"CellLeftRightPadding": 0.35,
"RowCount": 3,
"ColumnCount": 3,
"CellVerticalAlignment": "Center",
"CellHorizontalAlignment": "Center",
"Type": "Ordinary",
Expand Down Expand Up @@ -1202,8 +1198,6 @@
],
"CellBottomTopPadding": 0.35,
"CellLeftRightPadding": 0.35,
"RowCount": 3,
"ColumnCount": 3,
"CellVerticalAlignment": "Center",
"CellHorizontalAlignment": "Center",
"Type": "Ordinary",
Expand All @@ -1226,8 +1220,6 @@
],
"CellBottomTopPadding": 0.35,
"CellLeftRightPadding": 0.35,
"RowCount": 3,
"ColumnCount": 1,
"CellVerticalAlignment": "Center",
"CellHorizontalAlignment": "Center",
"Type": "Ordinary",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,6 @@
],
"CellBottomTopPadding": 0.35,
"CellLeftRightPadding": 0.35,
"RowCount": 3,
"ColumnCount": 1,
"CellVerticalAlignment": "Center",
"CellHorizontalAlignment": "Center",
"Type": "Ordinary",
Expand Down Expand Up @@ -823,8 +821,6 @@
],
"CellBottomTopPadding": 0.35,
"CellLeftRightPadding": 0.35,
"RowCount": 3,
"ColumnCount": 1,
"CellVerticalAlignment": "Center",
"CellHorizontalAlignment": "Center",
"Type": "Ordinary",
Expand Down Expand Up @@ -1024,8 +1020,6 @@
],
"CellBottomTopPadding": 0.35,
"CellLeftRightPadding": 0.35,
"RowCount": 3,
"ColumnCount": 1,
"CellVerticalAlignment": "Center",
"CellHorizontalAlignment": "Center",
"Type": "Ordinary",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@
],
"CellBottomTopPadding": 0.35,
"CellLeftRightPadding": 0.35,
"RowCount": 2,
"ColumnCount": 1,
"CellVerticalAlignment": "Center",
"CellHorizontalAlignment": "Center",
"Type": "Ordinary",
Expand Down Expand Up @@ -296,8 +294,6 @@
],
"CellBottomTopPadding": 0.35,
"CellLeftRightPadding": 0.35,
"RowCount": 2,
"ColumnCount": 3,
"CellVerticalAlignment": "Center",
"CellHorizontalAlignment": "Center",
"Type": "Ordinary",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,6 @@
],
"CellBottomTopPadding": 0.35,
"CellLeftRightPadding": 0.35,
"RowCount": 3,
"ColumnCount": 2,
"CellVerticalAlignment": "Center",
"CellHorizontalAlignment": "Left",
"Type": "Ordinary",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,6 @@
],
"CellBottomTopPadding": 0.35,
"CellLeftRightPadding": 0.35,
"RowCount": 2,
"ColumnCount": 2,
"CellVerticalAlignment": "Center",
"CellHorizontalAlignment": "Left",
"Type": "Ordinary",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@
],
"CellBottomTopPadding": 0.35,
"CellLeftRightPadding": 0.35,
"RowCount": 2,
"ColumnCount": 3,
"CellVerticalAlignment": "Center",
"CellHorizontalAlignment": "Center",
"Type": "Ordinary",
Expand Down
23 changes: 8 additions & 15 deletions src/WpfMath/Atoms/MatrixAtom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@ public MatrixAtom(
/// </summary>
public double CellLeftRightPadding { get; }

/// <summary>
/// Gets the number of rows in this <see cref="MatrixAtom"/>.
/// </summary>
public int RowCount => MatrixCells.Count;

/// <summary>
/// Gets the number of columns in this <see cref="MatrixAtom"/>.
/// </summary>
public int ColumnCount => MatrixCells[0]?.Count ?? 0;

public VerticalAlignment CellVerticalAlignment { get; }
public HorizontalAlignment CellHorizontalAlignment { get; }

Expand All @@ -65,32 +55,35 @@ protected override Box CreateBoxCore(TexEnvironment environment)
var style = environment.Style;
var axis = texFont.GetAxisHeight(style);

var rowCount = MatrixCells.Count;
var maxColumnCount = MatrixCells.Max(row => row.Count);

//Region for adjustment vars
double maxrowWidth = 0;

//stores the max cell height for each row
var RowsMaxCellHeight = new List<double>();
for (int i = 0; i < RowCount; i++)
for (int i = 0; i < rowCount; i++)
{
RowsMaxCellHeight.Add(0);
}
//stores the max cell width for each column
var ColumnsMaxCellWidth = new List<double>();
for (int i = 0; i < ColumnCount; i++)
for (int i = 0; i < maxColumnCount; i++)
{
ColumnsMaxCellWidth.Add(0);
}
//Create a vertical box to hold the rows and their cells
var resultBox = new VerticalBox();

for (int i = 0; i < RowCount; i++)
for (int i = 0; i < rowCount; i++)
{
//row top pad
resultBox.Add(new StrutBox(maxrowWidth, CellBottomTopPadding / 2, 0, 0));

var rowbox = new HorizontalBox() {Tag= $"Row:{i}",};

for (int j = 0; j < ColumnCount; j++)
for (int j = 0; j < maxColumnCount; j++)
{
double maxrowHeight = 0;
//cell left pad
Expand Down Expand Up @@ -410,7 +403,7 @@ protected override Box CreateBoxCore(TexEnvironment environment)
}
}

double adjustedTotalHeight = RowsMaxCellHeight.Sum()+ (RowCount * CellBottomTopPadding);
double adjustedTotalHeight = RowsMaxCellHeight.Sum()+ (rowCount * CellBottomTopPadding);

resultBox.Depth = 0;
resultBox.Height = adjustedTotalHeight>sigmaTotalHeight?adjustedTotalHeight:sigmaTotalHeight;
Expand Down

0 comments on commit 4b13316

Please sign in to comment.