/[schmitzm]/trunk/src/skrueger/geotools/MapView.java
ViewVC logotype

Annotation of /trunk/src/skrueger/geotools/MapView.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 226 - (hide annotations)
Thu Jul 16 07:37:43 2009 UTC (15 years, 7 months ago) by alfonx
File size: 6656 byte(s)
* Created a new ManageChartsForMapDialog that allows to manage charts and define which chart is visible in which map. Besides, that saving the ChartSTyles is not implemented, you can now basically define and use the charts.

* Created a TransitionShapefileRenderer in schmitzm. It's a copy (extend was not possible) of a normal ShapefileRenderer class, but extended by a hack to fall back to the normal StreamingRenderer if a FeatureOperationTreeFilter is applied to a MapLayer. 
* I have set this TransitionShapefileRenderer as default in JMapPane & Co.
* It's called "transition", because we will remove it as soon as we moved to GT 2.6 and switched the filters to eCQL.

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 154 /**
39     * SK: 21.6.09: ShapeFileRenderer is supposed to be about 5x faster on
40 alfonx 165 * ShapeFiles. The ShapeFileRenderer falls back to the StreamingRenderer.
41 alfonx 154 */
42     // Old code:
43 alfonx 165 // protected final GeoMapPane geoMapPane = new
44     // GeoMapPane(null,null,null,null, new StreamingRenderer());
45 alfonx 154 // New Code uses Streaming renderer.
46 alfonx 165 protected final GeoMapPane geoMapPane = new GeoMapPane(null, null, null,
47 alfonx 226 null, new TransitionShapefileRenderer());
48 mojays 2
49     private MapPaneToolBar jToolBar;
50    
51     /**
52     * Creates a new {@link MapView}. A {@link MapView} is a combination of a
53 alfonx 165 * {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left, and
54     * some buttons floating over the {@link JMapPane}
55 mojays 2 */
56 alfonx 226 public MapView(Component 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 alfonx 165 if (toolBar == null)
63     toolBar = new MapPaneToolBar(getMapPane());
64     jToolBar = toolBar;
65 mojays 2 }
66    
67 alfonx 165 /**
68     * Creates a new {@link MapView}. A {@link MapView} is a combination of a
69     * {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left, and
70     * some buttons floating over the {@link JMapPane}
71     */
72 alfonx 226 public MapView(Component parentGui) {
73 alfonx 165 this(parentGui, null);
74     }
75 mojays 2
76     /**
77 alfonx 165 * This routine creates the main components of the GUI: The left Side and
78     * the map on the right side.<br/>
79 alfonx 164 * Calls #getSidePanel() which can be overwritten (call super!).<br/>
80 mojays 2 *
81 alfonx 165 * This method initialized the variables {@link #statusBar} and
82     * {@link #splitPane}
83 alfonx 164 *
84 mojays 2 * @see #adjustSizeOfGeoMapPane()
85     */
86     public void initialize() {
87     // horizontales SplitPane initialisieren
88 alfonx 165
89 alfonx 154 // Status-Line to show Coordinates and Rastervalues.
90 alfonx 165 statusBar = new MapPaneStatusBar(getGeoMapPane().getMapPane());
91 alfonx 154 statusBar.setBorder(BorderFactory.createCompoundBorder(BorderFactory
92     .createLoweredBevelBorder(), BorderFactory.createEmptyBorder(2,
93     5, 2, 5)));
94     this.add(statusBar, BorderLayout.SOUTH);
95 mojays 2
96 alfonx 164 /**
97 alfonx 165 * The layout of the split pane can be configured in the atlas.
98     * setDividerLocation(-1); has no effect here because the component is
99     * not visible yet.
100 alfonx 164 */
101     getSplitPane().setDividerSize(5);
102 alfonx 165
103 alfonx 164 getSplitPane().setResizeWeight(0.0);
104     getSplitPane().add(getSidePane());
105 mojays 2
106     /***********************************************************************
107     * To the right side we now add a JPanel that consists of a toolbar and
108     * a gmp
109     */
110     JPanel newRight = new JPanel(new BorderLayout());
111     newRight.add(getToolBar(), BorderLayout.NORTH);
112     newRight.add(getGeoMapPane(), BorderLayout.CENTER);
113 alfonx 164 getSplitPane().add(newRight);
114 mojays 2
115 alfonx 164 this.add(getSplitPane(), BorderLayout.CENTER);
116 mojays 2 }
117    
118     /**
119     * Returns the tool bar which controls the active mouse actions on the map.
120 alfonx 165 *
121 mojays 2 * @return
122     */
123     public MapPaneToolBar getToolBar() {
124 alfonx 165 return jToolBar;
125 mojays 2 }
126    
127     /**
128     * Returns the split pane which divides the layer list from the map panel.
129     */
130     public JSplitPane getSplitPane() {
131 alfonx 164 return splitPane;
132 mojays 2 }
133    
134     /**
135 alfonx 165 * Sets the active tool. Simply calls
136     * {@link MapPaneToolBar#setSelectedTool(Integer)}.
137     *
138 mojays 2 * @param tool
139     * One of {@link #TOOL_INFO}, {@link #TOOL_PAN} .. constants
140     */
141     public void setSelectedTool(Integer tool) {
142 alfonx 165 jToolBar.setSelectedTool(tool);
143 mojays 2 }
144 alfonx 165
145     /**
146     * Sets whether a tool is activated or not. Simply calls
147     * {@link MapPaneToolBar#setButtonEnabled(int, boolean, boolean)}.
148     *
149     * @param tool
150     * tool ID
151     * @param enabled
152     * if {@code true} the tool becomes available
153     * @param hideOnDisable
154     * if {@code true} the button is also hidden if {@code enabled}
155     * is {@code false}
156     */
157     public void setToolEnabled(Integer tool, boolean enabled,
158     boolean hideOnDisable) {
159     jToolBar.setButtonEnabled(tool, enabled, hideOnDisable);
160 mojays 2 }
161    
162 alfonx 165 /**
163     * Sets the activation for all tools. Simply calls
164     * {@link MapPaneToolBar#setAllToolsEnabled(boolean, boolean)}.
165     *
166     * @param enabled
167     * if {@code true} all tool becomes available
168     * @param hideOnDisable
169     * if {@code true} the buttons are also hidden if {@code enabled}
170     * is {@code false}
171     */
172     public void setAllToolsEnabled(boolean enabled, boolean hideOnDisable) {
173     jToolBar.setAllToolsEnabled(enabled, hideOnDisable);
174     }
175 mojays 2
176 alfonx 165 /**
177     * Checks whether a tool is activated. Simply calls
178     * {@link MapPaneToolBar#isButtonEnabled(Integer)}.
179     *
180     * @param tool
181     * tool ID
182 mojays 2 * @return {@code false} if an unknown ID is specified
183     */
184     public boolean isToolEnabled(Integer tool) {
185 alfonx 165 return jToolBar.isButtonEnabled(tool);
186 mojays 2 }
187    
188     /**
189     * called by initialize() to fill the left of the XULUMapView Supposed to be
190     * overwritten by AtlasMapView or DesignMapView
191     */
192     public JComponent getSidePane() {
193     return new MapContextControlPane(getGeoMapPane().getMapPane(),
194     new ColorMapManager());
195     }
196    
197     /**
198     * Liefert die Status-Zeile, in der die Koordinaten und Raster-Werte
199 alfonx 165 * angezeigt werden.
200 mojays 2 */
201     public MapPaneStatusBar getStatusBar() {
202 alfonx 165 return this.statusBar;
203 mojays 2 }
204 alfonx 165
205 mojays 2 /**
206     * Liefert den Karten-Bereich der Komponente.
207     */
208     public final JMapPane getMapPane() {
209     return getGeoMapPane().getMapPane();
210     }
211    
212     public GeoMapPane getGeoMapPane() {
213     return geoMapPane;
214     }
215    
216     public int getSelectedTool() {
217     return jToolBar.getSelectedTool();
218     }
219    
220     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26