/[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 158 - (show annotations)
Mon Jun 22 13:45:32 2009 UTC (15 years, 8 months ago) by alfonx
File size: 6234 byte(s)
* Changed the Selection-Stlying-Filter: It's now based on GeoTools Filters! The new Filter() { .. } approach is not recommended in GeoTools and will probably produce other problems also. Because the ShapeFileRenderer is optimizing the filters (thats why it's 10 times faster), its doing some stuff that only works on GeoTools Filters:

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26