Ignore:
Timestamp:
2005-10-03T04:18:02+02:00 (19 years ago)
Author:
imi
Message:
  • added Selection Dialog
  • added support for graphic engines with a better default engine
  • reorganized data classes with back references
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/gui/MapFrame.java

    r7 r8  
    33import java.awt.BorderLayout;
    44import java.awt.Component;
    5 import java.awt.event.ActionEvent;
    6 import java.awt.event.ActionListener;
    7 import java.awt.event.KeyEvent;
     5import java.awt.event.WindowAdapter;
     6import java.awt.event.WindowEvent;
     7import java.beans.PropertyChangeEvent;
     8import java.beans.PropertyChangeListener;
    89
    9 import javax.swing.AbstractAction;
    1010import javax.swing.AbstractButton;
    11 import javax.swing.BorderFactory;
    12 import javax.swing.Box;
    13 import javax.swing.BoxLayout;
    1411import javax.swing.ButtonGroup;
    15 import javax.swing.ImageIcon;
    16 import javax.swing.JComboBox;
    17 import javax.swing.JComponent;
    18 import javax.swing.JDialog;
    19 import javax.swing.JLabel;
    2012import javax.swing.JPanel;
    2113import javax.swing.JToggleButton;
    2214import javax.swing.JToolBar;
    23 import javax.swing.border.Border;
    24 import javax.swing.event.ChangeEvent;
    25 import javax.swing.event.ChangeListener;
    2615
    2716import org.openstreetmap.josm.actions.mapmode.AddLineSegmentAction;
     
    3524import org.openstreetmap.josm.actions.mapmode.SelectionAction;
    3625import org.openstreetmap.josm.actions.mapmode.ZoomAction;
    37 import org.openstreetmap.josm.data.Preferences;
    3826import org.openstreetmap.josm.data.osm.DataSet;
    39 import org.openstreetmap.josm.data.projection.Projection;
     27import org.openstreetmap.josm.gui.dialogs.PropertiesDialog;
     28import org.openstreetmap.josm.gui.dialogs.SelectionListDialog;
    4029
    4130/**
     
    4635 */
    4736public class MapFrame extends JPanel {
    48 
    49         /**
    50          * Open the properties page
    51          * @author imi
    52          */
    53         public class PropertiesAction extends AbstractAction {
    54                 private JDialog dlg;
    55                 public PropertiesAction() {
    56                         super("Properties", new ImageIcon("images/properties.png"));
    57                         putValue(MNEMONIC_KEY, KeyEvent.VK_P);
    58                 }
    59                 public void actionPerformed(ActionEvent e) {
    60                         if (dlg != null) {
    61                                 dlg.setVisible(true);
    62                                 dlg.requestFocus();
    63                                 return;
    64                         }
    65                         dlg = new JDialog(Main.main, "Properties of "+Main.main.getNameOfLoadedMapFrame(), false);
    66                         final Border panelBorder = BorderFactory.createEmptyBorder(5,0,0,0);
    67                         Box panel = Box.createVerticalBox();
    68 
    69                         // making an array of all projections and the current one within
    70                         Projection[] allProjections = Preferences.allProjections.clone();
    71                         for (int i = 0; i < allProjections.length; ++i)
    72                                 if (allProjections[i].getClass() == mapView.getProjection().getClass())
    73                                         allProjections[i] = mapView.getProjection();
    74                        
    75                         // projection
    76                         Box projectionPanel = Box.createHorizontalBox();
    77                         projectionPanel.setBorder(panelBorder);
    78                         projectionPanel.add(new JLabel("Projection"));
    79                         final JComboBox projectionCombo = new JComboBox(allProjections);
    80                         projectionPanel.add(projectionCombo);
    81                         panel.add(projectionPanel);
    82                         final JPanel configurationPanel = new JPanel();
    83                         configurationPanel.setLayout(new BoxLayout(configurationPanel, BoxLayout.X_AXIS));
    84                        
    85                         // projections details
    86                         projectionCombo.addActionListener(new ActionListener(){
    87                                 public void actionPerformed(ActionEvent e) {
    88                                         configurationPanel.removeAll();
    89                                         mapView.setProjection((Projection)projectionCombo.getSelectedItem());
    90                                         JComponent panel = mapView.getProjection().getConfigurationPanel();
    91                                         if (panel != null) {
    92                                                 panel.setBorder(panelBorder);
    93                                                 configurationPanel.add(panel);
    94                                         }
    95                                         dlg.pack();
    96                                 }
    97                         });
    98                         panel.add(configurationPanel);
    99                         projectionCombo.setSelectedItem(mapView.getProjection());
    100                        
    101                         panel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
    102                         dlg.setContentPane(panel);
    103                         dlg.pack();
    104                         dlg.setResizable(false);
    105                         dlg.setVisible(true);
    106                 }
    107         }
    10837
    10938        /**
     
    15584                autoScaleButton.setText(null);
    15685                autoScaleButton.setSelected(mapView.isAutoScale());
    157                 mapView.addChangeListener(new ChangeListener(){
    158                         public void stateChanged(ChangeEvent e) {
    159                                 autoScaleButton.setSelected(mapView.isAutoScale());
     86                mapView.addPropertyChangeListener(new PropertyChangeListener(){
     87                        public void propertyChange(PropertyChangeEvent evt) {
     88                                if (evt.getPropertyName().equals("autoScale"))
     89                                        autoScaleButton.setSelected(mapView.isAutoScale());
    16090                        }
    16191                });
    16292
    16393                // properties
    164                 toolBarActions.add(new IconToggleButton(this, new PropertiesAction()));
     94                toolBarActions.add(new IconToggleButton(this, new PropertiesDialog(this)));
     95               
     96                // selection dialog
     97                SelectionListDialog selectionList = new SelectionListDialog(dataSet);
     98                final IconToggleButton buttonSelection = new IconToggleButton(this, selectionList);
     99                selectionList.addWindowListener(new WindowAdapter(){
     100                        @Override
     101                        public void windowClosing(WindowEvent e) {
     102                                buttonSelection.setSelected(false);
     103                        }
     104                });
     105                toolBarActions.add(buttonSelection);
    165106        }
    166107
Note: See TracChangeset for help on using the changeset viewer.