a few changes
This commit is contained in:
		
							parent
							
								
									1db0ce7ca7
								
							
						
					
					
						commit
						7e50caf26a
					
				| @ -16,8 +16,8 @@ import javax.swing.JScrollBar; | |||||||
| 
 | 
 | ||||||
| public class GUI_ViewRoute { | public class GUI_ViewRoute { | ||||||
| 	JFrame frame; | 	JFrame frame; | ||||||
| 	private String[] vehicleColNames = {"Num", "Status", "Length","Capacity", "Best Time", "Used By"}; | 	private String[] routeColNames = {"Num", "Status", "Length","Capacity", "Best Time", "Used By"}; | ||||||
| 	private Object[][] vehicleData; | 	private Object[][] routeData; | ||||||
| 	private JTable table; | 	private JTable table; | ||||||
| 	private Route[] stdRoute; | 	private Route[] stdRoute; | ||||||
| 	private PDate currenttimeManager; | 	private PDate currenttimeManager; | ||||||
| @ -41,24 +41,24 @@ public class GUI_ViewRoute { | |||||||
| 		frame.getContentPane().setLayout(null); | 		frame.getContentPane().setLayout(null); | ||||||
| 		frame.setLocationRelativeTo(null); | 		frame.setLocationRelativeTo(null); | ||||||
| 		 | 		 | ||||||
| 		vehicleData = new Object[stdRoute.length][6]; | 		routeData = new Object[stdRoute.length][6]; | ||||||
| 		for (int i = 0; i < stdRoute.length; i++) { | 		for (int i = 0; i < stdRoute.length; i++) { | ||||||
| 			vehicleData[i][0] = i; | 			routeData[i][0] = i; | ||||||
| 			vehicleData[i][1] = String.format("%s : %s",stdRoute[i].getHotelArea(),stdRoute[i].getMashier()); | 			routeData[i][1] = String.format("%s : %s",stdRoute[i].getHotelArea(),stdRoute[i].getMashier()); | ||||||
| 			vehicleData[i][2] = stdRoute[i].getTotalLength(); | 			routeData[i][2] = stdRoute[i].getTotalLength(); | ||||||
| 			vehicleData[i][3] = String.format("%.2f",stdRoute[i].capcity()); | 			routeData[i][3] = String.format("%.2f",stdRoute[i].capcity()); | ||||||
| 			vehicleData[i][4] = stdRoute[i].getFastestTimeOfTravel(new Bus()); | 			routeData[i][4] = stdRoute[i].getFastestTimeOfTravel(new Bus()); | ||||||
| 			int count = 0; | 			int count = 0; | ||||||
| 			for (Campaign campaign : listOfCampaigns) | 			for (Campaign campaign : listOfCampaigns) | ||||||
| 				if (campaign.getRoute() == stdRoute[i]) | 				if (campaign.getRoute() == stdRoute[i]) | ||||||
| 					count += campaign.getVehicles().size(); | 					count += campaign.getVehicles().size(); | ||||||
| 			 | 			 | ||||||
| 			vehicleData[i][5] = String.format("%d buses", count); | 			routeData[i][5] = String.format("%d buses", count); | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| 		 | 		 | ||||||
| 		table = new JTable(vehicleData,vehicleColNames); | 		table = new JTable(routeData,routeColNames); | ||||||
| 		table.setModel(new DefaultTableModel(vehicleData,vehicleColNames)); | 		table.setModel(new DefaultTableModel(routeData,routeColNames)); | ||||||
| 		table.getColumnModel().getColumn(0).setPreferredWidth(30); | 		table.getColumnModel().getColumn(0).setPreferredWidth(30); | ||||||
| 		table.getColumnModel().getColumn(1).setPreferredWidth(190); | 		table.getColumnModel().getColumn(1).setPreferredWidth(190); | ||||||
| 		table.getColumnModel().getColumn(2).setPreferredWidth(55); | 		table.getColumnModel().getColumn(2).setPreferredWidth(55); | ||||||
| @ -67,7 +67,7 @@ public class GUI_ViewRoute { | |||||||
| 		table.setColumnSelectionAllowed(true); | 		table.setColumnSelectionAllowed(true); | ||||||
| 		table.setCellSelectionEnabled(true); | 		table.setCellSelectionEnabled(true); | ||||||
| 		DefaultTableModel model = new DefaultTableModel(); | 		DefaultTableModel model = new DefaultTableModel(); | ||||||
| 		model.setColumnIdentifiers(vehicleColNames); | 		model.setColumnIdentifiers(routeColNames); | ||||||
| 		ListSelectionModel model2 = table.getSelectionModel(); | 		ListSelectionModel model2 = table.getSelectionModel(); | ||||||
| 		model2.addListSelectionListener(e -> { | 		model2.addListSelectionListener(e -> { | ||||||
| 			int row = model2.getMinSelectionIndex(); | 			int row = model2.getMinSelectionIndex(); | ||||||
|  | |||||||
| @ -21,8 +21,8 @@ public class GUI_ViewStreet { | |||||||
| 	private ArrayList<Vehicle> vehicles = new ArrayList<>(); | 	private ArrayList<Vehicle> vehicles = new ArrayList<>(); | ||||||
| 	private Street[] stdStreet = new Street[StreetNames.values().length]; | 	private Street[] stdStreet = new Street[StreetNames.values().length]; | ||||||
| 	private PDate currenttimeManager; | 	private PDate currenttimeManager; | ||||||
| 	private Object[][] busData; | 	private Object[][] vehicleData; | ||||||
| 	private String[] busColNames = {"ID", "District", "location","Progress", "trip time"}; | 	private String[] vehicleColNames = {"ID", "District", "location","Progress", "trip time"}; | ||||||
| 	private JTable table; | 	private JTable table; | ||||||
| 	private JLabel lblCapcityValue;  | 	private JLabel lblCapcityValue;  | ||||||
| 	private JLabel lblDate; | 	private JLabel lblDate; | ||||||
| @ -50,27 +50,27 @@ public class GUI_ViewStreet { | |||||||
| 		 | 		 | ||||||
| 		 | 		 | ||||||
| 		 | 		 | ||||||
| 		busData = new Object[vehicles.size()][6]; | 		vehicleData = new Object[vehicles.size()][6]; | ||||||
| 		for (int i = 0; i < vehicles.size(); i++) { | 		for (int i = 0; i < vehicles.size(); i++) { | ||||||
| 			busData[i][0] = vehicles.get(i).getUID(); | 			vehicleData[i][0] = vehicles.get(i).getUID(); | ||||||
| 			if (vehicles.get(i) instanceof Bus) | 			if (vehicles.get(i) instanceof Bus) | ||||||
| 				busData[i][1] = ((Bus)vehicles.get(i)).getCampaign().getHotelDistrict().name(); | 				vehicleData[i][1] = ((Bus)vehicles.get(i)).getCampaign().getHotelDistrict().name(); | ||||||
| 			else busData[i][1] = "Local Vehicle"; | 			else vehicleData[i][1] = "Local Vehicle"; | ||||||
| 			busData[i][2] = vehicles.get(i).getCurrentLocation(); | 			vehicleData[i][2] = vehicles.get(i).getCurrentLocation(); | ||||||
| 			busData[i][3] = vehicles.get(i).getProgress(); | 			vehicleData[i][3] = vehicles.get(i).getProgress(); | ||||||
| 			busData[i][4] = vehicles.get(i).getTripTime(); | 			vehicleData[i][4] = vehicles.get(i).getTripTime(); | ||||||
| 			 | 			 | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| 		table = new JTable(busData,busColNames); | 		table = new JTable(vehicleData,vehicleColNames); | ||||||
| 		table.setColumnSelectionAllowed(true); | 		table.setColumnSelectionAllowed(true); | ||||||
| 		table.setCellSelectionEnabled(true); | 		table.setCellSelectionEnabled(true); | ||||||
| 		DefaultTableModel model = new DefaultTableModel(); | 		DefaultTableModel model = new DefaultTableModel(); | ||||||
| 		model.setColumnIdentifiers(busColNames); | 		model.setColumnIdentifiers(vehicleColNames); | ||||||
| 		table.getTableHeader().setBackground(new Color(17,17,17)); | 		table.getTableHeader().setBackground(new Color(17,17,17)); | ||||||
| 		table.getTableHeader().setFont(new Font("Rockwell", Font.PLAIN, 18)); | 		table.getTableHeader().setFont(new Font("Rockwell", Font.PLAIN, 18)); | ||||||
| 		table.getTableHeader().setForeground(Color.WHITE); | 		table.getTableHeader().setForeground(Color.WHITE); | ||||||
| 		table.setModel(new DefaultTableModel(busData ,busColNames)); | 		table.setModel(new DefaultTableModel(vehicleData ,vehicleColNames)); | ||||||
| 		table.setBackground(new Color(17,17,17)); | 		table.setBackground(new Color(17,17,17)); | ||||||
| 		table.setForeground(Color.WHITE); | 		table.setForeground(Color.WHITE); | ||||||
| 		table.setGridColor(new Color(102, 102, 102)); | 		table.setGridColor(new Color(102, 102, 102)); | ||||||
| @ -248,18 +248,18 @@ public class GUI_ViewStreet { | |||||||
| 	 | 	 | ||||||
| 	public void updateTable() { | 	public void updateTable() { | ||||||
| 		if (vehicles.isEmpty()) return; | 		if (vehicles.isEmpty()) return; | ||||||
| 		busData = new Object[vehicles.size()][6]; | 		vehicleData = new Object[vehicles.size()][6]; | ||||||
| 		for (int i = 0; i < vehicles.size(); i++) { | 		for (int i = 0; i < vehicles.size(); i++) { | ||||||
| 			busData[i][0] = vehicles.get(i).getUID();// TODO: There is an Exception error here; | 			vehicleData[i][0] = vehicles.get(i).getUID();// TODO: There is an Exception error here; | ||||||
| 			if (vehicles.get(i) instanceof Bus) | 			if (vehicles.get(i) instanceof Bus) | ||||||
| 				busData[i][1] = ((Bus)vehicles.get(i)).getCampaign().getHotelDistrict().name(); | 				vehicleData[i][1] = ((Bus)vehicles.get(i)).getCampaign().getHotelDistrict().name(); | ||||||
| 			else busData[i][1] = "Local Vehicle"; | 			else vehicleData[i][1] = "Local Vehicle"; | ||||||
| 			busData[i][2] = vehicles.get(i).getCurrentLocation(); | 			vehicleData[i][2] = vehicles.get(i).getCurrentLocation(); | ||||||
| 			busData[i][3] = vehicles.get(i).getProgress(); | 			vehicleData[i][3] = vehicles.get(i).getProgress(); | ||||||
| 			busData[i][4] = vehicles.get(i).getTripTime(); | 			vehicleData[i][4] = vehicles.get(i).getTripTime(); | ||||||
| 			 | 			 | ||||||
| 		} | 		} | ||||||
| 		table.setModel(new DefaultTableModel(busData ,busColNames)); | 		table.setModel(new DefaultTableModel(vehicleData ,vehicleColNames)); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public double capcityPoint(int x) { | 	public double capcityPoint(int x) { | ||||||
|  | |||||||
| @ -47,6 +47,7 @@ public class MakkahCity { | |||||||
| 	private static JLabel lblMinimumTripValue; | 	private static JLabel lblMinimumTripValue; | ||||||
|     private static JLabel lblBusesArrivedInTheLastHourValue; |     private static JLabel lblBusesArrivedInTheLastHourValue; | ||||||
|     private static JLabel lblAverageTripForLastHourValue; |     private static JLabel lblAverageTripForLastHourValue; | ||||||
|  |     private static JButton btnPause; | ||||||
| 	 | 	 | ||||||
| 
 | 
 | ||||||
| 	public static void main(String[] args) { | 	public static void main(String[] args) { | ||||||
| @ -79,8 +80,7 @@ public class MakkahCity { | |||||||
| 		//Street data | 		//Street data | ||||||
| 		Object[][] streetData = new Object[stdStreet.length][6]; | 		Object[][] streetData = new Object[stdStreet.length][6]; | ||||||
| 		String[] streetColNames = {"Street Name", "Street Load %", "Total", "Buses", | 		String[] streetColNames = {"Street Name", "Street Load %", "Total", "Buses", | ||||||
| 				"Local Vehicles", | 				"Local Vehicles","Avg. Time"}; | ||||||
| 				"Avg. Time"}; |  | ||||||
| 
 | 
 | ||||||
| 		for (int i = 0; i < stdStreet.length; i++) { | 		for (int i = 0; i < stdStreet.length; i++) { | ||||||
| 			streetData[i][0] = stdStreet[i].getName().name(); | 			streetData[i][0] = stdStreet[i].getName().name(); | ||||||
| @ -153,8 +153,9 @@ public class MakkahCity { | |||||||
| 		btnViewRoutes.setBackground(new Color(9,9,9)); | 		btnViewRoutes.setBackground(new Color(9,9,9)); | ||||||
| 		btnViewRoutes.setForeground(Color.white); | 		btnViewRoutes.setForeground(Color.white); | ||||||
| 		btnViewRoutes.addActionListener(e -> { | 		btnViewRoutes.addActionListener(e -> { | ||||||
| 			EventControll t =  new EventControll(); | 			GUI_ViewRoute r = new GUI_ViewRoute(stdRoutes ,listOfCampaigns, currenttimeManager); | ||||||
| 			t.setData(stdRoutes[0]); | 			pause_flag = true; | ||||||
|  | 			btnPause.setText("Unpause"); | ||||||
| 		}); | 		}); | ||||||
| 		JButton btnViewBuses = new JButton("View Buses"); | 		JButton btnViewBuses = new JButton("View Buses"); | ||||||
| 		btnViewBuses.setBounds(1307, 76, 166, 29); | 		btnViewBuses.setBounds(1307, 76, 166, 29); | ||||||
| @ -163,6 +164,8 @@ public class MakkahCity { | |||||||
| 		btnViewBuses.setForeground(Color.white); | 		btnViewBuses.setForeground(Color.white); | ||||||
| 		btnViewBuses.addActionListener(e -> { | 		btnViewBuses.addActionListener(e -> { | ||||||
| 			GUI_ViewBuses t =  new GUI_ViewBuses(listOfCampaigns , currenttimeManager); | 			GUI_ViewBuses t =  new GUI_ViewBuses(listOfCampaigns , currenttimeManager); | ||||||
|  | 			pause_flag = true; | ||||||
|  | 			btnPause.setText("Unpause"); | ||||||
| 		}); | 		}); | ||||||
| 		 | 		 | ||||||
| 		JButton btnViewCampaigns = new JButton("View Campaigns"); | 		JButton btnViewCampaigns = new JButton("View Campaigns"); | ||||||
| @ -178,6 +181,8 @@ public class MakkahCity { | |||||||
| 		btnViewStreet.setForeground(Color.white); | 		btnViewStreet.setForeground(Color.white); | ||||||
| 		btnViewStreet.addActionListener(e -> { | 		btnViewStreet.addActionListener(e -> { | ||||||
| 			GUI_ViewStreet t =  new GUI_ViewStreet(stdStreet,currenttimeManager); | 			GUI_ViewStreet t =  new GUI_ViewStreet(stdStreet,currenttimeManager); | ||||||
|  | 			pause_flag = true; | ||||||
|  | 			btnPause.setText("Unpause"); | ||||||
| 		}); | 		}); | ||||||
| 
 | 
 | ||||||
| 		JButton btnExit = new JButton("Exit"); | 		JButton btnExit = new JButton("Exit"); | ||||||
| @ -187,7 +192,7 @@ public class MakkahCity { | |||||||
| 		btnExit.setBounds(1307, 623, 166, 29); | 		btnExit.setBounds(1307, 623, 166, 29); | ||||||
| 		btnExit.addActionListener(actionEvent -> exit_flag = true); | 		btnExit.addActionListener(actionEvent -> exit_flag = true); | ||||||
| 
 | 
 | ||||||
| 		JButton btnPause = new JButton("Pause"); | 		btnPause = new JButton("Pause"); | ||||||
| 		btnPause.setBackground(new Color(9,9,9)); | 		btnPause.setBackground(new Color(9,9,9)); | ||||||
| 		btnPause.setFont(new Font("Rockwell", Font.PLAIN, 16)); | 		btnPause.setFont(new Font("Rockwell", Font.PLAIN, 16)); | ||||||
| 		btnPause.setForeground(Color.white); | 		btnPause.setForeground(Color.white); | ||||||
| @ -410,6 +415,7 @@ public class MakkahCity { | |||||||
| 			} | 			} | ||||||
| 			if (isAllArrived() && allArrivedToArafatTime == null) allArrivedToArafatTime = (Date)currenttimeManager.getCurrentTime().clone(); | 			if (isAllArrived() && allArrivedToArafatTime == null) allArrivedToArafatTime = (Date)currenttimeManager.getCurrentTime().clone(); | ||||||
| 			firstDayTimeMan.step(Calendar.MINUTE, 1); | 			firstDayTimeMan.step(Calendar.MINUTE, 1); | ||||||
|  | 			lblDate.setText(currenttimeManager.getCurrentTime().toString()); | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| 		currenttimeManager = lastDayTimeMan; | 		currenttimeManager = lastDayTimeMan; | ||||||
| @ -470,6 +476,7 @@ public class MakkahCity { | |||||||
| 			} | 			} | ||||||
| 			if (isAllArrived() && allArrivedToHotelsTime == null) allArrivedToHotelsTime = (Date)currenttimeManager.getCurrentTime().clone(); | 			if (isAllArrived() && allArrivedToHotelsTime == null) allArrivedToHotelsTime = (Date)currenttimeManager.getCurrentTime().clone(); | ||||||
| 			lastDayTimeMan.step(Calendar.MINUTE, 1); | 			lastDayTimeMan.step(Calendar.MINUTE, 1); | ||||||
|  | 			lblDate.setText(currenttimeManager.getCurrentTime().toString()); | ||||||
| 		} | 		} | ||||||
| 		//When done show menu to analyze. Exit from menu too. | 		//When done show menu to analyze. Exit from menu too. | ||||||
| 		inputListener.pause(); | 		inputListener.pause(); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user