void generatePlans(CoverageCell[][] mat, CoverageCell first) { Vector<String> selectedVehicles = new Vector<String>(); Vector<SystemsList> tmp = getConsole().getSubPanelsOfClass(SystemsList.class); selectedVehicles.addAll(tmp.get(0).getSelectedSystems(true)); Object planid; if (selectedVehicles.size() > 1) planid = JOptionPane.showInputDialog(getConsole(), "Enter desired plan prefix"); else planid = JOptionPane.showInputDialog(getConsole(), "Enter desired plan name"); MissionType mission = getConsole().getMission(); if (mission == null) { GuiUtils.errorMessage(getConsole(), "Coverage Plan Solver", "No mission has been set"); return; } if (selectedVehicles.size() <= 1) { CoverageCell current = first, next = current.next; PlanCreator creator = new PlanCreator(mission); creator.setLocation(first.realWorldLoc); // creator.addManeuver("Goto"); while (next != null) { if (next.j != current.j) { CoverageCell pivot = current; while (pivot.previous != null && pivot.previous.i == current.i) pivot = pivot.previous; creator.setLocation(pivot.realWorldLoc); creator.addManeuver("Goto"); creator.setLocation(next.realWorldLoc); creator.addManeuver("Goto"); } current = next; next = current.next; } PlanType plan = creator.getPlan(); plan.setId(planid.toString()); plan.setVehicle(getConsole().getMainSystem()); mission.addPlan(plan); mission.save(false); getConsole().updateMissionListeners(); } else { double distance = 0; CoverageCell current = first, next = current.next; distance += current.realWorldLoc.getDistanceInMeters(next.realWorldLoc); while (next != null) { if (next.j != current.j) { CoverageCell pivot = current; while (pivot.previous != null && pivot.previous.i == current.i) pivot = pivot.previous; } distance += current.realWorldLoc.getDistanceInMeters(next.realWorldLoc); current = next; next = current.next; } double distEach = distance / selectedVehicles.size(); current = first; next = current.next; PlanCreator creator = new PlanCreator(mission); creator.setLocation(current.realWorldLoc); distance = 0; int curIndex = 0; while (next != null) { if (next.j != current.j) { CoverageCell pivot = current; while (pivot.previous != null && pivot.previous.i == current.i) pivot = pivot.previous; creator.setLocation(pivot.realWorldLoc); creator.addManeuver("Goto"); distance += current.realWorldLoc.getDistanceInMeters(next.realWorldLoc); if (distance < distEach) { creator.setLocation(next.realWorldLoc); creator.addManeuver("Goto"); } } else distance += current.realWorldLoc.getDistanceInMeters(next.realWorldLoc); if (distance > distEach) { creator.setLocation(current.realWorldLoc); creator.addManeuver("Goto"); PlanType plan = creator.getPlan(); plan.setVehicle(selectedVehicles.get(curIndex)); plan.setId(planid + "_" + selectedVehicles.get(curIndex++)); mission.addPlan(plan); creator = new PlanCreator(mission); creator.setLocation(current.realWorldLoc); creator.addManeuver("Goto"); distance = 0; } current = next; next = current.next; } PlanType plan = creator.getPlan(); plan.setVehicle(selectedVehicles.get(curIndex)); plan.setId(planid + "_" + selectedVehicles.get(curIndex++)); mission.addPlan(plan); mission.save(false); getConsole().updateMissionListeners(); } }