找到封闭的GeneralPath所包含的区域 [英] Find the area enclosed by a closed GeneralPath

查看:355
本文介绍了找到封闭的GeneralPath所包含的区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能存在重复:


$ b如何计算java.awt.geom.Area的面积?


$ b

我不知道该如何开始,希望有人可以帮忙?

我有一个关闭的 java.awt.geom.GeneralPath ,我尝试测量 squarepixel 中的平方(区域 code> point ^ 2 ))。

解决方案

GeneralPath implements Shape ,您可以计算次数 contains()是<$ c对于 Rectangle 中由 getBounds()返回的每个像素,$ c> true 。如果需要,可以通过 AffineTransform createTransformedShape()方法进行扩展。


Possible Duplicate:
How to calculate the area of a java.awt.geom.Area?

I don't know how to start on this and I hope someone can help ?

I have a closed java.awt.geom.GeneralPath and I try to measure the square ( area in squarepixel ( point ^ 2 ) ).

解决方案

Because GeneralPath implements Shape, you can count the number times contains() is true for each pixel in the Rectangle returned by getBounds(). If need be, you can scale via the createTransformedShape() method of AffineTransform.

这篇关于找到封闭的GeneralPath所包含的区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆