当前位置: 首页>>代码示例>>Python>>正文


Python Math.rint方法代码示例

本文整理汇总了Python中java.lang.Math.rint方法的典型用法代码示例。如果您正苦于以下问题:Python Math.rint方法的具体用法?Python Math.rint怎么用?Python Math.rint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.Math的用法示例。


在下文中一共展示了Math.rint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getColorMap

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import rint [as 别名]
 def getColorMap(self, fmax, fmin):
     # we always draw O(100) gradations...as we don't expect a very large variation
     theMap = self.createImage(DMVisualization.NO_OF_GRADATIONS+30, 40)
     stepValue = 0.0;                            
     
     imageGraphics = theMap.getGraphics()
     
     j = 0
     i = 0.0
     
     imageGraphics.setColor(self.visualizationPanelBD.getBackground())
     imageGraphics.fillRect(0, 0, DMVisualization.NO_OF_GRADATIONS+30, 40)
     
     imageGraphics.setFont(Font("Sans Serif", Font.ITALIC, 10))
     
     # first shade:        
     stepValue = (10e-5 - self.dmVisualThreashold) / (DMVisualization.NO_OF_GRADATIONS / 6)
     imageGraphics.setColor(Color(~self.visualizationPanelBD.getBackground().getRGB()))
     imageGraphics.drawString("10e-6", j, 30)
     i=self.dmVisualThreashold; j=0 
     while i<=10e-5:            
         imageGraphics.setColor(self.findInterpolatedColor(fmax, fmin, i))
         imageGraphics.drawLine(j, 0, j, 20)            
         i+=stepValue; j+=1
     imageGraphics.setColor(Color(~self.visualizationPanelBD.getBackground().getRGB()))         
     
     # second shade:        
     stepValue = (10e-4 - 10e-5) / (DMVisualization.NO_OF_GRADATIONS / 6)
     imageGraphics.setColor(Color(~self.visualizationPanelBD.getBackground().getRGB()))
     imageGraphics.drawString("10e-5", j, 30)
     i=10e-5
     while i<=10e-4:            
         imageGraphics.setColor(self.findInterpolatedColor(fmax, fmin, i))
         imageGraphics.drawLine(j, 0, j, 20)         
         i+=stepValue; j+=1
     imageGraphics.setColor(Color(~self.visualizationPanelBD.getBackground().getRGB()))
     imageGraphics.drawString("10e-4", j, 30)
     
     # third shade:
     stepValue = (10e-3 - 10e-4) / (DMVisualization.NO_OF_GRADATIONS / 6)
     i=10e-4
     while i<=10e-3:            
         imageGraphics.setColor(self.findInterpolatedColor(fmax, fmin, i))
         imageGraphics.drawLine(j, 0, j, 20)
         i+=stepValue; j+=1
     imageGraphics.setColor(Color(~self.visualizationPanelBD.getBackground().getRGB()))
     imageGraphics.drawString("10e-3", j, 30)
     
     # forth shade:
     stepValue = (10e-2 - 10e-3) / (DMVisualization.NO_OF_GRADATIONS / 6)
     i=10e-3
     while i<=10e-2:            
         imageGraphics.setColor(self.findInterpolatedColor(fmax, fmin, i))
         imageGraphics.drawLine(j, 0, j, 20)
         i+=stepValue; j+=1
     imageGraphics.setColor(Color(~self.visualizationPanelBD.getBackground().getRGB()))
     imageGraphics.drawString("10e-2", j, 30)
     
     # fifth shade:
     stepValue = (10e-1 - 10e-2) / (DMVisualization.NO_OF_GRADATIONS / 6)
     i=10e-2
     while i<=10e-1:            
         imageGraphics.setColor(self.findInterpolatedColor(fmax, fmin, i))
         imageGraphics.drawLine(j, 0, j, 20)
         i+=stepValue; j+=1
     imageGraphics.setColor(Color(~self.visualizationPanelBD.getBackground().getRGB()))
     imageGraphics.drawString("10e-1", j, 30)
     
     # sixth shade:
     stepValue = (fmax - 10e-1) / (DMVisualization.NO_OF_GRADATIONS / 6)
     i=10e-1
     while i<=fmax:            
         imageGraphics.setColor(self.findInterpolatedColor(fmax, fmin, i))
         imageGraphics.drawLine(j, 0, j, 20)
         i+=stepValue; j+=1
     imageGraphics.setColor(Color(~self.visualizationPanelBD.getBackground().getRGB()))
     imageGraphics.drawString("" + repr(Math.rint(fmax)), j, 30)
     
     return theMap;
开发者ID:tommytracx,项目名称:metastudio,代码行数:81,代码来源:dmview.py


注:本文中的java.lang.Math.rint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。