资源简介
自己用eclipse做的,面向对象,不错的画图~包括直线,矩形,圆,颜色改变和对图像的变换操作。
代码片段和文件信息
package cn.edu.nju.software.grapheditor;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.util.ArrayList;
import cn.edu.nju.software.grapheditor.shape.Shape;
public class Drawing {
Color mycolor;
boolean q=false;
public int i=0;
public int[]amount=new int[100];
public ArrayList allshapes=new ArrayList();
public ArrayList allshapes2=new ArrayList();
public ArrayList allshapes3=new ArrayList();
public Color getcolor(){
return mycolor;
}
public void setcolor(Color a){
this.mycolor=a;
}
public void addshape(Shape a){
allshapes.add(a);
}
public void addshape2(int iShape a){
allshapes.add(ia);
}
public void delete(Shape a){
allshapes.remove(a);
}
public Drawing(Color initialColor) {
mycolor=initialColor;// Your code goes here
}
public Shape getFrontmostContainer(Point p) {
int size=allshapes.size();
for(int i=size-1;i>=0;i--){
if(allshapes.get(i).containsPoint(p)==true){
return allshapes.get(i);
}
}
// Your code goes here
return null;
}
public void draw(Graphics g) {
for(Shape s:allshapes){
g.setColor(s.getcolor());
s.drawShape(g);
}
// Your code goes here
}
public void front(Shape a){
allshapes.remove(a);
allshapes.add(a);
}
public void back(Shape a){
allshapes.remove(a);
allshapes.add(0a);
}
public void move(Shape sPoint aPoint b){
int deltaX=b.x-a.x;
int deltaY=b.y-a.y;
s.move(deltaX deltaY);
}
public void copy() throws CloneNotSupportedException{
int size=allshapes.size();
if(i>=0){
amount[i]=size;
for(int i=size-1;i>=0;i--){
allshapes2.add(allshapes.get(i).clone());
}
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 387 2009-05-14 20:27 hw2-project\.project
文件 232 2009-05-14 20:27 hw2-project\.classpath
文件 3685 2009-05-31 02:15 hw2-project\doc\Explanation
文件 1164 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\Editor$RoundRectButtonListener.class
文件 1647 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\Editor$BlueButtonListener.class
文件 1139 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\Editor$CopyButtonListener.class
文件 1166 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\Editor$ColorIndicator.class
文件 1149 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\Editor$DeleteButtonListener.class
文件 1652 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\Editor$GreenButtonListener.class
文件 1142 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\Editor$LineButtonListener.class
文件 2585 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\Editor$CanvasPanel.class
文件 1139 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\Editor$MoveButtonListener.class
文件 8089 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\Editor.class
文件 1271 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\Editor$UndoButtonListener.class
文件 1642 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\Editor$RedButtonListener.class
文件 1144 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\Editor$RectButtonListener.class
文件 1159 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\Editor$ExchangeButtonListener.class
文件 1144 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\Editor$FrontButtonListener.class
文件 1139 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\Editor$BackButtonListener.class
文件 1154 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\Editor$ReshapeButtonListener.class
文件 1139 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\Editor$OvalButtonListener.class
文件 3287 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\Drawing.class
文件 1570 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\cmd\UndoCmd.class
文件 1371 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\cmd\SegmentCmd.class
文件 1387 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\cmd\RoundRectCmd.class
文件 1759 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\cmd\ReshapeCmd.class
文件 1382 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\cmd\RectangleCmd.class
文件 1357 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\cmd\OvalCmd.class
文件 1389 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\cmd\MoveCmd.class
文件 1226 2009-12-06 19:30 hw2-project\bin\cn\edu\nju\software\grapheditor\cmd\FrontCmd.class
............此处省略53个文件信息
评论
共有 条评论