Changeset 15696 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2020-01-13T00:11:29+01:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/PublicTransportRouteTest.java
r15522 r15696 61 61 } 62 62 63 final List<WayConnectionType> links = connectionTypeCalculator.updateLinks( membersToCheck);63 final List<WayConnectionType> links = connectionTypeCalculator.updateLinks(r, membersToCheck); 64 64 for (int i = 0; i < links.size(); i++) { 65 65 final WayConnectionType link = links.get(i); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableLinkedCellRenderer.java
r15076 r15696 32 32 33 33 reset(); 34 if (value == null) 35 return this; 36 37 this.value = (WayConnectionType) value; 38 setToolTipText(((WayConnectionType) value).getTooltip()); 39 renderBackgroundForeground(getModel(table), null, isSelected); 34 if (value != null) { 35 this.value = (WayConnectionType) value; 36 setToolTipText(((WayConnectionType) value).getTooltip()); 37 renderBackgroundForeground(getModel(table), null, isSelected); 38 } 40 39 return this; 41 40 } … … 63 62 int w = 2; 64 63 int p = 2 + w + 1; 64 int y1 = computePreviousY(g, xloop, xowloop, xoff, w, p); 65 int y2 = computeNextY(g, ymax, xloop, xowloop, xoff, w, p); 66 67 /* vertical lines */ 68 if (value.onewayFollowsNext && value.onewayFollowsPrevious) { 69 g.setColor(Color.black); 70 } else { 71 g.setColor(Color.lightGray); 72 } 73 if (value.isLoop) { 74 g.drawLine(xoff+xloop, y1, xoff+xloop, y2); 75 } 76 77 if (value.isOnewayHead) { 78 setDotted(g); 79 y1 = 7; 80 81 int[] xValues = {xoff - xowloop + 1, xoff - xowloop + 1, xoff}; 82 int[] yValues = {ymax, y1+1, 1}; 83 g.drawPolyline(xValues, yValues, 3); 84 unsetDotted(g); 85 g.drawLine(xoff + xowloop, y1+1, xoff, 1); 86 } 87 88 if (value.isOnewayTail) { 89 setDotted(g); 90 y2 = ymax - 7; 91 92 int[] xValues = {xoff+1, xoff - xowloop + 1, xoff - xowloop + 1}; 93 int[] yValues = {ymax-1, y2, y1}; 94 g.drawPolyline(xValues, yValues, 3); 95 unsetDotted(g); 96 g.drawLine(xoff + xowloop, y2, xoff, ymax-1); 97 } 98 99 if ((value.isOnewayLoopForwardPart || value.isOnewayLoopBackwardPart) && !value.isOnewayTail && !value.isOnewayHead) { 100 setDotted(g); 101 g.drawLine(xoff - xowloop+1, y1, xoff - xowloop+1, y2 + 1); 102 unsetDotted(g); 103 } 104 105 if (!value.isOnewayLoopForwardPart && !value.isOnewayLoopBackwardPart) { 106 g.drawLine(xoff, y1, xoff, y2); 107 } 108 109 g.drawLine(xoff+xowloop, y1, xoff+xowloop, y2); 110 111 /* special icons */ 112 Image arrow = getArrow(); 113 if (value.direction == Direction.ROUNDABOUT_LEFT) { 114 g.drawImage(ROUNDABOUT_LEFT, xoff-6, 1, null); 115 } else if (value.direction == Direction.ROUNDABOUT_RIGHT) { 116 g.drawImage(ROUNDABOUT_RIGHT, xoff-6, 1, null); 117 } 118 119 if (!value.isOnewayLoopForwardPart && !value.isOnewayLoopBackwardPart && 120 (arrow != null)) { 121 g.drawImage(arrow, xoff-3, (y1 + y2) / 2 - 2, null); 122 } 123 124 if (value.isOnewayLoopBackwardPart && value.isOnewayLoopForwardPart) { 125 if (arrow == ARROW_DOWN) { 126 arrow = ARROW_UP; 127 } else if (arrow == ARROW_UP) { 128 arrow = ARROW_DOWN; 129 } 130 } 131 132 if (arrow != null) { 133 g.drawImage(arrow, xoff+xowloop-3, (y1 + y2) / 2 - 2, null); 134 } 135 } 136 137 private int computePreviousY(Graphics g, int xloop, int xowloop, int xoff, int w, int p) { 65 138 int y1; 66 int y2;67 139 68 140 if (value.linkPrev) { … … 95 167 } 96 168 } 169 return y1; 170 } 171 172 private int computeNextY(Graphics g, int ymax, int xloop, int xowloop, int xoff, int w, int p) { 173 int y2; 97 174 98 175 if (value.linkNext) { … … 126 203 } 127 204 } 128 129 /* vertical lines */ 130 if (value.onewayFollowsNext && value.onewayFollowsPrevious) { 131 g.setColor(Color.black); 132 } else { 133 g.setColor(Color.lightGray); 134 } 135 if (value.isLoop) { 136 g.drawLine(xoff+xloop, y1, xoff+xloop, y2); 137 } 138 139 if (value.isOnewayHead) { 140 setDotted(g); 141 y1 = 7; 142 143 int[] xValues = {xoff - xowloop + 1, xoff - xowloop + 1, xoff}; 144 int[] yValues = {ymax, y1+1, 1}; 145 g.drawPolyline(xValues, yValues, 3); 146 unsetDotted(g); 147 g.drawLine(xoff + xowloop, y1+1, xoff, 1); 148 } 149 150 if (value.isOnewayTail) { 151 setDotted(g); 152 y2 = ymax - 7; 153 154 int[] xValues = {xoff+1, xoff - xowloop + 1, xoff - xowloop + 1}; 155 int[] yValues = {ymax-1, y2, y1}; 156 g.drawPolyline(xValues, yValues, 3); 157 unsetDotted(g); 158 g.drawLine(xoff + xowloop, y2, xoff, ymax-1); 159 } 160 161 if ((value.isOnewayLoopForwardPart || value.isOnewayLoopBackwardPart) && !value.isOnewayTail && !value.isOnewayHead) { 162 setDotted(g); 163 g.drawLine(xoff - xowloop+1, y1, xoff - xowloop+1, y2 + 1); 164 unsetDotted(g); 165 } 166 167 if (!value.isOnewayLoopForwardPart && !value.isOnewayLoopBackwardPart) { 168 g.drawLine(xoff, y1, xoff, y2); 169 } 170 171 g.drawLine(xoff+xowloop, y1, xoff+xowloop, y2); 172 173 /* special icons */ 174 Image arrow; 175 switch (value.direction) { 176 case FORWARD: 177 arrow = ARROW_DOWN; 178 break; 179 case BACKWARD: 180 arrow = ARROW_UP; 181 break; 182 default: 183 arrow = null; 184 } 185 if (value.direction == Direction.ROUNDABOUT_LEFT) { 186 g.drawImage(ROUNDABOUT_LEFT, xoff-6, 1, null); 187 } else if (value.direction == Direction.ROUNDABOUT_RIGHT) { 188 g.drawImage(ROUNDABOUT_RIGHT, xoff-6, 1, null); 189 } 190 191 if (!value.isOnewayLoopForwardPart && !value.isOnewayLoopBackwardPart && 192 (arrow != null)) { 193 g.drawImage(arrow, xoff-3, (y1 + y2) / 2 - 2, null); 194 } 195 196 if (value.isOnewayLoopBackwardPart && value.isOnewayLoopForwardPart) { 197 if (arrow == ARROW_DOWN) { 198 arrow = ARROW_UP; 199 } else if (arrow == ARROW_UP) { 200 arrow = ARROW_DOWN; 201 } 202 } 203 204 if (arrow != null) { 205 g.drawImage(arrow, xoff+xowloop-3, (y1 + y2) / 2 - 2, null); 206 } 205 return y2; 206 } 207 208 private Image getArrow() { 209 if (!value.ignoreOneway) { 210 switch (value.direction) { 211 case FORWARD: 212 return ARROW_DOWN; 213 case BACKWARD: 214 return ARROW_UP; 215 default: 216 break; 217 } 218 } 219 return null; 207 220 } 208 221 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r15378 r15696 777 777 try { 778 778 if (connectionType == null) { 779 connectionType = wayConnectionTypeCalculator.updateLinks( members);779 connectionType = wayConnectionTypeCalculator.updateLinks(relation, members); 780 780 } 781 781 return connectionType.get(i); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionType.java
r15076 r15696 36 36 FORWARD, BACKWARD, ROUNDABOUT_LEFT, ROUNDABOUT_RIGHT, NONE; 37 37 38 /** 39 * Determines if the direction denotes a roundabout. 40 * @return {@code true} if the direction denotes a roundabout 41 */ 38 42 public boolean isRoundabout() { 39 43 return this == ROUNDABOUT_RIGHT || this == ROUNDABOUT_LEFT; … … 43 47 /** True, if the element is part of a closed loop of ways. */ 44 48 public boolean isLoop; 49 50 /** True, if all oneway features are ignored */ 51 public boolean ignoreOneway; 45 52 46 53 public boolean isOnewayLoopForwardPart; … … 54 61 public boolean onewayFollowsNext = true; 55 62 63 /** 64 * Constructs a valid instance. 65 * @param linkPrev {@code true} if linked to the previous member 66 * @param linkNext {@code true} if linked to the next member 67 * @param direction the direction type 68 */ 56 69 public WayConnectionType(boolean linkPrev, boolean linkNext, Direction direction) { 57 70 this.linkPrev = linkPrev; … … 62 75 } 63 76 77 /** 78 * Constructs a valid or invalid instance. 79 * @param invalid {@code true} if the instance is invalid (i.e does not concern a complete way) 80 */ 64 81 public WayConnectionType(boolean invalid) { 65 82 this.invalid = invalid; … … 75 92 } 76 93 94 /** 95 * Determines if the connection type is valid (i.e. it concerns a complete way). 96 * @return {@code true} if the connection type is valid (i.e. it concerns a complete way) 97 */ 77 98 public boolean isValid() { 78 99 return !invalid; -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculator.java
r15586 r15696 10 10 11 11 import org.openstreetmap.josm.data.osm.Node; 12 import org.openstreetmap.josm.data.osm.Relation; 12 13 import org.openstreetmap.josm.data.osm.RelationMember; 13 14 import org.openstreetmap.josm.data.osm.Way; … … 30 31 */ 31 32 public List<WayConnectionType> updateLinks(List<RelationMember> members) { 33 return updateLinks(null, members); 34 } 35 36 /** 37 * refresh the cache of member WayConnectionTypes 38 * @param r relation. Can be null, for plugins compatibility, but really shouldn't 39 * @param members relation members 40 * @return way connections 41 * @since 15696 42 */ 43 public List<WayConnectionType> updateLinks(Relation r, List<RelationMember> members) { 32 44 this.members = members; 33 45 final List<WayConnectionType> con = new ArrayList<>(); … … 46 58 for (int i = 0; i < members.size(); ++i) { 47 59 try { 48 lastWct = updateLinksFor( con, lastWct, i);60 lastWct = updateLinksFor(r, con, lastWct, i); 49 61 } catch (RuntimeException e) { 50 62 int index = i; … … 58 70 } 59 71 60 private WayConnectionType updateLinksFor( finalList<WayConnectionType> con, WayConnectionType lastWct, int i) {72 private WayConnectionType updateLinksFor(Relation r, List<WayConnectionType> con, WayConnectionType lastWct, int i) { 61 73 final RelationMember m = members.get(i); 62 74 if (isNoHandleableWay(m)) { … … 67 79 firstGroupIdx = i; 68 80 } else { 69 WayConnectionType wct = computeNextWayConnection( con, lastWct, i, m);81 WayConnectionType wct = computeNextWayConnection(r, con, lastWct, i, m); 70 82 71 83 if (!wct.linkPrev) { … … 84 96 } 85 97 86 private WayConnectionType computeNextWayConnection( finalList<WayConnectionType> con, WayConnectionType lastWct, int i,98 private WayConnectionType computeNextWayConnection(Relation r, List<WayConnectionType> con, WayConnectionType lastWct, int i, 87 99 final RelationMember m) { 88 100 WayConnectionType wct = new WayConnectionType(false); 89 101 wct.linkPrev = i > 0 && con.get(i-1) != null && con.get(i-1).isValid(); 90 102 wct.direction = NONE; 91 92 if (RelationSortUtils.isOneway(m)) { 103 wct.ignoreOneway = isOnewayIgnored(r); 104 105 if (!wct.ignoreOneway && RelationSortUtils.isOneway(m)) { 93 106 handleOneway(lastWct, i, wct); 94 107 } … … 121 134 } 122 135 136 if (!wct.ignoreOneway) { 137 handleOnewayFollows(lastWct, i, m, wct); 138 } 139 con.set(i, wct); 140 return wct; 141 } 142 143 private static boolean isOnewayIgnored(Relation r) { 144 return r != null && "boundary".equals(r.get("type")); 145 } 146 147 protected void handleOnewayFollows(WayConnectionType lastWct, int i, final RelationMember m, 148 WayConnectionType wct) { 123 149 if (lastWct != null && i > 0 && m.getMember() instanceof Way && members.get(i - 1).getMember() instanceof Way 124 150 && (m.getWay().isOneway() != 0 || members.get(i - 1).getWay().isOneway() != 0)) { … … 135 161 } 136 162 } 137 con.set(i, wct);138 return wct;139 163 } 140 164
Note:
See TracChangeset
for help on using the changeset viewer.