001package com.hfg.svg.path;
002
003import com.hfg.util.collection.CollectionUtil;
004
005import java.awt.geom.Path2D;
006import java.awt.geom.Point2D;
007import java.util.List;
008
009//------------------------------------------------------------------------------
010/**
011 * Object representation of an SVG (Scalable Vector Graphics) path closePath ('z') command.
012 *
013 * @author J. Alex Taylor, hairyfatguy.com
014 */
015//------------------------------------------------------------------------------
016// com.hfg XML/HTML Coding Library
017//
018// This library is free software; you can redistribute it and/or
019// modify it under the terms of the GNU Lesser General Public
020// License as published by the Free Software Foundation; either
021// version 2.1 of the License, or (at your option) any later version.
022//
023// This library is distributed in the hope that it will be useful,
024// but WITHOUT ANY WARRANTY; without even the implied warranty of
025// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
026// Lesser General Public License for more details.
027//
028// You should have received a copy of the GNU Lesser General Public
029// License along with this library; if not, write to the Free Software
030// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
031//
032// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
033// jataylor@hairyfatguy.com
034//------------------------------------------------------------------------------
035
036public class SvgPathClosePathCmd extends SvgPathCmd
037{
038
039   //---------------------------------------------------------------------------
040   public SvgPathClosePathCmd()
041   {
042      super('Z');
043      setNumSteps(0);
044   }
045
046
047   //---------------------------------------------------------------------------
048   @Override
049   public SvgPathClosePathCmd setRawNumbers(List<Float> inValue)
050   {
051      if (CollectionUtil.hasValues(inValue))
052      {
053         throw new SvgPathDataException("No numbers should be specified for a closePath command!");
054      }
055
056      super.setRawNumbers(inValue);
057      return this;
058   }
059
060
061   //--------------------------------------------------------------------------
062   // From http://www.w3.org/TR/SVG/paths.html
063   //
064   // Close the current subpath by drawing a straight line from the current point to current subpath's initial point.
065   // Since the Z and z commands take no parameters, they have an identical effect.
066   public Point2D.Float draw(Path2D.Float inPolyline)
067   {
068      inPolyline.closePath();
069
070      // Return the last point.
071      return null;
072   }
073}