Advertisement
dcndrd

Untitled

Nov 23rd, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1.  
  2. private void fillPathFields(String a, String b) {
  3. //Preenchendo todos os caminhos
  4. try {
  5. ArrayList<ArrayList<String>> paths = gf.getPossibleRoutes(a, b);
  6. String aText = "";
  7. for (int i = 0; i < paths.size(); i++) {
  8. ArrayList<String> p = paths.get(i);
  9. aText += "Caminho " + (i + 1) + ":\n";
  10. for (String p1 : p) {
  11. if(!p1.equals(b))
  12. aText += p1 + "\n->";
  13. else
  14. aText += p1 +"\n";
  15. }
  16. aText += "Total: "+MainInterface.format(gf.getPathWeigth(p))+"\n\n";
  17. }
  18. allPathsPane.setText(aText);
  19. } catch (VertexNotFoundException ex) {
  20. allPathsPane.setText("Não existem caminhos!");
  21. }
  22. try {
  23. //Preenchendo melhor caminho
  24. ArrayList<String> bestPath = gf.getSmallerPath(a, b);
  25. String bText = "";
  26. for (String s : bestPath) {
  27. if(s!= b)
  28. bText += s + "\n->";
  29. else
  30. bText += s +"\n";
  31. }
  32.  
  33. bestPathPane.setText(bText);
  34. } catch (PathlessException ex) {
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement