/[schmitzm]/branches/1.0-gt2-2.6/src/skrueger/geotools/MapView.java
ViewVC logotype

Annotation of /branches/1.0-gt2-2.6/src/skrueger/geotools/MapView.java

Parent Directory Parent Directory | Revision Log Revision Log


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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26