diff --git a/core/PApplet.java b/core/PApplet.java index 07e34d2c4..a11fea1ca 100644 --- a/core/PApplet.java +++ b/core/PApplet.java @@ -445,6 +445,12 @@ public class PApplet extends Applet // stop method register list) } + try { + if (path == null) { + System.getProperty("user.dir"); + } + } catch (Exception e) { } // may be a security problem + // create a dummy graphics context size(DEFAULT_WIDTH, DEFAULT_HEIGHT); //size(INITIAL_WIDTH, INITIAL_HEIGHT); @@ -3174,16 +3180,27 @@ public class PApplet extends Applet * but want an InputStream object so that you can use other Java * methods to take more control of how the stream is read. *

+ * If the requested item doesn't exist, null is returned. + * (Prior to 0096, die() would be called, killing the applet) + *

* The filename passed in can be: *

*/ public InputStream openStream(String filename) { InputStream stream = null; + // by default, data files are exported to the root path of the jar. + // (not the data folder) so check there first. + // the slash as a prefix means that it'll load from the root of + // the jar, rather than trying to dig into the package location + stream = getClass().getResourceAsStream("/" + filename); + //stream = getClass().getResourceAsStream(filename); + if (stream != null) return stream; + try { URL url = new URL(filename); stream = url.openStream(); @@ -3223,7 +3240,8 @@ public class PApplet extends Applet if (!filenameActual.equals(filenameShort)) { throw new RuntimeException("This file is named " + filenameActual + " not " + - filename + "."); + filename + ". Re-name it " + + "or change your code."); } } catch (IOException e) { } } @@ -3239,31 +3257,24 @@ public class PApplet extends Applet } try { - // by default, data files are exported to the root path of the jar. - // (not the data folder) so check there first. - stream = getClass().getResourceAsStream(filename); - if (stream != null) return stream; - // hm, check the data subfolder - stream = getClass().getResourceAsStream(dataPath(filename)); - if (stream != null) return stream; + //stream = getClass().getResourceAsStream("data/" + filename); + //if (stream != null) return stream; // attempt to load from a local file, used when running as // an application, or as a signed applet try { // first try to catch any security exceptions try { - File file = new File(path, filename); - stream = new FileInputStream(file); - if (stream != null) return stream; - - } catch (Exception e) { } // ignored - - try { - //stream = new FileInputStream(new File("data", filename)); stream = new FileInputStream(dataPath(filename)); if (stream != null) return stream; } catch (IOException e2) { } + try { + File file = new File(path, filename); + stream = new FileInputStream(file); + if (stream != null) return stream; + } catch (Exception e) { } // ignored + try { stream = new FileInputStream(filename); if (stream != null) return stream; @@ -3271,11 +3282,12 @@ public class PApplet extends Applet } catch (SecurityException se) { } // online, whups - if (stream == null) { - throw new IOException("openStream() could not open " + filename); - } + //if (stream == null) { + //throw new IOException("openStream() could not open " + filename); + //} } catch (Exception e) { - die(e.getMessage(), e); + //die(e.getMessage(), e); + e.printStackTrace(); } return null; // #$(*@ compiler } @@ -3480,6 +3492,9 @@ public class PApplet extends Applet * Return a full path to an item in the data folder. */ public String dataPath(String where) { + if (path == null) { + return "data" + File.separator + where; + } return path + File.separator + "data" + File.separator + where; } @@ -5358,9 +5373,9 @@ v PApplet.this.stop(); * the default is to center on the main screen. * * --present put the applet into full screen presentation - * mode. requires java 1.4. + * mode. requires java 1.4 or later. * - * --bgcolor=#xxxxxx background color of the window + * --bgcolor=#xxxxxx background color of the window. * * --sketch-path location of where to save files from functions * like saveStrings() or saveFrame(). defaults to diff --git a/core/PImage.java b/core/PImage.java index 0c8ad1695..0ce06527d 100644 --- a/core/PImage.java +++ b/core/PImage.java @@ -1990,7 +1990,7 @@ public class PImage implements PConstants, Cloneable { * Save this image to disk. This method will save to the "current" * folder, which when running inside the PDE will be the location * of the Processing application, not the sketch folder. To save - * inside the sketch folder, use the variable savePath from PApplet, + * inside the sketch folder, use the function savePath from PApplet, * or use saveFrame() instead. */ public void save(String filename) { diff --git a/core/done.txt b/core/done.txt index cec9c4cfd..2eb774132 100644 --- a/core/done.txt +++ b/core/done.txt @@ -1,3 +1,7 @@ +0095 core +X undo the fix that causes the width/height to be properly set + + 0094 core X fix bug that was causing font sizes not to be set on opengl X http://dev.processing.org/bugs/show_bug.cgi?id=174 diff --git a/core/todo.txt b/core/todo.txt index 4fcad9790..59d052857 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -1,5 +1,7 @@ -0095 core -X undo the fix that causes the width/height to be properly set +0096 core +X set applet.path to user.dir if init() is reached and it's not set + +_ "not available in P3D" should read "OPENGL" in opengl lib _ width, height set to zero in static mode _ probably only set when resize() is called, and it's not happening @@ -376,8 +378,29 @@ _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bu _ ellipses are just plain ugly _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1073409011;start=0 _ toxi ellipses don't adapt properly with transformations - - +_ more blend() modes (the five listed on the thread below?) +_ http://dev.processing.org/bugs/show_bug.cgi?id=132 +_ figure out what the modes should actually be: +_ photoshop: normal, dissolve; darken, multiply, color burn, +_ linear burn; lighten, screen, color dodge, linear +_ dodge; overlay, soft light, hard light, vivid light, +_ linear light, pin light, hard mix; difference, +_ exclusion; hue, saturation, color, luminosity +_ illustrator: normal; darken, multiply, color burn; lighten, +_ screen, color dodge; overlay, soft light, hard light; +_ difference, exclusion; hue, sat, color, luminosity +_ director: Copy, Transparent, Reverse, Ghost, Not copy, +_ Not transparent, Not reverse, Not ghost, Matte, Mask; +_ (below seems more useful: +_ Blend, Add pin, Add, Subtract pin, Background transparent, +_ Lightest, Subtract, Darkest, Lighten, Darken +_ flash: +_ DIFFERENCE: C = abs(A-B); +_ MULTIPLY: C = (A * B ) / 255 +_ SCREEN: C= 255 - ( (255-A) * (255-B) / 255 ) +_ OVERLAY: C = B < 128 ? (2*A*B/255) : 255-2*(255-A)*(255-B)/255 +_ HARD_LIGHT: C = A < 128 ? (2*A*B/255) : 255-2*(255-A)*(255-B)/255 +_ SOFT_LIGHT: C = B < 128 ? 2*((A>>1)+64)*B/255 : 255-(2*(255-((A>>1)+64))*(255-B)/255) _ clipping planes _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1058491568;start=0 _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1052313604;start=0 @@ -464,65 +487,42 @@ _ http://dev.processing.org/bugs/show_bug.cgi?id=103 CORE / PImage +_ access logs are being spammed because openStream() gets a 404 +_ the default should be to check the .jar file +_ image no load halts the program (rather than returning null) +_ note in the reference: png images work with java 1.3+ +_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=WebsiteBugs;action=display;num=1125968697 +_ http://java.sun.com/j2se/1.3/docs/guide/2d/new_features.html +_ loadImage() seems to be caching everything from the jar +_ http://java.sun.com/developer/technicalArticles/Media/imagestrategies/index.html +_ make a note of how to disable this +_ http://processing.org/discourse/yabb/YaBB.cgi?board=Programs;action=display;num=1078795681 _ bizarre image loading error with c_Rollover.zip -_ image loading bug is huge _ figure out how to handle cached images, multiple images +_ write a simple example for threaded image loading "load several" +_ include it as part of the javadoc _ MediaTracker blocking is prolly making jar download really slow _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1089914280 -_ also threaded images -_ don't grab pixels of java2d images unless asked -_ this is the difference between a lot of loadPixels() and not -_ so important to have it in before beta if that's the change -_ also when drawing an image, sense whether drawn rotated -_ specifically, if drawn rotated 90 in either direction, or 180 -_ if just rotate/translate, then can use SCREEN_SPACE for fonts _ dynamically load code for png and others on loadImage/saveFrame? +_ how to load external encoders/decoders _ updated png encoder _ http://processing.org/discourse/yabb/YaBB.cgi?board=Syntax;action=display;num=1083792994 _ should image i/o and sound i/o be moved into PImage and PSound? -_ how to load external encoders/decoders _ more image file i/o.. more advanced in newer java _ http://dev.processing.org/bugs/show_bug.cgi?id=165 +_ http://java.sun.com/products/java-media/jai/index.jsp _ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Programs;action=display;num=1120174647 _ read uncompressed tiff, read uncompressed tga files. _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1081190619 _ http://processing.org/discourse/yabb/YaBB.cgi?board=Tools;action=display;num=1066742994 -_ loadImage() seems to be caching everything from the jar -_ make a note of how to disable this -_ http://processing.org/discourse/yabb/YaBB.cgi?board=Programs;action=display;num=1078795681#8 _ get loadImage() to work properly with data folder _ should probably use the code from loadStream _ and the url stuff should be an alternate method altogether -_ alpha not set on saveFrame, so can't be used in photoshop as a layer -_ http://processing.org/discourse/yabb/YaBB.cgi?board=general;action=display;num=1078441623 _ expose function to write tiff header in PImage (advanced) _ helps with writing enormous images _ loadImage must be used inside or after setup _ either document this and/or provide a better error message _ http://processing.org/discourse/yabb/YaBB.cgi?board=Programs;action=display;num=1060879468 -_ more blend() modes (the five listed on the thread below?) -_ http://dev.processing.org/bugs/show_bug.cgi?id=132 -_ figure out what the modes should actually be: -_ photoshop: normal, dissolve; darken, multiply, color burn, -_ linear burn; lighten, screen, color dodge, linear -_ dodge; overlay, soft light, hard light, vivid light, -_ linear light, pin light, hard mix; difference, -_ exclusion; hue, saturation, color, luminosity -_ illustrator: normal; darken, multiply, color burn; lighten, -_ screen, color dodge; overlay, soft light, hard light; -_ difference, exclusion; hue, sat, color, luminosity -_ director: Copy, Transparent, Reverse, Ghost, Not copy, -_ Not transparent, Not reverse, Not ghost, Matte, Mask; -_ (below seems more useful: -_ Blend, Add pin, Add, Subtract pin, Background transparent, -_ Lightest, Subtract, Darkest, Lighten, Darken -_ flash: -_ DIFFERENCE: C = abs(A-B); -_ MULTIPLY: C = (A * B ) / 255 -_ SCREEN: C= 255 - ( (255-A) * (255-B) / 255 ) -_ OVERLAY: C = B < 128 ? (2*A*B/255) : 255-2*(255-A)*(255-B)/255 -_ HARD_LIGHT: C = A < 128 ? (2*A*B/255) : 255-2*(255-A)*(255-B)/255 -_ SOFT_LIGHT: C = B < 128 ? 2*((A>>1)+64)*B/255 : 255-(2*(255-((A>>1)+64))*(255-B)/255) _ figure out why tiff images won't open with after effects _ http://dev.processing.org/bugs/show_bug.cgi?id=153 _ open with photoshop, resave, see which tags change @@ -531,6 +531,15 @@ _ perhaps something gets corrected? _ loadImage() using spaces in the name _ if loadImage() with spaces when online(), throw an error +_ don't grab pixels of java2d images unless asked +_ this is the difference between a lot of loadPixels() and not +_ so important to have it in before beta if that's the change +_ also when drawing an image, sense whether drawn rotated +_ specifically, if drawn rotated 90 in either direction, or 180 +_ if just rotate/translate, then can use SCREEN_SPACE for fonts +_ alpha not set on saveFrame, so can't be used in photoshop as a layer +_ http://processing.org/discourse/yabb/YaBB.cgi?board=general;action=display;num=1078441623 + CORE / PSound