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内容请搜索靠谱客的其他文章。
发表评论 取消回复