?? polyline.java
字號:
package test.paint;
import java.awt.*;
/**
*PolyLine類,實現鉛筆與其畫刷的功能
* 作者:鐘雯
* 初始時間:2007 5-14
* 最后一次修改時間:2007 6-16
*/
public class PolyLine extends ResShape {
/**
* 有參構造函數
*/
public PolyLine(Color c, Stroke s, int x, int y, int z,int f)
{
super(c, s, x, y, z, f );
}
/**
* 無參構造函數
*/
public PolyLine() {
super();
}
/**
* Draw method
* 通過獲取points數組中記錄的元素,畫出鼠標移動路徑
* 特別分為兩種情況,便于畫刷的模式選擇
*/
public void draw(Graphics2D g) {
g.setColor(color);
g.setStroke(stroke);
//獲取鼠標移動時的點的軌跡
int[][] points = pointsSet.getPoints();
if (points == null)
return;
//點的個數
int s = points[0].length;
//當只有一個點的情況
if (s == 1) {
int x = points[0][0];
int y = points[1][0];
if(flag==1)
g.drawLine(x, y, x, y);
else
g.fillOval(x, y, radius, radius);
}
else {
if(flag==1)
{
//當選擇模式為方形時,調用該方法
g.drawPolyline(points[0], points[1], s);
}
else
{
//當選擇模式為橢圓時,調用該方法
for(int i=0; i<s; i++)
g.fillOval(points[0][i], points[1][i], radius, radius);
}
}
}
public void setIsFill(boolean x) {
// TODO Auto-generated method stub
}
public void setColor(Color col) {
// TODO Auto-generated method stub
}
public boolean intersects(double x, double y, double w, double h) {
// TODO Auto-generated method stub
return false;
}
public Rectangle getBounds() {
// TODO Auto-generated method stub
return null;
}
public int getX() {
// TODO Auto-generated method stub
return 0;
}
public int getY() {
// TODO Auto-generated method stub
return 0;
}
public boolean isImage() {
// TODO Auto-generated method stub
return false;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -