1 |
mojays |
2 |
package skrueger.geotools; |
2 |
|
|
|
3 |
|
|
import java.awt.BorderLayout; |
4 |
alfonx |
87 |
import java.awt.Window; |
5 |
mojays |
2 |
|
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 |
alfonx |
158 |
import org.geotools.renderer.lite.StreamingRenderer; |
13 |
alfonx |
154 |
import org.geotools.renderer.shape.ShapefileRenderer; |
14 |
mojays |
2 |
|
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 |
23 |
|
|
* TODO DOKU und initialize schöner machen. SK |
24 |
|
|
*/ |
25 |
|
|
public class MapView extends JPanel { |
26 |
|
|
private static final Logger LOGGER = Logger.getLogger(MapView.class); |
27 |
|
|
|
28 |
alfonx |
148 |
public final JSplitPane splitPane = new JSplitPane( |
29 |
mojays |
2 |
JSplitPane.HORIZONTAL_SPLIT); |
30 |
|
|
|
31 |
|
|
protected MapPaneStatusBar statusBar = null; |
32 |
|
|
|
33 |
|
|
/** |
34 |
|
|
* Komponente, in der die Karten, der Massstab und das Koordinaten-Raster |
35 |
alfonx |
154 |
* dargestellt werden. |
36 |
mojays |
2 |
*/ |
37 |
alfonx |
154 |
|
38 |
|
|
/** |
39 |
|
|
* SK: 21.6.09: ShapeFileRenderer is supposed to be about 5x faster on |
40 |
|
|
* ShapeFiles. The ShapeFileRenderer falls back to the |
41 |
|
|
* StreamingRenderer. |
42 |
|
|
*/ |
43 |
|
|
// Old code: |
44 |
|
|
// protected final GeoMapPane geoMapPane = new GeoMapPane(null,null,null,null, new StreamingRenderer()); |
45 |
|
|
|
46 |
|
|
// New Code uses Streaming renderer. |
47 |
alfonx |
159 |
protected final GeoMapPane geoMapPane = new GeoMapPane(null,null,null,null, new StreamingRenderer()); |
48 |
mojays |
2 |
|
49 |
|
|
private MapPaneToolBar jToolBar; |
50 |
|
|
|
51 |
|
|
/** |
52 |
|
|
* Creates a new {@link MapView}. A {@link MapView} is a combination of a |
53 |
|
|
* {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left, |
54 |
|
|
* and some buttons floating over the {@link JMapPane} |
55 |
|
|
*/ |
56 |
alfonx |
87 |
public MapView(Window parentGui, MapPaneToolBar toolBar) { |
57 |
mojays |
2 |
super(new BorderLayout()); |
58 |
|
|
// Call initialize() by yourself afterwards. |
59 |
|
|
// Needed because variables for the overwritten methods |
60 |
|
|
// are not yet set. |
61 |
alfonx |
87 |
getGeoMapPane().getMapPane().setWaitCursorComponent(parentGui); |
62 |
mojays |
2 |
if ( toolBar == null ) |
63 |
|
|
toolBar = new MapPaneToolBar(getMapPane()); |
64 |
|
|
jToolBar = toolBar; |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
/** |
68 |
|
|
* Creates a new {@link MapView}. A {@link MapView} is a combination of a |
69 |
|
|
* {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left, |
70 |
|
|
* and some buttons floating over the {@link JMapPane} |
71 |
|
|
*/ |
72 |
alfonx |
87 |
public MapView(Window parentGui) { |
73 |
|
|
this(parentGui, null); |
74 |
mojays |
2 |
} |
75 |
|
|
|
76 |
|
|
/** |
77 |
|
|
* Calls #getSidePanel() which can be overwritten. |
78 |
|
|
* |
79 |
|
|
* @see #adjustSizeOfGeoMapPane() |
80 |
|
|
*/ |
81 |
|
|
public void initialize() { |
82 |
|
|
// horizontales SplitPane initialisieren |
83 |
alfonx |
154 |
// Status-Line to show Coordinates and Rastervalues. |
84 |
|
|
statusBar = new MapPaneStatusBar(getGeoMapPane() |
85 |
|
|
.getMapPane()); |
86 |
|
|
statusBar.setBorder(BorderFactory.createCompoundBorder(BorderFactory |
87 |
|
|
.createLoweredBevelBorder(), BorderFactory.createEmptyBorder(2, |
88 |
|
|
5, 2, 5))); |
89 |
|
|
this.add(statusBar, BorderLayout.SOUTH); |
90 |
mojays |
2 |
|
91 |
alfonx |
148 |
splitPane.setDividerLocation(-1); |
92 |
mojays |
2 |
splitPane.setDividerSize(5); |
93 |
alfonx |
148 |
|
94 |
|
|
splitPane.setResizeWeight(0.0); |
95 |
mojays |
2 |
splitPane.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 |
|
|
splitPane.add(newRight); |
105 |
|
|
|
106 |
|
|
this.add(splitPane, BorderLayout.CENTER); |
107 |
|
|
} |
108 |
|
|
|
109 |
|
|
/** |
110 |
|
|
* Returns the tool bar which controls the active mouse actions on the map. |
111 |
|
|
* @return |
112 |
|
|
*/ |
113 |
|
|
public MapPaneToolBar getToolBar() { |
114 |
|
|
return jToolBar; |
115 |
|
|
} |
116 |
|
|
|
117 |
|
|
/** |
118 |
|
|
* Returns the split pane which divides the layer list from the map panel. |
119 |
|
|
*/ |
120 |
|
|
public JSplitPane getSplitPane() { |
121 |
|
|
return this.splitPane; |
122 |
|
|
} |
123 |
|
|
|
124 |
|
|
|
125 |
|
|
/** |
126 |
|
|
* Sets the active tool. |
127 |
|
|
* Simply calls {@link MapPaneToolBar#setSelectedTool(Integer)}. |
128 |
|
|
* @param tool |
129 |
|
|
* One of {@link #TOOL_INFO}, {@link #TOOL_PAN} .. constants |
130 |
|
|
*/ |
131 |
|
|
public void setSelectedTool(Integer tool) { |
132 |
|
|
jToolBar.setSelectedTool(tool); |
133 |
|
|
} |
134 |
|
|
|
135 |
|
|
/** |
136 |
|
|
* Sets whether a tool is activated or not. |
137 |
|
|
* Simply calls {@link MapPaneToolBar#setButtonEnabled(int, boolean, boolean)}. |
138 |
|
|
* @param tool tool ID |
139 |
|
|
* @param enabled if {@code true} the tool becomes available |
140 |
|
|
* @param hideOnDisable if {@code true} the button is also hidden if |
141 |
|
|
* {@code enabled} is {@code false} |
142 |
|
|
*/ |
143 |
|
|
public void setToolEnabled(Integer tool, boolean enabled, boolean hideOnDisable) { |
144 |
|
|
jToolBar.setButtonEnabled(tool,enabled,hideOnDisable); |
145 |
|
|
} |
146 |
|
|
|
147 |
|
|
/** |
148 |
|
|
* Sets the activation for all tools. |
149 |
|
|
* Simply calls {@link MapPaneToolBar#setAllToolsEnabled(boolean, boolean)}. |
150 |
|
|
* @param enabled if {@code true} all tool becomes available |
151 |
|
|
* @param hideOnDisable if {@code true} the buttons are also hidden if |
152 |
|
|
* {@code enabled} is {@code false} |
153 |
|
|
*/ |
154 |
|
|
public void setAllToolsEnabled(boolean enabled, boolean hideOnDisable) { |
155 |
|
|
jToolBar.setAllToolsEnabled(enabled, hideOnDisable); |
156 |
|
|
} |
157 |
|
|
|
158 |
|
|
/** |
159 |
|
|
* Checks whether a tool is activated. |
160 |
|
|
* Simply calls {@link MapPaneToolBar#isButtonEnabled(Integer)}. |
161 |
|
|
* @param tool tool ID |
162 |
|
|
* @return {@code false} if an unknown ID is specified |
163 |
|
|
*/ |
164 |
|
|
public boolean isToolEnabled(Integer tool) { |
165 |
|
|
return jToolBar.isButtonEnabled(tool); |
166 |
|
|
} |
167 |
|
|
|
168 |
|
|
/** |
169 |
|
|
* called by initialize() to fill the left of the XULUMapView Supposed to be |
170 |
|
|
* overwritten by AtlasMapView or DesignMapView |
171 |
|
|
*/ |
172 |
|
|
public JComponent getSidePane() { |
173 |
|
|
return new MapContextControlPane(getGeoMapPane().getMapPane(), |
174 |
|
|
new ColorMapManager()); |
175 |
|
|
} |
176 |
|
|
|
177 |
|
|
/** |
178 |
|
|
* Liefert die Status-Zeile, in der die Koordinaten und Raster-Werte |
179 |
|
|
* angezeigt werden. |
180 |
|
|
*/ |
181 |
|
|
public MapPaneStatusBar getStatusBar() { |
182 |
|
|
return this.statusBar; |
183 |
|
|
} |
184 |
|
|
|
185 |
|
|
/** |
186 |
|
|
* Liefert den Karten-Bereich der Komponente. |
187 |
|
|
*/ |
188 |
|
|
public final JMapPane getMapPane() { |
189 |
|
|
return getGeoMapPane().getMapPane(); |
190 |
|
|
} |
191 |
|
|
|
192 |
|
|
public GeoMapPane getGeoMapPane() { |
193 |
|
|
return geoMapPane; |
194 |
|
|
} |
195 |
|
|
|
196 |
|
|
public int getSelectedTool() { |
197 |
|
|
return jToolBar.getSelectedTool(); |
198 |
|
|
} |
199 |
|
|
|
200 |
|
|
} |