evolutions.addComponent(hlayout);
evolutions.addComponent(_vpanel);
// filling the airports
__server = new DQSPServerI();
for (String s : __server.listOfAirports()) {
eairports.addItem(s);
}
// listener for airports
eairports.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
// checking if there are any claims for the selected
// airport, so the existence of themes
if (__server.listOfThemes(
String.valueOf(eairports.getValue())).size() != 0) {
// filling themes
for (String s : __server.listOfThemes(String
.valueOf(eairports.getValue()))) {
themes.addItem(s);
}
themes.setVisible(true);
evolutions.setWidth("690px");
evolutions.setHeight("200px");
themes.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
options.setVisible(true);
vlayout.removeAllComponents();
// Default behavior
// creating and wrapping the chart
evoWrap = new JFreeChartWrapper(
createChart(
createMonthlyDataset(
String.valueOf(eairports
.getValue()),
String.valueOf(themes
.getValue())),
String.valueOf(themes
.getValue()),
"Nombre de Réclamations",
"MMM-yyyy"));
vlayout.addComponent(evoWrap);
vlayout.setComponentAlignment(evoWrap,
Alignment.MIDDLE_CENTER);
_vpanel.setVisible(true);
esave.setVisible(true);
evolutions.setSizeFull();
evolutions.center();
options.setValue("Mensuelle");
// listener for the save button
esave.addListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
if (String.valueOf(
options.getValue()).equals(
"Mensuelle")) {
// saving a monthly chart
try {
ChartUtilities
.saveChartAsJPEG(
new File(
"/home/matrix/Desktop/graphs/m_evoGraph.jpg"),
createChart(
createMonthlyDataset(
String.valueOf(eairports
.getValue()),
String.valueOf(themes
.getValue())),
themes.getValue()
.toString(),
"Nombre de Réclamations",
"MMM-yyyy"),
500, 300);
} catch (IOException e) {
e.printStackTrace();
}
__app.getMainWindow()
.showNotification(
"Notification",
"Graphe Enregistré",
Window.Notification.TYPE_TRAY_NOTIFICATION);
}
}
});
// decide which type of evolution you want
options.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(
ValueChangeEvent event) {
if (String.valueOf(
options.getValue()).equals(
"Mensuelle")) {
vlayout.removeAllComponents();
// creating and wrapping the
// chart
evoWrap = new JFreeChartWrapper(
createChart(
createMonthlyDataset(
String.valueOf(eairports
.getValue()),
String.valueOf(themes
.getValue())),
themes.getValue()
.toString(),
"Nombre de Réclamations",
"MMM-yyyy"));
vlayout.addComponent(evoWrap);
vlayout.setComponentAlignment(
evoWrap,
Alignment.MIDDLE_CENTER);
_vpanel.setVisible(true);
esave.setVisible(true);
evolutions.setSizeFull();
evolutions.center();
} else if (String.valueOf(
options.getValue()).equals(
"Annuelle")) {
vlayout.removeAllComponents();
// creating and wrapping the
// chart
evoWrap = new JFreeChartWrapper(
createChart(
createAnnualDataset(
String.valueOf(eairports
.getValue()),
String.valueOf(themes
.getValue())),
themes.getValue()
.toString(),
"Nombre de Réclamations",
"yyyy"));
vlayout.addComponent(evoWrap);
vlayout.setComponentAlignment(
evoWrap,
Alignment.MIDDLE_CENTER);
_vpanel.setVisible(true);
esave.setVisible(true);
evolutions.setSizeFull();
evolutions.center();
// setting a listener for the
// save button for annual_data
esave.addListener(new Button.ClickListener() {
@Override
public void buttonClick(
ClickEvent event) {
// saving an annual
// chart
try {
ChartUtilities
.saveChartAsJPEG(
new File(
"/home/matrix/Desktop/graphs/a_evoGraph.jpg"),
createChart(
createMonthlyDataset(
String.valueOf(eairports
.getValue()),
String.valueOf(themes
.getValue())),
themes.getValue()
.toString(),
"Nombre de Réclamations",
"yyyy"),
500,
300);
} catch (IOException e) {
e.printStackTrace();
}
__app.getMainWindow()
.showNotification(
"Notification",
"Graphe Enregistré",
Window.Notification.TYPE_TRAY_NOTIFICATION);
}
});
}
}
});
}
});
} else {
esave.setVisible(false);
themes.setVisible(false);
options.setVisible(false);
_vpanel.setVisible(false);
evolutions.setWidth("400px");
evolutions.setHeight("200px");
evolutions.center();
__app.getMainWindow().showNotification(
"Notification",
"Pas de données pour cet aéroport",
Window.Notification.TYPE_TRAY_NOTIFICATION);
}
}
});
__app.getMainWindow().addWindow(evolutions);
}
});
// Recurrences
menu.addButton("Récurrences", new TouchMenu.Command() {
@Override
public void menuSelected(TouchMenuButton selectedButton) {
rec = new Window("Récurrences");
rec.center();
rec.setWidth("400px");
rec.setHeight("200px");
rec.setImmediate(true);
airports = new ComboBox("Aéroport");
airports.setInputPrompt("Sélectionnez un aéroport");
airports.setIcon(new ThemeResource("icons/actions/identity.png"));
airports.setImmediate(true);
airports.setNullSelectionAllowed(false);
save = new Button();
save.setIcon(new ThemeResource("icons/actions/filesave.png"));
save.setVisible(false);
_vlayout.setSpacing(true);
_vlayout.setMargin(true);
_vlayout.setImmediate(true);
vpanel.addComponent(_vlayout);
vpanel.setVisible(false);
glayout = new GridLayout(2, 2);
glayout.setSpacing(true);
glayout.setSpacing(true);
glayout.addComponent(airports, 0, 0);
glayout.setComponentAlignment(airports, Alignment.BOTTOM_LEFT);
glayout.addComponent(save, 1, 0);
glayout.setComponentAlignment(save, Alignment.BOTTOM_RIGHT);
rec.addComponent(glayout);
rec.addComponent(vpanel);
// filling the airports
_server = new DQSPServerI();
for (String s : _server.listOfAirports()) {
airports.addItem(s);
}
// listener for airports
airports.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
if (_server.listOfThemes(
String.valueOf(airports.getValue())).size() != 0) {
rec.center();
// rec.setWidth("780px");
// rec.setHeight("700px");
rec.setSizeFull();
dataSet = new DefaultCategoryDataset();
dataSet.clear();
_vlayout.removeAllComponents();
for (String s : _server.listOfThemes(String
.valueOf(airports.getValue()))) {
int val = _server.numberOfAppearancesPerMonth(
s, String.valueOf(airports.getValue())) * 100 / 4;
dataSet.setValue(val, s, s);
}
// for save button
save.setVisible(true);
save.addListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
try {
ChartUtilities
.saveChartAsJPEG(
new File(
"/home/matrix/Desktop/graphs/graph.jpg"),
chartOfThemes, 500, 300);
} catch (IOException e) {
e.printStackTrace();
}
__app.getMainWindow()
.showNotification(
"Notification",
"Graphe Enregistré",
Window.Notification.TYPE_TRAY_NOTIFICATION);
}
});
chartOfThemes = ChartFactory.createBarChart3D(
"Récurrences", "Thème", "Récurrence (%)",
dataSet, PlotOrientation.VERTICAL, true,
true, false);
wrapChart = new JFreeChartWrapper(chartOfThemes);
wrapChart.setImmediate(true);
_vlayout.addComponent(wrapChart);
_vlayout.setComponentAlignment(wrapChart,
Alignment.MIDDLE_CENTER);
vpanel.setVisible(true);
} else {
save.setVisible(false);
vpanel.setVisible(false);
rec.setWidth("400px");
rec.setHeight("200px");
rec.center();
__app.getMainWindow().showNotification(
"Notification",
"Pas de données pour cet aéroport",
Window.Notification.TYPE_TRAY_NOTIFICATION);
}
}
});
__app.getMainWindow().addWindow(rec);
}
});
// Comparisons
menu.addButton("Comparaisons", new TouchMenu.Command() {
@Override
public void menuSelected(TouchMenuButton selectedButton) {
compa = new Window("Comparaisons");
compa.center();
compa.setWidth("400px");
compa.setHeight("200px");
compa.setImmediate(true);
compa.removeAllComponents();
// connecting to server
___server = new DQSPServerI();
// to ensure the repaint of the horizontal layout
__hlayout.removeAllComponents();
compaType = new ComboBox("Type de Comparaison");