01: /*
02: * uDig - User Friendly Desktop Internet GIS client
03: * http://udig.refractions.net
04: * (C) 2004, Refractions Research Inc.
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: */
17: package net.refractions.udig.printing.ui.internal;
18:
19: import net.refractions.udig.printing.model.Box;
20: import net.refractions.udig.printing.model.ModelFactory;
21: import net.refractions.udig.printing.model.Page;
22: import net.refractions.udig.printing.model.impl.LabelBoxPrinter;
23: import net.refractions.udig.printing.model.impl.MapBoxPrinter;
24: import net.refractions.udig.project.internal.Map;
25:
26: import org.eclipse.draw2d.geometry.Dimension;
27: import org.eclipse.draw2d.geometry.Point;
28:
29: /**
30: * Implementation of a Template at its most basic. Contains a title bar
31: * and a map.
32: *
33: * @author Richard Gould
34: */
35: public class BasicTemplate extends AbstractTemplate {
36:
37: /**
38: * Constructs the BasicTemplate and populates its two boxes with a title
39: * and a map.
40: */
41: public BasicTemplate() {
42: super ();
43: }
44:
45: /**
46: * Populates the templates two boxes with a title and map
47: * @param page * @param decorators a List of the Layers that are Decorators to be handled separate from the Map
48: *
49: * @param map the Map to be drawn
50: * @param width
51: * @param height
52: */
53: public void init(Page page, Map map, int width, int height) {
54:
55: Box box = ModelFactory.eINSTANCE.createBox();
56: LabelBoxPrinter labelBoxPrinter = new LabelBoxPrinter();
57: labelBoxPrinter
58: .setText(Messages.BasicTemplate_label_defaultTitle);
59: box.setBoxPrinter(labelBoxPrinter);
60: box.setID("Standard Label"); //$NON-NLS-1$
61: box.setSize(new Dimension(150, 30));
62: box.setLocation(new Point(10, 10));
63: boxes.add(box);
64:
65: Box mapBox = ModelFactory.eINSTANCE.createBox();
66: MapBoxPrinter mapBoxPrinter = new MapBoxPrinter();
67: mapBox.setID("Standard Map Box"); //$NON-NLS-1$
68: mapBox.setBoxPrinter(mapBoxPrinter);
69: mapBoxPrinter.setMap(map);
70: mapBox.setSize(new Dimension(400, 400));
71: mapBox.setLocation(new Point(50, 50));
72: boxes.add(mapBox);
73: //
74: // //This code should be added back in at some point
75: // for (int i = 0; i < decorators.size(); i++) {
76: // DecoratorBox decoratorBox = ModelFactory.eINSTANCE.createDecoratorBox();
77: // decoratorBox.setMap(map);
78: // decoratorBox.setLayer(decorators.get(i));
79: // decoratorBox.setSize(new Dimension(130, 75));
80: // decoratorBox.setLocation(new Point(100, 10));
81: //
82: // boxes.add(decoratorBox);
83: //
84: // Connection connection = ModelFactory.eINSTANCE.createConnection();
85: // connection.setSource(mapBox);
86: // connection.setTarget(decoratorBox);
87: // connection.reconnect();
88: // }
89:
90: page.setName(map.getName());
91: }
92:
93: /**
94: * @see net.refractions.udig.printing.ui.Template#getName()
95: */
96: public String getName() {
97: return Messages.BasicTemplate_name;
98: }
99: }
|