diff --git a/GetThere/Final Maps - Get There /AtwaterKent-1st.jpg b/GetThere/Final Maps - Get There /AtwaterKent-1st.jpg new file mode 100755 index 0000000..2dd87ce Binary files /dev/null and b/GetThere/Final Maps - Get There /AtwaterKent-1st.jpg differ diff --git a/GetThere/Final Maps - Get There /AtwaterKent-2nd.jpg b/GetThere/Final Maps - Get There /AtwaterKent-2nd.jpg new file mode 100644 index 0000000..6c2f187 Binary files /dev/null and b/GetThere/Final Maps - Get There /AtwaterKent-2nd.jpg differ diff --git a/GetThere/Final Maps - Get There /AtwaterKent-3rd.jpg b/GetThere/Final Maps - Get There /AtwaterKent-3rd.jpg new file mode 100755 index 0000000..8774046 Binary files /dev/null and b/GetThere/Final Maps - Get There /AtwaterKent-3rd.jpg differ diff --git a/GetThere/Final Maps - Get There /AtwaterKent-Base.jpg b/GetThere/Final Maps - Get There /AtwaterKent-Base.jpg new file mode 100755 index 0000000..463ca25 Binary files /dev/null and b/GetThere/Final Maps - Get There /AtwaterKent-Base.jpg differ diff --git a/GetThere/Final Maps - Get There /BoyntonHall-1st.jpg b/GetThere/Final Maps - Get There /BoyntonHall-1st.jpg new file mode 100755 index 0000000..16af5df Binary files /dev/null and b/GetThere/Final Maps - Get There /BoyntonHall-1st.jpg differ diff --git a/GetThere/Final Maps - Get There /BoyntonHall-2nd.jpg b/GetThere/Final Maps - Get There /BoyntonHall-2nd.jpg new file mode 100755 index 0000000..baf3cd1 Binary files /dev/null and b/GetThere/Final Maps - Get There /BoyntonHall-2nd.jpg differ diff --git a/GetThere/Final Maps - Get There /BoyntonHall-3rd.jpg b/GetThere/Final Maps - Get There /BoyntonHall-3rd.jpg new file mode 100755 index 0000000..10e8d09 Binary files /dev/null and b/GetThere/Final Maps - Get There /BoyntonHall-3rd.jpg differ diff --git a/GetThere/Final Maps - Get There /BoyntonHall-Base.jpg b/GetThere/Final Maps - Get There /BoyntonHall-Base.jpg new file mode 100755 index 0000000..f9ef968 Binary files /dev/null and b/GetThere/Final Maps - Get There /BoyntonHall-Base.jpg differ diff --git a/GetThere/Final Maps - Get There /Campus Map.jpg b/GetThere/Final Maps - Get There /Campus Map.jpg new file mode 100755 index 0000000..b83fce9 Binary files /dev/null and b/GetThere/Final Maps - Get There /Campus Map.jpg differ diff --git a/GetThere/Final Maps - Get There /CampusCenter-1st.jpg b/GetThere/Final Maps - Get There /CampusCenter-1st.jpg new file mode 100755 index 0000000..cef4075 Binary files /dev/null and b/GetThere/Final Maps - Get There /CampusCenter-1st.jpg differ diff --git a/GetThere/Final Maps - Get There /CampusCenter-2nd.jpg b/GetThere/Final Maps - Get There /CampusCenter-2nd.jpg new file mode 100755 index 0000000..d899708 Binary files /dev/null and b/GetThere/Final Maps - Get There /CampusCenter-2nd.jpg differ diff --git a/GetThere/Final Maps - Get There /CampusCenter-3rd.jpg b/GetThere/Final Maps - Get There /CampusCenter-3rd.jpg new file mode 100755 index 0000000..fe83089 Binary files /dev/null and b/GetThere/Final Maps - Get There /CampusCenter-3rd.jpg differ diff --git a/GetThere/Final Maps - Get There /GordonLibrary-1st.jpg b/GetThere/Final Maps - Get There /GordonLibrary-1st.jpg new file mode 100755 index 0000000..61fc3c0 Binary files /dev/null and b/GetThere/Final Maps - Get There /GordonLibrary-1st.jpg differ diff --git a/GetThere/Final Maps - Get There /GordonLibrary-2nd.jpg b/GetThere/Final Maps - Get There /GordonLibrary-2nd.jpg new file mode 100755 index 0000000..f8fbc60 Binary files /dev/null and b/GetThere/Final Maps - Get There /GordonLibrary-2nd.jpg differ diff --git a/GetThere/Final Maps - Get There /GordonLibrary-3rd.jpg b/GetThere/Final Maps - Get There /GordonLibrary-3rd.jpg new file mode 100755 index 0000000..5287b4b Binary files /dev/null and b/GetThere/Final Maps - Get There /GordonLibrary-3rd.jpg differ diff --git a/GetThere/Final Maps - Get There /GordonLibrary-Base.jpg b/GetThere/Final Maps - Get There /GordonLibrary-Base.jpg new file mode 100755 index 0000000..1100a74 Binary files /dev/null and b/GetThere/Final Maps - Get There /GordonLibrary-Base.jpg differ diff --git a/GetThere/Final Maps - Get There /GordonLibrary-SubBase.jpg b/GetThere/Final Maps - Get There /GordonLibrary-SubBase.jpg new file mode 100755 index 0000000..33144b1 Binary files /dev/null and b/GetThere/Final Maps - Get There /GordonLibrary-SubBase.jpg differ diff --git a/GetThere/Final Maps - Get There /HigginsHouse-1st.jpg b/GetThere/Final Maps - Get There /HigginsHouse-1st.jpg new file mode 100755 index 0000000..4e66c53 Binary files /dev/null and b/GetThere/Final Maps - Get There /HigginsHouse-1st.jpg differ diff --git a/GetThere/Final Maps - Get There /HigginsHouse-2nd.jpg b/GetThere/Final Maps - Get There /HigginsHouse-2nd.jpg new file mode 100755 index 0000000..c366cdc Binary files /dev/null and b/GetThere/Final Maps - Get There /HigginsHouse-2nd.jpg differ diff --git a/GetThere/Final Maps - Get There /HigginsHouse-3rd.jpg b/GetThere/Final Maps - Get There /HigginsHouse-3rd.jpg new file mode 100755 index 0000000..aa2653e Binary files /dev/null and b/GetThere/Final Maps - Get There /HigginsHouse-3rd.jpg differ diff --git a/GetThere/Final Maps - Get There /HigginsHouse-Appartment.jpg b/GetThere/Final Maps - Get There /HigginsHouse-Appartment.jpg new file mode 100755 index 0000000..c745ca1 Binary files /dev/null and b/GetThere/Final Maps - Get There /HigginsHouse-Appartment.jpg differ diff --git a/GetThere/Final Maps - Get There /HigginsHouse-Garage.jpg b/GetThere/Final Maps - Get There /HigginsHouse-Garage.jpg new file mode 100755 index 0000000..316075d Binary files /dev/null and b/GetThere/Final Maps - Get There /HigginsHouse-Garage.jpg differ diff --git a/GetThere/Final Maps - Get There /ProjectCenter-1st.jpg b/GetThere/Final Maps - Get There /ProjectCenter-1st.jpg new file mode 100755 index 0000000..c9ebd8d Binary files /dev/null and b/GetThere/Final Maps - Get There /ProjectCenter-1st.jpg differ diff --git a/GetThere/Final Maps - Get There /ProjectCenter-2nd.jpg b/GetThere/Final Maps - Get There /ProjectCenter-2nd.jpg new file mode 100755 index 0000000..7a20538 Binary files /dev/null and b/GetThere/Final Maps - Get There /ProjectCenter-2nd.jpg differ diff --git a/GetThere/Final Maps - Get There /StartingImageDev.jpg b/GetThere/Final Maps - Get There /StartingImageDev.jpg new file mode 100755 index 0000000..3d15d0b Binary files /dev/null and b/GetThere/Final Maps - Get There /StartingImageDev.jpg differ diff --git a/GetThere/Final Maps - Get There /StartingImageUser.jpg b/GetThere/Final Maps - Get There /StartingImageUser.jpg new file mode 100755 index 0000000..867c143 Binary files /dev/null and b/GetThere/Final Maps - Get There /StartingImageUser.jpg differ diff --git a/GetThere/Final Maps - Get There /StrattonHall-1st.jpg b/GetThere/Final Maps - Get There /StrattonHall-1st.jpg new file mode 100755 index 0000000..14a0256 Binary files /dev/null and b/GetThere/Final Maps - Get There /StrattonHall-1st.jpg differ diff --git a/GetThere/Final Maps - Get There /StrattonHall-2nd.jpg b/GetThere/Final Maps - Get There /StrattonHall-2nd.jpg new file mode 100755 index 0000000..0a61a79 Binary files /dev/null and b/GetThere/Final Maps - Get There /StrattonHall-2nd.jpg differ diff --git a/GetThere/Final Maps - Get There /StrattonHall-3rd.jpg b/GetThere/Final Maps - Get There /StrattonHall-3rd.jpg new file mode 100755 index 0000000..ef94dbf Binary files /dev/null and b/GetThere/Final Maps - Get There /StrattonHall-3rd.jpg differ diff --git a/GetThere/Final Maps - Get There /StrattonHall-Base.jpg b/GetThere/Final Maps - Get There /StrattonHall-Base.jpg new file mode 100755 index 0000000..e393a30 Binary files /dev/null and b/GetThere/Final Maps - Get There /StrattonHall-Base.jpg differ diff --git a/GetThere/Get There - Jars (Iteration 2 presentation).zip b/GetThere/Get There - Jars (Iteration 2 presentation).zip new file mode 100644 index 0000000..b28cedc Binary files /dev/null and b/GetThere/Get There - Jars (Iteration 2 presentation).zip differ diff --git a/GetThere/MapList.ser b/GetThere/MapList.ser index 44b6093..fdc5b21 100644 Binary files a/GetThere/MapList.ser and b/GetThere/MapList.ser differ diff --git a/GetThere/src/DevGUI.java b/GetThere/src/DevGUI.java index 7134482..217cab3 100755 --- a/GetThere/src/DevGUI.java +++ b/GetThere/src/DevGUI.java @@ -22,8 +22,7 @@ import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; +import javax.swing.*; import java.util.*; import java.io.FileInputStream; @@ -31,6 +30,7 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.FileOutputStream; +import java.io.File; import java.awt.image.BufferedImage; @@ -92,8 +92,18 @@ public DevGUI(){ @SuppressWarnings("unchecked") public static void main(String[] args) { + + if(new File("MapList.ser").canRead()){ + maps.addAll((LinkedList) deserialize("MapList"));} + + + for(int c = 1; c < 8; c++){ + if(new File("MapList"+c+".ser").canRead()){ + maps.addAll((LinkedList) deserialize("MapList"+c));} + + } + - maps = (LinkedList) deserialize("MapList"); EventQueue.invokeLater(new Runnable() { public void run() { @@ -251,23 +261,11 @@ public void actionPerformed(ActionEvent e){ } }); - - JButton btnCreateMapLink = new JButton("Map link"); - btnCreateMapLink.setBounds(762, 196, 132, 29); - uiPanel.add(btnCreateMapLink); - btnCreateMapLink.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e){ - System.out.println("Create Special Nodes Pushed."); - createNodes = false; - createSpecial = false; - createEdges = false; - createMapLink = true; - } - }); + //Construct button and add action listener JButton btnMakeNeighbors = new JButton("Make Neighbors"); - btnMakeNeighbors.setBounds(762, 226, 132, 29); + btnMakeNeighbors.setBounds(762, 196, 132, 29); uiPanel.add(btnMakeNeighbors); btnMakeNeighbors.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e){ @@ -278,10 +276,43 @@ public void actionPerformed(ActionEvent e){ createMapLink = false; } }); + + +// //Construct button and add action listener +// JButton btnSetScale= new JButton("Set Scale"); +// btnSetScale.setBounds(762, 256, 132, 29); +// uiPanel.add(btnSetScale); +// btnSetScale.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent e){ +// +// +// +// System.out.println("Set Scale Pushed"); +// +// } +// }); + + +// SpinnerNumberModel model = new SpinnerNumberModel(1.0, 0.1, 1.4, .01); +// final JSpinner spinner = new JSpinner(model); +// spinner.setPreferredSize(new Dimension(45, spinner.getPreferredSize().height)); +// spinner.addChangeListener(new ChangeListener() +// { +// public void stateChanged(ChangeEvent e) +// { +// float scale = ((Double)spinner.getValue()).floatValue(); +// System.out.print(scale); +// } +// }); +// +// uiPanel.add(new JLabel("scale")); +// uiPanel.add(spinner); + + //Construct button and add action listener JButton btnExport = new JButton("Save Changes"); - btnExport.setBounds(762, 256, 132, 29); + btnExport.setBounds(762, 226, 132, 29); uiPanel.add(btnExport); btnExport.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e){ @@ -290,7 +321,7 @@ public void actionPerformed(ActionEvent e){ m1.produceEdges(); serialize("MapList", maps); if(updateMap){ - + for (int i = 0; i < maps.size(); i++) { if(maps.get(i).getMapName() != null){ if(!currentMapList.contains(maps.get(i).getMapName())){ @@ -310,7 +341,7 @@ public void actionPerformed(ActionEvent e){ JButton btnDeleteMap = new JButton("Delete Map"); - btnDeleteMap.setBounds(762, 316, 132, 29); + btnDeleteMap.setBounds(762, 286, 132, 29); uiPanel.add(btnDeleteMap); btnDeleteMap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e){ @@ -345,7 +376,8 @@ public void actionPerformed(ActionEvent e){ public class MouseEvents extends JComponent implements MouseMotionListener{ private static final long serialVersionUID = 1L; private static final int SquareWidth = 5; - public String nodes; + public String nodes; + private String nodeName; int nodeIndex; MouseEvents() { @@ -371,19 +403,20 @@ public void mouseClicked(MouseEvent evt) { if(createNodes){ if (nodeIndex < 0){ // not inside a square Node newNode = new Node(x, y); - newNode.setName(currentMapName + "."+ newNode.getName()); + newNode.setMapName(currentMapName); currentStartNodes.add(newNode); - + } } if(createSpecial){ if (nodeIndex < 0){ // not inside a square - String nodeName = currentMapName +"."+ JOptionPane.showInputDialog("Enter Node Name:"); + nodeName = JOptionPane.showInputDialog("Enter Node Name:"); if(nodeName == null || (nodeName != null && ("".equals(nodeName)))){ return; } else { - String[] types = {"No Type", "Bathroom", "Blue Tower", "Elevator", - "Stairs", "Food", "Emergency Exit", "Lecture Hall", "Office"}; + String[] types = {"No Type", "Men's Bathroom", "Women's Bathroom", "Blue Tower", "Elevator", + "Stairs", "Food", "Emergency Exit", "Lecture Hall", "Office", "Door", + "Room"}; Object selectedValue = JOptionPane.showInputDialog(null, "Choose a Node Type", "Input", JOptionPane.INFORMATION_MESSAGE, null, @@ -392,12 +425,19 @@ public void mouseClicked(MouseEvent evt) { switch((String)selectedValue){ case "No Type": currentStartNodes.add(new Node(x, y, nodeName, NodeType.NOTYPE)); + currentStartNodes.get(currentStartNodes.size() - 1).setMapName(currentMapName); break; - case "Bathroom": - currentStartNodes.add(new Node(x, y, nodeName, NodeType.BATHROOM)); + case "Men's Bathroom": + currentStartNodes.add(new Node(x, y, nodeName, NodeType.MBATHROOM)); + currentStartNodes.get(currentStartNodes.size() - 1).setMapName(currentMapName); + break; + case "Women's Bathroom": + currentStartNodes.add(new Node(x, y, nodeName, NodeType.FBATHROOM)); + currentStartNodes.get(currentStartNodes.size() - 1).setMapName(currentMapName); break; case "Blue Tower": currentStartNodes.add(new Node(x, y, nodeName, NodeType.BLUETOWER)); + currentStartNodes.get(currentStartNodes.size() - 1).setMapName(currentMapName); break; case "Elevator": makeLink(x, y, nodeName, NodeType.ELEVATOR); @@ -407,21 +447,29 @@ public void mouseClicked(MouseEvent evt) { break; case "Food": currentStartNodes.add(new Node(x, y, nodeName, NodeType.FOOD)); + currentStartNodes.get(currentStartNodes.size() - 1).setMapName(currentMapName); break; case "Emergency Exit": makeLink(x, y, nodeName, NodeType.EMERGEXIT); break; case "Lecture Hall": currentStartNodes.add(new Node(x, y, nodeName, NodeType.LECTUREHALL)); + currentStartNodes.get(currentStartNodes.size() - 1).setMapName(currentMapName); break; case "Office": currentStartNodes.add(new Node(x, y, nodeName, NodeType.OFFICE)); + currentStartNodes.get(currentStartNodes.size() - 1).setMapName(currentMapName); break; case "Door": makeLink(x, y, nodeName, NodeType.DOOR); break; + case "Room": + currentStartNodes.add(new Node(x, y, nodeName, NodeType.ROOM)); + currentStartNodes.get(currentStartNodes.size() - 1).setMapName(currentMapName); + break; default: currentStartNodes.add(new Node(x, y, nodeName, NodeType.NOTYPE)); + currentStartNodes.get(currentStartNodes.size() - 1).setMapName(currentMapName); } } } @@ -429,9 +477,9 @@ public void mouseClicked(MouseEvent evt) { } if(createMapLink){ if (nodeIndex < 0){ // not inside a square - Node newNode = new Node(x, y); - newNode.setType(currentType); - newNode.setName(currentMapName + "."+ newNode.getName()); + Node newNode = new Node(x, y, nodeName, currentType); + newNode.setMapName(currentMapName); + newNode.setName(newNode.getName()); currentStartNodes.add(newNode); Edge newEdge = new Edge(currentNode, newNode, 0); currentStartEdges.add(newEdge); @@ -456,7 +504,7 @@ public void mouseClicked(MouseEvent evt) { System.out.println(nodeIndex); currentStartEdges.add(new Edge(currentStartNodes.get(staringEdgeIndex), currentStartNodes.get(nodeIndex), - (int) calcDistance(currentStartNodes.get(staringEdgeIndex), currentStartNodes.get(nodeIndex)))); + (int) calcDistance(currentStartNodes.get(staringEdgeIndex), currentStartNodes.get(nodeIndex), maps.get(indexOfCurrentMap).getScale()))); count = 0; } } @@ -479,7 +527,7 @@ public void mouseClicked(MouseEvent evt) { addMouseMotionListener(this); } - + public void makeLink(int x, int y, String nodeName, NodeType type){ int i; currentType = type; @@ -488,10 +536,10 @@ public void makeLink(int x, int y, String nodeName, NodeType type){ mapNames[i] = currentMapList.get(i); } Object selectedMap = JOptionPane.showInputDialog(null, - "Choose a map to connect to", - "Input", - JOptionPane.INFORMATION_MESSAGE, null, - mapNames, mapNames[1]); + "Choose a map to connect to", + "Input", + JOptionPane.INFORMATION_MESSAGE, null, + mapNames, mapNames[1]); String tempMapName = (String) selectedMap; for (i = 0; i = 0) { - currentStartNodes.get(nodeIndex).setX(x); - currentStartNodes.get(nodeIndex).setY(y); - } +// if(nodeIndex >= 0) { +// currentStartNodes.get(nodeIndex).setX(x); +// currentStartNodes.get(nodeIndex).setY(y); +// } } } public Boolean getDeveloperMode(){ @@ -646,4 +741,4 @@ public void setDeveloperMode(Boolean modeSelect){ this.developerMode = modeSelect; } -} +} \ No newline at end of file diff --git a/GetThere/src/Djikstra.java b/GetThere/src/Djikstra.java index a09917f..bde94c8 100755 --- a/GetThere/src/Djikstra.java +++ b/GetThere/src/Djikstra.java @@ -71,7 +71,7 @@ public LinkedList navigate(Node start, Node goal){ return path; } - public LinkedList nearestBathroom(Node start){ + public LinkedList nearestSpecialNode(Node start, NodeType type){ if(start == null){ throw new IllegalArgumentException(); } @@ -83,7 +83,7 @@ public LinkedList nearestBathroom(Node start){ frontier.add(start); LinkedList temp = new LinkedList(); LinkedList path = new LinkedList(); - if(start.getType() == (NodeType.BATHROOM)){ + if(start.getType() == type){ path.add(start); return path; } @@ -95,7 +95,7 @@ public LinkedList nearestBathroom(Node start){ while (!(frontier.isEmpty())){ current = frontier.poll(); // possibly use remove - if(current.getType() == (NodeType.BATHROOM)){ + if(current.getType() == type){ break; } possibleNodes = current.getPossibleNodes(); @@ -170,52 +170,112 @@ else if (path.size() == 1){ current = path.removeFirst(); next = path.removeFirst(); counter +=1; - result += counter + ". " + "Walk " + current.getCost(next) + "\n"; + int nextCost = current.getCost(next); + if(nextCost != 0){ + result += counter + ". " + "Walk " + nextCost + " ft"+ "\n"; + } + else{ + if(current.getType().equals(NodeType.STAIRS)){ + result += counter + ". " + "Take the stairs "+ "\n"; + } + else if (current.getType().equals(NodeType.ELEVATOR)){ + result += counter + ". " + "Take the elevator"+ "\n"; + } + } + boolean straightFlag = false; + int straightValue = 0; + boolean straightPrintFlag = false; while(path.size() > 0){ + previous = current; current = next; next = path.removeFirst(); + nextCost = current.getCost(next); + if (nextCost == 0){ + if(current.getType().equals(NodeType.STAIRS)){ + result += counter + ". " + "Take the stairs "+ "\n"; + } + else if (current.getType().equals(NodeType.ELEVATOR)){ + result += counter + ". " + "Take the elevator"+ "\n"; + } + } // double a = Math.sqrt((Math.pow(next.getX() - previous.getX(),2)) + (Math.pow(next.getY() - previous.getY(),2))); // double b = Math.sqrt((Math.pow(next.getX() - current.getX(),2)) + (Math.pow(next.getY() - current.getY(),2))); // double c = Math.sqrt((Math.pow(current.getX() - previous.getX(),2)) + (Math.pow(current.getY() - previous.getY(),2))); // int angle = (int) Math.toDegrees(Math.acos((b*b + c*c - a*a)/(2*b*c))); + else{ int angle = (int) Math.toDegrees((Math.atan2(next.getY()-current.getY(),next.getX()-current.getX()) - Math.atan2(current.getY()-previous.getY(),current.getX()-previous.getX()))); //result += "Angle = " + angle + " \n"; + if(angle < 10 && angle > -10){ + if (!straightFlag){ + counter +=1; + result += counter + ". " +"Keep straight and "; + straightFlag = true; + straightValue += nextCost; + } + else { + straightValue += nextCost; + } + } + + else{ + if(straightFlag){ + result += "walk " + straightValue + " ft" + "\n"; + straightValue = 0; + straightFlag = false; + + } + if(angle < -65 && angle > -115){ counter +=1; - result += counter + ". " +"Take a left and "; + result += counter + ". " +"Take a left and "; + result += "walk " + nextCost + " ft" + "\n"; + } else if(angle > 65 && angle < 115){ counter +=1; result += counter + ". " +"Take a right and "; + result += "walk " + nextCost + " ft" + "\n"; + } else if(angle < 65 && angle > 10){ counter +=1; result += counter + ". " +"Take a slight right and "; + result += "walk " + nextCost + " ft" + "\n"; } else if(angle < -10 && angle > -65){ counter +=1; result += counter + ". " +"Take a slight left and "; + result += "walk " + nextCost + " ft" + "\n"; } else if (angle == 180 || angle == -180){ counter +=1; result += counter + ". " +"retrace your steps and contact whoever wrote this code, cause he screwed up, then "; + result += "walk " + nextCost + " ft" + "\n"; } else if(angle > 115){ - counter +=1; - result += counter + ". " +"Take a hard right and "; - } - else if(angle < -115){ counter +=1; result += counter + ". " +"Take a hard left and "; + result += "walk " + nextCost + " ft" + "\n"; } - else if(angle < 10 && angle > -10){ + else if(angle < -115){ counter +=1; - result += counter + ". " +"Keep straight and "; + result += counter + ". " +"Take a hard right and "; + result += "walk " + nextCost + " ft" + "\n"; } - result += "walk " + current.getCost(next) + " \n"; + + + + } + } } counter +=1; + if(straightFlag){ + result += "walk " + straightValue + " ft \n"; + straightValue = 0; + straightFlag = false; + + } result += counter + ". " + "You have reached your destination \n"; return result; diff --git a/GetThere/src/EndUserGUI.java b/GetThere/src/EndUserGUI.java index 8573802..c263a04 100755 --- a/GetThere/src/EndUserGUI.java +++ b/GetThere/src/EndUserGUI.java @@ -7,7 +7,6 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; -import java.awt.Rectangle; import java.awt.RenderingHints; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -15,7 +14,6 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; import java.awt.geom.GeneralPath; -import java.awt.geom.Line2D; import java.awt.image.BufferedImage; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -62,11 +60,11 @@ public class EndUserGUI extends JPanel implements ActionListener{ //private static LinkedList currentEndEdges = new LinkedList(); private String[] startRooms; - private String[] endRooms = new String[100]; + private String[] endRooms; // private String buildingSelectedSTART; //track which building is selected to start in. // private String buildingSelectedEND; //private String currentMapName; - private BufferedImage currentMapFile; + private static BufferedImage currentMapFile; private boolean startClicked = false; private boolean endClicked = false; @@ -79,7 +77,7 @@ public class EndUserGUI extends JPanel implements ActionListener{ private JFrame frame; //Creates the main frame for the GUI private JPanel uiPanel; //Panel to hold the interface buttons private JPanel mapPanel; //Panel to hold the map - private Image mapImage; + //private Image mapImage; //Represents the map to be chosen //private Image pathImage; //Image that draws the path on the map @@ -104,6 +102,7 @@ public class EndUserGUI extends JPanel implements ActionListener{ //Buttons on the UI private JButton searchButton; + private JButton clearButton; Graphics g; boolean updatePath = false; private JButton leftArrow; @@ -124,6 +123,8 @@ public class EndUserGUI extends JPanel implements ActionListener{ private Integer totalMaps = 1; private int arrowCounter = 0; private int floor = -1; + + private Map currentlyShownMap; private JButton emergency; private Icon emergencyIcon; @@ -133,6 +134,8 @@ public class EndUserGUI extends JPanel implements ActionListener{ private JButton history; private JButton transport; private Icon transportIcon; + private JButton nearestBathroom; + private Icon bathroomIcon; private String emailDirections; @@ -148,7 +151,6 @@ public EndUserGUI(){ @SuppressWarnings("unchecked") public static void main(String[] args) { maps = (LinkedList) deserialize("MapList"); - EventQueue.invokeLater(new Runnable() { EndUserGUI window = new EndUserGUI(); public void run() { @@ -205,13 +207,14 @@ private void initialize() { //Frame operations frame = new JFrame(); - frame.setBounds(100, 100, 1030, 700); + frame.setBounds(100, 100, 1200, 700); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.X_AXIS)); frame.setTitle("Get There"); frame.setResizable(false); frame.setVisible(true); + System.out.println(maps.get(maps.size()-1).getMapName()); //Panel Operations uiPanel = new JPanel(); frame.getContentPane().add(uiPanel); @@ -230,7 +233,7 @@ private void initialize() { buildingStart.setBounds(762, 26, 132, 29); roomStart = new JLabel("Select Room:"); - roomStart.setBounds(900, 26, 132, 29); + roomStart.setBounds(983, 26, 132, 29); endPoint = new JLabel("TO"); endPoint.setBounds(780, 72, 132, 29); @@ -239,7 +242,7 @@ private void initialize() { buildingEnd.setBounds(762, 92, 132, 29); roomEnd = new JLabel("Select Room:"); - roomEnd.setBounds(900, 92, 132, 29); + roomEnd.setBounds(983, 92, 132, 29); //Add Labels to the uiPanel @@ -251,14 +254,14 @@ private void initialize() { uiPanel.add(roomEnd); startRoomSEL.setModel(new DefaultComboBoxModel(new String[]{})); - startRoomSEL.setBounds(893, 50, 132, 29); + startRoomSEL.setBounds(983, 50, 210, 29); startRoomSEL.setEditable(false); startRoomSEL.setVisible(true); startRoomSEL.setName("Start"); - - + mapNumber = new JTextPane(); mapNumber.setBounds(360, 634, 47, 20); + mapNumber.setEditable(false); mapNumber.setFont(new Font("Helvetica Neue", Font.BOLD, 14)); mapNumber.setAlignmentX(StyleConstants.ALIGN_CENTER); mapNumber.setAlignmentY(StyleConstants.ALIGN_CENTER); @@ -266,11 +269,12 @@ private void initialize() { //Construct Combo boxes to select start point startBuildingSEL = new JComboBox(); - startBuildingSEL.setBounds(755, 50, 132, 29); + startBuildingSEL.setBounds(755, 50, 232, 29); startBuildingSEL.setEditable(false); startBuildingSEL.setVisible(true); startBuildingSEL.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { + //currentMapFile = maps.get(maps.size()-1).getImage(); updatePath = false; mapNumber.setText(""); startRoomSELLaunched = false; @@ -286,15 +290,16 @@ public void actionPerformed(ActionEvent e) { break; } currentStartNodes = maps.get(indexOfCurrentMap).getNodes(); - startRooms = new String[currentStartNodes.size()]; + startRooms = new String[currentStartNodes.size()]; currentStartEdges = maps.get(indexOfCurrentMap).getEdges(); currentMapFile = maps.get(indexOfCurrentMap).getImage(); + currentlyShownMap = maps.get(indexOfCurrentMap); arrowCounter = 0; mapsForPaths = null; startRoomSEL.removeAllItems(); for(int i = 0; i < currentStartNodes.size(); ++i){ startRooms[i] = currentStartNodes.get(i).getName(); - if(startRooms[i] != "") + if(startRooms[i] != "" && currentStartNodes.get(i).getType() != NodeType.NOTYPE) startRoomSEL.addItem(startRooms[i]); } startHoverFlag = false; @@ -309,15 +314,14 @@ public void actionPerformed(ActionEvent e) { } endRoomSEL.setModel(new DefaultComboBoxModel(new String[]{})); - endRoomSEL.setBounds(893, 116, 132, 29); + endRoomSEL.setBounds(983, 116, 210, 29); endRoomSEL.setEditable(false); endRoomSEL.setVisible(true); endRoomSEL.setName("End"); - //Construct Combo boxes to select end point endBuildingSEL = new JComboBox(); - endBuildingSEL.setBounds(755, 116, 132, 29); + endBuildingSEL.setBounds(755, 116, 232, 29); endBuildingSEL.setEditable(false); endBuildingSEL.setVisible(true); endBuildingSEL.addActionListener(new ActionListener(){ @@ -332,13 +336,16 @@ public void actionPerformed(ActionEvent e) { break; } currentEndNodes = maps.get(indexOfCurrentMap).getNodes(); - currentMapFile = maps.get(indexOfCurrentMap).getImage(); + endRooms = new String[currentEndNodes.size()]; + currentMapFile = maps.get(indexOfCurrentMap).getImage(); + currentlyShownMap = maps.get(indexOfCurrentMap); endRoomSEL.removeAllItems(); arrowCounter = 0; mapsForPaths = null; - for(int i = 0; i < currentEndNodes.size(); ++i){ + + for(int i = 0; i < currentEndNodes.size(); i++){ endRooms[i] = currentEndNodes.get(i).getName(); - if(endRooms[i] != "") + if(endRooms[i] != "" && currentEndNodes.get(i).getType() != NodeType.NOTYPE) endRoomSEL.addItem(endRooms[i]); } endHoverFlag = false; @@ -363,10 +370,25 @@ public void actionPerformed(ActionEvent e) { //Construct button and add button to uiPanel searchButton = new JButton ("Search"); - searchButton.setBounds(820, 150, 132, 29); + searchButton.setBounds(987, 150, 132, 30); uiPanel.add(searchButton); - + clearButton = new JButton ("Clear"); + clearButton.setBounds(853, 150, 132, 30); + uiPanel.add(clearButton); + clearButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) + { + updatePath = false; + startClicked = false; + endClicked = false; + endNode = null; + directions.setText(""); + mapsForPaths = null; + mapNumber.setText(""); + } + }); + leftArrow = new JButton("<<"); leftArrow.setBounds(275, 630, 80, 29); uiPanel.add(leftArrow); @@ -382,7 +404,7 @@ public void actionPerformed(ActionEvent e) { rightArrow.setEnabled(false); JLabel instructions = new JLabel("How to get there?"); - instructions.setBounds(762, 180, 132, 29); + instructions.setBounds(930, 180, 132, 29); uiPanel.add(instructions); directions = new JTextArea(); @@ -391,7 +413,7 @@ public void actionPerformed(ActionEvent e) { directions.setLineWrap(true); directions.setEditable(false); JScrollPane scrollDire = new JScrollPane(directions); - scrollDire.setBounds(762, 210, 255, 420); + scrollDire.setBounds(835, 210, 300, 420); scrollDire.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); uiPanel.add(scrollDire); @@ -400,7 +422,7 @@ public void actionPerformed(ActionEvent e) { emergency = new JButton(); emergency.setToolTipText("Emergency Information"); emergency.setIcon(emergencyIcon); - emergency.setBounds(790, 632, 40, 40); + emergency.setBounds(872, 632, 40, 40); uiPanel.add(emergency); String emergencyInfo = "Call Campus Police:" + "\n" + "508-831-5555"; emergency.addActionListener(new ActionListener(){ @@ -413,7 +435,7 @@ public void actionPerformed(ActionEvent e){ email = new JButton(); email.setToolTipText("Send Directions via Email"); email.setIcon(emailIcon); - email.setBounds(840, 632, 40, 40); + email.setBounds(920, 632, 40, 40); uiPanel.add(email); email.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -436,7 +458,7 @@ public void actionPerformed(ActionEvent e) transport = new JButton(); transport.setToolTipText("View Transport Schedule"); transport.setIcon(transportIcon); - transport.setBounds(890, 632, 40, 40); + transport.setBounds(968, 632, 40, 40); uiPanel.add(transport); transport.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ @@ -464,12 +486,46 @@ public void actionPerformed(ActionEvent e){ } }); + bathroomIcon = new ImageIcon("IconImages/bathroomIcon.png"); + Icon bathroomIconBIG = new ImageIcon("IconImages/bathroomIconBIG.png"); + nearestBathroom = new JButton(); + nearestBathroom.setToolTipText("Find nearest Bathroom"); + nearestBathroom.setIcon(bathroomIcon); + nearestBathroom.setBounds(1017, 632, 40, 40); + uiPanel.add(nearestBathroom); + nearestBathroom.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) + { +// String[] bathroomTypes = {"Female", "Male"}; +// Object selectedValue = JOptionPane.showInputDialog(null, "Bathroom Tyope", "Select Gender", +// JOptionPane.INFORMATION_MESSAGE, bathroomIconBIG,bathroomTypes, bathroomTypes[0]); +// if(selectedValue != null){ +// switch((String) selectedValue){ +// case "Female": +// listPath = pathCalc.nearestSpecialNode(startNode, NodeType.FBATHROOM); +// if(listPath != null){ +// updatePath = true; +// } +// break; +// case "Male": +// listPath = pathCalc.nearestSpecialNode(startNode, NodeType.MBATHROOM); +// if(listPath != null){ +// updatePath = true; +// } +// break; +// default: +// break; +// } +// } + } + }); + historyIcon = new ImageIcon("IconImages/historyIcon.png"); ImageIcon historyIconBIG = new ImageIcon("IconImages/historyIconBIG.png"); history = new JButton(); history.setToolTipText("...Coming Soon"); history.setIcon(historyIcon); - history.setBounds(940, 632, 40, 40); + history.setBounds(1064, 632, 40, 40); uiPanel.add(history); history.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ @@ -500,23 +556,13 @@ public void actionPerformed(ActionEvent e) directions.setText("Please Select End point"); updatePath = false; } - if(updatePath){ + if(updatePath && startNode != null && endNode != null){ System.out.println(startBuildingSEL.getSelectedItem()); System.out.println(floor); listPath = pathCalc.navigate(startNode, endNode); mapsForPaths = new LinkedList(); System.out.println(listPath.size()); for (i = 0; i < listPath.size(); i++){ - //String fullNodeLocation = listPath.get(i).getName(); - //int dotLoc = fullNodeLocation.indexOf("."); - //System.out.println(dotLoc); - //System.out.println(fullNodeLocation); - //String nodeLocation = fullNodeLocation.substring(0, dotLoc); - // if(fullNodeLocation != startBuildingSEL.getSelectedItem()){ - // for(int j = 0; j 1){ @@ -535,6 +582,8 @@ public void actionPerformed(ActionEvent e) mapNumber.setText(String.valueOf(1) + " of " + String.valueOf(totalMaps)); } } +// emailDirections = "From: " + startNode.getMapName() + " " + startNode.getName() + "\n" + "to " +// + Node.getMapName() + ", " + endRoomSEL.getSelectedItem() + "\n" + "\n" + emailDirections = pathCalc.gpsInstructions(pathCalc.navigate(startNode, endNode)); directions.setText(emailDirections); System.out.println("check List: " + listPath.size()); @@ -552,6 +601,7 @@ public void actionPerformed(ActionEvent e){ arrowCounter -= 1; mapNumber.setText(String.valueOf(arrowCounter + 1) + " of " + String.valueOf(totalMaps)); currentMapFile = mapsForPaths.get(arrowCounter).getImage(); + currentlyShownMap = mapsForPaths.get(arrowCounter); }else if (arrowCounter == 0){ leftArrow.setEnabled(false); } @@ -566,6 +616,7 @@ public void actionPerformed(ActionEvent e){ arrowCounter += 1; mapNumber.setText(String.valueOf(arrowCounter + 1) + " of " + String.valueOf(totalMaps)); currentMapFile = mapsForPaths.get(arrowCounter).getImage(); + currentlyShownMap = mapsForPaths.get(arrowCounter); }else if (arrowCounter == totalMaps-1){ rightArrow.setEnabled(false); } @@ -610,9 +661,9 @@ private Node findClosestNode(int x, int y) { double shortestDistance = Double.MAX_VALUE; double previousShortestDistance; Node result = null; - for(int i = 0; i < currentStartNodes.size(); i++){ + for(int i = 0; i < currentlyShownMap.getNodes().size(); i++){ previousShortestDistance = shortestDistance; - Node temp = currentStartNodes.get(i); + Node temp = currentlyShownMap.getNodes().get(i); shortestDistance = Math.min(Math.sqrt((temp.getX()-x)*(temp.getX()-x) + (temp.getY()-y)*(temp.getY()-y)), shortestDistance); if(previousShortestDistance != shortestDistance){ result = temp; @@ -656,27 +707,27 @@ public void paintComponent(Graphics g) { BasicStroke.JOIN_ROUND); g2d.setStroke(s); - if (path==null && updatePath == true) { + if (path==null && updatePath == true && listPath.size() > 0) { removeAll(); int i; path = new GeneralPath(); path.moveTo(listPath.getFirst().getX(), listPath.getFirst().getY()); for (i=1; i " + hovered.getX() + "---" + hovered.getY()); System.out.println(getPopupName()); if(!startHoverFlag){ startHoverFlag = true; return; - } + } if(!endHoverFlag){ - endHoverFlag = true; - return; - } + endHoverFlag = true; + return; + } + if(getPopupName().equals("Start")){ startClicked = true; startNode = hovered; @@ -827,17 +859,13 @@ else if(getPopupName().equals("End")){ System.out.println("END SELECTED"); } } - } + + } - private Node getNodeByName(String name) { - for(int i = 0; i < currentStartNodes.size(); i++){ - if(currentStartNodes.get(i).getName().equals(name)){ - return currentStartNodes.get(i); - } - } - for(int j = 0; j < currentEndNodes.size(); j++){ - if(currentEndNodes.get(j).getName().equals(name)){ - return currentEndNodes.get(j); + private Node getNodeByName(String name, LinkedList nodes) { + for(int i = 0; i < nodes.size(); i++){ + if(nodes.get(i).getName().equals(name)){ + return nodes.get(i); } } return null; @@ -857,4 +885,16 @@ private String getPopupName() { return jcb.getName(); } } + + private int IDCount; + public void fixIDs(LinkedList mapList){ + IDCount = 0; + for(int i = 0; i < mapList.size(); i++){ + for (int j = 0; j < mapList.get(i).getNodes().size(); j++){ + mapList.get(i).getNodes().get(j).setID(IDCount); + IDCount++; + } + } + } + } \ No newline at end of file diff --git a/GetThere/src/Map.java b/GetThere/src/Map.java index 483f94c..ed7a6d2 100755 --- a/GetThere/src/Map.java +++ b/GetThere/src/Map.java @@ -18,8 +18,9 @@ public class Map implements Serializable{ private LinkedList nodes; private LinkedList edges; private String mapName; + private double scale; - public Map(String mapPath, String mapName){ + public Map(String mapPath, String mapName, double s){ BufferedImage img = null; try { img = ImageIO.read(new File(mapPath)); @@ -28,6 +29,7 @@ public Map(String mapPath, String mapName){ this.mapName = mapName; nodes = new LinkedList(); edges = new LinkedList(); + this.scale = s; } public Map(BufferedImage img, String mapName){ @@ -82,6 +84,10 @@ public void addEdge(Edge edge){ this.edges.add(edge); } + public double getScale(){ + return this.scale; + } + public void deleteNode(Node node){ for(int i = 0; i < nodes.size(); i++){ if(node.equals(nodes.get(i))) diff --git a/GetThere/src/Node.java b/GetThere/src/Node.java index 531c234..ba37905 100755 --- a/GetThere/src/Node.java +++ b/GetThere/src/Node.java @@ -13,8 +13,10 @@ public class Node implements Serializable{ private NodeType type; private LinkedList possibleNodes; private String name; + private String mapName; private LinkedList EdgesList; private int priority; + private int ID; // private double distance; //heuristic public Node(int x, int y) { @@ -42,7 +44,23 @@ public Node(int x, int y, String name, NodeType t){ this.type = t; this.possibleNodes = new LinkedList(); this.EdgesList = new LinkedList(); - } + } + + public void setID(int id){ + this.ID = id; + } + + public int getID(){ + return this.ID; + } + + public String getMapName(){ + return this.mapName; + } + + public void setMapName(String mapName){ + this.mapName = mapName; + } public int getPriority(){ return this.priority; diff --git a/GetThere/src/NodeType.java b/GetThere/src/NodeType.java index b87ae24..93adb78 100755 --- a/GetThere/src/NodeType.java +++ b/GetThere/src/NodeType.java @@ -1,6 +1,8 @@ public enum NodeType { NOTYPE, - BATHROOM, + BATHROOM, + MBATHROOM, + FBATHROOM, BLUETOWER, ELEVATOR, STAIRS, @@ -8,5 +10,6 @@ public enum NodeType { EMERGEXIT, LECTUREHALL, OFFICE, - DOOR + DOOR, + ROOM } \ No newline at end of file diff --git a/GetThere/src/SelectMap.java b/GetThere/src/SelectMap.java index 146cb05..1dd9987 100755 --- a/GetThere/src/SelectMap.java +++ b/GetThere/src/SelectMap.java @@ -17,7 +17,7 @@ public SelectMap(final DevGUI gui) { super("Import map"); - setSize(350, 100); + setSize(500, 75); setDefaultCloseOperation(EXIT_ON_CLOSE); Container c = getContentPane(); @@ -26,6 +26,7 @@ public SelectMap(final DevGUI gui) { JButton openButton = new JButton("Open"); JButton importButton = new JButton("Import"); final JTextField mapName = new JTextField("Map name", 13); + final JTextField scale = new JTextField("Scale", 6); // Create a file chooser that opens up as an Open dialog @@ -45,7 +46,7 @@ public void actionPerformed(ActionEvent ae) { importButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { - Map newMap = new Map(filePath, mapName.getText()); + Map newMap = new Map(filePath, mapName.getText(), Double.parseDouble(scale.getText()) ); DevGUI.maps.add(newMap); System.out.println("TEST"); } @@ -54,7 +55,9 @@ public void actionPerformed(ActionEvent ae) { c.add(openButton); c.add(mapName); + c.add(scale); c.add(importButton); + }