Back to index

moin  1.9.0~rc2
AbstractConnector.java
Go to the documentation of this file.
00001 /*
00002  * @(#)AbstractConnector.java 5.1
00003  *
00004  */
00005 
00006 package CH.ifa.draw.standard;
00007 
00008 import java.awt.*;
00009 import java.io.*;
00010 import CH.ifa.draw.framework.*;
00011 import CH.ifa.draw.util.*;
00012 
00018 public abstract class AbstractConnector implements Connector {
00022     private Figure      fOwner;
00023 
00024     /*
00025      * Serialization support.
00026      */
00027     private static final long serialVersionUID = -5170007865562687545L;
00028     private int abstractConnectorSerializedDataVersion = 1;
00029 
00035     public AbstractConnector() {
00036         fOwner = null;
00037     }
00038 
00042     public AbstractConnector(Figure owner) {
00043         fOwner = owner;
00044     }
00045 
00049     public Figure owner() {
00050         return fOwner;
00051     }
00052 
00053     public Point findStart(ConnectionFigure connection) {
00054         return findPoint(connection);
00055     }
00056 
00057     public Point findEnd(ConnectionFigure connection) {
00058         return findPoint(connection);
00059     }
00060 
00066     protected Point findPoint(ConnectionFigure connection) {
00067         return Geom.center(displayBox());
00068     }
00069 
00073     public Rectangle displayBox() {
00074         return owner().displayBox();
00075     }
00076 
00080     public boolean containsPoint(int x, int y) {
00081         return owner().containsPoint(x, y);
00082     }
00083 
00087     public void draw(Graphics g) {
00088         // invisible by default
00089     }
00090 
00094     public void write(StorableOutput dw) {
00095         dw.writeStorable(fOwner);
00096     }
00097 
00098     public String getMap() {
00099        return "";
00100     }
00101 
00105     public void read(StorableInput dr) throws IOException {
00106         fOwner = (Figure)dr.readStorable();
00107     }
00108 
00109 }
00110