Changeset 13766 in josm for trunk/src/org
- Timestamp:
- 2018-05-14T22:18:40+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DefaultNameFormatter.java
r13717 r13766 140 140 if (osm instanceof INode) { 141 141 return format((INode) osm); 142 } else if (osm instanceof IWay <?>) {142 } else if (osm instanceof IWay) { 143 143 return format((IWay<?>) osm); 144 144 } else if (osm instanceof IRelation) { 145 return format((IRelation ) osm);145 return format((IRelation<?>) osm); 146 146 } 147 147 return null; … … 306 306 307 307 @Override 308 public String format(IRelation relation) {308 public String format(IRelation<?> relation) { 309 309 StringBuilder name = new StringBuilder(); 310 310 if (relation.isIncomplete()) { … … 336 336 } 337 337 338 private static StringBuilder formatRelationNameAndType(IRelation relation, StringBuilder result, TaggingPreset preset) {338 private static StringBuilder formatRelationNameAndType(IRelation<?> relation, StringBuilder result, TaggingPreset preset) { 339 339 if (preset == null || !(relation instanceof TemplateEngineDataProvider)) { 340 340 result.append(getRelationTypeName(relation)); … … 353 353 } 354 354 355 private final Comparator<IRelation > relationComparator = (r1, r2) -> {355 private final Comparator<IRelation<?>> relationComparator = (r1, r2) -> { 356 356 //TODO This doesn't work correctly with formatHooks 357 357 … … 396 396 397 397 @Override 398 public Comparator<IRelation > getRelationComparator() {398 public Comparator<IRelation<?>> getRelationComparator() { 399 399 return relationComparator; 400 400 } 401 401 402 private static String getRelationTypeName(IRelation relation) {402 private static String getRelationTypeName(IRelation<?> relation) { 403 403 String name = trc("Relation type", relation.get("type")); 404 404 if (name == null) { … … 433 433 } 434 434 435 private static String getNameTagValue(IRelation relation, String nameTag) {435 private static String getNameTagValue(IRelation<?> relation, String nameTag) { 436 436 if ("name".equals(nameTag)) { 437 437 if (Config.getPref().getBoolean("osm-primitives.localize-name", true)) … … 456 456 } 457 457 458 private static String getRelationName(IRelation relation) {458 private static String getRelationName(IRelation<?> relation) { 459 459 String nameTag; 460 460 for (String n : getNamingtagsForRelations()) { -
trunk/src/org/openstreetmap/josm/data/osm/IRelation.java
r13667 r13766 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import java.util.List; 5 4 6 /** 5 7 * IRelation captures the common functions of {@link Relation} and {@link RelationData}. 8 * @param <M> Type of OSM relation member 6 9 * @since 4098 7 10 */ 8 public interface IRelation extends IPrimitive {11 public interface IRelation<M extends IRelationMember<?>> extends IPrimitive { 9 12 10 13 /** … … 13 16 */ 14 17 int getMembersCount(); 18 19 /** 20 * Returns the relation member at the specified index. 21 * @param index the index of the relation member 22 * @return relation member at the specified index 23 * @since 13766 (IRelation) 24 */ 25 M getMember(int index); 26 27 /** 28 * Returns members of the relation. 29 * @return Members of the relation. Changes made in returned list are not mapped 30 * back to the primitive, use setMembers() to modify the members 31 * @since 1925 32 * @since 13766 (IRelation) 33 */ 34 List<M> getMembers(); 15 35 16 36 /** -
trunk/src/org/openstreetmap/josm/data/osm/IRelationMember.java
r13677 r13766 6 6 /** 7 7 * IRelationMember captures the common functions of {@link RelationMember} and {@link RelationMemberData}. 8 * @param <P> the base type of OSM primitives 8 9 * @since 13677 9 10 */ 10 public interface IRelationMember extends PrimitiveId {11 public interface IRelationMember<P extends IPrimitive> extends PrimitiveId { 11 12 12 13 /** … … 50 51 */ 51 52 boolean isRelation(); 53 54 /** 55 * Returns type of member for icon display. 56 * @return type of member for icon display 57 * @since 13766 (IRelationMember) 58 */ 59 default OsmPrimitiveType getDisplayType() { 60 return getMember().getDisplayType(); 61 } 62 63 /** 64 * Returns the relation member. 65 * @return Member. Returned value is never null. 66 * @since 13766 (IRelationMember) 67 */ 68 P getMember(); 52 69 } -
trunk/src/org/openstreetmap/josm/data/osm/IWay.java
r13717 r13766 77 77 if (o instanceof IRelation) 78 78 return 1; 79 return o instanceof IWay <?>? Long.compare(getUniqueId(), o.getUniqueId()) : -1;79 return o instanceof IWay ? Long.compare(getUniqueId(), o.getUniqueId()) : -1; 80 80 } 81 81 -
trunk/src/org/openstreetmap/josm/data/osm/NameFormatter.java
r13717 r13766 35 35 * @since 13564 (signature) 36 36 */ 37 String format(IRelation relation);37 String format(IRelation<?> relation); 38 38 39 39 /** … … 64 64 * @since 13564 (signature) 65 65 */ 66 Comparator<IRelation > getRelationComparator();66 Comparator<IRelation<?>> getRelationComparator(); 67 67 } -
trunk/src/org/openstreetmap/josm/data/osm/NameFormatterHook.java
r13717 r13766 15 15 * @return The corrected type name if needed, null otherwise. 16 16 */ 17 String checkRelationTypeName(IRelation relation, String defaultName);17 String checkRelationTypeName(IRelation<?> relation, String defaultName); 18 18 19 19 /** … … 39 39 * @return The corrected format if needed, null otherwise. 40 40 */ 41 String checkFormat(IRelation relation, String defaultName);41 String checkFormat(IRelation<?> relation, String defaultName); 42 42 } -
trunk/src/org/openstreetmap/josm/data/osm/OsmData.java
r13764 r13766 24 24 * @since 13764 25 25 */ 26 public interface OsmData<O extends IPrimitive, N extends INode, W extends IWay<N>, R extends IRelation > extends Data, Lockable {26 public interface OsmData<O extends IPrimitive, N extends INode, W extends IWay<N>, R extends IRelation<?>> extends Data, Lockable { 27 27 28 28 // -------------- -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitiveType.java
r13717 r13766 86 86 public static OsmPrimitiveType from(IPrimitive obj) { 87 87 if (obj instanceof INode) return NODE; 88 if (obj instanceof IWay <?>) return WAY;88 if (obj instanceof IWay) return WAY; 89 89 if (obj instanceof IRelation) return RELATION; 90 90 throw new IllegalArgumentException("Unknown type: "+obj); -
trunk/src/org/openstreetmap/josm/data/osm/QuadBucketPrimitiveStore.java
r13764 r13766 20 20 * @since 12048 21 21 */ 22 public class QuadBucketPrimitiveStore<N extends INode, W extends IWay<N>, R extends IRelation > {22 public class QuadBucketPrimitiveStore<N extends INode, W extends IWay<N>, R extends IRelation<?>> { 23 23 /** 24 24 * All nodes goes here, even when included in other data (ways etc). This enables the instant -
trunk/src/org/openstreetmap/josm/data/osm/Relation.java
r13667 r13766 24 24 * 25 25 * @author Frederik Ramm 26 * @since 343 26 27 */ 27 public final class Relation extends OsmPrimitive implements IRelation {28 public final class Relation extends OsmPrimitive implements IRelation<RelationMember> { 28 29 29 30 private RelationMember[] members = new RelationMember[0]; … … 31 32 private BBox bbox; 32 33 33 /** 34 * @return Members of the relation. Changes made in returned list are not mapped 35 * back to the primitive, use setMembers() to modify the members 36 * @since 1925 37 */ 34 @Override 38 35 public List<RelationMember> getMembers() { 39 36 return new CopyList<>(members); … … 75 72 } 76 73 77 /** 78 * Returns the relation member at the specified index. 79 * @param index the index of the relation member 80 * @return relation member at the specified index 81 */ 74 @Override 82 75 public RelationMember getMember(int index) { 83 76 return members[index]; -
trunk/src/org/openstreetmap/josm/data/osm/RelationData.java
r13764 r13766 11 11 * @since 2284 12 12 */ 13 public class RelationData extends PrimitiveData implements IRelation {13 public class RelationData extends PrimitiveData implements IRelation<RelationMemberData> { 14 14 15 15 private static final long serialVersionUID = 1163664954890478565L; … … 41 41 } 42 42 43 /** 44 * Returns relation members. 45 * @return relation members 46 */ 43 @Override 47 44 public List<RelationMemberData> getMembers() { 48 45 return members; … … 63 60 64 61 @Override 62 public RelationMemberData getMember(int index) { 63 return members.get(index); 64 } 65 66 @Override 65 67 public long getMemberId(int idx) { 66 return members.get(idx).getMemberId();68 return getMember(idx).getMemberId(); 67 69 } 68 70 69 71 @Override 70 72 public String getRole(int idx) { 71 return members.get(idx).getRole();73 return getMember(idx).getRole(); 72 74 } 73 75 74 76 @Override 75 77 public OsmPrimitiveType getMemberType(int idx) { 76 return members.get(idx).getMemberType();78 return getMember(idx).getMemberType(); 77 79 } 78 80 -
trunk/src/org/openstreetmap/josm/data/osm/RelationMember.java
r13677 r13766 12 12 * @since 343 13 13 */ 14 public class RelationMember implements IRelationMember {14 public class RelationMember implements IRelationMember<OsmPrimitive> { 15 15 16 16 /** … … 37 37 public boolean isWay() { 38 38 return member instanceof Way; 39 }40 41 /**42 * Returns type of member for icon display.43 * @return type of member for icon display44 * @since 384445 */46 public OsmPrimitiveType getDisplayType() {47 return member.getDisplayType();48 39 } 49 40 … … 80 71 } 81 72 82 /** 83 * Returns the relation member. 84 * @return Member. Returned value is never null. 85 * @since 1937 86 */ 73 @Override 87 74 public OsmPrimitive getMember() { 88 75 return member; -
trunk/src/org/openstreetmap/josm/data/osm/RelationMemberData.java
r13677 r13766 11 11 * @since 2284 12 12 */ 13 public class RelationMemberData implements IRelationMember , Serializable {13 public class RelationMemberData implements IRelationMember<PrimitiveData>, Serializable { 14 14 15 15 private static final long serialVersionUID = 381392198209333319L; … … 64 64 65 65 @Override 66 public OsmPrimitiveType getDisplayType() { 67 return memberType; 68 } 69 70 @Override 66 71 public boolean isNode() { 67 72 return OsmPrimitiveType.NODE == memberType; … … 76 81 public boolean isRelation() { 77 82 return OsmPrimitiveType.RELATION == memberType; 83 } 84 85 @Override 86 public PrimitiveData getMember() { 87 throw new UnsupportedOperationException(); 78 88 } 79 89 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/PrimitiveVisitor.java
r13717 r13766 28 28 * @param r The relation to inspect. 29 29 */ 30 void visit(IRelation r);30 void visit(IRelation<?> r); 31 31 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r13761 r13766 730 730 * @return The current selected relation membership 731 731 */ 732 public IRelation getSelectedMembershipRelation() {732 public IRelation<?> getSelectedMembershipRelation() { 733 733 int row = membershipTable.getSelectedRow(); 734 return row > -1 ? (IRelation ) membershipData.getValueAt(row, 0) : null;734 return row > -1 ? (IRelation<?>) membershipData.getValueAt(row, 0) : null; 735 735 } 736 736 -
trunk/src/org/openstreetmap/josm/io/OsmWriter.java
r13717 r13766 282 282 283 283 @Override 284 public void visit(IRelation e) {284 public void visit(IRelation<?> e) { 285 285 if (e.isIncomplete()) return; 286 286 addCommon(e, "relation");
Note:
See TracChangeset
for help on using the changeset viewer.