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

📄 abstractconnector.java

📁 开源(Open Source)项目JHotDraw的文档和源程序
💻 JAVA
字号:
/*
 * @(#)AbstractConnector.java 5.2
 *
 */

package CH.ifa.draw.standard;

import java.awt.*;
import java.io.IOException;
import CH.ifa.draw.framework.*;
import CH.ifa.draw.util.*;

/**
 * AbstractConnector provides default implementation for
 * the Connector interface.
 * @see Connector
 */
public abstract class AbstractConnector implements Connector {
    /**
     * the owner of the connector
     */
    private Figure      fOwner;

    /*
     * Serialization support.
     */
    private static final long serialVersionUID = -5170007865562687545L;
    private int abstractConnectorSerializedDataVersion = 1;

    /**
     * Constructs a connector that has no owner. It is only
     * used internally to resurrect a connectors from a
     * StorableOutput. It should never be called directly.
     */
    public AbstractConnector() {
        fOwner = null;
    }

    /**
     * Constructs a connector with the given owner figure.
     */
    public AbstractConnector(Figure owner) {
        fOwner = owner;
    }

    /**
     * Gets the connector's owner.
     */
    public Figure owner() {
        return fOwner;
    }

    public Point findStart(ConnectionFigure connection) {
        return findPoint(connection);
    }

    public Point findEnd(ConnectionFigure connection) {
        return findPoint(connection);
    }

    /**
     * Gets the connection point. Override when the connector
     * does not need to distinguish between the start and end
     * point of a connection.
     */
    protected Point findPoint(ConnectionFigure connection) {
        return Geom.center(displayBox());
    }

    /**
     * Gets the display box of the connector.
     */
    public Rectangle displayBox() {
        return owner().displayBox();
    }

    /**
     * Tests if a point is contained in the connector.
     */
    public boolean containsPoint(int x, int y) {
        return owner().containsPoint(x, y);
    }

    /**
     * Draws this connector. By default connectors are invisible.
     */
    public void draw(Graphics g) {
        // invisible by default
    }

    /**
     * Stores the connector and its owner to a StorableOutput.
     */
    public void write(StorableOutput dw) {
        dw.writeStorable(fOwner);
    }

    /**
     * Reads the connector and its owner from a StorableInput.
     */
    public void read(StorableInput dr) throws IOException {
        fOwner = (Figure)dr.readStorable();
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -