]> git.kianting.info Git - clo/blobdiff - src/libclo/breakLines.ts
update readme
[clo] / src / libclo / breakLines.ts
index f761b1868525b52e2e76b491110e1a2d98b82ac6..f3f6a3c856d4765f12567409280db65161f5ea59 100644 (file)
@@ -49,8 +49,14 @@ export class BreakLineAlgorithm {
             return item.width;
         }
     }
-
+    
+    /**segement node of one paragraph into lines. 
+     * @args items: nodes of a line
+     * @args linewidth: the line width
+     * @returns segmented nodes into lines
+    */
     segmentedNodes(items : BoxesItem[], lineWidth : number) : BoxesItem[][]{
+
         let lineWidthFixed = lineWidth;
         this.totalCost(items ,lineWidthFixed);
         let nodeList = this.generateBreakLineNodeList();
@@ -64,6 +70,8 @@ export class BreakLineAlgorithm {
             up = nodeList[i+1];
 
         }
+
+
         return res;
     }
 
@@ -105,16 +113,15 @@ export class BreakLineAlgorithm {
 
         let a = Infinity;
         for(var k=itemsLength-2; this.lineCost(items, k+1,itemsLength-1, lineWidthFixed) < Infinity; k--){
+            
             let tmp = this.totalCostAux(items, k, lineWidthFixed);
-
+            
             if (a > tmp){
                 this.prevNodes[itemsLength-1] = k
                 a = tmp;
             }
+            
         }
-
-        console.log("~~~", lineWidth);
-        console.log((<CharBox>items[itemsLength-2]));
         return a;
 
     }
@@ -163,7 +170,8 @@ export class BreakLineAlgorithm {
      * @param lineWidth line width
      */
     lineCost(items : BoxesItem[], i : number, j : number, lineWidth: number) : number{
-        if (this.lineCostStorage[i] !== null && this.lineCostStorage[i][j] !== null){
+        if (this.lineCostStorage[i][j] !== null){
+            console.log("AA")
             return this.lineCostStorage[i][j];
         }