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 |
|
|
42 |
import org.apache.log4j.Logger; |
import org.apache.log4j.Logger; |
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 |
/** |
/** |
51 |
* Achtung! Dieser code ist verwuestet TODO DOKU und initialize schöner machen. |
* TODO Dokument |
|
* SK |
|
52 |
*/ |
*/ |
53 |
public class MapView extends JPanel { |
public class MapView extends JPanel { |
54 |
private static final Logger LOGGER = Logger.getLogger(MapView.class); |
private static final Logger LOGGER = Logger.getLogger(MapView.class); |
57 |
JSplitPane.HORIZONTAL_SPLIT); |
JSplitPane.HORIZONTAL_SPLIT); |
58 |
|
|
59 |
protected MapPaneStatusBar statusBar = null; |
protected MapPaneStatusBar statusBar = null; |
|
|
|
60 |
/** |
/** |
61 |
* Komponente, in der die Karten, der Massstab und das Koordinaten-Raster |
* Komponente, in der die Karten, der Massstab und das Koordinaten-Raster |
62 |
* dargestellt werden. |
* dargestellt werden. |
63 |
*/ |
*/ |
|
|
|
64 |
protected final GeoMapPane geoMapPane = new GeoMapPane(); |
protected final GeoMapPane geoMapPane = new GeoMapPane(); |
65 |
|
|
66 |
private MapPaneToolBar jToolBar; |
private MapPaneToolBar jToolBar; |
68 |
/** |
/** |
69 |
* 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 |
70 |
* {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left, and |
* {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left, and |
71 |
* some buttons floating over the {@link JMapPane} |
* some buttons floating over the {@link SelectableXMapPane} |
72 |
*/ |
*/ |
73 |
public MapView(Component parentGui, MapPaneToolBar toolBar) { |
public MapView(Component parentGui, MapPaneToolBar toolBar) { |
74 |
super(new BorderLayout()); |
super(new BorderLayout()); |
75 |
// Call initialize() by yourself afterwards. |
// Call initialize() by yourself afterwards. |
76 |
// Needed because variables for the overwritten methods |
// Needed because variables for the overwritten methods |
77 |
// are not yet set. |
// are not yet set. |
|
getGeoMapPane().getMapPane().setWaitCursorComponent(parentGui); |
|
78 |
jToolBar = toolBar; |
jToolBar = toolBar; |
79 |
|
|
80 |
|
// By default the MapPane will render with antialiasing on |
81 |
|
getGeoMapPane().getMapPane().setAntiAliasing(true); |
82 |
} |
} |
83 |
|
|
84 |
/** |
/** |
85 |
* 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 |
86 |
* {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left, and |
* {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left, and |
87 |
* some buttons floating over the {@link JMapPane} |
* some buttons floating over the {@link SelectableXMapPane} |
88 |
*/ |
*/ |
89 |
public MapView(Component parentGui) { |
public MapView(Component parentGui) { |
90 |
this(parentGui, null); |
this(parentGui, null); |
105 |
|
|
106 |
// Status-Line to show Coordinates and Rastervalues. |
// Status-Line to show Coordinates and Rastervalues. |
107 |
statusBar = new MapPaneStatusBar(getGeoMapPane().getMapPane()); |
statusBar = new MapPaneStatusBar(getGeoMapPane().getMapPane()); |
108 |
statusBar.setBorder(BorderFactory.createCompoundBorder(BorderFactory |
statusBar.setBorder(BorderFactory.createCompoundBorder( |
109 |
.createLoweredBevelBorder(), BorderFactory.createEmptyBorder(2, |
BorderFactory.createLoweredBevelBorder(), |
110 |
5, 2, 5))); |
BorderFactory.createEmptyBorder(2, 5, 2, 5))); |
111 |
this.add(statusBar, BorderLayout.SOUTH); |
this.add(statusBar, BorderLayout.SOUTH); |
112 |
|
|
113 |
/** |
/** |
124 |
* 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 |
125 |
* a gmp |
* a gmp |
126 |
*/ |
*/ |
127 |
JPanel newRight = new JPanel(new MigLayout("center, wrap 1","[grow]","[][grow]")); |
JPanel newRight = new JPanel(new MigLayout("center, wrap 1", "[grow]", |
128 |
|
"[][grow]")); |
129 |
newRight.add(getToolBar()); |
newRight.add(getToolBar()); |
130 |
newRight.add(getGeoMapPane(),"growx, growy"); |
newRight.add(getGeoMapPane(), "growx, growy"); |
131 |
getSplitPane().add(newRight); |
getSplitPane().add(newRight); |
132 |
|
|
133 |
this.add(getSplitPane(), BorderLayout.CENTER); |
this.add(getSplitPane(), BorderLayout.CENTER); |
134 |
|
|
135 |
} |
} |
136 |
|
|
137 |
/** |
/** |
227 |
/** |
/** |
228 |
* Liefert den Karten-Bereich der Komponente. |
* Liefert den Karten-Bereich der Komponente. |
229 |
*/ |
*/ |
230 |
public final JMapPane getMapPane() { |
public final SelectableXMapPane getMapPane() { |
231 |
return getGeoMapPane().getMapPane(); |
return getGeoMapPane().getMapPane(); |
232 |
} |
} |
233 |
|
|
239 |
return jToolBar.getSelectedTool(); |
return jToolBar.getSelectedTool(); |
240 |
} |
} |
241 |
|
|
242 |
|
/** |
243 |
|
* Help the garbage collection |
244 |
|
*/ |
245 |
|
public void dispose() { |
246 |
|
if (geoMapPane != null) |
247 |
|
geoMapPane.dispose(); |
248 |
|
} |
249 |
|
|
250 |
} |
} |