View Javadoc

1   /*
2    * Created on Dec 2, 2005. Copyright 1999-2006 Faculty of Mathematics, Physics
3    * and Informatics, Comenius University, Bratislava. This file is protected by
4    * the Mozilla Public License version 1.1 (the "License"); you may not use this
5    * file except in compliance with the License. You may obtain a copy of the
6    * License at http://euromath2.sourceforge.net/license.html Unless required by
7    * applicable law or agreed to in writing, software distributed under the
8    * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9    * OF ANY KIND, either express or implied. See the License for the specific
10   * language governing permissions and limitations under the License.
11   */
12  package sk.uniba.euromath.foRenderer.figures;
13  import java.util.List;
14  import org.apache.fop.area.Footnote;
15  import org.eclipse.draw2d.IFigure;
16  import org.eclipse.draw2d.geometry.Dimension;
17  import org.eclipse.draw2d.geometry.Point;
18  import org.eclipse.draw2d.geometry.Rectangle;
19  /***
20   * @author Martin Vysny
21   */
22  public class FootnoteFigure extends BasicFOPFigure {
23  	public FootnoteFigure(Footnote footnote) {
24  		super(footnote);
25  		setLayoutManager(new FootnoteFigureLayout());
26  	}
27  	public class FootnoteFigureLayout extends BaseFOLayout {
28  		public FootnoteFigureLayout() {
29  			super();
30  		}
31  		protected Dimension calculatePreferredSize(IFigure parent, int wHint,
32  				int hHint) {
33  			preferredSize = new Dimension();
34  			List children = parent.getChildren();
35  			IFigure child;
36  			Dimension size;
37  			for (int i = 0; i < children.size(); i++) {
38  				child = (IFigure) children.get(i);
39  				size = child.getPreferredSize();
40  				preferredSize.height += size.height;
41  				preferredSize.width = Math.max(preferredSize.width, size.width);
42  			}
43  			return preferredSize;
44  		}
45  		public void layout(IFigure parent) {
46  			Point origin = getOrigin(parent);
47  			IFigure child;
48  			Dimension size;
49  			List children = parent.getChildren();
50  			for (int i = 0; i < children.size(); i++) {
51  				child = (IFigure) children.get(i);
52  				size = child.getPreferredSize();
53  				child.setBounds(new Rectangle(origin, size));
54  				origin.y += size.height;
55  			}
56  		}
57  	}
58  }