001/* 002 * ============================================================================ 003 * Copyright © 2002-2023 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.lang.Double.min; 021import static java.lang.String.format; 022import static java.util.Arrays.stream; 023import static java.util.Collections.emptyList; 024import static java.util.stream.Collectors.joining; 025import static org.apiguardian.api.API.Status.INTERNAL; 026import static org.tquadrat.foundation.lang.CommonConstants.EMPTY_String_ARRAY; 027import static org.tquadrat.foundation.lang.CommonConstants.XMLATTRIBUTE_Language; 028import static org.tquadrat.foundation.lang.CommonConstants.XMLATTRIBUTE_Whitespace; 029import static org.tquadrat.foundation.lang.Objects.nonNull; 030import static org.tquadrat.foundation.lang.Objects.requireNonNullArgument; 031import static org.tquadrat.foundation.lang.Objects.requireNotEmptyArgument; 032import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_AlignmentBaseline; 033import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_BaselineShift; 034import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Class; 035import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Clip; 036import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ClipPath; 037import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ClipRule; 038import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Color; 039import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ColorInterpolation; 040import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ColorInterpolationFilters; 041import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ColorProfile; 042import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ColorRendering; 043import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Cursor; 044import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Direction; 045import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Display; 046import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_DominantBaseline; 047import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_EnableBackground; 048import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ExternalResourcesRequired; 049import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Fill; 050import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FillOpacity; 051import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FillRule; 052import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Filter; 053import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FloodColor; 054import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FloodOpacity; 055import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FontFamily; 056import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FontSize; 057import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FontSizeAdjust; 058import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FontStretch; 059import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FontStyle; 060import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FontVariant; 061import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_FontWeight; 062import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_GlyphOrientationHorizontal; 063import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_GlyphOrientationVertical; 064import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Height; 065import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Id; 066import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ImageRendering; 067import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Kerning; 068import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Lang; 069import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_LetterSpacing; 070import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_LightingColor; 071import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_MarkerEnd; 072import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_MarkerMid; 073import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_MarkerStart; 074import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Mask; 075import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnAbort; 076import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnActivate; 077import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnCanPlay; 078import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnCanPlayThrough; 079import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnCancel; 080import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnChange; 081import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnClick; 082import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnClose; 083import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnCopy; 084import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnCueChange; 085import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnCut; 086import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnDblClick; 087import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnDrag; 088import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnDragEnd; 089import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnDragEnter; 090import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnDragExit; 091import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnDragLeave; 092import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnDragOver; 093import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnDragStart; 094import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnDrop; 095import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnDurationChange; 096import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnEmptied; 097import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnEnded; 098import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnError; 099import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnFocus; 100import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnFocusIn; 101import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnFocusOut; 102import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnInput; 103import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnInvalid; 104import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnKeyDown; 105import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnKeyPress; 106import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnKeyUp; 107import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnLoad; 108import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnLoadStart; 109import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnLoadedData; 110import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnLoadedMetadata; 111import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnMouseDown; 112import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnMouseEnter; 113import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnMouseLeave; 114import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnMouseMove; 115import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnMouseOut; 116import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnMouseOver; 117import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnMouseUp; 118import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnMouseWheel; 119import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnPaste; 120import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnPause; 121import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnPlay; 122import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnPlaying; 123import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnProgress; 124import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnRateChange; 125import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnReset; 126import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnResize; 127import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnScroll; 128import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnSeeked; 129import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnSeeking; 130import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnSelect; 131import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnShow; 132import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnStalled; 133import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnSubmit; 134import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnSuspend; 135import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnTimeUpdate; 136import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnToggle; 137import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnUnload; 138import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnVolumeChange; 139import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_OnWaiting; 140import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Opacity; 141import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Overflow; 142import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_PathLength; 143import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_PointerEvents; 144import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_PreserveAspectRatio; 145import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Reference; 146import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_RequiredExtensions; 147import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_RequiredFeatures; 148import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ShapeRendering; 149import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_StopColor; 150import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_StopOpacity; 151import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Stroke; 152import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_StrokeDashArray; 153import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_StrokeDashOffset; 154import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_StrokeLineCap; 155import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_StrokeLineJoin; 156import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_StrokeMiterLimit; 157import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_StrokeOpacity; 158import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_StrokeWidth; 159import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Style; 160import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_SystemLanguage; 161import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_TabIndex; 162import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_TextAnchor; 163import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_TextDecoration; 164import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_TextRendering; 165import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Transform; 166import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_UnicodeBidi; 167import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_VectorEffect; 168import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ViewBox; 169import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Visibility; 170import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Width; 171import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_WordSpacing; 172import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_WritingMode; 173import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_XLink_Actuate; 174import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_XLink_ArcRole; 175import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_XLink_Reference; 176import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_XLink_Role; 177import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_XLink_Show; 178import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_XLink_Title; 179import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_XLink_Type; 180import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_rx; 181import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ry; 182import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_x; 183import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_y; 184import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_Description; 185import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_Title; 186import static org.tquadrat.foundation.svg.SVGUtils.XMLATTRIBUTE_Base; 187import static org.tquadrat.foundation.util.StringUtils.isNotEmptyOrBlank; 188import static org.tquadrat.foundation.xml.builder.XMLBuilderUtils.getNMTokenValidator; 189import static org.tquadrat.foundation.xml.builder.XMLElement.Flags.ALLOWS_TEXT; 190 191import java.net.URI; 192import java.util.Collection; 193import java.util.Locale; 194import java.util.Optional; 195import java.util.Set; 196 197import org.apiguardian.api.API; 198import org.tquadrat.foundation.annotation.ClassVersion; 199import org.tquadrat.foundation.svg.SVGElement; 200import org.tquadrat.foundation.svg.SVGElementAdapter; 201import org.tquadrat.foundation.svg.SVGUtils; 202import org.tquadrat.foundation.svg.type.SVGAlignmentBaseLine; 203import org.tquadrat.foundation.svg.type.SVGColor; 204import org.tquadrat.foundation.svg.type.SVGNumber; 205import org.tquadrat.foundation.svg.type.SVGNumber.SVGUserUnitValue; 206import org.tquadrat.foundation.svg.type.SVGPaint; 207import org.tquadrat.foundation.svg.type.SVGPreserveAspectRatio; 208import org.tquadrat.foundation.svg.type.SVGTransform; 209import org.tquadrat.foundation.xml.builder.XMLElement; 210import org.tquadrat.foundation.xml.builder.spi.XMLElementAdapter; 211 212/** 213 * <p>{@summary The base class for all SVG elements.}</p> 214 * <p>Some internal elements are even implemented by this class only (that's 215 * why it is not abstract).</p> 216 * 217 * @extauthor Thomas Thrien - thomas.thrien@tquadrat.org 218 * @version $Id: SVGElementImpl.java 1074 2023-10-02 12:05:06Z tquadrat $ 219 * @since 0.0.5 220 * 221 * @UMLGraph.link 222 */ 223@SuppressWarnings( {"ClassWithTooManyMethods", "OverlyComplexClass"} ) 224@ClassVersion( sourceVersion = "$Id: SVGElementImpl.java 1074 2023-10-02 12:05:06Z tquadrat $" ) 225@API( status = INTERNAL, since = "0.0.5" ) 226public sealed class SVGElementImpl extends XMLElementAdapter implements SVGElement 227 permits SVGElementAdapter, SVGClipPathImpl, 228 SVGGroupImpl, SVGImpl, SVGLineImpl, SVGMarkerImpl, SVGPathImpl, 229 SVGRectangleImpl, SVGStyleImpl, SVGSymbolImpl, SVGTextBase, SVGUseImpl 230{ 231 /*------------*\ 232 ====** Attributes **======================================================= 233 \*------------*/ 234 /** 235 * Flag that indicates whether a description was already provided for this 236 * element. 237 */ 238 private boolean m_HasDescription; 239 240 /** 241 * Flag that indicates whether a title was already provided for this 242 * element. 243 */ 244 private boolean m_HasTitle; 245 246 /*--------------*\ 247 ====** Constructors **===================================================== 248 \*--------------*/ 249 /** 250 * Creates a new {@code SVGElementImpl} instance. 251 * 252 * @param elementName The name of the element. 253 * @param flags The configuration flags for the new element. 254 */ 255 protected SVGElementImpl( final String elementName, final Flags... flags ) 256 { 257 super( elementName, Set.of( requireNonNullArgument( flags, "flags" ) ) ); 258 259 m_HasDescription = false; 260 m_HasTitle = false; 261 } // SVGElementImpl() 262 263 /*---------*\ 264 ====** Methods **========================================================== 265 \*---------*/ 266 /** 267 * Adds a child to this element. 268 * 269 * @param <E> The implementation type for the {@code children}. 270 * @param child The child to add. 271 * @throws IllegalArgumentException The given child is not valid for 272 * this element or no children are allowed at all. 273 * @throws IllegalStateException The child has already a parent that is 274 * not this element. 275 */ 276 public <E extends SVGElement> void addChild( final E child ) throws IllegalArgumentException, IllegalStateException 277 { 278 addChild( (XMLElement) child ); 279 } // addChild() 280 281 /** 282 * Sets the abort handler for this SVG element. 283 * 284 * @param value The abort handler. 285 * 286 * @see SVGUtils#SVGATTRIBUTE_OnAbort 287 */ 288 public void setAbortHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnAbort, value, NO_APPEND ); } 289 290 /** 291 * Sets the activation handler for this SVG element. 292 * 293 * @param value The activation handler. 294 * 295 * @see SVGUtils#SVGATTRIBUTE_OnActivate 296 */ 297 public void setActivationHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnActivate, value, NO_APPEND ); } 298 299 /** 300 * Sets the presentation attribute {@code alignment-baseline} for this SVG element. 301 * 302 * @param value The attribute type. 303 * 304 * @see SVGUtils#SVGATTRIBUTE_AlignmentBaseline 305 */ 306 public void setAlignmentBaseline( final SVGAlignmentBaseLine value ) 307 { 308 setAttribute( SVGATTRIBUTE_AlignmentBaseline, nonNull( value ) ? value.toString() : null, NO_APPEND ); 309 } // setAlignmentBaseline() 310 311 /** 312 * Sets the attribute with the given name. 313 * 314 * @param name The name of the attribute; the name is case-sensitive. 315 * @param value The attribute's type; if {@code null} the 316 * attribute will be removed. 317 * @throws IllegalArgumentException An attribute with the given name is 318 * not valid for the element, or no attributes are allowed at all. 319 */ 320 @SuppressWarnings( {"PublicMethodNotExposedInInterface", "UseOfConcreteClass"} ) 321 public void setAttribute( final String name, final SVGNumber value ) throws IllegalArgumentException 322 { 323 setAttribute( name, nonNull( value ) ? value.value() : null, NO_APPEND ); 324 } // setAttribute() 325 326 /** 327 * Sets the presentation attribute {@code baseline-shift} for this SVG element. 328 * 329 * @param value The attribute type. 330 * 331 * @see SVGUtils#SVGATTRIBUTE_BaselineShift 332 */ 333 public void setBaselineShift( final String value ) { setAttribute( SVGATTRIBUTE_BaselineShift, value, NO_APPEND ); } 334 335 /** 336 * Sets the cancel handler for this SVG element. 337 * 338 * @param value The cancel handler. 339 * 340 * @see SVGUtils#SVGATTRIBUTE_OnCancel 341 */ 342 public void setCancelHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnCancel, value, NO_APPEND ); } 343 344 /** 345 * Sets the can-play handler for this SVG element. 346 * 347 * @param value The can-play handler. 348 * 349 * @see SVGUtils#SVGATTRIBUTE_OnCanPlay 350 */ 351 public void setCanPlayHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnCanPlay, value, NO_APPEND ); } 352 353 /** 354 * Sets the can-play-through handler for this SVG element. 355 * 356 * @param value The can-play-through handler. 357 * 358 * @see SVGUtils#SVGATTRIBUTE_OnCanPlayThrough 359 */ 360 public void setCanPlayThroughHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnCanPlayThrough, value, NO_APPEND ); } 361 362 /** 363 * Sets the change handler for this SVG element. 364 * 365 * @param value The change handler. 366 * 367 * @see SVGUtils#SVGATTRIBUTE_OnChange 368 */ 369 public void setChangeHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnChange, value, NO_APPEND ); } 370 371 /** 372 * Sets the CSS class for the SVG element. 373 * 374 * @param value The name of a CSS class for this SVG element. 375 */ 376 public void setClass( final CharSequence value ) { setAttribute( SVGATTRIBUTE_Class, value, Optional.of( " " ) ); } 377 378 /** 379 * Sets the click handler for this SVG element. 380 * 381 * @param value The click handler. 382 * 383 * @see SVGUtils#SVGATTRIBUTE_OnClick 384 */ 385 public void setClickHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnClick, value, NO_APPEND ); } 386 387 /** 388 * Sets the presentation attribute {@code clip} for this SVG element. 389 * 390 * @param value The attribute type. 391 * 392 * @see SVGUtils#SVGATTRIBUTE_Clip 393 */ 394 public void setClip( final String value ) { setAttribute( SVGATTRIBUTE_Clip, value, NO_APPEND ); } 395 396 /** 397 * Sets the {@code clip-path} attribute for this SVG element. 398 * 399 * @param value The URI for the clip path. 400 * 401 * @see SVGUtils#SVGATTRIBUTE_ClipPath 402 */ 403 public void setClipPath( final URI value ) 404 { 405 setAttribute( SVGATTRIBUTE_ClipPath, nonNull( value ) ? format( "url(%s)", value.toString() ) : null ); 406 } // setClipPath() 407 408 /** 409 * Sets the presentation attribute {@code clip-rule} for this SVG element. 410 * 411 * @param value The attribute type. 412 * 413 * @see SVGUtils#SVGATTRIBUTE_ClipRule 414 */ 415 public void setClipRule( final String value ) { setAttribute( SVGATTRIBUTE_ClipRule, value, NO_APPEND ); } 416 417 /** 418 * Sets the global event attribute {@code onclose} for this SVG element. 419 * 420 * @param value The attribute type. 421 * 422 * @see SVGUtils#SVGATTRIBUTE_OnClose 423 */ 424 public void setCloseHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnClose, value ); } 425 426 /** 427 * Sets the colour for this SVG element. 428 * 429 * @param value The colour. 430 * 431 * @see SVGUtils#SVGATTRIBUTE_Color 432 */ 433 @SuppressWarnings( "UseOfConcreteClass" ) 434 public void setColor( final SVGColor value ) 435 { 436 setAttribute( SVGATTRIBUTE_Color, nonNull( value ) ? value.value() : null ); 437 } // setColor() 438 439 /** 440 * Sets the presentation attribute {@code color-interpolation} for this SVG element. 441 * 442 * @param value The attribute type. 443 * 444 * @see SVGUtils#SVGATTRIBUTE_ColorInterpolation 445 */ 446 public void setColorInterpolation( final String value ) { setAttribute( SVGATTRIBUTE_ColorInterpolation, value, NO_APPEND ); } 447 448 /** 449 * Sets the presentation attribute {@code color-interpolation-filters} for this SVG element. 450 * 451 * @param value The attribute type. 452 * 453 * @see SVGUtils#SVGATTRIBUTE_ColorInterpolationFilters 454 */ 455 public void setColorInterpolationFilters( final String value ) { setAttribute( SVGATTRIBUTE_ColorInterpolationFilters, value ); } 456 457 /** 458 * Sets the presentation attribute {@code color-profile} for this SVG element. 459 * 460 * @param value The attribute type. 461 * 462 * @see SVGUtils#SVGATTRIBUTE_ColorProfile 463 */ 464 public void setColorProfile( final String value ) { setAttribute( SVGATTRIBUTE_ColorProfile, value ); } 465 466 /** 467 * Sets the presentation attribute {@code color-rendering} for this SVG element. 468 * 469 * @param value The attribute type. 470 * 471 * @see SVGUtils#SVGATTRIBUTE_ColorRendering 472 */ 473 public void setColorRendering( final String value ) { setAttribute( SVGATTRIBUTE_ColorRendering, value ); } 474 475 /** 476 * Sets the copy handler for this SVG element. 477 * 478 * @param value The copy handler. 479 * 480 * @see SVGUtils#SVGATTRIBUTE_OnCopy 481 */ 482 public void setCopyHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnCopy, value ); } 483 484 /** 485 * Sets the global event attribute {@code oncuechange} for this SVG element. 486 * 487 * @param value The attribute type. 488 * 489 * @see SVGUtils#SVGATTRIBUTE_OnCueChange 490 */ 491 public void setCueChangeHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnCueChange, value ); } 492 493 /** 494 * Sets the presentation attribute {@code cursor} for this SVG element. 495 * 496 * @param value The attribute type. 497 * 498 * @see SVGUtils#SVGATTRIBUTE_Cursor 499 */ 500 public void setCursor( final String value ) { setAttribute( SVGATTRIBUTE_Cursor, value ); } 501 502 /** 503 * Sets the cut handler for this SVG element. 504 * 505 * @param value The cut handler. 506 * 507 * @see SVGUtils#SVGATTRIBUTE_OnCut 508 */ 509 public void setCutHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnCut, value ); } 510 511 /** 512 * Sets the global event attribute {@code ondblclick} for this SVG element. 513 * 514 * @param value The attribute type. 515 * 516 * @see SVGUtils#SVGATTRIBUTE_OnDblClick 517 */ 518 public void setDblClickHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnDblClick, value ); } 519 520 /** 521 * Sets the description for the SVG element.<br> 522 * <br>This is not an attribute, instead a 523 * <code><{@value org.tquadrat.foundation.svg.SVGUtils#SVGELEMENT_Description}></code> 524 * element will be added as a child. 525 * 526 * @param description The description; nothing happens if {@code null}, 527 * empty, or blank. 528 * @throws IllegalStateException The given description is not 529 * {@code null}, empty, or blank, and a title was applied already 530 * earlier. 531 */ 532 public void setDescription( final CharSequence description ) 533 { 534 if( isNotEmptyOrBlank( description ) ) 535 { 536 if( m_HasDescription ) throw new IllegalStateException( "Description was already set" ); 537 538 final var element = new SVGElementImpl( SVGELEMENT_Description, ALLOWS_TEXT ); 539 element.updateRegistries( emptyList(), emptyList() ); 540 element.addText( description ); 541 addChild( (SVGElement) element ); 542 m_HasDescription = true; 543 } 544 } // setDescription() 545 546 /** 547 * Sets the presentation attribute {@code direction} for this SVG element. 548 * 549 * @param value The attribute type. 550 * 551 * @see SVGUtils#SVGATTRIBUTE_Direction 552 */ 553 public void setDirection( final String value ) { setAttribute( SVGATTRIBUTE_Direction, value ); } 554 555 /** 556 * Sets the presentation attribute {@code display} for this SVG element. 557 * 558 * @param value The attribute type. 559 * 560 * @see SVGUtils#SVGATTRIBUTE_Display 561 */ 562 public void setDisplay( final String value ) { setAttribute( SVGATTRIBUTE_Display, value ); } 563 564 /** 565 * Sets the presentation attribute {@code dominant-baseline} for this SVG element. 566 * 567 * @param value The attribute type. 568 * 569 * @see SVGUtils#SVGATTRIBUTE_DominantBaseline 570 */ 571 public void setDominantBaseline( final String value ) { setAttribute( SVGATTRIBUTE_DominantBaseline, value ); } 572 573 /** 574 * Sets the global event attribute {@code ondragend} for this SVG element. 575 * 576 * @param value The attribute type. 577 * 578 * @see SVGUtils#SVGATTRIBUTE_OnDragEnd 579 */ 580 public void setDragEndHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnDragEnd, value ); } 581 582 /** 583 * Sets the global event attribute {@code ondragenter} for this SVG element. 584 * 585 * @param value The attribute type. 586 * 587 * @see SVGUtils#SVGATTRIBUTE_OnDragEnter 588 */ 589 public void setDragEnterHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnDragEnter, value ); } 590 591 /** 592 * Sets the global event attribute {@code ondragexit} for this SVG element. 593 * 594 * @param value The attribute type. 595 * 596 * @see SVGUtils#SVGATTRIBUTE_OnDragExit 597 */ 598 public void setDragExitHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnDragExit, value ); } 599 600 /** 601 * Sets the global event attribute {@code ondrag} for this SVG element. 602 * 603 * @param value The attribute type. 604 * 605 * @see SVGUtils#SVGATTRIBUTE_OnDrag 606 */ 607 public void setDragHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnDrag, value ); } 608 609 /** 610 * Sets the global event attribute {@code ondragleave} for this SVG element. 611 * 612 * @param value The attribute type. 613 * 614 * @see SVGUtils#SVGATTRIBUTE_OnDragLeave 615 */ 616 public void setDragLeaveHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnDragLeave, value ); } 617 618 /** 619 * Sets the global event attribute {@code ondragover} for this SVG element. 620 * 621 * @param value The attribute type. 622 * 623 * @see SVGUtils#SVGATTRIBUTE_OnDragOver 624 */ 625 public void setDragOverHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnDragOver, value ); } 626 627 /** 628 * Sets the global event attribute {@code ondragstart} for this SVG element. 629 * 630 * @param value The attribute type. 631 * 632 * @see SVGUtils#SVGATTRIBUTE_OnDragStart 633 */ 634 public void setDragStartHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnDragStart, value ); } 635 636 /** 637 * Sets the global event attribute {@code ondrop} for this SVG element. 638 * 639 * @param value The attribute type. 640 * 641 * @see SVGUtils#SVGATTRIBUTE_OnDrop 642 */ 643 public void setDropHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnDrop, value ); } 644 645 /** 646 * Sets the global event attribute {@code ondurationchange} for this SVG element. 647 * 648 * @param value The attribute type. 649 * 650 * @see SVGUtils#SVGATTRIBUTE_OnDurationChange 651 */ 652 public void setDurationChangeHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnDurationChange, value ); } 653 654 /** 655 * Sets the global event attribute {@code onemptied} for this SVG element. 656 * 657 * @param value The attribute type. 658 * 659 * @see SVGUtils#SVGATTRIBUTE_OnEmptied 660 */ 661 public void setEmptiedHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnEmptied, value ); } 662 663 /** 664 * Sets the presentation attribute {@code enable-background} for this SVG element. 665 * 666 * @param value The attribute type. 667 * 668 * @see SVGUtils#SVGATTRIBUTE_EnableBackground 669 */ 670 public void setEnableBackground( final String value ) { setAttribute( SVGATTRIBUTE_EnableBackground, value ); } 671 672 /** 673 * Sets the global event attribute {@code onended} for this SVG element. 674 * 675 * @param value The attribute type. 676 * 677 * @see SVGUtils#SVGATTRIBUTE_OnEnded 678 */ 679 public void setEndedHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnEnded, value ); } 680 681 /** 682 * Sets the global event attribute {@code onerror} for this SVG element. 683 * 684 * @param value The attribute type. 685 * 686 * @see SVGUtils#SVGATTRIBUTE_OnError 687 */ 688 public void setErrorHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnError, value ); } 689 690 /** 691 * Sets the attribute that indicates whether external resources are 692 * required to render this SVG element. 693 * 694 * @param flag {@code true} if external resources are needed, 695 * {@code false} if all required resources are local to the current 696 * context. 697 */ 698 public void setExternalResourcesRequired( final boolean flag ) 699 { 700 setAttribute( SVGATTRIBUTE_ExternalResourcesRequired, flag ); 701 } // setExternalResourcesRequired() 702 703 /** 704 * Sets the presentation attribute {@code fill} for this SVG element. 705 * 706 * @param value The attribute type. 707 * 708 * @see SVGUtils#SVGATTRIBUTE_Fill 709 */ 710 @SuppressWarnings( "UseOfConcreteClass" ) 711 public void setFill( final SVGPaint value ) 712 { 713 setAttribute( SVGATTRIBUTE_Fill, nonNull( value ) ? value.value() : null ); 714 } // setFill() 715 716 /** 717 * Sets the presentation attribute {@code fill-opacity} for this SVG element. 718 * 719 * @param value The attribute type. 720 * 721 * @see SVGUtils#SVGATTRIBUTE_FillOpacity 722 */ 723 public void setFillOpacity( final String value ) { setAttribute( SVGATTRIBUTE_FillOpacity, value ); } 724 725 /** 726 * Sets the presentation attribute {@code fill-rule} for this SVG element. 727 * 728 * @param value The attribute type. 729 * 730 * @see SVGUtils#SVGATTRIBUTE_FillRule 731 */ 732 public void setFillRule( final String value ) { setAttribute( SVGATTRIBUTE_FillRule, value ); } 733 734 /** 735 * Sets the presentation attribute {@code filter} for this SVG element. 736 * 737 * @param value The attribute type. 738 * 739 * @see SVGUtils#SVGATTRIBUTE_Filter 740 */ 741 public void setFilter( final String value ) { setAttribute( SVGATTRIBUTE_Filter, value ); } 742 743 /** 744 * Sets the presentation attribute {@code flood-color} for this SVG element. 745 * 746 * @param value The attribute type. 747 * 748 * @see SVGUtils#SVGATTRIBUTE_FloodColor 749 */ 750 public void setFloodColor( final String value ) { setAttribute( SVGATTRIBUTE_FloodColor, value ); } 751 752 /** 753 * Sets the presentation attribute {@code flood-opacity} for this SVG element. 754 * 755 * @param value The attribute type. 756 * 757 * @see SVGUtils#SVGATTRIBUTE_FloodOpacity 758 */ 759 public void setFloodOpacity( final String value ) { setAttribute( SVGATTRIBUTE_FloodOpacity, value ); } 760 761 /** 762 * Sets the global event attribute {@code onfocus} for this SVG element. 763 * 764 * @param value The attribute type. 765 * 766 * @see SVGUtils#SVGATTRIBUTE_OnFocus 767 */ 768 public void setFocusHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnFocus, value ); } 769 770 /** 771 * Sets the focus-in handler for this SVG element. 772 * 773 * @param value The focus-in handler. 774 * 775 * @see SVGUtils#SVGATTRIBUTE_OnFocusIn 776 */ 777 public void setFocusInHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnFocusIn, value ); } 778 779 /** 780 * Sets the focus-out handler for this SVG element. 781 * 782 * @param value The focus-out handler. 783 * 784 * @see SVGUtils#SVGATTRIBUTE_OnFocusOut 785 */ 786 public void setFocusOutHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnFocusOut, value ); } 787 788 /** 789 * Sets the presentation attribute {@code font-family} for this SVG element. 790 * 791 * @param value The attribute type. 792 * 793 * @see SVGUtils#SVGATTRIBUTE_FontFamily 794 */ 795 public void setFontFamily( final String value ) { setAttribute( SVGATTRIBUTE_FontFamily, value ); } 796 797 /** 798 * Sets the presentation attribute {@code font-size} for this SVG element. 799 * 800 * @param value The attribute type. 801 * 802 * @see SVGUtils#SVGATTRIBUTE_FontSize 803 */ 804 public void setFontSize( final String value ) { setAttribute( SVGATTRIBUTE_FontSize, value ); } 805 806 /** 807 * Sets the presentation attribute {@code font-size-adjust} for this SVG element. 808 * 809 * @param value The attribute type. 810 * 811 * @see SVGUtils#SVGATTRIBUTE_FontSizeAdjust 812 */ 813 public void setFontSizeAdjust( final String value ) { setAttribute( SVGATTRIBUTE_FontSizeAdjust, value ); } 814 815 /** 816 * Sets the presentation attribute {@code font-stretch} for this SVG element. 817 * 818 * @param value The attribute type. 819 * 820 * @see SVGUtils#SVGATTRIBUTE_FontStretch 821 */ 822 public void setFontStretch( final String value ) { setAttribute( SVGATTRIBUTE_FontStretch, value ); } 823 824 /** 825 * Sets the presentation attribute {@code font-style} for this SVG element. 826 * 827 * @param value The attribute type. 828 * 829 * @see SVGUtils#SVGATTRIBUTE_FontStyle 830 */ 831 public void setFontStyle( final String value ) { setAttribute( SVGATTRIBUTE_FontStyle, value ); } 832 833 /** 834 * Sets the presentation attribute {@code font-variant} for this SVG element. 835 * 836 * @param value The attribute type. 837 * 838 * @see SVGUtils#SVGATTRIBUTE_FontVariant 839 */ 840 public void setFontVariant( final String value ) { setAttribute( SVGATTRIBUTE_FontVariant, value ); } 841 842 /** 843 * Sets the presentation attribute {@code font-weight} for this SVG element. 844 * 845 * @param value The attribute type. 846 * 847 * @see SVGUtils#SVGATTRIBUTE_FontWeight 848 */ 849 public void setFontWeight( final String value ) { setAttribute( SVGATTRIBUTE_FontWeight, value ); } 850 851 /** 852 * Sets the presentation attribute {@code glyph-orientation-horizontal} for this SVG element. 853 * 854 * @param value The attribute type. 855 * 856 * @see SVGUtils#SVGATTRIBUTE_GlyphOrientationHorizontal 857 */ 858 public void setGlyphOrientationHorizontal( final String value ) { setAttribute( SVGATTRIBUTE_GlyphOrientationHorizontal, value ); } 859 860 /** 861 * Sets the presentation attribute {@code glyph-orientation-vertical} for this SVG element. 862 * 863 * @param value The attribute type. 864 * 865 * @see SVGUtils#SVGATTRIBUTE_GlyphOrientationVertical 866 */ 867 public void setGlyphOrientationVertical( final String value ) { setAttribute( SVGATTRIBUTE_GlyphOrientationVertical, value ); } 868 869 /** 870 * Sets the height of the element. 871 * 872 * @param value The height. 873 */ 874 @SuppressWarnings( "UseOfConcreteClass" ) 875 public void setHeight( final SVGNumber value ) 876 { 877 if( nonNull( value ) && value.isNegative() ) throw new IllegalArgumentException( "height is negative" ); 878 setAttribute( SVGATTRIBUTE_Height, value ); 879 } // setHeight() 880 881 /** 882 * {@inheritDoc} 883 */ 884 @Override 885 public XMLElement setId( final String id ) throws IllegalArgumentException 886 { 887 if( !getNMTokenValidator().test( requireNotEmptyArgument( id, "id" ) ) ) throw new IllegalArgumentException( "Invalid id: %s".formatted( id ) ); 888 final var retValue = setAttribute( SVGATTRIBUTE_Id, id ); 889 890 //---* Done *---------------------------------------------------------- 891 return retValue; 892 } // setId() 893 894 /** 895 * Sets the presentation attribute {@code image-rendering} for this SVG element. 896 * 897 * @param value The attribute type. 898 * 899 * @see SVGUtils#SVGATTRIBUTE_ImageRendering 900 */ 901 public void setImageRendering( final String value ) { setAttribute( SVGATTRIBUTE_ImageRendering, value ); } 902 903 /** 904 * Sets the global event attribute {@code oninput} for this SVG element. 905 * 906 * @param value The attribute type. 907 * 908 * @see SVGUtils#SVGATTRIBUTE_OnInput 909 */ 910 public void setInputHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnInput, value ); } 911 912 /** 913 * Sets the global event attribute {@code oninvalid} for this SVG element. 914 * 915 * @param value The attribute type. 916 * 917 * @see SVGUtils#SVGATTRIBUTE_OnInvalid 918 */ 919 public void setInvalidHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnInvalid, value ); } 920 921 /** 922 * Sets the presentation attribute {@code kerning} for this SVG element. 923 * 924 * @param value The attribute type. 925 * 926 * @see SVGUtils#SVGATTRIBUTE_Kerning 927 */ 928 public void setKerning( final String value ) { setAttribute( SVGATTRIBUTE_Kerning, value ); } 929 930 /** 931 * Sets the global event attribute {@code onkeydown} for this SVG element. 932 * 933 * @param value The attribute type. 934 * 935 * @see SVGUtils#SVGATTRIBUTE_OnKeyDown 936 */ 937 public void setKeyDownHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnKeyDown, value ); } 938 939 /** 940 * Sets the global event attribute {@code onkeypress} for this SVG element. 941 * 942 * @param value The attribute type. 943 * 944 * @see SVGUtils#SVGATTRIBUTE_OnKeyPress 945 */ 946 public void setKeyPressHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnKeyPress, value ); } 947 948 /** 949 * Sets the global event attribute {@code onkeyup} for this SVG element. 950 * 951 * @param value The attribute type. 952 * 953 * @see SVGUtils#SVGATTRIBUTE_OnKeyUp 954 */ 955 public void setKeyUpHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnKeyUp, value ); } 956 957 /** 958 * {@inheritDoc} 959 */ 960 @Override 961 public void setLang( final Locale value ) 962 { 963 setAttribute( SVGATTRIBUTE_Lang, nonNull( value ) ? value.getLanguage() : null ); 964 } // setLang() 965 966 /** 967 * Sets the presentation attribute {@code letter-spacing} for this SVG element. 968 * 969 * @param value The attribute type. 970 * 971 * @see SVGUtils#SVGATTRIBUTE_LetterSpacing 972 */ 973 public void setLetterSpacing( final String value ) { setAttribute( SVGATTRIBUTE_LetterSpacing, value ); } 974 975 /** 976 * Sets the presentation attribute {@code lighting-color} for this SVG element. 977 * 978 * @param value The attribute type. 979 * 980 * @see SVGUtils#SVGATTRIBUTE_LightingColor 981 */ 982 public void setLightingColor( final String value ) { setAttribute( SVGATTRIBUTE_LightingColor, value ); } 983 984 /** 985 * Sets the global event attribute {@code onloadeddata} for this SVG element. 986 * 987 * @param value The attribute type. 988 * 989 * @see SVGUtils#SVGATTRIBUTE_OnLoadedData 990 */ 991 public void setLoadedDataHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnLoadedData, value ); } 992 993 /** 994 * Sets the global event attribute {@code onloadedmetadata} for this SVG element. 995 * 996 * @param value The attribute type. 997 * 998 * @see SVGUtils#SVGATTRIBUTE_OnLoadedMetadata 999 */ 1000 public void setLoadedMetadataHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnLoadedMetadata, value ); } 1001 1002 /** 1003 * Sets the global event attribute {@code onload} for this SVG element. 1004 * 1005 * @param value The attribute type. 1006 * 1007 * @see SVGUtils#SVGATTRIBUTE_OnLoad 1008 */ 1009 public void setLoadHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnLoad, value ); } 1010 1011 /** 1012 * Sets the global event attribute {@code onloadstart} for this SVG element. 1013 * 1014 * @param value The attribute type. 1015 * 1016 * @see SVGUtils#SVGATTRIBUTE_OnLoadStart 1017 */ 1018 public void setLoadStartHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnLoadStart, value ); } 1019 1020 /** 1021 * Sets the {@code marker-end} attribute for this SVG element. 1022 * 1023 * @param value The URI for the marker. 1024 * 1025 * @see SVGUtils#SVGATTRIBUTE_MarkerEnd 1026 */ 1027 public void setMarkerEnd( final URI value ) 1028 { 1029 setAttribute( SVGATTRIBUTE_MarkerEnd, nonNull( value ) ? format( "url(%s)", value.toString() ) : null ); 1030 } // setMarkerStart() 1031 1032 /** 1033 * Sets the {@code marker-mid} attribute for this SVG element. 1034 * 1035 * @param value The URI for the marker. 1036 * 1037 * @see SVGUtils#SVGATTRIBUTE_MarkerMid 1038 */ 1039 public void setMarkerMid( final URI value ) 1040 { 1041 setAttribute( SVGATTRIBUTE_MarkerMid, nonNull( value ) ? format( "url(%s)", value.toString() ) : null ); 1042 } // setMarkerStart() 1043 1044 /** 1045 * Sets the {@code marker-start} attribute for this SVG element. 1046 * 1047 * @param value The URI for the marker. 1048 * 1049 * @see SVGUtils#SVGATTRIBUTE_MarkerStart 1050 */ 1051 public void setMarkerStart( final URI value ) 1052 { 1053 setAttribute( SVGATTRIBUTE_MarkerStart, nonNull( value ) ? format( "url(%s)", value.toString() ) : null ); 1054 } // setMarkerStart() 1055 1056 /** 1057 * Sets the presentation attribute {@code mask} for this SVG element. 1058 * 1059 * @param value The attribute type. 1060 * 1061 * @see SVGUtils#SVGATTRIBUTE_Mask 1062 */ 1063 public void setMask( final String value ) { setAttribute( SVGATTRIBUTE_Mask, value ); } 1064 1065 /** 1066 * Sets the global event attribute {@code onmousedown} for this SVG element. 1067 * 1068 * @param value The attribute type. 1069 * 1070 * @see SVGUtils#SVGATTRIBUTE_OnMouseDown 1071 */ 1072 public void setMouseDownHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnMouseDown, value ); } 1073 1074 /** 1075 * Sets the global event attribute {@code onmouseenter} for this SVG element. 1076 * 1077 * @param value The attribute type. 1078 * 1079 * @see SVGUtils#SVGATTRIBUTE_OnMouseEnter 1080 */ 1081 public void setMouseEnterHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnMouseEnter, value ); } 1082 1083 /** 1084 * Sets the global event attribute {@code onmouseleave} for this SVG element. 1085 * 1086 * @param value The attribute type. 1087 * 1088 * @see SVGUtils#SVGATTRIBUTE_OnMouseLeave 1089 */ 1090 public void setMouseLeaveHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnMouseLeave, value ); } 1091 1092 /** 1093 * Sets the global event attribute {@code onmousemove} for this SVG element. 1094 * 1095 * @param value The attribute type. 1096 * 1097 * @see SVGUtils#SVGATTRIBUTE_OnMouseMove 1098 */ 1099 public void setMouseMoveHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnMouseMove, value ); } 1100 1101 /** 1102 * Sets the global event attribute {@code onmouseout} for this SVG element. 1103 * 1104 * @param value The attribute type. 1105 * 1106 * @see SVGUtils#SVGATTRIBUTE_OnMouseOut 1107 */ 1108 public void setMouseOutHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnMouseOut, value ); } 1109 1110 /** 1111 * Sets the global event attribute {@code onmouseover} for this SVG element. 1112 * 1113 * @param value The attribute type. 1114 * 1115 * @see SVGUtils#SVGATTRIBUTE_OnMouseOver 1116 */ 1117 public void setMouseOverHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnMouseOver, value ); } 1118 1119 /** 1120 * Sets the global event attribute {@code onmouseup} for this SVG element. 1121 * 1122 * @param value The attribute type. 1123 * 1124 * @see SVGUtils#SVGATTRIBUTE_OnMouseUp 1125 */ 1126 public void setMouseUpHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnMouseUp, value ); } 1127 1128 /** 1129 * Sets the global event attribute {@code onmousewheel} for this SVG element. 1130 * 1131 * @param value The attribute type. 1132 * 1133 * @see SVGUtils#SVGATTRIBUTE_OnMouseWheel 1134 */ 1135 public void setMouseWheelHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnMouseWheel, value ); } 1136 1137 /** 1138 * Sets the presentation attribute {@code opacity} for this SVG element. 1139 * 1140 * @param value The attribute type. 1141 * 1142 * @see SVGUtils#SVGATTRIBUTE_Opacity 1143 */ 1144 public void setOpacity( final String value ) { setAttribute( SVGATTRIBUTE_Opacity, value ); } 1145 1146 /** 1147 * Sets the presentation attribute {@code overflow} for this SVG element. 1148 * 1149 * @param value The attribute type. 1150 * 1151 * @see SVGUtils#SVGATTRIBUTE_Overflow 1152 */ 1153 public void setOverflow( final String value ) { setAttribute( SVGATTRIBUTE_Overflow, value ); } 1154 1155 /** 1156 * Sets the paste handler for this SVG element. 1157 * 1158 * @param value The paste handler. 1159 * 1160 * @see SVGUtils#SVGATTRIBUTE_OnPaste 1161 */ 1162 public void setPasteHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnPaste, value ); } 1163 1164 /** 1165 * Sets the length of the path represented by this SVG element.<br> 1166 * <br>Various operations, including text on a path and motion animation 1167 * and various stroke operations, require that the user agent compute the 1168 * distance along the geometry of a graphics element, such as a 1169 * ‘path’.<br> 1170 * <br>Exact mathematics exist for computing distance along a path, but 1171 * the formulas are highly complex and require substantial computation. 1172 * It is recommended that authoring products and user agents employ 1173 * algorithms that produce as precise results as possible; however, to 1174 * accommodate implementation differences and to help distance 1175 * calculations produce results that approximate author intent, the 1176 * {@code pathLength} attribute can be used to provide the author's 1177 * computation of the total length of the path so that the user agent can 1178 * scale distance-along-a-path computations by the ratio of 1179 * {@code pathLength} to the user agent's own computed type for total 1180 * path length. 1181 * 1182 * @param length The author's computation of the total length of the 1183 * path, in user units. This type is used to calibrate the user 1184 * agent's own distance-along-a-path calculations with that of the 1185 * author. The user agent will scale all distance-along-a-path 1186 * computations by the ratio of this type to the user agent's own 1187 * computed type for total path length.<br> 1188 * <br>A type of zero is valid, but a negative type is an error. 1189 * 1190 * @throws IllegalArgumentException The type is less than 0. 1191 */ 1192 @SuppressWarnings( "UseOfConcreteClass" ) 1193 public void setPathLength( final SVGUserUnitValue length ) 1194 { 1195 if( nonNull( length ) && length.isNegative() ) throw new IllegalArgumentException( "length is negative: %s".formatted( length.value() ) ); 1196 1197 setAttribute( SVGATTRIBUTE_PathLength, nonNull( length ) ? length.toString() : null ); 1198 } // setPathLength() 1199 1200 /** 1201 * Sets the global event attribute {@code onpause} for this SVG element. 1202 * 1203 * @param value The attribute type. 1204 * 1205 * @see SVGUtils#SVGATTRIBUTE_OnPause 1206 */ 1207 public void setPauseHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnPause, value ); } 1208 1209 /** 1210 * Sets the global event attribute {@code onplay} for this SVG element. 1211 * 1212 * @param value The attribute type. 1213 * 1214 * @see SVGUtils#SVGATTRIBUTE_OnPlay 1215 */ 1216 public void setPlayHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnPlay, value ); } 1217 1218 /** 1219 * Sets the global event attribute {@code onplaying} for this SVG element. 1220 * 1221 * @param value The attribute type. 1222 * 1223 * @see SVGUtils#SVGATTRIBUTE_OnPlaying 1224 */ 1225 public void setPlayingHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnPlaying, value ); } 1226 1227 /** 1228 * Sets the presentation attribute {@code pointer-events} for this SVG element. 1229 * 1230 * @param value The attribute type. 1231 * 1232 * @see SVGUtils#SVGATTRIBUTE_PointerEvents 1233 */ 1234 public void setPointerEvents( final String value ) { setAttribute( SVGATTRIBUTE_PointerEvents, value ); } 1235 1236 /** 1237 * Sets the mode for the aspect ratio preservation for this element. 1238 * 1239 * @param value The type; if {@code null} the 1240 * attribute will be removed. 1241 */ 1242 public void setPreserveAspectRatio( final SVGPreserveAspectRatio value ) 1243 { 1244 setAttribute( SVGATTRIBUTE_PreserveAspectRatio, nonNull( value ) ? value.toString() : null ); 1245 } // setPreserveAspectRatio() 1246 1247 /** 1248 * {@inheritDoc} 1249 */ 1250 @Override 1251 public void setPreserveSpace( final boolean flag ) 1252 { 1253 setAttribute( XMLATTRIBUTE_Whitespace, flag ? "preserve" : "default" ); 1254 } // setPreserveSpace() 1255 1256 /** 1257 * Sets the global event attribute {@code onprogress} for this SVG element. 1258 * 1259 * @param value The attribute type. 1260 * 1261 * @see SVGUtils#SVGATTRIBUTE_OnProgress 1262 */ 1263 public void setProgressHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnProgress, value ); } 1264 1265 /** 1266 * Sets the global event attribute {@code onratechange} for this SVG element. 1267 * 1268 * @param value The attribute type. 1269 * 1270 * @see SVGUtils#SVGATTRIBUTE_OnRateChange 1271 */ 1272 public void setRateChangeHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnRateChange, value ); } 1273 1274 /** 1275 * Sets the 1276 * {@value org.tquadrat.foundation.svg.SVGUtils#SVGATTRIBUTE_Reference} 1277 * attribute that refers to another SVG element. 1278 * 1279 * @param reference The reference. 1280 */ 1281 @SuppressWarnings( "PublicMethodNotExposedInInterface" ) 1282 public void setReference( final URI reference ) 1283 { 1284 setAttribute( SVGATTRIBUTE_Reference, nonNull( reference ) ? requireNotEmptyArgument( reference, "reference" ).toString() : null ); 1285 } // setReference() 1286 1287 /** 1288 * Sets a list of extensions that are required to render this SVG element. 1289 * 1290 * @param values The URIs that identify the required extensions. 1291 */ 1292 public void setRequiredExtensions( final URI... values ) 1293 { 1294 setAttribute( SVGATTRIBUTE_RequiredExtensions, nonNull( values ) 1295 ? stream( values ) 1296 .map( URI::toString ) 1297 .collect( joining( " " ) ) 1298 : null ); 1299 } // setRequiredExtensions 1300 1301 /** 1302 * Sets a list of features that are required to render this SVG element. 1303 * 1304 * @param values The URIs that identify the required features. 1305 */ 1306 public void setRequiredFeatures( final URI... values ) 1307 { 1308 setAttribute( SVGATTRIBUTE_RequiredFeatures, nonNull( values ) 1309 ? stream( values ) 1310 .map( URI::toString ) 1311 .collect( joining( " " ) ) 1312 : null ); 1313 } // setRequiredFeatures() 1314 1315 /** 1316 * Sets the global event attribute {@code onreset} for this SVG element. 1317 * 1318 * @param value The attribute type. 1319 * 1320 * @see SVGUtils#SVGATTRIBUTE_OnReset 1321 */ 1322 public void setResetHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnReset, value ); } 1323 1324 /** 1325 * Sets the resize handler for this SVG element. 1326 * 1327 * @param value The resize handler. 1328 * 1329 * @see SVGUtils#SVGATTRIBUTE_OnResize 1330 */ 1331 public void setResizeHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnResize, value ); } 1332 1333 /** 1334 * Sets the {@value SVGUtils#SVGATTRIBUTE_rx} attribute for this SVG 1335 * element.<br> 1336 * <br>The attribute is a radius, but what kind of radius and where it is 1337 * used depends on the type of the SVG element. 1338 * 1339 * @param value The attribute type. 1340 * 1341 * @see SVGUtils#SVGATTRIBUTE_rx 1342 */ 1343 @SuppressWarnings( "UseOfConcreteClass" ) 1344 public void setRx( final SVGNumber value ) 1345 { 1346 if( nonNull( value ) && value.isNegative() ) throw new IllegalArgumentException( "rx is negative" ); 1347 setAttribute( SVGATTRIBUTE_rx, value ); 1348 } // setRx() 1349 1350 /** 1351 * Sets the {@value SVGUtils#SVGATTRIBUTE_ry} attribute for this SVG 1352 * element.<br> 1353 * <br>The attribute is a radius, but what kind of radius and where it is 1354 * used depends on the type of the SVG element. 1355 * 1356 * @param value The attribute type. 1357 * 1358 * @see SVGUtils#SVGATTRIBUTE_ry 1359 */ 1360 @SuppressWarnings( "UseOfConcreteClass" ) 1361 public void setRy( final SVGNumber value ) 1362 { 1363 if( nonNull( value ) && value.isNegative() ) throw new IllegalArgumentException( "ry is negative" ); 1364 setAttribute( SVGATTRIBUTE_ry, value ); 1365 } // setRy() 1366 1367 /** 1368 * Sets the scroll handler for this SVG element. 1369 * 1370 * @param value The scroll handler. 1371 * 1372 * @see SVGUtils#SVGATTRIBUTE_OnScroll 1373 */ 1374 public void setScrollHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnScroll, value ); } 1375 1376 /** 1377 * Sets the global event attribute {@code onseeked} for this SVG element. 1378 * 1379 * @param value The attribute type. 1380 * 1381 * @see SVGUtils#SVGATTRIBUTE_OnSeeked 1382 */ 1383 public void setSeekedHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnSeeked, value ); } 1384 1385 /** 1386 * Sets the global event attribute {@code onseeking} for this SVG element. 1387 * 1388 * @param value The attribute type. 1389 * 1390 * @see SVGUtils#SVGATTRIBUTE_OnSeeking 1391 */ 1392 public void setSeekingHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnSeeking, value ); } 1393 1394 /** 1395 * Sets the global event attribute {@code onselect} for this SVG element. 1396 * 1397 * @param value The attribute type. 1398 * 1399 * @see SVGUtils#SVGATTRIBUTE_OnSelect 1400 */ 1401 public void setSelectHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnSelect, value ); } 1402 1403 /** 1404 * Sets the presentation attribute {@code shape-rendering} for this SVG element. 1405 * 1406 * @param value The attribute type. 1407 * 1408 * @see SVGUtils#SVGATTRIBUTE_ShapeRendering 1409 */ 1410 public void setShapeRendering( final String value ) { setAttribute( SVGATTRIBUTE_ShapeRendering, value ); } 1411 1412 /** 1413 * Sets the global event attribute {@code onshow} for this SVG element. 1414 * 1415 * @param value The attribute type. 1416 * 1417 * @see SVGUtils#SVGATTRIBUTE_OnShow 1418 */ 1419 public void setShowHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnShow, value ); } 1420 1421 /** 1422 * Sets the global event attribute {@code onstalled} for this SVG element. 1423 * 1424 * @param value The attribute type. 1425 * 1426 * @see SVGUtils#SVGATTRIBUTE_OnStalled 1427 */ 1428 public void setStalledHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnStalled, value ); } 1429 1430 /** 1431 * Sets the presentation attribute {@code stop-color} for this SVG element. 1432 * 1433 * @param value The attribute type. 1434 * 1435 * @see SVGUtils#SVGATTRIBUTE_StopColor 1436 */ 1437 public void setStopColor( final String value ) { setAttribute( SVGATTRIBUTE_StopColor, value ); } 1438 1439 /** 1440 * Sets the presentation attribute {@code stop-opacity} for this SVG element. 1441 * 1442 * @param value The attribute type. 1443 * 1444 * @see SVGUtils#SVGATTRIBUTE_StopOpacity 1445 */ 1446 public void setStopOpacity( final String value ) { setAttribute( SVGATTRIBUTE_StopOpacity, value ); } 1447 1448 /** 1449 * Sets the presentation attribute {@code stroke} for this SVG element. 1450 * 1451 * @param value The attribute type. 1452 * 1453 * @see SVGUtils#SVGATTRIBUTE_Stroke 1454 */ 1455 @SuppressWarnings( "UseOfConcreteClass" ) 1456 public void setStroke( final SVGPaint value ) 1457 { 1458 setAttribute( SVGATTRIBUTE_Stroke, nonNull( value ) ? value.value() : null ); 1459 } // setStroke() 1460 1461 /** 1462 * Sets the presentation attribute {@code stroke-dasharray} for this SVG element. 1463 * 1464 * @param value The attribute type. 1465 * 1466 * @see SVGUtils#SVGATTRIBUTE_StrokeDashArray 1467 */ 1468 public void setStrokeDashArray( final String value ) { setAttribute( SVGATTRIBUTE_StrokeDashArray, value ); } 1469 1470 /** 1471 * Sets the presentation attribute {@code stroke-dashoffset} for this SVG element. 1472 * 1473 * @param value The attribute type. 1474 * 1475 * @see SVGUtils#SVGATTRIBUTE_StrokeDashOffset 1476 */ 1477 public void setStrokeDashOffset( final String value ) { setAttribute( SVGATTRIBUTE_StrokeDashOffset, value ); } 1478 1479 /** 1480 * Sets the presentation attribute {@code stroke-linecap} for this SVG element. 1481 * 1482 * @param value The attribute type. 1483 * 1484 * @see SVGUtils#SVGATTRIBUTE_StrokeLineCap 1485 */ 1486 public void setStrokeLineCap( final String value ) { setAttribute( SVGATTRIBUTE_StrokeLineCap, value ); } 1487 1488 /** 1489 * Sets the presentation attribute {@code stroke-linejoin} for this SVG element. 1490 * 1491 * @param value The attribute type. 1492 * 1493 * @see SVGUtils#SVGATTRIBUTE_StrokeLineJoin 1494 */ 1495 public void setStrokeLineJoin( final String value ) { setAttribute( SVGATTRIBUTE_StrokeLineJoin, value ); } 1496 1497 /** 1498 * Sets the presentation attribute {@code stroke-miterlimit} for this SVG element. 1499 * 1500 * @param value The attribute type. 1501 * 1502 * @see SVGUtils#SVGATTRIBUTE_StrokeMiterLimit 1503 */ 1504 public void setStrokeMiterLimit( final String value ) { setAttribute( SVGATTRIBUTE_StrokeMiterLimit, value ); } 1505 1506 /** 1507 * Sets the presentation attribute {@code stroke-opacity} for this SVG 1508 * element.<br> 1509 * <br>Any type outside the range 0.0 (fully transparent) to 1.0 (fully 1510 * opaque) will be clamped to this range. 1511 * 1512 * @param value The attribute type. 1513 * 1514 * @see SVGUtils#SVGATTRIBUTE_StrokeOpacity 1515 */ 1516 public void setStrokeOpacity( final double value ) 1517 { 1518 if( Double.isNaN( value ) ) throw new IllegalArgumentException( "type is NaN" ); 1519 setAttribute( SVGATTRIBUTE_StrokeOpacity, value < 0.0 ? 0.0 : min( value, 1.0 ) ); 1520 } // setStrokeOpacity() 1521 1522 /** 1523 * Sets the presentation attribute {@code stroke-width} for this SVG element. 1524 * 1525 * @param value The attribute type. 1526 * 1527 * @see SVGUtils#SVGATTRIBUTE_StrokeWidth 1528 */ 1529 @SuppressWarnings( "UseOfConcreteClass" ) 1530 public void setStrokeWidth( final SVGNumber value ) 1531 { 1532 setAttribute( SVGATTRIBUTE_StrokeWidth, nonNull( value ) ? value.toString() : null ); 1533 } // setStrokeWidth() 1534 1535 /** 1536 * Sets the CSS style for the SVG element. 1537 * 1538 * @param value A CSS style definition. 1539 */ 1540 public void setStyle( final CharSequence value ) 1541 { 1542 setAttribute( SVGATTRIBUTE_Style, value, Optional.of( "; " ) ); 1543 } // setStyle() 1544 1545 /** 1546 * Sets the global event attribute {@code onsubmit} for this SVG element. 1547 * 1548 * @param value The attribute type. 1549 * 1550 * @see SVGUtils#SVGATTRIBUTE_OnSubmit 1551 */ 1552 public void setSubmitHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnSubmit, value ); } 1553 1554 /** 1555 * Sets the global event attribute {@code onsuspend} for this SVG element. 1556 * 1557 * @param value The attribute type. 1558 * 1559 * @see SVGUtils#SVGATTRIBUTE_OnSuspend 1560 */ 1561 public void setSuspendHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnSuspend, value ); } 1562 1563 /** 1564 * Sets a list of languages; the current SVG element will be rendered 1565 * only if the current system language matches one entry of this list. 1566 * 1567 * @param values The allowed languages. 1568 */ 1569 public void setSystemLanguage( final Locale... values ) 1570 { 1571 setAttribute( SVGATTRIBUTE_SystemLanguage, nonNull( values ) 1572 ? stream( values ) 1573 .map( Locale::getLanguage ) 1574 .collect( joining( "," ) ) 1575 : null ); 1576 } // setSystemLanguage() 1577 1578 /** 1579 * {@inheritDoc} 1580 */ 1581 @Override 1582 public void setTabIndex( final int value ) { setAttribute( SVGATTRIBUTE_TabIndex, value ); } 1583 1584 /** 1585 * Sets the presentation attribute {@code text-anchor} for this SVG element. 1586 * 1587 * @param value The attribute type. 1588 * 1589 * @see SVGUtils#SVGATTRIBUTE_TextAnchor 1590 */ 1591 public void setTextAnchor( final String value ) { setAttribute( SVGATTRIBUTE_TextAnchor, value ); } 1592 1593 /** 1594 * Sets the presentation attribute {@code text-decoration} for this SVG element. 1595 * 1596 * @param value The attribute type. 1597 * 1598 * @see SVGUtils#SVGATTRIBUTE_TextDecoration 1599 */ 1600 public void setTextDecoration( final String value ) { setAttribute( SVGATTRIBUTE_TextDecoration, value ); } 1601 1602 /** 1603 * Sets the presentation attribute {@code text-rendering} for this SVG element. 1604 * 1605 * @param value The attribute type. 1606 * 1607 * @see SVGUtils#SVGATTRIBUTE_TextRendering 1608 */ 1609 public void setTextRendering( final String value ) { setAttribute( SVGATTRIBUTE_TextRendering, value ); } 1610 1611 /** 1612 * Sets the global event attribute {@code ontimeupdate} for this SVG element. 1613 * 1614 * @param value The attribute type. 1615 * 1616 * @see SVGUtils#SVGATTRIBUTE_OnTimeUpdate 1617 */ 1618 public void setTimeUpdateHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnTimeUpdate, value ); } 1619 1620 /** 1621 * {@inheritDoc} 1622 */ 1623 @Override 1624 public void setTitle( final CharSequence title ) 1625 { 1626 if( isNotEmptyOrBlank( title ) ) 1627 { 1628 if( m_HasTitle ) throw new IllegalStateException( "Title was already set" ); 1629 1630 final var element = new SVGElementImpl( SVGELEMENT_Title, ALLOWS_TEXT ); 1631 element.updateRegistries( emptyList(), emptyList() ); 1632 element.addText( title ); 1633 addChild( (SVGElement) element ); 1634 m_HasTitle = true; 1635 } 1636 } // setTitle() 1637 1638 /** 1639 * Sets the global event attribute {@code ontoggle} for this SVG element. 1640 * 1641 * @param value The attribute type. 1642 * 1643 * @see SVGUtils#SVGATTRIBUTE_OnToggle 1644 */ 1645 public void setToggleHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnToggle, value ); } 1646 1647 /** 1648 * Sets the transformations for this SVG element. 1649 * 1650 * @param values The transformations. 1651 * 1652 * @see SVGUtils#SVGATTRIBUTE_Transform 1653 */ 1654 public void setTransform( final SVGTransform... values ) 1655 { 1656 final var value = nonNull( values ) && (values.length > 0) 1657 ? stream( values ) 1658 .map( SVGTransform::toString ) 1659 .collect( joining( " " ) ) 1660 : null; 1661 setAttribute( SVGATTRIBUTE_Transform, value, Optional.of( " " ) ); 1662 } // setTransform() 1663 1664 /** 1665 * Sets the presentation attribute {@code unicode-bidi} for this SVG element. 1666 * 1667 * @param value The attribute type. 1668 * 1669 * @see SVGUtils#SVGATTRIBUTE_UnicodeBidi 1670 */ 1671 public void setUnicodeBidi( final String value ) { setAttribute( SVGATTRIBUTE_UnicodeBidi, value ); } 1672 1673 /** 1674 * Sets the "unload" handler for this SVG element. 1675 * 1676 * @param value The unload handler. 1677 * 1678 * @see SVGUtils#SVGATTRIBUTE_OnUnload 1679 */ 1680 public void setUnloadHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnUnload, value ); } 1681 1682 /** 1683 * Sets the presentation attribute {@code vector-effect} for this SVG element. 1684 * 1685 * @param value The attribute type. 1686 * 1687 * @see SVGUtils#SVGATTRIBUTE_VectorEffect 1688 */ 1689 public void setVectorEffect( final String value ) { setAttribute( SVGATTRIBUTE_VectorEffect, value ); } 1690 1691 /** 1692 * Defines the visible area for this element. 1693 * 1694 * @param x The x coordinate of top left corner of the area. 1695 * @param y The y coordinate of top left corner of the area. 1696 * @param width The width of the area. 1697 * @param height The height of the area. 1698 */ 1699 @SuppressWarnings( "UseOfConcreteClass" ) 1700 public void setViewBox( final SVGNumber x, final SVGNumber y, final SVGNumber width, final SVGNumber height ) 1701 { 1702 final var value = format( "%s,%s,%s,%s", requireNonNullArgument( x, "x" ), requireNonNullArgument( y, "y" ), requireNonNullArgument( width, "width" ), requireNonNullArgument( height, "height" ) ); 1703 setAttribute( SVGATTRIBUTE_ViewBox, value ); 1704 } // setViewBox() 1705 1706 /** 1707 * Sets the presentation attribute {@code visibility} for this SVG element. 1708 * 1709 * @param value The attribute type. 1710 * 1711 * @see SVGUtils#SVGATTRIBUTE_Visibility 1712 */ 1713 public void setVisibility( final String value ) { setAttribute( SVGATTRIBUTE_Visibility, value ); } 1714 1715 /** 1716 * Sets the global event attribute {@code onvolumechange} for this SVG element. 1717 * 1718 * @param value The attribute type. 1719 * 1720 * @see SVGUtils#SVGATTRIBUTE_OnVolumeChange 1721 */ 1722 public void setVolumeChangeHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnVolumeChange, value ); } 1723 1724 /** 1725 * Sets the wait handler for this SVG element. 1726 * 1727 * @param value The wait handler. 1728 * 1729 * @see SVGUtils#SVGATTRIBUTE_OnWaiting 1730 */ 1731 public void setWaitHandler( final String value ) { setAttribute( SVGATTRIBUTE_OnWaiting, value ); } 1732 1733 /** 1734 * Sets the width of the element. 1735 * 1736 * @param value The width. 1737 */ 1738 @SuppressWarnings( "UseOfConcreteClass" ) 1739 public void setWidth( final SVGNumber value ) 1740 { 1741 if( nonNull( value ) && value.isNegative() ) throw new IllegalArgumentException( "width is negative" ); 1742 setAttribute( SVGATTRIBUTE_Width, value ); 1743 } // setWidth() 1744 1745 /** 1746 * Sets the presentation attribute {@code word-spacing} for this SVG element. 1747 * 1748 * @param value The attribute type. 1749 * 1750 * @see SVGUtils#SVGATTRIBUTE_WordSpacing 1751 */ 1752 public void setWordSpacing( final String value ) { setAttribute( SVGATTRIBUTE_WordSpacing, value ); } 1753 1754 /** 1755 * Sets the presentation attribute {@code writing-mode} for this SVG element. 1756 * 1757 * @param value The attribute type. 1758 * 1759 * @see SVGUtils#SVGATTRIBUTE_WritingMode 1760 */ 1761 public void setWritingMode( final String value ) { setAttribute( SVGATTRIBUTE_WritingMode, value ); } 1762 1763 /** 1764 * Sets the x coordinate for the upper left corner of the element. 1765 * 1766 * @param value The x coordinate. 1767 */ 1768 @SuppressWarnings( "UseOfConcreteClass" ) 1769 public void setX( final SVGNumber value ) { setAttribute( SVGATTRIBUTE_x, value ); } 1770 1771 /** 1772 * Sets the XLink {@code actuate} attribute. 1773 * 1774 * @param value The attribute type. 1775 */ 1776 public void setXlinkActuate( final CharSequence value ) { setAttribute( SVGATTRIBUTE_XLink_Actuate, value ); } 1777 1778 /** 1779 * Sets the XLink {@code arcrole} attribute. 1780 * 1781 * @param value The attribute type. 1782 */ 1783 public void setXLinkArcRole( final CharSequence value ) { setAttribute( SVGATTRIBUTE_XLink_ArcRole, value ); } 1784 1785 /** 1786 * Sets the XLink {@code reference} attribute. 1787 * 1788 * @param value The attribute type. 1789 */ 1790 public void setXLinkReference( final CharSequence value ) { setAttribute( SVGATTRIBUTE_XLink_Reference, value ); } 1791 1792 /** 1793 * Sets the XLink {@code role} attribute. 1794 * 1795 * @param value The attribute type. 1796 */ 1797 public void setXLinkRole( final CharSequence value ) { setAttribute( SVGATTRIBUTE_XLink_Role, value ); } 1798 1799 /** 1800 * Sets the XLink {@code show} attribute. 1801 * 1802 * @param value The attribute type. 1803 */ 1804 public void setXLinkShow( final CharSequence value ) { setAttribute( SVGATTRIBUTE_XLink_Show, value ); } 1805 1806 /** 1807 * Sets the XLink {@code title} attribute. 1808 * 1809 * @param value The attribute type. 1810 */ 1811 public void setXLinkTitle( final CharSequence value ) { setAttribute( SVGATTRIBUTE_XLink_Title, value ); } 1812 1813 /** 1814 * Sets the XLink {@code type} attribute. 1815 * 1816 * @param value The attribute type. 1817 */ 1818 public void setXLinkType( final CharSequence value ) { setAttribute( SVGATTRIBUTE_XLink_Type, value ); } 1819 1820 /** 1821 * {@inheritDoc} 1822 */ 1823 @Override 1824 public void setXMLBase( final URI value ) 1825 { 1826 setAttribute( XMLATTRIBUTE_Base, nonNull( value ) ? value.toString() : null ); 1827 } // setXMLBase() 1828 1829 /** 1830 * {@inheritDoc} 1831 */ 1832 @Override 1833 public void setXMLId( final String id ) throws IllegalArgumentException { super.setId( id ); } 1834 1835 /** 1836 * {@inheritDoc} 1837 */ 1838 @Override 1839 public void setXMLLang( final Locale value ) 1840 { 1841 setAttribute( XMLATTRIBUTE_Language, nonNull( value ) ? value.getLanguage() : null ); 1842 } // setXMLLang() 1843 1844 /** 1845 * Sets the y coordinate for the upper left corner of the element. 1846 * 1847 * @param value The y coordinate. 1848 */ 1849 @SuppressWarnings( "UseOfConcreteClass" ) 1850 public void setY( final SVGNumber value ) { setAttribute( SVGATTRIBUTE_y, value ); } 1851 1852 /** 1853 * Updates the registries with the valid children and attributes for this 1854 * element. 1855 * 1856 * @param childElements The names of valid child elements. 1857 * @param attributes The names of valid attributes <i>in the sequence 1858 * they should have when the element written to output</i>. 1859 * 1860 * @see org.tquadrat.foundation.xml.builder.spi.AttributeSupport#registerAttributes(String...) 1861 * @see org.tquadrat.foundation.xml.builder.spi.AttributeSupport#registerSequence(String...) 1862 * @see org.tquadrat.foundation.xml.builder.spi.ChildSupport#registerChildren(String...) 1863 */ 1864 protected final void updateRegistries( final Collection<String> childElements, final Collection<String> attributes ) 1865 { 1866 registerValidChildren( requireNonNullArgument( childElements, "childElements" ).toArray( EMPTY_String_ARRAY ) ); 1867 1868 registerValidAttributes( requireNonNullArgument( attributes, "attributes" ).toArray( EMPTY_String_ARRAY ) ); 1869 1870 if( !attributes.isEmpty() ) 1871 { 1872 final var attributeSequence = attributes.stream().distinct().toArray( String []::new ); 1873 registerAttributeSequence( attributeSequence ); 1874 } 1875 } // updateRegistries() 1876} 1877// class SVGElementImpl 1878 1879/* 1880 * End of File 1881 */