?? boundedshape.java
字號:
/*
* BoundedShape.java
*
* Created on 2007年4月23日, 下午11:59
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package paintbox;
/**
*
* @author fly
*/
import java.awt.*;
public abstract class BoundedShape extends Shape{
/** Creates a new instance of BoundedShape */
protected Point upperLeft; //畫圖原點
protected int width, height; //寬和高
protected Color fillColor;
protected boolean filled;
public BoundedShape (Color color, Point corner, int wide, int high)
{
fillColor=null;
filled=false;
strokeColor = color;
upperLeft = corner;
width = wide;
height = high;
}
public void setFilled(Color fillColor)
{
filled=true;
this.fillColor=fillColor;
}
public void setUnFilled()
{
filled=false;
fillColor=null;
}
public void setShape (Point firstPt, Point currentPt) //畫圖(firstPt與current確定兩個點
{
if (firstPt.x <= currentPt.x)
if (firstPt.y <= currentPt.y)
upperLeft = firstPt;
else
upperLeft = new Point (firstPt.x, currentPt.y);
else
if (firstPt.y <= currentPt.y)
upperLeft = new Point (currentPt.x, firstPt.y);
else
upperLeft = currentPt;
width = Math.abs (currentPt.x - firstPt.x);
height = Math.abs (currentPt.y - firstPt.y);
}
public boolean isSlected(Point point)
{
boolean s=false;
s=((point.x>=upperLeft.x)&&(point.x<=(upperLeft.x+width))) &&
((point.y>=upperLeft.y)&&(point.y<=(upperLeft.y+height)));
return s;
}
public void positionChanged(int xChanged, int yChanged)
{
upperLeft.x+=xChanged;
upperLeft.y+=yChanged;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -