/[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 153 - (show annotations)
Sat Jun 20 12:48:24 2009 UTC (15 years, 8 months ago) by alfonx
File size: 5794 byte(s)
* Organized Imports
* Fixed a BuG in AS, PolygonSymbolEditGUI (Had to be Float instead of Double)
* Renamed DesignLayerPanel to DesginMapLegend etc...
* Bugfixed ManageLayerSytlesForMapDialog to trigger a preview of the new legend.
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
13 import schmitzm.geotools.gui.GeoMapPane;
14 import schmitzm.geotools.gui.JMapPane;
15 import schmitzm.geotools.gui.MapContextControlPane;
16 import schmitzm.geotools.gui.MapPaneStatusBar;
17 import schmitzm.geotools.styling.ColorMapManager;
18
19 /**
20 * Achtung! Dieser code ist verwuestet
21 * TODO DOKU und initialize schöner machen. SK
22 */
23 public class MapView extends JPanel {
24 private static final Logger LOGGER = Logger.getLogger(MapView.class);
25
26 public final JSplitPane splitPane = new JSplitPane(
27 JSplitPane.HORIZONTAL_SPLIT);
28
29 protected MapPaneStatusBar statusBar = null;
30
31 /**
32 * Komponente, in der die Karten, der Massstab und das Koordinaten-Raster
33 * dargestellt werden
34 */
35 protected final GeoMapPane geoMapPane = new GeoMapPane();
36
37 private MapPaneToolBar jToolBar;
38
39 /**
40 * Creates a new {@link MapView}. A {@link MapView} is a combination of a
41 * {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left,
42 * and some buttons floating over the {@link JMapPane}
43 */
44 public MapView(Window parentGui, MapPaneToolBar toolBar) {
45 super(new BorderLayout());
46 // Call initialize() by yourself afterwards.
47 // Needed because variables for the overwritten methods
48 // are not yet set.
49 getGeoMapPane().getMapPane().setWaitCursorComponent(parentGui);
50 if ( toolBar == null )
51 toolBar = new MapPaneToolBar(getMapPane());
52 jToolBar = toolBar;
53 }
54
55 /**
56 * Creates a new {@link MapView}. A {@link MapView} is a combination of a
57 * {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left,
58 * and some buttons floating over the {@link JMapPane}
59 */
60 public MapView(Window parentGui) {
61 this(parentGui, null);
62 }
63
64 /**
65 * Calls #getSidePanel() which can be overwritten.
66 *
67 * @see #adjustSizeOfGeoMapPane()
68 */
69 public void initialize() {
70 // horizontales SplitPane initialisieren
71 // SK 19.6.09: Removed because we are not using it. Probably a test.
72 // // Status-Zeile
73 // statusBar = new MapPaneStatusBar(getGeoMapPane()
74 // .getMapPane());
75 // statusBar.setBorder(BorderFactory.createCompoundBorder(BorderFactory
76 // .createLoweredBevelBorder(), BorderFactory.createEmptyBorder(2,
77 // 5, 2, 5)));
78 // this.add(statusBar, BorderLayout.SOUTH);
79
80 splitPane.setDividerLocation(-1);
81 splitPane.setDividerSize(5);
82
83 splitPane.setResizeWeight(0.0);
84 splitPane.add(getSidePane());
85
86 /***********************************************************************
87 * To the right side we now add a JPanel that consists of a toolbar and
88 * a gmp
89 */
90 JPanel newRight = new JPanel(new BorderLayout());
91 newRight.add(getToolBar(), BorderLayout.NORTH);
92 newRight.add(getGeoMapPane(), BorderLayout.CENTER);
93 splitPane.add(newRight);
94
95 this.add(splitPane, BorderLayout.CENTER);
96 }
97
98 /**
99 * Returns the tool bar which controls the active mouse actions on the map.
100 * @return
101 */
102 public MapPaneToolBar getToolBar() {
103 return jToolBar;
104 }
105
106 /**
107 * Returns the split pane which divides the layer list from the map panel.
108 */
109 public JSplitPane getSplitPane() {
110 return this.splitPane;
111 }
112
113
114 /**
115 * Sets the active tool.
116 * Simply calls {@link MapPaneToolBar#setSelectedTool(Integer)}.
117 * @param tool
118 * One of {@link #TOOL_INFO}, {@link #TOOL_PAN} .. constants
119 */
120 public void setSelectedTool(Integer tool) {
121 jToolBar.setSelectedTool(tool);
122 }
123
124 /**
125 * Sets whether a tool is activated or not.
126 * Simply calls {@link MapPaneToolBar#setButtonEnabled(int, boolean, boolean)}.
127 * @param tool tool ID
128 * @param enabled if {@code true} the tool becomes available
129 * @param hideOnDisable if {@code true} the button is also hidden if
130 * {@code enabled} is {@code false}
131 */
132 public void setToolEnabled(Integer tool, boolean enabled, boolean hideOnDisable) {
133 jToolBar.setButtonEnabled(tool,enabled,hideOnDisable);
134 }
135
136 /**
137 * Sets the activation for all tools.
138 * Simply calls {@link MapPaneToolBar#setAllToolsEnabled(boolean, boolean)}.
139 * @param enabled if {@code true} all tool becomes available
140 * @param hideOnDisable if {@code true} the buttons are also hidden if
141 * {@code enabled} is {@code false}
142 */
143 public void setAllToolsEnabled(boolean enabled, boolean hideOnDisable) {
144 jToolBar.setAllToolsEnabled(enabled, hideOnDisable);
145 }
146
147 /**
148 * Checks whether a tool is activated.
149 * Simply calls {@link MapPaneToolBar#isButtonEnabled(Integer)}.
150 * @param tool tool ID
151 * @return {@code false} if an unknown ID is specified
152 */
153 public boolean isToolEnabled(Integer tool) {
154 return jToolBar.isButtonEnabled(tool);
155 }
156
157 /**
158 * called by initialize() to fill the left of the XULUMapView Supposed to be
159 * overwritten by AtlasMapView or DesignMapView
160 */
161 public JComponent getSidePane() {
162 return new MapContextControlPane(getGeoMapPane().getMapPane(),
163 new ColorMapManager());
164 }
165
166 /**
167 * Liefert die Status-Zeile, in der die Koordinaten und Raster-Werte
168 * angezeigt werden.
169 */
170 public MapPaneStatusBar getStatusBar() {
171 return this.statusBar;
172 }
173
174 /**
175 * Liefert den Karten-Bereich der Komponente.
176 */
177 public final JMapPane getMapPane() {
178 return getGeoMapPane().getMapPane();
179 }
180
181 public GeoMapPane getGeoMapPane() {
182 return geoMapPane;
183 }
184
185 public int getSelectedTool() {
186 return jToolBar.getSelectedTool();
187 }
188
189 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26