trackeditor: add debug validateLinks

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@8550 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 3b76c09a0138c7432b42fe3df877068e9f0bf702
Former-commit-id: 9962b28293f786d7e6bb7b4f5c982b84746eab44
This commit is contained in:
iobyte 2022-09-25 18:56:58 +00:00
parent 7bb14eb878
commit ca209725be
2 changed files with 55 additions and 3 deletions

View file

@ -444,7 +444,7 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene
Editor.getProperties().setCurveNameCount(count2);
newShape2.setName("curve " + count2);
data.insertElementAt(newShape2, pos + 1);
//Undo.add(new UndoSplitSegment(cloneShape, newShape2));
//Undo.add(new UndoSplitSegment(editorFrame, oldShape, cloneShape, newShape2));
break;
}
case "rgt":
@ -500,7 +500,7 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene
Editor.getProperties().setCurveNameCount(count2);
newShape2.setName("curve " + count2);
data.insertElementAt(newShape2, pos + 1);
//Undo.add(new UndoSplitSegment(cloneShape, newShape2));
//Undo.add(new UndoSplitSegment(editorFrame, oldShape, cloneShape, newShape2));
break;
}
case "str":
@ -534,7 +534,7 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene
Editor.getProperties().setStraightNameCount(count3);
newShape3.setName("straight " + count3);
data.insertElementAt(newShape3, pos + 1);
//Undo.add(new UndoSplitSegment(cloneShape, newShape3));
//Undo.add(new UndoSplitSegment(editorFrame, oldShape, cloneShape, newShape3));
break;
}
default:

View file

@ -118,4 +118,56 @@ public class SegmentVector extends Vector<Segment>
(get(i).nextShape != null ? get(i).nextShape.getName() : "null"));
}
}
public boolean validateLinks()
{
boolean valid = true;
if (size() > 0)
{
if (get(0).getPreviousShape() != null)
{
System.out.println("segment[0] previousShape not null");
valid = false;
}
if (get(size() - 1).getNextShape() != null)
{
System.out.println("segment[" + (size() - 1) + "] nextShape not null");
valid = false;
}
}
for (int i = 0; i < size(); i++)
{
Segment segment = get(i);
if (segment.previousShape == null && i != 0)
{
System.out.println("segment[" + i + "] previousShape null");
valid = false;
}
if (segment.previousShape != null && segment.previousShape.nextShape != null &&
!segment.previousShape.nextShape.getName().equals(segment.getName()))
{
System.out.println("segment[" + i + "] previousShape bad");
valid = false;
}
if (segment.nextShape == null && i != size() - 1)
{
System.out.println("segment[" + i + "] nextShape null");
valid = false;
}
if (segment.nextShape != null && segment.nextShape.previousShape != null &&
!segment.nextShape.previousShape.getName().equals(segment.getName()))
{
System.out.println("segment[" + i + "] nextShape bad");
valid = false;
}
}
return valid;
}
}