001package com.hfg.svg; 002 003import com.hfg.svg.filtereffect.*; 004import com.hfg.util.collection.CollectionUtil; 005import com.hfg.xml.XMLAttribute; 006import com.hfg.xml.XMLTag; 007import com.hfg.xml.XMLizable; 008 009import java.awt.*; 010import java.util.regex.Matcher; 011 012//------------------------------------------------------------------------------ 013/** 014 * Object representation of an SVG (Scalable Vector Graphics) 'filter' tag. 015 * 016 * @author J. Alex Taylor, hairyfatguy.com 017 */ 018//------------------------------------------------------------------------------ 019// com.hfg XML/HTML Coding Library 020// 021// This library is free software; you can redistribute it and/or 022// modify it under the terms of the GNU Lesser General Public 023// License as published by the Free Software Foundation; either 024// version 2.1 of the License, or (at your option) any later version. 025// 026// This library is distributed in the hope that it will be useful, 027// but WITHOUT ANY WARRANTY; without even the implied warranty of 028// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 029// Lesser General Public License for more details. 030// 031// You should have received a copy of the GNU Lesser General Public 032// License along with this library; if not, write to the Free Software 033// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 034// 035// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 036// jataylor@hairyfatguy.com 037//------------------------------------------------------------------------------ 038 039public class SvgFilter extends AbstractSvgNode implements SvgNode 040{ 041 042 //########################################################################## 043 // CONSTRUCTORS 044 //########################################################################## 045 046 //--------------------------------------------------------------------------- 047 public SvgFilter() 048 { 049 super(SVG.filter); 050 } 051 052 //--------------------------------------------------------------------------- 053 public SvgFilter(XMLTag inXMLTag) 054 { 055 this(); 056 057 inXMLTag.verifyTagName(getTagName()); 058 059 if (CollectionUtil.hasValues(inXMLTag.getAttributes())) 060 { 061 for (XMLAttribute attr : inXMLTag.getAttributes()) 062 { 063 setAttribute(attr.clone()); 064 } 065 } 066 067 java.util.List<XMLTag> subtags = inXMLTag.getSubtags(); 068 if (CollectionUtil.hasValues(subtags)) 069 { 070 for (XMLTag subtag : subtags) 071 { 072 addSubtag(SVG.constructFromXMLTag(subtag)); 073 } 074 } 075 } 076 077 //########################################################################## 078 // PUBLIC METHODS 079 //########################################################################## 080 081 //--------------------------------------------------------------------------- 082 public SvgFilter setFilterUnits(FilterCoordinateSystem inValue) 083 { 084 setAttribute(SvgAttr.filterUnits, inValue); 085 return this; 086 } 087 088 //--------------------------------------------------------------------------- 089 public SvgFilter setId(String inValue) 090 { 091 setAttribute(SvgAttr.id, inValue); 092 return this; 093 } 094 095 //--------------------------------------------------------------------------- 096 public SvgFilter setHeight(int inValue) 097 { 098 setAttribute(SvgAttr.height, inValue); 099 return this; 100 } 101 102 //--------------------------------------------------------------------------- 103 public SvgFilter setHeight(String inValue) 104 { 105 setAttribute(SvgAttr.height, inValue); 106 return this; 107 } 108 109 110 //--------------------------------------------------------------------------- 111 public SvgFilter setWidth(int inValue) 112 { 113 setAttribute(SvgAttr.width, inValue); 114 return this; 115 } 116 117 //--------------------------------------------------------------------------- 118 public SvgFilter setWidth(String inValue) 119 { 120 setAttribute(SvgAttr.width, inValue); 121 return this; 122 } 123 124 //--------------------------------------------------------------------------- 125 public SvgFilter setX(int inValue) 126 { 127 setAttribute(SvgAttr.x, inValue); 128 return this; 129 } 130 131 //--------------------------------------------------------------------------- 132 public SvgFilter setX(String inValue) 133 { 134 setAttribute(SvgAttr.x, inValue); 135 return this; 136 } 137 138 139 //--------------------------------------------------------------------------- 140 public SvgFilter setY(int inValue) 141 { 142 setAttribute(SvgAttr.y, inValue); 143 return this; 144 } 145 146 //--------------------------------------------------------------------------- 147 public SvgFilter setY(String inValue) 148 { 149 setAttribute(SvgAttr.y, inValue); 150 return this; 151 } 152 153 //--------------------------------------------------------------------------- 154 public SvgFeBlend addFeBlend() 155 { 156 SvgFeBlend feBlend = new SvgFeBlend(); 157 addSubtag(feBlend); 158 return feBlend; 159 } 160 161 //--------------------------------------------------------------------------- 162 public SvgFeColorMatrix addFeColorMatrix() 163 { 164 SvgFeColorMatrix feColorMatrix = new SvgFeColorMatrix(); 165 addSubtag(feColorMatrix); 166 return feColorMatrix; 167 } 168 169 //--------------------------------------------------------------------------- 170 public SvgFeComponentTransfer addFeComponentTransfer() 171 { 172 SvgFeComponentTransfer feComponentTransfer = new SvgFeComponentTransfer(); 173 addSubtag(feComponentTransfer); 174 return feComponentTransfer; 175 } 176 177 //--------------------------------------------------------------------------- 178 public SvgFeComposite addFeComposite() 179 { 180 SvgFeComposite feComposite = new SvgFeComposite(); 181 addSubtag(feComposite); 182 return feComposite; 183 } 184 185 //--------------------------------------------------------------------------- 186 public SvgFeConvolveMatrix addFeConvolveMatrix() 187 { 188 SvgFeConvolveMatrix feConvolveMatrix = new SvgFeConvolveMatrix(); 189 addSubtag(feConvolveMatrix); 190 return feConvolveMatrix; 191 } 192 193 //--------------------------------------------------------------------------- 194 public SvgFeDiffuseLighting addFeDiffuseLighting() 195 { 196 SvgFeDiffuseLighting feDiffuseLighting = new SvgFeDiffuseLighting(); 197 addSubtag(feDiffuseLighting); 198 return feDiffuseLighting; 199 } 200 201 //--------------------------------------------------------------------------- 202 public SvgFeDisplacementMap addFeDisplacementMap() 203 { 204 SvgFeDisplacementMap feDisplacementMap = new SvgFeDisplacementMap(); 205 addSubtag(feDisplacementMap); 206 return feDisplacementMap; 207 } 208 209 //--------------------------------------------------------------------------- 210 public SvgFeFlood addFeFlood() 211 { 212 SvgFeFlood feFlood = new SvgFeFlood(); 213 addSubtag(feFlood); 214 return feFlood; 215 } 216 217 //--------------------------------------------------------------------------- 218 public SvgFeGaussianBlur addFeGaussianBlur() 219 { 220 SvgFeGaussianBlur feGaussianBlur = new SvgFeGaussianBlur(); 221 addSubtag(feGaussianBlur); 222 return feGaussianBlur; 223 } 224 225 //--------------------------------------------------------------------------- 226 public SvgFeImage addFeImage() 227 { 228 SvgFeImage feImage = new SvgFeImage(); 229 addSubtag(feImage); 230 return feImage; 231 } 232 233 //--------------------------------------------------------------------------- 234 public SvgFeMerge addFeMerge() 235 { 236 SvgFeMerge feMerge = new SvgFeMerge(); 237 addSubtag(feMerge); 238 return feMerge; 239 } 240 241 //--------------------------------------------------------------------------- 242 public SvgFeMorphology addFeMorphology() 243 { 244 SvgFeMorphology feMorphology = new SvgFeMorphology(); 245 addSubtag(feMorphology); 246 return feMorphology; 247 } 248 249 //--------------------------------------------------------------------------- 250 public SvgFeOffset addFeOffset() 251 { 252 SvgFeOffset feOffset = new SvgFeOffset(); 253 addSubtag(feOffset); 254 return feOffset; 255 } 256 257 //--------------------------------------------------------------------------- 258 public SvgFeSpecularLighting addFeSpecularLighting() 259 { 260 SvgFeSpecularLighting feSpecularLighting = new SvgFeSpecularLighting(); 261 addSubtag(feSpecularLighting); 262 return feSpecularLighting; 263 } 264 265 //--------------------------------------------------------------------------- 266 public SvgFeTile addFeTile() 267 { 268 SvgFeTile feTile = new SvgFeTile(); 269 addSubtag(feTile); 270 return feTile; 271 } 272 273 //--------------------------------------------------------------------------- 274 public SvgFeTurbulence addFeTurbulence() 275 { 276 SvgFeTurbulence feTurbulence = new SvgFeTurbulence(); 277 addSubtag(feTurbulence); 278 return feTurbulence; 279 } 280}