01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
10: //The Original Code is "The Columba Project"
11: //
12: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14: //
15: //All Rights Reserved.
16: package org.columba.core.print;
17:
18: import java.awt.Graphics2D;
19: import java.util.Vector;
20:
21: public class cVGroup extends cPrintObject {
22: Vector members;
23:
24: public cVGroup() {
25: members = new Vector();
26: }
27:
28: public void add(cPrintObject po) {
29: po.setType(cPrintObject.GROUPMEMBER);
30: members.add(po);
31: }
32:
33: public void print(Graphics2D g) {
34: cPrintObject act;
35:
36: computePositionAndSize();
37:
38: cPoint location = getDrawingOrigin();
39:
40: for (int i = 0; i < members.size(); i++) {
41: act = (cPrintObject) members.get(i);
42: act.setLocation(location);
43: location = location.addHeight(act.getSize(
44: getDrawingSize().getWidth()).getHeight());
45:
46: act.setPage(page);
47: act.print(g);
48: }
49: }
50:
51: public cSize getSize(cUnit width) {
52: cUnit max = new cCmUnit();
53: cSize act;
54: cUnit maxWidth = new cCmUnit();
55:
56: for (int i = 0; i < members.size(); i++) {
57: act = ((cPrintObject) members.get(i)).getSize(width);
58:
59: if (act.getWidth().getPoints() > maxWidth.getPoints()) {
60: maxWidth = act.getWidth();
61: }
62:
63: max.addI(act.getHeight());
64: }
65:
66: max.addI(topMargin);
67: max.addI(bottomMargin);
68:
69: maxWidth.addI(leftMargin);
70: maxWidth.addI(rightMargin);
71:
72: return new cSize(maxWidth, max);
73: }
74: }
|