/[schmitzm]/branches/2.0-RC2/src/skrueger/geotools/MapView.java
ViewVC logotype

Annotation of /branches/2.0-RC2/src/skrueger/geotools/MapView.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 227 - (hide annotations)
Fri Jul 17 07:25:29 2009 UTC (15 years, 7 months ago) by alfonx
Original Path: trunk/src/skrueger/geotools/MapView.java
File size: 6268 byte(s)
* AV-Revert: Had to replace TransitionalShapefileRenderer again, because AR reported reproducable hangs on many Windows machines. 

* GP-Feature: Created an Export-Wizard! Check it out.. it's fun!

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26