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;
019
020import static java.util.Arrays.asList;
021import static org.apiguardian.api.API.Status.STABLE;
022import static org.tquadrat.foundation.lang.CommonConstants.XMLATTRIBUTE_Language;
023import static org.tquadrat.foundation.lang.CommonConstants.XMLATTRIBUTE_Whitespace;
024import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Id;
025import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_Lang;
026import static org.tquadrat.foundation.svg.SVGUtils.SVGATTRIBUTE_TabIndex;
027import static org.tquadrat.foundation.svg.SVGUtils.XMLATTRIBUTE_Base;
028import static org.tquadrat.foundation.svg.type.SVGElementCategory.retrieveElementCategory;
029
030import java.net.URI;
031import java.util.Collection;
032import java.util.List;
033import java.util.Locale;
034
035import org.apiguardian.api.API;
036import org.tquadrat.foundation.annotation.ClassVersion;
037import org.tquadrat.foundation.svg.internal.SVGElementImpl;
038import org.tquadrat.foundation.svg.type.SVGElementCategory;
039import org.tquadrat.foundation.xml.builder.XMLElement;
040import org.tquadrat.foundation.xml.builder.spi.Element;
041
042/**
043 *  The definition of an SVG element.
044 *
045 *  @extauthor Thomas Thrien - thomas.thrien@tquadrat.org
046 *  @version $Id: SVGElement.java 1074 2023-10-02 12:05:06Z tquadrat $
047 *  @since 0.0.5
048 *
049 *  @UMLGraph.link
050 */
051@ClassVersion( sourceVersion = "$Id: SVGElement.java 1074 2023-10-02 12:05:06Z tquadrat $" )
052@API( status = STABLE, since = "0.0.5" )
053public sealed interface SVGElement extends Element
054    permits SVGElementWithChildren, SVGStyle, SVGUse, SVGElementImpl
055{
056        /*------------------------*\
057    ====** Static Initialisations **===========================================
058        \*------------------------*/
059    /**
060     *  The core attributes.
061     */
062    @SuppressWarnings( "StaticCollection" )
063    public static final List<String> CORE_ATTRIBUTES = List.copyOf( asList(
064        SVGATTRIBUTE_Id,
065        SVGATTRIBUTE_Lang,
066        SVGATTRIBUTE_TabIndex,
067        XMLATTRIBUTE_Base,
068        XMLATTRIBUTE_Language,
069        XMLATTRIBUTE_Whitespace
070    ) );
071
072        /*---------*\
073    ====** Methods **==========================================================
074        \*---------*/
075    /**
076     *  Adds a comment.
077     *
078     *  @param  comment The comment text.
079     *  @return This instance.
080     *  @throws IllegalArgumentException    No comment allowed for this element.
081     */
082    public XMLElement addComment( final CharSequence comment ) throws IllegalArgumentException;
083
084    /**
085     *  Returns the element category.
086     *
087     *  @return The element categories; will never be {@code null}.
088     */
089    public default Collection<SVGElementCategory> getSVGElementCategory()
090    {
091        return retrieveElementCategory( getElementName() );
092    }   //  getSVGElementCategory()
093
094    /**
095     *  Sets the SVG id for the element.<br>
096     *  <br>The type will be validated using the method that is provided by a
097     *  call to
098     *  {@link org.tquadrat.foundation.xml.builder.XMLBuilderUtils#getNMTokenValidator()}.
099     *
100     *  @param  id  The id.
101     *  @return This instance.
102     *  @throws IllegalArgumentException    An attribute with the given name is
103     *      not valid for the element, or no attributes are allowed at all, or
104     *      the type is not a valid NMToken.
105     *
106     *  @see org.tquadrat.foundation.svg.SVGUtils#SVGATTRIBUTE_Id
107     */
108    public XMLElement setId( final String id ) throws IllegalArgumentException;
109
110    /**
111     *  Sets the human language attribute for this SVG element.
112     *
113     *  @param  value   The language code.
114     */
115    public void setLang( final Locale value );
116
117    /**
118     *  Sets attribute that defines how space is handled by this SVG element.
119     *
120     *  @param  flag    {@code true} to preserve space in the source,
121     *      {@code false} for the XML default behaviour (ignoring excessive
122     *      whitespace).
123     */
124    public void setPreserveSpace( final boolean flag );
125
126    /**
127     *  Sets the tabulator index for the SVG element.
128     *
129     *  @param  value   The tabindex type.
130     */
131    public void setTabIndex( final int value );
132
133    /**
134     *  Sets the title for the SVG element.<br>
135     *  <br>This is not an attribute, instead a
136     *  <code>&lt;{@value org.tquadrat.foundation.svg.SVGUtils#SVGELEMENT_Title}&gt;</code>
137     *  element will be added as a child.
138     *
139     *  @param  title   The title; nothing happens if {@code null}, empty, or
140     *      blank.
141     *  @throws IllegalStateException   The given title is not {@code null},
142     *      empty, or blank, and a title was applied already earlier.
143     */
144    public void setTitle( final CharSequence title );
145
146    /**
147     *  Sets XML attribute for the base URI that is used to reference external
148     *  resources.
149     *
150     *  @param  value   The base URI.
151     */
152    public void setXMLBase( final URI value );
153
154    /**
155     *  Sets the id for the element.<br>
156     *  <br>The type will be validated using the method that is provided by a
157     *  call to
158     *  {@link org.tquadrat.foundation.xml.builder.XMLBuilderUtils#getNMTokenValidator()}.
159     *
160     *  @param  id  The id.
161     *  @throws IllegalArgumentException    An attribute with the given name is
162     *      not valid for the element, or no attributes are allowed at all, or
163     *      the type is not a valid NMToken.
164     *
165     *  @see org.tquadrat.foundation.lang.CommonConstants#XMLATTRIBUTE_Id
166     */
167    public void setXMLId( final String id ) throws IllegalArgumentException;
168
169    /**
170     *  Sets XML attribute for the human language for this SVG element.
171     *
172     *  @param  value   The language code.
173     */
174    public void setXMLLang( final Locale value );
175}
176//  interface SVGElement
177
178/*
179 *  End of File
180 */