| 1 |
<?xml version="1.0" standalone="no"?> |
| 2 |
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN" |
| 3 |
"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 |
|
| 24 |
<!-- ====================================================================== --> |
| 25 |
<!-- Modification of a rect's attributes --> |
| 26 |
<!-- --> |
| 27 |
<!-- @author [email protected] --> |
| 28 |
<!-- @version $Id$ --> |
| 29 |
<!-- ====================================================================== --> |
| 30 |
|
| 31 |
<?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?> |
| 32 |
|
| 33 |
<svg id="body" width="450" height="500" viewBox="0 0 450 500" |
| 34 |
onload="doShowBounds=false"> |
| 35 |
<title>Resizing zero w/h items 'onload'</title> |
| 36 |
<text x="50%" y="45" class="title">Resizing zero w/h items 'onload'</text> |
| 37 |
|
| 38 |
<script type="text/ecmascript"><![CDATA[ |
| 39 |
var svgns = "http://www.w3.org/2000/svg"; |
| 40 |
var root = document.getRootElement(); |
| 41 |
var doShowBounds = true; |
| 42 |
var stressTest = false; |
| 43 |
|
| 44 |
function resizeRect(id, w, h) { |
| 45 |
var rect = document.getElementById(id); |
| 46 |
var ow = rect.getAttribute("width"); |
| 47 |
var oh = rect.getAttribute("height"); |
| 48 |
rect.setAttribute("width", w); |
| 49 |
rect.setAttribute("height", h); |
| 50 |
showBounds(rect); |
| 51 |
if (stressTest) |
| 52 |
setTimeout("resizeRect('"+id+"',"+ow+","+oh+")", 1000); |
| 53 |
} |
| 54 |
|
| 55 |
function resizeCircle(id, r) { |
| 56 |
var circle = document.getElementById(id); |
| 57 |
var or = circle.getAttribute("r"); |
| 58 |
circle.setAttribute("r", r); |
| 59 |
showBounds(circle); |
| 60 |
if (stressTest) |
| 61 |
setTimeout("resizeCircle('"+id+"',"+or+")", 1000); |
| 62 |
} |
| 63 |
function resizeEllipse(id, rx, ry) { |
| 64 |
var ellipse = document.getElementById(id); |
| 65 |
var orx = ellipse.getAttribute("rx"); |
| 66 |
var ory = ellipse.getAttribute("ry"); |
| 67 |
ellipse.setAttribute("rx", rx); |
| 68 |
ellipse.setAttribute("ry", ry); |
| 69 |
showBounds(ellipse); |
| 70 |
if (stressTest) |
| 71 |
setTimeout("resizeEllipse('"+id+"',"+orx+","+ory+")", 1000); |
| 72 |
} |
| 73 |
|
| 74 |
function showBounds(shape) { |
| 75 |
if (!doShowBounds) return; |
| 76 |
var bbox = shape.getBBox(); |
| 77 |
var elem; |
| 78 |
// System.err.println("XXX: [" + bbox.x + ", " +bbox.y + ", " + |
| 79 |
// bbox.width + ", " + bbox.height + "]"); |
| 80 |
if (bbox.width == 0) { |
| 81 |
if (bbox.height == 0) { |
| 82 |
elem = document.createElementNS(svgns, "circle"); |
| 83 |
elem.setAttribute("cx", ""+bbox.x); |
| 84 |
elem.setAttribute("cy", ""+bbox.y); |
| 85 |
elem.setAttribute("r", "5"); |
| 86 |
elem.setAttribute("stroke","none"); |
| 87 |
elem.setAttribute("fill","lime"); |
| 88 |
elem.setAttribute("fill-opacity", ".5"); |
| 89 |
shape.parentNode.insertBefore(elem, shape.nextSibling); |
| 90 |
return; |
| 91 |
} else { |
| 92 |
elem = document.createElementNS(svgns, "line"); |
| 93 |
elem.setAttribute("x1", ""+bbox.x); |
| 94 |
elem.setAttribute("y1", ""+bbox.y); |
| 95 |
elem.setAttribute("x2", ""+bbox.x); |
| 96 |
elem.setAttribute("y2", ""+(bbox.y+bbox.height)); |
| 97 |
} |
| 98 |
} else if (bbox.height == 0) { |
| 99 |
elem = document.createElementNS(svgns, "line"); |
| 100 |
elem.setAttribute("x1", ""+bbox.x); |
| 101 |
elem.setAttribute("y1", ""+bbox.y); |
| 102 |
elem.setAttribute("x2", ""+(bbox.x+bbox.width)); |
| 103 |
elem.setAttribute("y2", ""+bbox.y); |
| 104 |
} else { |
| 105 |
elem = document.createElementNS(svgns, "rect"); |
| 106 |
elem.setAttribute("x", ""+bbox.x); |
| 107 |
elem.setAttribute("y", ""+bbox.y); |
| 108 |
elem.setAttribute("width", ""+bbox.width); |
| 109 |
elem.setAttribute("height", ""+bbox.height); |
| 110 |
} |
| 111 |
elem.setAttribute("fill","none"); |
| 112 |
elem.setAttribute("stroke-width", "5"); |
| 113 |
elem.setAttribute("stroke", "lime"); |
| 114 |
elem.setAttribute("stroke-opacity", ".5"); |
| 115 |
shape.parentNode.insertBefore(elem, shape.nextSibling); |
| 116 |
} |
| 117 |
]]></script> |
| 118 |
|
| 119 |
<linearGradient id="testGrad" gradientUnits="objectBoundingBox" |
| 120 |
x1="0" y1="1" x2="1" y2="0"> |
| 121 |
<stop offset="0" style="stop-color:crimson" /> |
| 122 |
<stop offset="1" style="stop-color:gold" /> |
| 123 |
</linearGradient> |
| 124 |
|
| 125 |
<g id="test-content"> |
| 126 |
<g fill="red" stroke="black" stroke-width="2"> |
| 127 |
<rect id="r1-1" x="10" y="60" width="0" height="0" |
| 128 |
onload="resizeRect('r1-1', '50', '50')"/> |
| 129 |
<rect id="r1-2" x="70" y="60" width="50" height="0" |
| 130 |
onload="resizeRect('r1-2', '50', '50')"/> |
| 131 |
<rect id="r1-3" x="130" y="60" width="0" height="50" |
| 132 |
onload="resizeRect('r1-3', '50', '50')"/> |
| 133 |
<circle id="c1-1" cx="215" cy="85" r="0" |
| 134 |
onload="resizeCircle('c1-1', '25')"/> |
| 135 |
<ellipse id="e1-1" cx="275" cy="85" rx="0" ry="0" |
| 136 |
onload="resizeEllipse('e1-1', '25', '15')"/> |
| 137 |
<ellipse id="e1-2" cx="335" cy="85" rx="25" ry="0" |
| 138 |
onload="resizeEllipse('e1-2', '25', '15')"/> |
| 139 |
<ellipse id="e1-3" cx="395" cy="85" rx="0" ry="15" |
| 140 |
onload="resizeEllipse('e1-3', '25', '15')"/> |
| 141 |
</g> |
| 142 |
|
| 143 |
<g fill="url(#testGrad)" stroke="black" stroke-width="2"> |
| 144 |
<rect id="r2-1" x="10" y="120" width="0" height="0" |
| 145 |
onload="resizeRect('r2-1', '50', '50')"/> |
| 146 |
<rect id="r2-2" x="70" y="120" width="50" height="0" |
| 147 |
onload="resizeRect('r2-2', '50', '50')"/> |
| 148 |
<rect id="r2-3" x="130" y="120" width="0" height="50" |
| 149 |
onload="resizeRect('r2-3', '50', '50')"/> |
| 150 |
<circle id="c2-1" cx="215" cy="145" r="0" |
| 151 |
onload="resizeCircle('c2-1', '25')"/> |
| 152 |
<ellipse id="e2-1" cx="275" cy="145" rx="0" ry="0" |
| 153 |
onload="resizeEllipse('e2-1', '25', '15')"/> |
| 154 |
<ellipse id="e2-2" cx="335" cy="145" rx="50" ry="0" |
| 155 |
onload="resizeEllipse('e2-2', '25', '15')"/> |
| 156 |
<ellipse id="e2-3" cx="395" cy="145" rx="0" ry="50" |
| 157 |
onload="resizeEllipse('e2-3', '25', '15')"/> |
| 158 |
</g> |
| 159 |
|
| 160 |
<g fill="red" stroke="black" stroke-width="2"> |
| 161 |
<rect id="r3-1" x="10" y="180" width="50" height="50" |
| 162 |
onload="resizeRect('r3-1', '0', '0')"/> |
| 163 |
<rect id="r3-2" x="70" y="180" width="50" height="50" |
| 164 |
onload="resizeRect('r3-2', '50', '0')"/> |
| 165 |
<rect id="r3-3" x="130" y="180" width="50" height="50" |
| 166 |
onload="resizeRect('r3-3', '0', '50')"/> |
| 167 |
<circle id="c3-1" cx="215" cy="205" r="25" |
| 168 |
onload="resizeCircle('c3-1', '0')"/> |
| 169 |
<ellipse id="e3-1" cx="275" cy="205" rx="25" ry="15" |
| 170 |
onload="resizeEllipse('e3-1', '0', '0')"/> |
| 171 |
<ellipse id="e3-2" cx="335" cy="205" rx="25" ry="15" |
| 172 |
onload="resizeEllipse('e3-2', '25', '0')"/> |
| 173 |
<ellipse id="e3-3" cx="395" cy="205" rx="25" ry="15" |
| 174 |
onload="resizeEllipse('e3-3', '0', '15')"/> |
| 175 |
</g> |
| 176 |
|
| 177 |
<g fill="url(#testGrad)" stroke="black" stroke-width="2"> |
| 178 |
<rect id="r4-1" x="10" y="240" width="50" height="50" |
| 179 |
onload="resizeRect('r4-1', '0', '0')"/> |
| 180 |
<rect id="r4-2" x="70" y="240" width="50" height="50" |
| 181 |
onload="resizeRect('r4-2', '50', '0')"/> |
| 182 |
<rect id="r4-3" x="130" y="240" width="50" height="50" |
| 183 |
onload="resizeRect('r4-3', '0', '50')"/> |
| 184 |
<circle id="c4-1" cx="215" cy="265" r="25" |
| 185 |
onload="resizeCircle('c4-1', '0')"/> |
| 186 |
<ellipse id="e4-1" cx="275" cy="265" rx="25" ry="15" |
| 187 |
onload="resizeEllipse('e4-1', '0', '0')"/> |
| 188 |
<ellipse id="e4-2" cx="335" cy="265" rx="25" ry="15" |
| 189 |
onload="resizeEllipse('e4-2', '25', '0')"/> |
| 190 |
<ellipse id="e4-3" cx="395" cy="265" rx="25" ry="15" |
| 191 |
onload="resizeEllipse('e4-3', '0', '15')"/> |
| 192 |
</g> |
| 193 |
|
| 194 |
<g transform="translate(0,300)"> |
| 195 |
<image id="i5-1" x="10" y="0" width="50" height="50" |
| 196 |
xlink:href="../../resources/images/png2.png" |
| 197 |
onload="resizeRect('i5-1', '0', '0')"/> |
| 198 |
<image id="i5-2" x="70" y="0" width="50" height="50" |
| 199 |
xlink:href="../../resources/images/png2.png" |
| 200 |
onload="resizeRect('i5-2', '50', '0')"/> |
| 201 |
<image id="i5-3" x="130" y="0" width="50" height="50" |
| 202 |
xlink:href="../../resources/images/png2.png" |
| 203 |
onload="resizeRect('i5-3', '0', '50')"/> |
| 204 |
|
| 205 |
<image id="i5-4" x="190" y="0" width="0" height="0" |
| 206 |
xlink:href="../../resources/images/png2.png" |
| 207 |
onload="resizeRect('i5-4', '50', '50')"/> |
| 208 |
<image id="i5-5" x="250" y="0" width="50" height="0" |
| 209 |
xlink:href="../../resources/images/png2.png" |
| 210 |
onload="resizeRect('i5-5', '50', '50')"/> |
| 211 |
<image id="i5-6" x="310" y="0" width="0" height="50" |
| 212 |
xlink:href="../../resources/images/png2.png" |
| 213 |
onload="resizeRect('i5-6', '50', '50')"/> |
| 214 |
</g> |
| 215 |
|
| 216 |
<g transform="translate(0,360)"> |
| 217 |
<image id="i6-1" x="10" y="0" width="50" height="50" |
| 218 |
xlink:href="../../resources/images/svg2.svg" |
| 219 |
onload="resizeRect('i6-1', '0', '0')"/> |
| 220 |
<image id="i6-2" x="70" y="0" width="50" height="50" |
| 221 |
xlink:href="../../resources/images/svg2.svg" |
| 222 |
onload="resizeRect('i6-2', '50', '0')"/> |
| 223 |
<image id="i6-3" x="130" y="0" width="50" height="50" |
| 224 |
xlink:href="../../resources/images/svg2.svg" |
| 225 |
onload="resizeRect('i6-3', '0', '50')"/> |
| 226 |
|
| 227 |
<image id="i6-4" x="190" y="0" width="0" height="0" |
| 228 |
xlink:href="../../resources/images/svg2.svg" |
| 229 |
onload="resizeRect('i6-4', '50', '50')"/> |
| 230 |
<image id="i6-5" x="250" y="0" width="50" height="0" |
| 231 |
xlink:href="../../resources/images/svg2.svg" |
| 232 |
onload="resizeRect('i6-5', '50', '50')"/> |
| 233 |
<image id="i6-6" x="310" y="0" width="0" height="50" |
| 234 |
xlink:href="../../resources/images/svg2.svg" |
| 235 |
onload="resizeRect('i6-6', '50', '50')"/> |
| 236 |
</g> |
| 237 |
</g> |
| 238 |
</svg> |