/*
 * @(#)PolygonShape.java    2.4.0   6 September 2005
 *
 * Copyright 2005
 * 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;

import edu.neu.ccs.util.*;

import java.awt.*;
import java.awt.geom.*;
import java.beans.*;


/**
 * <p>Class <code>PolygonShape</code> defines a polygon using vertex
 * data.</p>
 *
 * <p>This class is a <code>BaseVertexShape</code> whose
 * <code>Path.Strategy</code> is fixed to be <code>Path.POLYGON</code>.
 *
 * <p>This class does not use the tangent array inherited from
 * <code>BaseShape</code>.</p>
 *
 * <p>To avoid confusion with the class <code>java.awt.Polygon</code>,
 * we name this class <code>PolygonShape</code>.  Our version of a
 * polygon is more general than the Java class since the internal
 * coordinates are floating point and since the user may choose the
 * closure mode and winding rule.</p>
 *
 * @author  Richard Rasala
 * @version 2.4.0
 * @since   2.4.0
 */
public class PolygonShape
    extends BaseVertexShape
{
    /** Bound property name to set the vertex data. */
    public static final String SET_VERTEX_DATA      = "set.vertex.data";
    
    /** Bound property name to set one vertex. */
    public static final String SET_VERTEX           = "set.vertex";
    
    /** Bound property name to add one vertex. */
    public static final String ADD_VERTEX           = "add.vertex";
    
    /** Bound property name to remove one vertex. */
    public static final String REMOVE_VERTEX        = "remove.vertex";
    

    /**
     * <p>The default constructor that creates an empty polygon
     * with the following defaults.</p>
     *
     * <ul>
     *   <li><code>ClosureMode.CLOSED</code></li>
     *   <li><code>WindingRule.WIND_NON_ZERO</code></li>
     * </ul>
     */
    public PolygonShape() {
        this(null, null, null);
    }
    
    
    /**
     * <p>The constructor that creates a polygon with the given vertex array
     * and the following defaults.</p>
     *
     * <ul>
     *   <li><code>ClosureMode.CLOSED</code></li>
     *   <li><code>WindingRule.WIND_NON_ZERO</code></li>
     * </ul>
     *
     * @param vertex the vertex data
     */
    public PolygonShape(float[][] vertex)
    {
        this(vertex, null, null);
    }
    
    
    /**
     * <p>The constructor that creates a polygon with the given vertex array,
     * the given closure mode, and the following default.</p>
     *
     * <ul>
     *   <li><code>WindingRule.WIND_NON_ZERO</code></li>
     * </ul>
     *
     * @param vertex      the vertex data
     * @param closuremode the closure mode
     */
    public PolygonShape(float[][] vertex, ClosureMode closuremode)
    {
        this(vertex, closuremode, null);
    }
    
    
    /**
     * <p>The constructor that creates a polygon with the given vertex array,
     * the given winding rule, and the following default.</p>
     *
     * <ul>
     *   <li><code>ClosureMode.CLOSED</code></li>
     * </ul>
     *
     * @param vertex      the vertex data
     * @param windingrule the winding rule
     */
    public PolygonShape(float[][] vertex, WindingRule windingrule)
    {
        this(vertex, null, windingrule);
    }
    
    
    /**
     * <p>The constructor that creates a polygon with the given vertex array,
     * the given closure mode, and the given winding rule.</p>
     *
     * @param vertex          the vertex data
     * @param closuremode     the closure mode
     * @param windingrule     the winding rule
     */
    public PolygonShape
        (float[][]        vertex,
         ClosureMode      closuremode,
         WindingRule      windingrule)
    {
        super.setPathStrategy(Path.POLYGON);
        setVertexData(vertex);
        setClosureMode(closuremode);
        setWindingRule(windingrule);
    }
    
    
    /**
     * <p>Since the <code>Path.Strategy</code> of this class is fixed
     * to be <code>Path.POLYGON</code>, this method overrides the
     * inherited method to do nothing.</p>
     */
    public final void setPathStrategy(Path.Strategy pathstrategy) { }
    
}

