Changeset 11508 in josm


Ignore:
Timestamp:
2017-01-29T04:29:01+01:00 (9 months ago)
Author:
Don-vip
Message:

fix #14282 - add robustness to GPX settings panel (patch by kidelo)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/GPXSettingsPanel.java

    r11483 r11508  
    77import java.awt.Color;
    88import java.awt.Component;
     9import java.awt.Dimension;
    910import java.awt.GridBagLayout;
    1011import java.awt.event.ActionListener;
     
    281282
    282283        colorTypeHeatMapTune.addPropertyChangeListener(e -> {
    283             // get image size of environment
    284             final int iconSize = (int) colorTypeHeatMapTune.getPreferredSize().getHeight();
    285             // ask the GPX draw for the correct color of that layer
    286             final Color color = GpxDrawHelper.DEFAULT_COLOR.getChildColor(layerName != null ? layerName : "").get();
    287             colorTypeHeatIconLabel.setIcon(GpxDrawHelper.getColorMapImageIcon(color, colorTypeHeatMapTune.getSelectedIndex(), iconSize));
     284            final Dimension dim = colorTypeHeatMapTune.getPreferredSize();
     285            if (null != dim) {
     286                // get image size of environment
     287                final int iconSize = (int) dim.getHeight();
     288                final Color color;
     289                // ask the GPX draw for the correct color of that layer ( if there is one )
     290                if (null != layerName) {
     291                    color = GpxDrawHelper.DEFAULT_COLOR.getChildColor(layerName).get();
     292                } else {
     293                    color = GpxDrawHelper.DEFAULT_COLOR.getDefaultValue();
     294                }
     295                colorTypeHeatIconLabel.setIcon(GpxDrawHelper.getColorMapImageIcon(color, colorTypeHeatMapTune.getSelectedIndex(), iconSize));
     296            }
    288297        });
    289298
Note: See TracChangeset for help on using the changeset viewer.