FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

add getBoolean(), deprecate the getAttributeXxxx(), add listChildren(… · bchenault/processing@3b1bc7c · GitHub

Repository navigation

Commit 3b1bc7c

Browse files
committed
add getBoolean(), deprecate the getAttributeXxxx(), add listChildren(), more cleanup on indents and namespace mess
1 parent ecb1b7e commit 3b1bc7c

7 files changed

Lines changed: 881 additions & 727 deletions

File tree

‎core/.settings/org.eclipse.jdt.core.prefs‎

Lines changed: 271 additions & 271 deletions
Large diffs are not rendered by default.

‎core/src/processing/core/PShapeSVG.java‎

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public PShapeSVG(XMLElement svg) {
181181

182182
// not proper parsing of the viewBox, but will cover us for cases where
183183
// the width and height of the object is not specified
184-
String viewBoxStr = svg.getStringAttribute("viewBox");
184+
String viewBoxStr = svg.getString("viewBox");
185185
if (viewBoxStr != null) {
186186
int[] viewBox = PApplet.parseInt(PApplet.splitTokens(viewBoxStr));
187187
width = viewBox[2];
@@ -191,8 +191,8 @@ public PShapeSVG(XMLElement svg) {
191191
// TODO if viewbox is not same as width/height, then use it to scale
192192
// the original objects. for now, viewbox only used when width/height
193193
// 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");
196196
if (unitWidth != null) {
197197
width = parseUnitSize(unitWidth);
198198
height = parseUnitSize(unitHeight);
@@ -266,7 +266,7 @@ public PShapeSVG(PShapeSVG parent, XMLElement properties) {
266266
}
267267

268268
element = properties;
269-
name = properties.getStringAttribute("id");
269+
name = properties.getString("id");
270270
// @#$(* adobe illustrator mangles names of objects when re-saving
271271
if (name != null) {
272272
while (true) {
@@ -277,10 +277,10 @@ public PShapeSVG(PShapeSVG parent, XMLElement properties) {
277277
}
278278
}
279279

280-
String displayStr = properties.getStringAttribute("display", "inline");
280+
String displayStr = properties.getString("display", "inline");
281281
visible = !displayStr.equals("none");
282282

283-
String transformStr = properties.getStringAttribute("transform");
283+
String transformStr = properties.getString("transform");
284284
if (transformStr != null) {
285285
matrix = parseMatrix(transformStr);
286286
}
@@ -453,7 +453,7 @@ protected void parsePoly(boolean close) {
453453
family = PATH;
454454
this.close = close;
455455

456-
String pointsAttr = element.getStringAttribute("points");
456+
String pointsAttr = element.getString("points");
457457
if (pointsAttr != null) {
458458
String[] pointsBuffer = PApplet.splitTokens(pointsAttr);
459459
vertexCount = pointsBuffer.length;
@@ -471,7 +471,7 @@ protected void parsePath() {
471471
family = PATH;
472472
primitive = 0;
473473

474-
String pathData = element.getStringAttribute("d");
474+
String pathData = element.getString("d");
475475
if (pathData == null) return;
476476
char[] pathDataChars = pathData.toCharArray();
477477

@@ -875,50 +875,50 @@ static protected PMatrix2D parseMatrix(String matrixStr) {
875875

876876
protected void parseColors(XMLElement properties) {
877877
if (properties.hasAttribute("opacity")) {
878-
String opacityText = properties.getStringAttribute("opacity");
878+
String opacityText = properties.getString("opacity");
879879
setOpacity(opacityText);
880880
}
881881

882882
if (properties.hasAttribute("stroke")) {
883-
String strokeText = properties.getStringAttribute("stroke");
883+
String strokeText = properties.getString("stroke");
884884
setColor(strokeText, false);
885885
}
886886

887887
if (properties.hasAttribute("stroke-opacity")) {
888-
String strokeOpacityText = properties.getStringAttribute("stroke-opacity");
888+
String strokeOpacityText = properties.getString("stroke-opacity");
889889
setStrokeOpacity(strokeOpacityText);
890890
}
891891

892892
if (properties.hasAttribute("stroke-width")) {
893893
// 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");
895895
setStrokeWeight(lineweight);
896896
}
897897

898898
if (properties.hasAttribute("stroke-linejoin")) {
899-
String linejoin = properties.getStringAttribute("stroke-linejoin");
899+
String linejoin = properties.getString("stroke-linejoin");
900900
setStrokeJoin(linejoin);
901901
}
902902

903903
if (properties.hasAttribute("stroke-linecap")) {
904-
String linecap = properties.getStringAttribute("stroke-linecap");
904+
String linecap = properties.getString("stroke-linecap");
905905
setStrokeCap(linecap);
906906
}
907907

908908
// fill defaults to black (though stroke defaults to "none")
909909
// http://www.w3.org/TR/SVG/painting.html#FillProperties
910910
if (properties.hasAttribute("fill")) {
911-
String fillText = properties.getStringAttribute("fill");
911+
String fillText = properties.getString("fill");
912912
setColor(fillText, true);
913913
}
914914

915915
if (properties.hasAttribute("fill-opacity")) {
916-
String fillOpacityText = properties.getStringAttribute("fill-opacity");
916+
String fillOpacityText = properties.getString("fill-opacity");
917917
setFillOpacity(fillOpacityText);
918918
}
919919

920920
if (properties.hasAttribute("style")) {
921-
String styleText = properties.getStringAttribute("style");
921+
String styleText = properties.getString("style");
922922
String[] styleTokens = PApplet.splitTokens(styleText, ";");
923923

924924
//PApplet.println(styleTokens);
@@ -1097,7 +1097,7 @@ static protected HashMap<String, String> parseStyleAttributes(String style) {
10971097
* @return unit-parsed version of the data
10981098
*/
10991099
static protected float getFloatWithUnit(XMLElement element, String attribute) {
1100-
String val = element.getStringAttribute(attribute);
1100+
String val = element.getString(attribute);
11011101
return (val == null) ? 0 : parseUnitSize(val);
11021102
}
11031103

@@ -1157,14 +1157,14 @@ public Gradient(PShapeSVG parent, XMLElement properties) {
11571157
XMLElement elem = elements[i];
11581158
String name = elem.getName();
11591159
if (name.equals("stop")) {
1160-
String offsetAttr = elem.getStringAttribute("offset");
1160+
String offsetAttr = elem.getString("offset");
11611161
float div = 1.0f;
11621162
if (offsetAttr.endsWith("%")) {
11631163
div = 100.0f;
11641164
offsetAttr = offsetAttr.substring(0, offsetAttr.length() - 1);
11651165
}
11661166
offset[count] = PApplet.parseFloat(offsetAttr) / div;
1167-
String style = elem.getStringAttribute("style");
1167+
String style = elem.getString("style");
11681168
HashMap<String, String> styles = parseStyleAttributes(style);
11691169

11701170
String colorStr = styles.get("stop-color");
@@ -1195,7 +1195,7 @@ public LinearGradient(PShapeSVG parent, XMLElement properties) {
11951195
this.y2 = getFloatWithUnit(properties, "y2");
11961196

11971197
String transformStr =
1198-
properties.getStringAttribute("gradientTransform");
1198+
properties.getString("gradientTransform");
11991199

12001200
if (transformStr != null) {
12011201
float t[] = parseMatrix(transformStr).get(null);
@@ -1224,7 +1224,7 @@ public RadialGradient(PShapeSVG parent, XMLElement properties) {
12241224
this.r = getFloatWithUnit(properties, "r");
12251225

12261226
String transformStr =
1227-
properties.getStringAttribute("gradientTransform");
1227+
properties.getString("gradientTransform");
12281228

12291229
if (transformStr != null) {
12301230
float t[] = parseMatrix(transformStr).get(null);

‎core/src/processing/xml/StdXMLBuilder.java‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public void startElement(String name,
178178

179179
if (this.stack.empty()) {
180180
//System.out.println("setting root");
181-
parent.set(fullName, nsURI, systemID, lineNr);
181+
parent.init(fullName, nsURI, systemID, lineNr);
182182
stack.push(parent);
183183
root = parent;
184184
} else {
@@ -236,7 +236,7 @@ public void endElement(String name,
236236

237237
if (child.getLocalName() == null) {
238238
elt.setContent(child.getContent());
239-
elt.removeChildAtIndex(0);
239+
elt.removeChild(0);
240240
}
241241
}
242242
}
@@ -276,15 +276,15 @@ public void addAttribute(String key,
276276

277277
if (top.hasAttribute(fullName)) {
278278
throw new XMLParseException(top.getSystemID(),
279-
top.getLineNr(),
279+
top.getLine(),
280280
"Duplicate attribute: " + key);
281281
}
282282

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+
// }
288288
}
289289

290290

‎core/src/processing/xml/StdXMLParser.java‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -497,17 +497,18 @@ protected void processElement(String defaultNamespace,
497497
attrTypes.addElement("CDATA");
498498
}
499499

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+
// }
511512

512513
if (prefix == null) {
513514
this.builder.startElement(name, prefix, defaultNamespace,
@@ -523,9 +524,9 @@ protected void processElement(String defaultNamespace,
523524
for (int i = 0; i < attrNames.size(); i++) {
524525
String key = (String) attrNames.elementAt(i);
525526

526-
if (key.startsWith("xmlns")) {
527-
continue;
528-
}
527+
// if (key.startsWith("xmlns")) {
528+
// continue;
529+
// }
529530

530531
String value = (String) attrValues.elementAt(i);
531532
String type = (String) attrTypes.elementAt(i);

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL