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

package CH.ifa.draw.figures;

import java.awt.Point;

import CH.ifa.draw.standard.AbstractLocator;
import de.renew.draw.storables.ontology.Figure;

/**
 * A poly line figure consists of a list of points.
 * It has an optional line decoration at the start and end.
 * <p>
 * {@link LineDecoration}
 * @deprecated This class is not to be used externally and will later be hidden.
 */
@Deprecated(since = "5.0", forRemoval = true)
@SuppressWarnings("removal")
class PolyLineLocator extends AbstractLocator {
    final int _index;

    public PolyLineLocator(int index) {
        _index = index;
    }

    @Override
    public Point locate(Figure owner) {
        PolyLineable plf = (PolyLineable) owner;

        // guard against changing PolyLineFigures -> temporary hack
        if (_index < plf.pointCount()) {
            return ((PolyLineable) owner).pointAt(_index);
        }
        return new Point(0, 0);
    }
}