本文整理汇总了Python中java.lang.Math.max方法的典型用法代码示例。如果您正苦于以下问题:Python Math.max方法的具体用法?Python Math.max怎么用?Python Math.max使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.Math
的用法示例。
在下文中一共展示了Math.max方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render_shape_to_graphics
# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import max [as 别名]
def render_shape_to_graphics(self, shape):
r = shape.getShapeRenderer()
# Find the size that the shape will be rendered to at the specified scale and resolution.
shapeSizeInPixels = r.getSizeInPixels(1.0, 96.0)
# Rotating the shape may result in clipping as the image canvas is too small. Find the longest side
# and make sure that the graphics canvas is large enough to compensate for this.
maxSide = Math.max(shapeSizeInPixels.width, shapeSizeInPixels.height)
image = BufferedImage(int(maxSide * 1.25), int(maxSide * 1.25), BufferedImage.TYPE_INT_ARGB)
# Rendering to a graphics object means we can specify settings and transformations to be applied to
# the shape that is rendered. In our case we will rotate the rendered shape.
gr = image.getGraphics()
# Clear the shape with the background color of the document.
gr.setBackground(shape.getDocument().getPageColor())
gr.clearRect(0, 0, image.getWidth(), image.getHeight())
# Center the rotation using translation method below
gr.translate(image.getWidth() / 8, image.getHeight() / 2)
# Rotate the image by 45 degrees.
gr.rotate(45 * Math.PI / 180)
# Undo the translation.
gr.translate(-image.getWidth() / 8, -image.getHeight() / 2)
# Render the shape onto the graphics object.
r.renderToSize(gr, 0, 0, shapeSizeInPixels.width, shapeSizeInPixels.height)
ImageIO.write(image, "png", File(self.dataDir + "TestFile.RenderToGraphics.png"))
gr.dispose()
print "Shape rendered to Graphics successfully."
示例2: p_addition
# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import max [as 别名]
def p_addition(p):
'''addition : term
| term addOP addition'''
from java.lang import Math
import Addition
if len(p) == 4 and isinstance( p[1], int ) and isinstance( p[3], int ):
print "Calling java Math: ", Math.max(p[1], p[3])
print "Calling java Addition.add: ", Addition.add(p[1], p[3])
if len(p) == 4: p[0] = str(p[1]) + str(p[2]) + str(p[3])
else : p[0] = p[1]
示例3: eval
# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import max [as 别名]
phi = eval(self.poly_terms)
return (i + LinAlg.dotProduct(phi,self.poly_x), j + LinAlg.dotProduct(phi,self.poly_y))
if __name__ == "__main__":
#--------------------------------------
model = PolyUndistortionModel(sys.argv[1])
im = ImageIO.read(File(sys.argv[2]))
undistorted = []
maxx, maxy, minx, miny = float('-Inf'), float('-Inf'), float('Inf'), float('Inf')
for i in range(im.width):
for j in range(im.height):
ii, jj = model.undistort(i, j)
undistorted.append([ii, jj, im.getRGB(i,j)])
maxx = Math.max(maxx, ii)
minx = Math.min(minx, ii)
maxy = Math.max(maxy, jj)
miny = Math.min(miny, jj)
rangex, rangey = maxx-minx, maxy-miny
imout = BufferedImage(int(im.width*0.4), int(im.height*0.4), BufferedImage.TYPE_INT_ARGB)
scale = imout.width/rangex
for u in undistorted:
x, y = int((u[0]-minx)*scale), int((u[1]-miny)*scale)
if x < imout.width and y < imout.height:
imout.setRGB(x, y, 0xFF000000 | u[2])
token = sys.argv[2].split('.')[0]
ImageIO.write(imout, 'png', File(token + '.out.png'))
示例4: test_java_stuff
# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import max [as 别名]
def test_java_stuff(self):
from java.lang import Math
maxval = Math.max(4, 7)
self.assertEqual(7, maxval)