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");
compaType.setImmediate(true);
compaType.setIcon(new ThemeResource("icons/actions/misc.png"));
compaType.setInputPrompt("Choisissez un type");
compaType.addItem("globale");
compaType.addItem("thématique");
compaType.setNullSelectionAllowed(false);
__hlayout.addComponent(compaType);
__hlayout.setComponentAlignment(compaType,
Alignment.BOTTOM_LEFT);
_history = new ComboBox("Année");
_history.setImmediate(true);
_history.setInputPrompt("Année");
_history.setIcon(new ThemeResource("icons/actions/history.png"));
_history.setVisible(false);
_history.setNullSelectionAllowed(false);
__hlayout.addComponent(_history);
__hlayout.setComponentAlignment(_history,
Alignment.BOTTOM_RIGHT);
for (Integer i : ___server.listOfYears()) {
_history.addItem(i);
}
compaTheme = new ComboBox("Thème");
compaTheme
.setIcon(new ThemeResource("icons/actions/blend.png"));
compaTheme.setVisible(false);
compaTheme.setImmediate(true);
compaTheme.setNullSelectionAllowed(false);
compaTheme.setInputPrompt("Choisissez un thème");
// filling themes
for (String s : ___server.listOfThemesInClaims()) {
compaTheme.addItem(s);
}
__hlayout.addComponent(compaTheme);
__hlayout.setComponentAlignment(compaTheme,
Alignment.BOTTOM_RIGHT);
saveComp = new Button();
saveComp.setIcon(new ThemeResource("icons/actions/filesave.png"));
saveComp.setDescription("Enregistrer");
saveComp.setVisible(false);
__hlayout.addComponent(saveComp);
__hlayout.setComponentAlignment(saveComp,
Alignment.BOTTOM_RIGHT);
__hlayout.setSpacing(true);
compa.addComponent(__hlayout);
__vlayout.setSpacing(true);
__vlayout.setMargin(true);
__vlayout.setImmediate(true);
__vpanel.addComponent(__vlayout);
__vpanel.setVisible(false);
compa.addComponent(__vpanel);
// adding listener to comparison type
compaType.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
/*
* _history.setVisible(true);
* __vlayout.removeAllComponents();
* compaTheme.setVisible(false); //_history.setValue(new
* Integer(2011)); compChart =
* createChart(createGlobalDataset(2011),
* "Comparaisons Globale",
* "Nombre de Réclamations/Nombre de passagers traités"
* ,"MMM-yyyy"); compChartWrap = new
* JFreeChartWrapper(compChart);
* __vlayout.addComponent(compChartWrap);
* __vlayout.setComponentAlignment(compChartWrap,
* Alignment.MIDDLE_CENTER); compa.setSizeFull();
* compa.center(); __vpanel.setVisible(true); //for save
* button saveComp.setVisible(true);
* saveComp.addListener(new Button.ClickListener() {
*
* @Override public void buttonClick(ClickEvent event) {
* try { ChartUtilities.saveChartAsJPEG(new
* File("/home/matrix/Desktop/graphs/graph.jpg"),
* compChart, 600, 500); } catch (IOException e) {
* e.printStackTrace(); } //displaying a notification
* __app.getMainWindow() .showNotification(
* "Notification", "Graphe Enregistré",
* Window.Notification.TYPE_TRAY_NOTIFICATION); } });
*/
if (String.valueOf(compaType.getValue()).equals(
"globale")) {
__vlayout.removeAllComponents();
_history.setVisible(true);
_history.setValue(new Integer(2011));
compaTheme.setVisible(false);
// Default Behavior
compChart = createChart(
createGlobalDataset((Integer) _history
.getValue()),
"Évolution annuelle du nombre totale de réclamations",
"Nombre de Réclamations/Nombre de passagers traités",
"MMM-yyyy");
compChartWrap = new JFreeChartWrapper(compChart);
__vlayout.addComponent(compChartWrap);
__vlayout.setComponentAlignment(compChartWrap,
Alignment.MIDDLE_CENTER);
compa.setSizeFull();
compa.center();
__vpanel.setVisible(true);
// for save button
saveComp.setVisible(true);
saveComp.addListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
try {
ChartUtilities
.saveChartAsJPEG(
new File(
"/home/matrix/Desktop/graphs/comp_graph_g.jpg"),
compChart, 500, 400);
} catch (IOException e) {
e.printStackTrace();
}
// displaying a notification
__app.getMainWindow()
.showNotification(
"Notification",
"Graphe Enregistré",
Window.Notification.TYPE_TRAY_NOTIFICATION);
}
});
// ------------------------------------------------------------
_history.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
compChart = createChart(
createGlobalDataset((Integer) _history
.getValue()),
"Évolution annuelle du nombre totale de réclamations",
"Nombre de Réclamations/Nombre de passagers traités",
"MMM-yyyy");
compChartWrap = new JFreeChartWrapper(
compChart);
__vlayout.addComponent(compChartWrap);
__vlayout.setComponentAlignment(
compChartWrap,
Alignment.MIDDLE_CENTER);
compa.setSizeFull();
compa.center();
__vpanel.setVisible(true);
// for save button
saveComp.setVisible(true);
saveComp.addListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
try {
ChartUtilities
.saveChartAsJPEG(
new File(
"/home/matrix/Desktop/graphs/comp_graph_g.jpg"),
compChart, 500,
400);
} catch (IOException e) {
e.printStackTrace();
}
// displaying a notification
__app.getMainWindow()
.showNotification(
"Notification",
"Graphe Enregistré",
Window.Notification.TYPE_TRAY_NOTIFICATION);
}
});
}
});
}
if (String.valueOf(compaType.getValue()).equals(
"thématique")) {
__vlayout.removeAllComponents();
_history.setVisible(true);
compaTheme.setVisible(true);
__vpanel.setVisible(false);
compaTheme
.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(
ValueChangeEvent event) {
__vlayout.removeAllComponents();
compChart = createChart(
createThemeDataset(
(Integer) _history
.getValue(),
String.valueOf(compaTheme
.getValue())),
"Comparaisons thématique '"
+ compaTheme
.getValue()
.toString()
+ "'",
"Nombre de Réclamations/Nombre de passagers traités",
"MMM-yyyy");
compChartWrap = new JFreeChartWrapper(
compChart);
__vlayout
.addComponent(compChartWrap);
__vlayout.setComponentAlignment(
compChartWrap,