Changeset 1990 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-08-23T22:37:39+02:00 (15 years ago)
- 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 34 34 import org.openstreetmap.josm.data.Preferences; 35 35 import org.openstreetmap.josm.data.UndoRedoHandler; 36 import org.openstreetmap.josm.data.coor.CoordinateFormat; 36 37 import org.openstreetmap.josm.data.osm.DataSet; 37 38 import org.openstreetmap.josm.data.projection.Mercator; … … 330 331 UIManager.put("OptionPane.noIcon", UIManager.get("OptionPane.cancelIcon")); 331 332 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 332 343 Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize(); 333 344 String geometry = Main.pref.get("gui.geometry"); -
trunk/src/org/openstreetmap/josm/actions/DownloadReferrersAction.java
r1847 r1990 18 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 19 import org.openstreetmap.josm.data.osm.visitor.MergeVisitor; 20 import org.openstreetmap.josm.gui.DefaultNameFormatter; 20 21 import org.openstreetmap.josm.gui.OptionPaneUtil; 21 22 import org.openstreetmap.josm.gui.PleaseWaitRunnable; … … 147 148 if (cancelled) 148 149 return; 149 progressMonitor.subTask(tr("({0}/{1}) Loading parents of primitive {2}", i+1,primitives.size(), primitive.get Name()));150 progressMonitor.subTask(tr("({0}/{1}) Loading parents of primitive {2}", i+1,primitives.size(), primitive.getDisplayName(DefaultNameFormatter.getInstance()))); 150 151 downloadParents(primitive, progressMonitor.createSubTaskMonitor(1, false)); 151 152 i++; -
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r1951 r1990 31 31 import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor; 32 32 import org.openstreetmap.josm.data.osm.visitor.Visitor; 33 import org.openstreetmap.josm.gui.DefaultNameFormatter; 33 34 import org.openstreetmap.josm.gui.OptionPaneUtil; 34 import org.openstreetmap.josm.gui.PrimitiveNameFormatter;35 35 import org.openstreetmap.josm.tools.Shortcut; 36 36 … … 357 357 Main.main.undoRedo.add( 358 358 new SequenceCommand(tr("Split way {0} into {1} parts", 359 new PrimitiveNameFormatter().getName(selectedWay), wayChunks.size()), 359 selectedWay.getDisplayName(DefaultNameFormatter.getInstance()), 360 wayChunks.size()), 360 361 commandList)); 361 362 getCurrentDataSet().setSelected(newSelection); -
trunk/src/org/openstreetmap/josm/command/AddCommand.java
r1989 r1990 13 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 14 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 15 import org.openstreetmap.josm.gui. PrimitiveNameFormatter;15 import org.openstreetmap.josm.gui.DefaultNameFormatter; 16 16 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 17 17 import org.openstreetmap.josm.tools.ImageProvider; … … 73 73 new JLabel( 74 74 tr(msg, 75 new PrimitiveNameFormatter().getName(osm)75 osm.getDisplayName(DefaultNameFormatter.getInstance()) 76 76 ), 77 77 ImageProvider.get(OsmPrimitiveType.from(osm)), -
trunk/src/org/openstreetmap/josm/command/ChangeCommand.java
r1989 r1990 13 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 14 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 15 import org.openstreetmap.josm.gui. PrimitiveNameFormatter;15 import org.openstreetmap.josm.gui.DefaultNameFormatter; 16 16 import org.openstreetmap.josm.tools.ImageProvider; 17 17 … … 53 53 return new DefaultMutableTreeNode( 54 54 new JLabel(tr(msg, 55 new PrimitiveNameFormatter().getName(osm)),55 osm.getDisplayName(DefaultNameFormatter.getInstance()), 56 56 ImageProvider.get(OsmPrimitiveType.from(osm)), 57 JLabel.HORIZONTAL)) ;57 JLabel.HORIZONTAL))); 58 58 } 59 59 } -
trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java
r1989 r1990 2 2 package org.openstreetmap.josm.command; 3 3 4 import static org.openstreetmap.josm.tools.I18n.marktr; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.marktr;6 6 import static org.openstreetmap.josm.tools.I18n.trn; 7 7 … … 16 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; 17 17 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 18 import org.openstreetmap.josm.gui. PrimitiveNameFormatter;18 import org.openstreetmap.josm.gui.DefaultNameFormatter; 19 19 import org.openstreetmap.josm.tools.ImageProvider; 20 20 … … 95 95 @Override public MutableTreeNode description() { 96 96 String text; 97 PrimitiveNameFormatter formatter = new PrimitiveNameFormatter();98 97 if (objects.size() == 1) { 99 98 OsmPrimitive primitive = objects.iterator().next(); 100 String name = formatter.getName(primitive);101 99 String msg = ""; 102 100 if (value == null) { … … 106 104 case RELATION: msg = marktr("Remove \"{0}\" for relation ''{1}''"); break; 107 105 } 108 text = tr(msg, key, name);106 text = tr(msg, key, primitive.getDisplayName(DefaultNameFormatter.getInstance())); 109 107 } else { 110 108 switch(OsmPrimitiveType.from(primitive)) { … … 113 111 case RELATION: msg = marktr("Set {0}={1} for relation ''{2}''"); break; 114 112 } 115 text = tr(msg, key, value, name);113 text = tr(msg, key, value, primitive.getDisplayName(DefaultNameFormatter.getInstance())); 116 114 } 117 115 } … … 128 126 root.add(new DefaultMutableTreeNode( 129 127 new JLabel( 130 formatter.getName(osm),128 osm.getDisplayName(DefaultNameFormatter.getInstance()), 131 129 ImageProvider.get(OsmPrimitiveType.from(osm)), 132 130 JLabel.HORIZONTAL) -
trunk/src/org/openstreetmap/josm/command/ChangeRelationMemberRoleCommand.java
r1930 r1990 14 14 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 15 15 import org.openstreetmap.josm.data.osm.Relation; 16 import org.openstreetmap.josm.gui. PrimitiveNameFormatter;16 import org.openstreetmap.josm.gui.DefaultNameFormatter; 17 17 import org.openstreetmap.josm.tools.ImageProvider; 18 18 … … 70 70 tr("Change relation member role for {0} {1}", 71 71 OsmPrimitiveType.from(relation), 72 new PrimitiveNameFormatter().getName(relation)72 relation.getDisplayName(DefaultNameFormatter.getInstance()) 73 73 ), 74 74 ImageProvider.get(OsmPrimitiveType.from(relation)), -
trunk/src/org/openstreetmap/josm/command/ConflictAddCommand.java
r1857 r1990 8 8 import javax.swing.JLabel; 9 9 import javax.swing.JOptionPane; 10 import javax.swing.text.html.Option;11 10 import javax.swing.tree.DefaultMutableTreeNode; 12 11 import javax.swing.tree.MutableTreeNode; … … 16 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; 17 16 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 17 import org.openstreetmap.josm.gui.DefaultNameFormatter; 18 18 import org.openstreetmap.josm.gui.OptionPaneUtil; 19 import org.openstreetmap.josm.gui.PrimitiveNameFormatter;20 19 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 21 20 import org.openstreetmap.josm.tools.ImageProvider; … … 36 35 + "This conflict can't be added.</html>", 37 36 getLayer().getName(), 38 new PrimitiveNameFormatter().getName(conflict.getMy())37 conflict.getMy().getDisplayName(DefaultNameFormatter.getInstance()) 39 38 ), 40 39 tr("Double conflict"), … … 56 55 System.out.println(tr("Warning: layer ''{0}'' doesn't exist anymore. Can't remove conflict for primitmive ''{1}''", 57 56 getLayer().getName(), 58 new PrimitiveNameFormatter().getName(conflict.getMy())57 conflict.getMy().getDisplayName(DefaultNameFormatter.getInstance()) 59 58 )); 60 59 return; … … 71 70 new JLabel( 72 71 tr("Add conflict for ''{0}''", 73 new PrimitiveNameFormatter().getName(conflict.getMy())72 conflict.getMy().getDisplayName(DefaultNameFormatter.getInstance()) 74 73 ), 75 74 ImageProvider.get(OsmPrimitiveType.from(conflict.getMy())), -
trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
r1989 r1990 33 33 import org.openstreetmap.josm.data.osm.visitor.CollectBackReferencesVisitor; 34 34 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; 35 import org.openstreetmap.josm.gui.DefaultNameFormatter; 35 36 import org.openstreetmap.josm.gui.ExtendedDialog; 36 import org.openstreetmap.josm.gui.PrimitiveNameFormatter;37 37 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 38 38 import org.openstreetmap.josm.tools.ImageProvider; … … 115 115 } 116 116 117 return new DefaultMutableTreeNode(new JLabel(tr(msg, new PrimitiveNameFormatter().getName(primitive)),117 return new DefaultMutableTreeNode(new JLabel(tr(msg, primitive.getDisplayName(DefaultNameFormatter.getInstance())), 118 118 ImageProvider.get(OsmPrimitiveType.from(primitive)), JLabel.HORIZONTAL)); 119 119 } … … 140 140 ); 141 141 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))); 144 145 } 145 146 return root; … … 173 174 174 175 private static int testRelation(Relation ref, OsmPrimitive osm) { 175 PrimitiveNameFormatter formatter = new PrimitiveNameFormatter();176 176 String role = new String(); 177 177 for (RelationMember m : ref.getMembers()) { … … 183 183 if (role.length() > 0) 184 184 return new ExtendedDialog(Main.parent, tr("Conflicting relation"), tr( 185 "Selection \"{0}\" is used by relation \"{1}\" with role {2}.\nDelete from relation?", formatter186 .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"), 187 187 tr("Cancel") }, new String[] { "dialogs/delete.png", "cancel.png" }).getValue(); 188 188 else 189 189 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[] { 192 193 "dialogs/delete.png", "cancel.png" }).getValue(); 193 194 } -
trunk/src/org/openstreetmap/josm/command/RemoveRelationMemberCommand.java
r1989 r1990 2 2 package org.openstreetmap.josm.command; 3 3 4 import static org.openstreetmap.josm.tools.I18n.marktr; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.marktr;6 6 7 7 import java.util.Collection; … … 16 16 import org.openstreetmap.josm.data.osm.Relation; 17 17 import org.openstreetmap.josm.data.osm.RelationMember; 18 import org.openstreetmap.josm.gui. PrimitiveNameFormatter;18 import org.openstreetmap.josm.gui.DefaultNameFormatter; 19 19 import org.openstreetmap.josm.tools.ImageProvider; 20 20 … … 74 74 new JLabel( 75 75 tr(msg, 76 new PrimitiveNameFormatter().getName(member.member),76 member.member.getDisplayName(DefaultNameFormatter.getInstance()), 77 77 relation.getMembers().indexOf(member), 78 new PrimitiveNameFormatter().getName(relation)78 relation.getDisplayName(DefaultNameFormatter.getInstance()) 79 79 ), 80 80 ImageProvider.get(OsmPrimitiveType.from(relation)), -
trunk/src/org/openstreetmap/josm/corrector/RoleCorrectionTableModel.java
r1930 r1990 6 6 import java.util.List; 7 7 8 import org.openstreetmap.josm.gui. PrimitiveNameFormatter;8 import org.openstreetmap.josm.gui.DefaultNameFormatter; 9 9 10 10 public class RoleCorrectionTableModel extends 11 11 CorrectionTableModel<RoleCorrection> { 12 private static final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter();13 12 14 13 public RoleCorrectionTableModel(List<RoleCorrection> roleCorrections) { … … 40 39 switch (colIndex) { 41 40 case 0: 42 return NAME_FORMATTER.getName(roleCorrection.relation);41 return roleCorrection.relation.getDisplayName(DefaultNameFormatter.getInstance()); 43 42 case 1: 44 43 return roleCorrection.member.getRole(); -
trunk/src/org/openstreetmap/josm/corrector/TagCorrector.java
r1857 r1990 28 28 import org.openstreetmap.josm.data.osm.Relation; 29 29 import org.openstreetmap.josm.data.osm.Way; 30 import org.openstreetmap.josm.gui.DefaultNameFormatter; 30 31 import org.openstreetmap.josm.gui.JMultilineLabel; 31 32 import org.openstreetmap.josm.gui.OptionPaneUtil; 32 import org.openstreetmap.josm.gui.PrimitiveNameFormatter;33 33 import org.openstreetmap.josm.tools.GBC; 34 34 import org.openstreetmap.josm.tools.ImageProvider; 35 35 36 36 public abstract class TagCorrector<P extends OsmPrimitive> { 37 private static final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter();38 37 39 38 public abstract Collection<Command> execute(P primitive, P oldprimitive) … … 101 100 102 101 final JLabel primitiveLabel = new JLabel( 103 NAME_FORMATTER.getName(primitive) + ":",102 primitive.getDisplayName(DefaultNameFormatter.getInstance()) + ":", 104 103 ImageProvider.get(OsmPrimitiveType.from(primitive)), 105 104 JLabel.LEFT … … 127 126 128 127 final JLabel primitiveLabel = new JLabel( 129 NAME_FORMATTER.getName(primitive),128 primitive.getDisplayName(DefaultNameFormatter.getInstance()), 130 129 ImageProvider.get(OsmPrimitiveType.from(primitive)), 131 130 JLabel.LEFT -
trunk/src/org/openstreetmap/josm/data/coor/LatLon.java
r1789 r1990 25 25 private static DecimalFormat cDdFormatter = new DecimalFormat("###0.0000"); 26 26 27 /**28 * Possible ways to display coordinates29 */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 }34 27 35 28 public static String dms(double pCoordinate) { … … 42 35 43 36 return tDegree + "\u00B0" + cDmsMinuteFormatter.format(tMinutes) + "\'" 44 37 + cDmsSecondFormatter.format(tSeconds) + "\""; 45 38 } 46 39 … … 94 87 Bounds b = Main.proj.getWorldBoundsLatLon(); 95 88 return lat() < b.min.lat() || lat() > b.max.lat() || 96 89 lon() < b.min.lon() || lon() > b.max.lon(); 97 90 } 98 91 … … 112 105 public double greatCircleDistance(LatLon other) { 113 106 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 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); 117 110 } 118 111 … … 130 123 } else { 131 124 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 } 134 131 } 135 132 return rv; … … 149 146 public LatLon interpolate(LatLon ll2, double proportion) { 150 147 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())); 152 149 } 153 150 -
trunk/src/org/openstreetmap/josm/data/osm/Changeset.java
r1933 r1990 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 6 import org.openstreetmap.josm.data.osm.visitor.Visitor; 5 import static org.openstreetmap.josm.tools.I18n.tr;6 7 7 8 /** … … 35 36 @Override 36 37 public String getName() { 38 // no translation 39 return "changeset " + id; 40 } 41 42 @Override 43 public String getLocalName(){ 37 44 return tr("Changeset {0}",id); 38 45 } 46 47 @Override 48 public String getDisplayName(NameFormatter formatter) { 49 return formatter.format(this); 50 } 39 51 } -
trunk/src/org/openstreetmap/josm/data/osm/Node.java
r1814 r1990 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr;4 import java.util.Locale; 5 5 6 import org.openstreetmap.josm.Main;7 6 import org.openstreetmap.josm.data.coor.CachedLatLon; 8 7 import org.openstreetmap.josm.data.coor.EastNorth; 9 8 import org.openstreetmap.josm.data.coor.LatLon; 10 import org.openstreetmap.josm.data.coor.LatLon.CoordinateFormat;11 9 import org.openstreetmap.josm.data.osm.visitor.Visitor; 10 import static org.openstreetmap.josm.tools.I18n.tr; 12 11 13 12 /** … … 50 49 } 51 50 52 private static CoordinateFormat mCord;53 51 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 }71 52 72 53 /** … … 127 108 128 109 @Override 110 public String getDisplayName(NameFormatter formatter) { 111 return formatter.format(this); 112 } 113 114 @Override 129 115 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); 141 129 } 142 130 } -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r1933 r1990 10 10 import java.util.Date; 11 11 import java.util.HashMap; 12 import java.util.Locale; 12 13 import java.util.Map; 13 14 import java.util.Map.Entry; … … 358 359 return keys != null && !keys.isEmpty(); 359 360 } 360 361 /**362 * Replies the name of this primitive.363 *364 * @return the name of this primitive365 */366 public abstract String getName();367 361 368 362 /** … … 463 457 return false; 464 458 } 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); 465 505 } -
trunk/src/org/openstreetmap/josm/data/osm/Relation.java
r1951 r1990 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 import static org.openstreetmap.josm.tools.I18n.trn;5 4 6 5 import java.util.ArrayList; 7 import java.util.Arrays;8 import java.util.Collection;9 6 import java.util.List; 10 7 11 import org.openstreetmap.josm.Main;12 8 import org.openstreetmap.josm.data.osm.visitor.Visitor; 13 9 import org.openstreetmap.josm.tools.CopyList; … … 104 100 return members.remove(index); 105 101 } 106 107 final static String[] defnames = {"name", "ref", "restriction", "note"};108 static Collection<String> names = null;109 102 110 103 @Override public void visit(Visitor visitor) { … … 164 157 } 165 158 166 @Override167 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 201 159 // seems to be different from member "incomplete" - FIXME 202 160 public boolean isIncomplete() { … … 233 191 members.removeAll(todelete); 234 192 } 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 } 235 215 } -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r1946 r1990 180 180 } 181 181 182 @Override183 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 210 182 public void removeNode(Node n) { 211 183 if (incomplete) return; … … 263 235 return n == firstNode() || n == lastNode(); 264 236 } 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 } 265 259 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r1937 r1990 34 34 import org.openstreetmap.josm.data.osm.RelationMember; 35 35 import org.openstreetmap.josm.data.osm.Way; 36 import org.openstreetmap.josm.gui.DefaultNameFormatter; 36 37 import org.openstreetmap.josm.gui.mappaint.AreaElemStyle; 37 38 import org.openstreetmap.josm.gui.mappaint.ElemStyle; … … 94 95 return (styles != null) ? styles.get(osm) : null; 95 96 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; 102 104 } 103 105 … … 106 108 return (styles != null) ? styles.getIcon(osm) : null; 107 109 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; 112 115 } 113 116 … … 129 132 * @param n The node to draw. 130 133 */ 134 @Override 131 135 public void visit(Node n) { 132 136 /* check, if the node is visible at all */ 133 137 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())) 137 141 { 138 142 n.mappaintVisibleCode = viewid; … … 146 150 // return; 147 151 148 if (nodeStyle != null && isZoomOk(nodeStyle) && showIcons > dist) 152 if (nodeStyle != null && isZoomOk(nodeStyle) && showIcons > dist) { 149 153 drawNode(n, nodeStyle.icon, nodeStyle.annotate, n.isSelected()); 150 else if (n.highlighted)154 } else if (n.highlighted) { 151 155 drawNode(n, highlightColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 152 else if (n.isSelected())156 } else if (n.isSelected()) { 153 157 drawNode(n, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 154 else if (n.isTagged())158 } else if (n.isTagged()) { 155 159 drawNode(n, nodeColor, taggedNodeSize, taggedNodeRadius, fillUnselectedNode); 156 else160 } else { 157 161 drawNode(n, nodeColor, unselectedNodeSize, unselectedNodeRadius, fillUnselectedNode); 162 } 158 163 } 159 164 … … 162 167 * @param w The way to draw. 163 168 */ 169 @Override 164 170 public void visit(Way w) { 165 171 if(w.getNodesCount() < 2) … … 177 183 for (Node n : w.getNodes()) 178 184 { 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 } 183 197 } 184 198 185 199 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())) 189 203 { 190 204 w.mappaintVisibleCode = viewid; … … 201 215 202 216 w.mappaintVisibleCode = 0; 203 if(fillAreas > dist) 217 if(fillAreas > dist) { 204 218 w.clearErrors(); 219 } 205 220 206 221 if(wayStyle==null) … … 226 241 if (fillAreas > dist) 227 242 { 228 // profilerVisibleAreas++;243 // profilerVisibleAreas++; 229 244 drawArea(w, w.isSelected() ? selectedColor : areaStyle.color); 230 if(!w.isClosed()) 245 if(!w.isClosed()) { 231 246 w.putError(tr("Area style way is not closed."), true); 247 } 232 248 } 233 249 drawWay(w, areaStyle.line, areaStyle.color, w.isSelected()); … … 241 257 (even if the tag is negated as in oneway=false) or the way is selected */ 242 258 boolean showDirection = w.isSelected() || ((!useRealWidth) && (showDirectionArrow 243 && (!showRelevantDirectionsOnly || w.hasDirectionKeys())));259 && (!showRelevantDirectionsOnly || w.hasDirectionKeys()))); 244 260 /* head only takes over control if the option is true, 245 261 the direction should be shown at all and not only because it's selected */ … … 253 269 if(l != null) 254 270 { 255 if (l.color != null) color = l.color; 271 if (l.color != null) { 272 color = l.color; 273 } 256 274 width = l.width; 257 275 realWidth = l.realWidth; … … 259 277 dashedColor = l.dashedColor; 260 278 } 261 if(selected) 279 if(selected) { 262 280 color = selectedColor; 281 } 263 282 if (realWidth > 0 && useRealWidth && !showDirection) 264 283 { 265 284 int tmpWidth = (int) (100 / (float) (circum / realWidth)); 266 if (tmpWidth > width) width = tmpWidth; 285 if (tmpWidth > width) { 286 width = tmpWidth; 287 } 267 288 268 289 /* if we have a "width" tag, try use it */ … … 281 302 } 282 303 283 if(w.highlighted) 304 if(w.highlighted) { 284 305 color = highlightColor; 285 else if(w.isSelected())306 } else if(w.isSelected()) { 286 307 color = selectedColor; 308 } 287 309 288 310 /* draw overlays under the way */ … … 299 321 { 300 322 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); 302 324 } 303 325 lastN = n; … … 313 335 { 314 336 Node n = it.next(); 315 if(lastN != null) 337 if(lastN != null) { 316 338 drawSeg(lastN, n, color, 317 showOnlyHeadArrowOnly ? !it.hasNext() : showDirection, width, dashed, dashedColor); 339 showOnlyHeadArrowOnly ? !it.hasNext() : showDirection, width, dashed, dashedColor); 340 } 318 341 lastN = n; 319 342 } … … 332 355 { 333 356 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); 335 358 } 336 359 lastN = n; … … 386 409 { 387 410 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 } 392 420 } 393 421 else 394 422 { 395 423 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 } 400 433 } 401 434 if(mode != 0) … … 403 436 joinArray[i] = null; 404 437 joined = true; 405 if(c.isSelected()) selected = true; 438 if(c.isSelected()) { 439 selected = true; 440 } 406 441 --left; 407 if(n == null) n = w.getNodes(); 442 if(n == null) { 443 n = w.getNodes(); 444 } 408 445 n.remove((mode == 21 || mode == 22) ? nl : 0); 409 if(mode == 21) 446 if(mode == 21) { 410 447 n.addAll(c.getNodes()); 411 else if(mode == 12)448 } else if(mode == 12) { 412 449 n.addAll(0, c.getNodes()); 413 else if(mode == 22)450 } else if(mode == 22) 414 451 { 415 for(Node node : c.getNodes()) 452 for(Node node : c.getNodes()) { 416 453 n.add(nl, node); 454 } 417 455 } 418 456 else /* mode == 11 */ 419 457 { 420 for(Node node : c.getNodes()) 458 for(Node node : c.getNodes()) { 421 459 n.add(0, node); 460 } 422 461 } 423 462 } … … 437 476 { 438 477 errs.putError(tr("multipolygon way ''{0}'' is not closed.", 439 w.getName()), true);478 w.getDisplayName(DefaultNameFormatter.getInstance())), true); 440 479 } 441 480 } … … 447 486 448 487 public void drawSelectedMember(OsmPrimitive osm, ElemStyle style, Boolean area, 449 Boolean areaselected)488 Boolean areaselected) 450 489 { 451 490 if(osm instanceof Way) … … 456 495 AreaElemStyle areaStyle = (AreaElemStyle)style; 457 496 drawWay(way, areaStyle.line, selectedColor, true); 458 if(area) 497 if(area) { 459 498 drawArea(way, areaselected ? selectedColor : areaStyle.color); 499 } 460 500 } 461 501 else … … 466 506 else if(osm instanceof Node) 467 507 { 468 if(style != null && isZoomOk(style)) 508 if(style != null && isZoomOk(style)) { 469 509 drawNode((Node)osm, ((IconElemStyle)style).icon, 470 ((IconElemStyle)style).annotate, true);471 else510 ((IconElemStyle)style).annotate, true); 511 } else { 472 512 drawNode((Node)osm, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 513 } 473 514 } 474 515 osm.mappaintDrawnCode = paintid; 475 516 } 476 517 518 @Override 477 519 public void visit(Relation r) { 478 520 … … 497 539 { 498 540 if(drawMultipolygon(r)) 499 return;541 return; 500 542 } 501 543 else if (drawRestriction && "restriction".equals(r.get("type"))) … … 511 553 { 512 554 drawSelectedMember(m.getMember(), styles != null ? getPrimitiveStyle(m.getMember()) 513 : null, true, true);555 : null, true, true); 514 556 } 515 557 } … … 535 577 // System.out.println("member " + m.member + " selected " + r.selected); 536 578 537 if(m.getMember() == null) 579 if(m.getMember() == null) { 538 580 // TODO Nullable member will not be allowed after RelationMember.member is encalupsed 539 581 r.putError(tr("Empty member in relation."), true); 540 else if(m.getMember().deleted)582 } else if(m.getMember().deleted) { 541 583 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) 545 586 return; 546 }547 587 else 548 588 { … … 553 593 { 554 594 r.putError(tr("Way ''{0}'' with less than two points.", 555 w.getName()), true);595 w.getDisplayName(DefaultNameFormatter.getInstance())), true); 556 596 } 557 597 else if("from".equals(m.getRole())) { 558 if(fromWay != null) 598 if(fromWay != null) { 559 599 r.putError(tr("More than one \"from\" way found."), true); 560 else {600 } else { 561 601 fromWay = w; 562 602 } 563 603 } else if("to".equals(m.getRole())) { 564 if(toWay != null) 604 if(toWay != null) { 565 605 r.putError(tr("More than one \"to\" way found."), true); 566 else {606 } else { 567 607 toWay = w; 568 608 } 569 609 } else if("via".equals(m.getRole())) { 570 if(via != null) 610 if(via != null) { 571 611 r.putError(tr("More than one \"via\" found."), true); 572 else612 } else { 573 613 via = w; 574 }575 else614 } 615 } else { 576 616 r.putError(tr("Unknown role ''{0}''.", m.getRole()), true); 617 } 577 618 } 578 619 else if(m.isNode()) … … 581 622 if("via".equals(m.getRole())) 582 623 { 583 if(via != null) 624 if(via != null) { 584 625 r.putError(tr("More than one \"via\" found."), true); 585 else626 } else { 586 627 via = n; 587 }588 else628 } 629 } else { 589 630 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 } 593 635 } 594 636 } … … 615 657 return; 616 658 } 617 if(!toWay.isFirstLastNode(viaNode)) 659 if(!toWay.isFirstLastNode(viaNode)) { 618 660 r.putError(tr("The \"to\" way doesn't start or end at a \"via\" node."), true); 661 } 619 662 } 620 663 else … … 623 666 Node firstNode = viaWay.firstNode(); 624 667 Node lastNode = viaWay.lastNode(); 625 if(fromWay.isFirstLastNode(firstNode)) 668 if(fromWay.isFirstLastNode(firstNode)) { 626 669 viaNode = firstNode; 627 else if(fromWay.isFirstLastNode(lastNode))670 } else if(fromWay.isFirstLastNode(lastNode)) { 628 671 viaNode = firstNode; 629 else {672 } else { 630 673 r.putError(tr("The \"from\" way doesn't start or end at the \"via\" way."), true); 631 674 return; 632 675 } 633 if(!toWay.isFirstLastNode(viaNode == firstNode ? lastNode : firstNode)) 676 if(!toWay.isFirstLastNode(viaNode == firstNode ? lastNode : firstNode)) { 634 677 r.putError(tr("The \"to\" way doesn't start or end at the \"via\" way."), true); 678 } 635 679 } 636 680 … … 675 719 (calculate the vector vx/vy with the specified length and the direction 676 720 away from the "via" node along the first segment of the "from" way) 677 */721 */ 678 722 double distanceFromVia=14; 679 723 double dx = (pFrom.x >= pVia.x) ? (pFrom.x - pVia.x) : (pVia.x - pFrom.x); … … 691 735 double vy = distanceFromVia * Math.sin(fromAngle); 692 736 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 } 695 743 696 744 //if(restrictionDebug) … … 700 748 (calculate the vx2/vy2 vector with the specified length and the direction 701 749 90degrees away from the first segment of the "from" way) 702 */750 */ 703 751 double distanceFromWay=10; 704 752 double vx2 = 0; … … 740 788 vx2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg + 180)); 741 789 vy2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg + 180)); 742 790 } else { 743 791 vx2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg)); 744 792 vy2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg)); … … 783 831 for (RelationMember m : r.getMembers()) 784 832 { 785 if(m.getMember() == null) 833 if(m.getMember() == null) { 786 834 //TODO Remove useless nullcheck when RelationMember.member is encalupsed 787 835 r.putError(tr("Empty member in relation."), true); 788 else if(m.getMember().deleted)836 } else if(m.getMember().deleted) { 789 837 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) { 792 840 incomplete = true; 793 else841 } else 794 842 { 795 843 if(m.isWay()) … … 799 847 { 800 848 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())) { 804 852 inner.add(w); 805 else if("outer".equals(m.getRole()))853 } else if("outer".equals(m.getRole())) { 806 854 outer.add(w); 807 else855 } else 808 856 { 809 857 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()) { 812 860 outer.add(w); 813 else if(r.isSelected())861 } else if(r.isSelected()) { 814 862 drawSelectedMember(m.getMember(), styles != null 815 ? getPrimitiveStyle(m.getMember()) : null, true, true); 863 ? getPrimitiveStyle(m.getMember()) : null, true, true); 864 } 816 865 } 817 866 } … … 819 868 { 820 869 r.putError(tr("Non-Way ''{0}'' in multipolygon.", 821 m.getMember().getName()), true);870 m.getMember().getDisplayName(DefaultNameFormatter.getInstance())), true); 822 871 } 823 872 } … … 829 878 for (Way w : outer) 830 879 { 831 if(wayStyle == null) 832 wayStyle = styles.getArea(w); 880 if(wayStyle == null) { 881 wayStyle = styles.getArea(w); 882 } 833 883 } 834 884 r.mappaintStyle = wayStyle; … … 844 894 for (Way w : outer) 845 895 { 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 } 848 901 } 849 902 if(join.size() != 0) 850 903 { 851 for(Way w : joinWays(join, incomplete ? null : r)) 904 for(Way w : joinWays(join, incomplete ? null : r)) { 852 905 outerclosed.add(w); 906 } 853 907 } 854 908 … … 856 910 for (Way w : inner) 857 911 { 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 } 860 917 } 861 918 if(join.size() != 0) 862 919 { 863 for(Way w : joinWays(join, incomplete ? null : r)) 920 for(Way w : joinWays(join, incomplete ? null : r)) { 864 921 innerclosed.add(w); 922 } 865 923 } 866 924 … … 868 926 { 869 927 r.putError(tr("No outer way for multipolygon ''{0}''.", 870 r.getName()), true);928 r.getDisplayName(DefaultNameFormatter.getInstance())), true); 871 929 visible = true; /* prevent killing remaining ways */ 872 930 } … … 892 950 for(int i = 0; i < p.npoints; ++i) 893 951 { 894 if(poly.contains(p.xpoints[i],p.ypoints[i])) 952 if(poly.contains(p.xpoints[i],p.ypoints[i])) { 895 953 --contains; 954 } 896 955 } 897 956 if(contains == 0) return 1; … … 901 960 public void addInner(Polygon p) 902 961 { 903 if(inner == null) 962 if(inner == null) { 904 963 inner = new ArrayList<Polygon>(); 964 } 905 965 inner.add(p); 906 966 } … … 908 968 { 909 969 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]); 912 972 } 913 973 public Polygon get() … … 917 977 for (Polygon pp : inner) 918 978 { 919 for(int i = 0; i < pp.npoints; ++i) 979 for(int i = 0; i < pp.npoints; ++i) { 920 980 poly.addPoint(pp.xpoints[i],pp.ypoints[i]); 981 } 921 982 poly.addPoint(p.x,p.y); 922 983 } … … 954 1015 { 955 1016 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); 957 1018 } 958 if(o == null || o.contains(pd.poly) > 0) 1019 if(o == null || o.contains(pd.poly) > 0) { 959 1020 o = pd; 1021 } 960 1022 } 961 1023 } … … 965 1027 { 966 1028 r.putError(tr("Inner way ''{0}'' is outside.", 967 wInner.getName()), true);1029 wInner.getDisplayName(DefaultNameFormatter.getInstance())), true); 968 1030 } 969 1031 o = poly.get(0); … … 978 1040 { 979 1041 drawAreaPolygon(p, (pd.way.isSelected() || r.isSelected()) ? selectedColor 980 : areaStyle.color);1042 : areaStyle.color); 981 1043 visible = true; 982 1044 } … … 986 1048 { 987 1049 r.mappaintVisibleCode = viewid; 988 for (Way wInner : inner) 1050 for (Way wInner : inner) { 989 1051 wInner.mappaintVisibleCode = viewid; 990 for (Way wOuter : outer) 1052 } 1053 for (Way wOuter : outer) { 991 1054 wOuter.mappaintVisibleCode = viewid; 1055 } 992 1056 return drawn; 993 1057 } … … 998 1062 { 999 1063 if(zoomok && (wInner.mappaintDrawnCode != paintid 1000 || outer.size() == 0))1064 || outer.size() == 0)) 1001 1065 { 1002 1066 drawWay(wInner, ((AreaElemStyle)wayStyle).line, 1003 ((AreaElemStyle)wayStyle).color, wInner.isSelected()1004 || r.isSelected());1067 ((AreaElemStyle)wayStyle).color, wInner.isSelected() 1068 || r.isSelected()); 1005 1069 } 1006 1070 wInner.mappaintDrawnCode = paintid; … … 1011 1075 { 1012 1076 drawSelectedMember(wInner, innerStyle, 1013 !wayStyle.equals(innerStyle), wInner.isSelected());1077 !wayStyle.equals(innerStyle), wInner.isSelected()); 1014 1078 } 1015 1079 if(wayStyle.equals(innerStyle)) 1016 1080 { 1017 1081 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()) { 1020 1084 wInner.mappaintDrawnAreaCode = paintid; 1085 } 1021 1086 } 1022 1087 } … … 1030 1095 { 1031 1096 drawWay(wOuter, ((AreaElemStyle)wayStyle).line, 1032 ((AreaElemStyle)wayStyle).color, wOuter.isSelected()1033 || r.isSelected());1097 ((AreaElemStyle)wayStyle).color, wOuter.isSelected() 1098 || r.isSelected()); 1034 1099 } 1035 1100 wOuter.mappaintDrawnCode = paintid; … … 1038 1103 { 1039 1104 if(outerStyle instanceof AreaElemStyle 1040 && !wayStyle.equals(outerStyle))1105 && !wayStyle.equals(outerStyle)) 1041 1106 { 1042 1107 r.putError(tr("Style for outer way ''{0}'' mismatches.", 1043 wOuter.getName()), true);1108 wOuter.getDisplayName(DefaultNameFormatter.getInstance())), true); 1044 1109 } 1045 1110 if(r.isSelected()) … … 1047 1112 drawSelectedMember(wOuter, outerStyle, false, false); 1048 1113 } 1049 else if(outerStyle instanceof AreaElemStyle) 1114 else if(outerStyle instanceof AreaElemStyle) { 1050 1115 wOuter.mappaintDrawnAreaCode = paintid; 1116 } 1051 1117 } 1052 1118 } … … 1115 1181 for (String rn : regionalNameOrder) { 1116 1182 name = n.get(rn); 1117 if (name != null) break; 1183 if (name != null) { 1184 break; 1185 } 1118 1186 } 1119 1187 } … … 1129 1197 Point p2 = nc.getPoint(n2); 1130 1198 1131 if (!isSegmentVisible(p1, p2)) {1199 if (!isSegmentVisible(p1, p2)) 1132 1200 return; 1133 }1134 1201 //profilerVisibleSegments++; 1135 1202 currentPath.moveTo(p1.x, p1.y); … … 1144 1211 } 1145 1212 1213 @Override 1146 1214 protected void displaySegments() { 1147 1215 displaySegments(null, 0, new float[0], null); … … 1159 1227 g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); 1160 1228 } 1161 } 1162 else 1229 } else { 1163 1230 g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); 1231 } 1164 1232 } 1165 1233 g2d.draw(currentPath); … … 1178 1246 g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); 1179 1247 } 1180 } 1181 else 1248 } else { 1182 1249 g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); 1250 } 1183 1251 } 1184 1252 g2d.draw(currentPath); 1185 1253 } 1186 1254 1187 if(useStrokes > dist) 1255 if(useStrokes > dist) { 1188 1256 g2d.setStroke(new BasicStroke(1)); 1257 } 1189 1258 1190 1259 currentPath = new GeneralPath(); … … 1203 1272 * @param color The color of the node. 1204 1273 */ 1274 @Override 1205 1275 public void drawNode(Node n, Color color, int size, int radius, boolean fill) { 1206 1276 if (isZoomOk(null) && size > 1) { … … 1216 1286 g.fillRect(p.x - radius, p.y - radius, size, size); 1217 1287 g.drawRect(p.x - radius, p.y - radius, size, size); 1218 } else 1288 } else { 1219 1289 g.drawRect(p.x - radius, p.y - radius, size, size); 1290 } 1220 1291 1221 1292 if(showNames > dist) … … 1234 1305 } 1235 1306 1307 @Override 1236 1308 public void getColors() 1237 1309 { … … 1242 1314 1243 1315 /* Shows areas before non-areas */ 1316 @Override 1244 1317 public void visitAll(DataSet data, Boolean virtual) { 1245 1318 … … 1303 1376 1304 1377 /*** RELATIONS ***/ 1305 // profilerN = 0;1378 // profilerN = 0; 1306 1379 for (final Relation osm : data.relations) 1307 1380 { … … 1309 1382 { 1310 1383 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 // } 1320 1393 1321 1394 /*** AREAS ***/ 1322 // profilerN = 0;1395 // profilerN = 0; 1323 1396 for (final Way osm : data.ways) 1324 1397 { 1325 1398 if (!osm.incomplete && !osm.deleted 1326 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid)1399 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) 1327 1400 { 1328 1401 if(isPrimitiveArea(osm) && osm.mappaintDrawnAreaCode != paintid) 1329 1402 { 1330 1403 osm.visit(this); 1331 // profilerN++;1332 } else 1404 // profilerN++; 1405 } else { 1333 1406 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 // } 1343 1417 1344 1418 /*** WAYS ***/ 1345 // profilerN = 0;1419 // profilerN = 0; 1346 1420 fillAreas = 0; 1347 1421 for (final OsmPrimitive osm : noAreaWays) 1348 1422 { 1349 1423 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 // } 1359 1433 } 1360 1434 else 1361 1435 { 1362 1436 /*** WAYS (filling disabled) ***/ 1363 // profilerN = 0;1437 // profilerN = 0; 1364 1438 for (final OsmPrimitive osm : data.ways) 1365 1439 if (!osm.incomplete && !osm.deleted && !osm.isSelected() 1366 && osm.mappaintVisibleCode != viewid )1440 && osm.mappaintVisibleCode != viewid ) 1367 1441 { 1368 1442 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 // } 1378 1452 } 1379 1453 … … 1383 1457 for (final OsmPrimitive osm : data.getSelected()) { 1384 1458 if (!osm.incomplete && !osm.deleted && !(osm instanceof Node) 1385 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid)1459 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) 1386 1460 { 1387 1461 osm.visit(this); 1388 // profilerN++;1462 // profilerN++; 1389 1463 } 1390 1464 } … … 1403 1477 for (final OsmPrimitive osm : data.nodes) 1404 1478 if (!osm.incomplete && !osm.deleted 1405 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid)1479 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) 1406 1480 { 1407 1481 osm.visit(this); 1408 // profilerN++;1482 // profilerN++; 1409 1483 } 1410 1484 … … 1419 1493 if (virtualNodeSize != 0) 1420 1494 { 1421 // profilerN = 0;1495 // profilerN = 0; 1422 1496 currentColor = nodeColor; 1423 1497 for (final OsmPrimitive osm : data.ways) 1424 1498 if (!osm.incomplete && !osm.deleted 1425 && osm.mappaintVisibleCode != viewid )1499 && osm.mappaintVisibleCode != viewid ) 1426 1500 { 1427 1501 /* TODO: move this into the SimplePaint code? */ 1428 // if(!profilerOmitDraw)1429 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 // } 1438 1512 1439 1513 displaySegments(null); -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r1814 r1990 37 37 import org.openstreetmap.josm.Main; 38 38 import org.openstreetmap.josm.actions.HelpAction.Helpful; 39 import org.openstreetmap.josm.data.coor.CoordinateFormat; 39 40 import org.openstreetmap.josm.data.coor.LatLon; 40 import org.openstreetmap.josm.data.coor.LatLon.CoordinateFormat;41 import org.openstreetmap.josm.data.osm.Node;42 41 import org.openstreetmap.josm.data.osm.OsmPrimitive; 43 42 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 59 58 */ 60 59 public class MapStatus extends JPanel implements Helpful { 61 private static final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter();62 60 63 61 /** … … 163 161 osmNearest = mv.getNearest(ms.mousePos); 164 162 if (osmNearest != null) { 165 nameText.setText( NAME_FORMATTER.getName(osmNearest));163 nameText.setText(osmNearest.getDisplayName(DefaultNameFormatter.getInstance())); 166 164 } else { 167 165 nameText.setText(tr("(no object)")); … … 195 193 for (final OsmPrimitive osm : osms) { 196 194 final StringBuilder text = new StringBuilder(); 197 String name = NAME_FORMATTER.getName(osm);195 String name = osm.getDisplayName(DefaultNameFormatter.getInstance()); 198 196 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>"; 200 198 } 201 199 text.append(name); … … 283 281 // Do not update the view if ctrl is pressed. 284 282 if ((e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) == 0) { 285 CoordinateFormat mCord = Node.getCoordinateFormat();283 CoordinateFormat mCord = CoordinateFormat.getDefaultFormat(); 286 284 LatLon p = mv.getLatLon(e.getX(),e.getY()); 287 285 latText.setText(p.latToString(mCord)); -
trunk/src/org/openstreetmap/josm/gui/OsmPrimitivRenderer.java
r1814 r1990 25 25 */ 26 26 public class OsmPrimitivRenderer implements ListCellRenderer, TableCellRenderer { 27 static private final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter();28 29 27 /** 30 28 * Default list cell renderer - delegate for ListCellRenderer operation … … 62 60 private Component renderer(Component def, OsmPrimitive value) { 63 61 if (def != null && value != null && def instanceof JLabel) { 64 ((JLabel)def).setText( NAME_FORMATTER.getName(value));62 ((JLabel)def).setText(value.getDisplayName(DefaultNameFormatter.getInstance())); 65 63 ((JLabel)def).setIcon(ImageProvider.get(OsmPrimitiveType.from(value))); 66 64 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListTableCellRenderer.java
r1954 r1990 20 20 import org.openstreetmap.josm.data.osm.Node; 21 21 import org.openstreetmap.josm.data.osm.OsmPrimitive; 22 import org.openstreetmap.josm.gui.DefaultNameFormatter; 22 23 import org.openstreetmap.josm.gui.conflict.pair.ListMergeModel; 23 24 import org.openstreetmap.josm.tools.ImageProvider; … … 130 131 } 131 132 } 132 setText(node.get Name());133 setText(node.getDisplayName(DefaultNameFormatter.getInstance())); 133 134 setToolTipText(buildToolTipText(node)); 134 135 } … … 167 168 reset(); 168 169 switch(column) { 169 170 171 172 173 174 175 176 177 178 179 180 181 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)); 182 183 } 183 184 return this; -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberTableCellRenderer.java
r1954 r1990 18 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 19 import org.openstreetmap.josm.data.osm.RelationMember; 20 import org.openstreetmap.josm.gui.DefaultNameFormatter; 20 21 import org.openstreetmap.josm.gui.conflict.pair.ListMergeModel; 21 22 import org.openstreetmap.josm.tools.ImageProvider; … … 156 157 157 158 protected void renderPrimitive(RelationMember member) { 158 String displayName = member.getMember().get Name();159 String displayName = member.getMember().getDisplayName(DefaultNameFormatter.getInstance()); 159 160 setText(displayName); 160 161 setToolTipText(buildToolTipText(member.getMember())); … … 196 197 renderForeground(getModel(table), member, row, column, isSelected); 197 198 switch(column) { 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 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 217 218 } 218 219 return this; -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialog.java
r1987 r1990 25 25 import org.openstreetmap.josm.command.Command; 26 26 import org.openstreetmap.josm.data.osm.OsmPrimitive; 27 import org.openstreetmap.josm.gui.DefaultNameFormatter; 27 28 import org.openstreetmap.josm.gui.OptionPaneUtil; 28 import org.openstreetmap.josm.gui.PrimitiveNameFormatter;29 29 import org.openstreetmap.josm.gui.conflict.pair.ConflictResolver; 30 30 import org.openstreetmap.josm.gui.conflict.pair.properties.OperationCancelledException; … … 241 241 setTitle(tr("Resolve conflicts")); 242 242 } 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()))); 245 244 } 246 245 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r1987 r1990 66 66 import org.openstreetmap.josm.data.osm.RelationMember; 67 67 import org.openstreetmap.josm.data.osm.Way; 68 import org.openstreetmap.josm.gui.DefaultNameFormatter; 68 69 import org.openstreetmap.josm.gui.ExtendedDialog; 69 70 import org.openstreetmap.josm.gui.MapFrame; 70 import org.openstreetmap.josm.gui.PrimitiveNameFormatter;71 71 import org.openstreetmap.josm.gui.SideButton; 72 72 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; … … 99 99 */ 100 100 public class PropertiesDialog extends ToggleDialog implements SelectionChangedListener, LayerChangeListener { 101 static private final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter();102 103 101 /** 104 102 * Watches for double clicks and from editing or new property, depending on the … … 498 496 Component c = super.getTableCellRendererComponent(table, value, isSelected, false, row, column); 499 497 if (c instanceof JLabel) { 500 ((JLabel)c).setText( NAME_FORMATTER.getName((Relation)value));498 ((JLabel)c).setText(((Relation)value).getDisplayName(DefaultNameFormatter.getInstance())); 501 499 } 502 500 return c; … … 837 835 int result = new ExtendedDialog(Main.parent, 838 836 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())), 840 838 new String[] {tr("Delete from relation"), tr("Cancel")}, 841 839 new String[] {"dialogs/delete.png", "cancel.png"}).getValue(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r1944 r1990 29 29 import org.openstreetmap.josm.data.osm.RelationMember; 30 30 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 31 import org.openstreetmap.josm.gui.PrimitiveNameFormatter;32 31 import org.openstreetmap.josm.gui.SideButton; 33 32 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; … … 49 48 public class RelationListDialog extends ToggleDialog implements LayerChangeListener, DataChangeListener { 50 49 private static final Logger logger = Logger.getLogger(RelationListDialog.class.getName()); 51 static private final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter();52 50 53 51 /** -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ChildRelationBrowser.java
r1937 r1990 34 34 import org.openstreetmap.josm.data.osm.RelationMember; 35 35 import org.openstreetmap.josm.data.osm.visitor.MergeVisitor; 36 import org.openstreetmap.josm.gui.DefaultNameFormatter; 36 37 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 37 38 import org.openstreetmap.josm.gui.OptionPaneUtil; 38 39 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 39 import org.openstreetmap.josm.gui.PrimitiveNameFormatter;40 40 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 41 41 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor; … … 342 342 */ 343 343 protected void warnBecauseOfDeletedRelation(Relation r) { 344 PrimitiveNameFormatter nameFormatter = new PrimitiveNameFormatter();345 346 344 String message = tr("<html>The child relation<br>" 347 345 + "{0}<br>" 348 346 + "is deleted on the server. It can't be loaded", 349 nameFormatter.getName(r)347 r.getDisplayName(DefaultNameFormatter.getInstance()) 350 348 ); 351 349 … … 404 402 protected void realRun() throws SAXException, IOException, OsmTransferException { 405 403 try { 406 PrimitiveNameFormatter nameFormatter = new PrimitiveNameFormatter();407 404 while(! relationsToDownload.isEmpty() && !cancelled) { 408 405 Relation r = relationsToDownload.pop(); … … 411 408 } 412 409 rememberChildRelationsToDownload(r); 413 progressMonitor.setCustomText(tr("Downloading relation {0}", nameFormatter.getName(r)));410 progressMonitor.setCustomText(tr("Downloading relation {0}", r.getDisplayName(DefaultNameFormatter.getInstance()))); 414 411 OsmServerObjectReader reader = new OsmServerObjectReader(r.id, OsmPrimitiveType.RELATION, 415 412 true); … … 515 512 protected void realRun() throws SAXException, IOException, OsmTransferException { 516 513 try { 517 PrimitiveNameFormatter nameFormatter = new PrimitiveNameFormatter();518 514 Iterator<Relation> it = relations.iterator(); 519 515 while(it.hasNext() && !cancelled) { … … 522 518 continue; 523 519 } 524 progressMonitor.setCustomText(tr("Downloading relation {0}", nameFormatter.getName(r)));520 progressMonitor.setCustomText(tr("Downloading relation {0}", r.getDisplayName(DefaultNameFormatter.getInstance()))); 525 521 OsmServerObjectReader reader = new OsmServerObjectReader(r.id, OsmPrimitiveType.RELATION, 526 522 true); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r1987 r1990 64 64 import org.openstreetmap.josm.data.osm.visitor.MergeVisitor; 65 65 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; 66 import org.openstreetmap.josm.gui.DefaultNameFormatter; 66 67 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 67 68 import org.openstreetmap.josm.gui.OptionPaneUtil; 68 69 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 69 import org.openstreetmap.josm.gui.PrimitiveNameFormatter;70 70 import org.openstreetmap.josm.gui.SideButton; 71 71 import org.openstreetmap.josm.gui.dialogs.relation.ac.AutoCompletionCache; … … 697 697 698 698 abstract class AddFromSelectionAction extends AbstractAction { 699 private PrimitiveNameFormatter nameFormatter = new PrimitiveNameFormatter();700 701 699 protected boolean isPotentialDuplicate(OsmPrimitive primitive) { 702 700 return memberTableModel.hasMembersReferringTo(Collections.singleton(primitive)); … … 708 706 + "<br>" 709 707 + "Do you really want to add another relation member?</html>", 710 nameFormatter.getName(primitive)708 primitive.getDisplayName(DefaultNameFormatter.getInstance()) 711 709 ); 712 710 int ret = ConditionalOptionPaneUtil.showOptionDialog( … … 736 734 + "This creates circular references and is therefore discouraged.<br>" 737 735 + "Skipping relation ''{0}''.</html>", 738 this.nameFormatter.getName(primitive)736 primitive.getDisplayName(DefaultNameFormatter.getInstance()) 739 737 ); 740 738 OptionPaneUtil.showMessageDialog( … … 1170 1168 + "Please resolve this conflict first, then try again.</html>", 1171 1169 getLayer().getName(), 1172 new PrimitiveNameFormatter().getName(getRelation())1170 getRelation().getDisplayName(DefaultNameFormatter.getInstance()) 1173 1171 ), 1174 1172 tr("Double conflict"), -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableMemberCellRenderer.java
r1822 r1990 10 10 import org.openstreetmap.josm.data.osm.OsmPrimitive; 11 11 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 12 import org.openstreetmap.josm.gui. PrimitiveNameFormatter;12 import org.openstreetmap.josm.gui.DefaultNameFormatter; 13 13 import org.openstreetmap.josm.tools.ImageProvider; 14 14 15 15 public class MemberTableMemberCellRenderer extends MemberTableCellRenderer { 16 16 private HashMap<OsmPrimitiveType, ImageIcon> icons; 17 static private final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter();18 17 19 18 public MemberTableMemberCellRenderer() { … … 36 35 protected void renderPrimitive(OsmPrimitive primitive) { 37 36 setIcon(icons.get(OsmPrimitiveType.from(primitive))); 38 setText( NAME_FORMATTER.getName(primitive));37 setText(primitive.getDisplayName(DefaultNameFormatter.getInstance())); 39 38 setToolTipText(buildToolTipText(primitive)); 40 39 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationTreeCellRenderer.java
r1828 r1990 11 11 12 12 import org.openstreetmap.josm.data.osm.Relation; 13 import org.openstreetmap.josm.gui. PrimitiveNameFormatter;13 import org.openstreetmap.josm.gui.DefaultNameFormatter; 14 14 import org.openstreetmap.josm.tools.ImageProvider; 15 15 … … 20 20 */ 21 21 public class RelationTreeCellRenderer extends JLabel implements TreeCellRenderer { 22 private static final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter();23 22 public final static Color BGCOLOR_SELECTED = new Color(143,170,255); 24 23 … … 47 46 */ 48 47 protected void renderValue(Relation relation) { 49 setText( NAME_FORMATTER.getName(relation));48 setText(relation.getDisplayName(DefaultNameFormatter.getInstance())); 50 49 } 51 50 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/SelectionTableCellRenderer.java
r1814 r1990 15 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; 16 16 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 17 import org.openstreetmap.josm.gui. PrimitiveNameFormatter;17 import org.openstreetmap.josm.gui.DefaultNameFormatter; 18 18 import org.openstreetmap.josm.tools.ImageProvider; 19 19 … … 23 23 */ 24 24 public class SelectionTableCellRenderer extends JLabel implements TableCellRenderer { 25 static private final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter();26 27 25 public final static Color BGCOLOR_SELECTED = new Color(143,170,255); 28 26 public final static Color BGCOLOR_DOUBLE_ENTRY = new Color(255,234,213); … … 118 116 protected void renderPrimitive(OsmPrimitive primitive) { 119 117 setIcon(icons.get(OsmPrimitiveType.from(primitive))); 120 setText( NAME_FORMATTER.getName(primitive));118 setText(primitive.getDisplayName(DefaultNameFormatter.getInstance())); 121 119 setToolTipText(buildToolTipText(primitive)); 122 120 } -
trunk/src/org/openstreetmap/josm/gui/preferences/LafPreference.java
r1742 r1990 38 38 private JCheckBox showSplashScreen = new JCheckBox(tr("Show splash screen at startup")); 39 39 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")); 40 41 private JCheckBox drawHelperLine = new JCheckBox(tr("Draw rubber-band helper line")); 41 42 private JCheckBox modeless = new JCheckBox(tr("Modeless working (Potlatch style)")); … … 50 51 // no exception? Then Go! 51 52 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") 53 54 ); 54 55 } catch (Exception ex) { … … 85 86 panel.add(showID, GBC.eop().insets(20, 0, 0, 0)); 86 87 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 87 93 drawHelperLine.setToolTipText(tr("Draw rubber-band helper line")); 88 94 drawHelperLine.setSelected(Main.pref.getBoolean("draw.helper-line", true)); … … 107 113 Main.pref.put("draw.splashscreen", showSplashScreen.isSelected()); 108 114 Main.pref.put("osm-primitives.showid", showID.isSelected()); 115 Main.pref.put("osm-primitives.localize-name", showLocalizedName.isSelected()); 109 116 Main.pref.put("draw.helper-line", drawHelperLine.isSelected()); 110 117 Main.pref.put("modeless", modeless.isSelected()); 111 118 return Main.pref.put("laf", ((LookAndFeelInfo)lafCombo.getSelectedItem()).getClassName()); 112 119 } 113 114 120 } -
trunk/src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java
r1747 r1990 15 15 16 16 import org.openstreetmap.josm.Main; 17 import org.openstreetmap.josm.data.coor. LatLon.CoordinateFormat;17 import org.openstreetmap.josm.data.coor.CoordinateFormat; 18 18 import org.openstreetmap.josm.data.osm.Node; 19 19 import org.openstreetmap.josm.data.projection.Mercator; … … 67 67 public boolean ok() { 68 68 String projname = projectionCombo.getSelectedItem().getClass().getName(); 69 if(Main.pref.put("projection", projname)) 69 if(Main.pref.put("projection", projname)) { 70 70 Main.setProjection(projname); 71 } 71 72 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 } 74 76 return false; 75 77 } -
trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java
r1989 r1990 2 2 package org.openstreetmap.josm.io; 3 3 4 import static org.openstreetmap.josm.tools.I18n.marktr; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.marktr;6 6 7 7 import java.util.Collection; 8 import java.util.Collections;9 8 import java.util.LinkedList; 10 9 import java.util.List; … … 16 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; 17 16 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 18 import org.openstreetmap.josm.gui.PrimitiveNameFormatter;19 17 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 20 18 … … 27 25 */ 28 26 public class OsmServerWriter { 29 static private final PrimitiveNameFormatter NAME_FORMATTER = new PrimitiveNameFormatter();30 27 static private final Logger logger = Logger.getLogger(OsmServerWriter.class.getName()); 31 28 … … 108 105 primitives.size(), 109 106 time_left_str, 110 NAME_FORMATTER.getName(osm),107 osm.getLocalName(), 111 108 osm.id)); 112 109 makeApiRequest(osm,progressMonitor);
Note:
See TracChangeset
for help on using the changeset viewer.