Ignore:
Timestamp:
2013-08-21T18:15:12+02:00 (13 years ago)
Author:
Don-vip
Message:

fix #8849:

  • Used scaled down (16x16 pixels) of large (.svg) images if no size is explicitely defined
  • rendering of emergency=aed with recently added svg
  • optimizations/refactoring in icons rotating/rescaling code
  • fix of various warnings, javadoc
Location:
trunk/src/org/openstreetmap/josm/gui
Files:
4 edited

Legend:

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

    r3530 r6172  
    11// License: GPL. See LICENSE file for details.
    2 
    32package org.openstreetmap.josm.gui.dialogs;
    43
     
    1110import javax.swing.JSplitPane;
    1211
    13 import org.openstreetmap.josm.gui.MultiSplitPane;
    1412import org.openstreetmap.josm.gui.MultiSplitLayout.Divider;
    1513import org.openstreetmap.josm.gui.MultiSplitLayout.Leaf;
    1614import org.openstreetmap.josm.gui.MultiSplitLayout.Node;
    1715import org.openstreetmap.josm.gui.MultiSplitLayout.Split;
    18 
    19 public class DialogsPanel extends JPanel {
     16import org.openstreetmap.josm.gui.MultiSplitPane;
     17import org.openstreetmap.josm.tools.Destroyable;
     18
     19public class DialogsPanel extends JPanel implements Destroyable {
    2020    protected List<ToggleDialog> allDialogs = new ArrayList<ToggleDialog>();
    2121    protected MultiSplitPane mSpltPane = new MultiSplitPane();
     
    292292    }
    293293
     294    @Override
    294295    public void destroy() {
    295296        for (ToggleDialog t : allDialogs) {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java

    r6170 r6172  
    1313import java.awt.GridBagLayout;
    1414import java.awt.GridLayout;
    15 import java.awt.Image;
    1615import java.awt.Rectangle;
    1716import java.awt.Toolkit;
     
    3332import javax.swing.AbstractAction;
    3433import javax.swing.BorderFactory;
    35 import javax.swing.ImageIcon;
    3634import javax.swing.JButton;
    3735import javax.swing.JCheckBoxMenuItem;
     
    462460
    463461            // scale down the dialog icon
    464             ImageIcon inIcon = ImageProvider.get("dialogs", iconName);
    465             ImageIcon smallIcon = new ImageIcon(inIcon.getImage().getScaledInstance(16 , 16, Image.SCALE_SMOOTH));
    466             lblTitle = new JLabel("",smallIcon, JLabel.TRAILING);
     462            lblTitle = new JLabel("", new ImageProvider("dialogs", iconName).setWidth(16).get(), JLabel.TRAILING);
    467463            lblTitle.setIconTextGap(8);
    468464
     
    500496            // show the pref button if applicable
    501497            if (preferenceClass != null) {
    502                 inIcon = ImageProvider.get("preference");
    503                 smallIcon = new ImageIcon(inIcon.getImage().getScaledInstance(16 , 16, Image.SCALE_SMOOTH));
    504                 JButton pref = new JButton(smallIcon);
     498                JButton pref = new JButton(new ImageProvider("preference").setWidth(16).get());
    505499                pref.setToolTipText(tr("Open preferences for this panel"));
    506500                pref.setBorder(BorderFactory.createEmptyBorder());
  • trunk/src/org/openstreetmap/josm/gui/mappaint/NodeElemStyle.java

    r5812 r6172  
    66import java.awt.BasicStroke;
    77import java.awt.Color;
     8import java.awt.Image;
    89import java.awt.Rectangle;
    910import java.awt.Stroke;
     
    1920import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference;
    2021import org.openstreetmap.josm.gui.mappaint.StyleCache.StyleList;
     22import org.openstreetmap.josm.tools.ImageProvider;
    2123import org.openstreetmap.josm.tools.Utils;
    2224
     
    2527 */
    2628public class NodeElemStyle extends ElemStyle implements StyleKeys {
    27     public MapImage mapImage;
    28     public Symbol symbol;
     29    public final MapImage mapImage;
     30    public final Symbol symbol;
     31   
     32    private Image enabledNodeIcon;
     33    private Image disabledNodeIcon;
    2934
    3035    public enum SymbolShape { SQUARE, CIRCLE, TRIANGLE, PENTAGON, HEXAGON, HEPTAGON, OCTAGON, NONAGON, DECAGON }
     
    230235    }
    231236
     237    private Image getRealNodeIcon(final Image image) {
     238        final int maxSize = 16;
     239        // Scale down large (.svg) images to 16x16 pixels if no size is explicitely specified
     240        if ((mapImage.width  == -1 && image.getWidth(null) > maxSize)
     241         || (mapImage.height == -1 && image.getHeight(null) > maxSize)) {
     242            return ImageProvider.createBoundedImage(image, maxSize);
     243        } else {
     244            return image;
     245        }
     246    }
     247   
    232248    @Override
    233249    public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings settings, StyledMapRenderer painter, boolean selected, boolean member) {
     
    235251            Node n = (Node) primitive;
    236252            if (mapImage != null && painter.isShowIcons()) {
    237                 painter.drawNodeIcon(n, (painter.isInactiveMode() || n.isDisabled()) ? mapImage.getDisabled() : mapImage.getImage(),
    238                         Utils.color_int2float(mapImage.alpha), selected, member);
     253                final Image nodeIcon;
     254                if (painter.isInactiveMode() || n.isDisabled()) {
     255                    if (disabledNodeIcon == null) {
     256                        disabledNodeIcon = getRealNodeIcon(mapImage.getDisabled());
     257                    }
     258                    nodeIcon = disabledNodeIcon;
     259                } else {
     260                    if (enabledNodeIcon == null) {
     261                        enabledNodeIcon = getRealNodeIcon(mapImage.getImage());
     262                    }
     263                    nodeIcon = enabledNodeIcon;
     264                }
     265                painter.drawNodeIcon(n, nodeIcon, Utils.color_int2float(mapImage.alpha), selected, member);
    239266            } else if (symbol != null) {
    240267                Color fillColor = symbol.fillColor;
  • trunk/src/org/openstreetmap/josm/gui/widgets/TextContextualPopupMenu.java

    r6084 r6172  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.awt.Image;
    76import java.awt.event.ActionEvent;
    87import java.beans.PropertyChangeEvent;
     
    149148            mi.setText(label);
    150149            if (iconName != null && Main.pref.getBoolean("text.popupmenu.useicons", true)) {
    151                 ImageIcon icon = ImageProvider.get(iconName);
     150                ImageIcon icon = new ImageProvider(iconName).setWidth(16).get();
    152151                if (icon != null) {
    153                     mi.setIcon(new ImageIcon(icon.getImage().getScaledInstance(16 , 16, Image.SCALE_SMOOTH)));
     152                    mi.setIcon(icon);
    154153                }
    155154            }
Note: See TracChangeset for help on using the changeset viewer.