001package com.hfg.svg.filtereffect;
002
003import com.hfg.svg.AbstractSvgNode;
004import com.hfg.svg.SVG;
005import com.hfg.svg.SvgAttr;
006import com.hfg.xml.XMLTag;
007
008//------------------------------------------------------------------------------
009/**
010 Object representation of an SVG (Scalable Vector Graphics) 'feMorphology' filter effect tag.
011 <div>
012 From <a href='http://www.w3.org/TR/2003/REC-SVG11-20030114/filters.html#feMorphology'>
013 http://www.w3.org/TR/2003/REC-SVG11-20030114/filters.html#feMorphology</a>:
014 </div>
015 <div style='font-style:italic'>
016 <p>
017 "This filter primitive performs "fattening" or "thinning" of artwork. It is particularly
018 useful for fattening or thinning an alpha channel.
019 </p>
020 <p>
021 The dilation (or erosion) kernel is a rectangle with a width of 2*x-radius and a height of
022 2*y-radius. In dilation, the output pixel is the individual component-wise maximum of the
023 corresponding R,G,B,A values in the input image's kernel rectangle. In erosion, the output
024 pixel is the individual component-wise minimum of the corresponding R,G,B,A values in the
025 input image's kernel rectangle.
026 </p>
027 <p>
028 Frequently this operation will take place on alpha-only images, such as that produced by the
029 built-in input, SourceAlpha. In that case, the implementation might want to optimize the single
030 channel case.
031 </p>
032 <p>
033 If the input has infinite extent and is constant, this operation has no effect. If the input has
034 infinite extent and is a tile, the filter is evaluated with periodic boundary conditions.
035 </p>
036 <p>
037 Because 'feMorphology' operates on premultipied color values, it will always result in color
038 values less than or equal to the alpha channel."
039 </p>
040 </div>
041 @author J. Alex Taylor, hairyfatguy.com
042 */
043//------------------------------------------------------------------------------
044// com.hfg XML/HTML Coding Library
045//
046// This library is free software; you can redistribute it and/or
047// modify it under the terms of the GNU Lesser General Public
048// License as published by the Free Software Foundation; either
049// version 2.1 of the License, or (at your option) any later version.
050//
051// This library is distributed in the hope that it will be useful,
052// but WITHOUT ANY WARRANTY; without even the implied warranty of
053// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
054// Lesser General Public License for more details.
055//
056// You should have received a copy of the GNU Lesser General Public
057// License along with this library; if not, write to the Free Software
058// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
059//
060// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
061// jataylor@hairyfatguy.com
062//------------------------------------------------------------------------------
063
064public class SvgFeMorphology extends AbstractSvgNode
065{
066   //###########################################################################
067   // CONSTRUCTORS
068   //###########################################################################
069
070   //---------------------------------------------------------------------------
071   public SvgFeMorphology()
072   {
073      super(SVG.feMorphology);
074   }
075
076   //---------------------------------------------------------------------------
077   public SvgFeMorphology(XMLTag inXMLTag)
078   {
079      this();
080      initFromXMLTag(inXMLTag);
081   }
082
083   //###########################################################################
084   // PUBLIC METHODS
085   //###########################################################################
086
087
088   //---------------------------------------------------------------------------
089   public SvgFeMorphology setIn(FeInput inValue)
090   {
091      setAttribute(SvgAttr.in, inValue);
092      return this;
093   }
094
095
096   //---------------------------------------------------------------------------
097   /**
098    A keyword indicating whether to erode (i.e., thin) or dilate (fatten) the source graphic.
099    */
100   public SvgFeMorphology setOperator(MorphologyOperator inValue)
101   {
102      setAttribute(SvgAttr.operator, inValue);
103      return this;
104   }
105
106
107   //---------------------------------------------------------------------------
108   /**
109    The radius (or radii) for the operation. If two &lt;number&gt;s are provided, the first
110    number represents a x-radius and the second value represents a y-radius. If one
111    number is provided, then that value is used for both X and Y. The values are in
112    the coordinate system established by attribute primitiveUnits on the 'filter' element.
113    A negative value is an error. A value of zero disables the effect of the given filter
114    primitive (i.e., the result is a transparent black image).
115    If the attribute is not specified, then the effect is as if a value of 0 were specified.
116    */
117   public SvgFeMorphology setRadius(float inValue)
118   {
119      return setRadius(inValue + "");
120   }
121   //---------------------------------------------------------------------------
122   /**
123    The radius (or radii) for the operation. If two &lt;number&gt;s are provided, the first
124    number represents a x-radius and the second value represents a y-radius. If one
125    number is provided, then that value is used for both X and Y. The values are in
126    the coordinate system established by attribute primitiveUnits on the 'filter' element.
127    A negative value is an error. A value of zero disables the effect of the given filter
128    primitive (i.e., the result is a transparent black image).
129    If the attribute is not specified, then the effect is as if a value of 0 were specified.
130    */
131   public SvgFeMorphology setRadius(String inValue)
132   {
133      setAttribute(SvgAttr.radius, inValue);
134      return this;
135   }
136
137
138   //---------------------------------------------------------------------------
139   public SvgFeMorphology setColorInterpolationFilters(ColorInterpolationFilters inValue)
140   {
141      setAttribute(SvgAttr.colorInterpolationFilters, inValue);
142      return this;
143   }
144
145   //---------------------------------------------------------------------------
146   public SvgFeMorphology setHeight(int inValue)
147   {
148      setAttribute(SvgAttr.height, inValue);
149      return this;
150   }
151
152   //---------------------------------------------------------------------------
153   public SvgFeMorphology setHeight(String inValue)
154   {
155      setAttribute(SvgAttr.height, inValue);
156      return this;
157   }
158
159   //---------------------------------------------------------------------------
160   public SvgFeMorphology setResult(String inValue)
161   {
162      setAttribute(SvgAttr.result, inValue);
163      return this;
164   }
165
166   //---------------------------------------------------------------------------
167   public SvgFeMorphology setWidth(int inValue)
168   {
169      setAttribute(SvgAttr.width, inValue);
170      return this;
171   }
172
173   //---------------------------------------------------------------------------
174   public SvgFeMorphology setWidth(String inValue)
175   {
176      setAttribute(SvgAttr.width, inValue);
177      return this;
178   }
179
180   //---------------------------------------------------------------------------
181   public SvgFeMorphology setX(int inValue)
182   {
183      setAttribute(SvgAttr.x, inValue);
184      return this;
185   }
186
187   //---------------------------------------------------------------------------
188   public SvgFeMorphology setX(String inValue)
189   {
190      setAttribute(SvgAttr.x, inValue);
191      return this;
192   }
193
194
195   //---------------------------------------------------------------------------
196   public SvgFeMorphology setY(int inValue)
197   {
198      setAttribute(SvgAttr.y, inValue);
199      return this;
200   }
201
202   //---------------------------------------------------------------------------
203   public SvgFeMorphology setY(String inValue)
204   {
205      setAttribute(SvgAttr.y, inValue);
206      return this;
207   }
208   
209}