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.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* $Id$ */
  17. package org.apache.fop.area.inline;
  18. import java.util.List;
  19. import java.util.ArrayList;
  20. /**
  21. * Filled area.
  22. * This inline area contains some inline areas.
  23. * When the renderer gets the child areas to render
  24. * the inline areas are repeated to fill the ipd of
  25. * this inline parent.
  26. * This extends InlineParent so that the renderer will render
  27. * this as a normal inline parent.
  28. */
  29. public class FilledArea extends InlineParent {
  30. private int unitWidth;
  31. /**
  32. * Create a new filled area.
  33. */
  34. public FilledArea() {
  35. }
  36. /**
  37. * Set the unit width for the areas to fill the full width.
  38. *
  39. * @param w the unit width
  40. */
  41. public void setUnitWidth(int w) {
  42. unitWidth = w;
  43. }
  44. /**
  45. * Get the child areas for this filed area.
  46. * This copies the references of the inline areas so that
  47. * it fills the total width of the area a whole number of times
  48. * for the unit width.
  49. *
  50. * @return the list of child areas copied to fill the width
  51. */
  52. public List getChildAreas() {
  53. int units = (int)(getWidth() / unitWidth);
  54. List newList = new ArrayList();
  55. for (int count = 0; count < units; count++) {
  56. newList.addAll(inlines);
  57. }
  58. return newList;
  59. }
  60. }