- * Algorithms in LATEX language
-TotalCost(i) = min_{j}~TotalCost(j) + LineCost(j, i)~~~~j=0, 1, ..., i-1
-
-LineCost(j, i)= \begin{cases}
-\infty ~~~ if~~LineWidth - \sum_{k=j+1}^{i-1} OrigWidth(item[k]) - newLineWidth(item[i]) < 0 \\
-\infty~~if~~NOT~~breakable(item[i]) \\
-(LineWidth - \sum_{k=j+1}^{i-1} OrigWidth(item[k]) - newLineWidth(item[i]))^3 ~~elsewhere
-\end{cases} */
-
-/**check if a boeitem is BreakPoint Type */
-function isBreakPoint (item : any) : item is BreakPoint{
- return (item as BreakPoint).newLined !== undefined;
-}
-
-/**check if a boeitem is BreakPoint Type */
-function isHGlue (item : any) : item is HGlue{
- return (item as HGlue).stretchFactor !== undefined;
-}
-
-
-/** measuring original advance width */
-function origWidth(item : BoxesItem) : number{
- if (isBreakPoint(item)){
- console.log(item);
- return origWidth(item.original);
- }else if(Array.isArray(item)){
- return item.map((x)=>origWidth(x))
- .reduce((acc, current) => acc + current,
- 0.0,)
- }else if(isHGlue(item)){
- return 0.0;
+ * Algorithms in LATEX-like language
+ */
+
+export class BreakLineAlgorithm {
+
+ lineCostStorage : number[][];
+ totalCostAuxStorage : number[];
+ prevNodes : number[];
+
+
+
+ constructor(){
+ this.prevNodes = [];
+ this.totalCostAuxStorage = [];
+ this.lineCostStorage = [[]];