01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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:
18: /* $Id: InlineBlockParent.java 426576 2006-07-28 15:44:37Z jeremias $ */
19:
20: package org.apache.fop.area.inline;
21:
22: import org.apache.fop.area.Area;
23: import org.apache.fop.area.Block;
24:
25: /**
26: * Inline block parent area.
27: * This is an inline area that can have one block area as a child
28: */
29: public class InlineBlockParent extends InlineArea {
30:
31: /**
32: * The list of inline areas added to this inline parent.
33: */
34: protected Block child = null;
35:
36: /**
37: * Create a new inline block parent to add areas to.
38: */
39: public InlineBlockParent() {
40: }
41:
42: /**
43: * Override generic Area method.
44: *
45: * @param childArea the child area to add
46: */
47: public void addChildArea(Area childArea) {
48: if (child != null) {
49: throw new IllegalStateException(
50: "InlineBlockParent may have only one child area.");
51: }
52: if (childArea instanceof Block) {
53: child = (Block) childArea;
54: //Update extents from the child
55: setIPD(childArea.getAllocIPD());
56: setBPD(childArea.getAllocBPD());
57: } else {
58: throw new IllegalArgumentException(
59: "The child of an InlineBlockParent must be a"
60: + " Block area");
61: }
62: }
63:
64: /**
65: * Get the child areas for this inline parent.
66: *
67: * @return the list of child areas
68: */
69: public Block getChildArea() {
70: return child;
71: }
72:
73: }
|