Added and/or buttons
This commit is contained in:
@@ -27,7 +27,8 @@ public class InputPanel extends JPanel {
|
|||||||
|
|
||||||
private InputPanel()
|
private InputPanel()
|
||||||
{
|
{
|
||||||
super(new BorderLayout());
|
super();
|
||||||
|
this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
|
||||||
|
|
||||||
JPanel topPanel = new JPanel();
|
JPanel topPanel = new JPanel();
|
||||||
topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.LINE_AXIS));
|
topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.LINE_AXIS));
|
||||||
@@ -81,7 +82,7 @@ public class InputPanel extends JPanel {
|
|||||||
topPanel.add(button);
|
topPanel.add(button);
|
||||||
|
|
||||||
topPanel.add(Box.createHorizontalGlue());
|
topPanel.add(Box.createHorizontalGlue());
|
||||||
this.add(topPanel, BorderLayout.NORTH);
|
this.add(topPanel);
|
||||||
|
|
||||||
|
|
||||||
//------------
|
//------------
|
||||||
@@ -160,7 +161,178 @@ public class InputPanel extends JPanel {
|
|||||||
|
|
||||||
bottomPanel.add(fileButton);
|
bottomPanel.add(fileButton);
|
||||||
|
|
||||||
this.add(bottomPanel, BorderLayout.SOUTH);
|
this.add(bottomPanel);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//------------
|
||||||
|
//Advanced PANEL
|
||||||
|
//-----------
|
||||||
|
|
||||||
|
JPanel advPanel = new JPanel();
|
||||||
|
advPanel.setLayout(new BoxLayout(advPanel, BoxLayout.LINE_AXIS));
|
||||||
|
advPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
|
||||||
|
|
||||||
|
JComboBox<String> f1Combo = new JComboBox<String>(findFiles());
|
||||||
|
JComboBox<String> f2Combo = new JComboBox<String>(findFiles());
|
||||||
|
|
||||||
|
JButton orButton = new JButton("or");
|
||||||
|
orButton.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
|
BackgroundWorker.instance().addWorker(new BackgroundWorker.Worker() {
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
StatusPanel.Instance().setStatus("Parsing files", 10);
|
||||||
|
|
||||||
|
String file1 = (String)f1Combo.getSelectedItem();
|
||||||
|
String name1 = file1.replaceAll(".dot", "");
|
||||||
|
String file2 = (String)f2Combo.getSelectedItem();
|
||||||
|
String name2 = file2.replaceAll(".dot", "");
|
||||||
|
|
||||||
|
Importable p1 = FileParser.read(file1);
|
||||||
|
Importable p2 = FileParser.read(file1);
|
||||||
|
|
||||||
|
DFA<String> dfa1 = null;
|
||||||
|
|
||||||
|
if(p1.type == Importable.Type.NDFA)
|
||||||
|
{
|
||||||
|
StatusPanel.Instance().setStatus("Converting NDFA to DFA", 30);
|
||||||
|
NDFA<String> ndfa1 = (NDFA<String>)p1;
|
||||||
|
dfa1 = ndfa1.toDFA().minimaliseerHopcroft();
|
||||||
|
}
|
||||||
|
if(p1.type == Importable.Type.DFA)
|
||||||
|
{
|
||||||
|
dfa1 = (DFA<String>)p1;
|
||||||
|
}
|
||||||
|
if(p1.type == Importable.Type.REGEX)
|
||||||
|
{
|
||||||
|
StatusPanel.Instance().setStatus("Converting REGEX to DFA", 30);
|
||||||
|
RegExp regex = (RegExp) p1;
|
||||||
|
NDFA<String> ndfa1 = ThompsonConverter.convert(regex);
|
||||||
|
dfa1 = ndfa1.toDFA().minimaliseerHopcroft();
|
||||||
|
}
|
||||||
|
|
||||||
|
DFA<String> dfa2 = null;
|
||||||
|
|
||||||
|
if(p2.type == Importable.Type.NDFA)
|
||||||
|
{
|
||||||
|
StatusPanel.Instance().setStatus("Converting NDFA to DFA", 50);
|
||||||
|
NDFA<String> ndfa2 = (NDFA<String>)p2;
|
||||||
|
dfa2 = ndfa2.toDFA().minimaliseerHopcroft();
|
||||||
|
}
|
||||||
|
if(p2.type == Importable.Type.DFA)
|
||||||
|
{
|
||||||
|
dfa2 = (DFA<String>)p2;
|
||||||
|
}
|
||||||
|
if(p2.type == Importable.Type.REGEX)
|
||||||
|
{
|
||||||
|
StatusPanel.Instance().setStatus("Converting REGEX to DFA", 50);
|
||||||
|
RegExp regex2 = (RegExp) p2;
|
||||||
|
NDFA<String> ndfa2 = ThompsonConverter.convert(regex2);
|
||||||
|
dfa2 = ndfa2.toDFA().minimaliseerHopcroft();
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusPanel.Instance().setStatus("Executing or operation", 65);
|
||||||
|
DFA<String> of = dfa1.of(dfa2);
|
||||||
|
|
||||||
|
StatusPanel.Instance().setStatus("Generating image", 80);
|
||||||
|
|
||||||
|
File f = Graph.generateImage(of);
|
||||||
|
TabPanel.Instance().addGraph(name1 + " or " + name2, f, of);
|
||||||
|
|
||||||
|
StatusPanel.Instance().setStatus("Done", 100);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
JButton andButton = new JButton("and");
|
||||||
|
andButton.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
|
BackgroundWorker.instance().addWorker(new BackgroundWorker.Worker() {
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
StatusPanel.Instance().setStatus("Parsing files", 10);
|
||||||
|
|
||||||
|
String file1 = (String)f1Combo.getSelectedItem();
|
||||||
|
String name1 = file1.replaceAll(".dot", "");
|
||||||
|
String file2 = (String)f2Combo.getSelectedItem();
|
||||||
|
String name2 = file2.replaceAll(".dot", "");
|
||||||
|
|
||||||
|
Importable p1 = FileParser.read(file1);
|
||||||
|
Importable p2 = FileParser.read(file1);
|
||||||
|
|
||||||
|
DFA<String> dfa1 = null;
|
||||||
|
|
||||||
|
if(p1.type == Importable.Type.NDFA)
|
||||||
|
{
|
||||||
|
StatusPanel.Instance().setStatus("Converting NDFA to DFA", 30);
|
||||||
|
NDFA<String> ndfa1 = (NDFA<String>)p1;
|
||||||
|
dfa1 = ndfa1.toDFA().minimaliseerHopcroft();
|
||||||
|
}
|
||||||
|
if(p1.type == Importable.Type.DFA)
|
||||||
|
{
|
||||||
|
dfa1 = (DFA<String>)p1;
|
||||||
|
}
|
||||||
|
if(p1.type == Importable.Type.REGEX)
|
||||||
|
{
|
||||||
|
StatusPanel.Instance().setStatus("Converting REGEX to DFA", 30);
|
||||||
|
RegExp regex = (RegExp) p1;
|
||||||
|
NDFA<String> ndfa1 = ThompsonConverter.convert(regex);
|
||||||
|
dfa1 = ndfa1.toDFA().minimaliseerHopcroft();
|
||||||
|
}
|
||||||
|
|
||||||
|
DFA<String> dfa2 = null;
|
||||||
|
|
||||||
|
if(p2.type == Importable.Type.NDFA)
|
||||||
|
{
|
||||||
|
StatusPanel.Instance().setStatus("Converting NDFA to DFA", 50);
|
||||||
|
NDFA<String> ndfa2 = (NDFA<String>)p2;
|
||||||
|
dfa2 = ndfa2.toDFA().minimaliseerHopcroft();
|
||||||
|
}
|
||||||
|
if(p2.type == Importable.Type.DFA)
|
||||||
|
{
|
||||||
|
dfa2 = (DFA<String>)p2;
|
||||||
|
}
|
||||||
|
if(p2.type == Importable.Type.REGEX)
|
||||||
|
{
|
||||||
|
StatusPanel.Instance().setStatus("Converting REGEX to DFA", 50);
|
||||||
|
RegExp regex2 = (RegExp) p2;
|
||||||
|
NDFA<String> ndfa2 = ThompsonConverter.convert(regex2);
|
||||||
|
dfa2 = ndfa2.toDFA().minimaliseerHopcroft();
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusPanel.Instance().setStatus("Executing and operation", 65);
|
||||||
|
DFA<String> en = dfa1.en(dfa2);
|
||||||
|
|
||||||
|
StatusPanel.Instance().setStatus("Generating image", 80);
|
||||||
|
|
||||||
|
File f = Graph.generateImage(en);
|
||||||
|
TabPanel.Instance().addGraph(name1 + " and " + name2, f, en);
|
||||||
|
|
||||||
|
StatusPanel.Instance().setStatus("Done", 100);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
advPanel.add(f1Combo);
|
||||||
|
advPanel.add(Box.createRigidArea(new Dimension(10, 0)));
|
||||||
|
|
||||||
|
advPanel.add(andButton);
|
||||||
|
advPanel.add(Box.createRigidArea(new Dimension(10, 0)));
|
||||||
|
advPanel.add(orButton);
|
||||||
|
advPanel.add(Box.createRigidArea(new Dimension(10, 0)));
|
||||||
|
|
||||||
|
advPanel.add(f2Combo);
|
||||||
|
advPanel.add(Box.createRigidArea(new Dimension(10, 0)));
|
||||||
|
|
||||||
|
this.add(advPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] findFiles()
|
private String[] findFiles()
|
||||||
|
|||||||
Reference in New Issue
Block a user