From 6682ad1454a0511912ea2cd3930ae0bcce60ba85 Mon Sep 17 00:00:00 2001 From: benfry Date: Sun, 19 Jun 2011 14:52:51 +0000 Subject: [PATCH] more node and android fixes, starting on ColorSelector --- .../processing/app/tools/ColorSelector.java | 8 ++++-- app/src/processing/mode/android/Manifest.java | 14 +++++++--- core/src/processing/core/PNode.java | 4 +-- core/src/processing/core/PNodeXML.java | 28 +++++++++++-------- core/todo.txt | 17 ++++++++--- 5 files changed, 47 insertions(+), 24 deletions(-) diff --git a/app/src/processing/app/tools/ColorSelector.java b/app/src/processing/app/tools/ColorSelector.java index 724d88735..5a37735cd 100644 --- a/app/src/processing/app/tools/ColorSelector.java +++ b/app/src/processing/app/tools/ColorSelector.java @@ -411,16 +411,18 @@ public class ColorSelector implements Tool, DocumentListener { public void setup() { - size(WIDE, HIGH, P3D); + size(WIDE, HIGH); //, P3D); noLoop(); colorMode(HSB, 360, 256, 256); noFill(); rectMode(CENTER); + + loadPixels(); } public void draw() { - if ((g == null) || (g.pixels == null)) return; +// if ((g == null) || (g.pixels == null)) return; if ((width != WIDE) || (height < HIGH)) { //System.out.println("bad size " + width + " " + height); return; @@ -487,7 +489,7 @@ public class ColorSelector implements Tool, DocumentListener { static final int HIGH = 256; public void setup() { - size(WIDE, HIGH, P3D); + size(WIDE, HIGH); //, P3D); colorMode(HSB, 255, 100, 100); noLoop(); } diff --git a/app/src/processing/mode/android/Manifest.java b/app/src/processing/mode/android/Manifest.java index 688b7f0a4..65e0a9c30 100644 --- a/app/src/processing/mode/android/Manifest.java +++ b/app/src/processing/mode/android/Manifest.java @@ -111,9 +111,11 @@ public class Manifest { } // ...and add the new kids back for (String name : names) { - PNode newbie = new PNodeXML("uses-permission"); +// PNode newbie = new PNodeXML("uses-permission"); +// newbie.setString("android:name", PERMISSION_PREFIX + name); +// xml.addChild(newbie); + PNode newbie = xml.addChild("uses-permission"); newbie.setString("android:name", PERMISSION_PREFIX + name); - xml.addChild(newbie); } save(); } @@ -216,7 +218,9 @@ public class Manifest { activity.setString("android:name", "." + className); // this has to be right PrintWriter writer = PApplet.createWriter(file); - mf.write(writer); + writer.print(mf.toString()); + writer.flush(); +// mf.write(writer); writer.close(); } @@ -271,7 +275,9 @@ public class Manifest { */ protected void save(File file) { PrintWriter writer = PApplet.createWriter(file); - xml.write(writer); +// xml.write(writer); + writer.print(xml.toString()); + writer.flush(); writer.close(); } diff --git a/core/src/processing/core/PNode.java b/core/src/processing/core/PNode.java index 451cd1c47..398464c09 100644 --- a/core/src/processing/core/PNode.java +++ b/core/src/processing/core/PNode.java @@ -98,7 +98,7 @@ public interface PNode extends Serializable { public PNode[] getChildren(String name); - public void addChild(PNode kid); + public PNode addChild(String name); public void removeChild(PNode kid); @@ -202,5 +202,5 @@ public interface PNode extends Serializable { public String toString(int indent); - public void write(PrintWriter writer); +// public void write(PrintWriter writer); } \ No newline at end of file diff --git a/core/src/processing/core/PNodeXML.java b/core/src/processing/core/PNodeXML.java index 63fbd2070..573ed64b7 100644 --- a/core/src/processing/core/PNodeXML.java +++ b/core/src/processing/core/PNodeXML.java @@ -362,12 +362,18 @@ public class PNodeXML implements PNode, Serializable { } - public void addChild(PNode kid) { - node.appendChild(((PNodeXML) kid).node); - children = null; // TODO not efficient + public PNode addChild(String tag) { + Document document = node.getOwnerDocument(); + Node newChild = document.createElement(tag); + node.appendChild(newChild); + PNode pn = new PNodeXML(this, newChild); + if (children != null) { + children = (PNode[]) PApplet.concat(children, new PNode[] { pn }); + } + return pn; } - - + + public void removeChild(PNode kid) { node.removeChild(((PNodeXML) kid).node); children = null; // TODO not efficient @@ -593,10 +599,10 @@ public class PNodeXML implements PNode, Serializable { } - static final String HEADER = ""; - - public void write(PrintWriter writer) { - writer.println(HEADER); - writer.print(toString(2)); - } +// static final String HEADER = ""; +// +// public void write(PrintWriter writer) { +// writer.println(HEADER); +// writer.print(toString(2)); +// } } diff --git a/core/todo.txt b/core/todo.txt index 36e10d205..1d24687e5 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -23,11 +23,20 @@ cleaning o call reapplySettings() when using beginRecord()? X nope, won't work for many fonts, can't get the background -_ see if write() is necessary inside PNodeXML -_ it needs a proper header on it, so maybe that's the difference w/ toString() -_ inefficient: the way new nodes are created -_ also inefficient: adding/removing kids just nukes the children array +xml changes +o see if write() is necessary inside PNodeXML +o it needs a proper header on it, so maybe that's the difference w/ toString() +o inefficient: the way new nodes are created +o also inefficient: adding/removing kids just nukes the children array +X toString() adds the XML header + +_ add support for automatically including OpenGL when asking for P3D +_ when using P3D and not realizing that it's really OpenGL... +Exception in thread "Animation Thread" java.lang.NoClassDefFoundError: Could not initialize class javax.media.opengl.GLProfile +Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: no gluegen-rt in java.library.path + _ check on DXFWriter, since it used to subclass P3D +_ at least implement is3D? _ Potential race condition when resizing sketches _ http://code.google.com/p/processing/issues/detail?id=697