You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FilledArea.java 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * $Id$
  3. * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
  4. * For details on use and redistribution please refer to the
  5. * LICENSE file included with these sources.
  6. */
  7. package org.apache.fop.area.inline;
  8. import java.util.List;
  9. import java.util.ArrayList;
  10. /**
  11. * Filled area.
  12. * This inline area contains some inline areas.
  13. * When the renderer gets the child areas to render
  14. * the inline areas are repeated to fill the ipd of
  15. * this inline parent.
  16. * This extends InlineParent so that the renderer will render
  17. * this as a normal inline parent.
  18. */
  19. public class FilledArea extends InlineParent {
  20. private int unitWidth;
  21. /**
  22. * Create a new filled area.
  23. */
  24. public FilledArea() {
  25. }
  26. /**
  27. * Set the unit width for the areas to fill the full width.
  28. *
  29. * @param w the unit width
  30. */
  31. public void setUnitWidth(int w) {
  32. unitWidth = w;
  33. }
  34. /**
  35. * Get the child areas for this filed area.
  36. * This copies the references of the inline areas so that
  37. * it fills the total width of the area a whole number of times
  38. * for the unit width.
  39. *
  40. * @return the list of child areas copied to fill the width
  41. */
  42. public List getChildAreas() {
  43. int units = (int)(getWidth() / unitWidth);
  44. ArrayList newList = new ArrayList();
  45. for (int count = 0; count < units; count++) {
  46. newList.addAll(inlines);
  47. }
  48. return newList;
  49. }
  50. }