package OurApplication; import graph.DirectedGraph; import graph.EdgeMarking; import graph.ExampleGraphs; import graph.VertexMarking; import visualisation.ParameterArea; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; /** * This class provides an example for using visualization.ParameterArea. * @see ParameterArea * @author MSch�fer * DHBW Stuttgart/Campus Horb AI2008
*
*/ public class OurParameterArea extends ParameterArea{ private static final long serialVersionUID = 1L; private JRadioButton button1; private JRadioButton button2; private JRadioButton button3; private JRadioButton button4; private JRadioButton button5; private ExampleGraphs temp; private int selectedExample; /** TextField containing maximum sum up value. */ protected JTextField maxValue; /** * Standard constructor. * Creates SumUpParameterArea with an empty JTextField. */ public OurParameterArea() { super(); temp = new ExampleGraphs(); selectedExample = 1; // Standardmäßig Beispiel 1 setBorder(BorderFactory.createTitledBorder("ParameterArea")); // Layout-Manager setzen, um die Buttons vertikal anzuordnen setLayout(new GridLayout(4, 1, 5, 5)); // 4 Zeilen, 1 Spalte, 5 Pixel Abstand // Buttons erstellen button1 = new JRadioButton("Beispiel 1", true); button2 = new JRadioButton("Beispiel 2"); button3 = new JRadioButton("Beispiel 3"); button4 = new JRadioButton("Beispiel 4"); button5 = new JRadioButton("Eigener Graph"); // ButtonGroup erstellen und Buttons hinzufügen, um die gegenseitige Ausschließung zu gewährleisten ButtonGroup group = new ButtonGroup(); group.add(button1); group.add(button2); group.add(button3); group.add(button4); group.add(button5); // ActionListener hinzufügen button1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectedExample = 1; } }); button2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectedExample = 2; } }); button3.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectedExample = 3; } }); button4.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectedExample = 4; } }); button5.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectedExample = 5; } }); // Buttons zum Panel hinzufügen add(button1); add(button2); add(button3); add(button4); add(button5); } public DirectedGraph getSelectedGraph() { ExampleGraphs temp = new ExampleGraphs(); switch (selectedExample) { case 2: return temp.example2(); case 3: return temp.example3(); case 4: return temp.example4(); case 5: return new DirectedGraph<>(); case 1: default: return temp.example1(); } } }