Ticket #9995: hidpi_patch_3_images_progress.patch
File hidpi_patch_3_images_progress.patch, 22.1 KB (added by , 9 years ago) |
---|
-
src/org/openstreetmap/josm/actions/AboutAction.java
102 102 // Intermediate panel to allow proper optionPane resizing 103 103 JPanel panel = new JPanel(new GridBagLayout()); 104 104 panel.setPreferredSize(new Dimension(890, 300)); 105 panel.add(new JLabel("", new ImageProvider("logo.svg").setSize(ImageProvider.ImageSizes.ABOUT_LOGO).get(),105 panel.add(new JLabel("", ImageProvider.get("logo.svg", ImageProvider.ImageSizes.ABOUT_LOGO), 106 106 JLabel.CENTER), GBC.std().insets(0, 5, 0, 0)); 107 107 panel.add(about, GBC.std().fill()); 108 108 -
src/org/openstreetmap/josm/actions/mapmode/AddNoteAction.java
69 69 Main.map.selectMapMode(Main.map.mapModeSelect); 70 70 71 71 NoteInputDialog dialog = new NoteInputDialog(Main.parent, tr("Create new note"), tr("Create note")); 72 dialog.showNoteDialog(tr("Enter a detailed comment to create a note"), NotesDialog.ICON_NEW);72 dialog.showNoteDialog(tr("Enter a detailed comment to create a note"), ImageProvider.get("dialogs/notes", "note_new")); 73 73 74 74 if (dialog.getValue() != 1) { 75 75 Main.debug("User aborted note creation"); -
src/org/openstreetmap/josm/gui/SideButton.java
55 55 * @since 2710 56 56 */ 57 57 public SideButton(Action action, boolean usename) { 58 super(action);58 this(action); 59 59 if (!usename) { 60 60 setText(null); 61 fixIcon(action);62 doStyle();63 61 } 64 62 } 65 63 … … 71 69 */ 72 70 public SideButton(Action action, String imagename) { 73 71 super(action); 74 ImageProvider prov = new ImageProvider("dialogs", imagename); 75 setIcon(prov.setSize(ImageProvider.ImageSizes.SIDEBUTTON).get()); 72 setIcon(ImageProvider.get("dialogs", imagename, ImageProvider.ImageSizes.SIDEBUTTON)); 76 73 doStyle(); 77 74 } 78 75 -
src/org/openstreetmap/josm/gui/SplashScreen.java
67 67 contentPane.add(innerContentPane); 68 68 69 69 // Add the logo 70 JLabel logo = new JLabel( new ImageProvider("logo.svg").setSize(ImageProvider.ImageSizes.SPLASH_LOGO).get());70 JLabel logo = new JLabel(ImageProvider.get("logo.svg", ImageProvider.ImageSizes.SPLASH_LOGO)); 71 71 GridBagConstraints gbc = new GridBagConstraints(); 72 72 gbc.gridheight = 2; 73 73 gbc.insets = new Insets(0, 0, 0, 70); -
src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java
5 5 6 6 import java.awt.BorderLayout; 7 7 import java.awt.Component; 8 import java.awt.Image;9 8 import java.awt.event.ActionEvent; 10 9 import java.awt.event.MouseAdapter; 11 10 import java.awt.event.MouseEvent; … … 56 55 */ 57 56 public class NotesDialog extends ToggleDialog implements LayerChangeListener { 58 57 59 /** Small icon size for use in graphics calculations */60 public static final int ICON_SMALL_SIZE = 16;61 /** 24x24 icon for unresolved notes */62 public static final ImageIcon ICON_OPEN = ImageProvider.get("dialogs/notes", "note_open");63 /** 16x16 icon for unresolved notes */64 public static final ImageIcon ICON_OPEN_SMALL =65 new ImageIcon(ICON_OPEN.getImage().getScaledInstance(ICON_SMALL_SIZE, ICON_SMALL_SIZE, Image.SCALE_SMOOTH));66 /** 24x24 icon for resolved notes */67 public static final ImageIcon ICON_CLOSED = ImageProvider.get("dialogs/notes", "note_closed");68 /** 16x16 icon for resolved notes */69 public static final ImageIcon ICON_CLOSED_SMALL =70 new ImageIcon(ICON_CLOSED.getImage().getScaledInstance(ICON_SMALL_SIZE, ICON_SMALL_SIZE, Image.SCALE_SMOOTH));71 /** 24x24 icon for new notes */72 public static final ImageIcon ICON_NEW = ImageProvider.get("dialogs/notes", "note_new");73 /** 16x16 icon for new notes */74 public static final ImageIcon ICON_NEW_SMALL =75 new ImageIcon(ICON_NEW.getImage().getScaledInstance(ICON_SMALL_SIZE, ICON_SMALL_SIZE, Image.SCALE_SMOOTH));76 /** Icon for note comments */77 public static final ImageIcon ICON_COMMENT = ImageProvider.get("dialogs/notes", "note_comment");78 79 58 private NoteTableModel model; 80 59 private JList<Note> displayList; 81 60 private final AddCommentAction addCommentAction; … … 256 235 } 257 236 ImageIcon icon; 258 237 if (note.getId() < 0) { 259 icon = I CON_NEW_SMALL;238 icon = ImageProvider.get("dialogs/notes", "note_new", ImageProvider.ImageSizes.SMALLICON); 260 239 } else if (note.getState() == State.CLOSED) { 261 icon = I CON_CLOSED_SMALL;240 icon = ImageProvider.get("dialogs/notes", "note_closed", ImageProvider.ImageSizes.SMALLICON); 262 241 } else { 263 icon = I CON_OPEN_SMALL;242 icon = ImageProvider.get("dialogs/notes", "note_open", ImageProvider.ImageSizes.SMALLICON); 264 243 } 265 244 jlabel.setIcon(icon); 266 245 } … … 312 291 AddCommentAction() { 313 292 putValue(SHORT_DESCRIPTION, tr("Add comment")); 314 293 putValue(NAME, tr("Comment")); 315 putValue(SMALL_ICON, I CON_COMMENT);294 putValue(SMALL_ICON, ImageProvider.get("dialogs/notes", "note_comment")); 316 295 } 317 296 318 297 @Override … … 326 305 return; 327 306 } 328 307 NoteInputDialog dialog = new NoteInputDialog(Main.parent, tr("Comment on note"), tr("Add comment")); 329 dialog.showNoteDialog(tr("Add comment to note:"), NotesDialog.ICON_COMMENT);308 dialog.showNoteDialog(tr("Add comment to note:"), ImageProvider.get("dialogs/notes", "note_comment")); 330 309 if (dialog.getValue() != 1) { 331 310 return; 332 311 } … … 344 323 CloseAction() { 345 324 putValue(SHORT_DESCRIPTION, tr("Close note")); 346 325 putValue(NAME, tr("Close")); 347 putValue(SMALL_ICON, I CON_CLOSED);326 putValue(SMALL_ICON, ImageProvider.get("dialogs/notes", "note_closed")); 348 327 } 349 328 350 329 @Override 351 330 public void actionPerformed(ActionEvent e) { 352 331 NoteInputDialog dialog = new NoteInputDialog(Main.parent, tr("Close note"), tr("Close note")); 353 dialog.showNoteDialog(tr("Close note with message:"), NotesDialog.ICON_CLOSED);332 dialog.showNoteDialog(tr("Close note with message:"), ImageProvider.get("dialogs/notes", "note_closed")); 354 333 if (dialog.getValue() != 1) { 355 334 return; 356 335 } … … 369 348 NewAction() { 370 349 putValue(SHORT_DESCRIPTION, tr("Create a new note")); 371 350 putValue(NAME, tr("Create")); 372 putValue(SMALL_ICON, I CON_NEW);351 putValue(SMALL_ICON, ImageProvider.get("dialogs/notes", "note_new")); 373 352 } 374 353 375 354 @Override … … 389 368 ReopenAction() { 390 369 putValue(SHORT_DESCRIPTION, tr("Reopen note")); 391 370 putValue(NAME, tr("Reopen")); 392 putValue(SMALL_ICON, I CON_OPEN);371 putValue(SMALL_ICON, ImageProvider.get("dialogs/notes", "note_open")); 393 372 } 394 373 395 374 @Override 396 375 public void actionPerformed(ActionEvent e) { 397 376 NoteInputDialog dialog = new NoteInputDialog(Main.parent, tr("Reopen note"), tr("Reopen note")); 398 dialog.showNoteDialog(tr("Reopen note with message:"), NotesDialog.ICON_OPEN);377 dialog.showNoteDialog(tr("Reopen note with message:"), ImageProvider.get("dialogs/notes", "note_open")); 399 378 if (dialog.getValue() != 1) { 400 379 return; 401 380 } -
src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
506 506 add(lblMinimized); 507 507 508 508 // scale down the dialog icon 509 ImageIcon icon = new ImageProvider("dialogs", iconName).setSize(ImageProvider.ImageSizes.SMALLICON).get();509 ImageIcon icon = ImageProvider.get("dialogs", iconName, ImageProvider.ImageSizes.SMALLICON); 510 510 lblTitle = new JLabel("", icon, JLabel.TRAILING); 511 511 lblTitle.setIconTextGap(8); 512 512 … … 544 544 545 545 // show the pref button if applicable 546 546 if (preferenceClass != null) { 547 JButton pref = new JButton( new ImageProvider("preference").setSize(ImageProvider.ImageSizes.SMALLICON).get());547 JButton pref = new JButton(ImageProvider.get("preference", ImageProvider.ImageSizes.SMALLICON)); 548 548 pref.setToolTipText(tr("Open preferences for this panel")); 549 549 pref.setBorder(BorderFactory.createEmptyBorder()); 550 550 pref.addActionListener( -
src/org/openstreetmap/josm/gui/io/RecentlyOpenedFilesMenu.java
32 32 public RecentlyOpenedFilesMenu() { 33 33 super(tr("Open Recent")); 34 34 setToolTipText(tr("List of recently opened files")); 35 setIcon( new ImageProvider("openrecent").setSize(ImageProvider.ImageSizes.MENU).get());35 setIcon(ImageProvider.get("openrecent", ImageProvider.ImageSizes.MENU)); 36 36 putClientProperty("help", ht("/Action/OpenRecent")); 37 37 38 38 // build dynamically -
src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java
385 385 private static final String BASE_ICON = "BASE_ICON"; 386 386 private final transient Image save = ImageProvider.get("save").getImage(); 387 387 private final transient Image upld = ImageProvider.get("upload").getImage(); 388 private final transient Image saveDis = new BufferedImage(ICON_SIZE, ICON_SIZE, BufferedImage.TYPE_4BYTE_ABGR);389 private final transient Image upldDis = new BufferedImage(ICON_SIZE, ICON_SIZE, BufferedImage.TYPE_4BYTE_ABGR);388 private final transient Image saveDis = new ImageProvider("save").setDisabled(true).get().getImage(); 389 private final transient Image upldDis = new ImageProvider("upload").setDisabled(true).get().getImage(); 390 390 391 391 SaveAndProceedAction() { 392 // get disabled versions of icons393 new JLabel(ImageProvider.get("save")).getDisabledIcon().paintIcon(new JPanel(), saveDis.getGraphics(), 0, 0);394 new JLabel(ImageProvider.get("upload")).getDisabledIcon().paintIcon(new JPanel(), upldDis.getGraphics(), 0, 0);395 392 initForSaveAndExit(); 396 393 } 397 394 -
src/org/openstreetmap/josm/gui/layer/NoteLayer.java
36 36 import org.openstreetmap.josm.gui.io.AbstractIOTask; 37 37 import org.openstreetmap.josm.gui.io.UploadNoteLayerTask; 38 38 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 39 import org.openstreetmap.josm.gui.util.GuiSizesHelper; 39 40 import org.openstreetmap.josm.io.NoteExporter; 40 41 import org.openstreetmap.josm.io.OsmApi; 41 42 import org.openstreetmap.josm.io.XmlWriter; 42 43 import org.openstreetmap.josm.tools.ColorHelper; 44 import org.openstreetmap.josm.tools.ImageProvider; 43 45 import org.openstreetmap.josm.tools.Utils; 44 46 import org.openstreetmap.josm.tools.date.DateUtils; 45 47 … … 106 108 107 109 @Override 108 110 public void paint(Graphics2D g, MapView mv, Bounds box) { 111 final int iconHeight = GuiSizesHelper.getSizeDpiAdjusted( ImageProvider.ImageSizes.SMALLICON.getVirtualHeight() ); 112 final int iconWidth = GuiSizesHelper.getSizeDpiAdjusted( ImageProvider.ImageSizes.SMALLICON.getVirtualWidth() ); 113 109 114 for (Note note : noteData.getNotes()) { 110 115 Point p = mv.getPoint(note.getLatLon()); 111 116 112 117 ImageIcon icon; 113 118 if (note.getId() < 0) { 114 icon = NotesDialog.ICON_NEW_SMALL;119 icon = ImageProvider.get("dialogs/notes", "note_new", ImageProvider.ImageSizes.SMALLICON); 115 120 } else if (note.getState() == State.CLOSED) { 116 icon = NotesDialog.ICON_CLOSED_SMALL;121 icon = ImageProvider.get("dialogs/notes", "note_closed", ImageProvider.ImageSizes.SMALLICON); 117 122 } else { 118 icon = NotesDialog.ICON_OPEN_SMALL;123 icon = ImageProvider.get("dialogs/notes", "note_open", ImageProvider.ImageSizes.SMALLICON); 119 124 } 120 125 int width = icon.getIconWidth(); 121 126 int height = icon.getIconHeight(); … … 150 155 Point p = mv.getPoint(noteData.getSelectedNote().getLatLon()); 151 156 152 157 g.setColor(ColorHelper.html2color(Main.pref.get("color.selected"))); 153 g.drawRect(p.x - ( NotesDialog.ICON_SMALL_SIZE / 2), p.y - NotesDialog.ICON_SMALL_SIZE,154 NotesDialog.ICON_SMALL_SIZE - 1, NotesDialog.ICON_SMALL_SIZE- 1);158 g.drawRect(p.x - (iconWidth / 2), p.y - iconHeight, 159 iconWidth - 1, iconHeight - 1); 155 160 156 int tx = p.x + ( NotesDialog.ICON_SMALL_SIZE/ 2) + 5;157 int ty = p.y - NotesDialog.ICON_SMALL_SIZE- 1;161 int tx = p.x + (iconWidth / 2) + 5; 162 int ty = p.y - iconHeight - 1; 158 163 g.translate(tx, ty); 159 164 160 165 //Carried over from the OSB plugin. Not entirely sure why it is needed … … 179 184 180 185 @Override 181 186 public Icon getIcon() { 182 return NotesDialog.ICON_OPEN_SMALL;187 return ImageProvider.get("dialogs/notes", "note_open", ImageProvider.ImageSizes.SMALLICON); 183 188 } 184 189 185 190 @Override … … 242 247 Point clickPoint = e.getPoint(); 243 248 double snapDistance = 10; 244 249 double minDistance = Double.MAX_VALUE; 250 final int iconHeight = GuiSizesHelper.getSizeDpiAdjusted( ImageProvider.ImageSizes.SMALLICON.getVirtualHeight() ); 245 251 Note closestNote = null; 246 252 for (Note note : noteData.getNotes()) { 247 253 Point notePoint = Main.map.mapView.getPoint(note.getLatLon()); 248 254 //move the note point to the center of the icon where users are most likely to click when selecting 249 notePoint.setLocation(notePoint.getX(), notePoint.getY() - NotesDialog.ICON_SMALL_SIZE/ 2);255 notePoint.setLocation(notePoint.getX(), notePoint.getY() - iconHeight / 2); 250 256 double dist = clickPoint.distanceSq(notePoint); 251 257 if (minDistance > dist && clickPoint.distance(notePoint) < snapDistance) { 252 258 minDistance = dist; -
src/org/openstreetmap/josm/gui/mappaint/MapPaintMenu.java
85 85 */ 86 86 public MapPaintMenu() { 87 87 super(tr("Map Paint Styles")); 88 setIcon( new ImageProvider("dialogs", "mapstyle").setSize(ImageProvider.ImageSizes.MENU).get());88 setIcon(ImageProvider.get("dialogs", "mapstyle", ImageProvider.ImageSizes.MENU)); 89 89 MapPaintStyles.addMapPaintSylesUpdateListener(this); 90 90 putClientProperty("help", ht("/Dialog/MapPaint")); 91 91 } -
src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
511 511 ImageIcon icon = null; 512 512 513 513 if (iconName != null && !iconName.isEmpty()) { 514 icon = new ImageProvider("preferences", iconName).setSize(ImageProvider.ImageSizes.SETTINGS_TAB).get();514 icon = ImageProvider.get("preferences", iconName, ImageProvider.ImageSizes.SETTINGS_TAB); 515 515 } 516 516 if (settingsInitialized.contains(tps)) { 517 517 // If it has been initialized, add corresponding tab(s) -
src/org/openstreetmap/josm/gui/widgets/TextContextualPopupMenu.java
179 179 JMenuItem mi = new JMenuItem(action); 180 180 mi.setText(label); 181 181 if (iconName != null && Main.pref.getBoolean("text.popupmenu.useicons", true)) { 182 ImageIcon icon = new ImageProvider(iconName).setSize(ImageProvider.ImageSizes.SMALLICON).get();182 ImageIcon icon = ImageProvider.get(iconName, ImageProvider.ImageSizes.SMALLICON); 183 183 if (icon != null) { 184 184 mi.setIcon(icon); 185 185 } -
src/org/openstreetmap/josm/tools/ImageProvider.java
53 53 import javax.imageio.ImageReader; 54 54 import javax.imageio.metadata.IIOMetadata; 55 55 import javax.imageio.stream.ImageInputStream; 56 import javax.swing.Icon; 56 57 import javax.swing.ImageIcon; 58 import javax.swing.JPanel; 59 import javax.swing.UIManager; 57 60 import javax.xml.bind.DatatypeConverter; 58 61 59 62 import org.openstreetmap.josm.Main; … … 271 274 protected Collection<ClassLoader> additionalClassLoaders; 272 275 /** ordered list of overlay images */ 273 276 protected List<ImageOverlay> overlayInfo; 277 /** <code>true</code> if icon must be grayed out */ 278 protected boolean isDisabled = false; 274 279 275 280 private static SVGUniverse svgUniverse; 276 281 … … 600 605 } 601 606 602 607 /** 608 * Set, if image must be filtered to grayscale so it will look like disabled icon. 609 * 610 * @param disabled true, if image must be grayed out for disabled state 611 * @return the current object, for convenience 612 */ 613 public ImageProvider setDisabled(boolean disabled) { 614 this.isDisabled = disabled; 615 return this; 616 } 617 618 public Boolean getDisabled() { 619 return this.isDisabled; 620 } 621 622 /** 603 623 * Execute the image request and scale result. 604 624 * @return the requested image or null if the request failed 605 625 */ 606 626 public ImageIcon get() { 607 627 ImageResource ir = getResource(); 608 if (ir == null) 628 ImageIcon icon; 629 630 if (ir == null) { 609 631 return null; 632 } 610 633 if (virtualMaxWidth != -1 || virtualMaxHeight != -1) 611 returnir.getImageIconBounded(new Dimension(virtualMaxWidth, virtualMaxHeight));634 icon = ir.getImageIconBounded(new Dimension(virtualMaxWidth, virtualMaxHeight)); 612 635 else 613 return ir.getImageIcon(new Dimension(virtualWidth, virtualHeight)); 636 icon = ir.getImageIcon(new Dimension(virtualWidth, virtualHeight)); 637 638 if (isDisabled) { 639 //Use default Swing functionality to make icon look disabled by applying grayscaling filter. 640 Icon disabledIcon = UIManager.getLookAndFeel().getDisabledIcon(null, icon); 641 642 //Convert Icon to ImageIcon with BufferedImage inside 643 Image disabledImage = new BufferedImage(disabledIcon.getIconWidth(), disabledIcon.getIconHeight(), BufferedImage.TYPE_4BYTE_ABGR); 644 disabledIcon.paintIcon(new JPanel(), disabledImage.getGraphics(), 0, 0); 645 icon = new ImageIcon(disabledImage); 646 } 647 648 return icon; 614 649 } 615 650 616 651 /** … … 706 741 } 707 742 708 743 /** 744 * Load an image from directory with a given file name and size. 745 * 746 * @param subdir subdirectory the image lies in 747 * @param name The icon name (base name with or without '.png' or '.svg' extension) 748 * @param size Target icon size 749 * @return The requested Image. 750 * @throws RuntimeException if the image cannot be located 751 */ 752 public static ImageIcon get(String subdir, String name, ImageSizes size) { 753 return new ImageProvider(subdir, name).setSize(size).get(); 754 } 755 756 /** 709 757 * Load an empty image with a given size. 710 758 * 711 759 * @param size Target icon size … … 730 778 } 731 779 732 780 /** 781 * Load an image with a given file name and size. 782 * 783 * @param name The icon name (base name with or without '.png' or '.svg' extension) 784 * @param size Target icon size 785 * @return the requested image or null if the request failed 786 * @see #get(String, String) 787 */ 788 public static ImageIcon get(String name, ImageSizes size) { 789 return new ImageProvider(name).setSize(size).get(); 790 } 791 792 /** 733 793 * Load an image with a given file name, but do not throw an exception 734 794 * when the image cannot be found. 735 795 *