Changeset 5484 in josm for trunk/src/org


Ignore:
Timestamp:
2012-08-30T22:38:56+02:00 (12 years ago)
Author:
Don-vip
Message:

Recently added tags: correctly select one-char-length values, properly gray out icon and text for disabled (already present) tags

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r5481 r5484  
    114114import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionListItem;
    115115import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager;
     116import org.openstreetmap.josm.gui.util.GuiHelper;
    116117import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
    117118import org.openstreetmap.josm.tools.GBC;
     
    529530        if (itemToSelect != null) {
    530531            keys.setSelectedItem(itemToSelect);
    531             /* don't add single chars, as they are no properly selected */
    532             if(lastAddValue != null && lastAddValue.length() > 1) {
     532            if (lastAddValue != null) {
    533533                values.setSelectedItem(lastAddValue);
    534534            }
     
    593593            for (int i = tags.size()-1; i >= 0 && count <= tagsToShow; i--, count++) {
    594594                final Tag t = tags.get(i);
    595                 // Find and display icon
    596                 ImageIcon icon = MapPaintStyles.getNodeIcon(t, false); // Filters deprecated icon
    597                 if (icon == null) {
    598                     icon = new ImageIcon(new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB));
    599                 }
    600                 GridBagConstraints gbc = new GridBagConstraints();
    601                 gbc.ipadx = 5;
    602                 p.add(new JLabel(icon), gbc);
    603595                // Create action for reusing the tag, with keyboard shortcut Ctrl+(1-5)
    604596                String actionShortcutKey = "properties:recent:"+count;
     
    622614                    }
    623615                }
     616                // Find and display icon
     617                ImageIcon icon = MapPaintStyles.getNodeIcon(t, false); // Filters deprecated icon
     618                if (icon == null) {
     619                    icon = new ImageIcon(new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB));
     620                }
     621                GridBagConstraints gbc = new GridBagConstraints();
     622                gbc.ipadx = 5;
     623                p.add(new JLabel(action.isEnabled() ? icon : GuiHelper.getDisabledIcon(icon)), gbc);
    624624                // Create tag label
     625                final String color = action.isEnabled() ? "" : "; color:gray";
    625626                final JLabel tagLabel = new JLabel("<html>"
    626                     + "<style>td{border:1px solid gray; font-weight:normal;}</style>"
     627                    + "<style>td{border:1px solid gray; font-weight:normal"+color+"}</style>"
    627628                    + "<table><tr><td>" + t.toString() + "</td></tr></table></html>");
    628629                if (action.isEnabled()) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapImage.java

    r5470 r5484  
    66import java.awt.Image;
    77import java.awt.Rectangle;
    8 import java.awt.Toolkit;
    98import java.awt.image.BufferedImage;
    10 import java.awt.image.FilteredImageSource;
    11 import java.awt.image.ImageProducer;
    129
    13 import javax.swing.GrayFilter;
    1410import javax.swing.ImageIcon;
    1511
     
    1713import org.openstreetmap.josm.gui.mappaint.BoxTextElemStyle.BoxProvider;
    1814import org.openstreetmap.josm.gui.mappaint.BoxTextElemStyle.BoxProviderResult;
     15import org.openstreetmap.josm.gui.util.GuiHelper;
    1916import org.openstreetmap.josm.tools.ImageProvider;
    2017import org.openstreetmap.josm.tools.ImageProvider.ImageCallback;
     
    4946        if (img == null)
    5047            getImage(); // fix #7498 ?
    51         ImageProducer ip = new FilteredImageSource(img.getSource(), new GrayFilter(true, 20));
    52         disabledImg = Toolkit.getDefaultToolkit().createImage(ip);
     48        disabledImg = GuiHelper.getDisabledImage(img);
    5349        return disabledImg;
    5450    }
  • trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java

    r5297 r5484  
    77import java.awt.Container;
    88import java.awt.Image;
     9import java.awt.Toolkit;
     10import java.awt.image.FilteredImageSource;
    911import java.lang.reflect.InvocationTargetException;
    1012
     13import javax.swing.GrayFilter;
    1114import javax.swing.Icon;
    1215import javax.swing.ImageIcon;
     
    8083        return dlg.showDialog().getValue() != 2;
    8184    }
     85   
     86    /**
     87     * Replies the disabled (grayed) version of the specified image.
     88     * @param image The image to disable
     89     * @return The disabled (grayed) version of the specified image, brightened by 20%.
     90     * @since 5484
     91     */
     92    public static final Image getDisabledImage(Image image) {
     93        return Toolkit.getDefaultToolkit().createImage(
     94                new FilteredImageSource(image.getSource(), new GrayFilter(true, 20)));
     95    }
    8296
     97    /**
     98     * Replies the disabled (grayed) version of the specified icon.
     99     * @param icon The icon to disable
     100     * @return The disabled (grayed) version of the specified icon, brightened by 20%.
     101     * @since 5484
     102     */
     103    public static final ImageIcon getDisabledIcon(ImageIcon icon) {
     104        return new ImageIcon(getDisabledImage(icon.getImage()));
     105    }
    83106}
Note: See TracChangeset for help on using the changeset viewer.