我是靠谱客的博主 狂野小熊猫,最近开发中收集的这篇文章主要介绍java polygon 用法_Java Polygon.getBounds方法代码示例,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

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方法代码示例所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(54)

评论列表共有 0 条评论

立即
投稿
返回
顶部