/*
 * @(#)ClosureMode.java    1.0  5 May 2003
 *
 * Copyright 2004
 * College of Computer and Information Science
 * Northeastern University
 * Boston, MA  02115
 *
 * The Java Power Tools software may be used for educational
 * purposes as long as this copyright notice is retained intact
 * at the top of all source files.
 *
 * To discuss possible commercial use of this software, 
 * contact Richard Rasala at Northeastern University, 
 * College of Computer and Information Science,
 * 617-373-2462 or rasala@ccs.neu.edu.
 *
 * The Java Power Tools software has been designed and built
 * in collaboration with Viera Proulx and Jeff Raab.
 *
 * Should this software be modified, the words "Modified from 
 * Original" must be included as a comment below this notice.
 *
 * All publication rights are retained.  This software or its 
 * documentation may not be published in any media either
 * in whole or in part without explicit permission.
 *
 * This software was created with support from Northeastern 
 * University and from NSF grant DUE-9950829.
 */

package edu.neu.ccs.gui;

/**
 * <P>Class <CODE>ClosureMode</CODE> encapsulates the choices for the closure
 * mode of a polygon or bezier cubic curve.</P>
 *
 * <P>Class <CODE>ClosureMode</CODE> cannot be instantiated outside of its own
 * package.</P>
 *
 * @author  Richard Rasala
 * @version 2.3
 * @since   2.3
 */
public abstract class ClosureMode {

    /** Default package-private constructor to prevent outside instantiation. */
    ClosureMode() {}
    
    
    /**
     * Returns the limit index of a graphics computation as a function of the
     * length of the associated vertex or tangent array.
     *
     * @param length the length of the associated vertex or tangent array
     * @return the limit index of a graphics computation
     */
    public abstract int limit(int length);
    
    
    /**
     * <P><CODE>CLOSED</CODE> is the <CODE>ClosureMode</CODE> corresponding
     * to a closed polygon or closed bezier curve, that is, limit(length)
     * returns length.
     *
     * @see #OPEN
     */
    public static final ClosureMode CLOSED
        = new ClosureMode() {
            public int limit(int length) { return length; }
        };
    
    
    /**
     * <P><CODE>OPEN</CODE> is the <CODE>ClosureMode</CODE> corresponding
     * to an open polygon or open bezier curve, that is, limit(length)
     * returns (length - 1).
     *
     * @see #CLOSED
     */
    public static final ClosureMode OPEN
        = new ClosureMode() {
            public int limit(int length) { return length - 1; }
        };
    
}
