new Class for show the buses
This commit is contained in:
parent
f397003d32
commit
1b137dce3b
@ -45,79 +45,55 @@ public class GUI_ViewBuses {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public GUI_ViewBuses() {
|
public GUI_ViewBuses() {
|
||||||
//makeFrame();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void makeFrame() {
|
|
||||||
frame = new JFrame();
|
|
||||||
frame.setBounds(100, 100, 700, 1000);
|
|
||||||
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
||||||
// JScrollPane scrollPane = new JScrollPane();
|
|
||||||
gridBagLayout.columnWidths = new int[]{0, 0};
|
|
||||||
gridBagLayout.rowHeights = new int[]{0, 0, 0, 0};
|
|
||||||
// gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
||||||
// gridBagLayout.rowWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
|
|
||||||
frame.getContentPane().setLayout(gridBagLayout);
|
|
||||||
|
|
||||||
JLabel lblNewLabel = new JLabel("New label");
|
|
||||||
GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
|
|
||||||
gbc_lblNewLabel.insets = new Insets(0, 0, 5, 0);
|
|
||||||
gbc_lblNewLabel.gridx = 0;
|
|
||||||
gbc_lblNewLabel.gridy = 0;
|
|
||||||
|
|
||||||
|
|
||||||
GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
|
|
||||||
for (int i = 0; i<100 ; i++) {
|
|
||||||
JButton btnNewButton = new JButton(vehicles.get(i).getUID());
|
|
||||||
gbc_btnNewButton.insets = new Insets(0, 0, 5, 0);
|
|
||||||
gbc_btnNewButton.gridx = i%5;
|
|
||||||
gbc_btnNewButton.gridy = i/5 +1;
|
|
||||||
frame.getContentPane().add(btnNewButton, gbc_btnNewButton);
|
|
||||||
frame.getContentPane().add(lblNewLabel, gbc_lblNewLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
// GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
|
||||||
// gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
|
|
||||||
// gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
|
||||||
// gbc_scrollPane.gridx = 0;
|
|
||||||
// gbc_scrollPane.gridy = 1;
|
|
||||||
//scrollPane.setViewportView(gbc_scrollPane);
|
|
||||||
//frame.getContentPane().add(scrollPane, gbc_scrollPane);
|
|
||||||
frame.setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setData(ArrayList<Campaign> campaign) {
|
|
||||||
for (Campaign camp : campaign)
|
|
||||||
vehicles.add(camp.getVehicles().get(0));
|
|
||||||
makeFrame();
|
makeFrame();
|
||||||
}
|
}
|
||||||
|
private void makeFrame() {
|
||||||
|
frame = new JFrame("Buses");
|
||||||
|
Object[][] busData = new Object[vehicles.size()][5];
|
||||||
|
String[] busColNames = {"ID", "trip time", "location", "Street", "district"
|
||||||
|
};
|
||||||
|
|
||||||
|
table = new JTable(busData,busColNames);
|
||||||
|
DefaultTableModel model = new DefaultTableModel();
|
||||||
|
model.setColumnIdentifiers(busColNames);
|
||||||
|
table.getTableHeader().setBackground(new Color(17,17,17));
|
||||||
|
table.getTableHeader().setFont(new Font("Rockwell", Font.PLAIN, 18));
|
||||||
|
table.getTableHeader().setForeground(Color.WHITE);
|
||||||
|
table.setModel(model);
|
||||||
|
table.setBackground(new Color(17,17,17));
|
||||||
|
table.setForeground(Color.WHITE);
|
||||||
|
table.setGridColor(new Color(102, 102, 102));
|
||||||
|
table.setFont(new Font("Rockwell", Font.PLAIN, 18));
|
||||||
|
table.setRowHeight(25);
|
||||||
|
table.setAutoCreateRowSorter(true);
|
||||||
|
table.revalidate();
|
||||||
|
|
||||||
|
JScrollPane scrollPane = new JScrollPane(table);
|
||||||
|
scrollPane.setEnabled(false);
|
||||||
|
scrollPane.setBounds(20, 24, 668, 236);
|
||||||
|
|
||||||
|
frame.getContentPane().add(scrollPane);
|
||||||
|
frame.getContentPane().setBackground(new Color(70, 70, 70));
|
||||||
|
frame.getContentPane().setForeground(new Color(0, 0, 0));
|
||||||
|
frame.setBounds(100,100,814,454);
|
||||||
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
frame.getContentPane().setLayout(null);
|
||||||
|
frame.setLocationRelativeTo(null);
|
||||||
|
frame.getContentPane().add(scrollPane);
|
||||||
|
|
||||||
|
JButton btnNewButton = new JButton("New button");
|
||||||
|
btnNewButton.setBounds(89, 306, 89, 23);
|
||||||
|
frame.getContentPane().add(btnNewButton);
|
||||||
|
|
||||||
|
JButton btnNewButton_1 = new JButton("New button");
|
||||||
|
btnNewButton_1.setBounds(222, 306, 89, 23);
|
||||||
|
frame.getContentPane().add(btnNewButton_1);
|
||||||
|
|
||||||
|
JButton btnNewButton_2 = new JButton("New button");
|
||||||
|
btnNewButton_2.setBounds(341, 306, 89, 23);
|
||||||
|
frame.getContentPane().add(btnNewButton_2);
|
||||||
|
frame.setVisible(true);
|
||||||
|
|
||||||
|
|
||||||
/**
|
}
|
||||||
* Object[][] vehicleData = new Object[50][4]; String[] vehicleColNames =
|
|
||||||
* {"ID","Street", "Location", "Distance covered"};
|
|
||||||
*
|
|
||||||
* for (int i = 0; i < 50 ; i++) { vehicleData[i][0] = vehicles.get(i).getUID();
|
|
||||||
* vehicleData[i][1] = vehicles.get(i).getCurrentStreet(); vehicleData[i][2] =
|
|
||||||
* vehicles.get(i).getCurrentLocation(); vehicleData[i][3] =
|
|
||||||
* vehicles.get(i).getTotalDistanceTraveled(); //vehicleData[i][4] =
|
|
||||||
* vehicles.get(i).getTimeOfArrival(); }
|
|
||||||
*
|
|
||||||
* table = new JTable(vehicleData,vehicleColNames);
|
|
||||||
* frame.getContentPane().add(table, BorderLayout.CENTER);
|
|
||||||
* table.setEnabled(false); DefaultTableModel model = new DefaultTableModel();
|
|
||||||
* model.setColumnIdentifiers(vehicleData);
|
|
||||||
* table.getTableHeader().setBackground(new Color(17,17,17));
|
|
||||||
* table.getTableHeader().setForeground(Color.WHITE);
|
|
||||||
* table.getTableHeader().setFont(new Font("Rockwell", Font.PLAIN, 18));
|
|
||||||
* table.setBackground(new Color(17,17,17)); table.setForeground(Color.white);
|
|
||||||
* table.setSelectionBackground(Color.RED); table.setGridColor(new Color(102,
|
|
||||||
* 102, 102)); table.setSelectionForeground(Color.white); table.setFont(new
|
|
||||||
* Font("Rockwell", Font.PLAIN, 18)); table.setRowHeight(25);
|
|
||||||
* table.setLocation(700, 200); table.revalidate();
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @wbp.parser.entryPoint
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,7 @@ public class MakkahCity {
|
|||||||
districtData[i][6] = getShortestRoute(campPerDistrict[i].get(0), Mashier.MINA).getFastestTimeOfTravel(new Bus());
|
districtData[i][6] = getShortestRoute(campPerDistrict[i].get(0), Mashier.MINA).getFastestTimeOfTravel(new Bus());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//tables
|
//tables
|
||||||
|
|
||||||
@ -130,6 +131,7 @@ public class MakkahCity {
|
|||||||
|
|
||||||
//District table
|
//District table
|
||||||
districtTable = new JTable(districtData,districtColNames);
|
districtTable = new JTable(districtData,districtColNames);
|
||||||
|
districtTable.setEnabled(false);
|
||||||
districtTable.setForeground(new Color(255, 255, 255));
|
districtTable.setForeground(new Color(255, 255, 255));
|
||||||
districtTable.getTableHeader().setFont(new Font("Rockwell", Font.PLAIN, 18));
|
districtTable.getTableHeader().setFont(new Font("Rockwell", Font.PLAIN, 18));
|
||||||
districtTable.getTableHeader().setBackground(new Color(17,17,17));
|
districtTable.getTableHeader().setBackground(new Color(17,17,17));
|
||||||
@ -141,6 +143,7 @@ public class MakkahCity {
|
|||||||
districtTable.setFont(new Font("Rockwell", Font.PLAIN, 18));
|
districtTable.setFont(new Font("Rockwell", Font.PLAIN, 18));
|
||||||
districtTable.setGridColor(new Color(102, 102, 102));
|
districtTable.setGridColor(new Color(102, 102, 102));
|
||||||
JScrollPane districtScroll = new JScrollPane(districtTable);
|
JScrollPane districtScroll = new JScrollPane(districtTable);
|
||||||
|
districtScroll.setEnabled(false);
|
||||||
districtTable.setAutoCreateRowSorter(true);
|
districtTable.setAutoCreateRowSorter(true);
|
||||||
districtTable.setRowHeight(25);
|
districtTable.setRowHeight(25);
|
||||||
districtTable.revalidate();
|
districtTable.revalidate();
|
||||||
@ -156,16 +159,15 @@ public class MakkahCity {
|
|||||||
EventControll t = new EventControll();
|
EventControll t = new EventControll();
|
||||||
t.setData(stdRoutes[0]);
|
t.setData(stdRoutes[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
JButton btnViewBuses = new JButton("View Buses");
|
JButton btnViewBuses = new JButton("View Buses");
|
||||||
btnViewBuses.setBounds(1307, 76, 166, 29);
|
btnViewBuses.setBounds(1307, 76, 166, 29);
|
||||||
btnViewBuses.setFont(new Font("Rockwell", Font.PLAIN, 16));
|
btnViewBuses.setFont(new Font("Rockwell", Font.PLAIN, 16));
|
||||||
btnViewBuses.setBackground(new Color(9,9,9));
|
btnViewBuses.setBackground(new Color(9,9,9));
|
||||||
btnViewBuses.setForeground(Color.white);
|
btnViewBuses.setForeground(Color.white);
|
||||||
btnViewBuses.addActionListener(e -> {
|
// btnViewBuses.addActionListener(e -> {
|
||||||
GUI_ViewBuses t = new GUI_ViewBuses();
|
// GUI_ViewBuses t = new GUI_ViewBuses();
|
||||||
t.setData(listOfCampaigns);
|
// t.setData(listOfCampaigns);
|
||||||
});
|
// });
|
||||||
|
|
||||||
JButton btnViewCampaigns = new JButton("View Campaigns");
|
JButton btnViewCampaigns = new JButton("View Campaigns");
|
||||||
btnViewCampaigns.setBounds(1307, 119, 166, 29);
|
btnViewCampaigns.setBounds(1307, 119, 166, 29);
|
||||||
|
Loading…
Reference in New Issue
Block a user