Changeset 32528 in osm for applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetDialog.java
- Timestamp:
- 2016-07-02T03:55:03+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetDialog.java
r32462 r32528 1 // License: WTFPL. For details, see LICENSE file. 1 2 package iodb; 2 3 … … 72 73 * @param offsets The list of offset to choose from. 73 74 */ 74 public OffsetDialog( List<ImageryOffsetBase> offsets) {75 public OffsetDialog(List<ImageryOffsetBase> offsets) { 75 76 super(JOptionPane.getFrameForComponent(Main.parent), ImageryOffsetTools.DIALOG_TITLE, 76 77 MODAL ? ModalityType.DOCUMENT_MODAL : ModalityType.MODELESS); … … 94 95 calibrationBox.addActionListener(new ActionListener() { 95 96 @Override 96 public void actionPerformed( ActionEvent e) {97 public void actionPerformed(ActionEvent e) { 97 98 Main.pref.put(PREF_CALIBRATION, calibrationBox.isSelected()); 98 99 updateButtonPanel(); … … 103 104 deprecatedBox.addActionListener(new ActionListener() { 104 105 @Override 105 public void actionPerformed( ActionEvent e) {106 public void actionPerformed(ActionEvent e) { 106 107 Main.pref.put(PREF_DEPRECATED, deprecatedBox.isSelected()); 107 108 updateButtonPanel(); … … 135 136 private void updateButtonPanel() { 136 137 List<ImageryOffsetBase> filteredOffsets = filterOffsets(); 137 if (buttonPanel == null)138 if (buttonPanel == null) 138 139 buttonPanel = new JPanel(); 139 140 buttonPanel.removeAll(); 140 141 buttonPanel.setLayout(new GridLayout(filteredOffsets.size(), 1, 0, 5)); 141 for (ImageryOffsetBase offset : filteredOffsets) {142 for (ImageryOffsetBase offset : filteredOffsets) { 142 143 OffsetDialogButton button = new OffsetDialogButton(offset); 143 144 button.addActionListener(this); 144 145 JPopupMenu popupMenu = new JPopupMenu(); 145 146 popupMenu.add(new OffsetInfoAction(offset)); 146 if (!offset.isDeprecated()) {147 if (!offset.isDeprecated()) { 147 148 DeprecateOffsetAction action = new DeprecateOffsetAction(offset); 148 149 action.setListener(new DeprecateOffsetListener(offset)); … … 164 165 boolean showDeprecated = Main.pref.getBoolean(PREF_DEPRECATED, false); 165 166 List<ImageryOffsetBase> filteredOffsets = new ArrayList<>(); 166 for (ImageryOffsetBase offset : offsets) {167 if (offset.isDeprecated() && !showDeprecated)167 for (ImageryOffsetBase offset : offsets) { 168 if (offset.isDeprecated() && !showDeprecated) 168 169 continue; 169 if (offset instanceof CalibrationObject && !showCalibration)170 if (offset instanceof CalibrationObject && !showCalibration) 170 171 continue; 171 172 filteredOffsets.add(offset); 172 if (filteredOffsets.size() >= MAX_OFFSETS)173 if (filteredOffsets.size() >= MAX_OFFSETS) 173 174 break; 174 175 } … … 182 183 @Override 183 184 public void zoomChanged() { 184 for (Component c : buttonPanel.getComponents()) {185 if (c instanceof OffsetDialogButton) {186 ((OffsetDialogButton)c).updateLocation(); 185 for (Component c : buttonPanel.getComponents()) { 186 if (c instanceof OffsetDialogButton) { 187 ((OffsetDialogButton) c).updateLocation(); 187 188 } 188 189 } … … 194 195 */ 195 196 @Override 196 public void paint( Graphics2D g, MapView mv, Bounds bbox) {197 if (offsets == null)197 public void paint(Graphics2D g, MapView mv, Bounds bbox) { 198 if (offsets == null) 198 199 return; 199 200 200 Graphics2D g2 = (Graphics2D)g.create(); 201 Graphics2D g2 = (Graphics2D) g.create(); 201 202 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 202 203 g2.setStroke(new BasicStroke(2)); 203 for (ImageryOffsetBase offset : filterOffsets()) {204 for (ImageryOffsetBase offset : filterOffsets()) { 204 205 Point p = mv.getPoint(offset.getPosition()); 205 206 g2.setColor(Color.BLACK); … … 221 222 prepareDialog(); 222 223 MapView.addZoomChangeListener(this); 223 if ( !MODAL) {224 if (!MODAL) { 224 225 Main.map.mapView.addTemporaryLayer(this); 225 226 Main.map.mapView.repaint(); … … 237 238 */ 238 239 @Override 239 public void actionPerformed( ActionEvent e) {240 if (e.getSource() instanceof OffsetDialogButton) {241 selectedOffset = ((OffsetDialogButton)e.getSource()).getOffset(); 240 public void actionPerformed(ActionEvent e) { 241 if (e.getSource() instanceof OffsetDialogButton) { 242 selectedOffset = ((OffsetDialogButton) e.getSource()).getOffset(); 242 243 } else 243 244 selectedOffset = null; … … 245 246 || selectedOffset instanceof CalibrationObject 246 247 || Main.pref.getBoolean("iodb.close.on.select", true); 247 if (closeDialog) {248 if (closeDialog) { 248 249 MapView.removeZoomChangeListener(this); 249 250 setVisible(false); 250 251 } 251 if ( !MODAL) {252 if (closeDialog) {252 if (!MODAL) { 253 if (closeDialog) { 253 254 Main.map.mapView.removeTemporaryLayer(this); 254 255 Main.map.mapView.repaint(); 255 256 } 256 if (selectedOffset != null) {257 if (selectedOffset != null) { 257 258 applyOffset(); 258 if (!closeDialog)259 if (!closeDialog) 259 260 updateButtonPanel(); 260 261 } 261 262 } 262 263 } 263 264 264 265 265 /** … … 269 269 */ 270 270 public void applyOffset() { 271 if (selectedOffset instanceof ImageryOffset) {271 if (selectedOffset instanceof ImageryOffset) { 272 272 ImageryLayer layer = ImageryOffsetTools.getTopImageryLayer(); 273 ImageryOffsetTools.applyLayerOffset(layer, (ImageryOffset)selectedOffset); 273 ImageryOffsetTools.applyLayerOffset(layer, (ImageryOffset) selectedOffset); 274 274 ImageryOffsetWatcher.getInstance().markGood(); 275 275 Main.map.repaint(); 276 if (!Main.pref.getBoolean("iodb.offset.message", false)) {276 if (!Main.pref.getBoolean("iodb.offset.message", false)) { 277 277 JOptionPane.showMessageDialog(Main.parent, 278 278 tr("The topmost imagery layer has been shifted to presumably match\n" … … 282 282 Main.pref.put("iodb.offset.message", true); 283 283 } 284 } else if (selectedOffset instanceof CalibrationObject) {285 CalibrationLayer clayer = new CalibrationLayer((CalibrationObject)selectedOffset); 284 } else if (selectedOffset instanceof CalibrationObject) { 285 CalibrationLayer clayer = new CalibrationLayer((CalibrationObject) selectedOffset); 286 286 Main.getLayerManager().addLayer(clayer); 287 287 clayer.panToCenter(); 288 if (!Main.pref.getBoolean("iodb.calibration.message", false)) {288 if (!Main.pref.getBoolean("iodb.calibration.message", false)) { 289 289 JOptionPane.showMessageDialog(Main.parent, 290 290 tr("A layer has been added with a calibration geometry. Hide data layers,\n" … … 305 305 * Initialize the listener with an offset. 306 306 */ 307 publicDeprecateOffsetListener(ImageryOffsetBase offset) {307 DeprecateOffsetListener(ImageryOffsetBase offset) { 308 308 this.offset = offset; 309 309 } … … 324 324 class HelpAction extends AbstractAction { 325 325 326 publicHelpAction() {326 HelpAction() { 327 327 super(tr("Help")); 328 328 putValue(SMALL_ICON, ImageProvider.get("help")); … … 330 330 331 331 @Override 332 public void actionPerformed( ActionEvent e) {332 public void actionPerformed(ActionEvent e) { 333 333 String base = Main.pref.get("url.openstreetmap-wiki", "http://wiki.openstreetmap.org/wiki/"); 334 334 String lang = LanguageInfo.getWikiLanguagePrefix(); … … 341 341 lang = ""; 342 342 } 343 } catch (IOException ex) {343 } catch (IOException ex) { 344 344 lang = ""; 345 345 }
Note:
See TracChangeset
for help on using the changeset viewer.
