⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 boundedshape.java

📁 利用java编写的paintbox小程序
💻 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 + -