public static final boolean RETURN_UNMODIFIABLE_COLLECTIONS = false;
public static final boolean CHECK_PARAMERS = true;
- ArrayList<RouteLine> lines = new ArrayList<RouteLine>(4);
- ArrayList<RouteTerminal> terminals = new ArrayList<RouteTerminal>(4);
- ArrayList<RouteLine> transientLines = new ArrayList<RouteLine>(4);
- int caseId;
- boolean isSimpleConnection;
- boolean needsUpdate = false;
+ protected ArrayList<RouteLine> lines = new ArrayList<RouteLine>(4);
+ protected ArrayList<RouteTerminal> terminals = new ArrayList<RouteTerminal>(4);
+ protected ArrayList<RouteLine> transientLines = new ArrayList<RouteLine>(4);
+ protected int caseId;
+ protected boolean isSimpleConnection;
+ protected boolean needsUpdate = false;
public void updateTerminals() {
boolean changed = false;
needsUpdate = true;
}
- void removeTransientRouteLines() {
+ protected void removeTransientRouteLines() {
for(RouteLine line : transientLines)
line.remove();
transientLines.clear();
line.addPoint(b);
line.terminal = a;
transientLines.add(line);
+
+ // Path terminal
+ a.line = line;
+ b.line = line;
+
break;
}
case SimpleConnectionUtility.ONE_BEND_HORIZONTAL_VERTICAL: {
line2.terminal = b;
transientLines.add(line1);
transientLines.add(line2);
+
+ // Path terminal
+ a.line = line1;
+ b.line = line2;
break;
}
case SimpleConnectionUtility.ONE_BEND_VERTICAL_HORIZONTAL: {
line2.terminal = b;
transientLines.add(line1);
transientLines.add(line2);
+
+ //Path terminal
+ a.line = line1;
+ b.line = line2;
break;
}
case SimpleConnectionUtility.MORE_BENDS_BBS_DONT_INTERSECT:
break;
}
}
+ //routeFromTerminals(caseId==SimpleConnectionUtility.MORE_BENDS_BBS_INTERSECT);
}
else {
caseId = SimpleConnectionUtility.COMPLEX_CONNECTION;
}
}
- static class Interval {
+ public static class Interval {
public final double min;
public final double max;
public Interval(double min, double max) {
}
}
- class IntervalCache {
+ public class IntervalCache {
THashMap<RouteLine, Interval> cache =
new THashMap<RouteLine, Interval>();
public Interval get(RouteLine line) {
}
}
- private void routeFromTerminals(boolean boundingBoxesIntersect) {
+ protected void routeFromTerminals(boolean boundingBoxesIntersect) {
IntervalCache cache = new IntervalCache();
for(RouteTerminal terminal : terminals)
if(terminal.line != null) {
RouteLine nextTransient;
RouteTerminal terminal;
- RouteLine(boolean isHorizontal, double position) {
+ public RouteLine(boolean isHorizontal, double position) {
this.isHorizontal = isHorizontal;
this.position = position;
}
return hidden;
}
+ public void setHidden(boolean hidden) {
+ this.hidden = hidden;
+ }
+
public double getPosition() {
return position;
}
return points;
}
- void addPoint(RoutePoint link) {
+ public void addPoint(RoutePoint link) {
points.add(link);
}
point.removeFromOther(this);
}
- void setPointPositions() {
+ public void setPointPositions() {
if(isHorizontal) {
for(RoutePoint point : points)
point.y = position;
}
}
- void sortPoints() {
+ public void sortPoints() {
Collections.sort(points, isHorizontal
? RoutePoint.X_COMPARATOR
: RoutePoint.Y_COMPARATOR);
return terminal != null;
}
- RouteLine copy(THashMap<Object, Object> map) {
+ public RouteLine copy(THashMap<Object, Object> map) {
RouteLine copy = (RouteLine)map.get(this);
if(copy == null) {
copy = new RouteLine(isHorizontal, position);
public RouteTerminal getTerminal() {
return terminal;
}
+
+ public void setTerminal(RouteTerminal terminal) {
+ this.terminal = terminal;
+ }
public boolean beginsWithTerminal() {
RoutePoint begin = points.get(0);
private RouteLink() {
}
- RouteLink(RouteLine a, RouteLine b) {
+ public RouteLink(RouteLine a, RouteLine b) {
this.a = a;
this.b = b;
a.addPoint(this);
RouteLine line;
- RouteTerminal(double x, double y, double minX, double minY,
+ public RouteTerminal(double x, double y, double minX, double minY,
double maxX, double maxY, int allowedDirections,
boolean routeToBounds,
ILineEndStyle style, RouteTerminalPosition dynamicPosition) {
* adding necessary transient route lines.
* @param cache
*/
- void route(ArrayList<RouteLine> lines, IntervalCache cache, boolean boundingBoxesIntersect) {
+ protected void route(ArrayList<RouteLine> lines, IntervalCache cache, boolean boundingBoxesIntersect) {
if(routeToBounds) {
int lineDir;
boolean routeLineDoesNotIntersectTerminal;
return;
}
else {
- line.addPoint(this);
+ if (!line.getPoints().contains(this))
+ line.addPoint(this);
Interval interval = cache.get(line);
if(line.isHorizontal) {
if(interval.min < minX)
}
}
- private RouteLine createLine0(int dir) {
+ protected RouteLine createLine0(int dir) {
RouteLine line0 = (dir&1) == 0
? new RouteLine(true, y)
: new RouteLine(false, x)
}
}
- RouteTerminal copy(THashMap<Object, Object> map) {
+ public RouteTerminal copy(THashMap<Object, Object> map) {
RouteTerminal copy = (RouteTerminal)map.get(this);
if(copy == null) {
copy = new RouteTerminal(x, y, minX, minY, maxX, maxY,
return line;
}
+ public void setLine(RouteLine line) {
+ this.line = line;
+ }
+
public void setMinX(double minX) {
this.minX = minX;
}
public RouteTerminalPosition getDynamicPosition() {
return dynamicPosition;
}
+
+
public boolean updateDynamicPosition() {
boolean changed = false;
*
* @author Hannu Niemistö
*/
-class SimpleConnectionUtility {
+public class SimpleConnectionUtility {
public static boolean allowsDirection(RouteTerminal a, int dir) {
return Directions.isAllowed(a.getAllowedDirections(), dir);