Package graphmatcher.gui

Source Code of graphmatcher.gui.InputPanel

package graphmatcher.gui;

import graphmatcher.graph.Graph;
import graphmatcher.helper.GraphLoader;

import java.awt.Color;
import java.awt.GridLayout;
import java.util.Vector;

import javax.swing.BorderFactory;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

public class InputPanel extends JPanel {
  private GraphListPanel patternListPanel, templateListPanel;
  private GraphPanel patternGraphPanel, templateGraphPanel;

  public InputPanel() {
    setLayout(new GridLayout(1, 4));
    setBorder(BorderFactory.createTitledBorder("Graphen"));
    patternListPanel = new GraphListPanel("Pattern");
    add(patternListPanel);
    patternGraphPanel = new GraphPanel(Color.BLACK, Color.RED);
    add(patternGraphPanel);

    templateGraphPanel = new GraphPanel(Color.BLACK, Color.GREEN);
    add(templateGraphPanel);
    templateListPanel = new GraphListPanel("Template");
    add(templateListPanel);

    initListeners();

    Vector<Graph> patternGraphs = new Vector<Graph>();
    patternGraphs.add(GraphLoader.loadGraph("4e", "4e06c"));
    patternGraphs.add(GraphLoader.loadGraph("9e", "9e12c"));
    patternGraphs.add(GraphLoader.loadGraph("9e", "9e00c"));
    patternGraphs.add(GraphLoader.loadGraph("4f", "4f00c"));
    patternGraphs.add(GraphLoader.loadGraph("9e", "9e06s"));
    patternGraphs.add(GraphLoader.loadGraph("9e", "9e09c"));
    patternGraphs.add(GraphLoader.loadGraph("9e", "9e09s"));
    patternGraphs.add(GraphLoader.loadGraph("9e", "9e06c"));
    patternGraphs.add(GraphLoader.loadGraph("9e", "9e04c"));
    patternGraphs.add(GraphLoader.loadGraph("4f", "4f03s"));
    patternGraphs.add(GraphLoader.loadGraph("4e", "4effs"));
    patternGraphs.add(GraphLoader.loadGraph("4e", "4ef1c"));
    patternGraphs.add(GraphLoader.loadGraph("9f", "9fa5s"));
    // patternGraphs.add(GraphLoader.loadGraph("61", "6100c"));
    // patternGraphs.add(GraphLoader.loadGraph("80", "80ffs"));
    patternListPanel.setInitialData(patternGraphs);

    Vector<Graph> templateGraphs = new Vector<Graph>();
    templateGraphs.add(GraphLoader.loadGraph("4e", "4ebbs"));
    templateGraphs.add(GraphLoader.loadGraph("9e", "9e12s"));
    templateGraphs.add(GraphLoader.loadGraph("9e", "9e00s"));
    templateGraphs.add(GraphLoader.loadGraph("9e", "9e18s"));
    templateGraphs.add(GraphLoader.loadGraph("4f", "4f00t"));
    templateGraphs.add(GraphLoader.loadGraph("9e", "9e15s"));
    templateGraphs.add(GraphLoader.loadGraph("9e", "9e06c"));
    templateGraphs.add(GraphLoader.loadGraph("9e", "9e09s"));
    templateGraphs.add(GraphLoader.loadGraph("9e", "9e09c"));
    templateGraphs.add(GraphLoader.loadGraph("9e", "9e04c"));
    templateGraphs.add(GraphLoader.loadGraph("9e", "9e04s"));
    templateGraphs.add(GraphLoader.loadGraph("4f", "4f03c"));
    templateGraphs.add(GraphLoader.loadGraph("4e", "4effc"));
    templateGraphs.add(GraphLoader.loadGraph("4e", "4ef1s"));
    templateGraphs.add(GraphLoader.loadGraph("9f", "9fa5c"));
    // templateGraphs.add(GraphLoader.loadGraph("61", "6100g"));
    // templateGraphs.add(GraphLoader.loadGraph("80", "80ffc"));
    templateListPanel.setInitialData(templateGraphs);
  }

  public void initListeners() {
    patternListPanel.addListSelectionListener(new ListSelectionListener() {
      public void valueChanged(ListSelectionEvent e) {
        JList list = (JList) e.getSource();
        Graph graph = (Graph) list.getSelectedValue();
        patternGraphPanel.setGraph(graph);
      }
    });

    templateListPanel.addListSelectionListener(new ListSelectionListener() {
      public void valueChanged(ListSelectionEvent e) {
        JList list = (JList) e.getSource();
        Graph graph = (Graph) list.getSelectedValue();
        templateGraphPanel.setGraph(graph);
      }
    });
  }

  public Graph getTemplateGraph() {
    return templateGraphPanel.getGraph();
  }

  public Graph getPatternGraph() {
    return patternGraphPanel.getGraph();
  }
}
TOP

Related Classes of graphmatcher.gui.InputPanel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.