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 org.apiguardian.api.API.Status.STABLE;
021import static org.tquadrat.foundation.lang.Objects.requireNonNullArgument;
022import static org.tquadrat.foundation.svg.SVGUtils.number;
023
024import org.apiguardian.api.API;
025import org.tquadrat.foundation.annotation.ClassVersion;
026import org.tquadrat.foundation.svg.internal.SVGLineImpl;
027import org.tquadrat.foundation.svg.type.SVGNumber;
028import org.tquadrat.foundation.svg.type.SVGNumber.SVGUserUnitValue;
029
030/**
031 *  The definition of an SVG {@code <line>} element.
032 *
033 *  @extauthor Thomas Thrien - thomas.thrien@tquadrat.org
034 *  @version $Id: SVGLine.java 1074 2023-10-02 12:05:06Z tquadrat $
035 *  @since 0.0.5
036 *
037 *  @UMLGraph.link
038 */
039@ClassVersion( sourceVersion = "$Id: SVGLine.java 1074 2023-10-02 12:05:06Z tquadrat $" )
040@API( status = STABLE, since = "0.0.5" )
041public sealed interface SVGLine extends SVGElementWithChildren, AllowsConditionalProcessingAttributes, AllowsGlobalEventAttributes, AllowsGraphicalEventAttributes, AllowsPresentationAttributes, AllowsStyleAttributes
042    permits SVGElementAdapter, SVGLineImpl
043{
044        /*---------*\
045    ====** Methods **==========================================================
046        \*---------*/
047    /**
048     *  Sets the start and end points for this line.
049     *
050     *  @param  x1  The x coordinate for the starting point of the line.
051     *  @param  y1  The y coordinate for the starting point of the line.
052     *  @param  x2  The x coordinate for the ending point of the line.
053     *  @param  y2  The y coordinate for the ending point of the line.
054     */
055    @SuppressWarnings( "UseOfConcreteClass" )
056    public default void defineLine( final SVGNumber x1, final SVGNumber y1, final SVGNumber x2, final SVGNumber y2 )
057    {
058        setStartPoint( x1, y1 );
059        setEndPoint( x2, y2 );
060    }   //  defineLine()
061
062    /**
063     *  Sets the end point for this line.
064     *
065     *  @param  x  The x coordinate for the ending point of the line.
066     *  @param  y  The y coordinate for the ending point of the line.
067     */
068    @SuppressWarnings( "UseOfConcreteClass" )
069    public default void setEndPoint( final SVGNumber x, final SVGNumber y )
070    {
071        setX2( requireNonNullArgument( x, "x" ) );
072        setY2( requireNonNullArgument( y, "y" ) );
073    }   //  setEndPoint()
074
075    /**
076     *  Sets the length of the path represented by this SVG {@code <line>}
077     *  element.
078     *
079     *  @param  length  The author's computation of the total length of the
080     *      path, in user units. This type is used to calibrate the user
081     *      agent's own distance-along-a-path calculations with that of the
082     *      author. The user agent will scale all distance-along-a-path
083     *      computations by the ratio of this type to the user agent's own
084     *      computed type for total path length.<br>
085     *      <br>A type of zero is valid, but a negative type is an error.
086     *
087     *  @throws IllegalArgumentException    The type is less than 0.
088     */
089    public void setPathLength( @SuppressWarnings( "UseOfConcreteClass" ) final SVGUserUnitValue length );
090
091    /**
092     *  Sets the length of the path represented by this SVG {@code <line>}
093     *  element.
094     *
095     *  @param  length  The author's computation of the total length of the
096     *      path, in user units. This type is used to calibrate the user
097     *      agent's own distance-along-a-path calculations with that of the
098     *      author. The user agent will scale all distance-along-a-path
099     *      computations by the ratio of this type to the user agent's own
100     *      computed type for total path length.<br>
101     *      <br>A type of zero is valid, but a negative type is an error.
102     *
103     *  @throws IllegalArgumentException    The type is less than 0.
104     */
105    public default void setPathLength( final double length ) { setPathLength( number( length ) ); }
106
107    /**
108     *  Sets the length of the path represented by this SVG {@code <line>}
109     *  element.
110     *
111     *  @param  length  The author's computation of the total length of the
112     *      path, in user units. This type is used to calibrate the user
113     *      agent's own distance-along-a-path calculations with that of the
114     *      author. The user agent will scale all distance-along-a-path
115     *      computations by the ratio of this type to the user agent's own
116     *      computed type for total path length.<br>
117     *      <br>A type of zero is valid, but a negative type is an error.
118     *
119     *  @throws IllegalArgumentException    The type is less than 0.
120     */
121    public default void setPathLength( final long length ) { setPathLength( number( length ) ); }
122
123    /**
124     *  Sets the start point for this line.
125     *
126     *  @param  x   The x coordinate for the starting point of the line.
127     *  @param  y   The y coordinate for the starting point of the line.
128     */
129    @SuppressWarnings( "UseOfConcreteClass" )
130    public default void setStartPoint( final SVGNumber x, final SVGNumber y )
131    {
132        setX1( requireNonNullArgument( x, "x" ) );
133        setY1( requireNonNullArgument( y, "y" ) );
134    }   //  setStartPoint()
135
136    /**
137     *  Sets the x coordinate of the starting point for this line.
138     *
139     *  @param  value   The x coordinate.
140     */
141    public void setX1( @SuppressWarnings( "UseOfConcreteClass" ) final SVGNumber value );
142
143    /**
144     *  Sets the x coordinate of the ending point for this line.
145     *
146     *  @param  value   The x coordinate.
147     */
148    public void setX2( @SuppressWarnings( "UseOfConcreteClass" ) final SVGNumber value );
149
150    /**
151     *  Sets the y coordinate of the starting point for this line.
152     *
153     *  @param  value   The y coordinate.
154     */
155    public void setY1( @SuppressWarnings( "UseOfConcreteClass" ) final SVGNumber value );
156
157    /**
158     *  Sets the y coordinate of the ending point for this line.
159     *
160     *  @param  value   The y coordinate.
161     */
162    public void setY2( @SuppressWarnings( "UseOfConcreteClass" ) final SVGNumber value );
163}
164//  interface SVGLine
165
166/*
167 *  End of File
168 */