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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26