JAVA注释帮忙加一下,越多行越好~
尽量多的加注释使行数增加,顺便可以修改下程序,时间紧迫,谢谢啦!!!
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javadraw;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.geom.AffineTransform;
/**
*
* @author Anj
*/
//所有对象的父类 存储共享的类型信息
public abstract class RectBoundedShape implements IShape {
protected Color fore, back;
protected int isFilled;
protected Stroke stroke;
public AffineTransform at;
public float startX, startY, endX, endY;
protected String text = new String();
public Font f = new Font("Arial", 0, 50);
protected RectBoundedShape(int fi, Color c, Color d, Stroke s, int x, int y,String textcontent,Font font) {
fore = c;
back = d;
isFilled = fi;
stroke = s;
startX = endX = x;
startY = endY = y;
at = new AffineTransform();
text = textcontent;
f = font;
}
protected RectBoundedShape(){
at = new AffineTransform();
}
public void processCursorEvent(MouseEvent e) {
int x = e.getX();
int y = e.getY();
if (e.isShiftDown()) {
regulateShape(x, y);
} else {
endX = x;
endY = y;
}
}
protected void regulateShape(int x, int y) {
float w = x - startX;
float h = y - startY;
int s = (int) Math.min(Math.abs(w), Math.abs(h));
if (s == 0) {
endX = startX;
endY = startY;
} else {
endX = startX + s * (w / Math.abs(w));
endY = startY + s * (h / Math.abs(h));
}
}
//写入对象 把对象信息写入字符串
public String getShapeData() {
int si = 0;
for (int i = 0; i < DrawingBoard.STROKES.length; i++) {
if (stroke == DrawingBoard.STROKES[i]) {
si = i;
break;
}
}
StringBuffer buffer = new StringBuffer();
buffer.append(isFilled);
buffer.append(";");
buffer.append(fore.getRGB());
buffer.append(";");
buffer.append(back.getRGB());
b
uffer.append(";");
buffer.append(si);
buffer.append(";");
buffer.append(startX);
buffer.append(";");
buffer.append(startY);
buffer.append(";");
buffer.append(endX);
buffer.append(";");
buffer.append(endY);
buffer.append(";");
buffer.append(text);
buffer.append(";");
buffer.append(f.getFontName());
buffer.append(";");
buffer.append((int)f.getStyle());
buffer.append(";");
buffer.append(f.getSize());
buffer.append(";");
buffer.append(at.getScaleX());
buffer.append(";");
buffer.append(at.getScaleY());
buffer.append(";");
buffer.append(at.getShearX());
buffer.append(";");
buffer.append(at.getShearY());
buffer.append(";");
buffer.append(at.getTranslateX());
buffer.append(";");
buffer.append(at.getTranslateY());
return buffer.toString();
}
//从字符串中读取对象信息
public void setShapeData(String data) throws Exception {
String[] splits = data.split(";");
isFilled = Integer.parseInt(splits[0]);
fore = new Color(Integer.parseInt(splits[1]));
back = new Color(Integer.parseInt(splits[2]));
stroke = DrawingBoard.STROKES[Integer.parseInt(splits[3])];
startX = Float.parseFloat(splits[4]);
startY = Float.parseFloat(splits[5]);
endX = Float.parseFloat(splits[6]);
endY = Float.parseFloat(splits[7]);
text = new String(splits[8]);
f = new Font(splits[9], Integer.parseInt(splits[10]), Integer.parseInt(splits[11]));
at = new AffineTransform(Double.parseDouble(splits[12]),Double.parseDouble(splits[15]),Double.parseDouble(splits[14]),
Double.parseDouble(splits[13]),Double.parseDouble(splits[16]),Double.parseDouble(splits[17]));
}
}