1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
private void printStatForMultipleService(
HashMap<Ref, ServiceResourceStatistic> resourcesMap) {
if (resourcesMap == null) {
System.out
.println("\nService statistics map is null...Nothing to print.\n");
}
if (resourcesMap.size() == 0) {
System.out
.println("\nService statistics map is empty...Nothing to print.\n");
}
// Transformation en set pour parcourir la map
Set<Map.Entry<Ref, ServiceResourceStatistic>> set = resourcesMap
.entrySet();
int nbService = set.size();
System.out.println("nb service : " + nbService);
int nbStats = getStatArrayForOneService(set.iterator().next()
.getValue()).length;
System.out.println("nb stats : " + nbStats);
String[] serviceNames = new String[nbService];
String[] statNames = new String[nbStats];
double[][] data = new double[nbService][nbStats];
// Parcours de la map
int i = 0;
for (Map.Entry<Ref, ServiceResourceStatistic> mapEntry : set) {
// Creation du tableau de stat pour chaque service
ResourceStatistic[] resStatsArray = null;
// Récupération des différentes statistiques sous forme d'Array
resStatsArray = getStatArrayForOneService(mapEntry.getValue());
int j = 0;
// Parcours du tableau de statistique
for (ResourceStatistic resStats : resStatsArray) {
// Récupération d'une des statistiques du tableau
StatisticValue[] statValues = resStats.getStatistics();
// Pärcours des valeurs de la statistiques
for (StatisticValue value : statValues) {
if (value.getType() == StatisticType.INTERVAL) {
StatisticValue.IntervalStatistic is = (StatisticValue.IntervalStatistic) value;
// Nom de la statistique
statNames[j] = resStats.getName();
// récupération de l'interval moyen
data[i][j] = is.getAverage();
j++;
}
}
}// Nom du service
serviceNames[i] = mapEntry.getKey().getNames()[mapEntry.getKey()
.getNames().length - 1];
i++;
}
// Creation du dataset
CategoryDataset dataset = DatasetUtilities.createCategoryDataset(
serviceNames, statNames, data);
// Creation du multiple pie chart
JFreeChart chart = ChartFactory.createMultiplePieChart(
"Multiple Pie Chart", dataset, TableOrder.BY_ROW, true, true,
true);
// Sauvegarde sous format d'image en local
ChartRenderingInfo info = new ChartRenderingInfo(
new StandardEntityCollection());
File file1 = new File(this.idStat + ".jpeg");
try {
ChartUtilities.saveChartAsJPEG(file1, chart, 800, 600, info);
} catch (IOException e) {
e.printStackTrace();
}
} |
Partager