/[schmitzm]/trunk/src/skrueger/geotools/MapView.java
ViewVC logotype

Contents of /trunk/src/skrueger/geotools/MapView.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 227 - (show annotations)
Fri Jul 17 07:25:29 2009 UTC (15 years, 7 months ago) by alfonx
File size: 6268 byte(s)
* AV-Revert: Had to replace TransitionalShapefileRenderer again, because AR reported reproducable hangs on many Windows machines. 

* GP-Feature: Created an Export-Wizard! Check it out.. it's fun!

1 package skrueger.geotools;
2
3 import java.awt.BorderLayout;
4 import java.awt.Component;
5
6 import javax.swing.BorderFactory;
7 import javax.swing.JComponent;
8 import javax.swing.JPanel;
9 import javax.swing.JSplitPane;
10
11 import org.apache.log4j.Logger;
12 import org.geotools.renderer.lite.StreamingRenderer;
13 import org.geotools.renderer.shape.TransitionShapefileRenderer;
14
15 import schmitzm.geotools.gui.GeoMapPane;
16 import schmitzm.geotools.gui.JMapPane;
17 import schmitzm.geotools.gui.MapContextControlPane;
18 import schmitzm.geotools.gui.MapPaneStatusBar;
19 import schmitzm.geotools.styling.ColorMapManager;
20
21 /**
22 * Achtung! Dieser code ist verwuestet TODO DOKU und initialize schöner machen.
23 * SK
24 */
25 public class MapView extends JPanel {
26 private static final Logger LOGGER = Logger.getLogger(MapView.class);
27
28 private final JSplitPane splitPane = new JSplitPane(
29 JSplitPane.HORIZONTAL_SPLIT);
30
31 protected MapPaneStatusBar statusBar = null;
32
33 /**
34 * Komponente, in der die Karten, der Massstab und das Koordinaten-Raster
35 * dargestellt werden.
36 */
37
38 protected final GeoMapPane geoMapPane = new GeoMapPane();
39
40 private MapPaneToolBar jToolBar;
41
42 /**
43 * Creates a new {@link MapView}. A {@link MapView} is a combination of a
44 * {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left, and
45 * some buttons floating over the {@link JMapPane}
46 */
47 public MapView(Component parentGui, MapPaneToolBar toolBar) {
48 super(new BorderLayout());
49 // Call initialize() by yourself afterwards.
50 // Needed because variables for the overwritten methods
51 // are not yet set.
52 getGeoMapPane().getMapPane().setWaitCursorComponent(parentGui);
53 if (toolBar == null)
54 toolBar = new MapPaneToolBar(getMapPane());
55 jToolBar = toolBar;
56 }
57
58 /**
59 * Creates a new {@link MapView}. A {@link MapView} is a combination of a
60 * {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left, and
61 * some buttons floating over the {@link JMapPane}
62 */
63 public MapView(Component parentGui) {
64 this(parentGui, null);
65 }
66
67 /**
68 * This routine creates the main components of the GUI: The left Side and
69 * the map on the right side.<br/>
70 * Calls #getSidePanel() which can be overwritten (call super!).<br/>
71 *
72 * This method initialized the variables {@link #statusBar} and
73 * {@link #splitPane}
74 *
75 * @see #adjustSizeOfGeoMapPane()
76 */
77 public void initialize() {
78 // horizontales SplitPane initialisieren
79
80 // Status-Line to show Coordinates and Rastervalues.
81 statusBar = new MapPaneStatusBar(getGeoMapPane().getMapPane());
82 statusBar.setBorder(BorderFactory.createCompoundBorder(BorderFactory
83 .createLoweredBevelBorder(), BorderFactory.createEmptyBorder(2,
84 5, 2, 5)));
85 this.add(statusBar, BorderLayout.SOUTH);
86
87 /**
88 * The layout of the split pane can be configured in the atlas.
89 * setDividerLocation(-1); has no effect here because the component is
90 * not visible yet.
91 */
92 getSplitPane().setDividerSize(5);
93
94 getSplitPane().setResizeWeight(0.0);
95 getSplitPane().add(getSidePane());
96
97 /***********************************************************************
98 * To the right side we now add a JPanel that consists of a toolbar and
99 * a gmp
100 */
101 JPanel newRight = new JPanel(new BorderLayout());
102 newRight.add(getToolBar(), BorderLayout.NORTH);
103 newRight.add(getGeoMapPane(), BorderLayout.CENTER);
104 getSplitPane().add(newRight);
105
106 this.add(getSplitPane(), BorderLayout.CENTER);
107 }
108
109 /**
110 * Returns the tool bar which controls the active mouse actions on the map.
111 *
112 * @return
113 */
114 public MapPaneToolBar getToolBar() {
115 return jToolBar;
116 }
117
118 /**
119 * Returns the split pane which divides the layer list from the map panel.
120 */
121 public JSplitPane getSplitPane() {
122 return splitPane;
123 }
124
125 /**
126 * Sets the active tool. Simply calls
127 * {@link MapPaneToolBar#setSelectedTool(Integer)}.
128 *
129 * @param tool
130 * One of {@link #TOOL_INFO}, {@link #TOOL_PAN} .. constants
131 */
132 public void setSelectedTool(Integer tool) {
133 jToolBar.setSelectedTool(tool);
134 }
135
136 /**
137 * Sets whether a tool is activated or not. Simply calls
138 * {@link MapPaneToolBar#setButtonEnabled(int, boolean, boolean)}.
139 *
140 * @param tool
141 * tool ID
142 * @param enabled
143 * if {@code true} the tool becomes available
144 * @param hideOnDisable
145 * if {@code true} the button is also hidden if {@code enabled}
146 * is {@code false}
147 */
148 public void setToolEnabled(Integer tool, boolean enabled,
149 boolean hideOnDisable) {
150 jToolBar.setButtonEnabled(tool, enabled, hideOnDisable);
151 }
152
153 /**
154 * Sets the activation for all tools. Simply calls
155 * {@link MapPaneToolBar#setAllToolsEnabled(boolean, boolean)}.
156 *
157 * @param enabled
158 * if {@code true} all tool becomes available
159 * @param hideOnDisable
160 * if {@code true} the buttons are also hidden if {@code enabled}
161 * is {@code false}
162 */
163 public void setAllToolsEnabled(boolean enabled, boolean hideOnDisable) {
164 jToolBar.setAllToolsEnabled(enabled, hideOnDisable);
165 }
166
167 /**
168 * Checks whether a tool is activated. Simply calls
169 * {@link MapPaneToolBar#isButtonEnabled(Integer)}.
170 *
171 * @param tool
172 * tool ID
173 * @return {@code false} if an unknown ID is specified
174 */
175 public boolean isToolEnabled(Integer tool) {
176 return jToolBar.isButtonEnabled(tool);
177 }
178
179 /**
180 * called by initialize() to fill the left of the XULUMapView Supposed to be
181 * overwritten by AtlasMapView or DesignMapView
182 */
183 public JComponent getSidePane() {
184 return new MapContextControlPane(getGeoMapPane().getMapPane(),
185 new ColorMapManager());
186 }
187
188 /**
189 * Liefert die Status-Zeile, in der die Koordinaten und Raster-Werte
190 * angezeigt werden.
191 */
192 public MapPaneStatusBar getStatusBar() {
193 return this.statusBar;
194 }
195
196 /**
197 * Liefert den Karten-Bereich der Komponente.
198 */
199 public final JMapPane getMapPane() {
200 return getGeoMapPane().getMapPane();
201 }
202
203 public GeoMapPane getGeoMapPane() {
204 return geoMapPane;
205 }
206
207 public int getSelectedTool() {
208 return jToolBar.getSelectedTool();
209 }
210
211 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26