Back to index

moin  1.9.0~rc2
AbstractHandle.java
Go to the documentation of this file.
00001 /*
00002  * @(#)AbstractHandle.java 5.1
00003  *
00004  */
00005 
00006 package CH.ifa.draw.standard;
00007 
00008 import CH.ifa.draw.framework.*;
00009 import java.awt.*;
00010 
00018 public abstract class AbstractHandle implements Handle {
00019 
00023     public static final int HANDLESIZE = 8;
00024     private Figure fOwner;
00025 
00029     public AbstractHandle(Figure owner) {
00030         fOwner = owner;
00031     }
00032 
00037     public abstract Point locate();
00038 
00047     public void invokeStart(int  x, int  y, Drawing drawing) { }
00048 
00058     public void invokeStart(int  x, int  y, DrawingView view) {
00059         invokeStart(x, y, view.drawing());
00060     }
00061 
00070     public void invokeStep (int dx, int dy, Drawing drawing) { }
00071 
00079     public void invokeStep (int x, int y, int anchorX, int anchorY, DrawingView view) {
00080         invokeStep(x-anchorX, y-anchorY, view.drawing());
00081     }
00082 
00090     public void invokeEnd(int x, int y, int anchorX, int anchorY, DrawingView view) {
00091         invokeEnd(x-anchorX, y-anchorY, view.drawing());
00092     }
00093 
00100     public void invokeEnd  (int dx, int dy, Drawing drawing) { }
00101 
00105     public Figure owner() {
00106         return fOwner;
00107     }
00108 
00112     public Rectangle displayBox() {
00113         Point p = locate();
00114         return new Rectangle(
00115                 p.x - HANDLESIZE / 2,
00116                 p.y - HANDLESIZE / 2,
00117                 HANDLESIZE,
00118                 HANDLESIZE);
00119     }
00120 
00124     public boolean containsPoint(int x, int y) {
00125         return displayBox().contains(x, y);
00126     }
00127 
00131     public void draw(Graphics g) {
00132         Rectangle r = displayBox();
00133 
00134         g.setColor(Color.white);
00135         g.fillRect(r.x, r.y, r.width, r.height);
00136 
00137         g.setColor(Color.black);
00138         g.drawRect(r.x, r.y, r.width, r.height);
00139     }
00140 }
00141 
00142