本文整理汇总了Python中Graph.Graph.updateData方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.updateData方法的具体用法?Python Graph.updateData怎么用?Python Graph.updateData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph.Graph
的用法示例。
在下文中一共展示了Graph.updateData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DataPanel
# 需要导入模块: from Graph import Graph [as 别名]
# 或者: from Graph.Graph import updateData [as 别名]
class DataPanel(object):
def __init__(self, appScreen, petriDish, left, top, width, height):
self.dataPanelSurface = appScreen.subsurface(pygame.Rect((left, top),
(width, height)))
self.left = left
self.top = top
self.width = width
self.height = height
self.petriDish = petriDish
self.herbPlot = Graph(left, 100, width, height-100)
self.herbPlot.setColor((255,160,0))
self.predPlot = Graph(left, 100, width, height-100)
self.predPlot.setColor((255,40,0))
self.omniPlot = Graph(left, 100, width, height-100)
self.omniPlot.setColor((0,0,255))
self.grassPlot = Graph(left, 100, width, height-100)
self.grassPlot.setColor((0,255,0))
self.time = 0
def updatePlots(self, timePassed):
self.time += timePassed
# updates all plots
self.herbPlot.updateData(self.petriDish.getHerbivoreCount(),
timePassed)
self.herbPlot.plotData(self.dataPanelSurface)
self.predPlot.updateData(self.petriDish.getPredatorCount(),
timePassed)
self.predPlot.plotData(self.dataPanelSurface)
self.omniPlot.updateData(self.petriDish.getOmnivoreCount(),
timePassed)
self.omniPlot.plotData(self.dataPanelSurface)
self.grassPlot.updateData(self.petriDish.getGrassCount() * 200,
timePassed)
self.grassPlot.plotData(self.dataPanelSurface)
def blitAllData(self):
# draws all the data variables to the data panel
DataVariable('Herbivores', self.petriDish.getHerbivoreCount(),
self.dataPanelSurface, 20, 10, 100, 50).draw()
DataVariable('Predators', self.petriDish.getPredatorCount(),
self.dataPanelSurface, 20, 35, 100, 50).draw()
DataVariable('Omnivores', self.petriDish.getOmnivoreCount(),
self.dataPanelSurface, 20, 60, 100, 50).draw()
DataVariable('Grass', self.petriDish.getGrassCount(),
self.dataPanelSurface, 20, 85, 100, 50).draw()
DataVariable('hAvgSpeed', self.petriDish.getAvgHSpeed(),
self.dataPanelSurface, 20, 110, 100, 50).draw()
DataVariable('hAvgFleeSpeed', self.petriDish.getAvgHerbFleeSpeed(),
self.dataPanelSurface, 20, 135, 100, 50).draw()
DataVariable('hAvgVision', self.petriDish.getAvgHVision(),
self.dataPanelSurface, 20, 160, 100, 50).draw()
DataVariable('pAvgSpeed', self.petriDish.getAvgPSpeed(),
self.dataPanelSurface, 20, 185, 100, 50).draw()
DataVariable('pAvgChaseSpeed', self.petriDish.getAvgPredChaseSpeed(),
self.dataPanelSurface, 20, 210, 100, 50).draw()
DataVariable('pAvgVision', self.petriDish.getAvgPredVision(),
self.dataPanelSurface, 20, 235, 100, 50).draw()
DataVariable('oAvgSpeed', self.petriDish.getAvgOSpeed(),
self.dataPanelSurface, 20, 260, 100, 50).draw()
DataVariable('oAvgFleeSpeed', self.petriDish.getAvgOmniFleeSpeed(),
self.dataPanelSurface, 20, 285, 100, 50).draw()
DataVariable('oAvgVision', self.petriDish.getAvgOmniVision(),
self.dataPanelSurface, 20, 310, 100, 50).draw()