/*
 * @(#)Connector.java 5.1
 *
 */

package de.renew.draw.storables.ontology;

import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.io.Serializable;

/**
 * Connectors know how to locate a connection point on a figure.
 * A Connector knows its owning figure and can determine either
 * the start or the endpoint of a given connection figure. A connector
 * has a display box that describes the area of a figure it is
 * responsible for. A connector can be visible, but it doesn't have
 * to be.<br>
 * <hr>
 * <b>Design Patterns</b><P>
 * <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
 * <b><a href=../pattlets/sld004.htm>Strategy</a></b><br>
 * Connector implements the strategy to determine the connections points.<br>
 * <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
 * <b><a href=../pattlets/sld016.htm>Factory Method</a></b><br>
 * Connectors are created by the Figure's factory method connectorAt.
 * <hr>
 *
 * @see Figure#connectorAt
 * @see ConnectionFigure
 */
public interface Connector extends Serializable, Storable {

    /**
     * Finds the start point for the connection.
     * @param connection connection to find start point of
     * @return the start point of given connection
     */
    Point findStart(ConnectionFigure connection);

    /**
     * Finds the end point for the connection.
     * @param connection connection to find end point of
     * @return the end point of given connection
     */
    Point findEnd(ConnectionFigure connection);

    /**
     * Gets the connector's owner.
     * @return the connector's owner
     */
    Figure owner();

    /**
     * Gets the display box of the connector.
     * @return the display box of connector
     */
    Rectangle displayBox();

    /**
     * Tests if a point is contained in the connector.
     * @param x point on x-axis
     * @param y point on y-axis
     * @return boolean, {@code true} if point is contained
     */

    boolean containsPoint(int x, int y);

    /**
     * Draws this connector. Connectors don't have to be visible
     * and it is OK leave this method empty.
     * @param g graphics to draw into
     */

    void draw(Graphics g);
}