01: package com.xoetrope.print;
02:
03: import java.util.ArrayList;
04: import javax.swing.BorderFactory;
05: import net.xoetrope.swing.XComboBox;
06: import net.xoetrope.swing.XDialog;
07: import net.xoetrope.swing.XEdit;
08: import net.xoetrope.swing.XPanel;
09: import net.xoetrope.xui.data.XBaseModel;
10:
11: /**
12: * <p> Copyright (c) Xoetrope Ltd., 2001-2007, This software is licensed under
13: * the GNU Public License (GPL), please see license.txt for more details. If
14: * you make commercial use of this software you must purchase a commercial
15: * license from Xoetrope.</p>
16: */
17: public class MarginSelect extends XDialog {
18: XPanel pagePanel, marginPanel;
19:
20: /** Creates a new instance of MarginSelect */
21: public MarginSelect() {
22: }
23:
24: public void pageCreated() {
25: pagePanel = (XPanel) findComponent("pagePanel");
26: marginPanel = (XPanel) findComponent("marginPanel");
27:
28: pagePanel.setBorder(BorderFactory
29: .createTitledBorder("Page Size"));
30: marginPanel.setBorder(BorderFactory
31: .createTitledBorder("Margins (millimeters)"));
32: }
33:
34: public void setMargin() {
35: XComboBox marginBox = (XComboBox) findComponent("marginBox");
36: XEdit left = (XEdit) findComponent("left");
37: XEdit right = (XEdit) findComponent("right");
38: XEdit top = (XEdit) findComponent("top");
39: XEdit bottom = (XEdit) findComponent("bottom");
40:
41: String s1 = marginBox.getSelectedItem().toString();
42: double d1 = Double.valueOf(left.getText()).doubleValue() * 2.83464567;
43: double d2 = Double.valueOf(right.getText()).doubleValue() * 2.83464567;
44: double d3 = Double.valueOf(top.getText()).doubleValue() * 2.83464567;
45: double d4 = Double.valueOf(bottom.getText()).doubleValue() * 2.83464567;
46:
47: ArrayList marginList = new ArrayList();
48: marginList.add(s1);
49: marginList.add(new Float((float) d1));
50: marginList.add(new Float((float) d2));
51: marginList.add(new Float((float) d3));
52: marginList.add(new Float((float) d4));
53: rootModel.set("margins", marginList);
54:
55: closeDlg();
56: }
57: }
|