| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -181,7 +181,7 @@ public PShapeSVG(XMLElement svg) { | |||
| 181 | 181 | ||
| 182 | 182 | // not proper parsing of the viewBox, but will cover us for cases where | |
| 183 | 183 | // the width and height of the object is not specified | |
| 184 | - String viewBoxStr = svg.getStringAttribute("viewBox"); | ||
| 184 | + String viewBoxStr = svg.getString("viewBox"); | ||
| 185 | 185 | if (viewBoxStr != null) { | |
| 186 | 186 | int[] viewBox = PApplet.parseInt(PApplet.splitTokens(viewBoxStr)); | |
| 187 | 187 | width = viewBox[2]; | |
@@ -191,8 +191,8 @@ public PShapeSVG(XMLElement svg) { | |||
| 191 | 191 | // TODO if viewbox is not same as width/height, then use it to scale | |
| 192 | 192 | // the original objects. for now, viewbox only used when width/height | |
| 193 | 193 | // are empty values (which by the spec means w/h of "100%" | |
| 194 | - String unitWidth = svg.getStringAttribute("width"); | ||
| 195 | - String unitHeight = svg.getStringAttribute("height"); | ||
| 194 | + String unitWidth = svg.getString("width"); | ||
| 195 | + String unitHeight = svg.getString("height"); | ||
| 196 | 196 | if (unitWidth != null) { | |
| 197 | 197 | width = parseUnitSize(unitWidth); | |
| 198 | 198 | height = parseUnitSize(unitHeight); | |
@@ -266,7 +266,7 @@ public PShapeSVG(PShapeSVG parent, XMLElement properties) { | |||
| 266 | 266 | } | |
| 267 | 267 | ||
| 268 | 268 | element = properties; | |
| 269 | - name = properties.getStringAttribute("id"); | ||
| 269 | + name = properties.getString("id"); | ||
| 270 | 270 | // @#$(* adobe illustrator mangles names of objects when re-saving | |
| 271 | 271 | if (name != null) { | |
| 272 | 272 | while (true) { | |
@@ -277,10 +277,10 @@ public PShapeSVG(PShapeSVG parent, XMLElement properties) { | |||
| 277 | 277 | } | |
| 278 | 278 | } | |
| 279 | 279 | ||
| 280 | - String displayStr = properties.getStringAttribute("display", "inline"); | ||
| 280 | + String displayStr = properties.getString("display", "inline"); | ||
| 281 | 281 | visible = !displayStr.equals("none"); | |
| 282 | 282 | ||
| 283 | - String transformStr = properties.getStringAttribute("transform"); | ||
| 283 | + String transformStr = properties.getString("transform"); | ||
| 284 | 284 | if (transformStr != null) { | |
| 285 | 285 | matrix = parseMatrix(transformStr); | |
| 286 | 286 | } | |
@@ -453,7 +453,7 @@ protected void parsePoly(boolean close) { | |||
| 453 | 453 | family = PATH; | |
| 454 | 454 | this.close = close; | |
| 455 | 455 | ||
| 456 | - String pointsAttr = element.getStringAttribute("points"); | ||
| 456 | + String pointsAttr = element.getString("points"); | ||
| 457 | 457 | if (pointsAttr != null) { | |
| 458 | 458 | String[] pointsBuffer = PApplet.splitTokens(pointsAttr); | |
| 459 | 459 | vertexCount = pointsBuffer.length; | |
@@ -471,7 +471,7 @@ protected void parsePath() { | |||
| 471 | 471 | family = PATH; | |
| 472 | 472 | primitive = 0; | |
| 473 | 473 | ||
| 474 | - String pathData = element.getStringAttribute("d"); | ||
| 474 | + String pathData = element.getString("d"); | ||
| 475 | 475 | if (pathData == null) return; | |
| 476 | 476 | char[] pathDataChars = pathData.toCharArray(); | |
| 477 | 477 | ||
@@ -875,50 +875,50 @@ static protected PMatrix2D parseMatrix(String matrixStr) { | |||
| 875 | 875 | ||
| 876 | 876 | protected void parseColors(XMLElement properties) { | |
| 877 | 877 | if (properties.hasAttribute("opacity")) { | |
| 878 | - String opacityText = properties.getStringAttribute("opacity"); | ||
| 878 | + String opacityText = properties.getString("opacity"); | ||
| 879 | 879 | setOpacity(opacityText); | |
| 880 | 880 | } | |
| 881 | 881 | ||
| 882 | 882 | if (properties.hasAttribute("stroke")) { | |
| 883 | - String strokeText = properties.getStringAttribute("stroke"); | ||
| 883 | + String strokeText = properties.getString("stroke"); | ||
| 884 | 884 | setColor(strokeText, false); | |
| 885 | 885 | } | |
| 886 | 886 | ||
| 887 | 887 | if (properties.hasAttribute("stroke-opacity")) { | |
| 888 | - String strokeOpacityText = properties.getStringAttribute("stroke-opacity"); | ||
| 888 | + String strokeOpacityText = properties.getString("stroke-opacity"); | ||
| 889 | 889 | setStrokeOpacity(strokeOpacityText); | |
| 890 | 890 | } | |
| 891 | 891 | ||
| 892 | 892 | if (properties.hasAttribute("stroke-width")) { | |
| 893 | 893 | // if NaN (i.e. if it's 'inherit') then default back to the inherit setting | |
| 894 | - String lineweight = properties.getStringAttribute("stroke-width"); | ||
| 894 | + String lineweight = properties.getString("stroke-width"); | ||
| 895 | 895 | setStrokeWeight(lineweight); | |
| 896 | 896 | } | |
| 897 | 897 | ||
| 898 | 898 | if (properties.hasAttribute("stroke-linejoin")) { | |
| 899 | - String linejoin = properties.getStringAttribute("stroke-linejoin"); | ||
| 899 | + String linejoin = properties.getString("stroke-linejoin"); | ||
| 900 | 900 | setStrokeJoin(linejoin); | |
| 901 | 901 | } | |
| 902 | 902 | ||
| 903 | 903 | if (properties.hasAttribute("stroke-linecap")) { | |
| 904 | - String linecap = properties.getStringAttribute("stroke-linecap"); | ||
| 904 | + String linecap = properties.getString("stroke-linecap"); | ||
| 905 | 905 | setStrokeCap(linecap); | |
| 906 | 906 | } | |
| 907 | 907 | ||
| 908 | 908 | // fill defaults to black (though stroke defaults to "none") | |
| 909 | 909 | // http://www.w3.org/TR/SVG/painting.html#FillProperties | |
| 910 | 910 | if (properties.hasAttribute("fill")) { | |
| 911 | - String fillText = properties.getStringAttribute("fill"); | ||
| 911 | + String fillText = properties.getString("fill"); | ||
| 912 | 912 | setColor(fillText, true); | |
| 913 | 913 | } | |
| 914 | 914 | ||
| 915 | 915 | if (properties.hasAttribute("fill-opacity")) { | |
| 916 | - String fillOpacityText = properties.getStringAttribute("fill-opacity"); | ||
| 916 | + String fillOpacityText = properties.getString("fill-opacity"); | ||
| 917 | 917 | setFillOpacity(fillOpacityText); | |
| 918 | 918 | } | |
| 919 | 919 | ||
| 920 | 920 | if (properties.hasAttribute("style")) { | |
| 921 | - String styleText = properties.getStringAttribute("style"); | ||
| 921 | + String styleText = properties.getString("style"); | ||
| 922 | 922 | String[] styleTokens = PApplet.splitTokens(styleText, ";"); | |
| 923 | 923 | ||
| 924 | 924 | //PApplet.println(styleTokens); | |
@@ -1097,7 +1097,7 @@ static protected HashMap<String, String> parseStyleAttributes(String style) { | |||
| 1097 | 1097 | * @return unit-parsed version of the data | |
| 1098 | 1098 | */ | |
| 1099 | 1099 | static protected float getFloatWithUnit(XMLElement element, String attribute) { | |
| 1100 | - String val = element.getStringAttribute(attribute); | ||
| 1100 | + String val = element.getString(attribute); | ||
| 1101 | 1101 | return (val == null) ? 0 : parseUnitSize(val); | |
| 1102 | 1102 | } | |
| 1103 | 1103 | ||
@@ -1157,14 +1157,14 @@ public Gradient(PShapeSVG parent, XMLElement properties) { | |||
| 1157 | 1157 | XMLElement elem = elements[i]; | |
| 1158 | 1158 | String name = elem.getName(); | |
| 1159 | 1159 | if (name.equals("stop")) { | |
| 1160 | - String offsetAttr = elem.getStringAttribute("offset"); | ||
| 1160 | + String offsetAttr = elem.getString("offset"); | ||
| 1161 | 1161 | float div = 1.0f; | |
| 1162 | 1162 | if (offsetAttr.endsWith("%")) { | |
| 1163 | 1163 | div = 100.0f; | |
| 1164 | 1164 | offsetAttr = offsetAttr.substring(0, offsetAttr.length() - 1); | |
| 1165 | 1165 | } | |
| 1166 | 1166 | offset[count] = PApplet.parseFloat(offsetAttr) / div; | |
| 1167 | - String style = elem.getStringAttribute("style"); | ||
| 1167 | + String style = elem.getString("style"); | ||
| 1168 | 1168 | HashMap<String, String> styles = parseStyleAttributes(style); | |
| 1169 | 1169 | ||
| 1170 | 1170 | String colorStr = styles.get("stop-color"); | |
@@ -1195,7 +1195,7 @@ public LinearGradient(PShapeSVG parent, XMLElement properties) { | |||
| 1195 | 1195 | this.y2 = getFloatWithUnit(properties, "y2"); | |
| 1196 | 1196 | ||
| 1197 | 1197 | String transformStr = | |
| 1198 | - properties.getStringAttribute("gradientTransform"); | ||
| 1198 | + properties.getString("gradientTransform"); | ||
| 1199 | 1199 | ||
| 1200 | 1200 | if (transformStr != null) { | |
| 1201 | 1201 | float t[] = parseMatrix(transformStr).get(null); | |
@@ -1224,7 +1224,7 @@ public RadialGradient(PShapeSVG parent, XMLElement properties) { | |||
| 1224 | 1224 | this.r = getFloatWithUnit(properties, "r"); | |
| 1225 | 1225 | ||
| 1226 | 1226 | String transformStr = | |
| 1227 | - properties.getStringAttribute("gradientTransform"); | ||
| 1227 | + properties.getString("gradientTransform"); | ||
| 1228 | 1228 | ||
| 1229 | 1229 | if (transformStr != null) { | |
| 1230 | 1230 | float t[] = parseMatrix(transformStr).get(null); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -178,7 +178,7 @@ public void startElement(String name, | |||
| 178 | 178 | ||
| 179 | 179 | if (this.stack.empty()) { | |
| 180 | 180 | //System.out.println("setting root"); | |
| 181 | - parent.set(fullName, nsURI, systemID, lineNr); | ||
| 181 | + parent.init(fullName, nsURI, systemID, lineNr); | ||
| 182 | 182 | stack.push(parent); | |
| 183 | 183 | root = parent; | |
| 184 | 184 | } else { | |
@@ -236,7 +236,7 @@ public void endElement(String name, | |||
| 236 | 236 | ||
| 237 | 237 | if (child.getLocalName() == null) { | |
| 238 | 238 | elt.setContent(child.getContent()); | |
| 239 | - elt.removeChildAtIndex(0); | ||
| 239 | + elt.removeChild(0); | ||
| 240 | 240 | } | |
| 241 | 241 | } | |
| 242 | 242 | } | |
@@ -276,15 +276,15 @@ public void addAttribute(String key, | |||
| 276 | 276 | ||
| 277 | 277 | if (top.hasAttribute(fullName)) { | |
| 278 | 278 | throw new XMLParseException(top.getSystemID(), | |
| 279 | - top.getLineNr(), | ||
| 279 | + top.getLine(), | ||
| 280 | 280 | "Duplicate attribute: " + key); | |
| 281 | 281 | } | |
| 282 | 282 | ||
| 283 | - if (nsPrefix != null) { | ||
| 284 | - top.setAttribute(fullName, nsURI, value); | ||
| 285 | - } else { | ||
| 286 | - top.setAttribute(fullName, value); | ||
| 287 | - } | ||
| 283 | + // if (nsPrefix != null) { | ||
| 284 | + // top.setAttribute(fullName, nsURI, value); | ||
| 285 | + // } else { | ||
| 286 | + top.set(fullName, value); | ||
| 287 | + // } | ||
| 288 | 288 | } | |
| 289 | 289 | ||
| 290 | 290 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -497,17 +497,18 @@ protected void processElement(String defaultNamespace, | |||
| 497 | 497 | attrTypes.addElement("CDATA"); | |
| 498 | 498 | } | |
| 499 | 499 | ||
| 500 | - for (int i = 0; i < attrNames.size(); i++) { | ||
| 501 | - String key = (String) attrNames.elementAt(i); | ||
| 502 | - String value = (String) attrValues.elementAt(i); | ||
| 503 | - //String type = (String) attrTypes.elementAt(i); | ||
| 504 | - | ||
| 505 | - if (key.equals("xmlns")) { | ||
| 506 | - defaultNamespace = value; | ||
| 507 | - } else if (key.startsWith("xmlns:")) { | ||
| 508 | - namespaces.put(key.substring(6), value); | ||
| 509 | - } | ||
| 510 | - } | ||
| 500 | + // post 1.2.1, just treat namespaces like any other attribute | ||
| 501 | + // for (int i = 0; i < attrNames.size(); i++) { | ||
| 502 | + // String key = (String) attrNames.elementAt(i); | ||
| 503 | + // String value = (String) attrValues.elementAt(i); | ||
| 504 | + // //String type = (String) attrTypes.elementAt(i); | ||
| 505 | + | ||
| 506 | + // if (key.equals("xmlns")) { | ||
| 507 | + // defaultNamespace = value; | ||
| 508 | + // } else if (key.startsWith("xmlns:")) { | ||
| 509 | + // namespaces.put(key.substring(6), value); | ||
| 510 | + // } | ||
| 511 | + // } | ||
| 511 | 512 | ||
| 512 | 513 | if (prefix == null) { | |
| 513 | 514 | this.builder.startElement(name, prefix, defaultNamespace, | |
@@ -523,9 +524,9 @@ protected void processElement(String defaultNamespace, | |||
| 523 | 524 | for (int i = 0; i < attrNames.size(); i++) { | |
| 524 | 525 | String key = (String) attrNames.elementAt(i); | |
| 525 | 526 | ||
| 526 | - if (key.startsWith("xmlns")) { | ||
| 527 | - continue; | ||
| 528 | - } | ||
| 527 | + // if (key.startsWith("xmlns")) { | ||
| 528 | + // continue; | ||
| 529 | + // } | ||
| 529 | 530 | ||
| 530 | 531 | String value = (String) attrValues.elementAt(i); | |
| 531 | 532 | String type = (String) attrTypes.elementAt(i); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments