Ignore:
Timestamp:
2023-08-15T15:56:22+02:00 (11 months ago)
Author:
stoecker
Message:

move nodes count into own function, so it can be changed in a sub class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/DefaultNameFormatter.java

    r18795 r18808  
    166166            name.append(tr(" [v{0}]", version));
    167167        }
     168    }
     169
     170    /**
     171     * Decorates the name of primitive with nodes count
     172     *
     173     * @param name the name without the nodes count
     174     * @param primitive the primitive
     175     * @since 18808
     176     */
     177    protected void decorateNameWithNodes(StringBuilder name, IWay way) {
     178        char mark;
     179        // If current language is left-to-right (almost all languages)
     180        if (ComponentOrientation.getOrientation(Locale.getDefault()).isLeftToRight()) {
     181            // will insert Left-To-Right Mark to ensure proper display of text in the case when object name is right-to-left
     182            mark = '\u200E';
     183        } else {
     184            // otherwise will insert Right-To-Left Mark to ensure proper display in the opposite case
     185            mark = '\u200F';
     186        }
     187        int nodesNo = way.getRealNodesCount();
     188        /* note: length == 0 should no longer happen, but leave the bracket code
     189            nevertheless, who knows what future brings */
     190        /* I18n: count of nodes as parameter */
     191        String nodes = trn("{0} node", "{0} nodes", nodesNo, nodesNo);
     192        name.append(mark).append(" (").append(nodes).append(')');
    168193    }
    169194
     
    273298            }
    274299
    275             int nodesNo = way.getRealNodesCount();
    276             /* note: length == 0 should no longer happen, but leave the bracket code
    277                nevertheless, who knows what future brings */
    278             /* I18n: count of nodes as parameter */
    279             String nodes = trn("{0} node", "{0} nodes", nodesNo, nodesNo);
    280             name.append(mark).append(" (").append(nodes).append(')');
     300            decorateNameWithNodes(name, way);
    281301        }
    282302        decorateNameWithId(name, way);
Note: See TracChangeset for help on using the changeset viewer.