/[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 2 by mojays, Tue Feb 24 22:43:52 2009 UTC revision 153 by alfonx, Sat Jun 20 12:48:24 2009 UTC
# Line 1  Line 1 
1  package skrueger.geotools;  package skrueger.geotools;
2    
3  import java.awt.BorderLayout;  import java.awt.BorderLayout;
 import java.awt.Dimension;  
4  import java.awt.Window;  import java.awt.Window;
 import java.awt.event.ActionEvent;  
 import java.util.ArrayList;  
 import java.util.LinkedList;  
5    
 import javax.swing.AbstractAction;  
6  import javax.swing.BorderFactory;  import javax.swing.BorderFactory;
 import javax.swing.ButtonGroup;  
 import javax.swing.ImageIcon;  
 import javax.swing.JButton;  
7  import javax.swing.JComponent;  import javax.swing.JComponent;
 import javax.swing.JLabel;  
8  import javax.swing.JPanel;  import javax.swing.JPanel;
9  import javax.swing.JSplitPane;  import javax.swing.JSplitPane;
 import javax.swing.JToggleButton;  
 import javax.swing.JToolBar;  
10    
11  import org.apache.log4j.Logger;  import org.apache.log4j.Logger;
12    
# Line 25  import schmitzm.geotools.gui.GeoMapPane; Line 14  import schmitzm.geotools.gui.GeoMapPane;
14  import schmitzm.geotools.gui.JMapPane;  import schmitzm.geotools.gui.JMapPane;
15  import schmitzm.geotools.gui.MapContextControlPane;  import schmitzm.geotools.gui.MapContextControlPane;
16  import schmitzm.geotools.gui.MapPaneStatusBar;  import schmitzm.geotools.gui.MapPaneStatusBar;
 import schmitzm.geotools.map.event.JMapPaneEvent;  
 import schmitzm.geotools.map.event.JMapPaneListener;  
 import schmitzm.geotools.map.event.MapAreaChangedEvent;  
17  import schmitzm.geotools.styling.ColorMapManager;  import schmitzm.geotools.styling.ColorMapManager;
 import schmitzm.swing.SwingUtil;  
   
 import com.vividsolutions.jts.geom.Envelope;  
18    
19  /**  /**
20   * Achtung! Dieser code ist verwuestet   * Achtung! Dieser code ist verwuestet
  */  
   
 /**  
21   * TODO DOKU und initialize schöner machen. SK   * TODO DOKU und initialize schöner machen. SK
22   */   */
23  public class MapView extends JPanel {  public class MapView extends JPanel {
24          private static final Logger LOGGER = Logger.getLogger(MapView.class);          private static final Logger LOGGER = Logger.getLogger(MapView.class);
25    
26          private final JSplitPane splitPane = new JSplitPane(          public final JSplitPane splitPane = new JSplitPane(
27                          JSplitPane.HORIZONTAL_SPLIT);                          JSplitPane.HORIZONTAL_SPLIT);
28    
29          protected MapPaneStatusBar statusBar = null;          protected MapPaneStatusBar statusBar = null;
# Line 54  public class MapView extends JPanel { Line 34  public class MapView extends JPanel {
34           */           */
35          protected final GeoMapPane geoMapPane = new GeoMapPane();          protected final GeoMapPane geoMapPane = new GeoMapPane();
36    
 //  
 //      /** This is the layered Pane that holds the buttons and maybe the flying logo * */  
 //      protected JLayeredPane layeredPane;  
   
         protected boolean zoomBackForwardButtonInAction;  
   
37          private MapPaneToolBar jToolBar;          private MapPaneToolBar jToolBar;
38    
39          /**          /**
# Line 67  public class MapView extends JPanel { Line 41  public class MapView extends JPanel {
41           * {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left,           * {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left,
42           * and some buttons floating over the {@link JMapPane}           * and some buttons floating over the {@link JMapPane}
43           */           */
44          public MapView(Window owner2, MapPaneToolBar toolBar) {          public MapView(Window parentGui, MapPaneToolBar toolBar) {
45                  super(new BorderLayout());                  super(new BorderLayout());
46                  // Call initialize() by yourself afterwards.                  // Call initialize() by yourself afterwards.
47                  // Needed because variables for the overwritten methods                  // Needed because variables for the overwritten methods
48                  // are not yet set.                  // are not yet set.
49                  getGeoMapPane().getMapPane().setWaitCursorComponent(owner2);                  getGeoMapPane().getMapPane().setWaitCursorComponent(parentGui);
50                  if ( toolBar == null )                  if ( toolBar == null )
51                    toolBar = new MapPaneToolBar(getMapPane());                    toolBar = new MapPaneToolBar(getMapPane());
52                  jToolBar = toolBar;                  jToolBar = toolBar;
# Line 83  public class MapView extends JPanel { Line 57  public class MapView extends JPanel {
57       * {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left,       * {@link GeoMapPane}, a {@link MapContextManagerInterface} on the left,
58       * and some buttons floating over the {@link JMapPane}       * and some buttons floating over the {@link JMapPane}
59       */       */
60      public MapView(Window owner2) {      public MapView(Window parentGui) {
61        this(owner2, null);        this(parentGui, null);
62      }      }
63    
     // /**  
         // * Nuetzlich wenn die Componente gedruckt wird. Dann wird der Hintergrund  
         // auf {@link Color#WHITE} gesetzt.zoomoutToggleButton  
         // *  
         // * @author <a href="mailto:[email protected]">Stefan Alfons  
         // Kr&uuml;ger</a>  
         // */  
         // @Override  
         // public void print(Graphics g) {  
         //                
         // // SK: Ich habe keine Ahnung mehr, was das soll... Ich habs mal  
         // auskommentiert.  
         //  
         // // wrap in try/finally so that we always restore the state  
         // try {  
         // panToggleButton.setVisible(false);  
         // zoominToggleButton.setVisible(false);  
         // zoomoutToggleButton.setVisible(false);  
         // infoToggleButton.setVisible(false);  
         //  
         // super.print(g);  
         // } finally {  
         // panToggleButton.setVisible(true);  
         // zoominToggleButton.setVisible(true);  
         // zoomoutToggleButton.setVisible(true);  
         // infoToggleButton.setVisible(true);  
         // }  
         // }  
   
64          /**          /**
65           * Calls #getSidePanel() which can be overwritten.           * Calls #getSidePanel() which can be overwritten.
66           *           *
# Line 123  public class MapView extends JPanel { Line 68  public class MapView extends JPanel {
68           */           */
69          public void initialize() {          public void initialize() {
70                  // horizontales SplitPane initialisieren                  // horizontales SplitPane initialisieren
71    // SK 19.6.09: Removed because we are not using it. Probably a test.
72    //              // Status-Zeile
73    //              statusBar = new MapPaneStatusBar(getGeoMapPane()
74    //                              .getMapPane());
75    //              statusBar.setBorder(BorderFactory.createCompoundBorder(BorderFactory
76    //                              .createLoweredBevelBorder(), BorderFactory.createEmptyBorder(2,
77    //                              5, 2, 5)));
78    //              this.add(statusBar, BorderLayout.SOUTH);
79    
80                  // Status-Zeile                  splitPane.setDividerLocation(-1);
                 statusBar = new MapPaneStatusBar(getGeoMapPane()  
                                 .getMapPane());  
                 statusBar.setBorder(BorderFactory.createCompoundBorder(BorderFactory  
                                 .createLoweredBevelBorder(), BorderFactory.createEmptyBorder(2,  
                                 5, 2, 5)));  
                 this.add(statusBar, BorderLayout.SOUTH);  
   
                 splitPane.setDividerLocation(0.4);  
81                  splitPane.setDividerSize(5);                  splitPane.setDividerSize(5);
82                    
83                    splitPane.setResizeWeight(0.0);
84                  splitPane.add(getSidePane());                  splitPane.add(getSidePane());
85    
86                  /***********************************************************************                  /***********************************************************************
# Line 146  public class MapView extends JPanel { Line 92  public class MapView extends JPanel {
92                  newRight.add(getGeoMapPane(), BorderLayout.CENTER);                  newRight.add(getGeoMapPane(), BorderLayout.CENTER);
93                  splitPane.add(newRight);                  splitPane.add(newRight);
94    
                 // gpSize = new Dimension(40,50);  
                 // getGeoMapPane().setSize(gpSize);  
   
                 // layeredPane = new JLayeredPane();  
                 // layeredPane.add(getGeoMapPane(), JLayeredPane.DEFAULT_LAYER);  
                 // createMapButtons(layeredPane);  
   
                 // //****************************************************************************  
                 // // The JLayeredPane doesn't manage the size of its layers.. we do it  
                 // // This listener will actually correct the size of the JLayeredPane  
                 // //****************************************************************************  
                 // splitPane.addPropertyChangeListener(new PropertyChangeListener() {  
                 //  
                 // public void propertyChange(final PropertyChangeEvent evt) {  
                 // final JSplitPane sp = (JSplitPane) evt.getSource();  
                 //  
                 // adjustSizeOfGeoMapPane();  
                 //  
                 // }  
                 //  
                 // });  
   
95                  this.add(splitPane, BorderLayout.CENTER);                  this.add(splitPane, BorderLayout.CENTER);
96          }          }
97    
# Line 186  public class MapView extends JPanel { Line 110  public class MapView extends JPanel {
110                  return this.splitPane;                  return this.splitPane;
111          }          }
112    
         //  
         // /**  
         // * Called by the listerner. Calculates the exact size of the {@link  
         // GeoMapPane} and sets it.  
         // */  
         // private void adjustSizeOfGeoMapPane() {  
         // final int newWidth = (int) (splitPane.getSize().getWidth()  
         // - splitPane.getComponent(1).getSize().getWidth()  
         // - splitPane.getComponent(0).getSize().getWidth())  
         // - 4;  
         // final int newHeight = (int) splitPane.getComponent(1).getSize()  
         // .getHeight();  
         //  
         // if (newWidth <= 20 )  
         // return;  
         //  
         // gpSize.setSize(newWidth, newHeight);  
         //  
         // getGeoMapPane().getMapPane().setWaitCursorDuringNextRepaint(true);  
         //  
         // getGeoMapPane().setSize( gpSize );  
         // // getGeoMapPane().refreshMap(); nicht nötig .. schön  
         //  
         // positionLayeredObjects();  
         // }  
 //  
 //      /**  
 //       * Adds the floating Map Contol Buttons to the {@link JLayeredPane}, with Z =  
 //       * 10  
 //       *  
 //       * @param lp  
 //       *            {@link JLayeredPane} that contains the {@link GeoMapPane}  
 //       */  
 //      private void createMapButtons(final JLayeredPane lp) {  
 //  
 //              final Integer zlayer = new Integer(10);  
 //  
 //              toggleButtonsList = new LinkedList<JToggleButton>();  
 //              toggleButtonsList.add(infoToggleButton);  
 //              toggleButtonsList.add(panToggleButton);  
 //              toggleButtonsList.add(zoominToggleButton);  
 //              toggleButtonsList.add(zoomoutToggleButton);  
 //  
 //  
 //              positionLayeredObjects();  
 //  
 //              final ButtonGroup bg = new ButtonGroup();  
 //              for (final JToggleButton b : toggleButtonsList) {  
 //                      // final FontMetrics fm = b.getFontMetrics( b.getFont() );  
 //                      // final int w = fm.stringWidth( b.getText() );  
 //  
 //                      // b.setBorder( BorderFactory.createRaisedBevelBorder() );  
 //                      b.setBorder(BorderFactory.createEmptyBorder());  
 //                      b.setSize(new Dimension(32, 32));  
 //                      bg.add(b);  
 //                      lp.add(b, zlayer);  
 //              }  
 //  
 //              zoomBackButton.setSize(32, 32);  
 //              zoomBackButton.setBorder(BorderFactory.createEmptyBorder());  
 //              lp.add(zoomBackButton, zlayer);  
 //  
 //              zoomForwardButton.setSize(32, 32);  
 //              zoomForwardButton.setBorder(BorderFactory.createEmptyBorder());  
 //              lp.add(zoomForwardButton, zlayer);  
 //      }  
   
 //      /**  
 //       * This method will update the  
 //       */  
 //      public void updateIconsForButtons() {  
 //              if (zoomoutToggleButton.isSelected())  
 //                      zoomoutToggleButton.setIcon(new ImageIcon(MapView.class  
 //                                      .getResource("zoom_out.png")));  
 //              else  
 //                      zoomoutToggleButton.setIcon(new ImageIcon(MapView.class  
 //                                      .getResource("zoom_out.png")));  
 //  
 //              if (zoominToggleButton.isSelected())  
 //                      zoominToggleButton.setIcon(new ImageIcon(MapView.class  
 //                                      .getResource("zoom_in.png")));  
 //              else  
 //                      zoominToggleButton.setIcon(new ImageIcon(MapView.class  
 //                                      .getResource("zoom_in.png")));  
 //  
 //              if (infoToggleButton.isSelected())  
 //                      infoToggleButton.setIcon(new ImageIcon(MapView.class  
 //                                      .getResource("info.png")));  
 //              else  
 //                      infoToggleButton.setIcon(new ImageIcon(MapView.class  
 //                                      .getResource("info_aus.png")));  
 //  
 //              if (panToggleButton.isSelected())  
 //                      panToggleButton.setIcon(new ImageIcon(MapView.class  
 //                                      .getResource("pan.png")));  
 //              else  
 //                      panToggleButton.setIcon(new ImageIcon(MapView.class  
 //                                      .getResource("pan_aus.png")));  
 //  
 //      }  
113    
114          /**          /**
115           * Sets the active tool.           * Sets the active tool.
# Line 329  public class MapView extends JPanel { Line 153  public class MapView extends JPanel {
153          public boolean isToolEnabled(Integer tool) {          public boolean isToolEnabled(Integer tool) {
154            return jToolBar.isButtonEnabled(tool);            return jToolBar.isButtonEnabled(tool);
155          }          }
 //  
 //      /**  
 //       * Positions the Map Control Buttons on top of the {@link GeoMapPane}  
 //       *  
 //       * @author <a href="mailto:[email protected]">Stefan Alfons Kr&uuml;ger</a>  
 //       *  
 //       */  
 //      protected void positionLayeredObjects() {  
 //  
 //              // Abstand zwischen den Buttons und Button zu Rand  
 //              final int gap = 10;  
 //  
 //              // 45 entspicht der breite des Grids/ der Gradanzeige  
 //              // TODO den wert aus der geomappane auslesen...  
 //              int x = GridPanel.VERT_WIDTH;  
 //  
 //              for (final JToggleButton b : toggleButtonsList) {  
 //                      x += gap;  
 //                      // final FontMetrics fm = b.getFontMetrics( b.getFont() );  
 //                      b.setLocation(x, 10);  
 //  
 //                      final int w = 32;  
 //                      x += w;  
 //                      // y += b.getWidth();  
 //              }  
 //  
 //              // Und noch die zwei ZoomBackup und ZoomForward Buttons  
 //              zoomBackButton.setLocation(x + 32 + gap, 10);  
 //              zoomForwardButton.setLocation(x + 64 + gap * 2, 10);  
 //      }  
156    
157          /**          /**
158           * called by initialize() to fill the left of the XULUMapView Supposed to be           * called by initialize() to fill the left of the XULUMapView Supposed to be
# Line 384  public class MapView extends JPanel { Line 178  public class MapView extends JPanel {
178                  return getGeoMapPane().getMapPane();                  return getGeoMapPane().getMapPane();
179          }          }
180    
         // /**  
         // * Liefert das in einem Layer dargestellte Objekt.  
         // *  
         // * @param layer  
         // * ein Layer  
         // */  
         // public Object getMapObject(final MapLayer layer) {  
         // // return layerObjects.get(layer);  
         // return null;  
         // }  
   
181          public GeoMapPane getGeoMapPane() {          public GeoMapPane getGeoMapPane() {
182                  return geoMapPane;                  return geoMapPane;
183          }          }

Legend:
Removed from v.2  
changed lines
  Added in v.153

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26