Changeset 8 in josm for src/org/openstreetmap/josm/gui/MapFrame.java
- Timestamp:
- 2005-10-03T04:18:02+02:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/gui/MapFrame.java
r7 r8 3 3 import java.awt.BorderLayout; 4 4 import java.awt.Component; 5 import java.awt.event.ActionEvent; 6 import java.awt.event.ActionListener; 7 import java.awt.event.KeyEvent; 5 import java.awt.event.WindowAdapter; 6 import java.awt.event.WindowEvent; 7 import java.beans.PropertyChangeEvent; 8 import java.beans.PropertyChangeListener; 8 9 9 import javax.swing.AbstractAction;10 10 import javax.swing.AbstractButton; 11 import javax.swing.BorderFactory;12 import javax.swing.Box;13 import javax.swing.BoxLayout;14 11 import 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;20 12 import javax.swing.JPanel; 21 13 import javax.swing.JToggleButton; 22 14 import javax.swing.JToolBar; 23 import javax.swing.border.Border;24 import javax.swing.event.ChangeEvent;25 import javax.swing.event.ChangeListener;26 15 27 16 import org.openstreetmap.josm.actions.mapmode.AddLineSegmentAction; … … 35 24 import org.openstreetmap.josm.actions.mapmode.SelectionAction; 36 25 import org.openstreetmap.josm.actions.mapmode.ZoomAction; 37 import org.openstreetmap.josm.data.Preferences;38 26 import org.openstreetmap.josm.data.osm.DataSet; 39 import org.openstreetmap.josm.data.projection.Projection; 27 import org.openstreetmap.josm.gui.dialogs.PropertiesDialog; 28 import org.openstreetmap.josm.gui.dialogs.SelectionListDialog; 40 29 41 30 /** … … 46 35 */ 47 36 public class MapFrame extends JPanel { 48 49 /**50 * Open the properties page51 * @author imi52 */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 within70 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 // projection76 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 details86 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 }108 37 109 38 /** … … 155 84 autoScaleButton.setText(null); 156 85 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()); 160 90 } 161 91 }); 162 92 163 93 // 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); 165 106 } 166 107
Note:
See TracChangeset
for help on using the changeset viewer.