GT-3161 - Function Graph - fixed 3 bugs that caused some edges to get

clipped by vertices
This commit is contained in:
dragonmacher 2019-09-17 13:36:18 -04:00
parent c10939cb63
commit 99ded59e84
2 changed files with 26 additions and 16 deletions

View File

@ -253,14 +253,11 @@ public class DecompilerNestedLayout extends AbstractFGLayout {
Vertex2d start = vertex2dFactory.get(startVertex);
Vertex2d end = vertex2dFactory.get(endVertex);
Address startAddress = startVertex.getVertexAddress();
Address endAddress = endVertex.getVertexAddress();
int compareResult = startAddress.compareTo(endAddress);
boolean goingUp = compareResult > 0;
boolean goingUp = start.rowIndex > end.rowIndex;
if (goingUp) {
// we paint loops going back up differently than other edges so the user can
// visually pick out the loops much easier
DecompilerBlock block = blockGraphRoot.getBlock(endVertex);
DecompilerBlock loop = block.getParentLoop();
@ -383,8 +380,7 @@ public class DecompilerNestedLayout extends AbstractFGLayout {
double y2 = y1;
articulations.add(new Point2D.Double(x2, y2));
Column column = vertex2dFactory.getColumn(x1);
routeAroundColumnVertices(start, end, column.index, vertex2dFactory, articulations, x2);
routeAroundColumnVertices(start, end, vertex2dFactory, articulations, x2);
double x3 = x2;
double y3 = end.getBottom() - VERTEX_BORDER_THICKNESS;
@ -424,6 +420,11 @@ public class DecompilerNestedLayout extends AbstractFGLayout {
routeAroundColumnVertices(start, end, vertex2dFactory, articulations, x3);
articulations.add(new Point2D.Double(x3, y3));
double x4 = end.getX();
double y4 = y3;
articulations.add(new Point2D.Double(x4, y4)); // point is hidden behind the vertex
}
private void routeToTheLeft(Vertex2d start, Vertex2d end, FGEdge e,
@ -538,19 +539,28 @@ public class DecompilerNestedLayout extends AbstractFGLayout {
y2 = Math.min(y2, endYLimit);
articulations.add(new Point2D.Double(x2, y2));
// have not yet seen an example of vertex/edge clipping when routing to the right
// routeAroundColumnVertices(start, end, vertex2dFactory, articulations, x2);
routeAroundColumnVertices(start, end, vertex2dFactory, articulations, x2);
double x3 = end.getX();
double y3 = y2;
double x3 = x2;
double y3 = end.getY();
articulations.add(new Point2D.Double(x3, y3)); // point is hidden behind the vertex
double x4 = end.getX();
double y4 = y3;
articulations.add(new Point2D.Double(x4, y4)); // point is hidden behind the vertex
}
private void routeAroundColumnVertices(Vertex2d start, Vertex2d end,
Vertex2dFactory vertex2dFactory, List<Point2D> articulations, double edgeX) {
int column = end.columnIndex;
routeAroundColumnVertices(start, end, column, vertex2dFactory, articulations, edgeX);
Column column = vertex2dFactory.getColumn(edgeX);
int columnIndex = 0;
if (column != null) {
// a null column happens with a negative x value that is outside of any column
columnIndex = column.index;
}
routeAroundColumnVertices(start, end, columnIndex, vertex2dFactory, articulations, edgeX);
}
private void routeAroundColumnVertices(Vertex2d start, Vertex2d end, int column,

View File

@ -103,10 +103,10 @@ public class LayoutLocationMap<V, E> {
Column column = null;
Collection<Column> values = columnsByIndex.values();
for (Column nextColumn : values) {
column = nextColumn;
if (x < column.x) {
if (x < nextColumn.x) {
return column;
}
column = nextColumn;
}
return column;
}