// private static ArrayList<String> pairs;
// private static Random random = new Random();
public static void createMaximalLines(ArrayList<LineModel> currentLines) throws Exception {
LineModel leftLine = null;
LineModel rightLine = null;
int rightIndex;
for (int i = 0; i < currentLines.size(); i++) {
for (int j = 0; j < currentLines.size(); j++) {
// avoid duplicate testing
if (i >= j) continue;
// sort lines left to right
rightIndex = (
MathUtils.compare(currentLines.get(i).getP1(),
currentLines.get(j).getP1()) == 1) ? i : j;
leftLine = currentLines.get(rightIndex == i ? j : i);
rightLine = currentLines.get(rightIndex);
// proceed to test the lines
if (MathUtils.compare(leftLine.getP2(), rightLine.getP1()) != -1 &&
MathUtils.vectorsEqual(leftLine, rightLine) &&
MathUtils.vectorsEqual(
leftLine.getP1(), leftLine.getP2(),
leftLine.getP1(), rightLine.getP2()
)) {
// set the line to the longest possible
if (MathUtils.compare(leftLine.getP2(), rightLine.getP2()) == -1) {
flipPoints(leftLine.getP2(), rightLine.getP2());
}
Debugger.getInstance().addMessage("REMOVING: " + currentLines.get(rightIndex).toString());
currentLines.remove(rightIndex);
//decrease iterator