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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 48 by alfonx, Fri Apr 17 12:49:33 2009 UTC revision 227 by alfonx, Fri Jul 17 07:25:29 2009 UTC
# Line 1  Line 1 
1  package skrueger.geotools;  package skrueger.geotools;
2    
3  import java.awt.BorderLayout;  import java.awt.BorderLayout;
4    import java.awt.Component;
5    
6  import javax.swing.BorderFactory;  import javax.swing.BorderFactory;
7  import javax.swing.JComponent;  import javax.swing.JComponent;
# Line 8  import javax.swing.JPanel; Line 9  import javax.swing.JPanel;
9  import javax.swing.JSplitPane;  import javax.swing.JSplitPane;
10    
11  import org.apache.log4j.Logger;  import org.apache.log4j.Logger;
12    import org.geotools.renderer.lite.StreamingRenderer;
13    import org.geotools.renderer.shape.TransitionShapefileRenderer;
14    
15  import schmitzm.geotools.gui.GeoMapPane;  import schmitzm.geotools.gui.GeoMapPane;
16  import schmitzm.geotools.gui.JMapPane;  import schmitzm.geotools.gui.JMapPane;
17  import schmitzm.geotools.gui.MapContextControlPane;  import schmitzm.geotools.gui.MapContextControlPane;
18  import schmitzm.geotools.gui.MapPaneStatusBar;  import schmitzm.geotools.gui.MapPaneStatusBar;
19  import schmitzm.geotools.styling.ColorMapManager;  import schmitzm.geotools.styling.ColorMapManager;
 import schmitzm.swing.SwingUtil;  
20    
21  /**  /**
22   * Achtung! Dieser code ist verwuestet   * Achtung! Dieser code ist verwuestet TODO DOKU und initialize schöner machen.
23   */   * SK
   
 /**  
  * TODO DOKU und initialize schöner machen. SK  
24   */   */
25  public class MapView extends JPanel {  public class MapView extends JPanel {
26          private static final Logger LOGGER = Logger.getLogger(MapView.class);          private static final Logger LOGGER = Logger.getLogger(MapView.class);
# Line 30  public class MapView extends JPanel { Line 29  public class MapView extends JPanel {
29                          JSplitPane.HORIZONTAL_SPLIT);                          JSplitPane.HORIZONTAL_SPLIT);
30    
31          protected MapPaneStatusBar statusBar = null;          protected MapPaneStatusBar statusBar = null;
32            
33          /**          /**
34           * Komponente, in der die Karten, der Massstab und das Koordinaten-Raster           * Komponente, in der die Karten, der Massstab und das Koordinaten-Raster
35           * dargestellt werden           * dargestellt werden.
36           */           */
37    
38          protected final GeoMapPane geoMapPane = new GeoMapPane();          protected final GeoMapPane geoMapPane = new GeoMapPane();
39    
40          private MapPaneToolBar jToolBar;          private MapPaneToolBar jToolBar;
41    
42          /**          /**
43           * Creates a new {@link MapView}. A {@link MapView} is a combination of a           * Creates a new {@link MapView}. A {@link MapView} is a combination of a
44           * {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left,           * {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left, and
45           * and some buttons floating over the {@link JMapPane}           * some buttons floating over the {@link JMapPane}
46           */           */
47          public MapView(MapPaneToolBar toolBar) {          public MapView(Component parentGui, MapPaneToolBar toolBar) {
48                  super(new BorderLayout());                  super(new BorderLayout());
49                  // Call initialize() by yourself afterwards.                  // Call initialize() by yourself afterwards.
50                  // Needed because variables for the overwritten methods                  // Needed because variables for the overwritten methods
51                  // are not yet set.                  // are not yet set.
52                  getGeoMapPane().getMapPane().setWaitCursorComponent(SwingUtil.getParentWindow(this));                  getGeoMapPane().getMapPane().setWaitCursorComponent(parentGui);
53                  if ( toolBar == null )                  if (toolBar == null)
54                    toolBar = new MapPaneToolBar(getMapPane());                          toolBar = new MapPaneToolBar(getMapPane());
55                  jToolBar = toolBar;                  jToolBar = toolBar;
56          }          }
57    
58      /**          /**
59       * Creates a new {@link MapView}. A {@link MapView} is a combination of a           * Creates a new {@link MapView}. A {@link MapView} is a combination of a
60       * {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left,           * {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left, and
61       * and some buttons floating over the {@link JMapPane}           * some buttons floating over the {@link JMapPane}
62       */           */
63      public MapView() {          public MapView(Component parentGui) {
64        this(null);                  this(parentGui, null);
65      }          }
66    
67          /**          /**
68           * Calls #getSidePanel() which can be overwritten.           * This routine creates the main components of the GUI: The left Side and
69             * the map on the right side.<br/>
70             * Calls #getSidePanel() which can be overwritten (call super!).<br/>
71             *
72             * This method initialized the variables {@link #statusBar} and
73             * {@link #splitPane}
74           *           *
75           * @see #adjustSizeOfGeoMapPane()           * @see #adjustSizeOfGeoMapPane()
76           */           */
77          public void initialize() {          public void initialize() {
78                  // horizontales SplitPane initialisieren                  // horizontales SplitPane initialisieren
79    
80                  // Status-Zeile                  // Status-Line to show Coordinates and Rastervalues.
81                  statusBar = new MapPaneStatusBar(getGeoMapPane()                  statusBar = new MapPaneStatusBar(getGeoMapPane().getMapPane());
                                 .getMapPane());  
82                  statusBar.setBorder(BorderFactory.createCompoundBorder(BorderFactory                  statusBar.setBorder(BorderFactory.createCompoundBorder(BorderFactory
83                                  .createLoweredBevelBorder(), BorderFactory.createEmptyBorder(2,                                  .createLoweredBevelBorder(), BorderFactory.createEmptyBorder(2,
84                                  5, 2, 5)));                                  5, 2, 5)));
85                  this.add(statusBar, BorderLayout.SOUTH);                  this.add(statusBar, BorderLayout.SOUTH);
86    
87                  splitPane.setDividerLocation(0.4);                  /**
88                  splitPane.setDividerSize(5);                   * The layout of the split pane can be configured in the atlas.
89                     * setDividerLocation(-1); has no effect here because the component is
90                     * not visible yet.
91                     */
92                    getSplitPane().setDividerSize(5);
93    
94                  splitPane.add(getSidePane());                  getSplitPane().setResizeWeight(0.0);
95                    getSplitPane().add(getSidePane());
96    
97                  /***********************************************************************                  /***********************************************************************
98                   * To the right side we now add a JPanel that consists of a toolbar and                   * To the right side we now add a JPanel that consists of a toolbar and
# Line 92  public class MapView extends JPanel { Line 101  public class MapView extends JPanel {
101                  JPanel newRight = new JPanel(new BorderLayout());                  JPanel newRight = new JPanel(new BorderLayout());
102                  newRight.add(getToolBar(), BorderLayout.NORTH);                  newRight.add(getToolBar(), BorderLayout.NORTH);
103                  newRight.add(getGeoMapPane(), BorderLayout.CENTER);                  newRight.add(getGeoMapPane(), BorderLayout.CENTER);
104                  splitPane.add(newRight);                  getSplitPane().add(newRight);
105    
106                  this.add(splitPane, BorderLayout.CENTER);                  this.add(getSplitPane(), BorderLayout.CENTER);
107          }          }
108    
109          /**          /**
110           * Returns the tool bar which controls the active mouse actions on the map.           * Returns the tool bar which controls the active mouse actions on the map.
111             *
112           * @return           * @return
113           */           */
114          public MapPaneToolBar getToolBar() {          public MapPaneToolBar getToolBar() {
115            return jToolBar;                  return jToolBar;
116          }          }
117    
118          /**          /**
119           * Returns the split pane which divides the layer list from the map panel.           * Returns the split pane which divides the layer list from the map panel.
120           */           */
121          public JSplitPane getSplitPane() {          public JSplitPane getSplitPane() {
122                  return this.splitPane;                  return splitPane;
123          }          }
124    
   
125          /**          /**
126           * Sets the active tool.           * Sets the active tool. Simply calls
127           * Simply calls {@link MapPaneToolBar#setSelectedTool(Integer)}.           * {@link MapPaneToolBar#setSelectedTool(Integer)}.
128             *
129           * @param tool           * @param tool
130           *            One of {@link #TOOL_INFO}, {@link #TOOL_PAN} .. constants           *            One of {@link #TOOL_INFO}, {@link #TOOL_PAN} .. constants
131           */           */
132          public void setSelectedTool(Integer tool) {          public void setSelectedTool(Integer tool) {
133            jToolBar.setSelectedTool(tool);                  jToolBar.setSelectedTool(tool);
134          }          }
135            
136      /**          /**
137       * Sets whether a tool is activated or not.           * Sets whether a tool is activated or not. Simply calls
138       * Simply calls {@link MapPaneToolBar#setButtonEnabled(int, boolean, boolean)}.           * {@link MapPaneToolBar#setButtonEnabled(int, boolean, boolean)}.
139       * @param tool tool ID           *
140       * @param enabled if {@code true} the tool becomes available           * @param tool
141       * @param hideOnDisable if {@code true} the button is also hidden if           *            tool ID
142       *                      {@code enabled} is {@code false}           * @param enabled
143       */           *            if {@code true} the tool becomes available
144          public void setToolEnabled(Integer tool, boolean enabled, boolean hideOnDisable) {           * @param hideOnDisable
145             jToolBar.setButtonEnabled(tool,enabled,hideOnDisable);           *            if {@code true} the button is also hidden if {@code enabled}
146          }           *            is {@code false}
147             */
148      /**          public void setToolEnabled(Integer tool, boolean enabled,
149       * Sets the activation for all tools.                          boolean hideOnDisable) {
150       * Simply calls {@link MapPaneToolBar#setAllToolsEnabled(boolean, boolean)}.                  jToolBar.setButtonEnabled(tool, enabled, hideOnDisable);
151       * @param enabled if {@code true} all tool becomes available          }
152       * @param hideOnDisable if {@code true} the buttons are also hidden if  
153       *                      {@code enabled} is {@code false}          /**
154       */           * Sets the activation for all tools. Simply calls
155      public void setAllToolsEnabled(boolean enabled, boolean hideOnDisable) {           * {@link MapPaneToolBar#setAllToolsEnabled(boolean, boolean)}.
156        jToolBar.setAllToolsEnabled(enabled, hideOnDisable);           *
157      }             * @param enabled
158             *            if {@code true} all tool becomes available
159      /**           * @param hideOnDisable
160           * Checks whether a tool is activated.           *            if {@code true} the buttons are also hidden if {@code enabled}
161       * Simply calls {@link MapPaneToolBar#isButtonEnabled(Integer)}.           *            is {@code false}
162           * @param tool tool ID           */
163            public void setAllToolsEnabled(boolean enabled, boolean hideOnDisable) {
164                    jToolBar.setAllToolsEnabled(enabled, hideOnDisable);
165            }
166    
167            /**
168             * Checks whether a tool is activated. Simply calls
169             * {@link MapPaneToolBar#isButtonEnabled(Integer)}.
170             *
171             * @param tool
172             *            tool ID
173           * @return {@code false} if an unknown ID is specified           * @return {@code false} if an unknown ID is specified
174           */           */
175          public boolean isToolEnabled(Integer tool) {          public boolean isToolEnabled(Integer tool) {
176            return jToolBar.isButtonEnabled(tool);                  return jToolBar.isButtonEnabled(tool);
177          }          }
178    
179          /**          /**
# Line 167  public class MapView extends JPanel { Line 187  public class MapView extends JPanel {
187    
188          /**          /**
189           * Liefert die Status-Zeile, in der die Koordinaten und Raster-Werte           * Liefert die Status-Zeile, in der die Koordinaten und Raster-Werte
190           * angezeigt werden.           * angezeigt werden.
191           */           */
192          public MapPaneStatusBar getStatusBar() {          public MapPaneStatusBar getStatusBar() {
193            return this.statusBar;                  return this.statusBar;
194          }          }
195            
196          /**          /**
197           * Liefert den Karten-Bereich der Komponente.           * Liefert den Karten-Bereich der Komponente.
198           */           */

Legend:
Removed from v.48  
changed lines
  Added in v.227

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26