-
Notifications
You must be signed in to change notification settings - Fork 0
/
GUI.java
153 lines (148 loc) · 4.59 KB
/
GUI.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/**
*@file GUI.java
*This file contains class to initiate GUI making
*@author Abhinav Khattar 2015120
*@author Tushar Arora 2015107
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.text.*;
import javax.swing.border.Border;
import javax.swing.table.DefaultTableModel;
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
/**Contains the base GUI class that loads the frame, also contains the projects main*/
public class GUI
{
private JFrame mainFrame;
private JPanel upperPanel;
private JPanel sidePanel;
private JPanel displayPanel;
private JComboBox<String> queries;
private JButton submit,reset;
private GUIQuery g;
private GUIFactory gFactory;
private QueryFacade q0= new QueryFacade();
private int flag=0,flag2=0,tableWorking=0,pages=0;
public GUI()
{
runFrame();
initframe();
}
public void runFrame()
{
mainFrame=new JFrame("DBLP query engine");
submit=new JButton("Submit");
reset=new JButton("Reset");
sidePanel=new JPanel();
queries = new JComboBox<String>();
displayPanel=new JPanel();
queries.addItem("Queries");
queries.addItem("Query 1");
queries.addItem("Query 2");
queries.addItem("Query 3");
mainFrame.setSize(1200,520);
mainFrame.setLocation(0,0);
mainFrame.setResizable(false);
mainFrame.setLayout(null);
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
submit.setBackground(Color.BLACK);
reset.setBackground(Color.RED);
sidePanel.setPreferredSize(new Dimension(250,440));
sidePanel.setMinimumSize(new Dimension(250,440));
sidePanel.setMaximumSize(new Dimension(250,440));
sidePanel.setLocation(0,80);
sidePanel.setLayout(null);
sidePanel.setBorder(BorderFactory.createLineBorder(Color.black,2));
sidePanel.setBackground(Color.WHITE);
displayPanel.setPreferredSize(new Dimension(950,440));
displayPanel.setMinimumSize(new Dimension(950,440));
displayPanel.setMaximumSize(new Dimension(950,440));
displayPanel.setLocation(250,80);
displayPanel.setLayout(null);
displayPanel.setBorder(BorderFactory.createLineBorder(Color.black,2));
displayPanel.setBackground(Color.WHITE);
upperPanel=new JPanel();
upperPanel.setSize(new Dimension(1200,80));
upperPanel.setMinimumSize(new Dimension(1200,80));
upperPanel.setMaximumSize(new Dimension(1200,80));
upperPanel.setLocation(0,0);
upperPanel.setLayout(null);
}
public void initframe()
{
sidePanel.add(queries);
queries.setBounds(50,100,100,20);
queries.setAlignmentX(Component.CENTER_ALIGNMENT);
JLabel random = new JLabel("Results Here");
random.setBounds(150,100,150,40);
displayPanel.add(random);
JLabel header=new JLabel("<html><b>DBLP Query Engine</b></html>",JLabel.CENTER);
header.setFont(new Font("Calibri", Font.PLAIN, 45));
header.setBounds(350,10,500,60);
header.setAlignmentX(Component.CENTER_ALIGNMENT);
upperPanel.add(header);
upperPanel.setBorder(BorderFactory.createLineBorder(Color.black,2));
upperPanel.setBackground(Color.WHITE);
sidePanel.setVisible(true);
upperPanel.setVisible(true);
displayPanel.setVisible(true);
sidePanel.setBounds(0,80,250,440);
upperPanel.setBounds(0,0,1200,80);
displayPanel.setBounds(250,80,950,440);
mainFrame.add(sidePanel);
mainFrame.add(upperPanel);
mainFrame.add(displayPanel);
mainFrame.setVisible(true);
gFactory = new GUIFactory(mainFrame,queries,sidePanel,displayPanel,q0);
queries.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
JComboBox<? extends Object> q = (JComboBox<? extends Object>) event.getSource();
String selectedQuery = (String) q.getSelectedItem();
if (selectedQuery.equals("Query 1")) {
g=gFactory.getQuery("Query1");
g.start();
} else if (selectedQuery.equals("Query 2")) {
g=gFactory.getQuery("Query2");
g.start();
} else if(selectedQuery.equals("Query 3")) {
g=gFactory.getQuery("Query3");
g.start();
}
}
});
}
public static void main(String[] args)
{
System.setProperty("jdk.xml.entityExpansionLimit", "0");
AuthorManager.addFile("dblp.xml");
GuiLoading gl = new GuiLoading();
gl.start();
AuthorManager.createMap();
gl.stop();
GUI a = new GUI();
}
public void change(int i)
{
flag=i;
}
public void changeMode(int i)
{
flag2=i;
}
public static boolean isInteger(String s) {
boolean isValidInteger = false;
try
{
Integer.parseInt(s);
isValidInteger = true;
}
catch (NumberFormatException ex)
{}
return isValidInteger;
}
}