2 |
* Copyright (c) 2009 Martin O. J. Schmitz. |
* Copyright (c) 2009 Martin O. J. Schmitz. |
3 |
* |
* |
4 |
* This file is part of the SCHMITZM library - a collection of utility |
* This file is part of the SCHMITZM library - a collection of utility |
5 |
* classes based on Java 1.6, focussing (not only) on Java Swing |
* classes based on Java 1.6, focusing (not only) on Java Swing |
6 |
* and the Geotools library. |
* and the Geotools library. |
7 |
* |
* |
8 |
* The SCHMITZM project is hosted at: |
* The SCHMITZM project is hosted at: |
25 |
* |
* |
26 |
* Contributors: |
* Contributors: |
27 |
* Martin O. J. Schmitz - initial API and implementation |
* Martin O. J. Schmitz - initial API and implementation |
28 |
* Stefan A. Krüger - additional utility classes |
* Stefan A. Tzeggai - additional utility classes |
29 |
******************************************************************************/ |
******************************************************************************/ |
30 |
package skrueger.geotools; |
package skrueger.geotools; |
31 |
|
|
37 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
38 |
import javax.swing.JSplitPane; |
import javax.swing.JSplitPane; |
39 |
|
|
40 |
|
import net.miginfocom.swing.MigLayout; |
41 |
|
|
42 |
import org.apache.log4j.Logger; |
import org.apache.log4j.Logger; |
|
import org.geotools.renderer.lite.StreamingRenderer; |
|
|
import org.geotools.renderer.shape.TransitionShapefileRenderer; |
|
43 |
|
|
44 |
import schmitzm.geotools.gui.GeoMapPane; |
import schmitzm.geotools.gui.GeoMapPane; |
|
import schmitzm.geotools.gui.JMapPane; |
|
45 |
import schmitzm.geotools.gui.MapContextControlPane; |
import schmitzm.geotools.gui.MapContextControlPane; |
46 |
import schmitzm.geotools.gui.MapPaneStatusBar; |
import schmitzm.geotools.gui.MapPaneStatusBar; |
47 |
|
import schmitzm.geotools.gui.SelectableXMapPane; |
48 |
import schmitzm.geotools.styling.ColorMapManager; |
import schmitzm.geotools.styling.ColorMapManager; |
49 |
|
|
50 |
/** |
/** |
58 |
JSplitPane.HORIZONTAL_SPLIT); |
JSplitPane.HORIZONTAL_SPLIT); |
59 |
|
|
60 |
protected MapPaneStatusBar statusBar = null; |
protected MapPaneStatusBar statusBar = null; |
|
|
|
61 |
/** |
/** |
62 |
* Komponente, in der die Karten, der Massstab und das Koordinaten-Raster |
* Komponente, in der die Karten, der Massstab und das Koordinaten-Raster |
63 |
* dargestellt werden. |
* dargestellt werden. |
64 |
*/ |
*/ |
|
|
|
65 |
protected final GeoMapPane geoMapPane = new GeoMapPane(); |
protected final GeoMapPane geoMapPane = new GeoMapPane(); |
66 |
|
|
67 |
private MapPaneToolBar jToolBar; |
private MapPaneToolBar jToolBar; |
69 |
/** |
/** |
70 |
* Creates a new {@link MapView}. A {@link MapView} is a combination of a |
* Creates a new {@link MapView}. A {@link MapView} is a combination of a |
71 |
* {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left, and |
* {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left, and |
72 |
* some buttons floating over the {@link JMapPane} |
* some buttons floating over the {@link SelectableXMapPane} |
73 |
*/ |
*/ |
74 |
public MapView(Component parentGui, MapPaneToolBar toolBar) { |
public MapView(Component parentGui, MapPaneToolBar toolBar) { |
75 |
super(new BorderLayout()); |
super(new BorderLayout()); |
76 |
// Call initialize() by yourself afterwards. |
// Call initialize() by yourself afterwards. |
77 |
// Needed because variables for the overwritten methods |
// Needed because variables for the overwritten methods |
78 |
// are not yet set. |
// are not yet set. |
|
getGeoMapPane().getMapPane().setWaitCursorComponent(parentGui); |
|
|
if (toolBar == null) |
|
|
toolBar = new MapPaneToolBar(getMapPane()); |
|
79 |
jToolBar = toolBar; |
jToolBar = toolBar; |
80 |
|
|
81 |
|
// By default the MapPane will render with antialiasing on |
82 |
|
getGeoMapPane().getMapPane().setAntiAliasing(true); |
83 |
} |
} |
84 |
|
|
85 |
/** |
/** |
86 |
* Creates a new {@link MapView}. A {@link MapView} is a combination of a |
* Creates a new {@link MapView}. A {@link MapView} is a combination of a |
87 |
* {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left, and |
* {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left, and |
88 |
* some buttons floating over the {@link JMapPane} |
* some buttons floating over the {@link SelectableXMapPane} |
89 |
*/ |
*/ |
90 |
public MapView(Component parentGui) { |
public MapView(Component parentGui) { |
91 |
this(parentGui, null); |
this(parentGui, null); |
106 |
|
|
107 |
// Status-Line to show Coordinates and Rastervalues. |
// Status-Line to show Coordinates and Rastervalues. |
108 |
statusBar = new MapPaneStatusBar(getGeoMapPane().getMapPane()); |
statusBar = new MapPaneStatusBar(getGeoMapPane().getMapPane()); |
109 |
statusBar.setBorder(BorderFactory.createCompoundBorder(BorderFactory |
statusBar.setBorder(BorderFactory.createCompoundBorder( |
110 |
.createLoweredBevelBorder(), BorderFactory.createEmptyBorder(2, |
BorderFactory.createLoweredBevelBorder(), |
111 |
5, 2, 5))); |
BorderFactory.createEmptyBorder(2, 5, 2, 5))); |
112 |
this.add(statusBar, BorderLayout.SOUTH); |
this.add(statusBar, BorderLayout.SOUTH); |
113 |
|
|
114 |
/** |
/** |
125 |
* To the right side we now add a JPanel that consists of a toolbar and |
* To the right side we now add a JPanel that consists of a toolbar and |
126 |
* a gmp |
* a gmp |
127 |
*/ |
*/ |
128 |
JPanel newRight = new JPanel(new BorderLayout()); |
JPanel newRight = new JPanel(new MigLayout("center, wrap 1", "[grow]", |
129 |
newRight.add(getToolBar(), BorderLayout.NORTH); |
"[][grow]")); |
130 |
newRight.add(getGeoMapPane(), BorderLayout.CENTER); |
newRight.add(getToolBar()); |
131 |
|
newRight.add(getGeoMapPane(), "growx, growy"); |
132 |
getSplitPane().add(newRight); |
getSplitPane().add(newRight); |
133 |
|
|
134 |
this.add(getSplitPane(), BorderLayout.CENTER); |
this.add(getSplitPane(), BorderLayout.CENTER); |
135 |
|
|
136 |
} |
} |
137 |
|
|
138 |
/** |
/** |
139 |
* Returns the tool bar which controls the active mouse actions on the map. |
* Returns the tool bar which controls the active mouse actions on the map. |
140 |
* |
* |
141 |
* @return |
* @return never <code>null</code>, will rather create a default |
142 |
*/ |
*/ |
143 |
public MapPaneToolBar getToolBar() { |
public MapPaneToolBar getToolBar() { |
144 |
|
if (jToolBar == null) { |
145 |
|
jToolBar = new MapPaneToolBar(getMapPane()); |
146 |
|
} |
147 |
return jToolBar; |
return jToolBar; |
148 |
} |
} |
149 |
|
|
228 |
/** |
/** |
229 |
* Liefert den Karten-Bereich der Komponente. |
* Liefert den Karten-Bereich der Komponente. |
230 |
*/ |
*/ |
231 |
public final JMapPane getMapPane() { |
public final SelectableXMapPane getMapPane() { |
232 |
return getGeoMapPane().getMapPane(); |
return getGeoMapPane().getMapPane(); |
233 |
} |
} |
234 |
|
|
240 |
return jToolBar.getSelectedTool(); |
return jToolBar.getSelectedTool(); |
241 |
} |
} |
242 |
|
|
243 |
|
/** |
244 |
|
* Help the garbage collection |
245 |
|
*/ |
246 |
|
public void dispose() { |
247 |
|
if (geoMapPane != null) |
248 |
|
geoMapPane.dispose(); |
249 |
|
} |
250 |
|
|
251 |
} |
} |