• 大小: 22KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-12
  • 语言: Java
  • 标签: Graphics  2D  

资源简介

GUI界面 实现了简单的画线 圆 矩形 以及颜色 供学习参考使用

资源截图

代码片段和文件信息

package cn.control;

import java.awt.Graphics;

import cn.model.Circle;
import cn.model.GraphicsList;
import cn.model.Line;
import cn.model.Rect;

public class Control {
private GraphicsList gList = new GraphicsList();
public void drawLine(int x1 int y1 int x2 int y2Graphics g){
g.drawLine(x1y1x2y2);
gList.add(new Line(x1y1x2y2g.getColor()));
}
public void drawCircle(int x1 int y1 int x2 int y2Graphics g){
int width = Math.abs(x2 - x1);
int high = Math.abs(y2 - y1);
if(x2 - x1 < 0&y2 - y1 < 0){
x1 = x1 - width;
y1 = y1 - high;
}
g.drawOval(x1 y1 width high);
gList.add(new Circle(x1 y1 width highg.getColor()));
}
public void drawRect(int x1 int y1 int x2 int y2Graphics g) {
int width = Math.abs(x2 - x1);
int high = Math.abs(y2 - y1);
if(x2 - x1 < 0&y2 - y1 < 0){
x1 = x1 - width;
y1 = y1 - high;
}
g.drawRect(x1 y1 width high);
gList.add(new Rect(x1 y1 width highg.getColor()));
}
public GraphicsList getgList() {
return gList;
}

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-05-22 15:50  JPainter\
     文件         232  2015-05-22 06:38  JPainter\.classpath
     文件         384  2015-05-22 06:38  JPainter\.project
     目录           0  2015-05-23 08:19  JPainter\bin\
     目录           0  2015-05-23 08:19  JPainter\bin\cn\
     目录           0  2015-05-23 08:19  JPainter\bin\cn\control\
     文件        1640  2015-05-23 09:01  JPainter\bin\cn\control\Control.class
     文件        3036  2015-05-23 09:04  JPainter\bin\cn\control\UserControl.class
     目录           0  2015-05-23 08:19  JPainter\bin\cn\main\
     文件        1224  2015-05-23 08:19  JPainter\bin\cn\main\Main.class
     目录           0  2015-05-23 08:19  JPainter\bin\cn\model\
     文件        1371  2015-05-23 08:19  JPainter\bin\cn\model\Circle.class
     文件         282  2015-05-23 08:19  JPainter\bin\cn\model\GraphicsList.class
     文件        1350  2015-05-23 08:19  JPainter\bin\cn\model\Line.class
     文件        1365  2015-05-23 08:19  JPainter\bin\cn\model\Rect.class
     目录           0  2015-05-23 08:19  JPainter\bin\cn\ui\
     文件        1409  2015-05-23 08:38  JPainter\bin\cn\ui\Painterframe.class
     文件        2163  2015-05-23 08:19  JPainter\bin\cn\ui\UIButton.class
     文件        2164  2015-05-23 08:19  JPainter\bin\cn\ui\UICanvas.class
     目录           0  2015-05-22 16:55  JPainter\icon\
     文件         142  2015-05-22 15:43  JPainter\icon\Black.png
     文件         162  2015-05-22 15:43  JPainter\icon\Blue.png
     文件         281  2015-05-22 15:50  JPainter\icon\Circle.png
     文件         161  2015-05-22 16:39  JPainter\icon\Cyan.png
     文件         162  2015-05-22 15:43  JPainter\icon\Gray.png
     文件         162  2015-05-22 15:43  JPainter\icon\Green.png
     文件         241  2015-05-22 15:50  JPainter\icon\Line.png
     文件         162  2015-05-22 15:43  JPainter\icon\Pink.png
     文件         187  2015-05-22 15:50  JPainter\icon\Rect.png
     文件         162  2015-05-22 15:43  JPainter\icon\Red.png
     文件         161  2015-05-22 15:43  JPainter\icon\Yellow.png
............此处省略16个文件信息

评论

共有 条评论