/[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 111 by alfonx, Tue May 12 23:33:14 2009 UTC revision 226 by alfonx, Thu Jul 16 07:37:43 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.Window;  import java.awt.Component;
5    
6  import javax.swing.BorderFactory;  import javax.swing.BorderFactory;
7  import javax.swing.JComponent;  import javax.swing.JComponent;
# Line 9  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;
# Line 17  import schmitzm.geotools.gui.MapPaneStat Line 19  import schmitzm.geotools.gui.MapPaneStat
19  import schmitzm.geotools.styling.ColorMapManager;  import schmitzm.geotools.styling.ColorMapManager;
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          protected final GeoMapPane geoMapPane = new GeoMapPane();  
38            /**
39             * SK: 21.6.09: ShapeFileRenderer is supposed to be about 5x faster on
40             * ShapeFiles. The ShapeFileRenderer falls back to the StreamingRenderer.
41             */
42            // Old code:
43            // protected final GeoMapPane geoMapPane = new
44            // GeoMapPane(null,null,null,null, new StreamingRenderer());
45            // New Code uses Streaming renderer.
46            protected final GeoMapPane geoMapPane = new GeoMapPane(null, null, null,
47                            null, new TransitionShapefileRenderer());
48    
49          private MapPaneToolBar jToolBar;          private MapPaneToolBar jToolBar;
50    
51          /**          /**
52           * 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
53           * {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left,           * {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left, and
54           * and some buttons floating over the {@link JMapPane}           * some buttons floating over the {@link JMapPane}
55           */           */
56          public MapView(Window parentGui, MapPaneToolBar toolBar) {          public MapView(Component parentGui, MapPaneToolBar toolBar) {
57                  super(new BorderLayout());                  super(new BorderLayout());
58                  // Call initialize() by yourself afterwards.                  // Call initialize() by yourself afterwards.
59                  // Needed because variables for the overwritten methods                  // Needed because variables for the overwritten methods
60                  // are not yet set.                  // are not yet set.
61                  getGeoMapPane().getMapPane().setWaitCursorComponent(parentGui);                  getGeoMapPane().getMapPane().setWaitCursorComponent(parentGui);
62                  if ( toolBar == null )                  if (toolBar == null)
63                    toolBar = new MapPaneToolBar(getMapPane());                          toolBar = new MapPaneToolBar(getMapPane());
64                  jToolBar = toolBar;                  jToolBar = toolBar;
65          }          }
   
     /**  
      * Creates a new {@link MapView}. A {@link MapView} is a combination of a  
      * {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left,  
      * and some buttons floating over the {@link JMapPane}  
      */  
     public MapView(Window parentGui) {  
       this(parentGui, null);  
     }  
66    
67          /**          /**
68           * Calls #getSidePanel() which can be overwritten.           * Creates a new {@link MapView}. A {@link MapView} is a combination of a
69             * {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left, and
70             * some buttons floating over the {@link JMapPane}
71             */
72            public MapView(Component parentGui) {
73                    this(parentGui, null);
74            }
75    
76            /**
77             * This routine creates the main components of the GUI: The left Side and
78             * the map on the right side.<br/>
79             * Calls #getSidePanel() which can be overwritten (call super!).<br/>
80             *
81             * This method initialized the variables {@link #statusBar} and
82             * {@link #splitPane}
83           *           *
84           * @see #adjustSizeOfGeoMapPane()           * @see #adjustSizeOfGeoMapPane()
85           */           */
86          public void initialize() {          public void initialize() {
87                  // horizontales SplitPane initialisieren                  // horizontales SplitPane initialisieren
88    
89                  // Status-Zeile                  // Status-Line to show Coordinates and Rastervalues.
90                  statusBar = new MapPaneStatusBar(getGeoMapPane()                  statusBar = new MapPaneStatusBar(getGeoMapPane().getMapPane());
                                 .getMapPane());  
91                  statusBar.setBorder(BorderFactory.createCompoundBorder(BorderFactory                  statusBar.setBorder(BorderFactory.createCompoundBorder(BorderFactory
92                                  .createLoweredBevelBorder(), BorderFactory.createEmptyBorder(2,                                  .createLoweredBevelBorder(), BorderFactory.createEmptyBorder(2,
93                                  5, 2, 5)));                                  5, 2, 5)));
94                  this.add(statusBar, BorderLayout.SOUTH);                  this.add(statusBar, BorderLayout.SOUTH);
95    
96                  splitPane.setDividerLocation(0.4);                  /**
97                  splitPane.setDividerSize(5);                   * The layout of the split pane can be configured in the atlas.
98                     * setDividerLocation(-1); has no effect here because the component is
99                     * not visible yet.
100                     */
101                    getSplitPane().setDividerSize(5);
102    
103                  splitPane.add(getSidePane());                  getSplitPane().setResizeWeight(0.0);
104                    getSplitPane().add(getSidePane());
105    
106                  /***********************************************************************                  /***********************************************************************
107                   * 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 110  public class MapView extends JPanel {
110                  JPanel newRight = new JPanel(new BorderLayout());                  JPanel newRight = new JPanel(new BorderLayout());
111                  newRight.add(getToolBar(), BorderLayout.NORTH);                  newRight.add(getToolBar(), BorderLayout.NORTH);
112                  newRight.add(getGeoMapPane(), BorderLayout.CENTER);                  newRight.add(getGeoMapPane(), BorderLayout.CENTER);
113                  splitPane.add(newRight);                  getSplitPane().add(newRight);
114    
115                  this.add(splitPane, BorderLayout.CENTER);                  this.add(getSplitPane(), BorderLayout.CENTER);
116          }          }
117    
118          /**          /**
119           * 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.
120             *
121           * @return           * @return
122           */           */
123          public MapPaneToolBar getToolBar() {          public MapPaneToolBar getToolBar() {
124            return jToolBar;                  return jToolBar;
125          }          }
126    
127          /**          /**
128           * 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.
129           */           */
130          public JSplitPane getSplitPane() {          public JSplitPane getSplitPane() {
131                  return this.splitPane;                  return splitPane;
132          }          }
133    
   
134          /**          /**
135           * Sets the active tool.           * Sets the active tool. Simply calls
136           * Simply calls {@link MapPaneToolBar#setSelectedTool(Integer)}.           * {@link MapPaneToolBar#setSelectedTool(Integer)}.
137             *
138           * @param tool           * @param tool
139           *            One of {@link #TOOL_INFO}, {@link #TOOL_PAN} .. constants           *            One of {@link #TOOL_INFO}, {@link #TOOL_PAN} .. constants
140           */           */
141          public void setSelectedTool(Integer tool) {          public void setSelectedTool(Integer tool) {
142            jToolBar.setSelectedTool(tool);                  jToolBar.setSelectedTool(tool);
143          }          }
144            
145      /**          /**
146       * Sets whether a tool is activated or not.           * Sets whether a tool is activated or not. Simply calls
147       * Simply calls {@link MapPaneToolBar#setButtonEnabled(int, boolean, boolean)}.           * {@link MapPaneToolBar#setButtonEnabled(int, boolean, boolean)}.
148       * @param tool tool ID           *
149       * @param enabled if {@code true} the tool becomes available           * @param tool
150       * @param hideOnDisable if {@code true} the button is also hidden if           *            tool ID
151       *                      {@code enabled} is {@code false}           * @param enabled
152       */           *            if {@code true} the tool becomes available
153          public void setToolEnabled(Integer tool, boolean enabled, boolean hideOnDisable) {           * @param hideOnDisable
154             jToolBar.setButtonEnabled(tool,enabled,hideOnDisable);           *            if {@code true} the button is also hidden if {@code enabled}
155          }           *            is {@code false}
156             */
157      /**          public void setToolEnabled(Integer tool, boolean enabled,
158       * Sets the activation for all tools.                          boolean hideOnDisable) {
159       * Simply calls {@link MapPaneToolBar#setAllToolsEnabled(boolean, boolean)}.                  jToolBar.setButtonEnabled(tool, enabled, hideOnDisable);
160       * @param enabled if {@code true} all tool becomes available          }
161       * @param hideOnDisable if {@code true} the buttons are also hidden if  
162       *                      {@code enabled} is {@code false}          /**
163       */           * Sets the activation for all tools. Simply calls
164      public void setAllToolsEnabled(boolean enabled, boolean hideOnDisable) {           * {@link MapPaneToolBar#setAllToolsEnabled(boolean, boolean)}.
165        jToolBar.setAllToolsEnabled(enabled, hideOnDisable);           *
166      }             * @param enabled
167             *            if {@code true} all tool becomes available
168      /**           * @param hideOnDisable
169           * Checks whether a tool is activated.           *            if {@code true} the buttons are also hidden if {@code enabled}
170       * Simply calls {@link MapPaneToolBar#isButtonEnabled(Integer)}.           *            is {@code false}
171           * @param tool tool ID           */
172            public void setAllToolsEnabled(boolean enabled, boolean hideOnDisable) {
173                    jToolBar.setAllToolsEnabled(enabled, hideOnDisable);
174            }
175    
176            /**
177             * Checks whether a tool is activated. Simply calls
178             * {@link MapPaneToolBar#isButtonEnabled(Integer)}.
179             *
180             * @param tool
181             *            tool ID
182           * @return {@code false} if an unknown ID is specified           * @return {@code false} if an unknown ID is specified
183           */           */
184          public boolean isToolEnabled(Integer tool) {          public boolean isToolEnabled(Integer tool) {
185            return jToolBar.isButtonEnabled(tool);                  return jToolBar.isButtonEnabled(tool);
186          }          }
187    
188          /**          /**
# Line 167  public class MapView extends JPanel { Line 196  public class MapView extends JPanel {
196    
197          /**          /**
198           * Liefert die Status-Zeile, in der die Koordinaten und Raster-Werte           * Liefert die Status-Zeile, in der die Koordinaten und Raster-Werte
199           * angezeigt werden.           * angezeigt werden.
200           */           */
201          public MapPaneStatusBar getStatusBar() {          public MapPaneStatusBar getStatusBar() {
202            return this.statusBar;                  return this.statusBar;
203          }          }
204            
205          /**          /**
206           * Liefert den Karten-Bereich der Komponente.           * Liefert den Karten-Bereich der Komponente.
207           */           */

Legend:
Removed from v.111  
changed lines
  Added in v.226

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26