/*
* FuzzyTesterView.java
*/
package fuzzytester;
import Fuzzy.FuzzyConfig;
import it.polito.appeal.traci.Lane;
import it.polito.appeal.traci.LightState;
import it.polito.appeal.traci.Link;
import it.polito.appeal.traci.MeMeDetector;
import it.polito.appeal.traci.Repository;
import it.polito.appeal.traci.SumoTraciConnection;
import it.polito.appeal.traci.TLState;
import it.polito.appeal.traci.TrafficLight;
import it.polito.appeal.traci.ValueReadQuery;
import java.awt.Color;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.sourceforge.jFuzzyLogic.*;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.InetAddress;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Timer;
//import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.filechooser.FileNameExtensionFilter;
/**
* The application's main frame.
*/
public class FuzzyTesterView extends FrameView {
public FuzzyTesterView(SingleFrameApplication app) {
super(app);
initComponents();
this.sumoTimer = new Timer("timerSumo");
this.pauseSumo.setVisible(false);
// this.sumoTimer = new Timer(((Integer)this.simStep.getValue()).intValue(), new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// System.out.println("Time passes out");
// }
// });
this.RedFuzzyStatusLabel.setText("Fuzzy RedLight File");
redirectSystemStreams();
fuzzyConfig = new FuzzyConfig();
// status bar initialization - message timeout, idle icon and busy animation, etc
ResourceMap resourceMap = getResourceMap();
int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
messageTimer = new javax.swing.Timer(messageTimeout, new ActionListener() {
public void actionPerformed(ActionEvent e) {
statusMessageLabel.setText("");
}
});
messageTimer.setRepeats(false);
int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
for (int i = 0; i < busyIcons.length; i++) {
busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
}
busyIconTimer = new javax.swing.Timer(busyAnimationRate, new ActionListener() {
public void actionPerformed(ActionEvent e) {
busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
}
});
idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
statusAnimationLabel.setIcon(idleIcon);
progressBar.setVisible(false);
// connecting action tasks to status bar via TaskMonitor
TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
public void propertyChange(java.beans.PropertyChangeEvent evt) {
String propertyName = evt.getPropertyName();
if ("started".equals(propertyName)) {
if (!busyIconTimer.isRunning()) {
statusAnimationLabel.setIcon(busyIcons[0]);
busyIconIndex = 0;
busyIconTimer.start();
}
progressBar.setVisible(true);
progressBar.setIndeterminate(true);
} else if ("done".equals(propertyName)) {
busyIconTimer.stop();
statusAnimationLabel.setIcon(idleIcon);
progressBar.setVisible(false);
progressBar.setValue(0);
} else if ("message".equals(propertyName)) {
String text = (String)(evt.getNewValue());
statusMessageLabel.setText((text == null) ? "" : text);
messageTimer.restart();
} else if ("progress".equals(propertyName)) {
int value = (Integer)(evt.getNewValue());
progressBar.setVisible(true);
progressBar.setIndeterminate(false);
progressBar.setValue(value);
}
}
});
this.sliderDL.setMaximum(100);
this.sliderDL.setMinimum(0);
this.sliderStan.setMaximum(100);
this.sliderStan.setMinimum(0);
this.sliderTime.setMinimum(0);
this.sliderTime.setValue(10);
this.sliderTime.setMaximum(60);
this.wynik.setText("policz;)");
this.dlKolejki.setText(Integer.valueOf(sliderDL.getValue()).toString());
this.stanDrogi.setText(Integer.valueOf(sliderStan.getValue()).toString());
this.tRed.setText(Integer.valueOf(sliderTime.getValue()).toString());
this.gLdlKolekiSlider.setMinimum(0);
this.gLdlKolekiSlider.setValue(10);
this.gLdlKolekiSlider.setMaximum(100);
this.gLstanDrogiSlider.setMinimum(0);
this.gLstanDrogiSlider.setValue(10);
this.gLstanDrogiSlider.setMaximum(100);
this.gLDlKolejki.setText(Integer.valueOf(gLdlKolekiSlider.getValue()).toString());
this.gLStanDrogi.setText(Integer.valueOf(gLstanDrogiSlider.getValue()).toString());
// String fileName = "fuzzy.txt";
// this.fis = FIS.load(fileName,true);
// // Error while loading?
// if( fis == null ) {
// this.policz.setEnabled(false);
// this.policz.setText("Błąd");
//
// }
//this.fis.chart();
}
@Action
public void showAboutBox() {
if (aboutBox == null) {
JFrame mainFrame = FuzzyTesterApp.getApplication().getMainFrame();
aboutBox = new FuzzyTesterAboutBox(mainFrame);
aboutBox.setLocationRelativeTo(mainFrame);
}
FuzzyTesterApp.getApplication().show(aboutBox);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
mainPanel = new javax.swing.JPanel();
jSlider1 = new javax.swing.JSlider();
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
simStep = new javax.swing.JSpinner();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
sumoPathlabel = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
sumoConfigLabel = new javax.swing.JLabel();
startSumo = new javax.swing.JButton();
pauseSumo = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
RedFuzzyStatusLabel = new javax.swing.JLabel();
GreenFuzzyStatusLabel = new javax.swing.JLabel();
RedLightStatus = new javax.swing.JLabel();
GreenLightStatus = new javax.swing.JLabel();
showRLchart = new javax.swing.JCheckBox();
showGLchart = new javax.swing.JCheckBox();
jPanel4 = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
gLDlKolejki = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
gLStanDrogi = new javax.swing.JTextField();
gLdlKolekiSlider = new javax.swing.JSlider();
gLstanDrogiSlider = new javax.swing.JSlider();
gLWynik = new javax.swing.JTextField();
jLabel9 = new javax.swing.JLabel();
gLPolicz = new javax.swing.JButton();
wykresGlwynik = new javax.swing.JCheckBox();
jPanel3 = new javax.swing.JPanel();
sliderStan = new javax.swing.JSlider();
sliderTime = new javax.swing.JSlider();
sliderDL = new javax.swing.JSlider();
wynik = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
policz = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
stanDrogi = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
dlKolejki = new javax.swing.JTextField();
tRed = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
wykresWynikowyRLchecBox = new javax.swing.JCheckBox();
jScrollPane1 = new javax.swing.JScrollPane();
jLog = new javax.swing.JTextArea();
menuBar = new javax.swing.JMenuBar();
javax.swing.JMenu fileMenu = new javax.swing.JMenu();
javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
jMenu4 = new javax.swing.JMenu();
jMenuItem4 = new javax.swing.JMenuItem();
jMenuItem5 = new javax.swing.JMenuItem();
menuLogikaRozmyta = new javax.swing.JMenu();
oRedLightMenu = new javax.swing.JMenuItem();
oGreenLightMenu = new javax.swing.JMenuItem();
oLogikaZmianyMenu = new javax.swing.JMenuItem();
javax.swing.JMenu helpMenu = new javax.swing.JMenu();
javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
statusPanel = new javax.swing.JPanel();
javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
statusMessageLabel = new javax.swing.JLabel();
statusAnimationLabel = new javax.swing.JLabel();
progressBar = new javax.swing.JProgressBar();
jSlider2 = new javax.swing.JSlider();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenu2 = new javax.swing.JMenu();
mainPanel.setName("mainPanel"); // NOI18N
jSlider1.setName("jSlider1"); // NOI18N
jTabbedPane1.setName("jTabbedPane1"); // NOI18N
jPanel1.setName("jPanel1"); // NOI18N
simStep.setName("simStep"); // NOI18N
simStep.setValue(Integer.valueOf(10));
simStep.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
simStepStateChanged(evt);
}
});
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(fuzzytester.FuzzyTesterApp.class).getContext().getResourceMap(FuzzyTesterView.class);
jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
jLabel10.setName("jLabel10"); // NOI18N
jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
jLabel11.setName("jLabel11"); // NOI18N
sumoPathlabel.setForeground(resourceMap.getColor("sumoPathlabel.foreground")); // NOI18N
sumoPathlabel.setText(resourceMap.getString("sumoPathlabel.text")); // NOI18N
sumoPathlabel.setName("sumoPathlabel"); // NOI18N
jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
jLabel12.setName("jLabel12"); // NOI18N
sumoConfigLabel.setForeground(resourceMap.getColor("sumoConfigLabel.foreground")); // NOI18N
sumoConfigLabel.setText(resourceMap.getString("sumoConfigLabel.text")); // NOI18N
sumoConfigLabel.setName("sumoConfigLabel"); // NOI18N
startSumo.setText(resourceMap.getString("startSumo.text")); // NOI18N
startSumo.setEnabled(false);
startSumo.setName("startSumo"); // NOI18N
startSumo.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
startSumoMouseReleased(evt);
}
});
startSumo.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
startSumoStateChanged(evt);
}
});
pauseSumo.setText(resourceMap.getString("pauseSumo.text")); // NOI18N
pauseSumo.setName("pauseSumo"); // NOI18N
pauseSumo.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
pauseSumoMouseReleased(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(sumoPathlabel))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(sumoConfigLabel))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(startSumo)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(pauseSumo))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(simStep, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel10, javax.swing.GroupLayout.Alignment.LEADING)))
.addContainerGap(407, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel11)
.addComponent(sumoPathlabel))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel12)
.addComponent(sumoConfigLabel))
.addGap(13, 13, 13)
.addComponent(jLabel10)
.addGap(7, 7, 7)
.addComponent(simStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(startSumo)
.addComponent(pauseSumo))
.addContainerGap(112, Short.MAX_VALUE))
);
jTabbedPane1.addTab(resourceMap.getString("jPanel1.TabConstraints.tabTitle"), jPanel1); // NOI18N
jPanel2.setName("jPanel2"); // NOI18N
RedFuzzyStatusLabel.setText(resourceMap.getString("RedFuzzyStatusLabel.text")); // NOI18N
RedFuzzyStatusLabel.setName("RedFuzzyStatusLabel"); // NOI18N
GreenFuzzyStatusLabel.setText(resourceMap.getString("GreenFuzzyStatusLabel.text")); // NOI18N
GreenFuzzyStatusLabel.setName("GreenFuzzyStatusLabel"); // NOI18N
RedLightStatus.setText(resourceMap.getString("RedLightStatus.text")); // NOI18N
RedLightStatus.setName("RedLightStatus"); // NOI18N
GreenLightStatus.setText(resourceMap.getString("GreenLightStatus.text")); // NOI18N
GreenLightStatus.setName("GreenLightStatus"); // NOI18N
showRLchart.setText(resourceMap.getString("showRLchart.text")); // NOI18N
showRLchart.setEnabled(false);
showRLchart.setName("showRLchart"); // NOI18N
showRLchart.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
showRLchartMouseReleased(evt);
}
});
showGLchart.setText(resourceMap.getString("showGLchart.text")); // NOI18N
showGLchart.setEnabled(false);
showGLchart.setName("showGLchart"); // NOI18N
showGLchart.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
showGLchartMouseReleased(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(RedFuzzyStatusLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(RedLightStatus)
.addGap(36, 36, 36)
.addComponent(showRLchart))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(GreenFuzzyStatusLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(GreenLightStatus)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(showGLchart)))
.addContainerGap(333, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(RedFuzzyStatusLabel)
.addComponent(RedLightStatus)
.addComponent(showRLchart))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(GreenFuzzyStatusLabel)
.addComponent(GreenLightStatus))
.addComponent(showGLchart))
.addContainerGap(188, Short.MAX_VALUE))
);
jTabbedPane1.addTab(resourceMap.getString("jPanel2.TabConstraints.tabTitle"), jPanel2); // NOI18N
jPanel4.setName("jPanel4"); // NOI18N
jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
jLabel6.setName("jLabel6"); // NOI18N
jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
jLabel7.setName("jLabel7"); // NOI18N
gLDlKolejki.setEditable(false);
gLDlKolejki.setText(resourceMap.getString("gLDlKolejki.text")); // NOI18N
gLDlKolejki.setName("gLDlKolejki"); // NOI18N
jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
jLabel8.setName("jLabel8"); // NOI18N
gLStanDrogi.setEditable(false);
gLStanDrogi.setText(resourceMap.getString("gLStanDrogi.text")); // NOI18N
gLStanDrogi.setName("gLStanDrogi"); // NOI18N
gLdlKolekiSlider.setName("gLdlKolekiSlider"); // NOI18N
gLdlKolekiSlider.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
gLdlKolekiSliderStateChanged(evt);
}
});
gLstanDrogiSlider.setName("gLstanDrogiSlider"); // NOI18N
gLstanDrogiSlider.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
gLstanDrogiSliderStateChanged(evt);
}
});
gLWynik.setEditable(false);
gLWynik.setText(resourceMap.getString("gLWynik.text")); // NOI18N
gLWynik.setName("gLWynik"); // NOI18N
jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
jLabel9.setName("jLabel9"); // NOI18N
gLPolicz.setText(resourceMap.getString("gLPolicz.text")); // NOI18N
gLPolicz.setEnabled(false);
gLPolicz.setName("gLPolicz"); // NOI18N
gLPolicz.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
gLPoliczMouseReleased(evt);
}
});
wykresGlwynik.setText(resourceMap.getString("wykresGlwynik.text")); // NOI18N
wykresGlwynik.setName("wykresGlwynik"); // NOI18N
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel7)
.addComponent(jLabel8)
.addComponent(jLabel9))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel4Layout.createSequentialGroup()
.addGap(11, 11, 11)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(gLPolicz)
.addComponent(wykresGlwynik, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(gLStanDrogi, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 262, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(gLDlKolejki, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 262, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(21, 21, 21)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(gLstanDrogiSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(gLdlKolekiSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(gLWynik, javax.swing.GroupLayout.PREFERRED_SIZE, 262, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(67, Short.MAX_VALUE))
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(gLDlKolejki, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(gLdlKolekiSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(15, 15, 15)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(gLstanDrogiSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(gLStanDrogi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(gLWynik, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(wykresGlwynik)
.addGap(14, 14, 14)
.addComponent(gLPolicz)
.addContainerGap(48, Short.MAX_VALUE))
);
jTabbedPane1.addTab(resourceMap.getString("jPanel4.TabConstraints.tabTitle"), jPanel4); // NOI18N
jPanel3.setName("jPanel3"); // NOI18N
sliderStan.setName("sliderStan"); // NOI18N
sliderStan.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
sliderStanStateChanged(evt);
}
});
sliderTime.setName("sliderTime"); // NOI18N
sliderTime.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
sliderTimeStateChanged(evt);
}
});
sliderDL.setName("sliderDL"); // NOI18N
sliderDL.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
sliderDLStateChanged(evt);
}
});
wynik.setEditable(false);
wynik.setText(resourceMap.getString("wynik.text")); // NOI18N
wynik.setName("wynik"); // NOI18N
jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
jLabel5.setName("jLabel5"); // NOI18N
jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
jLabel1.setName("jLabel1"); // NOI18N
policz.setText(resourceMap.getString("policz.text")); // NOI18N
policz.setEnabled(false);
policz.setName("policz"); // NOI18N
policz.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
policzMouseClicked(evt);
}
});
jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
jLabel3.setName("jLabel3"); // NOI18N
stanDrogi.setEditable(false);
stanDrogi.setText(resourceMap.getString("stanDrogi.text")); // NOI18N
stanDrogi.setName("stanDrogi"); // NOI18N
jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
jLabel2.setName("jLabel2"); // NOI18N
dlKolejki.setEditable(false);
dlKolejki.setText(resourceMap.getString("dlKolejki.text")); // NOI18N
dlKolejki.setName("dlKolejki"); // NOI18N
tRed.setEditable(false);
tRed.setText(resourceMap.getString("tRed.text")); // NOI18N
tRed.setName("tRed"); // NOI18N
jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
jLabel4.setName("jLabel4"); // NOI18N
wykresWynikowyRLchecBox.setText(resourceMap.getString("wykresWynikowyRLchecBox.text")); // NOI18N
wykresWynikowyRLchecBox.setName("wykresWynikowyRLchecBox"); // NOI18N
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(82, 82, 82)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(wykresWynikowyRLchecBox, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 178, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(policz, javax.swing.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE))
.addGap(239, 239, 239))
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(16, 16, 16)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(21, 21, 21)
.addComponent(dlKolejki, javax.swing.GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(sliderDL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(jLabel5))
.addGap(18, 18, 18)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tRed, javax.swing.GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE)
.addComponent(stanDrogi, javax.swing.GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE)
.addComponent(wynik, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(sliderTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sliderStan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGap(16, 16, 16)))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addContainerGap(147, Short.MAX_VALUE)
.addComponent(wykresWynikowyRLchecBox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(policz)
.addGap(48, 48, 48))
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(sliderDL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(dlKolejki, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(stanDrogi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addComponent(sliderStan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4)
.addComponent(tRed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(9, 9, 9)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(wynik, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5)))
.addComponent(sliderTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(102, Short.MAX_VALUE)))
);
jTabbedPane1.addTab(resourceMap.getString("jPanel3.TabConstraints.tabTitle"), jPanel3); // NOI18N
jScrollPane1.setName("jScrollPane1"); // NOI18N
jLog.setBackground(resourceMap.getColor("jLog.background")); // NOI18N
jLog.setColumns(20);
jLog.setEditable(false);
jLog.setFont(resourceMap.getFont("jLog.font")); // NOI18N
jLog.setForeground(resourceMap.getColor("jLog.foreground")); // NOI18N
jLog.setRows(5);
jLog.setName("jLog"); // NOI18N
jScrollPane1.setViewportView(jLog);
javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
mainPanel.setLayout(mainPanelLayout);
mainPanelLayout.setHorizontalGroup(
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 652, Short.MAX_VALUE)
.addGroup(mainPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 632, Short.MAX_VALUE)
.addContainerGap())
);
mainPanelLayout.setVerticalGroup(
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(mainPanelLayout.createSequentialGroup()
.addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 268, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)
.addContainerGap())
);
menuBar.setName("menuBar"); // NOI18N
fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
fileMenu.setName("fileMenu"); // NOI18N
javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(fuzzytester.FuzzyTesterApp.class).getContext().getActionMap(FuzzyTesterView.class, this);
exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
exitMenuItem.setText(resourceMap.getString("exitMenuItem.text")); // NOI18N
exitMenuItem.setName("exitMenuItem"); // NOI18N
fileMenu.add(exitMenuItem);
menuBar.add(fileMenu);
jMenu4.setText(resourceMap.getString("jMenu4.text")); // NOI18N
jMenu4.setName("jMenu4"); // NOI18N
jMenuItem4.setText(resourceMap.getString("jMenuItem4.text")); // NOI18N
jMenuItem4.setName("jMenuItem4"); // NOI18N
jMenuItem4.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
jMenuItem4MouseReleased(evt);
}
});
jMenu4.add(jMenuItem4);
jMenuItem5.setText(resourceMap.getString("jMenuItem5.text")); // NOI18N
jMenuItem5.setName("jMenuItem5"); // NOI18N
jMenuItem5.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
jMenuItem5MouseReleased(evt);
}
});
jMenu4.add(jMenuItem5);
menuBar.add(jMenu4);
menuLogikaRozmyta.setText(resourceMap.getString("menuLogikaRozmyta.text")); // NOI18N
menuLogikaRozmyta.setName("menuLogikaRozmyta"); // NOI18N
menuLogikaRozmyta.addMenuListener(new javax.swing.event.MenuListener() {
public void menuDeselected(javax.swing.event.MenuEvent evt) {
}
public void menuCanceled(javax.swing.event.MenuEvent evt) {
}
public void menuSelected(javax.swing.event.MenuEvent evt) {
menuLogikaRozmytaMenuSelected(evt);
}
});
oRedLightMenu.setText(resourceMap.getString("oRedLightMenu.text")); // NOI18N
oRedLightMenu.setName("oRedLightMenu"); // NOI18N
oRedLightMenu.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
oRedLightMenuMouseClicked(evt);
}
public void mousePressed(java.awt.event.MouseEvent evt) {
oRedLightMenuMousePressed(evt);
}
});
oRedLightMenu.addMenuKeyListener(new javax.swing.event.MenuKeyListener() {
public void menuKeyPressed(javax.swing.event.MenuKeyEvent evt) {
oRedLightMenuMenuKeyPressed(evt);
}
public void menuKeyReleased(javax.swing.event.MenuKeyEvent evt) {
}
public void menuKeyTyped(javax.swing.event.MenuKeyEvent evt) {
}
});
menuLogikaRozmyta.add(oRedLightMenu);
oGreenLightMenu.setText(resourceMap.getString("oGreenLightMenu.text")); // NOI18N
oGreenLightMenu.setName("oGreenLightMenu"); // NOI18N
oGreenLightMenu.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
oGreenLightMenuMouseReleased(evt);
}
});
menuLogikaRozmyta.add(oGreenLightMenu);
oLogikaZmianyMenu.setText(resourceMap.getString("oLogikaZmianyMenu.text")); // NOI18N
oLogikaZmianyMenu.setName("oLogikaZmianyMenu"); // NOI18N
oLogikaZmianyMenu.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
oLogikaZmianyMenuMousePressed(evt);
}
public void mouseReleased(java.awt.event.MouseEvent evt) {
oLogikaZmianyMenuMouseReleased(evt);
}
});
menuLogikaRozmyta.add(oLogikaZmianyMenu);
menuBar.add(menuLogikaRozmyta);
helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
helpMenu.setName("helpMenu"); // NOI18N
aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
aboutMenuItem.setText(resourceMap.getString("aboutMenuItem.text")); // NOI18N
aboutMenuItem.setName("aboutMenuItem"); // NOI18N
helpMenu.add(aboutMenuItem);
menuBar.add(helpMenu);
statusPanel.setName("statusPanel"); // NOI18N
statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N
statusMessageLabel.setName("statusMessageLabel"); // NOI18N
statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N
progressBar.setName("progressBar"); // NOI18N
javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
statusPanel.setLayout(statusPanelLayout);
statusPanelLayout.setHorizontalGroup(
statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 652, Short.MAX_VALUE)
.addGroup(statusPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(statusMessageLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 478, Short.MAX_VALUE)
.addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(statusAnimationLabel)
.addContainerGap())
);
statusPanelLayout.setVerticalGroup(
statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(statusPanelLayout.createSequentialGroup()
.addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(statusMessageLabel)
.addComponent(statusAnimationLabel)
.addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(3, 3, 3))
);
jSlider2.setName("jSlider2"); // NOI18N
jMenuBar1.setName("jMenuBar1"); // NOI18N
jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
jMenu1.setName("jMenu1"); // NOI18N
jMenuBar1.add(jMenu1);
jMenu2.setText(resourceMap.getString("jMenu2.text")); // NOI18N
jMenu2.setName("jMenu2"); // NOI18N
jMenuBar1.add(jMenu2);
setComponent(mainPanel);
setMenuBar(menuBar);
setStatusBar(statusPanel);
}// </editor-fold>//GEN-END:initComponents
private void updateTextArea(final String text) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
jLog.append(text);
}
});
}
private void redirectSystemStreams() {
OutputStream out = new OutputStream() {
@Override
public void write(int b) throws IOException {
updateTextArea(String.valueOf((char) b));
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
updateTextArea(new String(b, off, len));
}
@Override
public void write(byte[] b) throws IOException {
write(b, 0, b.length);
}
};
System.setOut(new PrintStream(out, true));
System.setErr(new PrintStream(out, true));
}
private void policzMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_policzMouseClicked
double wynik = 0;
//fis.getVariable("KONIECZNOSC_ZMIANY").chartDefuzzifier(true);
if(this.wykresWynikowyRLchecBox.isSelected())wynik=this.wnioskowanieRedLight.Wnioskuj(Double.valueOf(this.dlKolejki.getText()), Double.valueOf(this.stanDrogi.getText()), Double.valueOf(this.tRed.getText()), true);
this.wynik.setText(String.format("%f", wynik));
}//GEN-LAST:event_policzMouseClicked
private void sliderDLStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sliderDLStateChanged
this.dlKolejki.setText(Integer.valueOf(sliderDL.getValue()).toString());
}//GEN-LAST:event_sliderDLStateChanged
private void sliderStanStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sliderStanStateChanged
this.stanDrogi.setText(Integer.valueOf(sliderStan.getValue()).toString());
}//GEN-LAST:event_sliderStanStateChanged
private void sliderTimeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sliderTimeStateChanged
this.tRed.setText(Integer.valueOf(sliderTime.getValue()).toString());
}//GEN-LAST:event_sliderTimeStateChanged
private void menuLogikaRozmytaMenuSelected(javax.swing.event.MenuEvent evt) {//GEN-FIRST:event_menuLogikaRozmytaMenuSelected
}//GEN-LAST:event_menuLogikaRozmytaMenuSelected
private void oRedLightMenuMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_oRedLightMenuMouseClicked
}//GEN-LAST:event_oRedLightMenuMouseClicked
private void oRedLightMenuMenuKeyPressed(javax.swing.event.MenuKeyEvent evt) {//GEN-FIRST:event_oRedLightMenuMenuKeyPressed
}//GEN-LAST:event_oRedLightMenuMenuKeyPressed
private void oRedLightMenuMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_oRedLightMenuMousePressed
JFileChooser fileChoser = new JFileChooser();
fileChoser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChoser.setMultiSelectionEnabled(false);
FileNameExtensionFilter filter = new FileNameExtensionFilter(
"Pliki logiki rozmytej", "fuz", "txt");
fileChoser.setFileFilter(filter);
int returnVal = fileChoser.showOpenDialog(this.getComponent());
if(returnVal == JFileChooser.APPROVE_OPTION) {
this.fuzzyConfig.SetRedLightFile(fileChoser.getSelectedFile().getPath());
System.out.println(new String("Wybrano plik logiki rozmytej dla drogi z czerwonym światłem ")+fuzzyConfig.GetRedLightFile());
if(TesterPlikowLogikiRozmytej.CheckRedLightFile(fuzzyConfig.GetRedLightFile())){
System.out.println(new String("Plik poprawny:)"));
this.RedLightStatus.setText("OK");
this.RedLightStatus.setForeground(Color.green);
this.wnioskowanieRedLight = new WnioskowaczRedLight(fuzzyConfig.GetRedLightFile());
this.showRLchart.setEnabled(true);
this.policz.setEnabled(true);
}
else{
System.out.println(new String("Plik niepoprawny:("));
this.RedLightStatus.setText("NOT OK");
this.RedLightStatus.setForeground(Color.red);
this.policz.setEnabled(false);
this.showRLchart.setEnabled(false);
}
}
}//GEN-LAST:event_oRedLightMenuMousePressed
private void oGreenLightMenuMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_oGreenLightMenuMouseReleased
JFileChooser fileChoser = new JFileChooser();
fileChoser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChoser.setMultiSelectionEnabled(false);
FileNameExtensionFilter filter = new FileNameExtensionFilter(
"Pliki logiki rozmytej", "fuz", "txt");
fileChoser.setFileFilter(filter);
int returnVal = fileChoser.showOpenDialog(this.getComponent());
if(returnVal == JFileChooser.APPROVE_OPTION) {
this.fuzzyConfig.SetGreenLightFile(fileChoser.getSelectedFile().getPath());
System.out.println(new String("Wybrano plik logiki rozmytej dla drogi z zielonym światłem ")+fuzzyConfig.GetGreenLightFile());
if(TesterPlikowLogikiRozmytej.CheckGreenLightFile(fuzzyConfig.GetGreenLightFile())){
System.out.println(new String("Plik poprawny:)"));
this.GreenLightStatus.setText("OK");
this.GreenLightStatus.setForeground(Color.green);
this.wnioskowanieGreenLight = new WnioskowaczGreenLight(fuzzyConfig.GetGreenLightFile());
this.gLPolicz.setEnabled(true);
this.showGLchart.setEnabled(true);
}
else{
System.out.println(new String("Plik niepoprawny:("));
this.GreenLightStatus.setText("NOT OK");
this.GreenLightStatus.setForeground(Color.red);
this.showGLchart.setEnabled(true);
}
}
}//GEN-LAST:event_oGreenLightMenuMouseReleased
private void oLogikaZmianyMenuMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_oLogikaZmianyMenuMousePressed
}//GEN-LAST:event_oLogikaZmianyMenuMousePressed
private void oLogikaZmianyMenuMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_oLogikaZmianyMenuMouseReleased
JFileChooser fileChoser = new JFileChooser();
fileChoser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChoser.setMultiSelectionEnabled(false);
FileNameExtensionFilter filter = new FileNameExtensionFilter(
"Pliki logiki rozmytej", "fuz", "txt");
fileChoser.setFileFilter(filter);
int returnVal = fileChoser.showOpenDialog(this.getComponent());
if(returnVal == JFileChooser.APPROVE_OPTION) {
this.fuzzyConfig.SetWnioskowanieFile(fileChoser.getSelectedFile().getPath());
System.out.println(new String("Wybrano plik logiki rozmytej dla decydowania o zmianie światła ")+fuzzyConfig.GetWioskowanieFile());
}
}//GEN-LAST:event_oLogikaZmianyMenuMouseReleased
private void gLPoliczMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_gLPoliczMouseReleased
double wynik = 0;
if(wykresGlwynik.isSelected()){
wynik =
this.wnioskowanieGreenLight.Wnioskuj(Double.valueOf(this.gLDlKolejki.getText()), Double.valueOf(this.gLStanDrogi.getText()), true);
System.out.println("wnioskowanie + chart");
}
else{
wynik =
this.wnioskowanieGreenLight.Wnioskuj(Double.valueOf(this.gLDlKolejki.getText()), Double.valueOf(this.gLStanDrogi.getText()));
System.out.println("wnioskowanie");
}
this.gLWynik.setText(String.format("%f", wynik));
}//GEN-LAST:event_gLPoliczMouseReleased
private void gLstanDrogiSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_gLstanDrogiSliderStateChanged
this.gLStanDrogi.setText(Integer.valueOf(gLstanDrogiSlider.getValue()).toString());
}//GEN-LAST:event_gLstanDrogiSliderStateChanged
private void gLdlKolekiSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_gLdlKolekiSliderStateChanged
this.gLDlKolejki.setText(Integer.valueOf(gLdlKolekiSlider.getValue()).toString());
}//GEN-LAST:event_gLdlKolekiSliderStateChanged
private void showRLchartMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_showRLchartMouseReleased
if(this.showRLchart.isEnabled()){
if(this.showRLchart.isSelected()){
this.wnioskowanieRedLight.ShowChart();
this.showRLchart.setEnabled(false);
}
}
}//GEN-LAST:event_showRLchartMouseReleased
private void showGLchartMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_showGLchartMouseReleased
if(this.showGLchart.isEnabled()){
if(this.showGLchart.isSelected()){
this.wnioskowanieGreenLight.ShowChart();
this.showGLchart.setEnabled(false);
}
}
}//GEN-LAST:event_showGLchartMouseReleased
private void simStepStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_simStepStateChanged
if((Integer)simStep.getValue()<10){
this.simStep.setValue(Integer.valueOf(10));
}
}//GEN-LAST:event_simStepStateChanged
private void startSumoStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_startSumoStateChanged
}//GEN-LAST:event_startSumoStateChanged
private void startSumoMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_startSumoMouseReleased
if(this.startSumo.isEnabled()&&this.startSumo.getText().equals("Start")){
System.out.println("start");
this.pauseSumo.setVisible(true);
this.startSumo.setText("Stop");
this.startSumo.setEnabled(false);
sumoProcess = null;
conn = null;
final int PORT = 50003;
String exe = this.sumoEXE;
String[] args = new String[] {
exe,
"-c", this.sumoConfig
};
try {
sumoProcess = Runtime.getRuntime().exec(args);
} catch (IOException ex) {
Logger.getLogger(FuzzyTesterView.class.getName()).log(Level.SEVERE, null, ex);
}
try {
int exitVal = sumoProcess.exitValue();
throw new IOException("SUMO died with exit value " + exitVal);
}
catch (IOException ex) {
Logger.getLogger(FuzzyTesterView.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalThreadStateException e) {
// all OK, it's alive
}
try {
conn = new SumoTraciConnection(InetAddress.getLocalHost(), PORT);
} catch (IOException ex) {
Logger.getLogger(FuzzyTesterView.class.getName()).log(Level.SEVERE, null, ex);
} catch (InterruptedException ex) {
Logger.getLogger(FuzzyTesterView.class.getName()).log(Level.SEVERE, null, ex);
}
nss = new NextSimStep(conn);
this.sumoTimer = new Timer("sumoTimer");
this.sumoTimer.scheduleAtFixedRate(nss,
((Integer)this.simStep.getValue()).intValue(),
((Integer)this.simStep.getValue()).intValue());
this.simStep.setEnabled(false);
this.pauseSumo.setVisible(true);
this.startSumo.setText("Stop");
this.startSumo.setEnabled(true);
//test swiatel
}
else if(this.startSumo.isEnabled()&&this.startSumo.getText().equals("Stop")){
System.out.println("Zatrzymywanie symulacji...");
sumoTimer.purge();
sumoTimer.cancel();
System.out.println("Zamykanie połączeń...");
try {
conn.close();
} catch (IOException ex) {
Logger.getLogger(FuzzyTesterView.class.getName()).log(Level.SEVERE, null, ex);
} catch (InterruptedException ex) {
Logger.getLogger(FuzzyTesterView.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println("Zamykanie SUMO...");
sumoProcess.destroy();
this.startSumo.setText("Start");
this.simStep.setEnabled(true);
this.pauseSumo.setVisible(false);
this.pauseSumo.setText("Wstrzymaj");
}
}//GEN-LAST:event_startSumoMouseReleased
private void pauseSumoMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pauseSumoMouseReleased
if(this.pauseSumo.getText().equals("Wstrzymaj")){
System.out.println("Wstrzymywanie symulacji...");
sumoTimer.purge();
sumoTimer.cancel();
this.pauseSumo.setText("Wznów");
}
else if(this.pauseSumo.getText().equals("Wznów")){
System.out.println("Wznawianie symulacji...");
this.sumoTimer = new Timer("sumoTimer");
this.nss = new NextSimStep(conn);
this.sumoTimer.scheduleAtFixedRate(nss,
((Integer)this.simStep.getValue()).intValue(),
((Integer)this.simStep.getValue()).intValue());
this.pauseSumo.setText("Wstrzymaj");
}
}//GEN-LAST:event_pauseSumoMouseReleased
private void jMenuItem4MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenuItem4MouseReleased
JFileChooser fileChoser = new JFileChooser();
fileChoser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChoser.setMultiSelectionEnabled(false);
fileChoser.setFileFilter(new FileNameFilterek("sumo.cfg", "Pliki konfiguracji sumo"));
int returnVal = fileChoser.showOpenDialog(this.getComponent());
if(returnVal == JFileChooser.APPROVE_OPTION) {
this.sumoConfig = fileChoser.getSelectedFile().getPath();
this.sumoConfigLabel.setText(this.sumoConfig);
this.sumoConfigLabel.setForeground(Color.green);
System.out.println("Wybrano plik konfigurayjny dla symulatora SUMO "+this.sumoConfig);
}
if(this.sumoConfig!=null&&!this.sumoConfig.isEmpty()&&this.sumoEXE!=null&&!this.sumoEXE.isEmpty()){
this.startSumo.setEnabled(true);
}
}//GEN-LAST:event_jMenuItem4MouseReleased
private void jMenuItem5MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenuItem5MouseReleased
JFileChooser fileChoser = new JFileChooser();
fileChoser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChoser.setMultiSelectionEnabled(false);
fileChoser.setFileFilter(new FileNameFilterek("sumo-gui.exe", "Pliki GUI SUMO"));
int returnVal = fileChoser.showOpenDialog(this.getComponent());
if(returnVal == JFileChooser.APPROVE_OPTION) {
this.sumoEXE = fileChoser.getSelectedFile().getPath();
this.sumoPathlabel.setText(this.sumoEXE);
this.sumoPathlabel.setForeground(Color.green);
System.out.println(new String("Wskazano głowny program symulatora SUMO ")+this.sumoEXE);
if(this.sumoEXE!=null&&!this.sumoEXE.isEmpty()&&this.sumoConfig!=null&&!this.sumoConfig.isEmpty()){
this.startSumo.setEnabled(true);
}
}
}//GEN-LAST:event_jMenuItem5MouseReleased
private WnioskowaczRedLight wnioskowanieRedLight;
private WnioskowaczGreenLight wnioskowanieGreenLight;
private NextSimStep nss;
private FuzzyConfig fuzzyConfig;
private String sumoEXE;
private String sumoConfig;
private Timer sumoTimer;
private Process sumoProcess;
private SumoTraciConnection conn;
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel GreenFuzzyStatusLabel;
private javax.swing.JLabel GreenLightStatus;
private javax.swing.JLabel RedFuzzyStatusLabel;
private javax.swing.JLabel RedLightStatus;
private javax.swing.JTextField dlKolejki;
private javax.swing.JTextField gLDlKolejki;
private javax.swing.JButton gLPolicz;
private javax.swing.JTextField gLStanDrogi;
private javax.swing.JTextField gLWynik;
private javax.swing.JSlider gLdlKolekiSlider;
private javax.swing.JSlider gLstanDrogiSlider;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JTextArea jLog;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu4;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JSlider jSlider1;
private javax.swing.JSlider jSlider2;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JPanel mainPanel;
private javax.swing.JMenuBar menuBar;
private javax.swing.JMenu menuLogikaRozmyta;
private javax.swing.JMenuItem oGreenLightMenu;
private javax.swing.JMenuItem oLogikaZmianyMenu;
private javax.swing.JMenuItem oRedLightMenu;
private javax.swing.JButton pauseSumo;
private javax.swing.JButton policz;
private javax.swing.JProgressBar progressBar;
private javax.swing.JCheckBox showGLchart;
private javax.swing.JCheckBox showRLchart;
private javax.swing.JSpinner simStep;
private javax.swing.JSlider sliderDL;
private javax.swing.JSlider sliderStan;
private javax.swing.JSlider sliderTime;
private javax.swing.JTextField stanDrogi;
private javax.swing.JButton startSumo;
private javax.swing.JLabel statusAnimationLabel;
private javax.swing.JLabel statusMessageLabel;
private javax.swing.JPanel statusPanel;
private javax.swing.JLabel sumoConfigLabel;
private javax.swing.JLabel sumoPathlabel;
private javax.swing.JTextField tRed;
private javax.swing.JCheckBox wykresGlwynik;
private javax.swing.JCheckBox wykresWynikowyRLchecBox;
private javax.swing.JTextField wynik;
// End of variables declaration//GEN-END:variables
private final javax.swing.Timer messageTimer;
private final javax.swing.Timer busyIconTimer;
private final Icon idleIcon;
private final Icon[] busyIcons = new Icon[15];
private int busyIconIndex = 0;
private JDialog aboutBox;
}