Changeset 1990 in josm


Ignore:
Timestamp:
Aug 23, 2009 10:37:39 PM (4 years ago)
Author:
Gubaer
Message:

fixed #3261: Use the "name:$CURRENT_LOCALE" name in the JOSM UI instead of "name" when it exists
new: new checkbox in LAF preferences for enabling/disabling localized names for primitives

Location:
trunk/src/org/openstreetmap/josm
Files:
3 added
1 deleted
34 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/Main.java

    r1895 r1990  
    3434import org.openstreetmap.josm.data.Preferences; 
    3535import org.openstreetmap.josm.data.UndoRedoHandler; 
     36import org.openstreetmap.josm.data.coor.CoordinateFormat; 
    3637import org.openstreetmap.josm.data.osm.DataSet; 
    3738import org.openstreetmap.josm.data.projection.Mercator; 
     
    330331        UIManager.put("OptionPane.noIcon", UIManager.get("OptionPane.cancelIcon")); 
    331332 
     333        // init default coordinate format 
     334        // 
     335        try { 
     336            CoordinateFormat format = CoordinateFormat.valueOf(Main.pref.get("coordinates")); 
     337            CoordinateFormat.setCoordinateFormat(CoordinateFormat.valueOf(Main.pref.get("coordinates"))); 
     338        } catch (IllegalArgumentException iae) { 
     339            CoordinateFormat.setCoordinateFormat(CoordinateFormat.DECIMAL_DEGREES); 
     340        } 
     341 
     342 
    332343        Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize(); 
    333344        String geometry = Main.pref.get("gui.geometry"); 
  • trunk/src/org/openstreetmap/josm/actions/DownloadReferrersAction.java

    r1847 r1990  
    1818import org.openstreetmap.josm.data.osm.OsmPrimitive; 
    1919import org.openstreetmap.josm.data.osm.visitor.MergeVisitor; 
     20import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    2021import org.openstreetmap.josm.gui.OptionPaneUtil; 
    2122import org.openstreetmap.josm.gui.PleaseWaitRunnable; 
     
    147148                    if (cancelled) 
    148149                        return; 
    149                     progressMonitor.subTask(tr("({0}/{1}) Loading parents of primitive {2}", i+1,primitives.size(), primitive.getName())); 
     150                    progressMonitor.subTask(tr("({0}/{1}) Loading parents of primitive {2}", i+1,primitives.size(), primitive.getDisplayName(DefaultNameFormatter.getInstance()))); 
    150151                    downloadParents(primitive, progressMonitor.createSubTaskMonitor(1, false)); 
    151152                    i++; 
  • trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java

    r1951 r1990  
    3131import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor; 
    3232import org.openstreetmap.josm.data.osm.visitor.Visitor; 
     33import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    3334import org.openstreetmap.josm.gui.OptionPaneUtil; 
    34 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 
    3535import org.openstreetmap.josm.tools.Shortcut; 
    3636 
     
    357357        Main.main.undoRedo.add( 
    358358                new SequenceCommand(tr("Split way {0} into {1} parts", 
    359                         new PrimitiveNameFormatter().getName(selectedWay), wayChunks.size()), 
     359                        selectedWay.getDisplayName(DefaultNameFormatter.getInstance()), 
     360                        wayChunks.size()), 
    360361                        commandList)); 
    361362        getCurrentDataSet().setSelected(newSelection); 
  • trunk/src/org/openstreetmap/josm/command/AddCommand.java

    r1989 r1990  
    1313import org.openstreetmap.josm.data.osm.OsmPrimitive; 
    1414import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 
    15 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 
     15import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    1616import org.openstreetmap.josm.gui.layer.OsmDataLayer; 
    1717import org.openstreetmap.josm.tools.ImageProvider; 
     
    7373                new JLabel( 
    7474                        tr(msg, 
    75                                 new PrimitiveNameFormatter().getName(osm) 
     75                                osm.getDisplayName(DefaultNameFormatter.getInstance()) 
    7676                        ), 
    7777                        ImageProvider.get(OsmPrimitiveType.from(osm)), 
  • trunk/src/org/openstreetmap/josm/command/ChangeCommand.java

    r1989 r1990  
    1313import org.openstreetmap.josm.data.osm.OsmPrimitive; 
    1414import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 
    15 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 
     15import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    1616import org.openstreetmap.josm.tools.ImageProvider; 
    1717 
     
    5353        return new DefaultMutableTreeNode( 
    5454                new JLabel(tr(msg, 
    55                         new PrimitiveNameFormatter().getName(osm)), 
     55                        osm.getDisplayName(DefaultNameFormatter.getInstance()), 
    5656                        ImageProvider.get(OsmPrimitiveType.from(osm)), 
    57                         JLabel.HORIZONTAL)); 
     57                        JLabel.HORIZONTAL))); 
    5858    } 
    5959} 
  • trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java

    r1989 r1990  
    22package org.openstreetmap.josm.command; 
    33 
     4import static org.openstreetmap.josm.tools.I18n.marktr; 
    45import static org.openstreetmap.josm.tools.I18n.tr; 
    5 import static org.openstreetmap.josm.tools.I18n.marktr; 
    66import static org.openstreetmap.josm.tools.I18n.trn; 
    77 
     
    1616import org.openstreetmap.josm.data.osm.OsmPrimitive; 
    1717import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 
    18 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 
     18import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    1919import org.openstreetmap.josm.tools.ImageProvider; 
    2020 
     
    9595    @Override public MutableTreeNode description() { 
    9696        String text; 
    97         PrimitiveNameFormatter formatter = new PrimitiveNameFormatter(); 
    9897        if (objects.size() == 1) { 
    9998            OsmPrimitive primitive = objects.iterator().next(); 
    100             String name = formatter.getName(primitive); 
    10199            String msg = ""; 
    102100            if (value == null) { 
     
    106104                case RELATION: msg = marktr("Remove \"{0}\" for relation ''{1}''"); break; 
    107105                } 
    108                 text = tr(msg, key, name); 
     106                text = tr(msg, key, primitive.getDisplayName(DefaultNameFormatter.getInstance())); 
    109107            } else { 
    110108                switch(OsmPrimitiveType.from(primitive)) { 
     
    113111                case RELATION: msg = marktr("Set {0}={1} for relation ''{2}''"); break; 
    114112                } 
    115                 text = tr(msg, key, value, name); 
     113                text = tr(msg, key, value, primitive.getDisplayName(DefaultNameFormatter.getInstance())); 
    116114            } 
    117115        } 
     
    128126            root.add(new DefaultMutableTreeNode( 
    129127                    new JLabel( 
    130                             formatter.getName(osm), 
     128                            osm.getDisplayName(DefaultNameFormatter.getInstance()), 
    131129                            ImageProvider.get(OsmPrimitiveType.from(osm)), 
    132130                            JLabel.HORIZONTAL) 
  • trunk/src/org/openstreetmap/josm/command/ChangeRelationMemberRoleCommand.java

    r1930 r1990  
    1414import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 
    1515import org.openstreetmap.josm.data.osm.Relation; 
    16 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 
     16import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    1717import org.openstreetmap.josm.tools.ImageProvider; 
    1818 
     
    7070                        tr("Change relation member role for {0} {1}", 
    7171                                OsmPrimitiveType.from(relation), 
    72                                 new PrimitiveNameFormatter().getName(relation) 
     72                                relation.getDisplayName(DefaultNameFormatter.getInstance()) 
    7373                        ), 
    7474                        ImageProvider.get(OsmPrimitiveType.from(relation)), 
  • trunk/src/org/openstreetmap/josm/command/ConflictAddCommand.java

    r1857 r1990  
    88import javax.swing.JLabel; 
    99import javax.swing.JOptionPane; 
    10 import javax.swing.text.html.Option; 
    1110import javax.swing.tree.DefaultMutableTreeNode; 
    1211import javax.swing.tree.MutableTreeNode; 
     
    1615import org.openstreetmap.josm.data.osm.OsmPrimitive; 
    1716import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 
     17import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    1818import org.openstreetmap.josm.gui.OptionPaneUtil; 
    19 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 
    2019import org.openstreetmap.josm.gui.layer.OsmDataLayer; 
    2120import org.openstreetmap.josm.tools.ImageProvider; 
     
    3635                        + "This conflict can't be added.</html>", 
    3736                        getLayer().getName(), 
    38                         new PrimitiveNameFormatter().getName(conflict.getMy()) 
     37                        conflict.getMy().getDisplayName(DefaultNameFormatter.getInstance()) 
    3938                ), 
    4039                tr("Double conflict"), 
     
    5655            System.out.println(tr("Warning: layer ''{0}'' doesn't exist anymore. Can't remove conflict for primitmive ''{1}''", 
    5756                    getLayer().getName(), 
    58                     new PrimitiveNameFormatter().getName(conflict.getMy()) 
     57                    conflict.getMy().getDisplayName(DefaultNameFormatter.getInstance()) 
    5958            )); 
    6059            return; 
     
    7170                new JLabel( 
    7271                        tr("Add conflict for ''{0}''", 
    73                                 new PrimitiveNameFormatter().getName(conflict.getMy()) 
     72                                conflict.getMy().getDisplayName(DefaultNameFormatter.getInstance()) 
    7473                        ), 
    7574                        ImageProvider.get(OsmPrimitiveType.from(conflict.getMy())), 
  • trunk/src/org/openstreetmap/josm/command/DeleteCommand.java

    r1989 r1990  
    3333import org.openstreetmap.josm.data.osm.visitor.CollectBackReferencesVisitor; 
    3434import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; 
     35import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    3536import org.openstreetmap.josm.gui.ExtendedDialog; 
    36 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 
    3737import org.openstreetmap.josm.gui.layer.OsmDataLayer; 
    3838import org.openstreetmap.josm.tools.ImageProvider; 
     
    115115            } 
    116116 
    117             return new DefaultMutableTreeNode(new JLabel(tr(msg, new PrimitiveNameFormatter().getName(primitive)), 
     117            return new DefaultMutableTreeNode(new JLabel(tr(msg, primitive.getDisplayName(DefaultNameFormatter.getInstance())), 
    118118                    ImageProvider.get(OsmPrimitiveType.from(primitive)), JLabel.HORIZONTAL)); 
    119119        } 
     
    140140        ); 
    141141        for (OsmPrimitive osm : toDelete) { 
    142             root.add(new DefaultMutableTreeNode(new JLabel(new PrimitiveNameFormatter().getName(osm), ImageProvider 
    143                     .get(OsmPrimitiveType.from(osm)), JLabel.HORIZONTAL))); 
     142            root.add(new DefaultMutableTreeNode(new JLabel( 
     143                    osm.getDisplayName(DefaultNameFormatter.getInstance()), 
     144                    ImageProvider.get(OsmPrimitiveType.from(osm)), JLabel.HORIZONTAL))); 
    144145        } 
    145146        return root; 
     
    173174 
    174175    private static int testRelation(Relation ref, OsmPrimitive osm) { 
    175         PrimitiveNameFormatter formatter = new PrimitiveNameFormatter(); 
    176176        String role = new String(); 
    177177        for (RelationMember m : ref.getMembers()) { 
     
    183183        if (role.length() > 0) 
    184184            return new ExtendedDialog(Main.parent, tr("Conflicting relation"), tr( 
    185                     "Selection \"{0}\" is used by relation \"{1}\" with role {2}.\nDelete from relation?", formatter 
    186                     .getName(osm), formatter.getName(ref), role), new String[] { tr("Delete from relation"), 
     185                    "Selection \"{0}\" is used by relation \"{1}\" with role {2}.\nDelete from relation?", 
     186                    osm.getDisplayName(DefaultNameFormatter.getInstance()), ref.getDisplayName(DefaultNameFormatter.getInstance()), role), new String[] { tr("Delete from relation"), 
    187187                tr("Cancel") }, new String[] { "dialogs/delete.png", "cancel.png" }).getValue(); 
    188188        else 
    189189            return new ExtendedDialog(Main.parent, tr("Conflicting relation"), tr( 
    190                     "Selection \"{0}\" is used by relation \"{1}\".\nDelete from relation?", formatter.getName(osm), 
    191                     formatter.getName(ref)), new String[] { tr("Delete from relation"), tr("Cancel") }, new String[] { 
     190                    "Selection \"{0}\" is used by relation \"{1}\".\nDelete from relation?", 
     191                    osm.getDisplayName(DefaultNameFormatter.getInstance()), 
     192                    ref.getDisplayName(DefaultNameFormatter.getInstance())), new String[] { tr("Delete from relation"), tr("Cancel") }, new String[] { 
    192193                "dialogs/delete.png", "cancel.png" }).getValue(); 
    193194    } 
  • trunk/src/org/openstreetmap/josm/command/RemoveRelationMemberCommand.java

    r1989 r1990  
    22package org.openstreetmap.josm.command; 
    33 
     4import static org.openstreetmap.josm.tools.I18n.marktr; 
    45import static org.openstreetmap.josm.tools.I18n.tr; 
    5 import static org.openstreetmap.josm.tools.I18n.marktr; 
    66 
    77import java.util.Collection; 
     
    1616import org.openstreetmap.josm.data.osm.Relation; 
    1717import org.openstreetmap.josm.data.osm.RelationMember; 
    18 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 
     18import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    1919import org.openstreetmap.josm.tools.ImageProvider; 
    2020 
     
    7474                new JLabel( 
    7575                        tr(msg, 
    76                                 new PrimitiveNameFormatter().getName(member.member), 
     76                                member.member.getDisplayName(DefaultNameFormatter.getInstance()), 
    7777                                relation.getMembers().indexOf(member), 
    78                                 new PrimitiveNameFormatter().getName(relation) 
     78                                relation.getDisplayName(DefaultNameFormatter.getInstance()) 
    7979                        ), 
    8080                        ImageProvider.get(OsmPrimitiveType.from(relation)), 
  • trunk/src/org/openstreetmap/josm/corrector/RoleCorrectionTableModel.java

    r1930 r1990  
    66import java.util.List; 
    77 
    8 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 
     8import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    99 
    1010public class RoleCorrectionTableModel extends 
    1111CorrectionTableModel<RoleCorrection> { 
    12     private static final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter(); 
    1312 
    1413    public RoleCorrectionTableModel(List<RoleCorrection> roleCorrections) { 
     
    4039        switch (colIndex) { 
    4140        case 0: 
    42             return NAME_FORMATTER.getName(roleCorrection.relation); 
     41            return roleCorrection.relation.getDisplayName(DefaultNameFormatter.getInstance()); 
    4342        case 1: 
    4443            return roleCorrection.member.getRole(); 
  • trunk/src/org/openstreetmap/josm/corrector/TagCorrector.java

    r1857 r1990  
    2828import org.openstreetmap.josm.data.osm.Relation; 
    2929import org.openstreetmap.josm.data.osm.Way; 
     30import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    3031import org.openstreetmap.josm.gui.JMultilineLabel; 
    3132import org.openstreetmap.josm.gui.OptionPaneUtil; 
    32 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 
    3333import org.openstreetmap.josm.tools.GBC; 
    3434import org.openstreetmap.josm.tools.ImageProvider; 
    3535 
    3636public abstract class TagCorrector<P extends OsmPrimitive> { 
    37     private static final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter(); 
    3837 
    3938    public abstract Collection<Command> execute(P primitive, P oldprimitive) 
     
    101100 
    102101                final JLabel primitiveLabel = new JLabel( 
    103                         NAME_FORMATTER.getName(primitive) + ":", 
     102                        primitive.getDisplayName(DefaultNameFormatter.getInstance()) + ":", 
    104103                        ImageProvider.get(OsmPrimitiveType.from(primitive)), 
    105104                        JLabel.LEFT 
     
    127126 
    128127                final JLabel primitiveLabel = new JLabel( 
    129                         NAME_FORMATTER.getName(primitive), 
     128                        primitive.getDisplayName(DefaultNameFormatter.getInstance()), 
    130129                        ImageProvider.get(OsmPrimitiveType.from(primitive)), 
    131130                        JLabel.LEFT 
  • trunk/src/org/openstreetmap/josm/data/coor/LatLon.java

    r1789 r1990  
    2525    private static DecimalFormat cDdFormatter = new DecimalFormat("###0.0000"); 
    2626 
    27     /** 
    28      * Possible ways to display coordinates 
    29      */ 
    30     public enum CoordinateFormat { 
    31         DECIMAL_DEGREES {public String toString() {return tr("Decimal Degrees");}}, 
    32         DEGREES_MINUTES_SECONDS {public String toString() {return tr("Degrees Minutes Seconds");}}; 
    33     } 
    3427 
    3528    public static String dms(double pCoordinate) { 
     
    4235 
    4336        return tDegree + "\u00B0" + cDmsMinuteFormatter.format(tMinutes) + "\'" 
    44             + cDmsSecondFormatter.format(tSeconds) + "\""; 
     37        + cDmsSecondFormatter.format(tSeconds) + "\""; 
    4538    } 
    4639 
     
    9487        Bounds b = Main.proj.getWorldBoundsLatLon(); 
    9588        return lat() < b.min.lat() || lat() > b.max.lat() || 
    96             lon() < b.min.lon() || lon() > b.max.lon(); 
     89        lon() < b.min.lon() || lon() > b.max.lon(); 
    9790    } 
    9891 
     
    112105    public double greatCircleDistance(LatLon other) { 
    113106        return (Math.acos( 
    114             Math.sin(Math.toRadians(lat())) * Math.sin(Math.toRadians(other.lat())) + 
    115             Math.cos(Math.toRadians(lat()))*Math.cos(Math.toRadians(other.lat())) * 
    116                           Math.cos(Math.toRadians(other.lon()-lon()))) * 6378135); 
     107                Math.sin(Math.toRadians(lat())) * Math.sin(Math.toRadians(other.lat())) + 
     108                Math.cos(Math.toRadians(lat()))*Math.cos(Math.toRadians(other.lat())) * 
     109                Math.cos(Math.toRadians(other.lon()-lon()))) * 6378135); 
    117110    } 
    118111 
     
    130123        } else { 
    131124            rv = Math.atan((other.lon()-lon())/(other.lat()-lat())); 
    132             if (rv < 0) rv += Math.PI; 
    133             if (other.lon() < lon()) rv += Math.PI; 
     125            if (rv < 0) { 
     126                rv += Math.PI; 
     127            } 
     128            if (other.lon() < lon()) { 
     129                rv += Math.PI; 
     130            } 
    134131        } 
    135132        return rv; 
     
    149146    public LatLon interpolate(LatLon ll2, double proportion) { 
    150147        return new LatLon(this.lat() + proportion * (ll2.lat() - this.lat()), 
    151             this.lon() + proportion * (ll2.lon() - this.lon())); 
     148                this.lon() + proportion * (ll2.lon() - this.lon())); 
    152149    } 
    153150 
  • trunk/src/org/openstreetmap/josm/data/osm/Changeset.java

    r1933 r1990  
    22package org.openstreetmap.josm.data.osm; 
    33 
     4import static org.openstreetmap.josm.tools.I18n.tr; 
     5 
    46import org.openstreetmap.josm.data.osm.visitor.Visitor; 
    5 import static org.openstreetmap.josm.tools.I18n.tr; 
    67 
    78/** 
     
    3536    @Override 
    3637    public String getName() { 
     38        // no translation 
     39        return "changeset " + id; 
     40    } 
     41 
     42    @Override 
     43    public String getLocalName(){ 
    3744        return tr("Changeset {0}",id); 
    3845    } 
     46 
     47    @Override 
     48    public String getDisplayName(NameFormatter formatter) { 
     49        return formatter.format(this); 
     50    } 
    3951} 
  • trunk/src/org/openstreetmap/josm/data/osm/Node.java

    r1814 r1990  
    22package org.openstreetmap.josm.data.osm; 
    33 
    4 import static org.openstreetmap.josm.tools.I18n.tr; 
     4import java.util.Locale; 
    55 
    6 import org.openstreetmap.josm.Main; 
    76import org.openstreetmap.josm.data.coor.CachedLatLon; 
    87import org.openstreetmap.josm.data.coor.EastNorth; 
    98import org.openstreetmap.josm.data.coor.LatLon; 
    10 import org.openstreetmap.josm.data.coor.LatLon.CoordinateFormat; 
    119import org.openstreetmap.josm.data.osm.visitor.Visitor; 
     10import static org.openstreetmap.josm.tools.I18n.tr; 
    1211 
    1312/** 
     
    5049    } 
    5150 
    52     private static CoordinateFormat mCord; 
    5351 
    54     static public CoordinateFormat getCoordinateFormat() 
    55     { 
    56         return mCord; 
    57     } 
    58  
    59     static public void setCoordinateFormat() 
    60     { 
    61         try { 
    62             mCord = LatLon.CoordinateFormat.valueOf(Main.pref.get("coordinates")); 
    63         } catch (IllegalArgumentException iae) { 
    64             mCord = LatLon.CoordinateFormat.DECIMAL_DEGREES; 
    65         } 
    66     } 
    67  
    68     static { 
    69         setCoordinateFormat(); 
    70     } 
    7152 
    7253    /** 
     
    127108 
    128109    @Override 
     110    public String getDisplayName(NameFormatter formatter) { 
     111        return formatter.format(this); 
     112    } 
     113 
     114    @Override 
    129115    public String getName() { 
    130         String name; 
    131         if (incomplete) { 
    132             name = tr("incomplete"); 
    133         } else { 
    134             name = get("name"); 
    135             if (name == null) { 
    136                 name = id == 0 ? tr("node") : ""+id; 
    137             } 
    138             name += " (" + coor.latToString(mCord) + ", " + coor.lonToString(mCord) + ")"; 
    139         } 
    140         return name; 
     116        String name = super.getName(); 
     117        if (name != null) 
     118            return name; 
     119        // no translation 
     120        return "node " + id; 
     121    } 
     122 
     123    @Override 
     124    public String getLocalName(){ 
     125        String name = super.getLocalName(); 
     126        if (name != null) 
     127            return name; 
     128        return tr("node {0}",id); 
    141129    } 
    142130} 
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r1933 r1990  
    1010import java.util.Date; 
    1111import java.util.HashMap; 
     12import java.util.Locale; 
    1213import java.util.Map; 
    1314import java.util.Map.Entry; 
     
    358359        return keys != null && !keys.isEmpty(); 
    359360    } 
    360  
    361     /** 
    362      * Replies the name of this primitive. 
    363      *  
    364      * @return the name of this primitive 
    365      */ 
    366     public abstract String getName(); 
    367361 
    368362    /** 
     
    463457        return false; 
    464458    } 
     459 
     460 
     461    /** 
     462     * Replies the name of this primitive. The default implementation replies the value 
     463     * of the tag <tt>name</tt> or null, if this tag is not present. 
     464     *  
     465     * @return the name of this primitive 
     466     */ 
     467    public String getName() { 
     468        if (get("name") != null) 
     469            return get("name"); 
     470        return null; 
     471    } 
     472 
     473    /** 
     474     * Replies the a localized name for this primitive given by the value of the tags (in this order) 
     475     * <ul> 
     476     *   <li>name:lang_COUNTRY_Variant  of the current locale</li> 
     477     *   <li>name:lang_COUNTRY of the current locale</li> 
     478     *   <li>name:lang of the current locale</li> 
     479     *   <li>name of the current locale</li> 
     480     * </ul> 
     481     *  
     482     * null, if no such tag exists 
     483     *  
     484     * @return the name of this primitive 
     485     */ 
     486    public String getLocalName() { 
     487        String key = "name:" + Locale.getDefault().toString(); 
     488        if (get(key) != null) 
     489            return get(key); 
     490        key = "name:" + Locale.getDefault().getLanguage() + "_" + Locale.getDefault().getCountry(); 
     491        if (get(key) != null) 
     492            return get(key); 
     493        key = "name:" + Locale.getDefault().getLanguage(); 
     494        if (get(key) != null) 
     495            return get(key); 
     496        return getName(); 
     497    } 
     498 
     499    /** 
     500     * Replies the display name of a primitive formatted by <code>formatter</code> 
     501     *  
     502     * @return the display name 
     503     */ 
     504    public abstract String getDisplayName(NameFormatter formatter); 
    465505} 
  • trunk/src/org/openstreetmap/josm/data/osm/Relation.java

    r1951 r1990  
    22 
    33import static org.openstreetmap.josm.tools.I18n.tr; 
    4 import static org.openstreetmap.josm.tools.I18n.trn; 
    54 
    65import java.util.ArrayList; 
    7 import java.util.Arrays; 
    8 import java.util.Collection; 
    96import java.util.List; 
    107 
    11 import org.openstreetmap.josm.Main; 
    128import org.openstreetmap.josm.data.osm.visitor.Visitor; 
    139import org.openstreetmap.josm.tools.CopyList; 
     
    104100        return members.remove(index); 
    105101    } 
    106  
    107     final static String[] defnames = {"name", "ref", "restriction", "note"}; 
    108     static Collection<String> names = null; 
    109102 
    110103    @Override public void visit(Visitor visitor) { 
     
    164157    } 
    165158 
    166     @Override 
    167     public String getName() { 
    168         String name; 
    169         if (incomplete) { 
    170             name = tr("incomplete"); 
    171         } else { 
    172             name = get("type"); 
    173             if (name == null) { 
    174                 name = tr("relation"); 
    175             } 
    176  
    177             name += " ("; 
    178             if(names == null) { 
    179                 names = Main.pref.getCollection("relation.nameOrder", Arrays.asList(defnames)); 
    180             } 
    181             String nameTag = null; 
    182             for (String n : names) { 
    183                 nameTag = get(n); 
    184                 if (nameTag != null) { 
    185                     break; 
    186                 } 
    187             } 
    188             if (nameTag != null) { 
    189                 name += "\"" + nameTag + "\", "; 
    190             } 
    191  
    192             int mbno = members.size(); 
    193             name += trn("{0} member", "{0} members", mbno, mbno) + ")"; 
    194             if(errors != null) { 
    195                 name = "*"+name; 
    196             } 
    197         } 
    198         return name; 
    199     } 
    200  
    201159    // seems to be different from member "incomplete" - FIXME 
    202160    public boolean isIncomplete() { 
     
    233191        members.removeAll(todelete); 
    234192    } 
     193 
     194    @Override 
     195    public String getName() { 
     196        String name = super.getName(); 
     197        if (name != null) 
     198            return name; 
     199        // no translation 
     200        return "relation " + id; 
     201    } 
     202 
     203    @Override 
     204    public String getLocalName(){ 
     205        String name = super.getLocalName(); 
     206        if (name != null) 
     207            return name; 
     208        return tr("relation {0}",id); 
     209    } 
     210 
     211    @Override 
     212    public String getDisplayName(NameFormatter formatter) { 
     213        return formatter.format(this); 
     214    } 
    235215} 
  • trunk/src/org/openstreetmap/josm/data/osm/Way.java

    r1946 r1990  
    180180    } 
    181181 
    182     @Override 
    183     public String getName() { 
    184         String name; 
    185         if (incomplete) { 
    186             name = tr("incomplete"); 
    187         } else { 
    188             name = get("name"); 
    189             if (name == null) { 
    190                 name = get("ref"); 
    191             } 
    192             if (name == null) { 
    193                 name = 
    194                     (get("highway") != null) ? tr("highway") : 
    195                         (get("railway") != null) ? tr("railway") : 
    196                             (get("waterway") != null) ? tr("waterway") : 
    197                                 (get("landuse") != null) ? tr("landuse") : ""; 
    198             } 
    199  
    200             int nodesNo = new HashSet<Node>(nodes).size(); 
    201             String nodes = trn("{0} node", "{0} nodes", nodesNo, nodesNo); 
    202             name += (name.length() > 0) ? " ("+nodes+")" : nodes; 
    203             if(errors != null) { 
    204                 name = "*"+name; 
    205             } 
    206         } 
    207         return name; 
    208     } 
    209  
    210182    public void removeNode(Node n) { 
    211183        if (incomplete) return; 
     
    263235        return n == firstNode() || n == lastNode(); 
    264236    } 
     237 
     238    @Override 
     239    public String getName() { 
     240        String name = super.getName(); 
     241        if (name != null) 
     242            return name; 
     243        // no translation 
     244        return "way " + id; 
     245    } 
     246 
     247    @Override 
     248    public String getLocalName(){ 
     249        String name = super.getLocalName(); 
     250        if (name != null) 
     251            return name; 
     252        return tr("way {0}",id); 
     253    } 
     254 
     255    @Override 
     256    public String getDisplayName(NameFormatter formatter) { 
     257        return formatter.format(this); 
     258    } 
    265259} 
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java

    r1937 r1990  
    3434import org.openstreetmap.josm.data.osm.RelationMember; 
    3535import org.openstreetmap.josm.data.osm.Way; 
     36import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    3637import org.openstreetmap.josm.gui.mappaint.AreaElemStyle; 
    3738import org.openstreetmap.josm.gui.mappaint.ElemStyle; 
     
    9495            return (styles != null) ? styles.get(osm) : null; 
    9596 
    96         if(osm.mappaintStyle == null && styles != null) { 
    97             osm.mappaintStyle = styles.get(osm); 
    98             if(osm instanceof Way) 
    99                 ((Way)osm).isMappaintArea = styles.isArea(osm); 
    100         } 
    101         return osm.mappaintStyle; 
     97            if(osm.mappaintStyle == null && styles != null) { 
     98                osm.mappaintStyle = styles.get(osm); 
     99                if(osm instanceof Way) { 
     100                    ((Way)osm).isMappaintArea = styles.isArea(osm); 
     101                } 
     102            } 
     103            return osm.mappaintStyle; 
    102104    } 
    103105 
     
    106108            return (styles != null) ? styles.getIcon(osm) : null; 
    107109 
    108         if(osm.mappaintStyle == null && styles != null) 
    109             osm.mappaintStyle = styles.getIcon(osm); 
    110  
    111         return (IconElemStyle)osm.mappaintStyle; 
     110            if(osm.mappaintStyle == null && styles != null) { 
     111                osm.mappaintStyle = styles.getIcon(osm); 
     112            } 
     113 
     114            return (IconElemStyle)osm.mappaintStyle; 
    112115    } 
    113116 
     
    129132     * @param n The node to draw. 
    130133     */ 
     134    @Override 
    131135    public void visit(Node n) { 
    132136        /* check, if the node is visible at all */ 
    133137        if((n.getEastNorth().east()  > maxEN.east() ) || 
    134            (n.getEastNorth().north() > maxEN.north()) || 
    135            (n.getEastNorth().east()  < minEN.east() ) || 
    136            (n.getEastNorth().north() < minEN.north())) 
     138                (n.getEastNorth().north() > maxEN.north()) || 
     139                (n.getEastNorth().east()  < minEN.east() ) || 
     140                (n.getEastNorth().north() < minEN.north())) 
    137141        { 
    138142            n.mappaintVisibleCode = viewid; 
     
    146150        //    return; 
    147151 
    148         if (nodeStyle != null && isZoomOk(nodeStyle) && showIcons > dist) 
     152        if (nodeStyle != null && isZoomOk(nodeStyle) && showIcons > dist) { 
    149153            drawNode(n, nodeStyle.icon, nodeStyle.annotate, n.isSelected()); 
    150         else if (n.highlighted) 
     154        } else if (n.highlighted) { 
    151155            drawNode(n, highlightColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 
    152         else if (n.isSelected()) 
     156        } else if (n.isSelected()) { 
    153157            drawNode(n, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 
    154         else if (n.isTagged()) 
     158        } else if (n.isTagged()) { 
    155159            drawNode(n, nodeColor, taggedNodeSize, taggedNodeRadius, fillUnselectedNode); 
    156         else 
     160        } else { 
    157161            drawNode(n, nodeColor, unselectedNodeSize, unselectedNodeRadius, fillUnselectedNode); 
     162        } 
    158163    } 
    159164 
     
    162167     * @param w The way to draw. 
    163168     */ 
     169    @Override 
    164170    public void visit(Way w) { 
    165171        if(w.getNodesCount() < 2) 
     
    177183        for (Node n : w.getNodes()) 
    178184        { 
    179             if(n.getEastNorth().east() > maxx) maxx = n.getEastNorth().east(); 
    180             if(n.getEastNorth().north() > maxy) maxy = n.getEastNorth().north(); 
    181             if(n.getEastNorth().east() < minx) minx = n.getEastNorth().east(); 
    182             if(n.getEastNorth().north() < miny) miny = n.getEastNorth().north(); 
     185            if(n.getEastNorth().east() > maxx) { 
     186                maxx = n.getEastNorth().east(); 
     187            } 
     188            if(n.getEastNorth().north() > maxy) { 
     189                maxy = n.getEastNorth().north(); 
     190            } 
     191            if(n.getEastNorth().east() < minx) { 
     192                minx = n.getEastNorth().east(); 
     193            } 
     194            if(n.getEastNorth().north() < miny) { 
     195                miny = n.getEastNorth().north(); 
     196            } 
    183197        } 
    184198 
    185199        if ((minx > maxEN.east()) || 
    186             (miny > maxEN.north()) || 
    187             (maxx < minEN.east()) || 
    188             (maxy < minEN.north())) 
     200                (miny > maxEN.north()) || 
     201                (maxx < minEN.east()) || 
     202                (maxy < minEN.north())) 
    189203        { 
    190204            w.mappaintVisibleCode = viewid; 
     
    201215 
    202216        w.mappaintVisibleCode = 0; 
    203         if(fillAreas > dist) 
     217        if(fillAreas > dist) { 
    204218            w.clearErrors(); 
     219        } 
    205220 
    206221        if(wayStyle==null) 
     
    226241            if (fillAreas > dist) 
    227242            { 
    228             //    profilerVisibleAreas++; 
     243                //    profilerVisibleAreas++; 
    229244                drawArea(w, w.isSelected() ? selectedColor : areaStyle.color); 
    230                 if(!w.isClosed()) 
     245                if(!w.isClosed()) { 
    231246                    w.putError(tr("Area style way is not closed."), true); 
     247                } 
    232248            } 
    233249            drawWay(w, areaStyle.line, areaStyle.color, w.isSelected()); 
     
    241257           (even if the tag is negated as in oneway=false) or the way is selected */ 
    242258        boolean showDirection = w.isSelected() || ((!useRealWidth) && (showDirectionArrow 
    243         && (!showRelevantDirectionsOnly || w.hasDirectionKeys()))); 
     259                && (!showRelevantDirectionsOnly || w.hasDirectionKeys()))); 
    244260        /* head only takes over control if the option is true, 
    245261           the direction should be shown at all and not only because it's selected */ 
     
    253269        if(l != null) 
    254270        { 
    255             if (l.color != null) color = l.color; 
     271            if (l.color != null) { 
     272                color = l.color; 
     273            } 
    256274            width = l.width; 
    257275            realWidth = l.realWidth; 
     
    259277            dashedColor = l.dashedColor; 
    260278        } 
    261         if(selected) 
     279        if(selected) { 
    262280            color = selectedColor; 
     281        } 
    263282        if (realWidth > 0 && useRealWidth && !showDirection) 
    264283        { 
    265284            int tmpWidth = (int) (100 /  (float) (circum / realWidth)); 
    266             if (tmpWidth > width) width = tmpWidth; 
     285            if (tmpWidth > width) { 
     286                width = tmpWidth; 
     287            } 
    267288 
    268289            /* if we have a "width" tag, try use it */ 
     
    281302        } 
    282303 
    283         if(w.highlighted) 
     304        if(w.highlighted) { 
    284305            color = highlightColor; 
    285         else if(w.isSelected()) 
     306        } else if(w.isSelected()) { 
    286307            color = selectedColor; 
     308        } 
    287309 
    288310        /* draw overlays under the way */ 
     
    299321                        { 
    300322                            drawSeg(lastN, n, s.color != null  && !w.isSelected() ? s.color : color, 
    301                             false, s.getWidth(width), s.dashed, s.dashedColor); 
     323                                    false, s.getWidth(width), s.dashed, s.dashedColor); 
    302324                        } 
    303325                        lastN = n; 
     
    313335        { 
    314336            Node n = it.next(); 
    315             if(lastN != null) 
     337            if(lastN != null) { 
    316338                drawSeg(lastN, n, color, 
    317                     showOnlyHeadArrowOnly ? !it.hasNext() : showDirection, width, dashed, dashedColor); 
     339                        showOnlyHeadArrowOnly ? !it.hasNext() : showDirection, width, dashed, dashedColor); 
     340            } 
    318341            lastN = n; 
    319342        } 
     
    332355                        { 
    333356                            drawSeg(lastN, n, s.color != null && !w.isSelected() ? s.color : color, 
    334                             false, s.getWidth(width), s.dashed, s.dashedColor); 
     357                                    false, s.getWidth(width), s.dashed, s.dashedColor); 
    335358                        } 
    336359                        lastN = n; 
     
    386409                            { 
    387410                                nl = w.getNodesCount()-1; 
    388                                 if(w.getNode(nl) == c.getNode(0)) mode = 21; 
    389                                 else if(w.getNode(nl) == c.getNode(cl)) mode = 22; 
    390                                 else if(w.getNode(0) == c.getNode(0)) mode = 11; 
    391                                 else if(w.getNode(0) == c.getNode(cl)) mode = 12; 
     411                                if(w.getNode(nl) == c.getNode(0)) { 
     412                                    mode = 21; 
     413                                } else if(w.getNode(nl) == c.getNode(cl)) { 
     414                                    mode = 22; 
     415                                } else if(w.getNode(0) == c.getNode(0)) { 
     416                                    mode = 11; 
     417                                } else if(w.getNode(0) == c.getNode(cl)) { 
     418                                    mode = 12; 
     419                                } 
    392420                            } 
    393421                            else 
    394422                            { 
    395423                                nl = n.size()-1; 
    396                                 if(n.get(nl) == c.getNode(0)) mode = 21; 
    397                                 else if(n.get(0) == c.getNode(cl)) mode = 12; 
    398                                 else if(n.get(0) == c.getNode(0)) mode = 11; 
    399                                 else if(n.get(nl) == c.getNode(cl)) mode = 22; 
     424                                if(n.get(nl) == c.getNode(0)) { 
     425                                    mode = 21; 
     426                                } else if(n.get(0) == c.getNode(cl)) { 
     427                                    mode = 12; 
     428                                } else if(n.get(0) == c.getNode(0)) { 
     429                                    mode = 11; 
     430                                } else if(n.get(nl) == c.getNode(cl)) { 
     431                                    mode = 22; 
     432                                } 
    400433                            } 
    401434                            if(mode != 0) 
     
    403436                                joinArray[i] = null; 
    404437                                joined = true; 
    405                                 if(c.isSelected()) selected = true; 
     438                                if(c.isSelected()) { 
     439                                    selected = true; 
     440                                } 
    406441                                --left; 
    407                                 if(n == null) n = w.getNodes(); 
     442                                if(n == null) { 
     443                                    n = w.getNodes(); 
     444                                } 
    408445                                n.remove((mode == 21 || mode == 22) ? nl : 0); 
    409                                 if(mode == 21) 
     446                                if(mode == 21) { 
    410447                                    n.addAll(c.getNodes()); 
    411                                 else if(mode == 12) 
     448                                } else if(mode == 12) { 
    412449                                    n.addAll(0, c.getNodes()); 
    413                                 else if(mode == 22) 
     450                                } else if(mode == 22) 
    414451                                { 
    415                                     for(Node node : c.getNodes()) 
     452                                    for(Node node : c.getNodes()) { 
    416453                                        n.add(nl, node); 
     454                                    } 
    417455                                } 
    418456                                else /* mode == 11 */ 
    419457                                { 
    420                                     for(Node node : c.getNodes()) 
     458                                    for(Node node : c.getNodes()) { 
    421459                                        n.add(0, node); 
     460                                    } 
    422461                                } 
    423462                            } 
     
    437476                { 
    438477                    errs.putError(tr("multipolygon way ''{0}'' is not closed.", 
    439                     w.getName()), true); 
     478                            w.getDisplayName(DefaultNameFormatter.getInstance())), true); 
    440479                } 
    441480            } 
     
    447486 
    448487    public void drawSelectedMember(OsmPrimitive osm, ElemStyle style, Boolean area, 
    449     Boolean areaselected) 
     488            Boolean areaselected) 
    450489    { 
    451490        if(osm instanceof Way) 
     
    456495                AreaElemStyle areaStyle = (AreaElemStyle)style; 
    457496                drawWay(way, areaStyle.line, selectedColor, true); 
    458                 if(area) 
     497                if(area) { 
    459498                    drawArea(way, areaselected ? selectedColor : areaStyle.color); 
     499                } 
    460500            } 
    461501            else 
     
    466506        else if(osm instanceof Node) 
    467507        { 
    468             if(style != null && isZoomOk(style)) 
     508            if(style != null && isZoomOk(style)) { 
    469509                drawNode((Node)osm, ((IconElemStyle)style).icon, 
    470                 ((IconElemStyle)style).annotate, true); 
    471             else 
     510                        ((IconElemStyle)style).annotate, true); 
     511            } else { 
    472512                drawNode((Node)osm, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 
     513            } 
    473514        } 
    474515        osm.mappaintDrawnCode = paintid; 
    475516    } 
    476517 
     518    @Override 
    477519    public void visit(Relation r) { 
    478520 
     
    497539        { 
    498540            if(drawMultipolygon(r)) 
    499               return; 
     541                return; 
    500542        } 
    501543        else if (drawRestriction && "restriction".equals(r.get("type"))) 
     
    511553                { 
    512554                    drawSelectedMember(m.getMember(), styles != null ? getPrimitiveStyle(m.getMember()) 
    513                     : null, true, true); 
     555                            : null, true, true); 
    514556                } 
    515557            } 
     
    535577            //    System.out.println("member " + m.member + " selected " + r.selected); 
    536578 
    537             if(m.getMember() == null) 
     579            if(m.getMember() == null) { 
    538580                // TODO Nullable member will not be allowed after RelationMember.member is encalupsed 
    539581                r.putError(tr("Empty member in relation."), true); 
    540             else if(m.getMember().deleted) 
     582            } else if(m.getMember().deleted) { 
    541583                r.putError(tr("Deleted member ''{0}'' in relation.", 
    542                 m.getMember().getName()), true); 
    543             else if(m.getMember().incomplete) 
    544             { 
     584                        m.getMember().getDisplayName(DefaultNameFormatter.getInstance())), true); 
     585            } else if(m.getMember().incomplete) 
    545586                return; 
    546             } 
    547587            else 
    548588            { 
     
    553593                    { 
    554594                        r.putError(tr("Way ''{0}'' with less than two points.", 
    555                         w.getName()), true); 
     595                                w.getDisplayName(DefaultNameFormatter.getInstance())), true); 
    556596                    } 
    557597                    else if("from".equals(m.getRole())) { 
    558                         if(fromWay != null) 
     598                        if(fromWay != null) { 
    559599                            r.putError(tr("More than one \"from\" way found."), true); 
    560                         else { 
     600                        } else { 
    561601                            fromWay = w; 
    562602                        } 
    563603                    } else if("to".equals(m.getRole())) { 
    564                         if(toWay != null) 
     604                        if(toWay != null) { 
    565605                            r.putError(tr("More than one \"to\" way found."), true); 
    566                         else { 
     606                        } else { 
    567607                            toWay = w; 
    568608                        } 
    569609                    } else if("via".equals(m.getRole())) { 
    570                         if(via != null) 
     610                        if(via != null) { 
    571611                            r.putError(tr("More than one \"via\" found."), true); 
    572                         else 
     612                        } else { 
    573613                            via = w; 
    574                     } 
    575                     else 
     614                        } 
     615                    } else { 
    576616                        r.putError(tr("Unknown role ''{0}''.", m.getRole()), true); 
     617                    } 
    577618                } 
    578619                else if(m.isNode()) 
     
    581622                    if("via".equals(m.getRole())) 
    582623                    { 
    583                         if(via != null) 
     624                        if(via != null) { 
    584625                            r.putError(tr("More than one \"via\" found."), true); 
    585                         else 
     626                        } else { 
    586627                            via = n; 
    587                     } 
    588                     else 
     628                        } 
     629                    } else { 
    589630                        r.putError(tr("Unknown role ''{0}''.", m.getRole()), true); 
    590                 } 
    591                 else 
    592                     r.putError(tr("Unknown member type for ''{0}''.", m.getMember().getName()), true); 
     631                    } 
     632                } else { 
     633                    r.putError(tr("Unknown member type for ''{0}''.", m.getMember().getDisplayName(DefaultNameFormatter.getInstance())), true); 
     634                } 
    593635            } 
    594636        } 
     
    615657                return; 
    616658            } 
    617             if(!toWay.isFirstLastNode(viaNode)) 
     659            if(!toWay.isFirstLastNode(viaNode)) { 
    618660                r.putError(tr("The \"to\" way doesn't start or end at a \"via\" node."), true); 
     661            } 
    619662        } 
    620663        else 
     
    623666            Node firstNode = viaWay.firstNode(); 
    624667            Node lastNode = viaWay.lastNode(); 
    625             if(fromWay.isFirstLastNode(firstNode)) 
     668            if(fromWay.isFirstLastNode(firstNode)) { 
    626669                viaNode = firstNode; 
    627             else if(fromWay.isFirstLastNode(lastNode)) 
     670            } else if(fromWay.isFirstLastNode(lastNode)) { 
    628671                viaNode = firstNode; 
    629             else { 
     672            } else { 
    630673                r.putError(tr("The \"from\" way doesn't start or end at the \"via\" way."), true); 
    631674                return; 
    632675            } 
    633             if(!toWay.isFirstLastNode(viaNode == firstNode ? lastNode : firstNode)) 
     676            if(!toWay.isFirstLastNode(viaNode == firstNode ? lastNode : firstNode)) { 
    634677                r.putError(tr("The \"to\" way doesn't start or end at the \"via\" way."), true); 
     678            } 
    635679        } 
    636680 
     
    675719           (calculate the vector vx/vy with the specified length and the direction 
    676720           away from the "via" node along the first segment of the "from" way) 
    677         */ 
     721         */ 
    678722        double distanceFromVia=14; 
    679723        double dx = (pFrom.x >= pVia.x) ? (pFrom.x - pVia.x) : (pVia.x - pFrom.x); 
     
    691735        double vy = distanceFromVia * Math.sin(fromAngle); 
    692736 
    693         if(pFrom.x < pVia.x) vx = -vx; 
    694         if(pFrom.y < pVia.y) vy = -vy; 
     737        if(pFrom.x < pVia.x) { 
     738            vx = -vx; 
     739        } 
     740        if(pFrom.y < pVia.y) { 
     741            vy = -vy; 
     742        } 
    695743 
    696744        //if(restrictionDebug) 
     
    700748           (calculate the vx2/vy2 vector with the specified length and the direction 
    701749           90degrees away from the first segment of the "from" way) 
    702         */ 
     750         */ 
    703751        double distanceFromWay=10; 
    704752        double vx2 = 0; 
     
    740788                vx2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg + 180)); 
    741789                vy2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg + 180)); 
    742              } else { 
     790            } else { 
    743791                vx2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg)); 
    744792                vy2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg)); 
     
    783831        for (RelationMember m : r.getMembers()) 
    784832        { 
    785             if(m.getMember() == null) 
     833            if(m.getMember() == null) { 
    786834                //TODO Remove useless nullcheck when RelationMember.member is encalupsed 
    787835                r.putError(tr("Empty member in relation."), true); 
    788             else if(m.getMember().deleted) 
     836            } else if(m.getMember().deleted) { 
    789837                r.putError(tr("Deleted member ''{0}'' in relation.", 
    790                 m.getMember().getName()), true); 
    791             else if(m.getMember().incomplete) 
     838                        m.getMember().getDisplayName(DefaultNameFormatter.getInstance())), true); 
     839            } else if(m.getMember().incomplete) { 
    792840                incomplete = true; 
    793             else 
     841            } else 
    794842            { 
    795843                if(m.isWay()) 
     
    799847                    { 
    800848                        r.putError(tr("Way ''{0}'' with less than two points.", 
    801                         w.getName()), true); 
    802                     } 
    803                     else if("inner".equals(m.getRole())) 
     849                                w.getDisplayName(DefaultNameFormatter.getInstance())), true); 
     850                    } 
     851                    else if("inner".equals(m.getRole())) { 
    804852                        inner.add(w); 
    805                     else if("outer".equals(m.getRole())) 
     853                    } else if("outer".equals(m.getRole())) { 
    806854                        outer.add(w); 
    807                     else 
     855                    } else 
    808856                    { 
    809857                        r.putError(tr("No useful role ''{0}'' for Way ''{1}''.", 
    810                           m.getRole(), w.getName()), true); 
    811                         if(!m.hasRole()) 
     858                                m.getRole(), w.getDisplayName(DefaultNameFormatter.getInstance())), true); 
     859                        if(!m.hasRole()) { 
    812860                            outer.add(w); 
    813                         else if(r.isSelected()) 
     861                        } else if(r.isSelected()) { 
    814862                            drawSelectedMember(m.getMember(), styles != null 
    815                             ? getPrimitiveStyle(m.getMember()) : null, true, true); 
     863                                    ? getPrimitiveStyle(m.getMember()) : null, true, true); 
     864                        } 
    816865                    } 
    817866                } 
     
    819868                { 
    820869                    r.putError(tr("Non-Way ''{0}'' in multipolygon.", 
    821                     m.getMember().getName()), true); 
     870                            m.getMember().getDisplayName(DefaultNameFormatter.getInstance())), true); 
    822871                } 
    823872            } 
     
    829878            for (Way w : outer) 
    830879            { 
    831                if(wayStyle == null) 
    832                    wayStyle = styles.getArea(w); 
     880                if(wayStyle == null) { 
     881                    wayStyle = styles.getArea(w); 
     882                } 
    833883            } 
    834884            r.mappaintStyle = wayStyle; 
     
    844894            for (Way w : outer) 
    845895            { 
    846                 if(w.isClosed()) outerclosed.add(w); 
    847                 else join.add(w); 
     896                if(w.isClosed()) { 
     897                    outerclosed.add(w); 
     898                } else { 
     899                    join.add(w); 
     900                } 
    848901            } 
    849902            if(join.size() != 0) 
    850903            { 
    851                 for(Way w : joinWays(join, incomplete ? null : r)) 
     904                for(Way w : joinWays(join, incomplete ? null : r)) { 
    852905                    outerclosed.add(w); 
     906                } 
    853907            } 
    854908 
     
    856910            for (Way w : inner) 
    857911            { 
    858                 if(w.isClosed()) innerclosed.add(w); 
    859                 else join.add(w); 
     912                if(w.isClosed()) { 
     913                    innerclosed.add(w); 
     914                } else { 
     915                    join.add(w); 
     916                } 
    860917            } 
    861918            if(join.size() != 0) 
    862919            { 
    863                 for(Way w : joinWays(join, incomplete ? null : r)) 
     920                for(Way w : joinWays(join, incomplete ? null : r)) { 
    864921                    innerclosed.add(w); 
     922                } 
    865923            } 
    866924 
     
    868926            { 
    869927                r.putError(tr("No outer way for multipolygon ''{0}''.", 
    870                 r.getName()), true); 
     928                        r.getDisplayName(DefaultNameFormatter.getInstance())), true); 
    871929                visible = true; /* prevent killing remaining ways */ 
    872930            } 
     
    892950                        for(int i = 0; i < p.npoints; ++i) 
    893951                        { 
    894                             if(poly.contains(p.xpoints[i],p.ypoints[i])) 
     952                            if(poly.contains(p.xpoints[i],p.ypoints[i])) { 
    895953                                --contains; 
     954                            } 
    896955                        } 
    897956                        if(contains == 0) return 1; 
     
    901960                    public void addInner(Polygon p) 
    902961                    { 
    903                         if(inner == null) 
     962                        if(inner == null) { 
    904963                            inner = new ArrayList<Polygon>(); 
     964                        } 
    905965                        inner.add(p); 
    906966                    } 
     
    908968                    { 
    909969                        return (poly.npoints >= 3 
    910                         && poly.xpoints[0] == poly.xpoints[poly.npoints-1] 
    911                         && poly.ypoints[0] == poly.ypoints[poly.npoints-1]); 
     970                                && poly.xpoints[0] == poly.xpoints[poly.npoints-1] 
     971                                                                   && poly.ypoints[0] == poly.ypoints[poly.npoints-1]); 
    912972                    } 
    913973                    public Polygon get() 
     
    917977                            for (Polygon pp : inner) 
    918978                            { 
    919                                 for(int i = 0; i < pp.npoints; ++i) 
     979                                for(int i = 0; i < pp.npoints; ++i) { 
    920980                                    poly.addPoint(pp.xpoints[i],pp.ypoints[i]); 
     981                                } 
    921982                                poly.addPoint(p.x,p.y); 
    922983                            } 
     
    9541015                            { 
    9551016                                r.putError(tr("Intersection between ways ''{0}'' and ''{1}''.", 
    956                                 pd.way.getName(), wInner.getName()), true); 
     1017                                        pd.way.getDisplayName(DefaultNameFormatter.getInstance()), wInner.getDisplayName(DefaultNameFormatter.getInstance())), true); 
    9571018                            } 
    958                             if(o == null || o.contains(pd.poly) > 0) 
     1019                            if(o == null || o.contains(pd.poly) > 0) { 
    9591020                                o = pd; 
     1021                            } 
    9601022                        } 
    9611023                    } 
     
    9651027                        { 
    9661028                            r.putError(tr("Inner way ''{0}'' is outside.", 
    967                             wInner.getName()), true); 
     1029                                    wInner.getDisplayName(DefaultNameFormatter.getInstance())), true); 
    9681030                        } 
    9691031                        o = poly.get(0); 
     
    9781040                    { 
    9791041                        drawAreaPolygon(p, (pd.way.isSelected() || r.isSelected()) ? selectedColor 
    980                         : areaStyle.color); 
     1042                                : areaStyle.color); 
    9811043                        visible = true; 
    9821044                    } 
     
    9861048            { 
    9871049                r.mappaintVisibleCode = viewid; 
    988                 for (Way wInner : inner) 
     1050                for (Way wInner : inner) { 
    9891051                    wInner.mappaintVisibleCode = viewid; 
    990                 for (Way wOuter : outer) 
     1052                } 
     1053                for (Way wOuter : outer) { 
    9911054                    wOuter.mappaintVisibleCode = viewid; 
     1055                } 
    9921056                return drawn; 
    9931057            } 
     
    9981062                { 
    9991063                    if(zoomok && (wInner.mappaintDrawnCode != paintid 
    1000                     || outer.size() == 0)) 
     1064                            || outer.size() == 0)) 
    10011065                    { 
    10021066                        drawWay(wInner, ((AreaElemStyle)wayStyle).line, 
    1003                         ((AreaElemStyle)wayStyle).color, wInner.isSelected() 
    1004                         || r.isSelected()); 
     1067                                ((AreaElemStyle)wayStyle).color, wInner.isSelected() 
     1068                                || r.isSelected()); 
    10051069                    } 
    10061070                    wInner.mappaintDrawnCode = paintid; 
     
    10111075                    { 
    10121076                        drawSelectedMember(wInner, innerStyle, 
    1013                         !wayStyle.equals(innerStyle), wInner.isSelected()); 
     1077                                !wayStyle.equals(innerStyle), wInner.isSelected()); 
    10141078                    } 
    10151079                    if(wayStyle.equals(innerStyle)) 
    10161080                    { 
    10171081                        r.putError(tr("Style for inner way ''{0}'' equals multipolygon.", 
    1018                         wInner.getName()), false); 
    1019                         if(!r.isSelected()) 
     1082                                wInner.getDisplayName(DefaultNameFormatter.getInstance())), false); 
     1083                        if(!r.isSelected()) { 
    10201084                            wInner.mappaintDrawnAreaCode = paintid; 
     1085                        } 
    10211086                    } 
    10221087                } 
     
    10301095                    { 
    10311096                        drawWay(wOuter, ((AreaElemStyle)wayStyle).line, 
    1032                         ((AreaElemStyle)wayStyle).color, wOuter.isSelected() 
    1033                         || r.isSelected()); 
     1097                                ((AreaElemStyle)wayStyle).color, wOuter.isSelected() 
     1098                                || r.isSelected()); 
    10341099                    } 
    10351100                    wOuter.mappaintDrawnCode = paintid; 
     
    10381103                { 
    10391104                    if(outerStyle instanceof AreaElemStyle 
    1040                     && !wayStyle.equals(outerStyle)) 
     1105                            && !wayStyle.equals(outerStyle)) 
    10411106                    { 
    10421107                        r.putError(tr("Style for outer way ''{0}'' mismatches.", 
    1043                         wOuter.getName()), true); 
     1108                                wOuter.getDisplayName(DefaultNameFormatter.getInstance())), true); 
    10441109                    } 
    10451110                    if(r.isSelected()) 
     
    10471112                        drawSelectedMember(wOuter, outerStyle, false, false); 
    10481113                    } 
    1049                     else if(outerStyle instanceof AreaElemStyle) 
     1114                    else if(outerStyle instanceof AreaElemStyle) { 
    10501115                        wOuter.mappaintDrawnAreaCode = paintid; 
     1116                    } 
    10511117                } 
    10521118            } 
     
    11151181            for (String rn : regionalNameOrder) { 
    11161182                name = n.get(rn); 
    1117                 if (name != null) break; 
     1183                if (name != null) { 
     1184                    break; 
     1185                } 
    11181186            } 
    11191187        } 
     
    11291197        Point p2 = nc.getPoint(n2); 
    11301198 
    1131         if (!isSegmentVisible(p1, p2)) { 
     1199        if (!isSegmentVisible(p1, p2)) 
    11321200            return; 
    1133         } 
    11341201        //profilerVisibleSegments++; 
    11351202        currentPath.moveTo(p1.x, p1.y); 
     
    11441211    } 
    11451212 
     1213    @Override 
    11461214    protected void displaySegments() { 
    11471215        displaySegments(null, 0, new float[0], null); 
     
    11591227                        g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); 
    11601228                    } 
    1161                 } 
    1162                 else 
     1229                } else { 
    11631230                    g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); 
     1231                } 
    11641232            } 
    11651233            g2d.draw(currentPath); 
     
    11781246                            g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); 
    11791247                        } 
    1180                     } 
    1181                     else 
     1248                    } else { 
    11821249                        g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); 
     1250                    } 
    11831251                } 
    11841252                g2d.draw(currentPath); 
    11851253            } 
    11861254 
    1187             if(useStrokes > dist) 
     1255            if(useStrokes > dist) { 
    11881256                g2d.setStroke(new BasicStroke(1)); 
     1257            } 
    11891258 
    11901259            currentPath = new GeneralPath(); 
     
    12031272     * @param color The color of the node. 
    12041273     */ 
     1274    @Override 
    12051275    public void drawNode(Node n, Color color, int size, int radius, boolean fill) { 
    12061276        if (isZoomOk(null) && size > 1) { 
     
    12161286                g.fillRect(p.x - radius, p.y - radius, size, size); 
    12171287                g.drawRect(p.x - radius, p.y - radius, size, size); 
    1218             } else 
     1288            } else { 
    12191289                g.drawRect(p.x - radius, p.y - radius, size, size); 
     1290            } 
    12201291 
    12211292            if(showNames > dist) 
     
    12341305    } 
    12351306 
     1307    @Override 
    12361308    public void getColors() 
    12371309    { 
     
    12421314 
    12431315    /* Shows areas before non-areas */ 
     1316    @Override 
    12441317    public void visitAll(DataSet data, Boolean virtual) { 
    12451318 
     
    13031376 
    13041377            /*** RELATIONS ***/ 
    1305         //    profilerN = 0; 
     1378            //    profilerN = 0; 
    13061379            for (final Relation osm : data.relations) 
    13071380            { 
     
    13091382                { 
    13101383                    osm.visit(this); 
    1311         //            profilerN++; 
    1312                 } 
    1313             } 
    1314  
    1315         //    if(profiler) 
    1316         //    { 
    1317         //        System.out.format("Relations: %5dms, calls=%7d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 
    1318         //        profilerLast = java.lang.System.currentTimeMillis(); 
    1319         //    } 
     1384                    //            profilerN++; 
     1385                } 
     1386            } 
     1387 
     1388            //    if(profiler) 
     1389            //    { 
     1390            //        System.out.format("Relations: %5dms, calls=%7d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 
     1391            //        profilerLast = java.lang.System.currentTimeMillis(); 
     1392            //    } 
    13201393 
    13211394            /*** AREAS ***/ 
    1322         //    profilerN = 0; 
     1395            //    profilerN = 0; 
    13231396            for (final Way osm : data.ways) 
    13241397            { 
    13251398                if (!osm.incomplete && !osm.deleted 
    1326                 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) 
     1399                        && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) 
    13271400                { 
    13281401                    if(isPrimitiveArea(osm) && osm.mappaintDrawnAreaCode != paintid) 
    13291402                    { 
    13301403                        osm.visit(this); 
    1331         //                profilerN++; 
    1332                     } else 
     1404                        //                profilerN++; 
     1405                    } else { 
    13331406                        noAreaWays.add(osm); 
    1334                 } 
    1335             } 
    1336  
    1337         //    if(profiler) 
    1338         //    { 
    1339         //        System.out.format("Areas    : %5dms, calls=%7d, visible=%d\n", 
    1340         //            (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleAreas); 
    1341         //        profilerLast = java.lang.System.currentTimeMillis(); 
    1342         //    } 
     1407                    } 
     1408                } 
     1409            } 
     1410 
     1411            //    if(profiler) 
     1412            //    { 
     1413            //        System.out.format("Areas    : %5dms, calls=%7d, visible=%d\n", 
     1414            //            (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleAreas); 
     1415            //        profilerLast = java.lang.System.currentTimeMillis(); 
     1416            //    } 
    13431417 
    13441418            /*** WAYS ***/ 
    1345         //    profilerN = 0; 
     1419            //    profilerN = 0; 
    13461420            fillAreas = 0; 
    13471421            for (final OsmPrimitive osm : noAreaWays) 
    13481422            { 
    13491423                osm.visit(this); 
    1350         //        profilerN++; 
    1351             } 
    1352  
    1353         //    if(profiler) 
    1354         //    { 
    1355         //        System.out.format("Ways     : %5dms, calls=%7d, visible=%d\n", 
    1356         //            (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleWays); 
    1357         //        profilerLast = java.lang.System.currentTimeMillis(); 
    1358         //    } 
     1424                //        profilerN++; 
     1425            } 
     1426 
     1427            //    if(profiler) 
     1428            //    { 
     1429            //        System.out.format("Ways     : %5dms, calls=%7d, visible=%d\n", 
     1430            //            (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleWays); 
     1431            //        profilerLast = java.lang.System.currentTimeMillis(); 
     1432            //    } 
    13591433        } 
    13601434        else 
    13611435        { 
    13621436            /*** WAYS (filling disabled)  ***/ 
    1363         //    profilerN = 0; 
     1437            //    profilerN = 0; 
    13641438            for (final OsmPrimitive osm : data.ways) 
    13651439                if (!osm.incomplete && !osm.deleted && !osm.isSelected() 
    1366                 && osm.mappaintVisibleCode != viewid ) 
     1440                        && osm.mappaintVisibleCode != viewid ) 
    13671441                { 
    13681442                    osm.visit(this); 
    1369         //            profilerN++; 
    1370                 } 
    1371  
    1372         //    if(profiler) 
    1373         //    { 
    1374         //        System.out.format("Ways     : %5dms, calls=%7d, visible=%d\n", 
    1375         //            (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleWays); 
    1376         //        profilerLast = java.lang.System.currentTimeMillis(); 
    1377         //    } 
     1443                    //            profilerN++; 
     1444                } 
     1445 
     1446            //    if(profiler) 
     1447            //    { 
     1448            //        System.out.format("Ways     : %5dms, calls=%7d, visible=%d\n", 
     1449            //            (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleWays); 
     1450            //        profilerLast = java.lang.System.currentTimeMillis(); 
     1451            //    } 
    13781452        } 
    13791453 
     
    13831457        for (final OsmPrimitive osm : data.getSelected()) { 
    13841458            if (!osm.incomplete && !osm.deleted && !(osm instanceof Node) 
    1385             && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) 
     1459                    && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) 
    13861460            { 
    13871461                osm.visit(this); 
    1388         //        profilerN++; 
     1462                //        profilerN++; 
    13891463            } 
    13901464        } 
     
    14031477        for (final OsmPrimitive osm : data.nodes) 
    14041478            if (!osm.incomplete && !osm.deleted 
    1405             && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) 
     1479                    && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) 
    14061480            { 
    14071481                osm.visit(this); 
    1408         //        profilerN++; 
     1482                //        profilerN++; 
    14091483            } 
    14101484 
     
    14191493        if (virtualNodeSize != 0) 
    14201494        { 
    1421         //    profilerN = 0; 
     1495            //    profilerN = 0; 
    14221496            currentColor = nodeColor; 
    14231497            for (final OsmPrimitive osm : data.ways) 
    14241498                if (!osm.incomplete && !osm.deleted 
    1425                 && osm.mappaintVisibleCode != viewid ) 
     1499                        && osm.mappaintVisibleCode != viewid ) 
    14261500                { 
    14271501                    /* TODO: move this into the SimplePaint code? */ 
    1428         //            if(!profilerOmitDraw) 
    1429                         visitVirtual((Way)osm); 
    1430         //            profilerN++; 
    1431                 } 
    1432  
    1433         //    if(profiler) 
    1434         //    { 
    1435         //        System.out.format("Virtual  : %5dms, calls=%7d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 
    1436         //        profilerLast = java.lang.System.currentTimeMillis(); 
    1437         //    } 
     1502                    //            if(!profilerOmitDraw) 
     1503                    visitVirtual((Way)osm); 
     1504                    //            profilerN++; 
     1505                } 
     1506 
     1507            //    if(profiler) 
     1508            //    { 
     1509            //        System.out.format("Virtual  : %5dms, calls=%7d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 
     1510            //        profilerLast = java.lang.System.currentTimeMillis(); 
     1511            //    } 
    14381512 
    14391513            displaySegments(null); 
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r1814 r1990  
    3737import org.openstreetmap.josm.Main; 
    3838import org.openstreetmap.josm.actions.HelpAction.Helpful; 
     39import org.openstreetmap.josm.data.coor.CoordinateFormat; 
    3940import org.openstreetmap.josm.data.coor.LatLon; 
    40 import org.openstreetmap.josm.data.coor.LatLon.CoordinateFormat; 
    41 import org.openstreetmap.josm.data.osm.Node; 
    4241import org.openstreetmap.josm.data.osm.OsmPrimitive; 
    4342import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 
     
    5958 */ 
    6059public class MapStatus extends JPanel implements Helpful { 
    61     private static final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter(); 
    6260 
    6361    /** 
     
    163161                    osmNearest = mv.getNearest(ms.mousePos); 
    164162                    if (osmNearest != null) { 
    165                         nameText.setText(NAME_FORMATTER.getName(osmNearest)); 
     163                        nameText.setText(osmNearest.getDisplayName(DefaultNameFormatter.getInstance())); 
    166164                    } else { 
    167165                        nameText.setText(tr("(no object)")); 
     
    195193                        for (final OsmPrimitive osm : osms) { 
    196194                            final StringBuilder text = new StringBuilder(); 
    197                             String name = NAME_FORMATTER.getName(osm); 
     195                            String name = osm.getDisplayName(DefaultNameFormatter.getInstance()); 
    198196                            if (osm.id == 0 || osm.modified) { 
    199                                 name = "<i><b>"+ new PrimitiveNameFormatter().getName(osm)+"*</b></i>"; 
     197                                name = "<i><b>"+ osm.getDisplayName(DefaultNameFormatter.getInstance())+"*</b></i>"; 
    200198                            } 
    201199                            text.append(name); 
     
    283281                // Do not update the view if ctrl is pressed. 
    284282                if ((e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) == 0) { 
    285                     CoordinateFormat mCord = Node.getCoordinateFormat(); 
     283                    CoordinateFormat mCord = CoordinateFormat.getDefaultFormat(); 
    286284                    LatLon p = mv.getLatLon(e.getX(),e.getY()); 
    287285                    latText.setText(p.latToString(mCord)); 
  • trunk/src/org/openstreetmap/josm/gui/OsmPrimitivRenderer.java

    r1814 r1990  
    2525 */ 
    2626public class OsmPrimitivRenderer implements ListCellRenderer, TableCellRenderer { 
    27     static private final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter(); 
    28  
    2927    /** 
    3028     * Default list cell renderer - delegate for ListCellRenderer operation 
     
    6260    private Component renderer(Component def, OsmPrimitive value) { 
    6361        if (def != null && value != null && def instanceof JLabel) { 
    64             ((JLabel)def).setText(NAME_FORMATTER.getName(value)); 
     62            ((JLabel)def).setText(value.getDisplayName(DefaultNameFormatter.getInstance())); 
    6563            ((JLabel)def).setIcon(ImageProvider.get(OsmPrimitiveType.from(value))); 
    6664        } 
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListTableCellRenderer.java

    r1954 r1990  
    2020import org.openstreetmap.josm.data.osm.Node; 
    2121import org.openstreetmap.josm.data.osm.OsmPrimitive; 
     22import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    2223import org.openstreetmap.josm.gui.conflict.pair.ListMergeModel; 
    2324import org.openstreetmap.josm.tools.ImageProvider; 
     
    130131            } 
    131132        } 
    132         setText(node.getName()); 
     133        setText(node.getDisplayName(DefaultNameFormatter.getInstance())); 
    133134        setToolTipText(buildToolTipText(node)); 
    134135    } 
     
    167168        reset(); 
    168169        switch(column) { 
    169             case 0: 
    170                 renderRowId(getModel(table),row, isSelected); 
    171                 break; 
    172             case 1: 
    173                 if (node == null) { 
    174                     renderEmptyRow(); 
    175                 } else { 
    176                     renderNode(getModel(table), node, row, isSelected); 
    177                 } 
    178                 break; 
    179             default: 
    180                 // should not happen 
    181                 throw new RuntimeException(tr("unexpected column index. Got {0}", column)); 
     170        case 0: 
     171            renderRowId(getModel(table),row, isSelected); 
     172            break; 
     173        case 1: 
     174            if (node == null) { 
     175                renderEmptyRow(); 
     176            } else { 
     177                renderNode(getModel(table), node, row, isSelected); 
     178            } 
     179            break; 
     180        default: 
     181            // should not happen 
     182            throw new RuntimeException(tr("unexpected column index. Got {0}", column)); 
    182183        } 
    183184        return this; 
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberTableCellRenderer.java

    r1954 r1990  
    1818import org.openstreetmap.josm.data.osm.OsmPrimitive; 
    1919import org.openstreetmap.josm.data.osm.RelationMember; 
     20import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    2021import org.openstreetmap.josm.gui.conflict.pair.ListMergeModel; 
    2122import org.openstreetmap.josm.tools.ImageProvider; 
     
    156157 
    157158    protected void renderPrimitive(RelationMember member) { 
    158         String displayName = member.getMember().getName(); 
     159        String displayName = member.getMember().getDisplayName(DefaultNameFormatter.getInstance()); 
    159160        setText(displayName); 
    160161        setToolTipText(buildToolTipText(member.getMember())); 
     
    196197        renderForeground(getModel(table), member, row, column, isSelected); 
    197198        switch(column) { 
    198             case 0: 
    199                 renderRowId(row); 
    200                 break; 
    201             case 1: 
    202                 if (member == null) { 
    203                     renderEmptyRow(); 
    204                 } else { 
    205                     renderRole(member); 
    206                 } 
    207                 break; 
    208             case 2: 
    209                 if (member == null) { 
    210                     renderEmptyRow(); 
    211                 } else { 
    212                     renderPrimitive(member); 
    213                 } 
    214                 break; 
    215             default: 
    216                 // should not happen 
     199        case 0: 
     200            renderRowId(row); 
     201            break; 
     202        case 1: 
     203            if (member == null) { 
     204                renderEmptyRow(); 
     205            } else { 
     206                renderRole(member); 
     207            } 
     208            break; 
     209        case 2: 
     210            if (member == null) { 
     211                renderEmptyRow(); 
     212            } else { 
     213                renderPrimitive(member); 
     214            } 
     215            break; 
     216        default: 
     217            // should not happen 
    217218        } 
    218219        return this; 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialog.java

    r1987 r1990  
    2525import org.openstreetmap.josm.command.Command; 
    2626import org.openstreetmap.josm.data.osm.OsmPrimitive; 
     27import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    2728import org.openstreetmap.josm.gui.OptionPaneUtil; 
    28 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 
    2929import org.openstreetmap.josm.gui.conflict.pair.ConflictResolver; 
    3030import org.openstreetmap.josm.gui.conflict.pair.properties.OperationCancelledException; 
     
    241241            setTitle(tr("Resolve conflicts")); 
    242242        } else { 
    243             PrimitiveNameFormatter formatter = new PrimitiveNameFormatter(); 
    244             setTitle(tr("Resolve conflicts for ''{0}''", formatter.getName(my))); 
     243            setTitle(tr("Resolve conflicts for ''{0}''", my.getDisplayName(DefaultNameFormatter.getInstance()))); 
    245244        } 
    246245    } 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java

    r1987 r1990  
    6666import org.openstreetmap.josm.data.osm.RelationMember; 
    6767import org.openstreetmap.josm.data.osm.Way; 
     68import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    6869import org.openstreetmap.josm.gui.ExtendedDialog; 
    6970import org.openstreetmap.josm.gui.MapFrame; 
    70 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 
    7171import org.openstreetmap.josm.gui.SideButton; 
    7272import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 
     
    9999 */ 
    100100public class PropertiesDialog extends ToggleDialog implements SelectionChangedListener, LayerChangeListener { 
    101     static private final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter(); 
    102  
    103101    /** 
    104102     * Watches for double clicks and from editing or new property, depending on the 
     
    498496                Component c = super.getTableCellRendererComponent(table, value, isSelected, false, row, column); 
    499497                if (c instanceof JLabel) { 
    500                     ((JLabel)c).setText(NAME_FORMATTER.getName((Relation)value)); 
     498                    ((JLabel)c).setText(((Relation)value).getDisplayName(DefaultNameFormatter.getInstance())); 
    501499                } 
    502500                return c; 
     
    837835            int result = new ExtendedDialog(Main.parent, 
    838836                    tr("Change relation"), 
    839                     tr("Really delete selection from relation {0}?", NAME_FORMATTER.getName(cur)), 
     837                    tr("Really delete selection from relation {0}?", cur.getDisplayName(DefaultNameFormatter.getInstance())), 
    840838                    new String[] {tr("Delete from relation"), tr("Cancel")}, 
    841839                    new String[] {"dialogs/delete.png", "cancel.png"}).getValue(); 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java

    r1944 r1990  
    2929import org.openstreetmap.josm.data.osm.RelationMember; 
    3030import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 
    31 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 
    3231import org.openstreetmap.josm.gui.SideButton; 
    3332import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 
     
    4948public class RelationListDialog extends ToggleDialog implements LayerChangeListener, DataChangeListener { 
    5049    private static final Logger logger = Logger.getLogger(RelationListDialog.class.getName()); 
    51     static private final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter(); 
    5250 
    5351    /** 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ChildRelationBrowser.java

    r1937 r1990  
    3434import org.openstreetmap.josm.data.osm.RelationMember; 
    3535import org.openstreetmap.josm.data.osm.visitor.MergeVisitor; 
     36import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    3637import org.openstreetmap.josm.gui.ExceptionDialogUtil; 
    3738import org.openstreetmap.josm.gui.OptionPaneUtil; 
    3839import org.openstreetmap.josm.gui.PleaseWaitRunnable; 
    39 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 
    4040import org.openstreetmap.josm.gui.layer.OsmDataLayer; 
    4141import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor; 
     
    342342         */ 
    343343        protected void warnBecauseOfDeletedRelation(Relation r) { 
    344             PrimitiveNameFormatter nameFormatter = new PrimitiveNameFormatter(); 
    345  
    346344            String message = tr("<html>The child relation<br>" 
    347345                    + "{0}<br>" 
    348346                    + "is deleted on the server. It can't be loaded", 
    349                     nameFormatter.getName(r) 
     347                    r.getDisplayName(DefaultNameFormatter.getInstance()) 
    350348            ); 
    351349 
     
    404402        protected void realRun() throws SAXException, IOException, OsmTransferException { 
    405403            try { 
    406                 PrimitiveNameFormatter nameFormatter = new PrimitiveNameFormatter(); 
    407404                while(! relationsToDownload.isEmpty() && !cancelled) { 
    408405                    Relation r = relationsToDownload.pop(); 
     
    411408                    } 
    412409                    rememberChildRelationsToDownload(r); 
    413                     progressMonitor.setCustomText(tr("Downloading relation {0}", nameFormatter.getName(r))); 
     410                    progressMonitor.setCustomText(tr("Downloading relation {0}", r.getDisplayName(DefaultNameFormatter.getInstance()))); 
    414411                    OsmServerObjectReader reader = new OsmServerObjectReader(r.id, OsmPrimitiveType.RELATION, 
    415412                            true); 
     
    515512        protected void realRun() throws SAXException, IOException, OsmTransferException { 
    516513            try { 
    517                 PrimitiveNameFormatter nameFormatter = new PrimitiveNameFormatter(); 
    518514                Iterator<Relation> it = relations.iterator(); 
    519515                while(it.hasNext() && !cancelled) { 
     
    522518                        continue; 
    523519                    } 
    524                     progressMonitor.setCustomText(tr("Downloading relation {0}", nameFormatter.getName(r))); 
     520                    progressMonitor.setCustomText(tr("Downloading relation {0}", r.getDisplayName(DefaultNameFormatter.getInstance()))); 
    525521                    OsmServerObjectReader reader = new OsmServerObjectReader(r.id, OsmPrimitiveType.RELATION, 
    526522                            true); 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java

    r1987 r1990  
    6464import org.openstreetmap.josm.data.osm.visitor.MergeVisitor; 
    6565import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; 
     66import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    6667import org.openstreetmap.josm.gui.ExceptionDialogUtil; 
    6768import org.openstreetmap.josm.gui.OptionPaneUtil; 
    6869import org.openstreetmap.josm.gui.PleaseWaitRunnable; 
    69 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 
    7070import org.openstreetmap.josm.gui.SideButton; 
    7171import org.openstreetmap.josm.gui.dialogs.relation.ac.AutoCompletionCache; 
     
    697697 
    698698    abstract class  AddFromSelectionAction extends AbstractAction { 
    699         private PrimitiveNameFormatter nameFormatter = new PrimitiveNameFormatter(); 
    700  
    701699        protected boolean isPotentialDuplicate(OsmPrimitive primitive) { 
    702700            return memberTableModel.hasMembersReferringTo(Collections.singleton(primitive)); 
     
    708706                    + "<br>" 
    709707                    + "Do you really want to add another relation member?</html>", 
    710                     nameFormatter.getName(primitive) 
     708                    primitive.getDisplayName(DefaultNameFormatter.getInstance()) 
    711709            ); 
    712710            int ret = ConditionalOptionPaneUtil.showOptionDialog( 
     
    736734                    + "This creates circular references and is therefore discouraged.<br>" 
    737735                    + "Skipping relation ''{0}''.</html>", 
    738                     this.nameFormatter.getName(primitive) 
     736                    primitive.getDisplayName(DefaultNameFormatter.getInstance()) 
    739737            ); 
    740738            OptionPaneUtil.showMessageDialog( 
     
    11701168                            + "Please resolve this conflict first, then try again.</html>", 
    11711169                            getLayer().getName(), 
    1172                             new PrimitiveNameFormatter().getName(getRelation()) 
     1170                            getRelation().getDisplayName(DefaultNameFormatter.getInstance()) 
    11731171                    ), 
    11741172                    tr("Double conflict"), 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableMemberCellRenderer.java

    r1822 r1990  
    1010import org.openstreetmap.josm.data.osm.OsmPrimitive; 
    1111import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 
    12 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 
     12import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    1313import org.openstreetmap.josm.tools.ImageProvider; 
    1414 
    1515public class MemberTableMemberCellRenderer extends MemberTableCellRenderer { 
    1616    private HashMap<OsmPrimitiveType, ImageIcon> icons; 
    17     static private final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter(); 
    1817 
    1918    public MemberTableMemberCellRenderer() { 
     
    3635    protected void renderPrimitive(OsmPrimitive primitive) { 
    3736        setIcon(icons.get(OsmPrimitiveType.from(primitive))); 
    38         setText(NAME_FORMATTER.getName(primitive)); 
     37        setText(primitive.getDisplayName(DefaultNameFormatter.getInstance())); 
    3938        setToolTipText(buildToolTipText(primitive)); 
    4039    } 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationTreeCellRenderer.java

    r1828 r1990  
    1111 
    1212import org.openstreetmap.josm.data.osm.Relation; 
    13 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 
     13import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    1414import org.openstreetmap.josm.tools.ImageProvider; 
    1515 
     
    2020 */ 
    2121public class RelationTreeCellRenderer extends JLabel implements TreeCellRenderer { 
    22     private static final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter(); 
    2322    public final static Color BGCOLOR_SELECTED = new Color(143,170,255); 
    2423 
     
    4746     */ 
    4847    protected void renderValue(Relation relation) { 
    49         setText(NAME_FORMATTER.getName(relation)); 
     48        setText(relation.getDisplayName(DefaultNameFormatter.getInstance())); 
    5049    } 
    5150 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/SelectionTableCellRenderer.java

    r1814 r1990  
    1515import org.openstreetmap.josm.data.osm.OsmPrimitive; 
    1616import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 
    17 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 
     17import org.openstreetmap.josm.gui.DefaultNameFormatter; 
    1818import org.openstreetmap.josm.tools.ImageProvider; 
    1919 
     
    2323 */ 
    2424public  class SelectionTableCellRenderer extends JLabel implements TableCellRenderer { 
    25     static private final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter(); 
    26  
    2725    public final static Color BGCOLOR_SELECTED = new Color(143,170,255); 
    2826    public final static Color BGCOLOR_DOUBLE_ENTRY = new Color(255,234,213); 
     
    118116    protected void renderPrimitive(OsmPrimitive primitive) { 
    119117        setIcon(icons.get(OsmPrimitiveType.from(primitive))); 
    120         setText(NAME_FORMATTER.getName(primitive)); 
     118        setText(primitive.getDisplayName(DefaultNameFormatter.getInstance())); 
    121119        setToolTipText(buildToolTipText(primitive)); 
    122120    } 
  • trunk/src/org/openstreetmap/josm/gui/preferences/LafPreference.java

    r1742 r1990  
    3838    private JCheckBox showSplashScreen = new JCheckBox(tr("Show splash screen at startup")); 
    3939    private JCheckBox showID = new JCheckBox(tr("Show object ID in selection lists")); 
     40    private JCheckBox showLocalizedName = new JCheckBox(tr("Show localized name in selection lists")); 
    4041    private JCheckBox drawHelperLine = new JCheckBox(tr("Draw rubber-band helper line")); 
    4142    private JCheckBox modeless = new JCheckBox(tr("Modeless working (Potlatch style)")); 
     
    5051            // no exception? Then Go! 
    5152            lafCombo.addItem( 
    52                 new UIManager.LookAndFeelInfo(((javax.swing.LookAndFeel)Oquaqua).getName(), "ch.randelshofer.quaqua.QuaquaLookAndFeel") 
     53                    new UIManager.LookAndFeelInfo(((javax.swing.LookAndFeel)Oquaqua).getName(), "ch.randelshofer.quaqua.QuaquaLookAndFeel") 
    5354            ); 
    5455        } catch (Exception ex) { 
     
    8586        panel.add(showID, GBC.eop().insets(20, 0, 0, 0)); 
    8687 
     88        // Show localized names 
     89        showLocalizedName.setToolTipText(tr("Show localized name in selection lists, if available")); 
     90        showLocalizedName.setSelected(Main.pref.getBoolean("osm-primitives.localize-name", true)); 
     91        panel.add(showLocalizedName, GBC.eop().insets(20, 0, 0, 0)); 
     92 
    8793        drawHelperLine.setToolTipText(tr("Draw rubber-band helper line")); 
    8894        drawHelperLine.setSelected(Main.pref.getBoolean("draw.helper-line", true)); 
     
    107113        Main.pref.put("draw.splashscreen", showSplashScreen.isSelected()); 
    108114        Main.pref.put("osm-primitives.showid", showID.isSelected()); 
     115        Main.pref.put("osm-primitives.localize-name", showLocalizedName.isSelected()); 
    109116        Main.pref.put("draw.helper-line", drawHelperLine.isSelected()); 
    110117        Main.pref.put("modeless", modeless.isSelected()); 
    111118        return Main.pref.put("laf", ((LookAndFeelInfo)lafCombo.getSelectedItem()).getClassName()); 
    112119    } 
    113  
    114120} 
  • trunk/src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java

    r1747 r1990  
    1515 
    1616import org.openstreetmap.josm.Main; 
    17 import org.openstreetmap.josm.data.coor.LatLon.CoordinateFormat; 
     17import org.openstreetmap.josm.data.coor.CoordinateFormat; 
    1818import org.openstreetmap.josm.data.osm.Node; 
    1919import org.openstreetmap.josm.data.projection.Mercator; 
     
    6767    public boolean ok() { 
    6868        String projname = projectionCombo.getSelectedItem().getClass().getName(); 
    69         if(Main.pref.put("projection", projname)) 
     69        if(Main.pref.put("projection", projname)) { 
    7070            Main.setProjection(projname); 
     71        } 
    7172        if(Main.pref.put("coordinates", 
    72         ((CoordinateFormat)coordinatesCombo.getSelectedItem()).name())) 
    73             Node.setCoordinateFormat(); 
     73                ((CoordinateFormat)coordinatesCombo.getSelectedItem()).name())) { 
     74            CoordinateFormat.setCoordinateFormat((CoordinateFormat)coordinatesCombo.getSelectedItem()); 
     75        } 
    7476        return false; 
    7577    } 
  • trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java

    r1989 r1990  
    22package org.openstreetmap.josm.io; 
    33 
     4import static org.openstreetmap.josm.tools.I18n.marktr; 
    45import static org.openstreetmap.josm.tools.I18n.tr; 
    5 import static org.openstreetmap.josm.tools.I18n.marktr; 
    66 
    77import java.util.Collection; 
    8 import java.util.Collections; 
    98import java.util.LinkedList; 
    109import java.util.List; 
     
    1615import org.openstreetmap.josm.data.osm.OsmPrimitive; 
    1716import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 
    18 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 
    1917import org.openstreetmap.josm.gui.progress.ProgressMonitor; 
    2018 
     
    2725 */ 
    2826public class OsmServerWriter { 
    29     static private final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter(); 
    3027    static private final Logger logger = Logger.getLogger(OsmServerWriter.class.getName()); 
    3128 
     
    108105                                primitives.size(), 
    109106                                time_left_str, 
    110                                 NAME_FORMATTER.getName(osm), 
     107                                osm.getLocalName(), 
    111108                                osm.id)); 
    112109                makeApiRequest(osm,progressMonitor); 
Note: See TracChangeset for help on using the changeset viewer.