source: josm/trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionType.java@ 12658

Last change on this file since 12658 was 12658, checked in by michael2402, 7 years ago

See #14794: Add javadoc for gui/dialogs/relation/sort package.

  • Property svn:eol-style set to native
File size: 3.0 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.dialogs.relation.sort;
3
4import static org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionType.Direction.NONE;
5import static org.openstreetmap.josm.tools.I18n.tr;
6
7/**
8 * A class used by the {@link RelationSorter} to store if two ways are already connected
9 */
10public class WayConnectionType {
11
12 /** True, if the corresponding primitive is not a way or the way is incomplete */
13 private final boolean invalid;
14
15 /** True, if linked to the previous member. */
16 public boolean linkPrev;
17 /** True, if linked to the next member. */
18 public boolean linkNext;
19
20 /**
21 * direction is FORWARD if the first node of this way is connected to the previous way
22 * and / or the last node of this way is connected to the next way.
23 * direction is BACKWARD if it is the other way around.
24 * direction has a ROUNDABOUT value, if it is tagged as such and it is somehow
25 * connected to the previous / next member.
26 * If there is no connection to the previous or next member, then
27 * direction has the value NONE.
28 */
29 public Direction direction;
30
31 public enum Direction {
32 FORWARD, BACKWARD, ROUNDABOUT_LEFT, ROUNDABOUT_RIGHT, NONE;
33
34 public boolean isRoundabout() {
35 return this == ROUNDABOUT_RIGHT || this == ROUNDABOUT_LEFT;
36 }
37 }
38
39 /** True, if the element is part of a closed loop of ways. */
40 public boolean isLoop;
41
42 public boolean isOnewayLoopForwardPart;
43 public boolean isOnewayLoopBackwardPart;
44 public boolean isOnewayHead;
45 public boolean isOnewayTail;
46
47 public WayConnectionType(boolean linkPrev, boolean linkNext, Direction direction) {
48 this.linkPrev = linkPrev;
49 this.linkNext = linkNext;
50 this.isLoop = false;
51 this.direction = direction;
52 invalid = false;
53 }
54
55 public WayConnectionType(boolean invalid) {
56 this.invalid = invalid;
57 }
58
59 /** construct invalid instance */
60 public WayConnectionType() {
61 this.linkPrev = false;
62 this.linkNext = false;
63 this.isLoop = false;
64 this.direction = NONE;
65 invalid = true;
66 }
67
68 public boolean isValid() {
69 return !invalid;
70 }
71
72 @Override
73 public String toString() {
74 return "[P "+linkPrev+" ;N "+linkNext+" ;D "+direction+" ;L "+isLoop+
75 " ;FP " + isOnewayLoopForwardPart+";BP " + isOnewayLoopBackwardPart+
76 ";OH " + isOnewayHead+";OT " + isOnewayTail+']';
77 }
78
79 /**
80 * Returns tooltip.
81 * @return tooltip
82 * @since 10248
83 */
84 public String getTooltip() {
85 if (!isValid())
86 return "";
87 else if (linkPrev && linkNext)
88 return tr("way is connected");
89 else if (linkPrev)
90 return tr("way is connected to previous relation member");
91 else if (linkNext)
92 return tr("way is connected to next relation member");
93 else
94 return tr("way is not connected to previous or next relation member");
95 }
96}
Note: See TracBrowser for help on using the repository browser.