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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26