From 4144bf0ab60e5c351b2a2b9aa0d91e00f93f532c Mon Sep 17 00:00:00 2001 From: Jdrezen <jeremie.drezen@gmail.com> Date: Wed, 12 May 2021 14:32:32 +0200 Subject: [PATCH] Merge branch 'master' into window_closing --- .../controleurPhilosophersExample.py | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/philosopher_example/controleurPhilosophersExample.py b/philosopher_example/controleurPhilosophersExample.py index b9e4373..cdb4dc5 100644 --- a/philosopher_example/controleurPhilosophersExample.py +++ b/philosopher_example/controleurPhilosophersExample.py @@ -11,8 +11,11 @@ class ControleurPhilosophersExample(Controleur): self.__numberPhilosopher = 10 self.__barChart = [] self.__barChart.append(self.addBarChart('Eaten Pastas')) - self.__barChart.append(self.addBarChart('Hours of tkinking')) - self.__barChart.append(self.addBarChart('Hours of hunger')) + self.__barChart.append(self.addPlotChart('Hours of tkinking')) + self.setPolicy(self.__barChart[1],0,"ro") + + self.__barChart.append(self.addPlotChart('Hours of hunger')) + self.addCurve(self.__barChart[2],'g+-') def initialisation(self): @@ -33,6 +36,14 @@ class ControleurPhilosophersExample(Controleur): self.setXLabel(self.__barChart[2],'Philosophers') self.setYLabel(self.__barChart[2],'Hours') + self.draw_text(40,15, "EATING") + self.draw_text(40,45, "THINKING") + self.draw_text(40,75, "HUNGRY") + + self.draw_rectangle(10, 10, 20, 20, 'green') + self.draw_rectangle(10, 40, 20, 20, 'blue') + self.draw_rectangle(10, 70, 20, 20, 'red') + for i in range(self.__numberPhilosopher): x = 100 * cos(2 * pi * i / self.__numberPhilosopher) + (widthCanvas / 2) y = 100 * sin(2 * pi * i / self.__numberPhilosopher) + (heightCanvas / 2) @@ -43,9 +54,11 @@ class ControleurPhilosophersExample(Controleur): self.__philosophers.append(carre) nom = 'Mr ' + str(i) + self.addColumn(self.__barChart[0],nom) - self.addColumn(self.__barChart[1],nom) - self.addColumn(self.__barChart[2],nom) + self.addPoint(self.__barChart[1],0,x-10,y-10) + self.addPoint(self.__barChart[2],0,i*50,y) + self.addPoint(self.__barChart[2],1,i*50,y-50) def updateWindow(self, env, amas): agents = amas.get_Agents_Sorted() @@ -58,11 +71,9 @@ class ControleurPhilosophersExample(Controleur): elif state == State.HUNGRY: self.change_color(self.__philosophers[i], 'red') - self.increaseValue(self.__barChart[2],i, 1) else: self.change_color(self.__philosophers[i], 'blue') - self.increaseValue(self.__barChart[1],i, 1) coords = self.get_coords_element(self.__philosophers[i]) if agents[i].get_Left_Fork().owned(agents[i]): -- GitLab