00001
00008 package VisuBDD;
00009
00010 import java.awt.*;
00011 import java.awt.event.*;
00012 import java.util.*;
00013
00014
00015 public class ControlDialog extends Dialog {
00016
00017 private VisualizeFrame mainFrame;
00018 private Panel controlPanel, buttonPanel, buttonPanel2, lineDistancePanel;
00019 private TextField maxRange;
00020 private CheckboxGroup group;
00021 private Checkbox val1, val2, val3, xorBox;
00022
00029 public ControlDialog(Frame mainWindow) {
00030 super(mainWindow);
00031
00032 Label maxValLabel, distanceLabel;
00033 Button startButton;
00034
00035 this.mainFrame = (VisualizeFrame) mainWindow;
00036
00037 maxValLabel = new Label("Maximum BDD Width");
00038 maxRange = new TextField(10);
00039 group = new CheckboxGroup();
00040
00041 distanceLabel = new Label("Vertical Stretching");
00042 val1 = new Checkbox("1", false, group);
00043 val2 = new Checkbox("2", true, group);
00044 val3 = new Checkbox("3", false, group);
00045
00046
00047 xorBox = new Checkbox("Combine Colors", false);
00048
00049 startButton = new Button("Repaint");
00050 startButton.addActionListener(new ActionListener() {
00051 public void actionPerformed(ActionEvent event) {
00052
00053 try {
00054 mainFrame.setMaxBddWidth(Double.parseDouble(maxRange.getText()));
00055 } catch (NumberFormatException e1) {
00056 System.out.println("\nYou have to type only double values into the"
00057 + " textfield.");
00058 }
00059
00060 mainFrame.setDistance(checkDistanceValue());
00061 mainFrame.setXorMode(xorBox.getState());
00062 mainFrame.repaint();
00063 }
00064 } );
00065
00066 controlPanel = new Panel(new FlowLayout());
00067 controlPanel.add(maxValLabel);
00068 controlPanel.add(maxRange);
00069
00070 buttonPanel = new Panel(new FlowLayout());
00071 buttonPanel.add(xorBox);
00072
00073 buttonPanel2 = new Panel(new FlowLayout());
00074 buttonPanel2.add(startButton);
00075
00076 lineDistancePanel = new Panel(new FlowLayout());
00077 lineDistancePanel.add(distanceLabel);
00078 lineDistancePanel.add(val1);
00079 lineDistancePanel.add(val2);
00080 lineDistancePanel.add(val3);
00081
00082 setLayout(new GridLayout(0,1));
00083 add(controlPanel);
00084 add(lineDistancePanel);
00085 add(buttonPanel);
00086 add(buttonPanel2);
00087
00088
00089 setResizable(false);
00090
00091 setTitle("Preferences");
00092 setLocation(50, 100);
00093
00094 pack();
00095
00096
00097 addWindowListener(
00098 new WindowAdapter() {
00099 public void windowClosing(WindowEvent evt) {
00100 dispose();
00101 }
00102 }
00103 );
00104
00105 }
00106
00107 private int checkDistanceValue() {
00108 int result = 0;
00109
00110 if (val1.getState()) {
00111 result = 1;
00112 } else if (val2.getState()) {
00113 result = 2;
00114 } else if (val3.getState()) {
00115 result = 3;
00116 } else {
00117 System.out.println("Runtime error in ControlDialog.checkDistance"
00118 + "Value()");
00119 System.out.println(" There is a selection error in the checkbox"
00120 + " group.");
00121 }
00122 return result;
00123 }
00124
00125 public void setMaxBDDWidth(double value) {
00126 maxRange.setText(String.valueOf(value));
00127 }
00128
00129 }