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