From 9b45347b0ee7455546e20ba74b28fccc5944df38 Mon Sep 17 00:00:00 2001 From: benfry Date: Fri, 2 Sep 2011 00:53:28 +0000 Subject: [PATCH] handful of bug fixes and tweaks --- core/src/processing/core/PApplet.java | 2 +- core/src/processing/core/PGraphicsJava2D.java | 4 +-- core/src/processing/core/PImage.java | 20 ++++++----- core/src/processing/core/PShapeSVG.java | 2 +- core/todo.txt | 6 ++-- .../processing/opengl/PGraphicsOpenGL.java | 4 +-- .../src/processing/opengl/PShape3D.java | 36 +++++++++---------- todo.txt | 10 +++++- 8 files changed, 48 insertions(+), 36 deletions(-) diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 2da3ccf8e..47d93550a 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -5190,7 +5190,7 @@ public class PApplet extends Applet // ??? // NODE I/O (XML, JSON, etc.) - public XML loadNode(String filename) { + public XML loadXML(String filename) { return new XML(this, filename); } diff --git a/core/src/processing/core/PGraphicsJava2D.java b/core/src/processing/core/PGraphicsJava2D.java index 7e5bfc61c..b83189666 100644 --- a/core/src/processing/core/PGraphicsJava2D.java +++ b/core/src/processing/core/PGraphicsJava2D.java @@ -1305,12 +1305,12 @@ public class PGraphicsJava2D extends PGraphics /*PGraphics2D*/ { } - public void skewX(float angle) { + public void shearX(float angle) { g2.shear(Math.tan(angle), 0); } - public void skewY(float angle) { + public void shearY(float angle) { g2.shear(0, Math.tan(angle)); } diff --git a/core/src/processing/core/PImage.java b/core/src/processing/core/PImage.java index 7cff3040e..effd88829 100644 --- a/core/src/processing/core/PImage.java +++ b/core/src/processing/core/PImage.java @@ -3049,18 +3049,22 @@ public class PImage implements PConstants, Cloneable { public boolean save(String filename) { // ignore boolean success = false; -// File file = new File(filename); -// if (!file.isAbsolute()) { - // always use savePath(), so that the intermediate directories are created if (parent != null) { - //file = new File(parent.savePath(filename)); + // use savePath(), so that the intermediate directories are created filename = parent.savePath(filename); + } else { - String msg = "PImage.save() requires an absolute path. " + - "Use createImage(), or pass savePath() to save()."; - PGraphics.showException(msg); + File file = new File(filename); + if (file.isAbsolute()) { + // make sure that the intermediate folders have been created + PApplet.createPath(file); + } else { + String msg = + "PImage.save() requires an absolute path. " + + "Use createImage(), or pass savePath() to save()."; + PGraphics.showException(msg); + } } -// } // Make sure the pixel data is ready to go loadPixels(); diff --git a/core/src/processing/core/PShapeSVG.java b/core/src/processing/core/PShapeSVG.java index f6c432d88..ff8e945c5 100644 --- a/core/src/processing/core/PShapeSVG.java +++ b/core/src/processing/core/PShapeSVG.java @@ -163,7 +163,7 @@ public class PShapeSVG extends PShape { public PShapeSVG(PApplet parent, String filename) { // this will grab the root document, starting // the xml version and initial comments are ignored - this(parent.loadNode(filename)); + this(parent.loadXML(filename)); } diff --git a/core/todo.txt b/core/todo.txt index 9a6e596bb..7e324814e 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -1,6 +1,8 @@ 0200 core X remove textMode(SCREEN) X added expand(long) and expand(double) because of Table +X PImage.save() with full path raises exception +X http://code.google.com/p/processing/issues/detail?id=808 _ change how beginRecord() works.. passing around PApplet vs PGraphics is gross _ have to pass PApplet just to make the rendering work to both renderers @@ -11,12 +13,10 @@ _ for more options, just integrate the fs library? _ http://www.superduper.org/processing/fullscreen_api/ _ https://github.com/kritzikratzi/jAppleMenuBar/blob/master/src/native/jAppleMenuBar.m -_ update wiki re: PNode... also include notes about the changes +X update wiki re: PNode... also include notes about the changes _ add note about textMode(SCREEN) to the wiki SCREEN was a super fast/efficient way of rendering text with P2D and P3D, but since they're going bye-bye and it's actually slower in the remaining renderers, it's going away. -_ PImage.save() with full path raises exception -_ http://code.google.com/p/processing/issues/detail?id=808 _ if save() returns boolean, does saveFrame()? _ also need to copy this over to android diff --git a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java index 98aebdc3c..f8de10d69 100644 --- a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java +++ b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java @@ -1878,8 +1878,8 @@ public class PGraphicsOpenGL extends PGraphics { "using u and v coordinates with vertex()"); } if (textureMode == IMAGE) { - u /= (float) img.width; - v /= (float) img.height; + u /= img.width; + v /= img.height; } texturesU[t] = u; diff --git a/java/libraries/opengl/src/processing/opengl/PShape3D.java b/java/libraries/opengl/src/processing/opengl/PShape3D.java index c65951494..125a988ab 100644 --- a/java/libraries/opengl/src/processing/opengl/PShape3D.java +++ b/java/libraries/opengl/src/processing/opengl/PShape3D.java @@ -2111,7 +2111,7 @@ public class PShape3D extends PShape { protected void setColorImpl(float[] c) { - PShape3D p = (PShape3D)root; + PShape3D p = root; p.loadColors(); for (int i = firstVertex; i <= lastVertex; i++) { p.set(i, c); @@ -2150,7 +2150,7 @@ public class PShape3D extends PShape { protected void setNormalImpl(float[] n) { - PShape3D p = (PShape3D)root; + PShape3D p = root; p.loadNormals(); for (int i = firstVertex; i <= lastVertex; i++) { p.set(i, n); @@ -2166,9 +2166,9 @@ public class PShape3D extends PShape { // Expanding identical, contiguous shapes. Names are taken into account (two // shapes with different names are considered to be different, even though the // rest of their parameters are identical). - child0 = (PShape3D)childList.get(0); + child0 = childList.get(0); for (int i = 1; i < childList.size(); i++) { - child1 = (PShape3D)childList.get(i); + child1 = childList.get(i); if (child0.equalTo(child1, false)) { child0.lastVertex = child1.lastVertex; // Extending child0. child0.lastIndex = child1.lastIndex; @@ -2184,16 +2184,16 @@ public class PShape3D extends PShape { // Deleting superfluous shapes. for (int i = childList.size() - 1; i >= 0; i--) { - if (((PShape3D)childList.get(i)).lastVertex == -1) { + if (childList.get(i).lastVertex == -1) { childList.remove(i); } } // Making sure the names are unique. for (int i = 1; i < childList.size(); i++) { - child1 = (PShape3D)childList.get(i); + child1 = childList.get(i); for (int j = i - 1; j >= 0; j--) { - child0 = (PShape3D)childList.get(j); + child0 = childList.get(j); if (child1.name.equals(child0.name)) { int pos = child0.name.indexOf(':'); if (-1 < pos) { @@ -2288,7 +2288,7 @@ public class PShape3D extends PShape { public void setVertices(ArrayList vertexList, int offset) { loadVertices(); for (int i = firstVertex; i <= lastVertex; i++) { - PVector v = (PVector)vertexList.get(i - firstVertex + offset); + PVector v = vertexList.get(i - firstVertex + offset); set(i, v.x, v.y, v.z); } updateVertices(); @@ -2301,7 +2301,7 @@ public class PShape3D extends PShape { public void setColors(ArrayList colorList, int offset) { loadColors(); for (int i = firstVertex; i <= lastVertex; i++) { - float[] c = (float[])colorList.get(i - firstVertex + offset); + float[] c = colorList.get(i - firstVertex + offset); set(i, c); } updateColors(); @@ -2315,7 +2315,7 @@ public class PShape3D extends PShape { public void setNormals(ArrayList normalList, int offset) { loadNormals(); for (int i = firstVertex; i <= lastVertex; i++) { - PVector n = (PVector)normalList.get(i - firstVertex + offset); + PVector n = normalList.get(i - firstVertex + offset); set(i, n.x, n.y, n.z); } updateNormals(); @@ -2337,7 +2337,7 @@ public class PShape3D extends PShape { public void setTexcoords(int unit, ArrayList tcoordList, int offset) { loadTexcoords(unit); for (int i = firstVertex; i <= lastVertex; i++) { - PVector tc = (PVector)tcoordList.get(i - firstVertex + offset); + PVector tc = tcoordList.get(i - firstVertex + offset); set(i, tc.x, tc.y); } updateTexcoords(); @@ -2349,7 +2349,7 @@ public class PShape3D extends PShape { childCount = 0; for (int i = 0; i < who.size(); i++) { - PShape child = (PShape)who.get(i); + PShape child = who.get(i); addChild(child); } } @@ -2599,7 +2599,7 @@ public class PShape3D extends PShape { indexBuffer = getGl().glMapBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, GL.GL_WRITE_ONLY).asIntBuffer(); for (int i = 0; i < indexCount; i++) { - indices[i] = (Integer)recordedIndices.get(i); + indices[i] = recordedIndices.get(i); } indexBuffer.put(indices); @@ -3521,13 +3521,13 @@ public class PShape3D extends PShape { ogl.beginShapeRecorderImpl(); for (int i = 0; i < faces.size(); i++) { - OBJFace face = (OBJFace) faces.get(i); + OBJFace face = faces.get(i); // Getting current material. if (mtlIdxCur != face.matIdx) { mtlIdxCur = PApplet.max(0, face.matIdx); // To make sure that at least we get the default material. - mtl = (OBJMaterial) materials.get(mtlIdxCur); + mtl = materials.get(mtlIdxCur); // Setting colors. ogl.specular(mtl.ks.x * 255.0f, mtl.ks.y * 255.0f, mtl.ks.z * 255.0f); @@ -3561,12 +3561,12 @@ public class PShape3D extends PShape { vert = norms = null; vertIdx = face.vertIdx.get(j).intValue() - 1; - vert = (PVector) vertices.get(vertIdx); + vert = vertices.get(vertIdx); if (j < face.normIdx.size()) { normIdx = face.normIdx.get(j).intValue() - 1; if (-1 < normIdx) { - norms = (PVector) normals.get(normIdx); + norms = normals.get(normIdx); } } @@ -3578,7 +3578,7 @@ public class PShape3D extends PShape { if (j < face.texIdx.size()) { texIdx = face.texIdx.get(j).intValue() - 1; if (-1 < texIdx) { - tex = (PVector) textures.get(texIdx); + tex = textures.get(texIdx); } } diff --git a/todo.txt b/todo.txt index b327ad393..3b0cb7302 100644 --- a/todo.txt +++ b/todo.txt @@ -3,6 +3,14 @@ X update to java 6u26 X re-upload with new version to include javac X HTML escapes for < and > not working properly X http://code.google.com/p/processing/issues/detail?id=771 +X code to quit if multiple instances are running from peter +X another problem with missing shearX/Y() in JAVA2D +X http://code.google.com/p/processing/issues/detail?id=784 + + +_ work on code to quit if multiple instances are running +_ need to bring the other instance to front +_ and/or open a new window _ --bgcolor shouldn't be in main() unless 'present' is turned on _ also add option for FSEM or not @@ -10,7 +18,7 @@ _ also add option for FSEM or not _ library imports failing for libs that define the same packages in 1.5.1 _ http://code.google.com/p/processing/issues/detail?id=725 -_ make application the correct one instead of applet +_ make application the default instead of applet _ renaming a normal tab to same name with ".java" fails with ".pde" version already exists _ http://code.google.com/p/processing/issues/detail?id=776