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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26