001/* 002 * ============================================================================ 003 * Copyright © 2002-2025 by Thomas Thrien. 004 * All Rights Reserved. 005 * ============================================================================ 006 * Licensed to the public under the agreements of the GNU Lesser General Public 007 * License, version 3.0 (the "License"). You may obtain a copy of the License at 008 * 009 * http://www.gnu.org/licenses/lgpl.html 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 014 * License for the specific language governing permissions and limitations 015 * under the License. 016 */ 017 018package org.tquadrat.foundation.svg.internal; 019 020import static java.util.Collections.emptyList; 021import static org.apiguardian.api.API.Status.INTERNAL; 022import static org.tquadrat.foundation.lang.CommonConstants.XMLATTRIBUTE_Id; 023import static org.tquadrat.foundation.lang.CommonConstants.XMLATTRIBUTE_Language; 024import static org.tquadrat.foundation.lang.CommonConstants.XMLATTRIBUTE_Whitespace; 025import static org.tquadrat.foundation.lang.Objects.nonNull; 026import static org.tquadrat.foundation.lang.Objects.requireNonNullArgument; 027import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_AlignmentBaseline; 028import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_BaseProfile; 029import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_BaselineShift; 030import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Class; 031import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Clip; 032import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ClipPath; 033import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ClipRule; 034import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Color; 035import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ColorInterpolation; 036import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ColorInterpolationFilters; 037import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ColorProfile; 038import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ColorRendering; 039import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ContentScriptType; 040import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Cursor; 041import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Direction; 042import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Display; 043import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_DominantBaseline; 044import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_EnableBackground; 045import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ExternalResourcesRequired; 046import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Fill; 047import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FillOpacity; 048import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FillRule; 049import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Filter; 050import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FloodColor; 051import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FloodOpacity; 052import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FontFamily; 053import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FontSize; 054import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FontSizeAdjust; 055import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FontStretch; 056import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FontStyle; 057import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FontVariant; 058import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FontWeight; 059import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_GlyphOrientationHorizontal; 060import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_GlyphOrientationVertical; 061import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Height; 062import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Id; 063import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ImageRendering; 064import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Kerning; 065import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Lang; 066import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_LetterSpacing; 067import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_LightingColor; 068import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_MarkerEnd; 069import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_MarkerMid; 070import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_MarkerStart; 071import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Mask; 072import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnAbort; 073import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnActivate; 074import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnError; 075import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnFocusIn; 076import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnFocusOut; 077import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnResize; 078import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnScroll; 079import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnUnload; 080import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Opacity; 081import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Overflow; 082import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_PointerEvents; 083import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_PreserveAspectRatio; 084import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_RequiredExtensions; 085import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_RequiredFeatures; 086import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ShapeRendering; 087import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_StopColor; 088import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_StopOpacity; 089import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Stroke; 090import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_StrokeDashArray; 091import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_StrokeDashOffset; 092import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_StrokeLineCap; 093import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_StrokeLineJoin; 094import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_StrokeMiterLimit; 095import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_StrokeOpacity; 096import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_StrokeWidth; 097import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Style; 098import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_SystemLanguage; 099import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_TabIndex; 100import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_TextAnchor; 101import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_TextDecoration; 102import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_TextRendering; 103import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Transform; 104import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_UnicodeBidi; 105import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_VectorEffect; 106import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Version; 107import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ViewBox; 108import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Visibility; 109import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Width; 110import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_WordSpacing; 111import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_WritingMode; 112import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ZoomAndPan; 113import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_x; 114import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_y; 115import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_AltGlyphDef; 116import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_Anchor; 117import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_ClipPath; 118import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_ColorProfile; 119import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_Cursor; 120import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_Defs; 121import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_Filter; 122import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_Font; 123import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_FontFace; 124import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_ForeignObject; 125import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_Image; 126import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_Marker; 127import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_Mask; 128import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_Pattern; 129import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_Root; 130import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_Script; 131import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_Style; 132import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_Switch; 133import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_Text; 134import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_View; 135import static org.tquadrat.foundation.svg.SVGUtils.XMLATTRIBUTE_Base; 136import static org.tquadrat.foundation.svg.SVGUtils.createStyle; 137import static org.tquadrat.foundation.svg.type.SVGElementCategory.ANIMATION; 138import static org.tquadrat.foundation.svg.type.SVGElementCategory.DESCRIPTIVE; 139import static org.tquadrat.foundation.svg.type.SVGElementCategory.GRADIENT; 140import static org.tquadrat.foundation.svg.type.SVGElementCategory.SHAPE; 141import static org.tquadrat.foundation.svg.type.SVGElementCategory.STRUCTURAL; 142import static org.tquadrat.foundation.xml.builder.XMLElement.Flags.ALLOWS_CHILDREN; 143import static org.tquadrat.foundation.xml.builder.XMLElement.Flags.VALIDATES_ATTRIBUTES; 144import static org.tquadrat.foundation.xml.builder.XMLElement.Flags.VALIDATES_CHILDREN; 145 146import java.util.ArrayList; 147import java.util.Collection; 148import java.util.HashSet; 149import java.util.List; 150import java.util.Optional; 151 152import org.apiguardian.api.API; 153import org.tquadrat.foundation.annotation.ClassVersion; 154import org.tquadrat.foundation.lang.Lazy; 155import org.tquadrat.foundation.svg.SVG; 156import org.tquadrat.foundation.svg.SVGElement; 157import org.tquadrat.foundation.svg.SVGStyle; 158import org.tquadrat.foundation.xml.builder.spi.Element; 159import jakarta.activation.MimeType; 160 161/** 162 * The implementation for the interface 163 * {@link SVG} 164 * for the {@code <svg>} element. 165 * 166 * @extauthor Thomas Thrien - thomas.thrien@tquadrat.org 167 * @version $Id: SVGImpl.java 1151 2025-10-01 21:32:15Z tquadrat $ 168 * @since 0.0.5 169 * 170 * @UMLGraph.link 171 */ 172@ClassVersion( sourceVersion = "$Id: SVGImpl.java 1151 2025-10-01 21:32:15Z tquadrat $" ) 173@API( status = INTERNAL, since = "0.0.5" ) 174public final class SVGImpl extends SVGElementImpl implements SVG 175{ 176 /*------------*\ 177 ====** Attributes **======================================================= 178 \*------------*/ 179 /** 180 * The optional {@code <defs>} element for this {@code <svg>} element. 181 */ 182 private final Lazy<SVGElementImpl> m_Definitions = Lazy.use( this::createDefinitionsElement ); 183 184 /** 185 * The style sheet for this {@code <svg>} element. 186 */ 187 @SuppressWarnings( "OptionalUsedAsFieldOrParameterType" ) 188 private Optional<SVGStyle> m_StyleSheet = Optional.empty(); 189 190 /*--------------*\ 191 ====** Constructors **===================================================== 192 \*--------------*/ 193 /** 194 * Creates a new {@code SVGImpl} instance. 195 */ 196 public SVGImpl() 197 { 198 super( SVGELEMENT_Root, ALLOWS_CHILDREN, VALIDATES_CHILDREN, VALIDATES_ATTRIBUTES ); 199 200 //---* The children and attributes for the <svg> element *------------- 201 final var childElements = validChildElements(); 202 203 final Collection<String> attributes = new ArrayList<>(); 204 attributes.addAll( List.of( SVGATTRIBUTE_Id, SVGATTRIBUTE_Version, 205 SVGATTRIBUTE_BaseProfile, SVGATTRIBUTE_ContentScriptType, 206 SVGATTRIBUTE_x, SVGATTRIBUTE_y, SVGATTRIBUTE_Width, 207 SVGATTRIBUTE_Height, SVGATTRIBUTE_ViewBox, 208 SVGATTRIBUTE_PreserveAspectRatio, SVGATTRIBUTE_ZoomAndPan, 209 SVGATTRIBUTE_Class, SVGATTRIBUTE_Style, SVGATTRIBUTE_Lang, 210 SVGATTRIBUTE_TabIndex, SVGATTRIBUTE_ExternalResourcesRequired, 211 SVGATTRIBUTE_RequiredExtensions, SVGATTRIBUTE_RequiredFeatures, 212 SVGATTRIBUTE_SystemLanguage, XMLATTRIBUTE_Id, XMLATTRIBUTE_Base, 213 XMLATTRIBUTE_Language, XMLATTRIBUTE_Whitespace, SVGATTRIBUTE_OnAbort, 214 SVGATTRIBUTE_OnActivate, SVGATTRIBUTE_OnError, 215 SVGATTRIBUTE_OnFocusIn, SVGATTRIBUTE_OnFocusOut, 216 SVGATTRIBUTE_OnResize, SVGATTRIBUTE_OnScroll, 217 SVGATTRIBUTE_OnUnload, SVGATTRIBUTE_AlignmentBaseline, 218 SVGATTRIBUTE_BaselineShift, SVGATTRIBUTE_Clip, 219 SVGATTRIBUTE_ClipPath, SVGATTRIBUTE_ClipRule, SVGATTRIBUTE_Color, 220 SVGATTRIBUTE_ColorInterpolation, 221 SVGATTRIBUTE_ColorInterpolationFilters, SVGATTRIBUTE_ColorProfile, 222 SVGATTRIBUTE_ColorRendering, SVGATTRIBUTE_Cursor, 223 SVGATTRIBUTE_Direction, SVGATTRIBUTE_Display, 224 SVGATTRIBUTE_DominantBaseline, SVGATTRIBUTE_EnableBackground, 225 SVGATTRIBUTE_Fill, SVGATTRIBUTE_FillOpacity, SVGATTRIBUTE_FillRule, 226 SVGATTRIBUTE_Filter, SVGATTRIBUTE_FloodColor, 227 SVGATTRIBUTE_FloodOpacity, SVGATTRIBUTE_FontFamily, 228 SVGATTRIBUTE_FontSize, SVGATTRIBUTE_FontSizeAdjust, 229 SVGATTRIBUTE_FontStretch, SVGATTRIBUTE_FontStyle, 230 SVGATTRIBUTE_FontVariant, SVGATTRIBUTE_FontWeight, 231 SVGATTRIBUTE_GlyphOrientationHorizontal, 232 SVGATTRIBUTE_GlyphOrientationVertical, SVGATTRIBUTE_ImageRendering, 233 SVGATTRIBUTE_Kerning, SVGATTRIBUTE_LetterSpacing, 234 SVGATTRIBUTE_LightingColor, SVGATTRIBUTE_MarkerEnd, 235 SVGATTRIBUTE_MarkerMid, SVGATTRIBUTE_MarkerStart, 236 SVGATTRIBUTE_Mask, SVGATTRIBUTE_Opacity, SVGATTRIBUTE_Overflow, 237 SVGATTRIBUTE_PointerEvents, SVGATTRIBUTE_ShapeRendering, 238 SVGATTRIBUTE_StopColor, SVGATTRIBUTE_StopOpacity, 239 SVGATTRIBUTE_Stroke, SVGATTRIBUTE_StrokeDashArray, 240 SVGATTRIBUTE_StrokeDashOffset, SVGATTRIBUTE_StrokeLineCap, 241 SVGATTRIBUTE_StrokeLineJoin, SVGATTRIBUTE_StrokeMiterLimit, 242 SVGATTRIBUTE_StrokeOpacity, SVGATTRIBUTE_StrokeWidth, 243 SVGATTRIBUTE_TextAnchor, SVGATTRIBUTE_TextDecoration, 244 SVGATTRIBUTE_TextRendering, SVGATTRIBUTE_Transform, 245 SVGATTRIBUTE_UnicodeBidi, SVGATTRIBUTE_VectorEffect, 246 SVGATTRIBUTE_Visibility, SVGATTRIBUTE_WordSpacing, 247 SVGATTRIBUTE_WritingMode ) ); 248 attributes.addAll( DOCUMENTEVENT_ATTRIBUTES ); 249 attributes.addAll( DOCUMENTELEMENTEVENT_ATTRIBUTES ); 250 251 updateRegistries( childElements, attributes ); 252 } // SVGImpl() 253 254 /*---------*\ 255 ====** Methods **========================================================== 256 \*---------*/ 257 /** 258 * {@inheritDoc} 259 */ 260 @Override 261 public final <E extends SVGElement> void addDefinition( final E child ) throws IllegalArgumentException, IllegalStateException 262 { 263 /* 264 * The class of the instance is only sufficient when it is a native 265 * SVG object. But everything that is derived from SVGElementAdapter is 266 * everything (including an SVGStyle), therefore we need to check the 267 * element name, too. 268 */ 269 if( requireNonNullArgument( child, "child" ) instanceof final SVGStyle style && child.getElementName().equals( SVGELEMENT_Style ) ) 270 { 271 addStyle( style ); 272 } 273 else 274 { 275 child.getAttribute( SVGATTRIBUTE_Id ).orElseThrow( () -> new IllegalArgumentException( "Id is missing" ) ); 276 m_Definitions.get().addChild( child ); 277 } 278 } // addDefinition() 279 280 /** 281 * {@inheritDoc} 282 */ 283 @Override 284 public final void addStyle( final SVGStyle style ) throws IllegalArgumentException, IllegalStateException 285 { 286 requireNonNullArgument( style, "style" ); 287 288 /* 289 * <style> elements will be merged if possible, and they do not need an 290 * id. 291 */ 292 if( m_StyleSheet.isPresent() ) 293 { 294 m_StyleSheet.get().merge( style ); 295 } 296 else 297 { 298 m_StyleSheet = Optional.of( style ); 299 m_Definitions.get().addChild( style ); 300 } 301 } // addDefinition() 302 303 /** 304 * Creates the element for the definitions. 305 * 306 * @return The {@code <defs>} element. 307 */ 308 private final SVGElementImpl createDefinitionsElement() 309 { 310 final var retValue = new SVGElementImpl( SVGELEMENT_Defs, ALLOWS_CHILDREN ); 311 312 //---* The children and attributes for the <defs> element *------------- 313 /* 314 * The valid children for the <defs> element are the same as for the 315 * <svg> element - excluding the <defs> element itself. 316 */ 317 final var childElements = validChildElements(); 318 childElements.remove( SVGELEMENT_Defs ); 319 320 /* 321 * The specification allows attributes for the <defs> element, but as 322 * we don't provide an API to set them, we do not configure them ... 323 */ 324 retValue.updateRegistries( childElements, emptyList() ); 325 326 //---* Done *---------------------------------------------------------- 327 return retValue; 328 } // createDefinitionsElement() 329 330 /** 331 * {@inheritDoc} 332 */ 333 @Override 334 public final Collection<? extends Element> getChildren() 335 { 336 final Collection<? extends Element> retValue; 337 if( m_Definitions.isPresent() ) 338 { 339 final Collection<Element> children = new ArrayList<>(); 340 children.add( m_Definitions.get() ); 341 children.addAll( super.getChildren() ); 342 retValue = List.copyOf( children ); 343 } 344 else 345 { 346 retValue = super.getChildren(); 347 } 348 349 //---* Done *---------------------------------------------------------- 350 return retValue; 351 } // getChildren() 352 353 /** 354 * {@inheritDoc} 355 */ 356 @Override 357 public final boolean hasChildren() 358 { 359 final var retValue = m_Definitions.isPresent() || super.hasChildren(); 360 361 //---* Done *---------------------------------------------------------- 362 return retValue; 363 } // hasChildren() 364 /** 365 * {@inheritDoc} 366 */ 367 @Override 368 public final void setContentScriptType( final MimeType value ) 369 { 370 setAttribute( SVGATTRIBUTE_ContentScriptType, nonNull( value ) ? value.toString() : null ); 371 } // setContentScriptType() 372 373 /** 374 * {@inheritDoc} 375 */ 376 @SuppressWarnings( "OptionalGetWithoutIsPresent" ) 377 @Override 378 public final SVGStyle setStyleSheet( final CharSequence... styles ) 379 { 380 /* 381 * After this call, m_StyleSheet is definitely no longer empty; it 382 * will be set as a side effect of SVG.addStyle(). Not nice, but 383 * efficient. 384 */ 385 m_StyleSheet.ifPresentOrElse( style -> style.addStyle( styles ), () -> addStyle( createStyle( styles ) ) ); 386 387 //---* Done *---------------------------------------------------------- 388 return m_StyleSheet.get(); 389 } // setStyleSheet() 390 391 /** 392 * {@inheritDoc} 393 */ 394 @Override 395 public final void setZoomAndPan( final boolean flag ) 396 { 397 setAttribute( SVGATTRIBUTE_ZoomAndPan, flag ? "magnify" : "disable" ); 398 } // setZoomAndPan() 399 400 /** 401 * Composes the list of the valid child elements for the {@code <svg>} 402 * element. 403 * 404 * @return The valid child elements. 405 */ 406 private final Collection<String> validChildElements() 407 { 408 //---* The valid child elements the <svg> element *-------------------- 409 final Collection<String> retValue = new HashSet<>(); 410 retValue.addAll( ANIMATION.getElements() ); 411 retValue.addAll( DESCRIPTIVE.getElements() ); 412 retValue.addAll( SHAPE.getElements() ); 413 retValue.addAll( STRUCTURAL.getElements() ); 414 retValue.addAll( GRADIENT.getElements() ); 415 retValue.addAll( List.of( SVGELEMENT_AltGlyphDef, 416 SVGELEMENT_Anchor, SVGELEMENT_ClipPath, SVGELEMENT_ColorProfile, 417 SVGELEMENT_Cursor, SVGELEMENT_Filter, SVGELEMENT_Font, 418 SVGELEMENT_FontFace, SVGELEMENT_ForeignObject, SVGELEMENT_Image, 419 SVGELEMENT_Marker, SVGELEMENT_Mask, SVGELEMENT_Pattern, 420 SVGELEMENT_Script, SVGELEMENT_Style, SVGELEMENT_Switch, 421 SVGELEMENT_Text, SVGELEMENT_View ) ); 422 423 //---* Done *---------------------------------------------------------- 424 return retValue; 425 } // validChildElements() 426} 427// class SVGImpl 428 429/* 430 * End of File 431 */