Changeset 2602 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-12-10T16:34:13+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
r2512 r2602 102 102 * @param buttonIcons 103 103 */ 104 public voidsetButtonIcons(String[] buttonIcons) {104 public ExtendedDialog setButtonIcons(String[] buttonIcons) { 105 105 this.bIcons = buttonIcons; 106 return this; 106 107 } 107 108 … … 112 113 * @param toolTipTexts the tool tip texts. Ignored, if null. 113 114 */ 114 public voidsetToolTipTexts(String[] toolTipTexts) {115 public ExtendedDialog setToolTipTexts(String[] toolTipTexts) { 115 116 this.bToolTipTexts = toolTipTexts; 117 return this; 116 118 } 117 119 … … 124 126 * @param content Any element that can be displayed in the message dialog 125 127 */ 126 public voidsetContent(Component content) {127 setContent(content, true);128 public ExtendedDialog setContent(Component content) { 129 return setContent(content, true); 128 130 } 129 131 … … 138 140 * 139 141 */ 140 public voidsetContent(Component content, boolean placeContentInScrollPane) {142 public ExtendedDialog setContent(Component content, boolean placeContentInScrollPane) { 141 143 this.content = content; 142 144 this.placeContentInScrollPane = placeContentInScrollPane; 145 return this; 143 146 } 144 147 … … 152 155 * @param message The text that should be shown to the user 153 156 */ 154 public voidsetContent(String message) {155 setContent(string2label(message), false);157 public ExtendedDialog setContent(String message) { 158 return setContent(string2label(message), false); 156 159 } 157 160 … … 160 163 * for the dialog. You can retrieve the result using <code>getValue</code> 161 164 */ 162 public voidshowDialog() {165 public ExtendedDialog showDialog() { 163 166 // Check if the user has set the dialog to not be shown again 164 167 if(toggleCheckState(togglePref)) { 165 168 result = ExtendedDialog.DialogNotShown; 166 return ;169 return this; 167 170 } 168 171 … … 170 173 setVisible(true); 171 174 toggleSaveState(); 175 return this; 172 176 } 173 177 … … 342 346 * 343 347 */ 344 public voidsetRememberWindowGeometry(String pref, WindowGeometry wg) {348 public ExtendedDialog setRememberWindowGeometry(String pref, WindowGeometry wg) { 345 349 rememberSizePref = pref == null ? "" : pref; 346 350 defaultWindowGeometry = wg; 351 return this; 347 352 } 348 353 … … 354 359 * @param togglePref The preference to save the checkbox state to 355 360 */ 356 public voidtoggleEnable(String togglePref) {361 public ExtendedDialog toggleEnable(String togglePref) { 357 362 this.toggleable = true; 358 363 this.togglePref = togglePref; 364 return this; 359 365 } 360 366 … … 363 369 * to be called for every dialog, as it's the default anyway. 364 370 */ 365 public voidtoggleDisable() {371 public ExtendedDialog toggleDisable() { 366 372 this.toggleable = false; 373 return this; 367 374 } 368 375 … … 373 380 * @param text 374 381 */ 375 public voidsetToggleCheckboxText(String text) {382 public ExtendedDialog setToggleCheckboxText(String text) { 376 383 this.toggleCheckboxText = text; 384 return this; 377 385 } 378 386 … … 429 437 * @param showHelpButton true, if the dialog displays a help button 430 438 */ 431 public voidconfigureContextsensitiveHelp(String helpTopic, boolean showHelpButton) {439 public ExtendedDialog configureContextsensitiveHelp(String helpTopic, boolean showHelpButton) { 432 440 this.helpTopic = helpTopic; 433 441 this.showHelpButton = showHelpButton; 442 return this; 434 443 } 435 444 -
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r2512 r2602 542 542 if (!layerList.getCellBounds(index, index).contains(e.getPoint())) 543 543 return; 544 if (!layerList.isSelectedIndex(index)) { 545 layerList.setSelectedIndex(index); 546 } 544 547 Layer layer = model.getLayer(index); 545 548 LayerListPopup menu = new LayerListPopup(layerList, layer); -
trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r2577 r2602 68 68 */ 69 69 protected boolean isCollapsed; 70 70 71 71 /** the preferred height if the toggle dialog is expanded */ 72 72 private int preferredHeight; … … 76 76 77 77 /** the JDialog displaying the toggle dialog as undocked dialog */ 78 pr ivateJDialog detachedDialog;78 protected JDialog detachedDialog; 79 79 80 80 /** … … 295 295 * 296 296 */ 297 pr ivateclass TitleBar extends JPanel {297 protected class TitleBar extends JPanel { 298 298 final private JLabel lblTitle; 299 299 final private JComponent lblTitle_weak; … … 478 478 isShowing = val; 479 479 Main.pref.put(preferencePrefix+".visible", val); 480 stateChanged(); 480 481 } 481 482 … … 483 484 isDocked = val; 484 485 Main.pref.put(preferencePrefix+".docked", val); 486 stateChanged(); 485 487 } 486 488 … … 488 490 isCollapsed = val; 489 491 Main.pref.put(preferencePrefix+".minimized", val); 492 stateChanged(); 490 493 } 491 494 … … 549 552 return true; 550 553 } 554 555 /** 556 * primitive stateChangedListener for subclasses 557 */ 558 protected void stateChanged() { 559 } 551 560 552 561 /*** -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java
r2592 r2602 133 133 // To avoid issues when the user tries to zoom in on the image borders, this point is not calculated 134 134 // again if there was less than 1.5seconds since the last event. 135 System.out.println(e);136 135 if (e.getWhen() - lastTimeForMousePoint > 1500 || mousePointInImg == null) { 137 136 lastTimeForMousePoint = e.getWhen(); … … 535 534 536 535 private Rectangle calculateDrawImageRectangle(Rectangle visibleRect) { 537 Dimension size = getSize(); 536 return calculateDrawImageRectangle(visibleRect, new Rectangle(0, 0, getSize().width, getSize().height)); 537 } 538 539 /** 540 * calculateDrawImageRectangle 541 * 542 * @param imgRect the part of the image that should be drawn (in image coordinates) 543 * @param compRect the part of the component where the image should be drawn (in component coordinates) 544 * @return the part of compRect with the same width/height ratio as the image 545 */ 546 static Rectangle calculateDrawImageRectangle(Rectangle imgRect, Rectangle compRect) { 538 547 int x, y, w, h; 539 548 x = 0; 540 549 y = 0; 541 w = size.width;542 h = size.height;543 544 int wFact = w * visibleRect.height;545 int hFact = h * visibleRect.width;550 w = compRect.width; 551 h = compRect.height; 552 553 int wFact = w * imgRect.height; 554 int hFact = h * imgRect.width; 546 555 if (wFact != hFact) { 547 556 if (wFact > hFact) { 548 w = hFact / visibleRect.height;549 x = ( size.width - w) / 2;557 w = hFact / imgRect.height; 558 x = (compRect.width - w) / 2; 550 559 } else { 551 h = wFact / visibleRect.width;552 y = ( size.height - h) / 2;553 } 554 } 555 return new Rectangle(x ,y, w, h);560 h = wFact / imgRect.width; 561 y = (compRect.height - h) / 2; 562 } 563 } 564 return new Rectangle(x + compRect.x, y + compRect.y, w, h); 556 565 } 557 566 -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java
r2601 r2602 9 9 10 10 import java.awt.BorderLayout; 11 import java.awt.Component; 11 12 import java.awt.Dimension; 12 import java.awt.FlowLayout; 13 import java.awt.GridBagConstraints; 14 import java.awt.GridBagLayout; 13 15 import java.awt.event.ActionEvent; 14 16 import java.awt.event.ActionListener; 15 17 import java.awt.event.KeyEvent; 16 18 import java.awt.event.WindowEvent; 19 20 import javax.swing.Box; 17 21 import javax.swing.AbstractAction; 18 22 import javax.swing.ImageIcon; … … 23 27 24 28 import org.openstreetmap.josm.Main; 25 import org.openstreetmap.josm.gui.SideButton;26 29 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; 27 30 import org.openstreetmap.josm.gui.dialogs.DialogsPanel.Action; … … 37 40 private static final String COMMAND_REMOVE = "remove"; 38 41 private static final String COMMAND_PREVIOUS = "previous"; 42 private static final String COMMAND_COLLAPSE = "collapse"; 39 43 40 44 private ImageDisplay imgDisplay = new ImageDisplay(); … … 43 47 // Only one instance of that class 44 48 static private ImageViewerDialog INSTANCE = null; 49 50 private boolean collapseButtonClicked = false; 45 51 46 52 public static ImageViewerDialog getInstance() { … … 53 59 private JButton btnNext; 54 60 private JButton btnPrevious; 61 private JButton btnCollapse; 55 62 56 63 private ImageViewerDialog() { … … 73 80 content.add(imgDisplay, BorderLayout.CENTER); 74 81 75 JPanel buttons = new JPanel();76 buttons.setLayout(new FlowLayout());77 78 82 Dimension buttonDim = new Dimension(26,26); 79 83 80 84 ImageAction prevAction = new ImageAction(COMMAND_PREVIOUS, ImageProvider.get("dialogs", "previous"), tr("Previous")); 81 85 btnPrevious = new JButton(prevAction); 82 86 btnPrevious.setPreferredSize(buttonDim); 83 buttons.add(btnPrevious);84 87 Shortcut scPrev = Shortcut.registerShortcut( 85 88 "geoimage:previous", tr("Geoimage: {0}", tr("Show previous Image")), KeyEvent.VK_PAGE_UP, Shortcut.GROUP_DIRECT); … … 92 95 JButton btnDelete = new JButton(new ImageAction(COMMAND_REMOVE, ImageProvider.get("dialogs", "delete"), tr("Remove photo from layer"))); 93 96 btnDelete.setPreferredSize(buttonDim); 94 buttons.add(btnDelete); 95 97 96 98 ImageAction nextAction = new ImageAction(COMMAND_NEXT, ImageProvider.get("dialogs", "next"), tr("Next")); 97 99 btnNext = new JButton(nextAction); 98 100 btnNext.setPreferredSize(buttonDim); 99 buttons.add(btnNext);100 101 Shortcut scNext = Shortcut.registerShortcut( 101 102 "geoimage:next", tr("Geoimage: {0}", tr("Show next Image")), KeyEvent.VK_PAGE_DOWN, Shortcut.GROUP_DIRECT); … … 108 109 JToggleButton tbCentre = new JToggleButton(new ImageAction(COMMAND_CENTERVIEW, ImageProvider.get("dialogs", "centreview"), tr("Center view"))); 109 110 tbCentre.setPreferredSize(buttonDim); 110 buttons.add(tbCentre); 111 111 112 112 JButton btnZoomBestFit = new JButton(new ImageAction(COMMAND_ZOOM, ImageProvider.get("dialogs", "zoom-best-fit"), tr("Zoom best fit and 1:1"))); 113 113 btnZoomBestFit.setPreferredSize(buttonDim); 114 115 btnCollapse = new JButton(new ImageAction(COMMAND_COLLAPSE, ImageProvider.get("dialogs", "collapse"), tr("Move dialog to the side pane"))); 116 btnCollapse.setPreferredSize(new Dimension(20,20)); 117 btnCollapse.setAlignmentY(Component.TOP_ALIGNMENT); 118 119 JPanel buttons = new JPanel(); 120 buttons.add(btnPrevious); 121 buttons.add(btnNext); 122 buttons.add(Box.createRigidArea(new Dimension(14, 0))); 123 buttons.add(tbCentre); 114 124 buttons.add(btnZoomBestFit); 115 116 content.add(buttons, BorderLayout.SOUTH); 125 buttons.add(Box.createRigidArea(new Dimension(14, 0))); 126 buttons.add(btnDelete); 127 128 JPanel bottomPane = new JPanel(); 129 bottomPane.setLayout(new GridBagLayout()); 130 GridBagConstraints gc = new GridBagConstraints(); 131 gc.gridx = 0; 132 gc.gridy = 0; 133 gc.anchor = GridBagConstraints.CENTER; 134 gc.weightx = 1; 135 bottomPane.add(buttons, gc); 136 137 gc.gridx = 1; 138 gc.gridy = 0; 139 gc.anchor = GridBagConstraints.PAGE_END; 140 gc.weightx = 0; 141 bottomPane.add(btnCollapse, gc); 142 143 content.add(bottomPane, BorderLayout.SOUTH); 117 144 118 145 add(content, BorderLayout.CENTER); … … 150 177 currentLayer.removeCurrentPhoto(); 151 178 } 179 } else if (COMMAND_COLLAPSE.equals(action)) { 180 collapseButtonClicked = true; 181 detachedDialog.getToolkit().getSystemEventQueue().postEvent(new WindowEvent(detachedDialog, WindowEvent.WINDOW_CLOSING)); 152 182 } 153 183 } … … 186 216 if (entry != null) { 187 217 imgDisplay.setImage(entry.file); 218 titleBar.setTitle("Geotagged Images" + (entry.file != null ? " - " + entry.file.getName() : "")); 188 219 StringBuffer osd = new StringBuffer(entry.file != null ? entry.file.getName() : ""); 189 220 if (entry.elevation != null) { … … 227 258 @Override 228 259 protected boolean dockWhenClosingDetachedDlg() { 260 if (collapseButtonClicked) { 261 collapseButtonClicked = false; 262 return true; 263 } 229 264 return false; 265 } 266 267 @Override 268 protected void stateChanged() { 269 super.stateChanged(); 270 if (btnCollapse != null) { 271 btnCollapse.setVisible(!isDocked); 272 } 230 273 } 231 274
Note:
See TracChangeset
for help on using the changeset viewer.