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.

InlineBlockParent.java 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.area.inline;
  19. import org.apache.fop.area.Area;
  20. import org.apache.fop.area.Block;
  21. /**
  22. * Inline block parent area.
  23. * This is an inline area that can have one block area as a child
  24. */
  25. public class InlineBlockParent extends InlineArea {
  26. private static final long serialVersionUID = -3661746143321407377L;
  27. /**
  28. * The list of inline areas added to this inline parent.
  29. */
  30. protected Block child;
  31. /**
  32. * Create a new inline block parent to add areas to.
  33. */
  34. public InlineBlockParent() {
  35. }
  36. /**
  37. * Override generic Area method.
  38. *
  39. * @param childArea the child area to add
  40. */
  41. @Override
  42. public void addChildArea(Area childArea) {
  43. if (child != null) {
  44. throw new IllegalStateException("InlineBlockParent may have only one child area.");
  45. }
  46. if (childArea instanceof Block) {
  47. child = (Block) childArea;
  48. //Update extents from the child
  49. setIPD(childArea.getAllocIPD());
  50. setBPD(childArea.getAllocBPD());
  51. } else {
  52. throw new IllegalArgumentException("The child of an InlineBlockParent must be a"
  53. + " Block area");
  54. }
  55. }
  56. /**
  57. * Get the child areas for this inline parent.
  58. *
  59. * @return the list of child areas
  60. */
  61. public Block getChildArea() {
  62. return child;
  63. }
  64. }