Changeset 9576 in josm
- Timestamp:
- 2016-01-23T04:49:01+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/FullscreenToggleAction.java
r9067 r9576 9 9 import java.awt.GraphicsEnvironment; 10 10 import java.awt.Rectangle; 11 import java.awt.Toolkit;12 11 import java.awt.Window; 13 12 import java.awt.event.ActionEvent; … … 21 20 22 21 import org.openstreetmap.josm.Main; 22 import org.openstreetmap.josm.gui.util.GuiHelper; 23 23 import org.openstreetmap.josm.tools.Shortcut; 24 24 … … 84 84 if (selected) { 85 85 prevBounds = frame.getBounds(); 86 frame.setBounds(new Rectangle( Toolkit.getDefaultToolkit().getScreenSize()));86 frame.setBounds(new Rectangle(GuiHelper.getScreenSize())); 87 87 } 88 88 -
trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
r8978 r9576 9 9 import java.awt.GridBagLayout; 10 10 import java.awt.Insets; 11 import java.awt.Toolkit;12 11 import java.awt.event.ActionEvent; 13 12 import java.awt.event.KeyEvent; … … 438 437 */ 439 438 protected Dimension findMaxDialogSize() { 440 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();439 Dimension screenSize = GuiHelper.getScreenSize(); 441 440 Dimension x = new Dimension(screenSize.width*2/3, screenSize.height*2/3); 442 441 if (parent != null) { … … 626 625 JMultilineLabel lbl = new JMultilineLabel(msg); 627 626 // Make it not wider than 1/2 of the screen 628 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();627 Dimension screenSize = GuiHelper.getScreenSize(); 629 628 lbl.setMaxWidth(screenSize.width/2); 630 629 // Disable default Enter key binding to allow dialog's one (then enables to hit default button from here) -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r9346 r9576 414 414 private Popup popupCreatePopup(Component content, MouseState ms) { 415 415 Point p = mv.getLocationOnScreen(); 416 Dimension scrn = Toolkit.getDefaultToolkit().getScreenSize();416 Dimension scrn = GuiHelper.getScreenSize(); 417 417 418 418 // Create a JScrollPane around the content, in case there's not enough space -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
r9564 r9576 14 14 import java.awt.GridBagConstraints; 15 15 import java.awt.GridBagLayout; 16 import java.awt.Toolkit;17 16 import java.awt.datatransfer.Clipboard; 18 17 import java.awt.datatransfer.Transferable; … … 505 504 private void selectACComboBoxSavingUnixBuffer(AutoCompletingComboBox cb) { 506 505 // select combobox with saving unix system selection (middle mouse paste) 507 Clipboard sysSel = Toolkit.getDefaultToolkit().getSystemSelection();506 Clipboard sysSel = GuiHelper.getSystemSelection(); 508 507 if (sysSel != null) { 509 508 Transferable old = Utils.getTransferableContent(sysSel); -
trunk/src/org/openstreetmap/josm/gui/download/SlippyMapChooser.java
r8932 r9576 5 5 6 6 import java.awt.Dimension; 7 import java.awt.Toolkit;8 7 import java.beans.PropertyChangeEvent; 9 8 import java.beans.PropertyChangeListener; … … 15 14 import org.openstreetmap.josm.gui.bbox.BBoxChooser; 16 15 import org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser; 16 import org.openstreetmap.josm.gui.util.GuiHelper; 17 17 18 18 /** … … 59 59 60 60 // retrieve the size of the display 61 Dimension iScreenSize = Toolkit.getDefaultToolkit().getScreenSize();61 Dimension iScreenSize = GuiHelper.getScreenSize(); 62 62 63 63 if (iDownloadDialogDimension == null) { -
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r9478 r9576 6 6 import java.awt.Color; 7 7 import java.awt.Component; 8 import java.awt.Dimension; 8 9 import java.awt.Font; 9 10 import java.awt.Graphics; 10 11 import java.awt.Graphics2D; 11 import java.awt.GraphicsEnvironment;12 12 import java.awt.GridBagLayout; 13 13 import java.awt.Image; … … 84 84 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 85 85 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 86 import org.openstreetmap.josm.gui.util.GuiHelper; 86 87 import org.openstreetmap.josm.io.WMSLayerImporter; 87 88 import org.openstreetmap.josm.tools.GBC; … … 670 671 671 672 protected int estimateTileCacheSize() { 672 // Default screen size in headless mode, for unit tests 673 int height = 800; 674 int width = 600; 675 if (!GraphicsEnvironment.isHeadless()) { 676 height = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight(); 677 width = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth(); 678 } 673 Dimension screenSize = GuiHelper.getScreenSize(); 674 int height = screenSize.height; 675 int width = screenSize.width; 679 676 int tileSize = 256; // default tile size 680 677 if (tileSource != null) { -
trunk/src/org/openstreetmap/josm/gui/layer/AlignImageryPanel.java
r9391 r9576 7 7 import java.awt.Font; 8 8 import java.awt.GridBagLayout; 9 import java.awt.Toolkit;10 9 import java.awt.event.ActionEvent; 11 10 import java.awt.event.ActionListener; … … 21 20 import org.openstreetmap.josm.data.imagery.ImageryInfo; 22 21 import org.openstreetmap.josm.data.preferences.BooleanProperty; 22 import org.openstreetmap.josm.gui.util.GuiHelper; 23 23 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; 24 24 import org.openstreetmap.josm.gui.widgets.UrlLabel; … … 90 90 if (Main.isDisplayingMapView() && showAgain.get() && !infoToAdd.isGeoreferenceValid()) { 91 91 if (Main.map.getTopPanel(AlignImageryPanel.class) == null) { 92 double w = Toolkit.getDefaultToolkit().getScreenSize().getWidth();92 double w = GuiHelper.getScreenSize().getWidth(); 93 93 AlignImageryPanel p = new AlignImageryPanel(w > 1300, showAgain, infoToAdd); 94 94 Main.map.addTopPanel(p); -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/CustomizeDrawingAction.java
r8509 r9576 7 7 import java.awt.Component; 8 8 import java.awt.Dimension; 9 import java.awt.Toolkit;10 9 import java.awt.event.ActionEvent; 11 10 import java.util.LinkedList; … … 83 82 JScrollPane scrollpane = GuiHelper.embedInVerticalScrollPane(panel); 84 83 scrollpane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); 85 int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;84 int screenHeight = GuiHelper.getScreenSize().height; 86 85 if (screenHeight < 700) { 87 86 // to fit on screen 800x600 -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackAction.java
r8526 r9576 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.GraphicsEnvironment; 6 7 import java.awt.GridBagLayout; 7 8 import java.awt.event.ActionEvent; 8 9 import java.io.IOException; 9 10 import java.util.ArrayList; 10 import java.util.Collection;11 11 import java.util.List; 12 12 … … 103 103 104 104 protected AbstractTileSourceLayer askedLayer() { 105 Collection<AbstractTileSourceLayer> targetLayers = Main.map.mapView.getLayersOfType(AbstractTileSourceLayer.class);105 List<AbstractTileSourceLayer> targetLayers = Main.map.mapView.getLayersOfType(AbstractTileSourceLayer.class); 106 106 if (targetLayers.isEmpty()) { 107 warnNoImageryLayers(); 107 if (!GraphicsEnvironment.isHeadless()) { 108 warnNoImageryLayers(); 109 } 108 110 return null; 109 111 } … … 114 116 pnl.add(new JLabel(tr("Please select the imagery layer.")), GBC.eol()); 115 117 pnl.add(layerList, GBC.eol()); 118 if (GraphicsEnvironment.isHeadless()) { 119 // return first layer in headless mode, for unit tests 120 return targetLayers.get(0); 121 } 116 122 ExtendedDialog ed = new ExtendedDialog(Main.parent, tr("Select imagery layer"), new String[]{tr("Download"), tr("Cancel")}); 117 123 ed.setButtonIcons(new String[]{"dialogs/down", "cancel"}); -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java
r8836 r9576 11 11 import java.awt.GridBagLayout; 12 12 import java.awt.Insets; 13 import java.awt.Toolkit;14 13 import java.awt.event.ActionEvent; 15 14 import java.awt.event.ActionListener; … … 32 31 import org.openstreetmap.josm.gui.help.HelpUtil; 33 32 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane.ValidationListener; 33 import org.openstreetmap.josm.gui.util.GuiHelper; 34 34 import org.openstreetmap.josm.tools.GBC; 35 35 import org.openstreetmap.josm.tools.ImageProvider; … … 84 84 // set the maximum width to the current screen. If the dialog is opened on a 85 85 // smaller screen than before, this will reset the stored preference. 86 this.setMaximumSize( Toolkit.getDefaultToolkit().getScreenSize());86 this.setMaximumSize(GuiHelper.getScreenSize()); 87 87 } 88 88 -
trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingComboBox.java
r9575 r9576 3 3 4 4 import java.awt.Component; 5 import java.awt.GraphicsEnvironment;6 import java.awt.Toolkit;7 5 import java.awt.datatransfer.Clipboard; 8 6 import java.awt.datatransfer.Transferable; … … 26 24 27 25 import org.openstreetmap.josm.Main; 26 import org.openstreetmap.josm.gui.util.GuiHelper; 28 27 import org.openstreetmap.josm.gui.widgets.JosmComboBox; 29 28 import org.openstreetmap.josm.tools.Utils; … … 133 132 final JTextComponent editorComponent = comboBox.getEditorComponent(); 134 133 // save unix system selection (middle mouse paste) 135 Clipboard sysSel = G raphicsEnvironment.isHeadless() ? null : Toolkit.getDefaultToolkit().getSystemSelection();134 Clipboard sysSel = GuiHelper.getSystemSelection(); 136 135 if (sysSel != null) { 137 136 Transferable old = Utils.getTransferableContent(sysSel); … … 198 197 } 199 198 // save unix system selection (middle mouse paste) 200 Clipboard sysSel = Toolkit.getDefaultToolkit().getSystemSelection();199 Clipboard sysSel = GuiHelper.getSystemSelection(); 201 200 if (sysSel != null) { 202 201 Transferable old = Utils.getTransferableContent(sysSel); -
trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java
r9246 r9576 11 11 import java.awt.Dimension; 12 12 import java.awt.Font; 13 import java.awt.GraphicsEnvironment; 13 14 import java.awt.GridBagLayout; 14 15 import java.awt.Image; … … 16 17 import java.awt.Toolkit; 17 18 import java.awt.Window; 19 import java.awt.datatransfer.Clipboard; 18 20 import java.awt.event.ActionListener; 19 21 import java.awt.event.HierarchyEvent; … … 383 385 c.setForeground(ColorHelper.getForegroundColor(background)); 384 386 } 387 388 /** 389 * Gets the size of the screen. On systems with multiple displays, the primary display is used. 390 * This method returns always 800x600 in headless mode (useful for unit tests). 391 * @return the size of this toolkit's screen, in pixels, or 800x600 392 * @see Toolkit#getScreenSize 393 * @since 9576 394 */ 395 public static Dimension getScreenSize() { 396 return GraphicsEnvironment.isHeadless() ? new Dimension(800, 600) : Toolkit.getDefaultToolkit().getScreenSize(); 397 } 398 399 /** 400 * Gets the singleton instance of the system selection as a <code>Clipboard</code> object. 401 * This allows an application to read and modify the current, system-wide selection. 402 * @return the system selection as a <code>Clipboard</code>, or <code>null</code> if the native platform does not 403 * support a system selection <code>Clipboard</code> or if GraphicsEnvironment.isHeadless() returns true 404 * @see Toolkit#getSystemSelection 405 * @since 9576 406 */ 407 public static Clipboard getSystemSelection() { 408 return GraphicsEnvironment.isHeadless() ? null : Toolkit.getDefaultToolkit().getSystemSelection(); 409 } 385 410 } -
trunk/src/org/openstreetmap/josm/gui/widgets/JosmComboBox.java
r9546 r9576 4 4 import java.awt.Component; 5 5 import java.awt.Dimension; 6 import java.awt.GraphicsEnvironment;7 import java.awt.Toolkit;8 6 import java.awt.event.MouseAdapter; 9 7 import java.awt.event.MouseEvent; … … 24 22 import javax.swing.plaf.basic.ComboPopup; 25 23 import javax.swing.text.JTextComponent; 24 25 import org.openstreetmap.josm.gui.util.GuiHelper; 26 26 27 27 /** … … 167 167 if (prototype != null) { 168 168 setPrototypeDisplayValue(prototype); 169 int screenHeight = G raphicsEnvironment.isHeadless() ? 600 : Toolkit.getDefaultToolkit().getScreenSize().height;169 int screenHeight = GuiHelper.getScreenSize().height; 170 170 // Compute maximum number of visible items based on the preferred size of the combo box. 171 171 // This assumes that items have the same height as the combo box, which is not granted by the look and feel -
trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java
r9230 r9576 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.HeadlessException; 7 import java.awt.Toolkit; 6 import java.awt.Dimension; 8 7 import java.util.HashMap; 9 8 import java.util.Map; … … 13 12 import org.openstreetmap.josm.data.coor.LatLon; 14 13 import org.openstreetmap.josm.data.projection.Ellipsoid; 14 import org.openstreetmap.josm.gui.util.GuiHelper; 15 15 16 16 public final class OsmUrlToBounds { … … 191 191 public static Bounds positionToBounds(final double lat, final double lon, final int zoom) { 192 192 int tileSizeInPixels = 256; 193 int height; 194 int width; 195 try { 196 height = Toolkit.getDefaultToolkit().getScreenSize().height; 197 width = Toolkit.getDefaultToolkit().getScreenSize().width; 198 if (Main.isDisplayingMapView()) { 199 height = Main.map.mapView.getHeight(); 200 width = Main.map.mapView.getWidth(); 201 } 202 } catch (HeadlessException he) { 203 // in headless mode, when running tests 204 height = 480; 205 width = 640; 193 Dimension screenSize = GuiHelper.getScreenSize(); 194 int height = screenSize.height; 195 int width = screenSize.width; 196 if (Main.isDisplayingMapView()) { 197 height = Main.map.mapView.getHeight(); 198 width = Main.map.mapView.getWidth(); 206 199 } 207 200 double scale = (1 << zoom) * tileSizeInPixels / (2 * Math.PI * Ellipsoid.WGS84.a); -
trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java
r9062 r9576 12 12 import java.awt.Point; 13 13 import java.awt.Rectangle; 14 import java.awt.Toolkit;15 14 import java.awt.Window; 16 15 import java.util.regex.Matcher; … … 20 19 21 20 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.gui.util.GuiHelper; 22 22 23 23 /** … … 468 468 */ 469 469 public static Rectangle getFullScreenInfo() { 470 return new Rectangle(new Point(0, 0), Toolkit.getDefaultToolkit().getScreenSize());470 return new Rectangle(new Point(0, 0), GuiHelper.getScreenSize()); 471 471 } 472 472
Note:
See TracChangeset
for help on using the changeset viewer.