package graphmatcher.gui;
import graphmatcher.graph.Graph;
import graphmatcher.matcher.AbstractMatcher;
import graphmatcher.matcher.MatcherFactory;
import graphmatcher.matcher.MatchingResult;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
public class GraphMatcherFrame extends JFrame {
private InputPanel _inputPanel;
private JButton matchButton;
private MatchingOptionPanel optionPanel;
private MatchingResultPanel resultPanel;
// private MatrixColorPanel _matrixPanel;
private MatchingPanel _matchingPanel;
private MatchingPanelOptionPanel _guiOptionPanel;
public GraphMatcherFrame() {
setLayout(new BorderLayout());
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
_inputPanel = new InputPanel();
add(_inputPanel, BorderLayout.NORTH);
JPanel westPanel = new JPanel(new BorderLayout());
optionPanel = new MatchingOptionPanel();
matchButton = new JButton("MATCH");
resultPanel = new MatchingResultPanel();
westPanel.add(optionPanel, BorderLayout.NORTH);
westPanel.add(matchButton, BorderLayout.CENTER);
westPanel.add(resultPanel, BorderLayout.SOUTH);
add(westPanel, BorderLayout.WEST);
_matchingPanel = new MatchingPanel();
add(_matchingPanel, BorderLayout.CENTER);
_guiOptionPanel = new MatchingPanelOptionPanel();
_guiOptionPanel.setMatchingPanel(_matchingPanel);
add(_guiOptionPanel, BorderLayout.SOUTH);
initActions();
pack();
}
private void initActions() {
matchButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Graph pattern = _inputPanel.getPatternGraph();
// AffineTransform at = new AffineTransform();
// at.rotate(Math.toRadians(180));
// GraphTools.transformGraph(pattern, at);
Graph template = _inputPanel.getTemplateGraph();
String matcherID = optionPanel.getSelectedMatcherID();
AbstractMatcher matcher = MatcherFactory.createMatcher(matcherID, pattern, template);
MatchingResult matchingResult = matcher.match(optionPanel.getMatchingOptions());
_matchingPanel.setOptions(_guiOptionPanel.showMatchingEdges(), _guiOptionPanel.showIndices(),
_guiOptionPanel.showTransformedPattern());
_matchingPanel.setMatchingResult(matchingResult);
resultPanel.setMatchingResult(matchingResult);
}
});
}
}