Exemplo n.º 1
0
 private void alignLineAreas(BlockArea b, LayoutState ls) {
   BlockAlignment alignment = ls.getReferenceAlignment();
   ReferenceArea r = ls.getReferenceArea();
   double measure = r.isVertical() ? r.getWidth() : r.getHeight();
   double consumed = 0;
   int numChildren = 0;
   for (AreaNode c : b.getChildren()) {
     consumed += c.getBPD();
     ++numChildren;
   }
   double available = measure - consumed;
   if (available > 0) {
     if (alignment == BlockAlignment.BEFORE) {
       // no-op
     } else if (alignment == BlockAlignment.AFTER) {
       // no-op
     } else if (alignment == BlockAlignment.CENTER) {
       // no-op
     } else {
       justifyLineAreas(b, measure, consumed, numChildren, alignment);
     }
   } else if (available < 0) {
     b.setOverflow(-available);
   }
 }
Exemplo n.º 2
0
 private void alignBlockAreas(ReferenceArea r, BlockAlignment alignment) {
   double measure = r.isVertical() ? r.getWidth() : r.getHeight();
   double consumed = 0;
   for (AreaNode c : r.getChildren()) {
     consumed += c.getBPD();
   }
   double available = measure - consumed;
   if (available > 0) {
     if (alignment == BlockAlignment.BEFORE) {
       AreaNode a = new BlockFillerArea(r.getElement(), 0, available);
       r.addChild(a, null);
     } else if (alignment == BlockAlignment.AFTER) {
       AreaNode a = new BlockFillerArea(r.getElement(), 0, available);
       r.insertChild(a, r.firstChild(), null);
     } else if (alignment == BlockAlignment.CENTER) {
       double half = available / 2;
       AreaNode a1 = new BlockFillerArea(r.getElement(), 0, half);
       AreaNode a2 = new BlockFillerArea(r.getElement(), 0, half);
       r.insertChild(a1, r.firstChild(), null);
       r.insertChild(a2, null, null);
     } else {
       // no-op
     }
   } else if (available < 0) {
     r.setOverflow(-available);
   }
 }