| <?xml version="1.0" encoding="UTF-8"?> |
| |
| <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN" "http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd" > |
| |
| <!-- |
| |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| |
| --><!-- ====================================================================== --> |
| <!-- Modification of a polygon attributes --> |
| <!-- --> |
| <!-- @author nicolas.socheleau@bitflash.com --> |
| <!-- @version $Id$ --> |
| <!-- ====================================================================== --> |
| <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?> |
| |
| <svg width="450" viewBox="0 0 450 500" height="500" id="body"> |
| <title><path> getPathSegList 'onload'</title> |
| |
| <text x="50%" y="45" class="title"><path> getPathSegList() in 'onload' |
| </text> |
| <script type="text/ecmascript"><![CDATA[ |
| function getNumberOfItems(evt) |
| { |
| var elt = evt.target; |
| nb = elt.getPathSegList().getNumberOfItems(); |
| var text = elt.getOwnerDocument().getElementById('test1_text'); |
| text.getFirstChild().appendData(" "+nb+" segments"); |
| } |
| function insertItemBefore(evt,fromIndex,index) |
| { |
| var elt = evt.target; |
| pointProvider = elt.getOwnerDocument().getElementById('test1'); |
| point = pointProvider.getPathSegList().getItem(fromIndex); |
| nb = elt.getPathSegList().insertItemBefore(point,index); |
| var text = elt.getOwnerDocument().getElementById('test4_text'); |
| text.getFirstChild().appendData(" ("+nb.getPathSegType()+")"); |
| } |
| function replaceItem(evt,fromIndex,index) |
| { |
| var elt = evt.target; |
| pointProvider = elt.getOwnerDocument().getElementById('test1'); |
| point = pointProvider.getPathSegList().getItem(fromIndex); |
| nb = elt.getPathSegList().replaceItem(point,index); |
| var text = elt.getOwnerDocument().getElementById('test5_text'); |
| text.getFirstChild().appendData(" ("+nb.getPathSegType()+")"); |
| } |
| |
| function initializeAppendItem(evt,fromIndex1) |
| { |
| var elt = evt.target; |
| pointProvider = elt.getOwnerDocument().getElementById('test1'); |
| point = pointProvider.createSVGPathSegMovetoAbs(150,200); |
| nb = elt.getPathSegList().initialize(point); |
| var text = elt.getOwnerDocument().getElementById('test71_text'); |
| text.getFirstChild().appendData(" ("+nb.getPathSegType()+")"); |
| point = pointProvider.getPathSegList().getItem(fromIndex1); |
| nb = elt.getPathSegList().appendItem(point); |
| text = elt.getOwnerDocument().getElementById('test72_text'); |
| text.getFirstChild().appendData(" ("+nb.getPathSegType()+")"); |
| } |
| |
| function createNextSibling(evt){ |
| |
| var elt = evt.target; |
| var doc = elt.getOwnerDocument(); |
| |
| var path = doc.createElementNS(elt.getNamespaceURI(),"path"); |
| path.setAttribute("style","fill:#ffd700;stroke-width:4.0;stroke:#ffa500"); |
| var segList = path.getPathSegList(); |
| |
| segList.appendItem(path.createSVGPathSegMovetoAbs(150,200)); |
| segList.appendItem(path.createSVGPathSegLinetoAbs(200,200)); |
| segList.appendItem(path.createSVGPathSegCurvetoCubicAbs(220,250,210,180,250,240)); |
| segList.appendItem(path.createSVGPathSegCurvetoQuadraticAbs(200,250,210,275)); |
| segList.appendItem(path.createSVGPathSegLinetoAbs(182.5,237.5)); |
| segList.appendItem(path.createSVGPathSegLinetoAbs(150,250)); |
| segList.appendItem(path.createSVGPathSegLinetoAbs(162.5,212.5)); |
| segList.appendItem(path.createSVGPathSegClosePath()); |
| |
| var text = elt.getOwnerDocument().getElementById('test8_text'); |
| text.getFirstChild().appendData(" "+segList.getNumberOfItems()+" segments"); |
| |
| elt.getParentNode().insertBefore(path,elt.getNextSibling()); |
| } |
| ]]></script> |
| <g id="test-content" transform="matrix(1.0 0.0 0.0 1.0 -140 -91.37931)"> |
| |
| <!-- onload="getNumberOfItems(evt)" --> |
| <text x="180" y="160" font-size="11">segment provider</text> |
| <path style="opacity:0.5;fill:#eee; stroke:#aaa; stroke-width:4" d="M150 200 L200 200 C 210 180 250 240 220 250 Q 210 275 200 250 L 182.5 237.5 150 250 162.5 212.5z"/> |
| <path id="test1" style="fill:gold; stroke:orange; stroke-width:4" d="M150 200 L200 200 C 210 180 250 240 220 250 Q 210 275 200 250 L 182.5 237.5 150 250 162.5 212.5z" onload="getNumberOfItems(evt)"/> |
| <text x="160" font-size="9" y="290" id="test1_text"> |
| path with |
| </text> |
| |
| <g transform="translate(0,150)" > |
| <!-- onload="insertItemBefore(evt)" --> |
| <text x="180" y="160" font-size="11" >insertItemBefore</text> |
| <path style="opacity:0.5;fill:#eee; stroke:#aaa; stroke-width:4" d="M150 200 L200 200 C 210 180 250 240 220 250 Q 210 275 200 250 L 182.5 237.5 150 250 162.5 212.5z"/> |
| <path id="test4" fill="#ffd700" stroke-width="4.0" |
| d="M200 200 L200 250 250 250 250 200z" |
| stroke="#ffa500" |
| onload="insertItemBefore(evt,5,1)" /> |
| <text x="160" font-size="9" y="290" id="test4_text"> |
| inserted seg |
| </text> |
| </g> |
| |
| <g transform="translate(150,150)" > |
| <!-- onload="replaceItem(evt)" --> |
| <text x="180" y="160" font-size="11" >replaceItem</text> |
| <path style="opacity:0.5;fill:#eee; stroke:#aaa; stroke-width:4" d="M150 200 L200 200 C 210 180 250 240 220 250 Q 210 275 200 250 L 182.5 237.5 150 250 162.5 212.5z"/> |
| <path id="test5" fill="#ffd700" stroke-width="4.0" |
| d="M200 200 L250 200 250 250 200 250z" |
| stroke="#ffa500" |
| onload="replaceItem(evt,3,2)" /> |
| <text x="160" font-size="9" y="290" id="test5_text"> |
| replaced seg |
| </text> |
| </g> |
| |
| <g transform="translate(300,150)" > |
| <!-- onload="initialize/appendItem(evt)" --> |
| <text x="180" y="160" font-size="11" >initialize/appendItem</text> |
| <path style="opacity:0.5;fill:#eee; stroke:#aaa; stroke-width:4" d="M150 200 L200 200 C 210 180 250 240 220 250 Q 210 275 200 250 L 182.5 237.5 150 250 162.5 212.5z"/> |
| <path id="test7" fill="#ffd700" stroke-width="4.0" |
| d="M200 200 L250 200 250 250 200 250z" |
| stroke="#ffa500" |
| onload="initializeAppendItem(evt,1)" /> |
| <text x="160" font-size="9" y="275" id="test71_text"> |
| intialized seg |
| </text> |
| <text x="160" font-size="9" y="285" id="test72_text"> |
| appended seg |
| </text> |
| </g> |
| |
| <g transform="translate(300,0)" > |
| <!-- onload="initialize/appendItem(evt)" --> |
| <text x="180" y="160" font-size="11" >new Path</text> |
| <path style="opacity:0.5;fill:#eee; stroke:#aaa; stroke-width:4" d="M150 200 L200 200 C 210 180 250 240 220 250 Q 210 275 200 250 L 182.5 237.5 150 250 162.5 212.5z" onload="createNextSibling(evt)" /> |
| <text x="160" font-size="9" y="285" id="test8_text"> |
| path with |
| </text> |
| </g> |
| |
| </g> |
| </svg> |