使用GeneralPath类追加 [英] append using GeneralPath class

查看:115
本文介绍了使用GeneralPath类追加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试以下代码:

i have been trying out the following code:

GeneralPath general = new GeneralPath(
				new Rectangle(super.singleWidth,super.singleHeight*3));
		general.append(new Rectangle
				(startWidth, super.singleHeight*3,
				(int)(super.singleWidth/1.3), super.getHeight()-super.singleHeight*3),
				true);
		int[] x = new int[3];
		int[] y = new int[3];
		x[0] = 0;
		y[0] = 0;
		x[1] = startWidth;
		y[1] = 0;
		x[2] = 0;
		x[2] = super.singleHeight*3;
//		general.append(new Polygon(polygonX, polygonY, 4), true);
		general.append(new Polygon(x, y, 3), true);



在其他地方声明polygonX和polygonY.它们是大小为4的两个数组.

我在最后两行中遇到问题.当我尝试"general.append(new Polygon(polygonX,polygonY,4),true);"时它减去形状而不是附加
它!如果我使用第二行"general.append(new Polygon(x,y,3),true);".我没什么区别.
我的意图是添加第一个多边形,或减去第二个多边形.



polygonX and polygonY are declared else where. They are two arrays of size 4.

I am having problem in the last two lines. When I try out "general.append(new Polygon(polygonX, polygonY, 4), true);" It subtracts the shape instead of appending
it! If I use the second line "general.append(new Polygon(x, y, 3), true);". I find no difference.
My intention is either to add the first polygon, or to subtract the second.

推荐答案

如果将Polygon设置为null,如
,会发生什么情况? new Polygon(x, y, null)??


另外,请检查 [
what happens if you set the Polygon with argument null like
new Polygon(x, y, null) ??


Also please check the doc to the GeneralPath.append()[^]

The boolean for connect is suspicious to me.


因为它们都是要加入的行,所以我不需要加入.我通过对整个对象使用一个多边形解决了这个问题.但是我仍然不明白为什么这段代码无法正常工作.
since they were all lines to be joined i did not need to join. I solved the problem by using one polygon for the whole thing. But i still don''t get why this code was not working.


这篇关于使用GeneralPath类追加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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