Changeset 16042 in josm


Ignore:
Timestamp:
2020-03-06T00:23:31+01:00 (4 years ago)
Author:
simon04
Message:

see #18864 - TaggingPreset: use short type for numeric field

Reduces retained size of TaggingPreset from 1_758_840 to 1_750_272 (de).

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItem.java

    r15667 r16042  
    129129        final Collection<String> s = Config.getPref().getList("taggingpreset.icon.sources", null);
    130130        ImageProvider imgProv = new ImageProvider(iconName).setDirs(s).setId("presets").setArchive(zipIcons).setOptional(true);
    131         if (maxSize != null) {
     131        if (maxSize != null && maxSize > 0) {
    132132            imgProv.setMaxSize(maxSize);
    133133        }
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Check.java

    r16035 r16042  
    3838    public String icon; // NOSONAR
    3939    /** The size of displayed icon. If not set, default is 16px */
    40     public String icon_size; // NOSONAR
     40    public short icon_size = 16; // NOSONAR
    4141
    4242    private QuadStateCheckBox check;
     
    134134     */
    135135    public ImageIcon getIcon() {
    136         Integer size = parseInteger(icon_size);
    137         return icon == null ? null : loadImageIcon(icon, TaggingPresetReader.getZipIcons(), size != null ? size : 16);
     136        return icon == null ? null : loadImageIcon(icon, TaggingPresetReader.getZipIcons(), (int) icon_size);
    138137    }
    139138
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/CheckGroup.java

    r15667 r16042  
    2424     * Number of columns (positive integer)
    2525     */
    26     public String columns; // NOSONAR
     26    public short columns = 1; // NOSONAR
    2727
    2828    /**
     
    3333    @Override
    3434    public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) {
    35         Integer cols = Integer.valueOf(columns);
    36         int rows = (int) Math.ceil(checks.size()/cols.doubleValue());
    37         JPanel panel = new JPanel(new GridLayout(rows, cols));
     35        int rows = (int) Math.ceil(checks.size() / ((double) columns));
     36        JPanel panel = new JPanel(new GridLayout(rows, columns));
    3837
    3938        for (Check check : checks) {
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Combo.java

    r12859 r16042  
    2222    public boolean editable = true; // NOSONAR
    2323    /** The length of the combo box (number of characters allowed). */
    24     public String length; // NOSONAR
     24    public short length; // NOSONAR
    2525
    2626    protected JosmComboBox<PresetListEntry> combobox;
     
    5959            tf.setHint(key);
    6060        }
    61         if (length != null && !length.isEmpty()) {
    62             tf.setMaxChars(Integer.valueOf(length));
     61        if (length > 0) {
     62            tf.setMaxChars((int) length);
    6363        }
    6464        AutoCompletionList acList = tf.getAutoCompletionList();
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java

    r16040 r16042  
    218218        public String icon; // NOSONAR
    219219        /** The size of displayed icon. If not set, default is size from icon file */
    220         public String icon_size; // NOSONAR
     220        public short icon_size; // NOSONAR
    221221        /** The localized version of {@link #display_value}. */
    222222        public String locale_display_value; // NOSONAR
     
    273273         */
    274274        public ImageIcon getIcon() {
    275             return icon == null ? null : loadImageIcon(icon, TaggingPresetReader.getZipIcons(), parseInteger(icon_size));
     275            return icon == null ? null : loadImageIcon(icon, TaggingPresetReader.getZipIcons(), (int) icon_size);
    276276        }
    277277
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Label.java

    r9665 r16042  
    2121    public String icon; // NOSONAR
    2222    /** The size of displayed icon. If not set, default is 16px */
    23     public String icon_size; // NOSONAR
     23    public short icon_size = 16; // NOSONAR
    2424
    2525    @Override
     
    4545     */
    4646    public ImageIcon getIcon() {
    47         Integer size = parseInteger(icon_size);
    48         return icon == null ? null : loadImageIcon(icon, TaggingPresetReader.getZipIcons(), size != null ? size : 16);
     47        return icon == null ? null : loadImageIcon(icon, TaggingPresetReader.getZipIcons(), (int) icon_size);
    4948    }
    5049}
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/MultiSelect.java

    r11017 r16042  
    2020     * Number of rows to display (positive integer, optional).
    2121     */
    22     public String rows; // NOSONAR
     22    public short rows; // NOSONAR
    2323
    2424    protected ConcatenatingJList list;
     
    4848        // if a number of rows has been specified in the preset,
    4949        // modify preferred height of scroll pane to match that row count.
    50         if (rows != null) {
     50        if (rows > 0) {
    5151            double height = renderer.getListCellRendererComponent(list,
    52                     new PresetListEntry("x"), 0, false, false).getPreferredSize().getHeight() * Integer.parseInt(rows);
     52                    new PresetListEntry("x"), 0, false, false).getPreferredSize().getHeight() * rows;
    5353            sp.setPreferredSize(new Dimension((int) sp.getPreferredSize().getWidth(), (int) height));
    5454        }
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Roles.java

    r16041 r16042  
    5656        public boolean required; // NOSONAR
    5757        /** How often must the element appear */
    58         private long count;
     58        private short count;
    5959
    6060        public void setType(String types) throws SAXException {
     
    8989
    9090        public void setCount(String count) {
    91             this.count = Long.parseLong(count);
     91            this.count = Short.parseShort(count);
    9292        }
    9393
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Text.java

    r16035 r16042  
    5454    public String auto_increment; // NOSONAR
    5555    /** The length of the text box (number of characters allowed). */
    56     public String length; // NOSONAR
     56    public short length; // NOSONAR
    5757    /** A comma separated list of alternative keys to use for autocompletion. */
    5858    public String alternative_autocomplete_keys; // NOSONAR
     
    7474            textField.setHint(key);
    7575        }
    76         if (length != null && !length.isEmpty()) {
    77             textField.setMaxChars(Integer.valueOf(length));
     76        if (length > 0) {
     77            textField.setMaxChars((int) length);
    7878        }
    7979        if (usage.unused()) {
  • trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/CheckGroupTest.java

    r9996 r16042  
    3434    public void testAddToPanel() {
    3535        CheckGroup cg = new CheckGroup();
    36         cg.columns = "1";
    3736        JPanel p = new JPanel();
    3837        assertEquals(0, p.getComponentCount());
Note: See TracChangeset for help on using the changeset viewer.