Ticket #1586: MapPaintVisitor.java.patch

File MapPaintVisitor.java.patch, 2.1 KB (added by stephankn, 18 years ago)

corrected patch implementing functionality

  • src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java

     
    1313import java.awt.geom.GeneralPath;
    1414import java.util.Collection;
    1515import java.util.LinkedList;
     16import java.util.Locale;
    1617
    1718import javax.swing.ImageIcon;
    1819
     
    4344        protected Font orderFont;
    4445        protected ElemStyles styles;
    4546        protected double circum;
     47        protected String regionalNameOrder[];
    4648
    4749        protected boolean isZoomOk(ElemStyle e) {
    4850                if (!zoomLevelDisplay) /* show everything if the user wishes so */
     
    225227                if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight())) return;
    226228                int w = icon.getIconWidth(), h=icon.getIconHeight();
    227229                icon.paintIcon ( Main.map.mapView, g, p.x-w/2, p.y-h/2 );
    228                 String name = (n.keys==null) ? null : n.keys.get("name");
     230                String name = getNodeName(n);
    229231                if (name!=null && annotate)
    230232                {
    231233                        g.setColor(textColor);
     
    241243                }
    242244        }
    243245
     246        protected String getNodeName(Node n) {
     247                String name = null;
     248                if (n.keys != null) {
     249                        for (int i = 0; i < regionalNameOrder.length; i++) {
     250                                name = n.keys.get(regionalNameOrder[i]);
     251                                if (name != null) break;
     252                        }
     253                }
     254                return name;
     255        }
     256
    244257        private void drawSeg(Node n1, Node n2, Color col, boolean showDirection, int width, boolean dashed) {
    245258                if (col != currentColor || width != currentWidth || dashed != currentDashed) {
    246259                        displaySegments(col, width, dashed);
     
    321334                circum = Main.map.mapView.getScale()*100*Main.proj.scaleFactor()*40041455; // circumference of the earth in meter
    322335                styles = MapPaintStyles.getStyles();
    323336                orderFont = new Font(Main.pref.get("mappaint.font","Helvetica"), Font.PLAIN, Main.pref.getInteger("mappaint.fontsize", 8));
     337                String currentLocale = Locale.getDefault().getLanguage();
     338                regionalNameOrder = (Main.pref.get("mappaint.nameOrder", "name:"+currentLocale+" int_name")+" name").split("\\s");
    324339
    325340                if(styles.hasAreas())
    326341                {