ProjektGraph/OurApplication/OurParameterArea.java

116 lines
2.7 KiB
Java
Raw Normal View History

2024-07-02 19:13:30 +00:00
package OurApplication;
import graph.DirectedGraph;
import graph.EdgeMarking;
import graph.ExampleGraphs;
import graph.VertexMarking;
2024-07-02 19:13:30 +00:00
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.
2024-07-02 19:13:30 +00:00
* @see ParameterArea
* @author MSch<EFBFBD>fer
* DHBW Stuttgart/Campus Horb AI2008<br>
* <br>
*/
2024-07-02 19:13:30 +00:00
public class OurParameterArea extends ParameterArea{
private static final long serialVersionUID = 1L;
private JRadioButton button1;
private JRadioButton button2;
private JRadioButton button3;
private JRadioButton button4;
private ExampleGraphs temp;
private int selectedExample;
/** TextField containing maximum sum up value. */
protected JTextField maxValue;
/**
* Standard constructor.
* Creates SumUpParameterArea with an empty JTextField.
*/
2024-07-02 19:13:30 +00:00
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");
// 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);
// 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;
}
});
// Buttons zum Panel hinzufügen
add(button1);
add(button2);
add(button3);
add(button4);
}
public DirectedGraph<VertexMarking, EdgeMarking> getSelectedGraph() {
ExampleGraphs temp = new ExampleGraphs();
switch (selectedExample) {
case 2:
return temp.example2();
case 3:
return temp.example3();
case 4:
return temp.example4();
case 1:
default:
return temp.example1();
}
2024-07-02 22:46:21 +00:00
}
}