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 org.apiguardian.api.API.Status.INTERNAL; 021import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Class; 022import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ClipPathUnits; 023import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_ExternalResourcesRequired; 024import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Id; 025import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Style; 026import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Transform; 027import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_ClipPath; 028import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_Text; 029import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_Use; 030import static org.tquadrat.foundation.svg.type.SVGElementCategory.ANIMATION; 031import static org.tquadrat.foundation.svg.type.SVGElementCategory.DESCRIPTIVE; 032import static org.tquadrat.foundation.svg.type.SVGElementCategory.SHAPE; 033import static org.tquadrat.foundation.xml.builder.XMLElement.Flags.ALLOWS_CHILDREN; 034import static org.tquadrat.foundation.xml.builder.XMLElement.Flags.VALIDATES_ATTRIBUTES; 035import static org.tquadrat.foundation.xml.builder.XMLElement.Flags.VALIDATES_CHILDREN; 036 037import java.util.ArrayList; 038import java.util.Collection; 039import java.util.HashSet; 040import java.util.List; 041 042import org.apiguardian.api.API; 043import org.tquadrat.foundation.annotation.ClassVersion; 044import org.tquadrat.foundation.svg.SVGClipPath; 045 046/** 047 * The implementation of the interface 048 * {@link SVGClipPath} 049 * for the SVG {@code <clipPath>} element. 050 * 051 * @extauthor Thomas Thrien - thomas.thrien@tquadrat.org 052 * @version $Id: SVGClipPathImpl.java 1151 2025-10-01 21:32:15Z tquadrat $ 053 * @since 0.0.5 054 * 055 * @UMLGraph.link 056 */ 057@ClassVersion( sourceVersion = "$Id: SVGClipPathImpl.java 1151 2025-10-01 21:32:15Z tquadrat $" ) 058@API( status = INTERNAL, since = "0.0.5" ) 059public final class SVGClipPathImpl extends SVGElementImpl implements SVGClipPath 060{ 061 /*--------------*\ 062 ====** Constructors **===================================================== 063 \*--------------*/ 064 /** 065 * Creates a new {@code SVGClipPathImpl} instance. 066 * 067 * @param id The mandatory id for the {@code <svg>} element. 068 */ 069 public SVGClipPathImpl( final String id ) 070 { 071 super( SVGELEMENT_ClipPath, ALLOWS_CHILDREN, VALIDATES_ATTRIBUTES, VALIDATES_CHILDREN ); 072 073 //---* The children and attributes for the <clipPatt> element *-------- 074 final Collection<String> childElements = new HashSet<>(); 075 childElements.addAll( ANIMATION.getElements() ); 076 childElements.addAll( DESCRIPTIVE.getElements() ); 077 childElements.addAll( SHAPE.getElements() ); 078 childElements.add( SVGELEMENT_Text ); 079 childElements.add( SVGELEMENT_Use ); 080 081 final Collection<String> attributes = new ArrayList<>(); 082 attributes.addAll( List.of( SVGATTRIBUTE_Id, SVGATTRIBUTE_Class, 083 SVGATTRIBUTE_Style, SVGATTRIBUTE_ExternalResourcesRequired, 084 SVGATTRIBUTE_Transform, SVGATTRIBUTE_ClipPathUnits ) ); 085 attributes.addAll( CORE_ATTRIBUTES ); 086 attributes.addAll( CONDITIONALPROCESSING_ATTRIBUTES ); 087 attributes.addAll( PRESENTATION_ATTRIBUTES ); 088 089 updateRegistries( childElements, attributes ); 090 091 setId( id ); 092 } // SVGClipPathImpl() 093 094 /*---------*\ 095 ====** Methods **========================================================== 096 \*---------*/ 097 /** 098 * {@inheritDoc} 099 */ 100 @Override 101 public final void setClipPathUnits( final boolean flag ) 102 { 103 setAttribute( SVGATTRIBUTE_ClipPathUnits, flag ? "objectBoundingBox" : "userSpaceOnUse" ); 104 } // setClipPathUnits() 105} 106// class SVGClipPathImpl 107 108/* 109 * End of File 110 */