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.lang.Objects.requireNotEmptyArgument;
022import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Height;
023import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Id;
024import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Reference;
025import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Width;
026import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_x;
027import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_y;
028import static org.tquadrat.foundation.svg.SVGUtils.SVGELEMENT_Use;
029import static org.tquadrat.foundation.svg.type.SVGElementCategory.ANIMATION;
030import static org.tquadrat.foundation.svg.type.SVGElementCategory.DESCRIPTIVE;
031import static org.tquadrat.foundation.xml.builder.XMLElement.Flags.ALLOWS_CHILDREN;
032import static org.tquadrat.foundation.xml.builder.XMLElement.Flags.VALIDATES_ATTRIBUTES;
033import static org.tquadrat.foundation.xml.builder.XMLElement.Flags.VALIDATES_CHILDREN;
034
035import java.net.URI;
036import java.util.ArrayList;
037import java.util.Collection;
038import java.util.HashSet;
039import java.util.List;
040
041import org.apiguardian.api.API;
042import org.tquadrat.foundation.annotation.ClassVersion;
043import org.tquadrat.foundation.svg.SVGUse;
044
045/**
046 *  The implementation for the interface
047 *  {@link SVGUse}
048 *  for the {@code <use>} element.
049 *
050 *  @extauthor Thomas Thrien - thomas.thrien@tquadrat.org
051 *  @version $Id: SVGUseImpl.java 1151 2025-10-01 21:32:15Z tquadrat $
052 *  @since 0.0.5
053 *
054 *  @UMLGraph.link
055 */
056@ClassVersion( sourceVersion = "$Id: SVGUseImpl.java 1151 2025-10-01 21:32:15Z tquadrat $" )
057@API( status = INTERNAL, since = "0.0.5" )
058public final class SVGUseImpl extends SVGElementImpl implements SVGUse
059{
060        /*--------------*\
061    ====** Constructors **=====================================================
062        \*--------------*/
063    /**
064     *  Creates a new {@code SVGUseImpl} instance.
065     *
066     *  @param  reference   The reference to the cloned element.
067     */
068    public SVGUseImpl( final URI reference )
069    {
070        super( SVGELEMENT_Use, ALLOWS_CHILDREN, VALIDATES_ATTRIBUTES, VALIDATES_CHILDREN );
071
072        //---* The children and attributes for the <use> element *-------------
073        final Collection<String> childElements = new HashSet<>();
074        childElements.addAll( ANIMATION.getElements() );
075        childElements.addAll( DESCRIPTIVE.getElements() );
076
077        final Collection<String> attributes = new ArrayList<>();
078        attributes.addAll( List.of( SVGATTRIBUTE_Id, SVGATTRIBUTE_x,
079            SVGATTRIBUTE_y, SVGATTRIBUTE_Width, SVGATTRIBUTE_Height,
080            SVGATTRIBUTE_Reference ) );
081        attributes.addAll( CONDITIONALPROCESSING_ATTRIBUTES );
082        attributes.addAll( CORE_ATTRIBUTES );
083        attributes.addAll( GRAPHICALEVENT_ATTRIBUTES );
084        attributes.addAll( PRESENTATION_ATTRIBUTES );
085        attributes.addAll( XLINK_ATTRIBUTES );
086
087        updateRegistries( childElements, attributes );
088
089        setReference( requireNotEmptyArgument( reference, "reference" ) );
090    }   //  SVGUseImpl()
091}
092//  class SVGUseImpl
093
094/*
095 *  End of File
096 */