Java图形填充实例.rar

时间:2022-07-30 05:18:59
【文件属性】:

文件名称:Java图形填充实例.rar

文件大小:11KB

文件格式:RAR

更新时间:2022-07-30 05:18:59

Java源码-初学实例

JAva对绘制出的图形进行填充的一个例子,包括了图形绘制和图形填充两个模块功能的演示,   super.paintComponent(g); //调用父类的绘制组件方法   Graphics2D g2D = (Graphics2D)g;   setBackground(Color.white);   setForeground(Color.black);   int charH = 16; //最大字符高度   int gridW = getWidth() / 5; //绘图网格宽度   int gridH = getHeight() / 4; //绘图网格高度   int posX = 2; //各图形绘制位置的x坐标   int posY = 2; //各图形位置的y坐标   int strY = gridH - 7; //字符串绘制位置的y坐标   int w = gridW - 2 * posX; //图形的宽度   int h = strY - charH - posY; //图形的高度   int cirlceD = Math.min(w, h); //圆的直径   Shape[][] shape = new Shape[2][5];   shape[0][0] = new Line2D.Float(0,0,w,h); //直线   shape[0][1] = new Rectangle2D.Double(0, 0, w, h); //矩形   shape[0][2] = new RoundRectangle2D.Float(0, 0, w, h,20,20); //圆角矩形   shape[0][3] = new Ellipse2D.Float(0,0,cirlceD, cirlceD); //圆   shape[0][4] = new Ellipse2D.Float(0, 0, w, h); //椭圆   shape[1][0] = new Arc2D.Float(0,0,w,h,45,225, Arc2D.OPEN); //开弧   shape[1][1] = new Arc2D.Float(0,0,w,h,45,225, Arc2D.CHORD); //弓形   shape[1][2] = new Arc2D.Float(0,0,w,h,45,225, Arc2D.PIE); //饼形   shape[1][3] = new QuadCurve2D.Double(0,0,w,h/6,w,h); //二次曲线   shape[1][4] = new CubicCurve2D.Double(0,0,w/2,h,w, h/2,w,h); //三次曲线


【文件预览】:
codesc.net
----jAVA常用图形的绘制与填充()
--------53-1.bmp(352KB)
--------GraphicsShapeDemo$DrawPanel.class(3KB)
--------GraphicsShapeDemo.class(795B)
--------GraphicsShapeDemo.java(3KB)

网友评论