Ignore:
Timestamp:
2014-01-03T04:51:04+01:00 (11 years ago)
Author:
Don-vip
Message:

fix some Sonar issues

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/bbox/SourceButton.java

    r6539 r6603  
    2424public class SourceButton extends JComponent {
    2525
    26     private final int layerHeight = 20;
    27     private final int leftPadding = 5;
    28     private final int topPadding = 5;
    29     private final int bottomPadding = 5;
    30 
     26    private static final int LAYER_HEIGHT = 20;
     27    private static final int LEFT_PADDING = 5;
     28    private static final int TOP_PADDING = 5;
     29    private static final int BOTTOM_PADDING = 5;
    3130
    3231    private TileSource[] sources;
     
    4746
    4847    public SourceButton(SlippyMapBBoxChooser slippyMapBBoxChooser, Collection<TileSource> sources) {
    49         super();
    5048        this.slippyMapBBoxChooser = slippyMapBBoxChooser;
    5149        setSources(sources);
     
    6866                        toggle();
    6967                    } else {
    70                         int result = (point.y - 5) / layerHeight;
     68                        int result = (point.y - 5) / LAYER_HEIGHT;
    7169                        if (result >= 0 && result < SourceButton.this.sources.length) {
    7270                            SourceButton.this.slippyMapBBoxChooser.toggleMapSource(SourceButton.this.sources[result]);
     
    7876                    toggle();
    7977                }
    80 
    8178            }
    8279        }
     
    105102
    106103                g.setColor(new Color(0, 0, 139, 179));
    107                 g.fillRoundRect(0, 0, barWidth + shrinkImage.getIconWidth(), sources.length * layerHeight + topPadding + bottomPadding, 10, 10);
     104                g.fillRoundRect(0, 0, barWidth + shrinkImage.getIconWidth(), sources.length * LAYER_HEIGHT + TOP_PADDING + BOTTOM_PADDING, 10, 10);
    108105                for (int i=0; i<sources.length; i++) {
    109106                    g.setColor(Color.WHITE);
    110                     g.fillOval(leftPadding, topPadding + i * layerHeight + 6, radioButtonSize, radioButtonSize);
    111                     g.drawString(sources[i].getName(), leftPadding + radioButtonSize + leftPadding, topPadding + i * layerHeight + g.getFontMetrics().getHeight());
     107                    g.fillOval(LEFT_PADDING, TOP_PADDING + i * LAYER_HEIGHT + 6, radioButtonSize, radioButtonSize);
     108                    g.drawString(sources[i].getName(), LEFT_PADDING + radioButtonSize + LEFT_PADDING, TOP_PADDING + i * LAYER_HEIGHT + g.getFontMetrics().getHeight());
    112109                    if (currentMap == i) {
    113110                        g.setColor(Color.BLACK);
    114                         g.fillOval(leftPadding + 1, topPadding + 7 + i * layerHeight, radioButtonSize - 2, radioButtonSize - 2);
     111                        g.fillOval(LEFT_PADDING + 1, TOP_PADDING + 7 + i * LAYER_HEIGHT, radioButtonSize - 2, radioButtonSize - 2);
    115112                    }
    116113                }
     
    155152            }
    156153            barWidth = textWidth + 50;
    157             shownDimension = new Dimension(barWidth + shrinkImage.getIconWidth(), sources.length * layerHeight + topPadding + bottomPadding);
     154            shownDimension = new Dimension(barWidth + shrinkImage.getIconWidth(), sources.length * LAYER_HEIGHT + TOP_PADDING + BOTTOM_PADDING);
    158155        }
    159156    }
Note: See TracChangeset for help on using the changeset viewer.