Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/SharpVectorModel/Shapes/SvgLineElement.cs @ 12762

Last change on this file since 12762 was 12762, checked in by aballeit, 9 years ago

#2283 GUI updates, Tree-chart, MCTS Version 2 (prune leaves)

File size: 6.4 KB
Line 
1// <developer>niklas@protocol7.com</developer>
2// <completed>100</completed>
3
4using System;
5using System.Xml;
6
7namespace SharpVectors.Dom.Svg
8{
9    /// <summary>
10    /// The SVGLineElement interface corresponds to the 'line' element. 
11    /// </summary>
12    public sealed class SvgLineElement : SvgTransformableElement, ISvgLineElement, ISharpMarkerHost
13    {
14        #region Private Fields
15
16        private ISvgAnimatedLength x1;
17        private ISvgAnimatedLength y1;
18        private ISvgAnimatedLength x2;
19        private ISvgAnimatedLength y2;
20
21        private SvgTests svgTests;
22        private SvgExternalResourcesRequired svgExternalResourcesRequired;
23
24        #endregion
25
26        #region Constructors and Destructor
27
28        public SvgLineElement(string prefix, string localname, string ns, SvgDocument doc)
29            : base(prefix, localname, ns, doc)
30        {
31            svgTests = new SvgTests(this);
32            svgExternalResourcesRequired = new SvgExternalResourcesRequired(this);
33        }
34
35        #endregion
36
37        #region Public Methods
38
39        public void Invalidate()
40        {
41        }
42
43        public override void HandleAttributeChange(XmlAttribute attribute)
44        {
45            if (attribute.NamespaceURI.Length == 0)
46            {
47                switch (attribute.LocalName)
48                {
49                    case "x1":
50                        x1 = null;
51                        Invalidate();
52                        return;
53                    case "y1":
54                        y1 = null;
55                        Invalidate();
56                        return;
57                    case "x2":
58                        x2 = null;
59                        Invalidate();
60                        return;
61                    case "y2":
62                        y2 = null;
63                        Invalidate();
64                        return;
65                    case "marker-start":
66                    case "marker-mid":
67                    case "marker-end":
68                    // Color.attrib, Paint.attrib
69                    case "color":
70                    case "fill":
71                    case "fill-rule":
72                    case "stroke":
73                    case "stroke-dasharray":
74                    case "stroke-dashoffset":
75                    case "stroke-linecap":
76                    case "stroke-linejoin":
77                    case "stroke-miterlimit":
78                    case "stroke-width":
79                    // Opacity.attrib
80                    case "opacity":
81                    case "stroke-opacity":
82                    case "fill-opacity":
83                    // Graphics.attrib
84                    case "display":
85                    case "image-rendering":
86                    case "shape-rendering":
87                    case "text-rendering":
88                    case "visibility":
89                        Invalidate();
90                        break;
91                    case "transform":
92                        Invalidate();
93                        break;
94                }
95
96                base.HandleAttributeChange(attribute);
97            }
98        }
99
100        #endregion
101
102        #region ISvgElement Members
103
104        /// <summary>
105        /// Gets a value providing a hint on the rendering defined by this element.
106        /// </summary>
107        /// <value>
108        /// An enumeration of the <see cref="SvgRenderingHint"/> specifying the rendering hint.
109        /// This will always return <see cref="SvgRenderingHint.Shape"/>
110        /// </value>
111        public override SvgRenderingHint RenderingHint
112        {
113            get
114            {
115                return SvgRenderingHint.Shape;
116            }
117        }
118
119        #endregion
120
121        #region ISvgLineElement Members
122
123        public ISvgAnimatedLength X1
124        {
125            get
126            {
127                if (x1 == null)
128                {
129                    x1 = new SvgAnimatedLength(this, "x1", SvgLengthDirection.Horizontal, "0");
130                }
131                return x1;
132            }
133        }
134
135        public ISvgAnimatedLength Y1
136        {
137            get
138            {
139                if (y1 == null)
140                {
141                    y1 = new SvgAnimatedLength(this, "y1", SvgLengthDirection.Vertical, "0");
142                }
143                return y1;
144            }
145
146        }
147
148        public ISvgAnimatedLength X2
149        {
150            get
151            {
152                if (x2 == null)
153                {
154                    x2 = new SvgAnimatedLength(this, "x2", SvgLengthDirection.Horizontal, "0");
155                }
156                return x2;
157            }
158        }
159
160        public ISvgAnimatedLength Y2
161        {
162            get
163            {
164                if (y2 == null)
165                {
166                    y2 = new SvgAnimatedLength(this, "y2", SvgLengthDirection.Vertical, "0");
167                }
168                return y2;
169            }
170        }
171
172        #endregion
173
174        #region ISvgExternalResourcesRequired Members
175       
176        public ISvgAnimatedBoolean ExternalResourcesRequired
177        {
178            get
179            {
180                return svgExternalResourcesRequired.ExternalResourcesRequired;
181            }
182        }
183
184        #endregion
185
186        #region ISvgTests Members
187
188        public ISvgStringList RequiredFeatures
189        {
190            get { return svgTests.RequiredFeatures; }
191        }
192
193        public ISvgStringList RequiredExtensions
194        {
195            get { return svgTests.RequiredExtensions; }
196        }
197
198        public ISvgStringList SystemLanguage
199        {
200            get { return svgTests.SystemLanguage; }
201        }
202
203        public bool HasExtension(string extension)
204        {
205            return svgTests.HasExtension(extension);
206        }
207
208        #endregion
209
210        #region ISharpMarkerHost Members
211
212        public SvgPointF[] MarkerPositions
213        {
214            get
215            {
216                return new SvgPointF[]
217                {
218                    new SvgPointF(X1.AnimVal.Value, Y1.AnimVal.Value),
219                    new SvgPointF(X2.AnimVal.Value, Y2.AnimVal.Value)
220                };
221            }
222        }
223
224        public double GetStartAngle(int index)
225        {
226            return 0;
227        }
228
229        public double GetEndAngle(int index)
230        {
231            return 0;
232        }
233
234        #endregion
235    }
236}
Note: See TracBrowser for help on using the repository browser.