| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
| 2 |
|
| 3 |
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN" "http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd" > |
| 4 |
|
| 5 |
<!-- |
| 6 |
|
| 7 |
Licensed to the Apache Software Foundation (ASF) under one or more |
| 8 |
contributor license agreements. See the NOTICE file distributed with |
| 9 |
this work for additional information regarding copyright ownership. |
| 10 |
The ASF licenses this file to You under the Apache License, Version 2.0 |
| 11 |
(the "License"); you may not use this file except in compliance with |
| 12 |
the License. You may obtain a copy of the License at |
| 13 |
|
| 14 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 15 |
|
| 16 |
Unless required by applicable law or agreed to in writing, software |
| 17 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 18 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 19 |
See the License for the specific language governing permissions and |
| 20 |
limitations under the License. |
| 21 |
|
| 22 |
--><!-- ====================================================================== --> |
| 23 |
<!-- Modification of a polygon attributes --> |
| 24 |
<!-- --> |
| 25 |
<!-- @author [email protected] --> |
| 26 |
<!-- @version $Id$ --> |
| 27 |
<!-- ====================================================================== --> |
| 28 |
<?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?> |
| 29 |
|
| 30 |
<svg width="450" viewBox="0 0 450 500" height="500" id="body"> |
| 31 |
<title><path> getPathSegList 'onload'</title> |
| 32 |
|
| 33 |
<text x="50%" y="45" class="title"><path> getPathSegList() in 'onload' |
| 34 |
</text> |
| 35 |
<script type="text/ecmascript"><![CDATA[ |
| 36 |
function getNumberOfItems(evt) |
| 37 |
{ |
| 38 |
var elt = evt.target; |
| 39 |
nb = elt.getPathSegList().getNumberOfItems(); |
| 40 |
var text = elt.getOwnerDocument().getElementById('test1_text'); |
| 41 |
text.getFirstChild().appendData(" "+nb+" segments"); |
| 42 |
} |
| 43 |
function insertItemBefore(evt,fromIndex,index) |
| 44 |
{ |
| 45 |
var elt = evt.target; |
| 46 |
pointProvider = elt.getOwnerDocument().getElementById('test1'); |
| 47 |
point = pointProvider.getPathSegList().getItem(fromIndex); |
| 48 |
nb = elt.getPathSegList().insertItemBefore(point,index); |
| 49 |
var text = elt.getOwnerDocument().getElementById('test4_text'); |
| 50 |
text.getFirstChild().appendData(" ("+nb.getPathSegType()+")"); |
| 51 |
} |
| 52 |
function replaceItem(evt,fromIndex,index) |
| 53 |
{ |
| 54 |
var elt = evt.target; |
| 55 |
pointProvider = elt.getOwnerDocument().getElementById('test1'); |
| 56 |
point = pointProvider.getPathSegList().getItem(fromIndex); |
| 57 |
nb = elt.getPathSegList().replaceItem(point,index); |
| 58 |
var text = elt.getOwnerDocument().getElementById('test5_text'); |
| 59 |
text.getFirstChild().appendData(" ("+nb.getPathSegType()+")"); |
| 60 |
} |
| 61 |
|
| 62 |
function initializeAppendItem(evt,fromIndex1) |
| 63 |
{ |
| 64 |
var elt = evt.target; |
| 65 |
pointProvider = elt.getOwnerDocument().getElementById('test1'); |
| 66 |
point = pointProvider.createSVGPathSegMovetoAbs(150,200); |
| 67 |
nb = elt.getPathSegList().initialize(point); |
| 68 |
var text = elt.getOwnerDocument().getElementById('test71_text'); |
| 69 |
text.getFirstChild().appendData(" ("+nb.getPathSegType()+")"); |
| 70 |
point = pointProvider.getPathSegList().getItem(fromIndex1); |
| 71 |
nb = elt.getPathSegList().appendItem(point); |
| 72 |
text = elt.getOwnerDocument().getElementById('test72_text'); |
| 73 |
text.getFirstChild().appendData(" ("+nb.getPathSegType()+")"); |
| 74 |
} |
| 75 |
|
| 76 |
function createNextSibling(evt){ |
| 77 |
|
| 78 |
var elt = evt.target; |
| 79 |
var doc = elt.getOwnerDocument(); |
| 80 |
|
| 81 |
var path = doc.createElementNS(elt.getNamespaceURI(),"path"); |
| 82 |
path.setAttribute("style","fill:#ffd700;stroke-width:4.0;stroke:#ffa500"); |
| 83 |
var segList = path.getPathSegList(); |
| 84 |
|
| 85 |
segList.appendItem(path.createSVGPathSegMovetoAbs(150,200)); |
| 86 |
segList.appendItem(path.createSVGPathSegLinetoAbs(200,200)); |
| 87 |
segList.appendItem(path.createSVGPathSegCurvetoCubicAbs(220,250,210,180,250,240)); |
| 88 |
segList.appendItem(path.createSVGPathSegCurvetoQuadraticAbs(200,250,210,275)); |
| 89 |
segList.appendItem(path.createSVGPathSegLinetoAbs(182.5,237.5)); |
| 90 |
segList.appendItem(path.createSVGPathSegLinetoAbs(150,250)); |
| 91 |
segList.appendItem(path.createSVGPathSegLinetoAbs(162.5,212.5)); |
| 92 |
segList.appendItem(path.createSVGPathSegClosePath()); |
| 93 |
|
| 94 |
var text = elt.getOwnerDocument().getElementById('test8_text'); |
| 95 |
text.getFirstChild().appendData(" "+segList.getNumberOfItems()+" segments"); |
| 96 |
|
| 97 |
elt.getParentNode().insertBefore(path,elt.getNextSibling()); |
| 98 |
} |
| 99 |
]]></script> |
| 100 |
<g id="test-content" transform="matrix(1.0 0.0 0.0 1.0 -140 -91.37931)"> |
| 101 |
|
| 102 |
<!-- onload="getNumberOfItems(evt)" --> |
| 103 |
<text x="180" y="160" font-size="11">segment provider</text> |
| 104 |
<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"/> |
| 105 |
<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)"/> |
| 106 |
<text x="160" font-size="9" y="290" id="test1_text"> |
| 107 |
path with |
| 108 |
</text> |
| 109 |
|
| 110 |
<g transform="translate(0,150)" > |
| 111 |
<!-- onload="insertItemBefore(evt)" --> |
| 112 |
<text x="180" y="160" font-size="11" >insertItemBefore</text> |
| 113 |
<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"/> |
| 114 |
<path id="test4" fill="#ffd700" stroke-width="4.0" |
| 115 |
d="M200 200 L200 250 250 250 250 200z" |
| 116 |
stroke="#ffa500" |
| 117 |
onload="insertItemBefore(evt,5,1)" /> |
| 118 |
<text x="160" font-size="9" y="290" id="test4_text"> |
| 119 |
inserted seg |
| 120 |
</text> |
| 121 |
</g> |
| 122 |
|
| 123 |
<g transform="translate(150,150)" > |
| 124 |
<!-- onload="replaceItem(evt)" --> |
| 125 |
<text x="180" y="160" font-size="11" >replaceItem</text> |
| 126 |
<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"/> |
| 127 |
<path id="test5" fill="#ffd700" stroke-width="4.0" |
| 128 |
d="M200 200 L250 200 250 250 200 250z" |
| 129 |
stroke="#ffa500" |
| 130 |
onload="replaceItem(evt,3,2)" /> |
| 131 |
<text x="160" font-size="9" y="290" id="test5_text"> |
| 132 |
replaced seg |
| 133 |
</text> |
| 134 |
</g> |
| 135 |
|
| 136 |
<g transform="translate(300,150)" > |
| 137 |
<!-- onload="initialize/appendItem(evt)" --> |
| 138 |
<text x="180" y="160" font-size="11" >initialize/appendItem</text> |
| 139 |
<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"/> |
| 140 |
<path id="test7" fill="#ffd700" stroke-width="4.0" |
| 141 |
d="M200 200 L250 200 250 250 200 250z" |
| 142 |
stroke="#ffa500" |
| 143 |
onload="initializeAppendItem(evt,1)" /> |
| 144 |
<text x="160" font-size="9" y="275" id="test71_text"> |
| 145 |
intialized seg |
| 146 |
</text> |
| 147 |
<text x="160" font-size="9" y="285" id="test72_text"> |
| 148 |
appended seg |
| 149 |
</text> |
| 150 |
</g> |
| 151 |
|
| 152 |
<g transform="translate(300,0)" > |
| 153 |
<!-- onload="initialize/appendItem(evt)" --> |
| 154 |
<text x="180" y="160" font-size="11" >new Path</text> |
| 155 |
<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)" /> |
| 156 |
<text x="160" font-size="9" y="285" id="test8_text"> |
| 157 |
path with |
| 158 |
</text> |
| 159 |
</g> |
| 160 |
|
| 161 |
</g> |
| 162 |
</svg> |