概述
import java.awt.Polygon; //导入方法依赖的package包/类
private SelectionShape translatePointsToRealSize(SelectionShape selectionPoint)
{
float resultH = (float) this.glitchArt.realHeight / this.glitchArt.lblImageRender.getHeight();
float resultW = (float) this.glitchArt.realWidth / this.glitchArt.lblImageRender.getWidth();
if(selectionPoint.getSelectionType() == SelectionTypes.FREEHAND && selectionPoint.isFreeHandSelectionConnected())
{
for(Point freeHandPoint: selectionPoint.getFreeHandSelectionPointList())
{
selectionPoint.addTranslatedFreeHandPoint(new Point(Math.round(freeHandPoint.x * resultW), Math.round(freeHandPoint.y * resultH)));
}
Polygon polygon = getPolygonFromPoints(selectionPoint.getFreeHandTranslatedSelectionPointList());
Rectangle boundedRegion = polygon.getBounds();
if(boundedRegion.height > this.glitchArt.realHeight - 1)
{
boundedRegion.height = this.glitchArt.realHeight - 1;
}
if(boundedRegion.y < 0)
{
boundedRegion.y = 0;
}
selectionPoint.setTranslatedRectangle(boundedRegion);
selectionPoint.setTranslatedPolygon(polygon);
}
else if(selectionPoint.getSelectionType() == SelectionTypes.RECTANGLE)
{
Point startPoint = new Point(Math.round(selectionPoint.getStartPoint().x * resultW), Math.round(selectionPoint.getStartPoint().y * resultW));
Point endPoint = new Point(Math.round(selectionPoint.getEndPoint().x * resultH), Math.round(selectionPoint.getEndPoint().y * resultH));
Rectangle selectionRectangle= new Rectangle(startPoint);
selectionRectangle.add(endPoint);
selectionPoint.setTranslatedRectangle(selectionRectangle);
}
return selectionPoint;
}
最后
以上就是狂野小熊猫为你收集整理的java polygon 用法_Java Polygon.getBounds方法代码示例的全部内容,希望文章能够帮你解决java polygon 用法_Java Polygon.getBounds方法代码示例所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复