private void justifyLineAreas(
     BlockArea b, double measure, double consumed, int numChildren, BlockAlignment alignment) {
   double available = measure - consumed;
   if (alignment == BlockAlignment.JUSTIFY) alignment = BlockAlignment.SPACE_BETWEEN;
   int numFillers;
   if (alignment == BlockAlignment.SPACE_AROUND) {
     numFillers = numChildren + 1;
   } else if (alignment == BlockAlignment.SPACE_BETWEEN) {
     numFillers = numChildren - 1;
   } else numFillers = 0;
   double fill;
   if (numFillers > 0) fill = available / numFillers;
   else fill = 0;
   if (fill > 0) {
     List<AreaNode> children = new java.util.ArrayList<AreaNode>(b.getChildren());
     for (AreaNode c : children) {
       AreaNode f = new BlockFillerArea(b.getElement(), 0, fill);
       if ((c == children.get(0)) && (alignment == BlockAlignment.SPACE_BETWEEN)) continue;
       else b.insertChild(f, c, null);
     }
     if (alignment == BlockAlignment.SPACE_AROUND) {
       AreaNode f = new BlockFillerArea(b.getElement(), 0, fill);
       b.insertChild(f, null, null);
     }
   }
 }
 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);
   }
 }