diff --git a/app/src/processing/mode/android/Manifest.java b/app/src/processing/mode/android/Manifest.java index fd7b7b648..3016ebe0b 100644 --- a/app/src/processing/mode/android/Manifest.java +++ b/app/src/processing/mode/android/Manifest.java @@ -23,7 +23,6 @@ package processing.mode.android; import java.io.File; import java.io.FileNotFoundException; -import java.io.FileReader; import java.io.IOException; import java.io.PrintWriter; @@ -201,7 +200,7 @@ public class Manifest { // load the copy from the build location and start messing with it XML mf = null; try { - mf = new XML(new FileReader(file)); + mf = new XML(file); // package name, or default String p = mf.getString("package").trim(); @@ -241,7 +240,7 @@ public class Manifest { File manifestFile = getManifestFile(); if (manifestFile.exists()) { try { - xml = new XML(new FileReader(manifestFile)); + xml = new XML(manifestFile); } catch (Exception e) { e.printStackTrace(); System.err.println("Problem reading AndroidManifest.xml, creating a new version"); @@ -261,7 +260,7 @@ public class Manifest { if (xml == null) { writeBlankManifest(manifestFile); try { - xml = new XML(new FileReader(manifestFile)); + xml = new XML(manifestFile); } catch (FileNotFoundException e) { System.err.println("Could not read " + manifestFile.getAbsolutePath()); e.printStackTrace(); diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 7a97eb370..59b7984e2 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -5822,8 +5822,14 @@ public class PApplet extends Applet * @see PApplet#loadTable(String) */ public XML loadXML(String filename) { + return loadXML(filename, null); + } + + + // version that uses 'options' though there are currently no supported options + public XML loadXML(String filename, String options) { try { - return new XML(this, filename); + return new XML(createInput(filename), options); } catch (Exception e) { e.printStackTrace(); return null; @@ -5831,6 +5837,31 @@ public class PApplet extends Applet } + public XML parseXML(String xmlString) { + return parseXML(xmlString, null); + } + + + public XML parseXML(String xmlString, String options) { + try { + return XML.parse(xmlString, options); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + + public boolean saveXML(XML xml, String filename) { + return saveXML(xml, filename, null); + } + + + public boolean saveXML(XML xml, String filename, String options) { + return xml.save(saveFile(filename), options); + } + + public Table createTable() { return new Table(); } @@ -5869,17 +5900,19 @@ public class PApplet extends Applet } - public void saveTable(Table table, String filename) { - saveTable(table, filename, null); + public boolean saveTable(Table table, String filename) { + return saveTable(table, filename, null); } - public void saveTable(Table table, String filename, String options) { + public boolean saveTable(Table table, String filename, String options) { try { table.save(saveFile(filename), options); + return true; } catch (IOException e) { e.printStackTrace(); } + return false; } @@ -10847,6 +10880,11 @@ public class PApplet extends Applet } + public PShape loadShape(String filename, String options) { + return g.loadShape(filename, options); + } + + /** * @webref shape * @see PShape diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java index 08d126e92..fae7f09ad 100644 --- a/core/src/processing/core/PGraphics.java +++ b/core/src/processing/core/PGraphics.java @@ -1604,6 +1604,11 @@ public class PGraphics extends PImage implements PConstants { * @see PApplet#createShape() */ public PShape loadShape(String filename) { + return loadShape(filename, null); + } + + + public PShape loadShape(String filename, String options) { showMissingWarning("loadShape"); return null; } diff --git a/core/src/processing/core/PGraphicsJava2D.java b/core/src/processing/core/PGraphicsJava2D.java index 0f3b209a8..9e28bc2b7 100644 --- a/core/src/processing/core/PGraphicsJava2D.java +++ b/core/src/processing/core/PGraphicsJava2D.java @@ -1380,17 +1380,23 @@ public class PGraphicsJava2D extends PGraphics /*PGraphics2D*/ { @Override public PShape loadShape(String filename) { + return loadShape(filename, null); + } + + + @Override + public PShape loadShape(String filename, String options) { String extension = PApplet.getExtension(filename); PShapeSVG svg = null; if (extension.equals("svg")) { - svg = new PShapeSVG(parent, filename); + svg = new PShapeSVG(parent.loadXML(filename)); } else if (extension.equals("svgz")) { try { InputStream input = new GZIPInputStream(parent.createInput(filename)); - XML xml = new XML(PApplet.createReader(input)); + XML xml = new XML(input, options); svg = new PShapeSVG(xml); } catch (Exception e) { e.printStackTrace(); diff --git a/core/src/processing/core/PShapeSVG.java b/core/src/processing/core/PShapeSVG.java index aa44d6386..74ff11fa3 100644 --- a/core/src/processing/core/PShapeSVG.java +++ b/core/src/processing/core/PShapeSVG.java @@ -159,14 +159,14 @@ public class PShapeSVG extends PShape { String fillName; // id of another object - /** - * Initializes a new SVG Object with the given filename. - */ - public PShapeSVG(PApplet parent, String filename) { - // this will grab the root document, starting - // the xml version and initial comments are ignored - this(parent.loadXML(filename)); - } +// /** +// * Initializes a new SVG Object with the given filename. +// */ +// public PShapeSVG(PApplet parent, String filename) { +// // this will grab the root document, starting +// // the xml version and initial comments are ignored +// this(parent.loadXML(filename)); +// } /** diff --git a/core/src/processing/data/Table.java b/core/src/processing/data/Table.java index 17ca02d03..c7fb90c33 100644 --- a/core/src/processing/data/Table.java +++ b/core/src/processing/data/Table.java @@ -119,6 +119,11 @@ public class Table { } + public Table(InputStream input) throws IOException { + this(input, null); + } + + /** * Read the table from a stream. Possible options include: *