Changeset 2621 in josm for trunk/src/org
- Timestamp:
- 2009-12-12T17:51:39+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/JosmAction.java
r2512 r2621 14 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 15 15 import org.openstreetmap.josm.data.osm.PrimitiveDeepCopy; 16 import org.openstreetmap.josm.gui.MapView; 16 17 import org.openstreetmap.josm.gui.layer.Layer; 17 18 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 18 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;19 19 import org.openstreetmap.josm.tools.Destroyable; 20 20 import org.openstreetmap.josm.tools.ImageProvider; … … 93 93 Main.contentPane.getActionMap().remove(sc.getKeyStroke()); 94 94 } 95 if (Layer.listeners != null) { 96 Layer.listeners.remove(layerChangeAdapter); 97 } 95 MapView.removeLayerChangeListener(layerChangeAdapter); 98 96 if (DataSet.selListeners != null) { 99 97 DataSet.selListeners.remove(selectionChangeAdapter); … … 146 144 layerChangeAdapter = new LayerChangeAdapter(); 147 145 selectionChangeAdapter = new SelectionChangeAdapter(); 148 Layer.listeners.add(layerChangeAdapter);146 MapView.addLayerChangeListener(layerChangeAdapter); 149 147 DataSet.selListeners.add(selectionChangeAdapter); 150 148 initEnabledState(); … … 195 193 * 196 194 */ 197 private class LayerChangeAdapter implements LayerChangeListener {195 private class LayerChangeAdapter implements MapView.LayerChangeListener { 198 196 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 199 197 updateEnabledState(); -
trunk/src/org/openstreetmap/josm/data/UndoRedoHandler.java
r2552 r2621 4 4 import java.util.Collection; 5 5 import java.util.Iterator; 6 import java.util.List;7 6 import java.util.LinkedList; 8 7 import java.util.Stack; … … 10 9 import org.openstreetmap.josm.Main; 11 10 import org.openstreetmap.josm.command.Command; 12 import org.openstreetmap.josm.data.osm.DataSet;13 11 import org.openstreetmap.josm.data.osm.OsmPrimitive; 12 import org.openstreetmap.josm.gui.MapView; 14 13 import org.openstreetmap.josm.gui.layer.Layer; 15 14 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 16 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;17 15 import org.openstreetmap.josm.gui.layer.OsmDataLayer.CommandQueueListener; 18 16 19 public class UndoRedoHandler implements LayerChangeListener {17 public class UndoRedoHandler implements MapView.LayerChangeListener { 20 18 21 19 /** … … 31 29 32 30 public UndoRedoHandler() { 33 Layer.listeners.add(this);31 MapView.addLayerChangeListener(this); 34 32 } 35 33 -
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r2575 r2621 7 7 import static org.openstreetmap.josm.tools.I18n.tr; 8 8 9 import java.awt.event.ActionEvent;10 import java.awt.event.ActionListener;11 9 import java.awt.event.KeyEvent; 12 10 … … 33 31 import org.openstreetmap.josm.actions.DuplicateAction; 34 32 import org.openstreetmap.josm.actions.ExitAction; 33 import org.openstreetmap.josm.actions.FullscreenToggleAction; 35 34 import org.openstreetmap.josm.actions.GpxExportAction; 36 35 import org.openstreetmap.josm.actions.HelpAction; 37 36 import org.openstreetmap.josm.actions.HistoryInfoAction; 38 37 import org.openstreetmap.josm.actions.InfoAction; 38 import org.openstreetmap.josm.actions.JoinAreasAction; 39 39 import org.openstreetmap.josm.actions.JoinNodeWayAction; 40 import org.openstreetmap.josm.actions.JoinAreasAction;41 40 import org.openstreetmap.josm.actions.JosmAction; 42 41 import org.openstreetmap.josm.actions.MergeLayerAction; … … 68 67 import org.openstreetmap.josm.actions.UploadSelectionAction; 69 68 import org.openstreetmap.josm.actions.WireframeToggleAction; 70 import org.openstreetmap.josm.actions.FullscreenToggleAction;71 69 import org.openstreetmap.josm.actions.ZoomInAction; 72 70 import org.openstreetmap.josm.actions.ZoomOutAction; … … 80 78 import org.openstreetmap.josm.actions.search.SearchAction; 81 79 import org.openstreetmap.josm.gui.layer.Layer; 82 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;83 80 import org.openstreetmap.josm.tools.Shortcut; 84 81 /** … … 309 306 } 310 307 311 class PresetsMenuEnabler implements LayerChangeListener {308 class PresetsMenuEnabler implements MapView.LayerChangeListener { 312 309 private JMenu presetsMenu; 313 310 public PresetsMenuEnabler(JMenu presetsMenu) { 314 Layer.listeners.add(this);311 MapView.addLayerChangeListener(this); 315 312 this.presetsMenu = presetsMenu; 316 313 } -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r2617 r2621 26 26 import java.util.LinkedList; 27 27 import java.util.List; 28 import java.util.concurrent.CopyOnWriteArrayList; 28 29 29 30 import javax.swing.AbstractButton; … … 64 65 */ 65 66 public class MapView extends NavigatableComponent implements PropertyChangeListener { 67 68 /** 69 * Interface to notify listeners of the change of the active layer. 70 * @author imi 71 */ 72 public interface LayerChangeListener { 73 void activeLayerChange(Layer oldLayer, Layer newLayer); 74 void layerAdded(Layer newLayer); 75 void layerRemoved(Layer oldLayer); 76 } 77 78 /** 79 * the layer listeners 80 */ 81 private static final Collection<MapView.LayerChangeListener> layerChangeListeners = new CopyOnWriteArrayList<MapView.LayerChangeListener>(); 82 83 /** 84 * Removes a layer change listener 85 * 86 * @param listener the listener. Ignored if null or already registered. 87 */ 88 public static void removeLayerChangeListener(MapView.LayerChangeListener listener) { 89 if (listener != null && layerChangeListeners.contains(listener)) { 90 layerChangeListeners.remove(listener); 91 } 92 } 93 94 /** 95 * Adds a layer change listener 96 * 97 * @param listener the listener. Ignored if null or already registered. 98 */ 99 public static void addLayerChangeListener(MapView.LayerChangeListener listener) { 100 if (listener != null && ! layerChangeListeners.contains(listener)) { 101 layerChangeListeners.add(listener); 102 } 103 } 104 105 protected static void fireActiveLayerChanged(Layer oldLayer, Layer newLayer) { 106 for (LayerChangeListener l : layerChangeListeners) { 107 l.activeLayerChange(oldLayer, newLayer); 108 } 109 } 110 111 protected static void fireLayerAdded(Layer newLayer) { 112 for (MapView.LayerChangeListener l : MapView.layerChangeListeners) { 113 l.layerAdded(newLayer); 114 } 115 } 116 117 protected static void fireLayerRemoved(Layer layer) { 118 for (MapView.LayerChangeListener l : MapView.layerChangeListeners) { 119 l.layerRemoved(layer); 120 } 121 } 66 122 67 123 /** … … 187 243 layers.add(0, layer); 188 244 } 189 190 for (Layer.LayerChangeListener l : Layer.listeners) { 191 l.layerAdded(layer); 192 } 245 fireLayerAdded(layer); 193 246 if (layer instanceof OsmDataLayer || activeLayer == null) { 194 247 // autoselect the new layer 195 248 Layer old = activeLayer; 196 249 setActiveLayer(layer); 197 for (Layer.LayerChangeListener l : Layer.listeners) { 198 l.activeLayerChange(old, layer); 199 } 250 fireActiveLayerChanged(old, layer); 200 251 } 201 252 layer.addPropertyChangeListener(this); … … 229 280 } 230 281 231 protected void fireActiveLayerChanged(Layer oldLayer, Layer newLayer) {232 for (Layer.LayerChangeListener l : Layer.listeners) {233 l.activeLayerChange(oldLayer, newLayer);234 }235 }236 282 237 283 /** … … 272 318 } 273 319 if (layers.remove(layer)) { 274 for (Layer.LayerChangeListener l : Layer.listeners) { 275 l.layerRemoved(layer); 276 } 320 fireLayerRemoved(layer); 277 321 } 278 322 layer.removePropertyChangeListener(this); … … 290 334 291 335 private boolean virtualNodesEnabled = false; 336 292 337 public void setVirtualNodesEnabled(boolean enabled) { 293 338 if(virtualNodesEnabled != enabled) { … … 536 581 activeLayer = layer; 537 582 if (old != layer) { 538 for (Layer.LayerChangeListener l : Layer.listeners) { 539 l.activeLayerChange(old, layer); 540 } 583 fireActiveLayerChanged(old, layer); 541 584 } 542 585 if (layer instanceof OsmDataLayer) { … … 650 693 } 651 694 } 695 652 696 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/ChangesetDialog.java
r2616 r2621 36 36 import org.openstreetmap.josm.data.osm.OsmPrimitive; 37 37 import org.openstreetmap.josm.gui.MapFrame; 38 import org.openstreetmap.josm.gui.MapView; 38 39 import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetInSelectionListModel; 39 40 import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetListCellRenderer; … … 43 44 import org.openstreetmap.josm.gui.help.HelpUtil; 44 45 import org.openstreetmap.josm.gui.io.CloseChangesetTask; 45 import org.openstreetmap.josm.gui.layer.Layer;46 46 import org.openstreetmap.josm.tools.ImageProvider; 47 47 import org.openstreetmap.josm.tools.OpenBrowser; … … 94 94 95 95 ChangesetCache.getInstance().addChangesetCacheListener(inSelectionModel); 96 Layer.listeners.add(inSelectionModel);96 MapView.addLayerChangeListener(inSelectionModel); 97 97 DataSet.selListeners.add(inSelectionModel); 98 98 99 99 ChangesetCache.getInstance().addChangesetCacheListener(inActiveDataLayerModel); 100 Layer.listeners.add(inActiveDataLayerModel);100 MapView.addLayerChangeListener(inActiveDataLayerModel); 101 101 102 102 DblClickHandler dblClickHandler = new DblClickHandler(); … … 112 112 public void tearDown() { 113 113 ChangesetCache.getInstance().removeChangesetCacheListener(inActiveDataLayerModel); 114 Layer.listeners.remove(inSelectionModel);114 MapView.removeLayerChangeListener(inSelectionModel); 115 115 DataSet.selListeners.remove(inSelectionModel); 116 Layer.listeners.remove(inActiveDataLayerModel);116 MapView.removeLayerChangeListener(inActiveDataLayerModel); 117 117 } 118 118 -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
r2512 r2621 43 43 import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor; 44 44 import org.openstreetmap.josm.data.osm.visitor.Visitor; 45 import org.openstreetmap.josm.gui.MapView; 45 46 import org.openstreetmap.josm.gui.NavigatableComponent; 46 47 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 47 48 import org.openstreetmap.josm.gui.SideButton; 48 import org.openstreetmap.josm.gui. help.HelpUtil;49 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 49 50 import org.openstreetmap.josm.gui.layer.Layer; 50 51 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 51 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;52 52 import org.openstreetmap.josm.tools.ImageProvider; 53 53 import org.openstreetmap.josm.tools.Shortcut; … … 58 58 * 59 59 */ 60 public final class ConflictDialog extends ToggleDialog implements LayerChangeListener, IConflictListener, SelectionChangedListener{60 public final class ConflictDialog extends ToggleDialog implements MapView.LayerChangeListener, IConflictListener, SelectionChangedListener{ 61 61 62 62 static public Color getColor() { … … 122 122 build(); 123 123 DataSet.selListeners.add(this); 124 Layer.listeners.add(this);124 MapView.addLayerChangeListener(this); 125 125 refreshView(); 126 } 127 128 129 130 @Override 131 public void tearDown() { 132 MapView.removeLayerChangeListener(this); 133 DataSet.selListeners.remove(this); 126 134 } 127 135 -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialog.java
r2512 r2621 28 28 import org.openstreetmap.josm.gui.conflict.pair.ConflictResolver; 29 29 import org.openstreetmap.josm.gui.conflict.pair.properties.OperationCancelledException; 30 import org.openstreetmap.josm.gui.help.HelpBrowser;31 30 import org.openstreetmap.josm.gui.help.HelpBrowserProxy; 32 31 import org.openstreetmap.josm.gui.help.HelpUtil; … … 231 230 ); 232 231 switch(ret) { 233 234 235 236 237 232 case JOptionPane.YES_OPTION: 233 setVisible(false); 234 break; 235 default: 236 return; 238 237 } 239 238 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java
r2512 r2621 4 4 import static org.openstreetmap.josm.tools.I18n.marktr; 5 5 import static org.openstreetmap.josm.tools.I18n.tr; 6 import static org.openstreetmap.josm.tools.I18n.trn; 6 7 import java.awt.BorderLayout; 8 import java.awt.Component; 9 import java.awt.GridLayout; 10 import java.awt.event.ActionEvent; 11 import java.awt.event.ActionListener; 12 import java.awt.event.KeyEvent; 13 import java.awt.event.MouseEvent; 7 14 8 15 import javax.swing.JCheckBox; 9 16 import javax.swing.JPanel; 10 import javax.swing.JTable;11 import javax.swing.table.JTableHeader;12 import javax.swing.table.DefaultTableCellRenderer;13 import javax.swing.event.TableModelListener;14 import javax.swing.event.TableModelEvent;15 import javax.swing.table.TableCellRenderer;16 import javax.swing.ListSelectionModel;17 17 import javax.swing.JPopupMenu; 18 18 import javax.swing.JScrollPane; 19 20 import java.awt.Component; 21 import java.awt.FlowLayout; 22 import java.awt.BorderLayout; 23 import java.awt.GridLayout; 24 import java.awt.event.KeyEvent; 25 import java.awt.event.ActionListener; 26 import java.awt.event.ActionEvent; 27 import java.awt.event.MouseEvent; 28 29 import org.openstreetmap.josm.Main; 19 import javax.swing.JTable; 20 import javax.swing.ListSelectionModel; 21 import javax.swing.event.TableModelEvent; 22 import javax.swing.event.TableModelListener; 23 import javax.swing.table.DefaultTableCellRenderer; 24 import javax.swing.table.JTableHeader; 25 import javax.swing.table.TableCellRenderer; 26 27 import org.openstreetmap.josm.actions.search.SearchAction; 28 import org.openstreetmap.josm.data.osm.Filter; 29 import org.openstreetmap.josm.data.osm.Filters; 30 import org.openstreetmap.josm.gui.MapView; 30 31 import org.openstreetmap.josm.gui.SideButton; 31 import org.openstreetmap.josm.gui. layer.Layer.LayerChangeListener;32 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 32 33 import org.openstreetmap.josm.gui.layer.DataChangeListener; 34 import org.openstreetmap.josm.gui.layer.Layer; 33 35 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 34 import org.openstreetmap.josm.gui.layer.Layer;35 import org.openstreetmap.josm.data.osm.Filters;36 import org.openstreetmap.josm.data.osm.Filter;37 36 import org.openstreetmap.josm.tools.Shortcut; 38 import org.openstreetmap.josm.data.osm.DataSet;39 import org.openstreetmap.josm.actions.search.SearchAction;40 37 41 38 /** … … 43 40 * @author Petr_Dlouhý 44 41 */ 45 public class FilterDialog extends ToggleDialog implements DataChangeListener, LayerChangeListener, TableModelListener {42 public class FilterDialog extends ToggleDialog implements DataChangeListener, MapView.LayerChangeListener, TableModelListener { 46 43 private JTable userTable; 47 44 private Filters filters = new Filters(); … … 54 51 55 52 public FilterDialog(){ 56 super(tr("Filter"), "filter", tr("Filter objects and hide/disable them."), 57 Shortcut.registerShortcut("subwindow:filter", tr("Toggle: {0}", tr("Filter")), KeyEvent.VK_F, Shortcut.GROUP_LAYER, Shortcut.SHIFT_DEFAULT), 162); 58 59 Layer.listeners.add(this); 60 build(); 53 super(tr("Filter"), "filter", tr("Filter objects and hide/disable them."), 54 Shortcut.registerShortcut("subwindow:filter", tr("Toggle: {0}", tr("Filter")), KeyEvent.VK_F, Shortcut.GROUP_LAYER, Shortcut.SHIFT_DEFAULT), 162); 55 56 MapView.addLayerChangeListener(this); 57 build(); 58 } 59 60 @Override 61 public void tearDown() { 62 MapView.removeLayerChangeListener(this); 61 63 } 62 64 … … 65 67 66 68 addButton = new SideButton(marktr("Add"), "add", "SelectionList", tr("Add filter."), 67 new ActionListener(){68 69 70 71 72 73 74 75 69 new ActionListener(){ 70 public void actionPerformed(ActionEvent evt){ 71 Filter filter = (Filter)SearchAction.showSearchDialog(new Filter()); 72 if(filter != null){ 73 filters.addFilter(filter); 74 filters.filter(); 75 } 76 } 77 }); 76 78 pnl.add(addButton); 77 79 78 80 editButton = new SideButton(marktr("Edit"), "edit", "SelectionList", tr("Edit filter."), 79 new ActionListener(){80 81 82 83 84 85 86 87 88 89 90 81 new ActionListener(){ 82 public void actionPerformed(ActionEvent evt){ 83 int index = userTable.getSelectionModel().getMinSelectionIndex(); 84 if(index < 0) return; 85 Filter f = filters.getFilter(index); 86 Filter filter = (Filter)SearchAction.showSearchDialog(f); 87 if(filter != null){ 88 filters.setFilter(index, filter); 89 filters.filter(); 90 } 91 } 92 }); 91 93 pnl.add(editButton); 92 94 93 95 deleteButton = new SideButton(marktr("Delete"), "delete", "SelectionList", tr("Delete filter."), 94 new ActionListener(){95 96 97 98 99 100 96 new ActionListener(){ 97 public void actionPerformed(ActionEvent evt){ 98 int index = userTable.getSelectionModel().getMinSelectionIndex(); 99 if(index < 0) return; 100 filters.removeFilter(index); 101 } 102 }); 101 103 pnl.add(deleteButton); 102 104 103 105 upButton = new SideButton(marktr("Up"), "up", "SelectionList", tr("Move filter up."), 104 new ActionListener(){105 106 107 108 109 110 111 106 new ActionListener(){ 107 public void actionPerformed(ActionEvent evt){ 108 int index = userTable.getSelectionModel().getMinSelectionIndex(); 109 if(index < 0) return; 110 filters.moveUpFilter(index); 111 userTable.getSelectionModel().setSelectionInterval(index-1, index-1); 112 } 113 }); 112 114 pnl.add(upButton); 113 115 114 116 downButton = new SideButton(marktr("Down"), "down", "SelectionList", tr("Move filter down."), 115 new ActionListener(){116 117 118 119 120 121 122 117 new ActionListener(){ 118 public void actionPerformed(ActionEvent evt){ 119 int index = userTable.getSelectionModel().getMinSelectionIndex(); 120 if(index < 0) return; 121 filters.moveDownFilter(index); 122 userTable.getSelectionModel().setSelectionInterval(index+1, index+1); 123 } 124 }); 123 125 pnl.add(downButton); 124 126 return pnl; … … 126 128 127 129 protected String[] columnToolTips = { 128 tr("Enable filter"),129 tr("Hide elements"),130 null,131 tr("Apply also for children"),132 tr("Inverse filter"),133 tr("Filter mode")130 tr("Enable filter"), 131 tr("Hide elements"), 132 null, 133 tr("Apply also for children"), 134 tr("Inverse filter"), 135 tr("Filter mode") 134 136 }; 135 137 … … 138 140 pnl.setLayout(new BorderLayout()); 139 141 userTable = new JTable(filters){ 142 @Override 140 143 protected JTableHeader createDefaultTableHeader() { 141 144 return new JTableHeader(columnModel) { 142 public String getToolTipText(MouseEvent e) { 143 String tip = null; 144 java.awt.Point p = e.getPoint(); 145 int index = columnModel.getColumnIndexAtX(p.x); 146 int realIndex = columnModel.getColumn(index).getModelIndex(); 147 return columnToolTips[realIndex]; 148 } 149 }; 150 } 145 @Override 146 public String getToolTipText(MouseEvent e) { 147 String tip = null; 148 java.awt.Point p = e.getPoint(); 149 int index = columnModel.getColumnIndexAtX(p.x); 150 int realIndex = columnModel.getColumn(index).getModelIndex(); 151 return columnToolTips[realIndex]; 152 } 153 }; 154 } 151 155 }; 152 156 … … 192 196 } 193 197 194 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 195 filters.filter(); 196 } 197 198 public void dataChanged(OsmDataLayer l){ 199 filters.filter(); 200 } 201 202 class StringRenderer extends DefaultTableCellRenderer { 203 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row,int column) { 204 Filters model = (Filters)table.getModel(); 205 Component cell = (Component)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); 206 cell.setEnabled(model.isCellEnabled(row, column)); 207 return cell; 208 } 209 } 210 211 class BooleanRenderer extends JCheckBox implements TableCellRenderer { 212 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row,int column) { 213 Filters model = (Filters)table.getModel(); 214 setSelected((Boolean)value); 215 setEnabled(model.isCellEnabled(row, column)); 216 setHorizontalAlignment(javax.swing.SwingConstants.CENTER); 217 return this; 218 } 219 } 220 221 public void tableChanged(TableModelEvent e){ 222 setTitle("Filter Hidden:" + filters.hiddenCount + " Disabled:" + filters.disabledCount); 223 } 198 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 199 filters.filter(); 200 } 201 202 public void dataChanged(OsmDataLayer l){ 203 filters.filter(); 204 } 205 206 class StringRenderer extends DefaultTableCellRenderer { 207 @Override 208 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row,int column) { 209 Filters model = (Filters)table.getModel(); 210 Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); 211 cell.setEnabled(model.isCellEnabled(row, column)); 212 return cell; 213 } 214 } 215 216 class BooleanRenderer extends JCheckBox implements TableCellRenderer { 217 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row,int column) { 218 Filters model = (Filters)table.getModel(); 219 setSelected((Boolean)value); 220 setEnabled(model.isCellEnabled(row, column)); 221 setHorizontalAlignment(javax.swing.SwingConstants.CENTER); 222 return this; 223 } 224 } 225 226 public void tableChanged(TableModelEvent e){ 227 setTitle("Filter Hidden:" + filters.hiddenCount + " Disabled:" + filters.disabledCount); 228 } 224 229 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r2602 r2621 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others2 1 package org.openstreetmap.josm.gui.dialogs; 3 2 … … 44 43 import org.openstreetmap.josm.gui.MapView; 45 44 import org.openstreetmap.josm.gui.SideButton; 45 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 46 46 import org.openstreetmap.josm.gui.io.SaveLayersDialog; 47 47 import org.openstreetmap.josm.gui.layer.Layer; 48 48 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 49 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;50 49 import org.openstreetmap.josm.tools.ImageProvider; 51 50 import org.openstreetmap.josm.tools.Shortcut; … … 95 94 private LayerList layerList; 96 95 96 ActivateLayerAction activateLayerAction; 97 97 98 protected JPanel createButtonPanel() { 98 99 JPanel buttonPanel = new JPanel(new GridLayout(1, 5)); … … 111 112 112 113 // -- activate action 113 ActivateLayerActionactivateLayerAction = new ActivateLayerAction();114 activateLayerAction = new ActivateLayerAction(); 114 115 adaptTo(activateLayerAction, selectionModel); 115 adaptToLayerChanges(activateLayerAction);116 MapView.addLayerChangeListener(activateLayerAction); 116 117 buttonPanel.add(new SideButton(activateLayerAction, "activate")); 117 118 … … 151 152 selectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 152 153 model = new LayerListModel(selectionModel); 153 Layer.listeners.add(model);154 MapView.addLayerChangeListener(model); 154 155 155 156 // create the list control … … 182 183 } 183 184 185 @Override 186 public void tearDown() { 187 MapView.removeLayerChangeListener(model); 188 MapView.removeLayerChangeListener(activateLayerAction); 189 } 190 184 191 public LayerListModel getModel() { 185 192 return model; … … 232 239 } 233 240 ); 234 }235 /**236 * Wires <code>listener</code> to {@see MapView} in such a way, that237 * <code>listener</code> receives a {@see IEnabledStateUpdating#updateEnabledState()}238 * on every {@see LayerChangeListener}-event emitted by {@see MapView}.239 *240 * @param listener the listener241 */242 protected void adaptToLayerChanges(final IEnabledStateUpdating listener) {243 Layer.listeners.add(244 new LayerChangeListener() {245 public void activeLayerChange(Layer oldLayer, Layer newLayer) {246 listener.updateEnabledState();247 }248 public void layerAdded(Layer newLayer) {249 listener.updateEnabledState();250 }251 public void layerRemoved(Layer oldLayer) {252 listener.updateEnabledState();253 }254 }255 );256 }257 258 private enum DeleteDecision {259 deleteCurrent,260 dontDeleteCurrent,261 deleteAll,262 cancel263 241 } 264 242 … … 400 378 */ 401 379 402 public final class ActivateLayerAction extends AbstractAction implements IEnabledStateUpdating {380 public final class ActivateLayerAction extends AbstractAction implements IEnabledStateUpdating, MapView.LayerChangeListener{ 403 381 private Layer layer; 404 382 … … 449 427 setEnabled(!isActiveLayer(layer)); 450 428 } 429 } 430 431 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 432 updateEnabledState(); 433 } 434 public void layerAdded(Layer newLayer) { 435 updateEnabledState(); 436 } 437 public void layerRemoved(Layer oldLayer) { 438 updateEnabledState(); 451 439 } 452 440 } … … 633 621 * the properties {@see Layer#VISIBLE_PROP} and {@see Layer#NAME_PROP}. 634 622 */ 635 public class LayerListModel extends DefaultListModel implements LayerChangeListener, PropertyChangeListener{623 public class LayerListModel extends DefaultListModel implements MapView.LayerChangeListener, PropertyChangeListener{ 636 624 637 625 /** manages list selection state*/ -
trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r2578 r2621 66 66 import org.openstreetmap.josm.gui.ExtendedDialog; 67 67 import org.openstreetmap.josm.gui.MapFrame; 68 import org.openstreetmap.josm.gui.MapView; 68 69 import org.openstreetmap.josm.gui.SideButton; 70 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 69 71 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 70 72 import org.openstreetmap.josm.gui.layer.Layer; 71 73 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 72 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;73 74 import org.openstreetmap.josm.gui.preferences.TaggingPresetPreference; 74 75 import org.openstreetmap.josm.gui.tagging.TaggingPreset; … … 95 96 * @author imi 96 97 */ 97 public class PropertiesDialog extends ToggleDialog implements SelectionChangedListener, LayerChangeListener {98 public class PropertiesDialog extends ToggleDialog implements SelectionChangedListener, MapView.LayerChangeListener { 98 99 /** 99 100 * Watches for double clicks and from editing or new property, depending on the … … 594 595 595 596 DataSet.selListeners.add(this); 596 Layer.listeners.add(this); 597 MapView.addLayerChangeListener(this); 598 } 599 600 @Override 601 public void tearDown() { 602 MapView.removeLayerChangeListener(this); 597 603 } 598 604 -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r2578 r2621 41 41 import org.openstreetmap.josm.data.osm.Way; 42 42 import org.openstreetmap.josm.gui.DefaultNameFormatter; 43 import org.openstreetmap.josm.gui.MapView; 43 44 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 44 45 import org.openstreetmap.josm.gui.SideButton; 46 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 45 47 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationTask; 46 48 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; … … 48 50 import org.openstreetmap.josm.gui.layer.Layer; 49 51 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 50 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;51 52 import org.openstreetmap.josm.tools.GBC; 52 53 import org.openstreetmap.josm.tools.ImageProvider; … … 60 61 * objects are visible on the map and can be selected there. Relations are not. 61 62 */ 62 public class RelationListDialog extends ToggleDialog implements LayerChangeListener, DataSetListener, DataChangeListener {63 public class RelationListDialog extends ToggleDialog implements MapView.LayerChangeListener, DataSetListener, DataChangeListener { 63 64 //private static final Logger logger = Logger.getLogger(RelationListDialog.class.getName()); 64 65 … … 137 138 138 139 @Override public void showNotify() { 139 Layer.listeners.add(this);140 Layer.listeners.add(newAction);140 MapView.addLayerChangeListener(this); 141 MapView.addLayerChangeListener(newAction); 141 142 // Register as a data set listener for the current edit layer only. 142 143 // See also activeLayerChanged … … 148 149 149 150 @Override public void hideNotify() { 150 Layer.listeners.remove(this); 151 Layer.listeners.remove(newAction); 152 Layer.listeners.add(newAction); 151 MapView.removeLayerChangeListener(this); 152 MapView.removeLayerChangeListener(newAction); 153 153 // unregistering from *all* data layer is somewhat overkill but it 154 154 // doesn't harm either. … … 345 345 * 346 346 */ 347 class NewAction extends AbstractAction implements LayerChangeListener{347 class NewAction extends AbstractAction implements MapView.LayerChangeListener{ 348 348 public NewAction() { 349 349 putValue(SHORT_DESCRIPTION,tr("Create a new relation")); -
trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r2563 r2621 43 43 import org.openstreetmap.josm.data.osm.Way; 44 44 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 45 import org.openstreetmap.josm.gui.MapView; 45 46 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 46 47 import org.openstreetmap.josm.gui.SideButton; 48 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 47 49 import org.openstreetmap.josm.gui.layer.Layer; 48 50 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 49 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;50 51 import org.openstreetmap.josm.tools.Shortcut; 51 52 … … 57 58 * @author imi 58 59 */ 59 public class SelectionListDialog extends ToggleDialog implements SelectionChangedListener, LayerChangeListener {60 public class SelectionListDialog extends ToggleDialog implements SelectionChangedListener, MapView.LayerChangeListener { 60 61 61 62 private static final int SELECTION_HISTORY_SIZE = 10; … … 163 164 164 165 DataSet.selListeners.add(this); 165 Layer.listeners.add(this); 166 MapView.addLayerChangeListener(this); 167 } 168 169 @Override 170 public void tearDown() { 171 MapView.removeLayerChangeListener(this); 172 DataSet.selListeners.remove(this); 166 173 } 167 174 -
trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java
r2512 r2621 41 41 import org.openstreetmap.josm.data.osm.OsmPrimitive; 42 42 import org.openstreetmap.josm.data.osm.User; 43 import org.openstreetmap.josm.gui.MapView; 43 44 import org.openstreetmap.josm.gui.SideButton; 45 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 44 46 import org.openstreetmap.josm.gui.layer.Layer; 45 47 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 46 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;47 48 import org.openstreetmap.josm.tools.ImageProvider; 48 49 import org.openstreetmap.josm.tools.Shortcut; … … 53 54 * 54 55 */ 55 public class UserListDialog extends ToggleDialog implements SelectionChangedListener, LayerChangeListener {56 public class UserListDialog extends ToggleDialog implements SelectionChangedListener, MapView.LayerChangeListener { 56 57 57 58 /** … … 69 70 build(); 70 71 DataSet.selListeners.add(this); 71 Layer.listeners.add(this); 72 MapView.addLayerChangeListener(this); 73 } 74 75 @Override 76 public void tearDown() { 77 MapView.removeLayerChangeListener(this); 78 DataSet.selListeners.remove(this); 72 79 } 73 80 … … 312 319 UserInfo info = data.get(row); 313 320 switch(column) { 314 315 316 321 case 0: /* author */ return info.getName() == null ? "" : info.getName(); 322 case 1: /* count */ return info.count; 323 case 2: /* percent */ return NumberFormat.getPercentInstance().format(info.percent); 317 324 } 318 325 return null; -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetInSelectionListModel.java
r2613 r2621 8 8 import org.openstreetmap.josm.data.SelectionChangedListener; 9 9 import org.openstreetmap.josm.data.osm.OsmPrimitive; 10 import org.openstreetmap.josm.gui.MapView; 11 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 10 12 import org.openstreetmap.josm.gui.layer.Layer; 11 13 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 12 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;13 14 14 public class ChangesetInSelectionListModel extends ChangesetListModel implements SelectionChangedListener, LayerChangeListener{15 public class ChangesetInSelectionListModel extends ChangesetListModel implements SelectionChangedListener, MapView.LayerChangeListener{ 15 16 16 17 public ChangesetInSelectionListModel(DefaultListSelectionModel selectionModel) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetsInActiveDataLayerListModel.java
r2613 r2621 5 5 6 6 import org.openstreetmap.josm.Main; 7 import org.openstreetmap.josm.gui.MapView; 8 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 7 9 import org.openstreetmap.josm.gui.layer.DataChangeListener; 8 10 import org.openstreetmap.josm.gui.layer.Layer; 9 11 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 10 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;11 12 12 public class ChangesetsInActiveDataLayerListModel extends ChangesetListModel implements LayerChangeListener, DataChangeListener{13 public class ChangesetsInActiveDataLayerListModel extends ChangesetListModel implements MapView.LayerChangeListener, DataChangeListener{ 13 14 14 15 public ChangesetsInActiveDataLayerListModel(DefaultListSelectionModel selectionModel) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r2581 r2621 544 544 getLayer().data.removeDataSetListener(memberTableModel); 545 545 getLayer().listenerDataChanged.remove(memberTableModel); 546 memberTable.unlinkAsListener(); 546 547 dispose(); 547 548 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java
r2563 r2621 25 25 import org.openstreetmap.josm.actions.AutoScaleAction; 26 26 import org.openstreetmap.josm.data.osm.OsmPrimitive; 27 import org.openstreetmap.josm.gui.MapView; 28 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 27 29 import org.openstreetmap.josm.gui.layer.Layer; 28 30 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 29 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;30 31 31 32 public class MemberTable extends JTable implements IMemberModelListener { … … 38 39 /** the popup menu */ 39 40 protected JPopupMenu popupMenu; 41 private ZoomToAction zoomToAction; 40 42 41 43 /** … … 148 150 149 151 /** 150 * creates the popup men151 */152 protected void createPopupMenu() {153 popupMenu = new JPopupMenu();154 ZoomToAction zoomToAction = new ZoomToAction();155 Layer.listeners.add(zoomToAction);156 getSelectionModel().addListSelectionListener(zoomToAction);157 popupMenu.add(zoomToAction);158 }159 160 /**161 152 * Replies the popup menu for this table 162 153 * … … 165 156 protected JPopupMenu getPopUpMenu() { 166 157 if (popupMenu == null) { 167 createPopupMenu(); 158 popupMenu = new JPopupMenu(); 159 zoomToAction = new ZoomToAction(); 160 MapView.addLayerChangeListener(zoomToAction); 161 getSelectionModel().addListSelectionListener(zoomToAction); 162 popupMenu.add(zoomToAction); 168 163 } 169 164 return popupMenu; 165 } 166 167 public void unlinkAsListener() { 168 MapView.removeLayerChangeListener(zoomToAction); 170 169 } 171 170 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java
r2512 r2621 12 12 13 13 import org.openstreetmap.josm.data.osm.Relation; 14 import org.openstreetmap.josm.gui.MapView; 14 15 import org.openstreetmap.josm.gui.layer.Layer; 15 16 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 16 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;17 17 18 18 /** … … 20 20 * 21 21 */ 22 public class RelationDialogManager extends WindowAdapter implements LayerChangeListener{22 public class RelationDialogManager extends WindowAdapter implements MapView.LayerChangeListener{ 23 23 24 24 /** keeps track of open relation editors */ … … 33 33 if (RelationDialogManager.relationDialogManager == null) { 34 34 RelationDialogManager.relationDialogManager = new RelationDialogManager(); 35 Layer.listeners.add(RelationDialogManager.relationDialogManager);35 MapView.addLayerChangeListener(RelationDialogManager.relationDialogManager); 36 36 } 37 37 return RelationDialogManager.relationDialogManager; -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/SelectionTableModel.java
r2563 r2621 13 13 import org.openstreetmap.josm.data.osm.DataSet; 14 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 15 import org.openstreetmap.josm.gui.MapView; 15 16 import org.openstreetmap.josm.gui.layer.Layer; 16 17 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 17 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;18 18 19 public class SelectionTableModel extends AbstractTableModel implements SelectionChangedListener, LayerChangeListener{19 public class SelectionTableModel extends AbstractTableModel implements SelectionChangedListener, MapView.LayerChangeListener{ 20 20 21 21 /** this selection table model only displays selected primitives in this layer */ … … 34 34 this.layer = layer; 35 35 cache = new ArrayList<OsmPrimitive>(); 36 Layer.listeners.add(this);36 MapView.addLayerChangeListener(this); 37 37 populateSelectedPrimitives(layer); 38 38 } … … 40 40 public void unregister() { 41 41 DataSet.selListeners.remove(this); 42 Layer.listeners.remove(this);42 MapView.removeLayerChangeListener(this); 43 43 } 44 44 -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java
r2512 r2621 10 10 import org.openstreetmap.josm.Main; 11 11 import org.openstreetmap.josm.data.osm.history.History; 12 import org.openstreetmap.josm.gui.MapView; 12 13 import org.openstreetmap.josm.gui.layer.Layer; 13 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;14 14 import org.openstreetmap.josm.tools.WindowGeometry; 15 15 16 public class HistoryBrowserDialogManager implements LayerChangeListener {16 public class HistoryBrowserDialogManager implements MapView.LayerChangeListener { 17 17 static private HistoryBrowserDialogManager instance; 18 18 static public HistoryBrowserDialogManager getInstance() { … … 27 27 protected HistoryBrowserDialogManager() { 28 28 dialogs = new HashMap<Long, HistoryBrowserDialog>(); 29 Layer.listeners.add(this);29 MapView.addLayerChangeListener(this); 30 30 } 31 31 -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java
r2556 r2621 29 29 import org.openstreetmap.josm.data.osm.history.HistoryWay; 30 30 import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor; 31 import org.openstreetmap.josm.gui.MapView; 31 32 import org.openstreetmap.josm.gui.layer.DataChangeListener; 32 33 import org.openstreetmap.josm.gui.layer.Layer; 33 34 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 34 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;35 35 36 36 /** … … 59 59 * @see HistoryBrowser 60 60 */ 61 public class HistoryBrowserModel extends Observable implements LayerChangeListener, DataSetListener, DataChangeListener {61 public class HistoryBrowserModel extends Observable implements MapView.LayerChangeListener, DataSetListener, DataChangeListener { 62 62 63 63 private static Logger logger = Logger.getLogger(HistoryBrowserModel.class.getName()); … … 97 97 getEditLayer().listenerDataChanged.add(this); 98 98 } 99 Layer.listeners.add(this); 100 99 MapView.addLayerChangeListener(this); 101 100 } 102 101 … … 772 771 getEditLayer().data.removeDataSetListener(this); 773 772 } 774 Layer.listeners.remove(this); 775 773 MapView.removeLayerChangeListener(this); 776 774 } 777 775 -
trunk/src/org/openstreetmap/josm/gui/layer/Layer.java
r2619 r2621 11 11 import java.beans.PropertyChangeSupport; 12 12 import java.io.File; 13 import java.util.Collection;14 import java.util.concurrent.CopyOnWriteArrayList;15 13 16 14 import javax.swing.AbstractAction; … … 49 47 50 48 /** 51 * Interface to notify listeners of the change of the active layer.52 * @author imi53 */54 public interface LayerChangeListener {55 void activeLayerChange(Layer oldLayer, Layer newLayer);56 void layerAdded(Layer newLayer);57 void layerRemoved(Layer oldLayer);58 }59 60 /**61 * The listener of the active layer changes. You may register/deregister yourself62 * while an LayerChangeListener - action is executed.63 *64 * @deprecated use {@see #addLayerChangeListener(LayerChangeListener)}65 * and {@see #removeLayerChangeListener(LayerChangeListener)}66 */67 @Deprecated68 public static final Collection<LayerChangeListener> listeners = new CopyOnWriteArrayList<LayerChangeListener>();69 70 /**71 * Adds a layer change listener72 *73 * @param listener the listener. Ignored if null or already registered.74 */75 public static void addLayerChangeListener(LayerChangeListener listener) {76 if (listener != null && ! listeners.contains(listener)) {77 listeners.add(listener);78 }79 }80 81 /**82 * Removes a layer change listener83 *84 * @param listener the listener. Ignored if null or already registered.85 */86 public static void removeLayerChangeListener(LayerChangeListener listener) {87 if (listener != null && listeners.contains(listener)) {88 listeners.remove(listener);89 }90 }91 92 /**93 49 * The visibility state of the layer. 94 50 * -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
r2617 r2621 16 16 import java.awt.Graphics2D; 17 17 import java.awt.Image; 18 import java.awt.MediaTracker;19 18 import java.awt.Point; 20 19 import java.awt.Rectangle; 21 import java.awt.Toolkit;22 20 import java.awt.event.MouseAdapter; 23 21 import java.awt.event.MouseEvent; 24 22 import java.awt.image.BufferedImage; 23 import java.beans.PropertyChangeEvent; 25 24 import java.beans.PropertyChangeListener; 26 import java.beans.PropertyChangeEvent;27 25 import java.io.File; 28 26 import java.io.IOException; … … 30 28 import java.util.ArrayList; 31 29 import java.util.Arrays; 30 import java.util.Collection; 32 31 import java.util.Collections; 33 import java.util.Collection;34 32 import java.util.Date; 33 import java.util.HashSet; 35 34 import java.util.LinkedHashSet; 36 import java.util.HashSet;37 35 import java.util.List; 38 36 … … 50 48 import org.openstreetmap.josm.gui.MapView; 51 49 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 50 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 52 51 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 53 52 import org.openstreetmap.josm.gui.layer.GpxLayer; … … 102 101 } 103 102 public int compareTo(ImageEntry image) { 104 if (time != null && image.time != null) {103 if (time != null && image.time != null) 105 104 return time.compareTo(image.time); 106 } else if (time == null && image.time == null) {105 else if (time == null && image.time == null) 107 106 return 0; 108 } else if (time == null) {107 else if (time == null) 109 108 return -1; 110 } else {109 else 111 110 return 1; 112 }113 111 } 114 112 } … … 147 145 } 148 146 149 if (cancelled) {147 if (cancelled) 150 148 return; 151 }152 149 progressMonitor.subTask(tr("Read photos...")); 153 150 progressMonitor.setTicksCount(files.size()); … … 205 202 e.printStackTrace(); 206 203 rememberError(tr("Unable to get canonical path for directory {0}\n", 207 204 f.getAbsolutePath())); 208 205 } 209 206 … … 228 225 229 226 } else { 230 231 } 232 } 233 234 if (nullFile) {227 files.add(f); 228 } 229 } 230 231 if (nullFile) 235 232 throw new NullPointerException(); 236 }237 233 } 238 234 … … 265 261 Main.main.addLayer(layer); 266 262 layer.hook_up_mouse_events(); // Main.map.mapView should exist 267 263 // now. Can add mouse listener 268 264 269 265 if (! cancelled && layer.data.size() > 0) { … … 329 325 new JSeparator(), 330 326 correlateItem 331 327 }; 332 328 } 333 329 … … 336 332 int i = 0; 337 333 for (ImageEntry e : data) 338 if (e.pos != null) 334 if (e.pos != null) { 339 335 i++; 336 } 340 337 return data.size() + " " + trn("image", "images", data.size()) 341 338 + " loaded. " + tr("{0} were found to be gps tagged.", i); 342 339 } 343 340 … … 406 403 407 404 return new Dimension( 408 (int) Math.round(f * thumb.getWidth(null)),409 (int) Math.round(f * thumb.getHeight(null)));405 (int) Math.round(f * thumb.getWidth(null)), 406 (int) Math.round(f * thumb.getHeight(null))); 410 407 } 411 408 … … 432 429 433 430 for (ImageEntry e : data) { 434 if (e.pos == null) 431 if (e.pos == null) { 435 432 continue; 433 } 436 434 Point p = mv.getPoint(e.pos); 437 435 if (e.thumbnail != null) { … … 444 442 else { // thumbnail not loaded yet 445 443 icon.paintIcon(mv, tempG, 446 447 444 p.x - icon.getIconWidth() / 2, 445 p.y - icon.getIconHeight() / 2); 448 446 } 449 447 } … … 454 452 else { 455 453 for (ImageEntry e : data) { 456 if (e.pos == null) 454 if (e.pos == null) { 457 455 continue; 456 } 458 457 Point p = mv.getPoint(e.pos); 459 458 icon.paintIcon(mv, g, 460 461 459 p.x - icon.getIconWidth() / 2, 460 p.y - icon.getIconHeight() / 2); 462 461 } 463 462 } … … 475 474 } else { 476 475 selectedIcon.paintIcon(mv, g, 477 478 476 p.x - selectedIcon.getIconWidth() / 2, 477 p.y - selectedIcon.getIconHeight() / 2); 479 478 } 480 479 } … … 484 483 @Override 485 484 public void visitBoundingBox(BoundingXYVisitor v) { 486 for (ImageEntry e : data) 485 for (ImageEntry e : data) { 487 486 v.visit(e.pos); 487 } 488 488 } 489 489 … … 508 508 509 509 Rational[] components = dir 510 510 .getRationalArray(GpsDirectory.TAG_GPS_LONGITUDE); 511 511 512 512 deg = components[0].intValue(); … … 516 516 lon = (deg + (min / 60) + (sec / 3600)); 517 517 518 if (dir.getString(GpsDirectory.TAG_GPS_LONGITUDE_REF).charAt(0) == 'W') 518 if (dir.getString(GpsDirectory.TAG_GPS_LONGITUDE_REF).charAt(0) == 'W') { 519 519 lon = -lon; 520 } 520 521 521 522 // latitude … … 529 530 lat = (deg + (min / 60) + (sec / 3600)); 530 531 531 if (dir.getString(GpsDirectory.TAG_GPS_LATITUDE_REF).charAt(0) == 'S') 532 if (dir.getString(GpsDirectory.TAG_GPS_LATITUDE_REF).charAt(0) == 'S') { 532 533 lat = -lat; 534 } 533 535 534 536 // Store values … … 569 571 570 572 public void checkPreviousNextButtons() { 571 // System.err.println("showing image " + currentPhoto);573 // System.err.println("showing image " + currentPhoto); 572 574 ImageViewerDialog.setNextEnabled(currentPhoto < data.size() - 1); 573 575 ImageViewerDialog.setPreviousEnabled(currentPhoto > 0); … … 596 598 @Override public void mousePressed(MouseEvent e) { 597 599 598 if (e.getButton() != MouseEvent.BUTTON1) {600 if (e.getButton() != MouseEvent.BUTTON1) 599 601 return; 600 } 601 if (isVisible()) 602 if (isVisible()) { 602 603 Main.map.mapView.repaint(); 604 } 603 605 } 604 606 605 607 @Override public void mouseReleased(MouseEvent ev) { 606 if (ev.getButton() != MouseEvent.BUTTON1) {608 if (ev.getButton() != MouseEvent.BUTTON1) 607 609 return; 608 } 609 if (!isVisible()) { 610 if (!isVisible()) 610 611 return; 611 }612 612 613 613 for (int i = data.size() - 1; i >= 0; --i) { 614 614 ImageEntry e = data.get(i); 615 if (e.pos == null) 615 if (e.pos == null) { 616 616 continue; 617 } 617 618 Point p = Main.map.mapView.getPoint(e.pos); 618 619 Rectangle r; … … 622 623 } else { 623 624 r = new Rectangle(p.x - icon.getIconWidth() / 2, 624 625 626 625 p.y - icon.getIconHeight() / 2, 626 icon.getIconWidth(), 627 icon.getIconHeight()); 627 628 } 628 629 if (r.contains(ev.getPoint())) { … … 636 637 }; 637 638 Main.map.mapView.addMouseListener(mouseAdapter); 638 Layer.listeners.add(new LayerChangeListener() {639 MapView.addLayerChangeListener(new LayerChangeListener() { 639 640 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 640 641 if (newLayer == GeoImageLayer.this && currentPhoto >= 0) { … … 656 657 data.clear(); 657 658 data = null; 659 // stop listening to layer change events 660 MapView.removeLayerChangeListener(this); 658 661 } 659 662 } -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r2512 r2621 44 44 import org.openstreetmap.josm.data.osm.Way; 45 45 import org.openstreetmap.josm.gui.ExtendedDialog; 46 import org.openstreetmap.josm.gui.MapView; 46 47 import org.openstreetmap.josm.gui.QuadStateCheckBox; 47 48 import org.openstreetmap.josm.gui.layer.Layer; 48 49 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 49 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;50 50 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionCache; 51 51 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionItemPritority; … … 65 65 * It is also able to construct dialogs out of preset definitions. 66 66 */ 67 public class TaggingPreset extends AbstractAction implements LayerChangeListener {67 public class TaggingPreset extends AbstractAction implements MapView.LayerChangeListener { 68 68 69 69 public TaggingPresetMenu group = null; … … 181 181 } 182 182 if(locale_text == null) { 183 if(text_context != null) 183 if(text_context != null) { 184 184 locale_text = trc(text_context, text); 185 else185 } else { 186 186 locale_text = tr(text); 187 } 187 188 } 188 189 p.add(new JLabel(locale_text+":"), GBC.std().insets(0,0,10,0)); … … 231 232 232 233 if(locale_text == null) { 233 if(text_context != null) 234 if(text_context != null) { 234 235 locale_text = trc(text_context, text); 235 else236 } else { 236 237 locale_text = tr(text); 238 } 237 239 } 238 240 … … 334 336 for (int i=0; i<value_array.length; i++) { 335 337 lhm.put(value_array[i], (locale_display_values == null) 336 ? (values_context == null ? tr(display_array[i])337 : tr(values_context, display_array[i])) : display_array[i]);338 ? (values_context == null ? tr(display_array[i]) 339 : tr(values_context, display_array[i])) : display_array[i]); 338 340 } 339 341 if(!usage.unused()){ … … 377 379 378 380 if(locale_text == null) { 379 if(text_context != null) 381 if(text_context != null) { 380 382 locale_text = trc(text_context, text); 381 else383 } else { 382 384 locale_text = tr(text); 385 } 383 386 } 384 387 p.add(new JLabel(locale_text+":"), GBC.std().insets(0,0,10,0)); … … 427 430 @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) { 428 431 if(locale_text == null) { 429 if(text_context != null) 432 if(text_context != null) { 430 433 locale_text = trc(text_context, text); 431 else434 } else { 432 435 locale_text = tr(text); 436 } 433 437 } 434 438 p.add(new JLabel(locale_text), GBC.eol()); … … 447 451 @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) { 448 452 if(locale_text == null) { 449 if(text == null) 453 if(text == null) { 450 454 locale_text = tr("More information about this feature"); 451 else if(text_context != null)455 } else if(text_context != null) { 452 456 locale_text = trc(text_context, text); 453 else457 } else { 454 458 locale_text = tr(text); 459 } 455 460 } 456 461 String url = locale_href; … … 508 513 */ 509 514 public TaggingPreset() { 510 Layer.listeners.add(this);515 MapView.addLayerChangeListener(this); 511 516 updateEnabledState(); 512 517 } … … 522 527 public String getLocaleName() { 523 528 if(locale_name == null) { 524 if(name_context != null) 529 if(name_context != null) { 525 530 locale_name = trc(name_context, name); 526 else531 } else { 527 532 locale_name = tr(name); 533 } 528 534 } 529 535 return locale_name; -
trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionCache.java
r2578 r2621 12 12 import org.openstreetmap.josm.data.osm.Relation; 13 13 import org.openstreetmap.josm.data.osm.RelationMember; 14 import org.openstreetmap.josm.gui.MapView; 14 15 import org.openstreetmap.josm.gui.layer.Layer; 15 16 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 16 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;17 17 18 18 /** … … 40 40 static { 41 41 caches = new HashMap<OsmDataLayer, AutoCompletionCache>(); 42 Layer.listeners.add(newLayerChangeListener() {42 MapView.addLayerChangeListener(new MapView.LayerChangeListener() { 43 43 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 44 44 // do nothing
Note:
See TracChangeset
for help on using the changeset viewer.