From e90ebc461acd1336c9a09dbfcae7b8e72a9be7ec Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Sat, 18 Jan 2014 01:40:23 +0530 Subject: [PATCH 01/44] Added ProgressBarGUI class, and modified saveAs(). ProgressBar now shows properly for all files within the main sketch folder, but not within sub-folders. To Do: 1. Make ProgressBar take into account files that have already been copied within sub-folders in the sketch, and not onlyafter the entire folder has been copied. 2. Rename "Saving X As Y..." with "Saving As " 3. The progress made for very large files is shown only after the ENTIRE file has been copied. Modify processing.app.Base as well so that for large files, the ProgressBar is updated in (almost) real time 4. Make "Done Saving" appear in Message Area only after the entire Save As operation is complete --- app/src/processing/app/Sketch.java | 165 +++++++++++++++++++++++++++-- 1 file changed, 156 insertions(+), 9 deletions(-) diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 669452b8c..b3af66a54 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -30,6 +30,9 @@ import java.io.*; import javax.swing.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + /** * Stores information about files in the current sketch. @@ -759,7 +762,7 @@ public class Sketch { if (!sanitaryName.equals(newName) && newFolder.exists()) { Base.showMessage("Cannot Save", "A sketch with the cleaned name\n" + - "“" + sanitaryName + "” already exists."); + "“" + sanitaryName + "â€� already exists."); return false; } newName = sanitaryName; @@ -847,20 +850,26 @@ public class Sketch { return true; } }); - // now copy over the items that make sense - for (File copyable : copyItems) { - if (copyable.isDirectory()) { - Base.copyDir(copyable, new File(newFolder, copyable.getName())); - } else { - Base.copyFile(copyable, new File(newFolder, copyable.getName())); - } - } + + final File newFolder2 = newFolder; + final File[] copyItems2 = copyItems; + + // create a new event dispatch thread + javax.swing.SwingUtilities.invokeLater(new Runnable() { + public void run() { + ProgressBarGUI p = new ProgressBarGUI(copyItems2,newFolder2); + } + }); + + // save the other tabs to their new location for (int i = 1; i < codeCount; i++) { File newFile = new File(newFolder, code[i].getFileName()); code[i].saveAs(newFile); } + + // While the old path to the main .pde is still set, remove the entry from // the Recent menu so that it's not sticking around after the rename. @@ -886,6 +895,143 @@ public class Sketch { } + + private class ProgressBarGUI extends JFrame implements + PropertyChangeListener { + + private static final long serialVersionUID = 1L; + private JProgressBar progressBar; + private JLabel saveAsLabel; + private Task t; + private File[] copyItems; + private File newFolder; + + // create a new background thread + private class Task extends SwingWorker { + + @Override + protected Void doInBackground() throws Exception { + // a large part of the file copying happens in this background + // thread + + long totalSize = 0; + for (File copyable : copyItems) { + totalSize += getFileLength(copyable); + } + + int i = 0; + + long progress = 0; + setProgress(0); + for (File copyable : ProgressBarGUI.this.copyItems) + // loop to copy over the items that make sense, and to set the + // current progress + { + if (copyable.isDirectory()) { + Base.copyDir(copyable, + new File(ProgressBarGUI.this.newFolder, + copyable.getName())); + } else { + Base.copyFile(copyable, + new File(ProgressBarGUI.this.newFolder, + copyable.getName())); + } + progress += getFileLength(copyable); + setProgress((int) Math.min( + Math.ceil((double)progress * 100.0 / (double)totalSize), 100)); + + System.out.println(""+(int) Math.min( + Math.ceil((double)progress * 100.0 / (double)totalSize), 100)); + + } + + return null; + } + + @Override + public void done() { + // to close the progress bar automatically when done + ProgressBarGUI.this.closeProgressBar(); + } + + } + + public ProgressBarGUI(File[] c, File nf) { + // initialize a copyItems and newFolder, which are used for file + // copying in the background thread + copyItems = c; + newFolder = nf; + + // the UI of the progres bar follows + setDefaultCloseOperation(DISPOSE_ON_CLOSE); + setBounds(200, 200, 400, 140); + setResizable(false); + setTitle("Saving As..."); + JPanel panel = new JPanel(null); + add(panel); + setContentPane(panel); + saveAsLabel = new JLabel("Saving X as Y..."); + saveAsLabel.setBounds(40, 20, 150, 20); + + progressBar = new JProgressBar(0, 100); + progressBar.setValue(0); + progressBar.setBounds(40, 50, 300, 30); + progressBar.setStringPainted(true); + + panel.add(progressBar); + panel.add(saveAsLabel); + Toolkit.setIcon(this); + this.setVisible(true); + + // create an instance of Task and run execute() on this instance to + // start background thread + t = new Task(); + t.addPropertyChangeListener(this); + t.execute(); + } + + private long getFileLength(File f)// function to return the length of + // the file, or + // ENTIRE directory, including the + // component files + // and sub-folders if passed + { + long fol_len = 0; + if (f.isDirectory()) { + String files[] = f.list(); + for (int i = 0; i < files.length; i++) { + File temp = new File(f, files[i]); + if (temp.isDirectory()) { + fol_len += getFileLength(temp); + } else { + fol_len += (long) (temp.length()); + } + } + } else { + return (long) (f.length()); + } + return fol_len; + } + + public void propertyChange(PropertyChangeEvent evt) + // detects a change in the property of the background task, i.e., is + // called when the size of files already copied changes + { + if ("progress" == evt.getPropertyName()) { + int progress = (Integer) evt.getNewValue(); + progressBar.setValue(progress); + } + } + + private void closeProgressBar() + // closes progress bar + { + this.dispose(); + } + + } + + /** * Update internal state for new sketch name or folder location. */ @@ -912,6 +1058,7 @@ public class Sketch { editor.updateTitle(); editor.base.rebuildSketchbookMenus(); // editor.header.rebuild(); + } From 645068ddf63948fe870e251c080f8705a37961db Mon Sep 17 00:00:00 2001 From: AmnonOwed Date: Wed, 22 Jan 2014 21:14:11 +0100 Subject: [PATCH 02/44] Ensure RGB pixels are fully opaque --- core/src/processing/core/PImage.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/processing/core/PImage.java b/core/src/processing/core/PImage.java index 430d67228..ed17683d7 100644 --- a/core/src/processing/core/PImage.java +++ b/core/src/processing/core/PImage.java @@ -283,10 +283,14 @@ public class PImage implements PConstants, Cloneable { width = bi.getWidth(); height = bi.getHeight(); pixels = new int[width * height]; - WritableRaster raster = bi.getRaster(); - raster.getDataElements(0, 0, width, height, pixels); - if (bi.getType() == BufferedImage.TYPE_INT_ARGB) { + pixels = ((DataBufferInt) bi.getRaster().getDataBuffer()).getData(); + int type = bi.getType(); + if (type == BufferedImage.TYPE_INT_ARGB) { format = ARGB; + } else if (type == BufferedImage.TYPE_INT_RGB) { + for (int i = 0; i < pixels.length; i++) { + pixels[i] = (255 << 24) | pixels[i]; + } } } else { // go the old school java 1.0 route From e6fb7e31b7afb52f81151db51a7dcfd8359374c4 Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Sun, 2 Feb 2014 01:34:26 +0530 Subject: [PATCH 03/44] Improved significantly on ProgressBar Improvements 1,2 and 4 as mentioned in the last commit have been implemented, i.e., ProgressBar now takes into account files within sub-folders, the Label now reads properly in the "Save As progress" dialog box, and "Done Saving" message appears in the message area only after the entire process is completed. To do: 1. Ensure progress bar reflects large files accurately 2. Add comments, minor clean-up --- app/src/processing/app/Base.java | 15 ++++++----- app/src/processing/app/Editor.java | 5 +++- app/src/processing/app/Sketch.java | 43 +++++++++++++++++------------- 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 50230531b..a9332c94e 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -1592,7 +1592,7 @@ public class Base { } - // Because the Oracle JDK is 64-bit only, we lose this ability, feature, + // Because the Oracle JDK is 64-bit only, we lose this ability, feature, // edge case, headache. // /** // * Return whether sketches will run as 32- or 64-bits. On Linux and Windows, @@ -1605,10 +1605,10 @@ public class Base { // } // return nativeBits; // } - - /** + + /** * Return whether sketches will run as 32- or 64-bits based - * on the JVM that's in use. + * on the JVM that's in use. */ static public int getNativeBits() { return nativeBits; @@ -2649,7 +2649,7 @@ public class Base { * files and potentially troublesome .svn folders. */ static public void copyDir(File sourceDir, - File targetDir) throws IOException { + File targetDir,Sketch.ProgressBarGUI.Task progBar,double progress,double totalSize) throws IOException { if (sourceDir.equals(targetDir)) { final String urDum = "source and target directories are identical"; throw new IllegalArgumentException(urDum); @@ -2664,10 +2664,13 @@ public class Base { File target = new File(targetDir, files[i]); if (source.isDirectory()) { //target.mkdirs(); - copyDir(source, target); + copyDir(source, target, progBar, progress, totalSize); target.setLastModified(source.lastModified()); } else { copyFile(source, target); + progress += source.length(); + progBar.setProgressBarStatus((int) Math.min( + Math.ceil((double)progress * 100.0 / (double)totalSize), 100)); } } } diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 3463555e0..240edaf51 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -2361,7 +2361,10 @@ public abstract class Editor extends JFrame implements RunnerListener { statusNotice("Saving..."); try { if (sketch.saveAs()) { - statusNotice("Done Saving."); + // statusNotice("Done Saving."); + // status is now printed from Sketch so that "Done Saving." + // is only printed after Save As when progress bar is shown. + // Disabling this for 0125, instead rebuild the menu inside // the Save As method of the Sketch object, since that's the // only one who knows whether something was renamed. diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index b3af66a54..9cbadfd41 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -716,6 +716,8 @@ public class Sketch { protected boolean saveAs() throws IOException { String newParentDir = null; String newName = null; + + final String oldName2 = folder.getName(); // TODO rewrite this to use shared version from PApplet final String PROMPT = "Save sketch folder as..."; if (Preferences.getBoolean("chooser.files.native")) { @@ -762,7 +764,7 @@ public class Sketch { if (!sanitaryName.equals(newName) && newFolder.exists()) { Base.showMessage("Cannot Save", "A sketch with the cleaned name\n" + - "“" + sanitaryName + "â€� already exists."); + "“" + sanitaryName + "” already exists."); return false; } newName = sanitaryName; @@ -854,11 +856,12 @@ public class Sketch { final File newFolder2 = newFolder; final File[] copyItems2 = copyItems; + final String newName2 = newName; // create a new event dispatch thread javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { - ProgressBarGUI p = new ProgressBarGUI(copyItems2,newFolder2); + ProgressBarGUI p = new ProgressBarGUI(copyItems2,newFolder2,oldName2,newName2); } }); @@ -868,8 +871,6 @@ public class Sketch { File newFile = new File(newFolder, code[i].getFileName()); code[i].saveAs(newFile); } - - // While the old path to the main .pde is still set, remove the entry from // the Recent menu so that it's not sticking around after the rename. @@ -896,7 +897,7 @@ public class Sketch { - private class ProgressBarGUI extends JFrame implements + public class ProgressBarGUI extends JFrame implements PropertyChangeListener { private static final long serialVersionUID = 1L; @@ -907,7 +908,7 @@ public class Sketch { private File newFolder; // create a new background thread - private class Task extends SwingWorker { + public class Task extends SwingWorker { @Override protected Void doInBackground() throws Exception { @@ -930,33 +931,38 @@ public class Sketch { if (copyable.isDirectory()) { Base.copyDir(copyable, new File(ProgressBarGUI.this.newFolder, - copyable.getName())); + copyable.getName()),this,progress,totalSize); + progress += getFileLength(copyable); } else { Base.copyFile(copyable, new File(ProgressBarGUI.this.newFolder, copyable.getName())); + progress += getFileLength(copyable); + setProgress((int) Math.min( + Math.ceil((double)progress * 100.0 / (double)totalSize), 100)); } - progress += getFileLength(copyable); - setProgress((int) Math.min( - Math.ceil((double)progress * 100.0 / (double)totalSize), 100)); - - System.out.println(""+(int) Math.min( - Math.ceil((double)progress * 100.0 / (double)totalSize), 100)); - } return null; } + + public void setProgressBarStatus(int status) + { + setProgress(status); + } @Override public void done() { - // to close the progress bar automatically when done + // to close the progress bar automatically when done, and to + // print that Saving is done in Message Area + + editor.statusNotice("Done Saving."); ProgressBarGUI.this.closeProgressBar(); } } - public ProgressBarGUI(File[] c, File nf) { + public ProgressBarGUI(File[] c, File nf, String oldName, String newName) { // initialize a copyItems and newFolder, which are used for file // copying in the background thread copyItems = c; @@ -970,8 +976,8 @@ public class Sketch { JPanel panel = new JPanel(null); add(panel); setContentPane(panel); - saveAsLabel = new JLabel("Saving X as Y..."); - saveAsLabel.setBounds(40, 20, 150, 20); + saveAsLabel = new JLabel("Saving "+oldName+" as "+newName+"..."); + saveAsLabel.setBounds(40, 20, 300, 20); progressBar = new JProgressBar(0, 100); progressBar.setValue(0); @@ -1058,7 +1064,6 @@ public class Sketch { editor.updateTitle(); editor.base.rebuildSketchbookMenus(); // editor.header.rebuild(); - } From 6f2b4ce9a9569e08916e140d8cd4e59fa08ce57f Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Sun, 2 Feb 2014 22:27:02 -0500 Subject: [PATCH 04/44] fixes #2341 - inconsistent bounds checks The core datastructure IntLost, FloatList, and StringList all have unsafe .get methods that do not perform bounds checking. This is in contrast to their .remove methods, which do perform bounds checking. Prior to this patch, the following would print 0: IntList il = new IntList(); println(il.get(5)); But if we tried to *remove* that element, we would get an ArrayIndexOutOfBoundException: il.remove(5); This patch causes calls to .get to throw exceptions instead of returning 0 (or null in the case of StringList) for uninitialized values. --- core/src/processing/data/FloatList.java | 3 +++ core/src/processing/data/IntList.java | 3 +++ core/src/processing/data/StringList.java | 3 +++ 3 files changed, 9 insertions(+) diff --git a/core/src/processing/data/FloatList.java b/core/src/processing/data/FloatList.java index 9921cb326..b379bf0b2 100644 --- a/core/src/processing/data/FloatList.java +++ b/core/src/processing/data/FloatList.java @@ -110,6 +110,9 @@ public class FloatList implements Iterable { * @brief Get an entry at a particular index */ public float get(int index) { + if (index >= count) { + throw new ArrayIndexOutOfBoundsException(index); + } return data[index]; } diff --git a/core/src/processing/data/IntList.java b/core/src/processing/data/IntList.java index 78775be3f..ea2d74af7 100644 --- a/core/src/processing/data/IntList.java +++ b/core/src/processing/data/IntList.java @@ -130,6 +130,9 @@ public class IntList implements Iterable { * @brief Get an entry at a particular index */ public int get(int index) { + if (index >= this.count) { + throw new ArrayIndexOutOfBoundsException(index); + } return data[index]; } diff --git a/core/src/processing/data/StringList.java b/core/src/processing/data/StringList.java index a407265a9..7811ee014 100644 --- a/core/src/processing/data/StringList.java +++ b/core/src/processing/data/StringList.java @@ -113,6 +113,9 @@ public class StringList implements Iterable { * @brief Get an entry at a particular index */ public String get(int index) { + if (index >= count) { + throw new ArrayIndexOutOfBoundsException(index); + } return data[index]; } From c1afe7fbc9ff237bd7be8376e54be063c25409ce Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Wed, 19 Feb 2014 17:47:44 +0530 Subject: [PATCH 05/44] Save As Progress Bar complete, resolving issue #70 Now works for large files within folders as well. Code is now commented as well. --- app/src/processing/app/Base.java | 90 +++++++++++++++++++++++++++--- app/src/processing/app/Sketch.java | 24 +++++--- 2 files changed, 96 insertions(+), 18 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index a9332c94e..3149ef34b 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -1592,7 +1592,7 @@ public class Base { } - // Because the Oracle JDK is 64-bit only, we lose this ability, feature, + // Because the Oracle JDK is 64-bit only, we lose this ability, feature, // edge case, headache. // /** // * Return whether sketches will run as 32- or 64-bits. On Linux and Windows, @@ -1605,10 +1605,10 @@ public class Base { // } // return nativeBits; // } - - /** + + /** * Return whether sketches will run as 32- or 64-bits based - * on the JVM that's in use. + * on the JVM that's in use. */ static public int getNativeBits() { return nativeBits; @@ -2604,6 +2604,47 @@ public class Base { } + static public void copyFile(File sourceFile, + File targetFile,Sketch.ProgressBarGUI.Task progBar, + double progress,double totalSize) throws IOException { + // Overloaded copyFile that is called whenever a Save As is being done, so that the + // ProgressBar is updated for very large files as well + BufferedInputStream from = + new BufferedInputStream(new FileInputStream(sourceFile)); + BufferedOutputStream to = + new BufferedOutputStream(new FileOutputStream(targetFile)); + byte[] buffer = new byte[16 * 1024]; + int bytesRead; + int totalRead=0; + while ((bytesRead = from.read(buffer)) != -1) { + to.write(buffer, 0, bytesRead); + totalRead += bytesRead; + if (totalRead >= 524288) //to update progress bar every 50MB + { + progress += totalRead; + progBar.setProgressBarStatus((int) Math.min( + Math.ceil((double)progress * 100.0 / (double)totalSize), 100)); + totalRead = 0; + } + } + if (sourceFile.length()>524288) { + // Update the progress bar one final time if file size is more than 50MB, + // otherwise, the update is handled either by the copyDir function, + // or directly by Sketch.ProgressBarGUI.Task.doInBackground() + progress += totalRead; + progBar.setProgressBarStatus((int) Math.min( + Math.ceil((double)progress * 100.0 / (double)totalSize), 100)); + } + from.close(); + from = null; + to.flush(); + to.close(); + to = null; + + targetFile.setLastModified(sourceFile.lastModified()); + targetFile.setExecutable(sourceFile.canExecute()); + } + /** * Grab the contents of a file as a string. */ @@ -2649,7 +2690,7 @@ public class Base { * files and potentially troublesome .svn folders. */ static public void copyDir(File sourceDir, - File targetDir,Sketch.ProgressBarGUI.Task progBar,double progress,double totalSize) throws IOException { + File targetDir) throws IOException { if (sourceDir.equals(targetDir)) { final String urDum = "source and target directories are identical"; throw new IllegalArgumentException(urDum); @@ -2664,17 +2705,48 @@ public class Base { File target = new File(targetDir, files[i]); if (source.isDirectory()) { //target.mkdirs(); - copyDir(source, target, progBar, progress, totalSize); + copyDir(source, target); target.setLastModified(source.lastModified()); } else { copyFile(source, target); - progress += source.length(); - progBar.setProgressBarStatus((int) Math.min( - Math.ceil((double)progress * 100.0 / (double)totalSize), 100)); } } } + + static public double copyDir(File sourceDir, + File targetDir,Sketch.ProgressBarGUI.Task progBar, + double progress,double totalSize) throws IOException { + // Overloaded copyDir so that the Save As progress bar gets updated when the + // files are in folders as well (like in the data folder) + if (sourceDir.equals(targetDir)) { + final String urDum = "source and target directories are identical"; + throw new IllegalArgumentException(urDum); + } + targetDir.mkdirs(); + String files[] = sourceDir.list(); + for (int i = 0; i < files.length; i++) { + // Ignore dot files (.DS_Store), dot folders (.svn) while copying + if (files[i].charAt(0) == '.') continue; + //if (files[i].equals(".") || files[i].equals("..")) continue; + File source = new File(sourceDir, files[i]); + File target = new File(targetDir, files[i]); + if (source.isDirectory()) { + //target.mkdirs(); + progress = copyDir(source, target, progBar, progress, totalSize); + progBar.setProgressBarStatus((int) Math.min( + Math.ceil((double)progress * 100.0 / (double)totalSize), 100)); + target.setLastModified(source.lastModified()); + } else { + copyFile(source, target, progBar, progress, totalSize); + // Update SaveAs progress bar + progress += source.length(); + progBar.setProgressBarStatus((int) Math.min( + Math.ceil((double)progress * 100.0 / (double)totalSize), 100)); + } + } + return progress; + } static public void copyDirNative(File sourceDir, File targetDir) throws IOException { diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 9cbadfd41..3678c9659 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -896,7 +896,8 @@ public class Sketch { } - + // Class used to handle progress bar, and run Save As in background so that + // progress bar can update without freezing public class ProgressBarGUI extends JFrame implements PropertyChangeListener { @@ -924,10 +925,10 @@ public class Sketch { long progress = 0; setProgress(0); - for (File copyable : ProgressBarGUI.this.copyItems) + for (File copyable : ProgressBarGUI.this.copyItems) { // loop to copy over the items that make sense, and to set the // current progress - { + if (copyable.isDirectory()) { Base.copyDir(copyable, new File(ProgressBarGUI.this.newFolder, @@ -936,18 +937,23 @@ public class Sketch { } else { Base.copyFile(copyable, new File(ProgressBarGUI.this.newFolder, - copyable.getName())); - progress += getFileLength(copyable); - setProgress((int) Math.min( + copyable.getName()), this,progress,totalSize); + if (getFileLength(copyable)<524288) { + // If the file length > 50MB, the Base.copyFile() function has + // been redesigned to change progress every 50MB so that + // the progress bar doesn't stagnate during that time + progress += getFileLength(copyable); + setProgress((int) Math.min( Math.ceil((double)progress * 100.0 / (double)totalSize), 100)); + } } } return null; } - public void setProgressBarStatus(int status) - { + public void setProgressBarStatus(int status) { + setProgress(status); } @@ -996,7 +1002,7 @@ public class Sketch { t.execute(); } - private long getFileLength(File f)// function to return the length of + public long getFileLength(File f)// function to return the length of // the file, or // ENTIRE directory, including the // component files From 0ee09ee2aaaf281d53fd0182b549188d2fb36525 Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Sat, 15 Mar 2014 23:59:02 +0530 Subject: [PATCH 06/44] Progress Bar now displays when Adding Files --- app/src/processing/app/Base.java | 55 ++++++++++-- app/src/processing/app/Sketch.java | 137 ++++++++++++++++++++++++----- 2 files changed, 163 insertions(+), 29 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 3149ef34b..762325af6 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -2605,7 +2605,7 @@ public class Base { static public void copyFile(File sourceFile, - File targetFile,Sketch.ProgressBarGUI.Task progBar, + File targetFile,Sketch.ProgressBarGUI.TaskSaveAs progBar, double progress,double totalSize) throws IOException { // Overloaded copyFile that is called whenever a Save As is being done, so that the // ProgressBar is updated for very large files as well @@ -2619,7 +2619,7 @@ public class Base { while ((bytesRead = from.read(buffer)) != -1) { to.write(buffer, 0, bytesRead); totalRead += bytesRead; - if (totalRead >= 524288) //to update progress bar every 50MB + if (totalRead >= 524288) //to update progress bar every 0.5MB { progress += totalRead; progBar.setProgressBarStatus((int) Math.min( @@ -2628,9 +2628,9 @@ public class Base { } } if (sourceFile.length()>524288) { - // Update the progress bar one final time if file size is more than 50MB, + // Update the progress bar one final time if file size is more than 0.5MB, // otherwise, the update is handled either by the copyDir function, - // or directly by Sketch.ProgressBarGUI.Task.doInBackground() + // or directly by Sketch.ProgressBarGUI.TaskSaveAs.doInBackground() progress += totalRead; progBar.setProgressBarStatus((int) Math.min( Math.ceil((double)progress * 100.0 / (double)totalSize), 100)); @@ -2644,6 +2644,51 @@ public class Base { targetFile.setLastModified(sourceFile.lastModified()); targetFile.setExecutable(sourceFile.canExecute()); } + + static public void copyFile(File sourceFile, File targetFile, + Sketch.ProgressBarGUI.TaskAddFile progBar) throws IOException { + // Overloaded copyFile that is called whenever a addFile is being done, + // so that the + // ProgressBar is updated + double totalSize = sourceFile.length(); + int progress = 0; + BufferedInputStream from = new BufferedInputStream(new FileInputStream( + sourceFile)); + BufferedOutputStream to = new BufferedOutputStream( + new FileOutputStream(targetFile)); + byte[] buffer = new byte[16 * 1024]; + int bytesRead; + int totalRead = 0; + while ((bytesRead = from.read(buffer)) != -1) { + to.write(buffer, 0, bytesRead); + totalRead += bytesRead; + if (totalRead >= 1024) // to update progress bar every 1kB + { + progress += totalRead; + progBar.setProgressBarStatus((int) Math.min( + Math.ceil((double) progress * 100.0 + / (double) totalSize), 100)); + totalRead = 0; + } + } + if (sourceFile.length() > 1024) { + // Update the progress bar one final time if file size is more than + // 1kB, + // otherwise, the update is handled directly by + // Sketch.ProgressBarGUI.TaskAddFile.doInBackground() + progress += totalRead; + progBar.setProgressBarStatus((int) Math.min( + Math.ceil((double) progress * 100.0 / (double) totalSize), + 100)); + } + from.close(); + from = null; + to.flush(); + to.close(); + to = null; + targetFile.setLastModified(sourceFile.lastModified()); + targetFile.setExecutable(sourceFile.canExecute()); +} /** * Grab the contents of a file as a string. @@ -2715,7 +2760,7 @@ public class Base { static public double copyDir(File sourceDir, - File targetDir,Sketch.ProgressBarGUI.Task progBar, + File targetDir,Sketch.ProgressBarGUI.TaskSaveAs progBar, double progress,double totalSize) throws IOException { // Overloaded copyDir so that the Save As progress bar gets updated when the // files are in folders as well (like in the data folder) diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 3678c9659..8e03224ab 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -858,7 +858,8 @@ public class Sketch { final File[] copyItems2 = copyItems; final String newName2 = newName; - // create a new event dispatch thread + // Create a new event dispatch thread- to display ProgressBar + // while Saving As javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { ProgressBarGUI p = new ProgressBarGUI(copyItems2,newFolder2,oldName2,newName2); @@ -896,20 +897,23 @@ public class Sketch { } - // Class used to handle progress bar, and run Save As in background so that - // progress bar can update without freezing +// Class used to handle progress bar, and run Save As or Add File in +// background so that +// progress bar can update without freezing public class ProgressBarGUI extends JFrame implements PropertyChangeListener { private static final long serialVersionUID = 1L; private JProgressBar progressBar; private JLabel saveAsLabel; - private Task t; + private TaskSaveAs t; + private TaskAddFile t2; private File[] copyItems; private File newFolder; - - // create a new background thread - public class Task extends SwingWorker { + private File addFile, sourceFile; + + // create a new background thread to save as + public class TaskSaveAs extends SwingWorker { @Override protected Void doInBackground() throws Exception { @@ -939,8 +943,8 @@ public class Sketch { new File(ProgressBarGUI.this.newFolder, copyable.getName()), this,progress,totalSize); if (getFileLength(copyable)<524288) { - // If the file length > 50MB, the Base.copyFile() function has - // been redesigned to change progress every 50MB so that + // If the file length > 0.5MB, the Base.copyFile() function has + // been redesigned to change progress every 0.5MB so that // the progress bar doesn't stagnate during that time progress += getFileLength(copyable); setProgress((int) Math.min( @@ -968,14 +972,59 @@ public class Sketch { } + // create a new background thread to add a file + public class TaskAddFile extends SwingWorker { + + @Override + protected Void doInBackground() throws Exception { + // a large part of the file copying happens in this background + // thread + + int i = 0; + long progress = 0; + setProgress(0); + + Base.copyFile(sourceFile, addFile, this); + + if (addFile.length()<1024) { + // If the file length > 1kB, the Base.copyFile() function has + // been redesigned to change progress every 1kB so that + // the progress bar doesn't stagnate during that time + + // If file <1 kB, just fill up Progress Bar to 100% + // directly, since time to copy is now negligable (when + // perceived by a human, anyway) + setProgress(100); + } + + return null; + } + + public void setProgressBarStatus(int status) { + setProgress(status); + } + + @Override + public void done() { + // to close the progress bar automatically when done, and to + // print that adding file is done in Message Area + + editor.statusNotice("One file added to the sketch."); + ProgressBarGUI.this.closeProgressBar(); + } + + } + + + //Use for Save As public ProgressBarGUI(File[] c, File nf, String oldName, String newName) { // initialize a copyItems and newFolder, which are used for file // copying in the background thread copyItems = c; newFolder = nf; - // the UI of the progres bar follows - setDefaultCloseOperation(DISPOSE_ON_CLOSE); + // the UI of the progress bar follows + setDefaultCloseOperation(HIDE_ON_CLOSE); setBounds(200, 200, 400, 140); setResizable(false); setTitle("Saving As..."); @@ -995,13 +1044,50 @@ public class Sketch { Toolkit.setIcon(this); this.setVisible(true); - // create an instance of Task and run execute() on this instance to + // create an instance of TaskSaveAs and run execute() on this + // instance to // start background thread - t = new Task(); + t = new TaskSaveAs(); t.addPropertyChangeListener(this); t.execute(); } + //Use for Add File + public ProgressBarGUI(File sf, File add) { + + addFile = add; + sourceFile = sf; + + // the UI of the progress bar follows + setDefaultCloseOperation(HIDE_ON_CLOSE); + setBounds(200, 200, 400, 140); + setResizable(false); + setTitle("Adding File..."); + JPanel panel = new JPanel(null); + add(panel); + setContentPane(panel); + saveAsLabel = new JLabel("Adding "+addFile.getName()); + saveAsLabel.setBounds(40, 20, 300, 20); + + progressBar = new JProgressBar(0, 100); + progressBar.setValue(0); + progressBar.setBounds(40, 50, 300, 30); + progressBar.setStringPainted(true); + + panel.add(progressBar); + panel.add(saveAsLabel); + Toolkit.setIcon(this); + this.setVisible(true); + + // create an instance of TaskAddFile and run execute() on this + // instance to + // start background thread + t2 = new TaskAddFile(); + t2.addPropertyChangeListener(this); + t2.execute(); + } + + public long getFileLength(File f)// function to return the length of // the file, or // ENTIRE directory, including the @@ -1110,7 +1196,8 @@ public class Sketch { boolean result = addFile(sourceFile); if (result) { - editor.statusNotice("One file added to the sketch."); +// editor.statusNotice("One file added to the sketch."); + //Done from within TaskAddFile inner class when copying is completed } } @@ -1203,16 +1290,18 @@ public class Sketch { // in case the user is "adding" the code in an attempt // to update the sketch's tabs - if (!sourceFile.equals(destFile)) { - try { - Base.copyFile(sourceFile, destFile); - - } catch (IOException e) { - Base.showWarning("Error adding file", - "Could not add '" + filename + "' to the sketch.", e); - return false; - } - } + if (!sourceFile.equals(destFile)) { + final File sourceFile2 = sourceFile; + final File destFile2 = destFile; + // Create a new event dispatch thread- to display ProgressBar + // while Saving As + javax.swing.SwingUtilities.invokeLater(new Runnable() { + public void run() { + ProgressBarGUI p = new ProgressBarGUI(sourceFile2, + destFile2); + } + }); + } if (codeExtension != null) { SketchCode newCode = new SketchCode(destFile, codeExtension); From 79853f32d923a96d94569cbe95cf91601a847f4e Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Wed, 2 Apr 2014 00:37:46 +0530 Subject: [PATCH 07/44] Shifted ProgresSBarGUI inner class to new class Sketch.ProgressBarGUI is now ProgressFrame Also performed some minor formatting --- app/src/processing/app/Base.java | 24 +-- app/src/processing/app/ProgressFrame.java | 248 ++++++++++++++++++++++ app/src/processing/app/Sketch.java | 245 +-------------------- 3 files changed, 265 insertions(+), 252 deletions(-) create mode 100644 app/src/processing/app/ProgressFrame.java diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 762325af6..d041fd7a3 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -2605,7 +2605,7 @@ public class Base { static public void copyFile(File sourceFile, - File targetFile,Sketch.ProgressBarGUI.TaskSaveAs progBar, + File targetFile,ProgressFrame.TaskSaveAs progBar, double progress,double totalSize) throws IOException { // Overloaded copyFile that is called whenever a Save As is being done, so that the // ProgressBar is updated for very large files as well @@ -2623,17 +2623,17 @@ public class Base { { progress += totalRead; progBar.setProgressBarStatus((int) Math.min( - Math.ceil((double)progress * 100.0 / (double)totalSize), 100)); + Math.ceil(progress * 100.0 / totalSize), 100)); totalRead = 0; } } if (sourceFile.length()>524288) { // Update the progress bar one final time if file size is more than 0.5MB, // otherwise, the update is handled either by the copyDir function, - // or directly by Sketch.ProgressBarGUI.TaskSaveAs.doInBackground() + // or directly by ProgressFrame.TaskSaveAs.doInBackground() progress += totalRead; progBar.setProgressBarStatus((int) Math.min( - Math.ceil((double)progress * 100.0 / (double)totalSize), 100)); + Math.ceil(progress * 100.0 / totalSize), 100)); } from.close(); from = null; @@ -2646,7 +2646,7 @@ public class Base { } static public void copyFile(File sourceFile, File targetFile, - Sketch.ProgressBarGUI.TaskAddFile progBar) throws IOException { + ProgressFrame.TaskAddFile progBar) throws IOException { // Overloaded copyFile that is called whenever a addFile is being done, // so that the // ProgressBar is updated @@ -2666,8 +2666,8 @@ public class Base { { progress += totalRead; progBar.setProgressBarStatus((int) Math.min( - Math.ceil((double) progress * 100.0 - / (double) totalSize), 100)); + Math.ceil(progress * 100.0 + / totalSize), 100)); totalRead = 0; } } @@ -2675,10 +2675,10 @@ public class Base { // Update the progress bar one final time if file size is more than // 1kB, // otherwise, the update is handled directly by - // Sketch.ProgressBarGUI.TaskAddFile.doInBackground() + // ProgressFrame.TaskAddFile.doInBackground() progress += totalRead; progBar.setProgressBarStatus((int) Math.min( - Math.ceil((double) progress * 100.0 / (double) totalSize), + Math.ceil(progress * 100.0 / totalSize), 100)); } from.close(); @@ -2760,7 +2760,7 @@ public class Base { static public double copyDir(File sourceDir, - File targetDir,Sketch.ProgressBarGUI.TaskSaveAs progBar, + File targetDir,ProgressFrame.TaskSaveAs progBar, double progress,double totalSize) throws IOException { // Overloaded copyDir so that the Save As progress bar gets updated when the // files are in folders as well (like in the data folder) @@ -2780,14 +2780,14 @@ public class Base { //target.mkdirs(); progress = copyDir(source, target, progBar, progress, totalSize); progBar.setProgressBarStatus((int) Math.min( - Math.ceil((double)progress * 100.0 / (double)totalSize), 100)); + Math.ceil(progress * 100.0 / totalSize), 100)); target.setLastModified(source.lastModified()); } else { copyFile(source, target, progBar, progress, totalSize); // Update SaveAs progress bar progress += source.length(); progBar.setProgressBarStatus((int) Math.min( - Math.ceil((double)progress * 100.0 / (double)totalSize), 100)); + Math.ceil(progress * 100.0 / totalSize), 100)); } } return progress; diff --git a/app/src/processing/app/ProgressFrame.java b/app/src/processing/app/ProgressFrame.java new file mode 100644 index 000000000..9aa5551a2 --- /dev/null +++ b/app/src/processing/app/ProgressFrame.java @@ -0,0 +1,248 @@ +package processing.app; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.File; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.SwingWorker; + +//Class used to handle progress bar, and run Save As or Add File in +//background so that +//progress bar can update without freezing +public class ProgressFrame extends JFrame implements PropertyChangeListener { + + private static final long serialVersionUID = 1L; + + private JProgressBar progressBar; + + private JLabel saveAsLabel; + + private TaskSaveAs t; + + private TaskAddFile t2; + + private File[] copyItems; + + private File newFolder; + + private File addFile, sourceFile; + + private Editor editor; + + // create a new background thread to save as + public class TaskSaveAs extends SwingWorker { + + @Override + protected Void doInBackground() throws Exception { + // a large part of the file copying happens in this background + // thread + + long totalSize = 0; + for (File copyable : copyItems) { + totalSize += getFileLength(copyable); + } + + long progress = 0; + setProgress(0); + for (File copyable : ProgressFrame.this.copyItems) { + // loop to copy over the items that make sense, and to set the + // current progress + + if (copyable.isDirectory()) { + Base.copyDir(copyable, new File(ProgressFrame.this.newFolder, + copyable.getName()), this, progress, + totalSize); + progress += getFileLength(copyable); + } else { + Base.copyFile(copyable, new File(ProgressFrame.this.newFolder, + copyable.getName()), this, progress, + totalSize); + if (getFileLength(copyable) < 524288) { + // If the file length > 0.5MB, the Base.copyFile() function has + // been redesigned to change progress every 0.5MB so that + // the progress bar doesn't stagnate during that time + progress += getFileLength(copyable); + setProgress((int) Math.min(Math.ceil(progress * 100.0 / totalSize), + 100)); + } + } + } + + return null; + } + + public void setProgressBarStatus(int status) { + + setProgress(status); + } + + @Override + public void done() { + // to close the progress bar automatically when done, and to + // print that Saving is done in Message Area + + editor.statusNotice("Done Saving."); + ProgressFrame.this.closeProgressBar(); + } + + } + + // create a new background thread to add a file + public class TaskAddFile extends SwingWorker { + + @Override + protected Void doInBackground() throws Exception { + // a large part of the file copying happens in this background + // thread + + setProgress(0); + + Base.copyFile(sourceFile, addFile, this); + + if (addFile.length() < 1024) { + // If the file length > 1kB, the Base.copyFile() function has + // been redesigned to change progress every 1kB so that + // the progress bar doesn't stagnate during that time + + // If file <1 kB, just fill up Progress Bar to 100% + // directly, since time to copy is now negligable (when + // perceived by a human, anyway) + setProgress(100); + } + + return null; + } + + public void setProgressBarStatus(int status) { + setProgress(status); + } + + @Override + public void done() { + // to close the progress bar automatically when done, and to + // print that adding file is done in Message Area + + editor.statusNotice("One file added to the sketch."); + ProgressFrame.this.closeProgressBar(); + } + + } + + //Use for Save As + public ProgressFrame(File[] c, File nf, String oldName, String newName, + Editor editor) { + // initialize a copyItems and newFolder, which are used for file + // copying in the background thread + copyItems = c; + newFolder = nf; + this.editor = editor; + + // the UI of the progress bar follows + setDefaultCloseOperation(HIDE_ON_CLOSE); + setBounds(200, 200, 400, 140); + setResizable(false); + setTitle("Saving As..."); + JPanel panel = new JPanel(null); + add(panel); + setContentPane(panel); + saveAsLabel = new JLabel("Saving " + oldName + " as " + newName + "..."); + saveAsLabel.setBounds(40, 20, 300, 20); + + progressBar = new JProgressBar(0, 100); + progressBar.setValue(0); + progressBar.setBounds(40, 50, 300, 30); + progressBar.setStringPainted(true); + + panel.add(progressBar); + panel.add(saveAsLabel); + Toolkit.setIcon(this); + this.setVisible(true); + + // create an instance of TaskSaveAs and run execute() on this + // instance to + // start background thread + t = new TaskSaveAs(); + t.addPropertyChangeListener(this); + t.execute(); + } + + //Use for Add File + public ProgressFrame(File sf, File add, Editor editor) { + + addFile = add; + sourceFile = sf; + this.editor = editor; + + // the UI of the progress bar follows + setDefaultCloseOperation(HIDE_ON_CLOSE); + setBounds(200, 200, 400, 140); + setResizable(false); + setTitle("Adding File..."); + JPanel panel = new JPanel(null); + add(panel); + setContentPane(panel); + saveAsLabel = new JLabel("Adding " + addFile.getName()); + saveAsLabel.setBounds(40, 20, 300, 20); + + progressBar = new JProgressBar(0, 100); + progressBar.setValue(0); + progressBar.setBounds(40, 50, 300, 30); + progressBar.setStringPainted(true); + + panel.add(progressBar); + panel.add(saveAsLabel); + Toolkit.setIcon(this); + this.setVisible(true); + + // create an instance of TaskAddFile and run execute() on this + // instance to + // start background thread + t2 = new TaskAddFile(); + t2.addPropertyChangeListener(this); + t2.execute(); + } + + public long getFileLength(File f)// function to return the length of + // the file, or + // ENTIRE directory, including the + // component files + // and sub-folders if passed + { + long fol_len = 0; + if (f.isDirectory()) { + String files[] = f.list(); + for (int i = 0; i < files.length; i++) { + File temp = new File(f, files[i]); + if (temp.isDirectory()) { + fol_len += getFileLength(temp); + } else { + fol_len += (temp.length()); + } + } + } else { + return (f.length()); + } + return fol_len; + } + + public void propertyChange(PropertyChangeEvent evt) + // detects a change in the property of the background task, i.e., is + // called when the size of files already copied changes + { + if ("progress" == evt.getPropertyName()) { + int progress = (Integer) evt.getNewValue(); + progressBar.setValue(progress); + } + } + + private void closeProgressBar() + // closes progress bar + { + this.dispose(); + } + +} diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 8e03224ab..58538a455 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -30,9 +30,6 @@ import java.io.*; import javax.swing.*; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - /** * Stores information about files in the current sketch. @@ -861,9 +858,9 @@ public class Sketch { // Create a new event dispatch thread- to display ProgressBar // while Saving As javax.swing.SwingUtilities.invokeLater(new Runnable() { - public void run() { - ProgressBarGUI p = new ProgressBarGUI(copyItems2,newFolder2,oldName2,newName2); - } + public void run() { + new ProgressFrame(copyItems2, newFolder2, oldName2, newName2, editor); + } }); @@ -897,238 +894,6 @@ public class Sketch { } -// Class used to handle progress bar, and run Save As or Add File in -// background so that -// progress bar can update without freezing - public class ProgressBarGUI extends JFrame implements - PropertyChangeListener { - - private static final long serialVersionUID = 1L; - private JProgressBar progressBar; - private JLabel saveAsLabel; - private TaskSaveAs t; - private TaskAddFile t2; - private File[] copyItems; - private File newFolder; - private File addFile, sourceFile; - - // create a new background thread to save as - public class TaskSaveAs extends SwingWorker { - - @Override - protected Void doInBackground() throws Exception { - // a large part of the file copying happens in this background - // thread - - long totalSize = 0; - for (File copyable : copyItems) { - totalSize += getFileLength(copyable); - } - - int i = 0; - - long progress = 0; - setProgress(0); - for (File copyable : ProgressBarGUI.this.copyItems) { - // loop to copy over the items that make sense, and to set the - // current progress - - if (copyable.isDirectory()) { - Base.copyDir(copyable, - new File(ProgressBarGUI.this.newFolder, - copyable.getName()),this,progress,totalSize); - progress += getFileLength(copyable); - } else { - Base.copyFile(copyable, - new File(ProgressBarGUI.this.newFolder, - copyable.getName()), this,progress,totalSize); - if (getFileLength(copyable)<524288) { - // If the file length > 0.5MB, the Base.copyFile() function has - // been redesigned to change progress every 0.5MB so that - // the progress bar doesn't stagnate during that time - progress += getFileLength(copyable); - setProgress((int) Math.min( - Math.ceil((double)progress * 100.0 / (double)totalSize), 100)); - } - } - } - - return null; - } - - public void setProgressBarStatus(int status) { - - setProgress(status); - } - - @Override - public void done() { - // to close the progress bar automatically when done, and to - // print that Saving is done in Message Area - - editor.statusNotice("Done Saving."); - ProgressBarGUI.this.closeProgressBar(); - } - - } - - // create a new background thread to add a file - public class TaskAddFile extends SwingWorker { - - @Override - protected Void doInBackground() throws Exception { - // a large part of the file copying happens in this background - // thread - - int i = 0; - long progress = 0; - setProgress(0); - - Base.copyFile(sourceFile, addFile, this); - - if (addFile.length()<1024) { - // If the file length > 1kB, the Base.copyFile() function has - // been redesigned to change progress every 1kB so that - // the progress bar doesn't stagnate during that time - - // If file <1 kB, just fill up Progress Bar to 100% - // directly, since time to copy is now negligable (when - // perceived by a human, anyway) - setProgress(100); - } - - return null; - } - - public void setProgressBarStatus(int status) { - setProgress(status); - } - - @Override - public void done() { - // to close the progress bar automatically when done, and to - // print that adding file is done in Message Area - - editor.statusNotice("One file added to the sketch."); - ProgressBarGUI.this.closeProgressBar(); - } - - } - - - //Use for Save As - public ProgressBarGUI(File[] c, File nf, String oldName, String newName) { - // initialize a copyItems and newFolder, which are used for file - // copying in the background thread - copyItems = c; - newFolder = nf; - - // the UI of the progress bar follows - setDefaultCloseOperation(HIDE_ON_CLOSE); - setBounds(200, 200, 400, 140); - setResizable(false); - setTitle("Saving As..."); - JPanel panel = new JPanel(null); - add(panel); - setContentPane(panel); - saveAsLabel = new JLabel("Saving "+oldName+" as "+newName+"..."); - saveAsLabel.setBounds(40, 20, 300, 20); - - progressBar = new JProgressBar(0, 100); - progressBar.setValue(0); - progressBar.setBounds(40, 50, 300, 30); - progressBar.setStringPainted(true); - - panel.add(progressBar); - panel.add(saveAsLabel); - Toolkit.setIcon(this); - this.setVisible(true); - - // create an instance of TaskSaveAs and run execute() on this - // instance to - // start background thread - t = new TaskSaveAs(); - t.addPropertyChangeListener(this); - t.execute(); - } - - //Use for Add File - public ProgressBarGUI(File sf, File add) { - - addFile = add; - sourceFile = sf; - - // the UI of the progress bar follows - setDefaultCloseOperation(HIDE_ON_CLOSE); - setBounds(200, 200, 400, 140); - setResizable(false); - setTitle("Adding File..."); - JPanel panel = new JPanel(null); - add(panel); - setContentPane(panel); - saveAsLabel = new JLabel("Adding "+addFile.getName()); - saveAsLabel.setBounds(40, 20, 300, 20); - - progressBar = new JProgressBar(0, 100); - progressBar.setValue(0); - progressBar.setBounds(40, 50, 300, 30); - progressBar.setStringPainted(true); - - panel.add(progressBar); - panel.add(saveAsLabel); - Toolkit.setIcon(this); - this.setVisible(true); - - // create an instance of TaskAddFile and run execute() on this - // instance to - // start background thread - t2 = new TaskAddFile(); - t2.addPropertyChangeListener(this); - t2.execute(); - } - - - public long getFileLength(File f)// function to return the length of - // the file, or - // ENTIRE directory, including the - // component files - // and sub-folders if passed - { - long fol_len = 0; - if (f.isDirectory()) { - String files[] = f.list(); - for (int i = 0; i < files.length; i++) { - File temp = new File(f, files[i]); - if (temp.isDirectory()) { - fol_len += getFileLength(temp); - } else { - fol_len += (long) (temp.length()); - } - } - } else { - return (long) (f.length()); - } - return fol_len; - } - - public void propertyChange(PropertyChangeEvent evt) - // detects a change in the property of the background task, i.e., is - // called when the size of files already copied changes - { - if ("progress" == evt.getPropertyName()) { - int progress = (Integer) evt.getNewValue(); - progressBar.setValue(progress); - } - } - - private void closeProgressBar() - // closes progress bar - { - this.dispose(); - } - - } - /** * Update internal state for new sketch name or folder location. @@ -1297,8 +1062,8 @@ public class Sketch { // while Saving As javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { - ProgressBarGUI p = new ProgressBarGUI(sourceFile2, - destFile2); + new ProgressFrame(sourceFile2, + destFile2, editor); } }); } From e7a93b9fe0ba07eaba353dd631762df3b8fb8da8 Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Wed, 2 Apr 2014 12:59:40 +0530 Subject: [PATCH 08/44] All ProgressBar code shifted to ProgressFrame clss Base is now exactly like the original. Only change in Sketch is that a new event dispatch thread has been created during Save As or Add File. Base back to original --- app/src/processing/app/Base.java | 120 ----------------- app/src/processing/app/ProgressFrame.java | 149 ++++++++++++++++++++-- app/src/processing/app/Sketch.java | 11 +- 3 files changed, 145 insertions(+), 135 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index d041fd7a3..50230531b 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -2604,92 +2604,6 @@ public class Base { } - static public void copyFile(File sourceFile, - File targetFile,ProgressFrame.TaskSaveAs progBar, - double progress,double totalSize) throws IOException { - // Overloaded copyFile that is called whenever a Save As is being done, so that the - // ProgressBar is updated for very large files as well - BufferedInputStream from = - new BufferedInputStream(new FileInputStream(sourceFile)); - BufferedOutputStream to = - new BufferedOutputStream(new FileOutputStream(targetFile)); - byte[] buffer = new byte[16 * 1024]; - int bytesRead; - int totalRead=0; - while ((bytesRead = from.read(buffer)) != -1) { - to.write(buffer, 0, bytesRead); - totalRead += bytesRead; - if (totalRead >= 524288) //to update progress bar every 0.5MB - { - progress += totalRead; - progBar.setProgressBarStatus((int) Math.min( - Math.ceil(progress * 100.0 / totalSize), 100)); - totalRead = 0; - } - } - if (sourceFile.length()>524288) { - // Update the progress bar one final time if file size is more than 0.5MB, - // otherwise, the update is handled either by the copyDir function, - // or directly by ProgressFrame.TaskSaveAs.doInBackground() - progress += totalRead; - progBar.setProgressBarStatus((int) Math.min( - Math.ceil(progress * 100.0 / totalSize), 100)); - } - from.close(); - from = null; - to.flush(); - to.close(); - to = null; - - targetFile.setLastModified(sourceFile.lastModified()); - targetFile.setExecutable(sourceFile.canExecute()); - } - - static public void copyFile(File sourceFile, File targetFile, - ProgressFrame.TaskAddFile progBar) throws IOException { - // Overloaded copyFile that is called whenever a addFile is being done, - // so that the - // ProgressBar is updated - double totalSize = sourceFile.length(); - int progress = 0; - BufferedInputStream from = new BufferedInputStream(new FileInputStream( - sourceFile)); - BufferedOutputStream to = new BufferedOutputStream( - new FileOutputStream(targetFile)); - byte[] buffer = new byte[16 * 1024]; - int bytesRead; - int totalRead = 0; - while ((bytesRead = from.read(buffer)) != -1) { - to.write(buffer, 0, bytesRead); - totalRead += bytesRead; - if (totalRead >= 1024) // to update progress bar every 1kB - { - progress += totalRead; - progBar.setProgressBarStatus((int) Math.min( - Math.ceil(progress * 100.0 - / totalSize), 100)); - totalRead = 0; - } - } - if (sourceFile.length() > 1024) { - // Update the progress bar one final time if file size is more than - // 1kB, - // otherwise, the update is handled directly by - // ProgressFrame.TaskAddFile.doInBackground() - progress += totalRead; - progBar.setProgressBarStatus((int) Math.min( - Math.ceil(progress * 100.0 / totalSize), - 100)); - } - from.close(); - from = null; - to.flush(); - to.close(); - to = null; - targetFile.setLastModified(sourceFile.lastModified()); - targetFile.setExecutable(sourceFile.canExecute()); -} - /** * Grab the contents of a file as a string. */ @@ -2758,40 +2672,6 @@ public class Base { } } - - static public double copyDir(File sourceDir, - File targetDir,ProgressFrame.TaskSaveAs progBar, - double progress,double totalSize) throws IOException { - // Overloaded copyDir so that the Save As progress bar gets updated when the - // files are in folders as well (like in the data folder) - if (sourceDir.equals(targetDir)) { - final String urDum = "source and target directories are identical"; - throw new IllegalArgumentException(urDum); - } - targetDir.mkdirs(); - String files[] = sourceDir.list(); - for (int i = 0; i < files.length; i++) { - // Ignore dot files (.DS_Store), dot folders (.svn) while copying - if (files[i].charAt(0) == '.') continue; - //if (files[i].equals(".") || files[i].equals("..")) continue; - File source = new File(sourceDir, files[i]); - File target = new File(targetDir, files[i]); - if (source.isDirectory()) { - //target.mkdirs(); - progress = copyDir(source, target, progBar, progress, totalSize); - progBar.setProgressBarStatus((int) Math.min( - Math.ceil(progress * 100.0 / totalSize), 100)); - target.setLastModified(source.lastModified()); - } else { - copyFile(source, target, progBar, progress, totalSize); - // Update SaveAs progress bar - progress += source.length(); - progBar.setProgressBarStatus((int) Math.min( - Math.ceil(progress * 100.0 / totalSize), 100)); - } - } - return progress; - } static public void copyDirNative(File sourceDir, File targetDir) throws IOException { diff --git a/app/src/processing/app/ProgressFrame.java b/app/src/processing/app/ProgressFrame.java index 9aa5551a2..3e91ee54c 100644 --- a/app/src/processing/app/ProgressFrame.java +++ b/app/src/processing/app/ProgressFrame.java @@ -2,7 +2,12 @@ package processing.app; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; import javax.swing.JFrame; import javax.swing.JLabel; @@ -53,16 +58,16 @@ public class ProgressFrame extends JFrame implements PropertyChangeListener { // current progress if (copyable.isDirectory()) { - Base.copyDir(copyable, new File(ProgressFrame.this.newFolder, - copyable.getName()), this, progress, - totalSize); + copyDir(copyable, + new File(ProgressFrame.this.newFolder, copyable.getName()), + this, progress, totalSize); progress += getFileLength(copyable); } else { - Base.copyFile(copyable, new File(ProgressFrame.this.newFolder, - copyable.getName()), this, progress, - totalSize); + copyFile(copyable, + new File(ProgressFrame.this.newFolder, copyable.getName()), + this, progress, totalSize); if (getFileLength(copyable) < 524288) { - // If the file length > 0.5MB, the Base.copyFile() function has + // If the file length > 0.5MB, the copyFile() function has // been redesigned to change progress every 0.5MB so that // the progress bar doesn't stagnate during that time progress += getFileLength(copyable); @@ -101,10 +106,10 @@ public class ProgressFrame extends JFrame implements PropertyChangeListener { setProgress(0); - Base.copyFile(sourceFile, addFile, this); + copyFile(sourceFile, addFile, this); if (addFile.length() < 1024) { - // If the file length > 1kB, the Base.copyFile() function has + // If the file length > 1kB, the copyFile() function has // been redesigned to change progress every 1kB so that // the progress bar doesn't stagnate during that time @@ -245,4 +250,130 @@ public class ProgressFrame extends JFrame implements PropertyChangeListener { this.dispose(); } + static public void copyFile(File sourceFile, File targetFile, + ProgressFrame.TaskSaveAs progBar, + double progress, double totalSize) + throws IOException { + // Overloaded copyFile that is called whenever a Save As is being done, so that the + // ProgressBar is updated for very large files as well + BufferedInputStream from = new BufferedInputStream( + new FileInputStream( + sourceFile)); + BufferedOutputStream to = new BufferedOutputStream( + new FileOutputStream( + targetFile)); + byte[] buffer = new byte[16 * 1024]; + int bytesRead; + int totalRead = 0; + while ((bytesRead = from.read(buffer)) != -1) { + to.write(buffer, 0, bytesRead); + totalRead += bytesRead; + if (totalRead >= 524288) //to update progress bar every 0.5MB + { + progress += totalRead; + progBar.setProgressBarStatus((int) Math.min(Math.ceil(progress * 100.0 + / totalSize), 100)); + totalRead = 0; + } + } + if (sourceFile.length() > 524288) { + // Update the progress bar one final time if file size is more than 0.5MB, + // otherwise, the update is handled either by the copyDir function, + // or directly by ProgressFrame.TaskSaveAs.doInBackground() + progress += totalRead; + progBar.setProgressBarStatus((int) Math.min(Math.ceil(progress * 100.0 + / totalSize), 100)); + } + from.close(); + from = null; + to.flush(); + to.close(); + to = null; + + targetFile.setLastModified(sourceFile.lastModified()); + targetFile.setExecutable(sourceFile.canExecute()); + } + + static public void copyFile(File sourceFile, File targetFile, + ProgressFrame.TaskAddFile progBar) + throws IOException { + // Overloaded copyFile that is called whenever a addFile is being done, + // so that the + // ProgressBar is updated + double totalSize = sourceFile.length(); + int progress = 0; + BufferedInputStream from = new BufferedInputStream( + new FileInputStream( + sourceFile)); + BufferedOutputStream to = new BufferedOutputStream( + new FileOutputStream( + targetFile)); + byte[] buffer = new byte[16 * 1024]; + int bytesRead; + int totalRead = 0; + while ((bytesRead = from.read(buffer)) != -1) { + to.write(buffer, 0, bytesRead); + totalRead += bytesRead; + if (totalRead >= 1024) // to update progress bar every 1kB + { + progress += totalRead; + progBar.setProgressBarStatus((int) Math.min(Math.ceil(progress * 100.0 + / totalSize), 100)); + totalRead = 0; + } + } + if (sourceFile.length() > 1024) { + // Update the progress bar one final time if file size is more than + // 1kB, + // otherwise, the update is handled directly by + // ProgressFrame.TaskAddFile.doInBackground() + progress += totalRead; + progBar.setProgressBarStatus((int) Math.min(Math.ceil(progress * 100.0 + / totalSize), 100)); + } + from.close(); + from = null; + to.flush(); + to.close(); + to = null; + targetFile.setLastModified(sourceFile.lastModified()); + targetFile.setExecutable(sourceFile.canExecute()); + } + + static public double copyDir(File sourceDir, File targetDir, + ProgressFrame.TaskSaveAs progBar, + double progress, double totalSize) + throws IOException { + // Overloaded copyDir so that the Save As progress bar gets updated when the + // files are in folders as well (like in the data folder) + if (sourceDir.equals(targetDir)) { + final String urDum = "source and target directories are identical"; + throw new IllegalArgumentException(urDum); + } + targetDir.mkdirs(); + String files[] = sourceDir.list(); + for (int i = 0; i < files.length; i++) { + // Ignore dot files (.DS_Store), dot folders (.svn) while copying + if (files[i].charAt(0) == '.') + continue; + //if (files[i].equals(".") || files[i].equals("..")) continue; + File source = new File(sourceDir, files[i]); + File target = new File(targetDir, files[i]); + if (source.isDirectory()) { + //target.mkdirs(); + progress = copyDir(source, target, progBar, progress, totalSize); + progBar.setProgressBarStatus((int) Math.min(Math.ceil(progress * 100.0 + / totalSize), 100)); + target.setLastModified(source.lastModified()); + } else { + copyFile(source, target, progBar, progress, totalSize); + // Update SaveAs progress bar + progress += source.length(); + progBar.setProgressBarStatus((int) Math.min(Math.ceil(progress * 100.0 + / totalSize), 100)); + } + } + return progress; + } + } diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 58538a455..ba274a638 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -1060,12 +1060,11 @@ public class Sketch { final File destFile2 = destFile; // Create a new event dispatch thread- to display ProgressBar // while Saving As - javax.swing.SwingUtilities.invokeLater(new Runnable() { - public void run() { - new ProgressFrame(sourceFile2, - destFile2, editor); - } - }); + javax.swing.SwingUtilities.invokeLater(new Runnable() { + public void run() { + new ProgressFrame(sourceFile2, destFile2, editor); + } + }); } if (codeExtension != null) { From fe7d4b8ad5da77d7c1657371a08ded6da651444a Mon Sep 17 00:00:00 2001 From: Yong Bakos Date: Mon, 28 Jul 2014 18:34:26 -0500 Subject: [PATCH 09/44] Correcting descriptions of reverse method for FloatList, IntList and StringList. Fixes https://github.com/processing/processing-docs/issues/50 --- core/src/processing/data/FloatList.java | 2 +- core/src/processing/data/IntList.java | 2 +- core/src/processing/data/StringList.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/processing/data/FloatList.java b/core/src/processing/data/FloatList.java index 9921cb326..0acb8496d 100644 --- a/core/src/processing/data/FloatList.java +++ b/core/src/processing/data/FloatList.java @@ -601,7 +601,7 @@ public class FloatList implements Iterable { /** * @webref floatlist:method - * @brief Reverse sort, orders values by first digit + * @brief Reverse the order of the list elements */ public void reverse() { int ii = count - 1; diff --git a/core/src/processing/data/IntList.java b/core/src/processing/data/IntList.java index 78775be3f..afa0333fa 100644 --- a/core/src/processing/data/IntList.java +++ b/core/src/processing/data/IntList.java @@ -569,7 +569,7 @@ public class IntList implements Iterable { /** * @webref intlist:method - * @brief Reverse sort, orders values by first digit + * @brief Reverse the order of the list elements */ public void reverse() { int ii = count - 1; diff --git a/core/src/processing/data/StringList.java b/core/src/processing/data/StringList.java index a407265a9..b5ec4bad0 100644 --- a/core/src/processing/data/StringList.java +++ b/core/src/processing/data/StringList.java @@ -495,7 +495,7 @@ public class StringList implements Iterable { /** * @webref stringlist:method - * @brief To come... + * @brief Reverse the order of the list elements */ public void reverse() { int ii = count - 1; From c45ddb5f4602dea0684f0c716ae7829d7d9e1731 Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Tue, 29 Jul 2014 10:47:04 +0530 Subject: [PATCH 10/44] added sketchbook - tree view --- app/src/processing/app/Editor.java | 13 ++++ app/src/processing/app/Mode.java | 99 ++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index fe18ab4a2..c9f470fc5 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -37,8 +37,11 @@ import java.util.List; import java.util.Timer; import javax.swing.*; +import javax.swing.border.EmptyBorder; import javax.swing.event.*; import javax.swing.text.*; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeSelectionModel; import javax.swing.undo.*; /** @@ -606,6 +609,16 @@ public abstract class Editor extends JFrame implements RunnerListener { fileMenu.add(item); fileMenu.add(base.getSketchbookMenu()); + + JMenuItem sbMenu = new JMenuItem("Sketchbook Tree"); + sbMenu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + mode.showSketchbookFrame(); + } + }); + + fileMenu.add(sbMenu); // fileMenu.add(mode.getExamplesMenu()); item = Toolkit.newJMenuItemShift("Examples...", 'O'); diff --git a/app/src/processing/app/Mode.java b/app/src/processing/app/Mode.java index 741474606..303411818 100644 --- a/app/src/processing/app/Mode.java +++ b/app/src/processing/app/Mode.java @@ -879,6 +879,105 @@ public abstract class Mode { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + public DefaultMutableTreeNode buildSketchbookTree(){ + //JMenuItem sbMenu = new JMenuItem("SB Tree"); + DefaultMutableTreeNode sbNode = new DefaultMutableTreeNode("Sketchbook"); + try { + base.addSketches(sbNode, Base.getSketchbookFolder()); + } catch (IOException e) { + e.printStackTrace(); + } + return sbNode; + } + + protected JFrame sketchbookFrame; + + public void showSketchbookFrame() { + if (sketchbookFrame == null) { + sketchbookFrame = new JFrame("Processing Sketchbook"); + Toolkit.setIcon(sketchbookFrame); + Toolkit.registerWindowCloseKeys(sketchbookFrame.getRootPane(), + new ActionListener() { + public void actionPerformed(ActionEvent e) { + sketchbookFrame.setVisible(false); + } + }); + + final JTree tree = new JTree(buildSketchbookTree()); + tree.getSelectionModel() + .setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); + tree.setShowsRootHandles(true); + tree.expandRow(0); + tree.setRootVisible(false); + + tree.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree + .getLastSelectedPathComponent(); + + int selRow = tree.getRowForLocation(e.getX(), e.getY()); + //TreePath selPath = tree.getPathForLocation(e.getX(), e.getY()); + //if (node != null && node.isLeaf() && node.getPath().equals(selPath)) { + if (node != null && node.isLeaf() && selRow != -1) { + SketchReference sketch = (SketchReference) node.getUserObject(); + base.handleOpen(sketch.getPath()); + } + } + } + }); + + tree.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { // doesn't fire keyTyped() + sketchbookFrame.setVisible(false); + } + } + + public void keyTyped(KeyEvent e) { + if (e.getKeyChar() == KeyEvent.VK_ENTER) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree + .getLastSelectedPathComponent(); + if (node != null && node.isLeaf()) { + SketchReference sketch = (SketchReference) node.getUserObject(); + base.handleOpen(sketch.getPath()); + } + } + } + }); + + tree.setBorder(new EmptyBorder(5, 5, 5, 5)); + if (Base.isMacOS()) { + tree.setToggleClickCount(2); + } else { + tree.setToggleClickCount(1); + } + JScrollPane treePane = new JScrollPane(tree); + treePane.setPreferredSize(new Dimension(250, 450)); + treePane.setBorder(new EmptyBorder(0, 0, 0, 0)); + sketchbookFrame.getContentPane().add(treePane); + sketchbookFrame.pack(); + } + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + // Space for the editor plus a li'l gap + int roughWidth = sketchbookFrame.getWidth() + 20; + Point p = null; + // If no window open, or the editor is at the edge of the screen + if (base.activeEditor == null + || (p = base.activeEditor.getLocation()).x < roughWidth) { + // Center the window on the screen + sketchbookFrame.setLocationRelativeTo(null); + } else { + // Open the window relative to the editor + sketchbookFrame.setLocation(p.x - roughWidth, p.y); + } + sketchbookFrame.setVisible(true); + } + }); + } /** * Get an image object from the theme folder. From d414a2a09dd99eb8436a6f52e8a091c0e982aa6f Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Tue, 29 Jul 2014 11:06:08 +0530 Subject: [PATCH 11/44] removed unnecessary imports --- app/src/processing/app/Editor.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index c9f470fc5..c24d8384b 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -37,11 +37,8 @@ import java.util.List; import java.util.Timer; import javax.swing.*; -import javax.swing.border.EmptyBorder; import javax.swing.event.*; import javax.swing.text.*; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.TreeSelectionModel; import javax.swing.undo.*; /** From f842601c9ae74bfe4afb8a906b41bdbd5fe88ab7 Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Tue, 29 Jul 2014 11:24:13 +0530 Subject: [PATCH 12/44] added sketchbook shortcut --- app/src/processing/app/Editor.java | 2 +- app/src/processing/app/Mode.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index c24d8384b..6074090b8 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -607,7 +607,7 @@ public abstract class Editor extends JFrame implements RunnerListener { fileMenu.add(base.getSketchbookMenu()); - JMenuItem sbMenu = new JMenuItem("Sketchbook Tree"); + JMenuItem sbMenu = Toolkit.newJMenuItemShift("Sketchbook Tree", 'K'); sbMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { diff --git a/app/src/processing/app/Mode.java b/app/src/processing/app/Mode.java index 303411818..5f0779e3d 100644 --- a/app/src/processing/app/Mode.java +++ b/app/src/processing/app/Mode.java @@ -880,7 +880,6 @@ public abstract class Mode { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . public DefaultMutableTreeNode buildSketchbookTree(){ - //JMenuItem sbMenu = new JMenuItem("SB Tree"); DefaultMutableTreeNode sbNode = new DefaultMutableTreeNode("Sketchbook"); try { base.addSketches(sbNode, Base.getSketchbookFolder()); From 222a60fcedf1c3fae9d895678ed4d9664efc84db Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Tue, 29 Jul 2014 10:40:00 -0400 Subject: [PATCH 13/44] remove %PATH% from the library path imports --- app/src/processing/mode/java/JavaBuild.java | 66 ++++++++++----------- todo.txt | 2 + 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/app/src/processing/mode/java/JavaBuild.java b/app/src/processing/mode/java/JavaBuild.java index 021f7ea5e..9e599eb12 100644 --- a/app/src/processing/mode/java/JavaBuild.java +++ b/app/src/processing/mode/java/JavaBuild.java @@ -422,7 +422,7 @@ public class JavaBuild { String entry = (dot == -1) ? item : item.substring(0, dot); // System.out.print(entry + " => "); - if (item.startsWith("static ")) { + if (item.startsWith("static ")) { // import static - https://github.com/processing/processing/issues/8 // Remove more stuff. int dot2 = item.lastIndexOf('.'); @@ -472,8 +472,8 @@ public class JavaBuild { javaClassPath = javaClassPath.substring(1, javaClassPath.length() - 1); } classPath += File.pathSeparator + javaClassPath; - - // But make sure that there isn't anything in there that's missing, + + // But make sure that there isn't anything in there that's missing, // otherwise ECJ will complain and die. For instance, Java 1.7 (or maybe // it's appbundler?) adds Java/Classes to the path, which kills us. //String[] classPieces = PApplet.split(classPath, File.pathSeparator); @@ -549,7 +549,7 @@ public class JavaBuild { if (pkg.startsWith("processing.data.")) return true; if (pkg.startsWith("processing.event.")) return true; if (pkg.startsWith("processing.opengl.")) return true; - + // if (pkg.startsWith("com.jogamp.")) return true; // // ignore core, data, and opengl packages @@ -1113,11 +1113,11 @@ public class JavaBuild { File folder = null; for (String platformName : PConstants.platformNames) { int platform = Base.getPlatformIndex(platformName); - + // Can only embed Java on the native platform - boolean embedJava = (platform == PApplet.platform) && + boolean embedJava = (platform == PApplet.platform) && Preferences.getBoolean("export.application.embed_java"); - + if (Preferences.getBoolean("export.application.platform." + platformName)) { if (Library.hasMultipleArch(platform, importedLibraries)) { // export the 32-bit version @@ -1223,34 +1223,34 @@ public class JavaBuild { contentsFolder.mkdirs(); // Info.plist will be written later - + // set the jar folder to a different location than windows/linux //jarFolder = new File(dotAppFolder, "Contents/Resources/Java"); jarFolder = new File(contentsFolder, "Java"); File macosFolder = new File(contentsFolder, "MacOS"); macosFolder.mkdirs(); - Base.copyFile(new File(contentsOrig, "MacOS/Processing"), + Base.copyFile(new File(contentsOrig, "MacOS/Processing"), new File(contentsFolder, "MacOS/" + sketch.getName())); - + File pkgInfo = new File(contentsFolder, "PkgInfo"); PrintWriter writer = PApplet.createWriter(pkgInfo); writer.println("APPL????"); writer.flush(); writer.close(); - + // Use faster(?) native copy here (also to do sym links) if (embedJava) { Base.copyDirNative(new File(contentsOrig, "PlugIns"), new File(contentsFolder, "PlugIns")); } - + File resourcesFolder = new File(contentsFolder, "Resources"); - Base.copyDir(new File(contentsOrig, "Resources/en.lproj"), + Base.copyDir(new File(contentsOrig, "Resources/en.lproj"), new File(resourcesFolder, "en.lproj")); Base.copyFile(mode.getContentFile("application/sketch.icns"), new File(resourcesFolder, "sketch.icns")); - + /* String stubName = "Contents/MacOS/JavaApplicationStub"; // need to set the stub to executable @@ -1279,7 +1279,7 @@ public class JavaBuild { if (embedJava) { Base.copyDirNative(Base.getJavaHome(), new File(destFolder, "java")); } - + } else if (exportPlatform == PConstants.WINDOWS) { if (embedJava) { Base.copyDir(Base.getJavaHome(), new File(destFolder, "java")); @@ -1312,7 +1312,7 @@ public class JavaBuild { } */ - + /// start copying all jar files Vector jarListVector = new Vector(); @@ -1448,7 +1448,7 @@ public class JavaBuild { runOptions.add("-Djna.nosys=true"); // https://github.com/processing/processing/issues/2559 if (exportPlatform == PConstants.WINDOWS) { - runOptions.add("-Djava.library.path=\"%EXEDIR%\\lib;%PATH%\""); + runOptions.add("-Djava.library.path=\"%EXEDIR%\\lib\""); } @@ -1461,7 +1461,7 @@ public class JavaBuild { runOptionsXML.append(opt); runOptionsXML.append(""); runOptionsXML.append('\n'); - } + } String PLIST_TEMPLATE = "Info.plist.tmpl"; File plistTemplate = new File(sketch.getFolder(), PLIST_TEMPLATE); @@ -1504,10 +1504,10 @@ public class JavaBuild { // attempt to code sign if the Xcode tools appear to be installed if (Base.isMacOS() && new File("/usr/bin/codesign_allocate").exists()) { if (embedJava) { - ProcessHelper.ffs("codesign", "--force", "--sign", "-", jdkPath); + ProcessHelper.ffs("codesign", "--force", "--sign", "-", jdkPath); } String appPath = dotAppFolder.getAbsolutePath(); - ProcessHelper.ffs("codesign", "--force", "--sign", "-", appPath); + ProcessHelper.ffs("codesign", "--force", "--sign", "-", appPath); } } else if (exportPlatform == PConstants.WINDOWS) { @@ -1517,27 +1517,27 @@ public class JavaBuild { XML project = new XML("project"); XML target = project.addChild("target"); target.setString("name", "windows"); - + XML taskdef = target.addChild("taskdef"); taskdef.setString("name", "launch4j"); taskdef.setString("classname", "net.sf.launch4j.ant.Launch4jTask"); String launchPath = mode.getContentFile("application/launch4j").getAbsolutePath(); taskdef.setString("classpath", launchPath + "/launch4j.jar:" + launchPath + "/lib/xstream.jar"); - + XML launch4j = target.addChild("launch4j"); // not all launch4j options are available when embedded inside the ant // build file (i.e. the icon param doesn't work), so use a config file // launch4j.setString("configFile", configFile.getAbsolutePath()); - + XML config = new XML("launch4jConfig"); config.addChild("headerType").setContent("gui"); config.addChild("dontWrapJar").setContent("true"); config.addChild("downloadUrl").setContent("http://java.com/download"); - + File exeFile = new File(destFolder, sketch.getName() + ".exe"); config.addChild("outfile").setContent(exeFile.getAbsolutePath()); - + File iconFile = mode.getContentFile("application/sketch.ico"); config.addChild("icon").setContent(iconFile.getAbsolutePath()); @@ -1554,7 +1554,7 @@ public class JavaBuild { for (String opt : runOptions) { jre.addChild("opt").setContent(opt); } - + /* XML config = launch4j.addChild("config"); config.setString("headerType", "gui"); @@ -1562,10 +1562,10 @@ public class JavaBuild { config.setString("outfile", exeFile.getAbsolutePath()); config.setString("dontWrapJar", "true"); config.setString("jarPath", "lib\\" + jarList[0]); - + File iconFile = mode.getContentFile("application/sketch.ico"); config.addChild("icon").setContent(iconFile.getAbsolutePath()); - + XML clazzPath = config.addChild("classPath"); clazzPath.setString("mainClass", sketch.getName()); for (int i = 1; i < jarList.length; i++) { @@ -1579,11 +1579,11 @@ public class JavaBuild { jre.addChild("opt").setContent(opt); } */ - + config.save(configFile); project.save(buildFile); if (!buildWindowsLauncher(buildFile, "windows")) { - // don't delete the build file, might be useful for debugging + // don't delete the build file, might be useful for debugging return false; } configFile.delete(); @@ -1601,10 +1601,10 @@ public class JavaBuild { // another fix for bug #234, LD_LIBRARY_PATH ignored on some platforms //ps.print("LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$APPDIR\n"); if (embedJava) { - // https://github.com/processing/processing/issues/2349 + // https://github.com/processing/processing/issues/2349 pw.print("$APPDIR/java/bin/"); } - String runOptionsStr = + String runOptionsStr = PApplet.join(runOptions.toArray(new String[0]), " "); pw.print("java " + runOptionsStr + " -Djava.library.path=\"$APPDIR:$APPDIR/lib\"" + @@ -1650,7 +1650,7 @@ public class JavaBuild { } - /** + /** * Run the launch4j build.xml file through ant to create the exe. * Most of this code was lifted from Android mode. */ diff --git a/todo.txt b/todo.txt index e8dd91c28..82e4185ad 100644 --- a/todo.txt +++ b/todo.txt @@ -1,6 +1,8 @@ 0229 pde (3.0a2) X new tab/rename dialog box X https://github.com/processing/processing/issues/2431 +X fix issue where the browser wasn't opening the reference properly +X https://github.com/processing/processing/pull/2657 pulls X insert tabs properly when prefs set for tabs mode From 514385835e37386485549ee278736fa10a85acbe Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Tue, 29 Jul 2014 19:49:45 -0400 Subject: [PATCH 14/44] fix code signing but/error on osx export (#2614) --- app/src/processing/mode/java/JavaBuild.java | 2 +- done.txt | 1 + todo.txt | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/processing/mode/java/JavaBuild.java b/app/src/processing/mode/java/JavaBuild.java index 9e599eb12..42f8de00f 100644 --- a/app/src/processing/mode/java/JavaBuild.java +++ b/app/src/processing/mode/java/JavaBuild.java @@ -1216,7 +1216,7 @@ public class JavaBuild { File jdkFolder = new File(Base.getJavaHome(), "../../.."); String jdkFolderName = jdkFolder.getCanonicalFile().getName(); jvmRuntime = "JVMRuntime\n " + jdkFolderName + ""; - jdkPath = new File(dotAppFolder, "Contents/PlugIns/" + jdkFolderName + ".jdk").getAbsolutePath(); + jdkPath = new File(dotAppFolder, "Contents/PlugIns/" + jdkFolderName).getAbsolutePath(); } File contentsFolder = new File(dotAppFolder, "Contents"); diff --git a/done.txt b/done.txt index 6273246fd..bffe7352c 100644 --- a/done.txt +++ b/done.txt @@ -22,6 +22,7 @@ X tweak mode integrated X https://github.com/processing/processing/pull/2624 X wrong mode selected if sketch is modified (checkbox changes) X https://github.com/processing/processing/issues/2615 +X https://github.com/processing/processing/issues/2586 X Add date and time stamps to the Contribution Manager X https://github.com/processing/processing/pull/2651 diff --git a/todo.txt b/todo.txt index 82e4185ad..8a8e41138 100644 --- a/todo.txt +++ b/todo.txt @@ -3,11 +3,18 @@ X new tab/rename dialog box X https://github.com/processing/processing/issues/2431 X fix issue where the browser wasn't opening the reference properly X https://github.com/processing/processing/pull/2657 +X fix "No such file or directory" error when exporting an application on OSX +X this also resulted in the application not being signed at all +X https://github.com/processing/processing/issues/2614 +X this is a fairly major issue... pulls X insert tabs properly when prefs set for tabs mode X https://github.com/processing/processing/pull/2607 +earlier +X maxHeapSize typo in the build scripts +X https://github.com/processing/processing/issues/2603 _ fix the build scripts to include the examples _ https://github.com/processing/processing/issues/2652 From 7a054cfdafbb8c995f8caa50c3dcc8921cec6645 Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Wed, 30 Jul 2014 15:45:58 +0400 Subject: [PATCH 15/44] Status Messages/Errors now clear in Contrib Manager --- .../processing/app/contrib/ContributionManagerDialog.java | 1 + app/src/processing/app/contrib/ContributionPanel.java | 4 ++++ app/src/processing/app/contrib/StatusPanel.java | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/app/src/processing/app/contrib/ContributionManagerDialog.java b/app/src/processing/app/contrib/ContributionManagerDialog.java index c0a23d79f..9d46e21cb 100644 --- a/app/src/processing/app/contrib/ContributionManagerDialog.java +++ b/app/src/processing/app/contrib/ContributionManagerDialog.java @@ -125,6 +125,7 @@ public class ContributionManagerDialog { * Close the window after an OK or Cancel. */ protected void disposeFrame() { + status.clear(); dialog.dispose(); editor = null; } diff --git a/app/src/processing/app/contrib/ContributionPanel.java b/app/src/processing/app/contrib/ContributionPanel.java index 37b4fb6b3..3a5a9c99d 100644 --- a/app/src/processing/app/contrib/ContributionPanel.java +++ b/app/src/processing/app/contrib/ContributionPanel.java @@ -101,6 +101,7 @@ class ContributionPanel extends JPanel { installActionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { + listPanel.contribManager.status.clear(); if (contrib instanceof AvailableContribution) { installContribution((AvailableContribution) contrib); contribListing.replaceContribution(contrib, contrib); @@ -110,6 +111,7 @@ class ContributionPanel extends JPanel { undoActionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { + listPanel.contribManager.status.clear(); if (contrib instanceof LocalContribution) { LocalContribution installed = (LocalContribution) contrib; installed.setDeletionFlag(false); @@ -120,6 +122,7 @@ class ContributionPanel extends JPanel { removeActionListener = new ActionListener() { public void actionPerformed(ActionEvent arg) { + listPanel.contribManager.status.clear(); if (contrib.isInstalled() && contrib instanceof LocalContribution) { updateButton.setEnabled(false); installRemoveButton.setEnabled(false); @@ -211,6 +214,7 @@ class ContributionPanel extends JPanel { updateButton.setVisible(false); updateButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { + listPanel.contribManager.status.clear(); updateButton.setEnabled(false); AvailableContribution ad = contribListing.getAvailableContribution(contrib); String url = ad.link; diff --git a/app/src/processing/app/contrib/StatusPanel.java b/app/src/processing/app/contrib/StatusPanel.java index a4f98e14c..ea1e874ac 100644 --- a/app/src/processing/app/contrib/StatusPanel.java +++ b/app/src/processing/app/contrib/StatusPanel.java @@ -45,6 +45,11 @@ class StatusPanel extends JLabel { setText(message); repaint(); } + + void clear() { + setText(""); + repaint(); + } } From cf4e7a7c46e4f830229dd046a7826ed224692061 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 09:15:02 -0400 Subject: [PATCH 16/44] add copy() method to Table --- core/src/processing/data/Table.java | 6 ++++++ core/todo.txt | 1 + 2 files changed, 7 insertions(+) diff --git a/core/src/processing/data/Table.java b/core/src/processing/data/Table.java index a76ec9bfe..a153d16aa 100644 --- a/core/src/processing/data/Table.java +++ b/core/src/processing/data/Table.java @@ -4284,4 +4284,10 @@ public class Table { } } */ + + + /** Make a copy of the current table */ + public Table copy() { + return new Table(rows()); + } } diff --git a/core/todo.txt b/core/todo.txt index ecf2cc743..93a05f7b3 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -1,4 +1,5 @@ 0229 core (3.0a2) +X add copy() method to Table pulls From a0bc02db16a3ca4e56c21fd55cd77594eb018ae9 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 09:38:19 -0400 Subject: [PATCH 17/44] return null on getString() for NaN values --- core/src/processing/data/Table.java | 16 ++++++++++++---- core/todo.txt | 4 ++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/core/src/processing/data/Table.java b/core/src/processing/data/Table.java index a153d16aa..93ba62fc4 100644 --- a/core/src/processing/data/Table.java +++ b/core/src/processing/data/Table.java @@ -2984,11 +2984,19 @@ public class Table { return missingString; } return columnCategories[column].key(cat); - } else { - return String.valueOf(Array.get(columns[column], row)); + } else if (columnTypes[column] == FLOAT) { + if (Float.isNaN(getFloat(row, column))) { + return null; + } + } else if (columnTypes[column] == DOUBLE) { + if (Double.isNaN(getFloat(row, column))) { + return null; + } } + return String.valueOf(Array.get(columns[column], row)); } + /** * @param columnName title of the column to reference */ @@ -3443,9 +3451,9 @@ public class Table { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - public void replaceAll(String orig, String replacement) { + public void replaceAll(String regex, String replacement) { for (int col = 0; col < columns.length; col++) { - replaceAll(orig, replacement, col); + replaceAll(regex, replacement, col); } } diff --git a/core/todo.txt b/core/todo.txt index 93a05f7b3..791022f45 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -1,6 +1,10 @@ 0229 core (3.0a2) X add copy() method to Table +_ need a better method for "missing" data in Table +_ if missing int is zero, can't just remove those values from saving a table +_ but for NaN values, it's a necessity + pulls X implement A and a (elliptical arcs) From d07e5a367befbcfeb7d3b5424d893128fe4d0c25 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 10:07:43 -0400 Subject: [PATCH 18/44] add note about what was added to Table --- core/todo.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/todo.txt b/core/todo.txt index 791022f45..38845f051 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -1,5 +1,7 @@ 0229 core (3.0a2) X add copy() method to Table +X return null from getString() on NaN float and double values +X affects how saveTable() works (writes blank entries instead of NaN) _ need a better method for "missing" data in Table _ if missing int is zero, can't just remove those values from saving a table From faf4584a5575f9e8e939e70a0b65d76173a25f35 Mon Sep 17 00:00:00 2001 From: Alexis Engelke Date: Wed, 30 Jul 2014 17:28:10 +0200 Subject: [PATCH 19/44] Updates for Nimbus LAF --- app/src/processing/app/EditorConsole.java | 8 +++++++- app/src/processing/app/contrib/ContributionPanel.java | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/processing/app/EditorConsole.java b/app/src/processing/app/EditorConsole.java index 6ad9eb709..935539841 100644 --- a/app/src/processing/app/EditorConsole.java +++ b/app/src/processing/app/EditorConsole.java @@ -212,7 +212,13 @@ public class EditorConsole extends JScrollPane { StyleConstants.setBold(errStyle, font.isBold()); StyleConstants.setItalic(errStyle, font.isItalic()); - consoleTextPane.setBackground(bgColor); + if (UIManager.getLookAndFeel().getID().equals("Nimbus")) { + getViewport().setBackground(bgColor); + consoleTextPane.setOpaque(false); + consoleTextPane.setBackground(new Color(0, 0, 0, 0)); + } else { + consoleTextPane.setBackground(bgColor); + } // calculate height of a line of text in pixels // and size window accordingly diff --git a/app/src/processing/app/contrib/ContributionPanel.java b/app/src/processing/app/contrib/ContributionPanel.java index 3a5a9c99d..c4a2763b5 100644 --- a/app/src/processing/app/contrib/ContributionPanel.java +++ b/app/src/processing/app/contrib/ContributionPanel.java @@ -185,6 +185,9 @@ class ContributionPanel extends JPanel { descriptionBlock.setContentType("text/html"); setTextStyle(descriptionBlock); descriptionBlock.setOpaque(false); + if (UIManager.getLookAndFeel().getID().equals("Nimbus")) { + descriptionBlock.setBackground(new Color(0, 0, 0, 0)); + } // stripTextSelectionListeners(descriptionBlock); descriptionBlock.setBorder(new EmptyBorder(4, 7, 7, 7)); From 72cc3dd54d7c873d68f3738372a80179831f427a Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 11:34:44 -0400 Subject: [PATCH 20/44] prevent multiple sketch windows opening (fixes 2506) --- app/src/processing/app/Base.java | 27 +++++++-------- todo.txt | 56 +++++++++++++++++--------------- 2 files changed, 43 insertions(+), 40 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index a24ee9a93..57d893c88 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -921,14 +921,18 @@ public class Base { return null; } - // System.err.println(" editors: " + editors); // Cycle through open windows to make sure that it's not already open. for (Editor editor : editors) { - if (editor.getSketch().getMainFile().equals(file)) { - editor.toFront(); - // move back to the top of the recent list - handleRecent(editor); - return editor; + // User may have double-clicked any PDE in the sketch folder, + // so we have to check each open tab (not just the main one). + // https://github.com/processing/processing/issues/2506 + for (SketchCode tab : editor.getSketch().getCode()) { + if (tab.getFile().equals(file)) { + editor.toFront(); + // move back to the top of the recent list + handleRecent(editor); + return editor; + } } } @@ -951,8 +955,6 @@ public class Base { // Editor.State state = new Editor.State(editors); Editor editor = nextMode.createEditor(this, path, state); if (editor == null) { - // if it's the last editor window -// if (editors.size() == 0 && defaultFileMenu == null) { // if it's not mode[0] already, then don't go into an infinite loop // trying to recreate a window with the default mode. if (nextMode == coreModes[0]) { @@ -965,15 +967,14 @@ public class Base { editor = coreModes[0].createEditor(this, path, state); } } - + // Make sure that the sketch actually loaded - if (editor.getSketch() == null) { -// System.err.println("sketch was null, getting out of handleOpen"); + Sketch sketch = editor.getSketch(); + if (sketch == null) { return null; // Just walk away quietly } -// editor.untitled = untitled; - editor.getSketch().setUntitled(untitled); + sketch.setUntitled(untitled); editors.add(editor); handleRecent(editor); diff --git a/todo.txt b/todo.txt index 8a8e41138..8ea0536a9 100644 --- a/todo.txt +++ b/todo.txt @@ -7,6 +7,13 @@ X fix "No such file or directory" error when exporting an application on OSX X this also resulted in the application not being signed at all X https://github.com/processing/processing/issues/2614 X this is a fairly major issue... +X user opens non-main pde of already open sketch, it'll open again +X https://github.com/processing/processing/issues/2506 + +gsoc +X clear status messages in the Contribution Manager +X https://github.com/processing/processing/pull/2667 +X https://github.com/processing/processing/issues/2599 pulls X insert tabs properly when prefs set for tabs mode @@ -15,31 +22,32 @@ X https://github.com/processing/processing/pull/2607 earlier X maxHeapSize typo in the build scripts X https://github.com/processing/processing/issues/2603 - -_ fix the build scripts to include the examples -_ https://github.com/processing/processing/issues/2652 -_ reference wasn't included either -_ https://github.com/processing/processing/issues/2656 - - -_ "Platform is ${platform}" message during 'ant clean' +X remove minim +X add the new sound library to the build process +X for() loop with nothing inside parens crashes Auto Format +X https://github.com/processing/processing/issues/2141 +o double-clicking a .pde file doesn't open properly on OS X +o https://github.com/processing/processing/issues/2639 +X moving p5 examples to the web repo +X remove reference.zip from main repo _ add a new pref for the 3.0 sketchbook location -_ remove minim -_ add the new sound library to the build process +_ fix the build scripts to include the examples +_ https://github.com/processing/processing/issues/2652 +_ all examples are out of "processing/java" and are now in "processing-docs/content/". The Book examples have been removed entirely from our repositories. +_ reference wasn't included either +_ https://github.com/processing/processing/issues/2656 +_ processing-web/java_generate/ReferenceGenerator + +_ make ant fail when trying to delete JRE files that don't exist +_ some aren't being removed properly +_ "Platform is ${platform}" message during 'ant clean' -_ double-clicking a .pde file doesn't open properly on OS X -_ https://github.com/processing/processing/issues/2639 _ OS X export button not disabled on other platforms _ https://github.com/processing/processing/issues/2642 _ look at the sound library https://github.com/wirsing/ProcessingSound -_ moving p5 examples to the web repo -all examples are out of "processing/java" and are now in "processing-docs/content/". The Book examples have been removed entirely from our repositories. -_ remove reference.zip from main repo -_ processing-web/java_generate/ReferenceGenerator - _ try new syntax package _ possibility of libraries folder inside a particular sketch? _ incorporate new preproc @@ -54,16 +62,8 @@ _ make reference and examples build process part of dist _ separate ant targets, but only require them for dist _ as separate targets, folks can build explicitly if they'd like -_ shouldn't write sketch.properties unless it's a non-default mode -_ https://github.com/processing/processing/issues/2531 _ huge i18n patch _ https://github.com/processing/processing/pull/2084 -_ make ant fail when trying to delete JRE files that don't exist -_ some aren't being removed properly - -earlier -X for() loop with nothing inside parens crashes Auto Format -X https://github.com/processing/processing/issues/2141 gsoc _ `return` keyword not treated as such when followed by a bracket @@ -72,13 +72,15 @@ _ IllegalArgumentException when clicking between editor windows _ https://github.com/processing/processing/issues/2530 _ "String index out of range" error _ https://github.com/processing/processing/issues/1940 +_ shouldn't write sketch.properties unless it's a non-default mode +_ https://github.com/processing/processing/issues/2531 +_ closing the color selector makes things freeze (only Linux and Windows?) +_ https://github.com/processing/processing/issues/2381 medium _ possible to open a sketch multiple times _ by double-clicking one of its files instead of the main pde file _ https://github.com/processing/processing/issues/2506 -_ closing the color selector makes things freeze (only Linux and Windows?) -_ https://github.com/processing/processing/issues/2381 _ check on why 2x core.jar inside the Java folder _ maybe OS X Java can't look in subfolders? (just auto-adds things) _ display "1" is not correct in 2.1.2 From ca0a0580c3b0e4a2a055d50d89ee6fdb175e006b Mon Sep 17 00:00:00 2001 From: Alexis Engelke Date: Wed, 30 Jul 2014 17:51:58 +0200 Subject: [PATCH 21/44] Fix processing/processing#2548 --- core/src/processing/data/StringList.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/processing/data/StringList.java b/core/src/processing/data/StringList.java index b5ec4bad0..7434c0e77 100644 --- a/core/src/processing/data/StringList.java +++ b/core/src/processing/data/StringList.java @@ -309,7 +309,7 @@ public class StringList implements Iterable { if (index < 0) { throw new IllegalArgumentException("insert() index cannot be negative: it was " + index); } - if (index >= values.length) { + if (index >= data.length) { throw new IllegalArgumentException("insert() index " + index + " is past the end of this list"); } From 47125c979747edf726150f5d21ea49609bb7d2db Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 11:58:45 -0400 Subject: [PATCH 22/44] disable the OS X export button on Windows and Linux (fixes 2642) --- app/src/processing/mode/java/JavaEditor.java | 9 +++++++++ todo.txt | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/processing/mode/java/JavaEditor.java b/app/src/processing/mode/java/JavaEditor.java index 70e083ea4..270209ef2 100644 --- a/app/src/processing/mode/java/JavaEditor.java +++ b/app/src/processing/mode/java/JavaEditor.java @@ -283,6 +283,11 @@ public class JavaEditor extends Editor { } }); + // Only possible to export OS X applications on OS X + if (!Base.isMacOS()) { + // Make sure they don't have a previous 'true' setting for this + Preferences.setBoolean("export.application.platform.macosx", false); + } final JCheckBox macosxButton = new JCheckBox("Mac OS X"); macosxButton.setSelected(Preferences.getBoolean("export.application.platform.macosx")); macosxButton.addItemListener(new ItemListener() { @@ -290,6 +295,10 @@ public class JavaEditor extends Editor { Preferences.setBoolean("export.application.platform.macosx", macosxButton.isSelected()); } }); + if (!Base.isMacOS()) { + macosxButton.setEnabled(false); + macosxButton.setToolTipText("Mac OS X export is only available on Mac OS X"); + } final JCheckBox linuxButton = new JCheckBox("Linux"); //linuxButton.setMnemonic(KeyEvent.VK_L); diff --git a/todo.txt b/todo.txt index 8ea0536a9..b1cb03c8a 100644 --- a/todo.txt +++ b/todo.txt @@ -18,6 +18,8 @@ X https://github.com/processing/processing/issues/2599 pulls X insert tabs properly when prefs set for tabs mode X https://github.com/processing/processing/pull/2607 +X improve look of Nimbus LAF +X https://github.com/processing/processing/pull/2671 earlier X maxHeapSize typo in the build scripts @@ -31,6 +33,7 @@ o https://github.com/processing/processing/issues/2639 X moving p5 examples to the web repo X remove reference.zip from main repo + _ add a new pref for the 3.0 sketchbook location _ fix the build scripts to include the examples _ https://github.com/processing/processing/issues/2652 @@ -47,12 +50,13 @@ _ OS X export button not disabled on other platforms _ https://github.com/processing/processing/issues/2642 _ look at the sound library https://github.com/wirsing/ProcessingSound +_ appears that sound is not yet supported on Windows _ try new syntax package _ possibility of libraries folder inside a particular sketch? _ incorporate new preproc _ https://github.com/fjenett/processing-preprocessor-antlr4 -_ glw? lwjgl? +_ glw? lwjgl? retina jogl? _ move sketchbook into its own window _ move recent into the sketchbook menu _ needs to recognize the p5 app folder From b92dec014839d966d9b2826c16fac334458d0c16 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 12:46:41 -0400 Subject: [PATCH 23/44] todo notes and minor tweak --- core/src/processing/core/PImage.java | 2 +- core/todo.txt | 11 ++++++++++ todo.txt | 30 ++++++++++++---------------- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/core/src/processing/core/PImage.java b/core/src/processing/core/PImage.java index ed17683d7..94be0a2e2 100644 --- a/core/src/processing/core/PImage.java +++ b/core/src/processing/core/PImage.java @@ -289,7 +289,7 @@ public class PImage implements PConstants, Cloneable { format = ARGB; } else if (type == BufferedImage.TYPE_INT_RGB) { for (int i = 0; i < pixels.length; i++) { - pixels[i] = (255 << 24) | pixels[i]; + pixels[i] = 0xFF000000 | pixels[i]; } } diff --git a/core/todo.txt b/core/todo.txt index 38845f051..116c23d80 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -2,6 +2,11 @@ X add copy() method to Table X return null from getString() on NaN float and double values X affects how saveTable() works (writes blank entries instead of NaN) +X get(5) with an empty Int/Float/StringList was returning 0 +X https://github.com/processing/processing/pull/2343 +X PImage resize() causes images to not draw +X https://github.com/processing/processing/issues/2228 +X https://github.com/processing/processing/pull/2324 _ need a better method for "missing" data in Table _ if missing int is zero, can't just remove those values from saving a table @@ -14,6 +19,8 @@ X https://github.com/processing/processing/issues/169 X http://code.google.com/p/processing/issues/detail?id=130 X https://github.com/processing/processing/pull/2659 X done with an approximation, if re-saving this will destroy data (docs) +X fix typo in StringList.insert() +X https://github.com/processing/processing/pull/2672 applet removal @@ -26,6 +33,10 @@ _ on FloatDict it was NaN, check across the lists and other dict types _ StringDict should always put NaN values at the end on sort _ same for the other list and dict classes _ (this is part of the point of having these easier versions) +_ get() methods in List/Dict shouldn't allow you to get bad values +_ but set() methods can automatically resize the arrays +_ though that means insert() should allow you to insert past the end +_ should we allow negative indices so that we can work relative to the end? _ better full screen mode for OS X _ https://github.com/processing/processing/issues/2641 diff --git a/todo.txt b/todo.txt index b1cb03c8a..9eb26a4fc 100644 --- a/todo.txt +++ b/todo.txt @@ -7,13 +7,21 @@ X fix "No such file or directory" error when exporting an application on OSX X this also resulted in the application not being signed at all X https://github.com/processing/processing/issues/2614 X this is a fairly major issue... -X user opens non-main pde of already open sketch, it'll open again +X possible to open a sketch multiple times +X by double-clicking one of its files instead of the main pde file +X user opens non-main pde of already open sketch, it'll open again X https://github.com/processing/processing/issues/2506 gsoc X clear status messages in the Contribution Manager X https://github.com/processing/processing/pull/2667 X https://github.com/processing/processing/issues/2599 +X may need a progress bar for "save as" +X or just the file copy function in general +X since it may take a long time (i.e. 1000s of screen grabs) +X http://code.google.com/p/processing/issues/detail?id=31 +X https://github.com/processing/processing/issues/70 +X https://github.com/processing/processing/pull/2370 pulls X insert tabs properly when prefs set for tabs mode @@ -34,6 +42,9 @@ X moving p5 examples to the web repo X remove reference.zip from main repo +_ huge i18n patch +_ https://github.com/processing/processing/pull/2084 + _ add a new pref for the 3.0 sketchbook location _ fix the build scripts to include the examples _ https://github.com/processing/processing/issues/2652 @@ -66,10 +77,7 @@ _ make reference and examples build process part of dist _ separate ant targets, but only require them for dist _ as separate targets, folks can build explicitly if they'd like -_ huge i18n patch -_ https://github.com/processing/processing/pull/2084 - -gsoc +gsoc/help me _ `return` keyword not treated as such when followed by a bracket _ https://github.com/processing/processing/issues/2099 _ IllegalArgumentException when clicking between editor windows @@ -82,9 +90,6 @@ _ closing the color selector makes things freeze (only Linux and Windows?) _ https://github.com/processing/processing/issues/2381 medium -_ possible to open a sketch multiple times -_ by double-clicking one of its files instead of the main pde file -_ https://github.com/processing/processing/issues/2506 _ check on why 2x core.jar inside the Java folder _ maybe OS X Java can't look in subfolders? (just auto-adds things) _ display "1" is not correct in 2.1.2 @@ -133,15 +138,6 @@ _ PDE and sketches are 2x smaller on high-res Windows 8 machines _ https://github.com/processing/processing/issues/2411 -pulls -_ may need a progress bar for "save as" -_ or just the file copy function in general -_ since it may take a long time (i.e. 1000s of screen grabs) -_ http://code.google.com/p/processing/issues/detail?id=31 -_ https://github.com/processing/processing/issues/70 -_ https://github.com/processing/processing/pull/2370 - - post 2.1 cleaning _ remove the prefs for 32/64-bit from Preferences _ remove the extra OS X cruft inside Runner.java From 8d532f8569627a735b609f46953a15d4fab86dd0 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 15:29:08 -0400 Subject: [PATCH 24/44] switch to OS X native full screen (fixes #2641) and remove native code for hiding menubar --- build/macosx/jAppleMenuBar.url | 2 - core/src/japplemenubar/JAppleMenuBar.java | 88 ------------------- core/src/processing/core/PApplet.java | 102 ++++++++++++++-------- core/todo.txt | 3 + todo.txt | 8 ++ 5 files changed, 77 insertions(+), 126 deletions(-) delete mode 100644 build/macosx/jAppleMenuBar.url delete mode 100755 core/src/japplemenubar/JAppleMenuBar.java diff --git a/build/macosx/jAppleMenuBar.url b/build/macosx/jAppleMenuBar.url deleted file mode 100644 index 62dc0f635..000000000 --- a/build/macosx/jAppleMenuBar.url +++ /dev/null @@ -1,2 +0,0 @@ -[InternetShortcut] -URL=https://github.com/kritzikratzi/jAppleMenuBar diff --git a/core/src/japplemenubar/JAppleMenuBar.java b/core/src/japplemenubar/JAppleMenuBar.java deleted file mode 100755 index 148eed94d..000000000 --- a/core/src/japplemenubar/JAppleMenuBar.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2011-12 hansi raber, released under LGPL under agreement - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation, version 2.1. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA -*/ -package japplemenubar; - -import java.io.*; - -import processing.core.PApplet; - - -/** - * Starting point for the application. General initialization should be done - * inside the ApplicationController's init() method. If certain kinds of - * non-Swing initialization takes too long, it should happen in a new Thread - * and off the Swing event dispatch thread (EDT). - * - * @author hansi - */ -public class JAppleMenuBar { - static JAppleMenuBar instance; - static final String FILENAME = "libjAppleMenuBar.jnilib"; - - static { - try { - File temp = File.createTempFile("processing", "menubar"); - temp.delete(); // remove the file itself - temp.mkdirs(); // create a directory out of it - temp.deleteOnExit(); - - File jnilibFile = new File(temp, FILENAME); - InputStream input = JAppleMenuBar.class.getResourceAsStream(FILENAME); - if (input != null) { - if (PApplet.saveStream(jnilibFile, input)) { - System.load(jnilibFile.getAbsolutePath()); - instance = new JAppleMenuBar(); - - } else { - sadness("Problem saving " + FILENAME + " for full screen use."); - } - } else { - sadness("Could not load " + FILENAME + " from core.jar"); - } - } catch (IOException e) { - sadness("Unknown error, here's the stack trace."); - e.printStackTrace(); - } - } - - - static void sadness(String msg) { - System.err.println("Full screen mode disabled. " + msg); - } - - -// static public void show() { -// instance.setVisible(true); -// } - - - static public void hide() { - instance.setVisible(false, false); - } - - - public native void setVisible(boolean visibility, boolean kioskMode); - - -// public void setVisible(boolean visibility) { -// // Keep original API in-tact. Default kiosk-mode to off. -// setVisible(visibility, false); -// } -} diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index edc1a1960..0cb8b3a66 100755 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -10410,25 +10410,6 @@ public class PApplet extends Applet } -// /** -// * GIF image of the Processing logo. -// */ -// static public final byte[] ICON_IMAGE = { -// 71, 73, 70, 56, 57, 97, 16, 0, 16, 0, -77, 0, 0, 0, 0, 0, -1, -1, -1, 12, -// 12, 13, -15, -15, -14, 45, 57, 74, 54, 80, 111, 47, 71, 97, 62, 88, 117, -// 1, 14, 27, 7, 41, 73, 15, 52, 85, 2, 31, 55, 4, 54, 94, 18, 69, 109, 37, -// 87, 126, -1, -1, -1, 33, -7, 4, 1, 0, 0, 15, 0, 44, 0, 0, 0, 0, 16, 0, 16, -// 0, 0, 4, 122, -16, -107, 114, -86, -67, 83, 30, -42, 26, -17, -100, -45, -// 56, -57, -108, 48, 40, 122, -90, 104, 67, -91, -51, 32, -53, 77, -78, -100, -// 47, -86, 12, 76, -110, -20, -74, -101, 97, -93, 27, 40, 20, -65, 65, 48, -// -111, 99, -20, -112, -117, -123, -47, -105, 24, 114, -112, 74, 69, 84, 25, -// 93, 88, -75, 9, 46, 2, 49, 88, -116, -67, 7, -19, -83, 60, 38, 3, -34, 2, -// 66, -95, 27, -98, 13, 4, -17, 55, 33, 109, 11, 11, -2, -128, 121, 123, 62, -// 91, 120, -128, 127, 122, 115, 102, 2, 119, 0, -116, -113, -119, 6, 102, -// 121, -108, -126, 5, 18, 6, 4, -102, -101, -100, 114, 15, 17, 0, 59 -// }; - - static ArrayList iconImages; protected void setIconImage(Frame frame) { @@ -10457,18 +10438,46 @@ public class PApplet extends Applet } - // Not gonna do this dynamically, only on startup. Too much headache. -// public void fullscreen() { -// if (frame != null) { -// if (PApplet.platform == MACOSX) { -// japplemenubar.JAppleMenuBar.hide(); -// } -// GraphicsConfiguration gc = frame.getGraphicsConfiguration(); -// Rectangle rect = gc.getBounds(); -//// GraphicsDevice device = gc.getDevice(); -// frame.setBounds(rect.x, rect.y, rect.width, rect.height); -// } -// } + /** + * Use reflection to call + * com.apple.eawt.FullScreenUtilities.setWindowCanFullScreen(window, true); + */ + static private void macosxFullScreenEnable(Window window) { + try { + Class util = Class.forName("com.apple.eawt.FullScreenUtilities"); + Class params[] = new Class[] { Window.class, Boolean.TYPE }; + Method method = util.getMethod("setWindowCanFullScreen", params); + method.invoke(util, window, true); + + } catch (ClassNotFoundException cnfe) { + // ignored + } catch (Exception e) { + e.printStackTrace(); + } + } + + + /** + * Use reflection to call + * com.apple.eawt.Application.getApplication().requestToggleFullScreen(window); + */ + static private void macosxFullScreenToggle(Window window) { + try { + Class appClass = Class.forName("com.apple.eawt.Application"); + + Method getAppMethod = appClass.getMethod("getApplication"); + Object app = getAppMethod.invoke(null, new Object[0]); + + Method requestMethod = + appClass.getMethod("requestToggleFullScreen", Window.class); + requestMethod.invoke(app, window); + + } catch (ClassNotFoundException cnfe) { + // ignored + } catch (Exception e) { + e.printStackTrace(); + } + } /** @@ -10868,11 +10877,21 @@ public class PApplet extends Applet // // or cmd/ctrl-shift-R in the PDE. if (present) { - if (platform == MACOSX) { - // Call some native code to remove the menu bar on OS X. Not necessary - // on Linux and Windows, who are happy to make full screen windows. - japplemenubar.JAppleMenuBar.hide(); - } +// if (platform == MACOSX) { +// println("before"); +// println(screenRect); +// println(frame.getBounds()); +// +// // Call some native code to remove the menu bar on OS X. Not necessary +// // on Linux and Windows, who are happy to make full screen windows. +//// japplemenubar.JAppleMenuBar.hide(); +// toggleFullScreen(frame); +// println("after"); +// println(screenRect); +// println(frame.getBounds()); +// +// println(applet.width + " " + applet.height); +// } // After the pack(), the screen bounds are gonna be 0s frame.setBounds(screenRect); @@ -10880,6 +10899,17 @@ public class PApplet extends Applet (screenRect.height - applet.height) / 2, applet.width, applet.height); + if (platform == MACOSX) { + macosxFullScreenEnable(frame); + macosxFullScreenToggle(frame); + +// toggleFullScreen(frame); +// println("after"); +// println(screenRect); +// println(frame.getBounds()); +// println(applet.width + " " + applet.height); + } + if (!hideStop) { Label label = new Label("stop"); label.setForeground(stopColor); diff --git a/core/todo.txt b/core/todo.txt index 116c23d80..21c48b082 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -7,6 +7,9 @@ X https://github.com/processing/processing/pull/2343 X PImage resize() causes images to not draw X https://github.com/processing/processing/issues/2228 X https://github.com/processing/processing/pull/2324 +X move to native OS X full screen (gets rid of native code) +X https://github.com/processing/processing/issues/2641 +_ sometimes causes placement to temporarily be in the wrong spot _ need a better method for "missing" data in Table _ if missing int is zero, can't just remove those values from saving a table diff --git a/todo.txt b/todo.txt index 9eb26a4fc..fee146299 100644 --- a/todo.txt +++ b/todo.txt @@ -41,6 +41,14 @@ o https://github.com/processing/processing/issues/2639 X moving p5 examples to the web repo X remove reference.zip from main repo +_ SOCKS proxy not working: +_ https://github.com/processing/processing/issues/2643 +_ detect proxy settings? +_ old issue: https://github.com/processing/processing/issues/1476 +_ http://docs.oracle.com/javase/7/docs/technotes/guides/net/proxies.html +_ http://docs.oracle.com/javase/1.5.0/docs/guide/net/proxies.html +_ http://stackoverflow.com/questions/4933677/detecting-windows-ie-proxy-setting-using-java +_ http://www.java2s.com/Code/Java/Network-Protocol/DetectProxySettingsforInternetConnection.htm _ huge i18n patch _ https://github.com/processing/processing/pull/2084 From ad6430b988f963eacb876e3980be813e6854ef67 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 15:52:53 -0400 Subject: [PATCH 25/44] clean up prefs, remove old 32/64-bit stuff from OS X --- app/src/processing/app/Preferences.java | 244 +----------------- .../processing/mode/java/runner/Runner.java | 214 --------------- core/todo.txt | 45 ++-- todo.txt | 27 +- 4 files changed, 41 insertions(+), 489 deletions(-) diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index 77343774e..e8ae91d75 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -117,7 +117,6 @@ public class Preferences { JCheckBox memoryOverrideBox; JTextField memoryField; JCheckBox checkUpdatesBox; - //JTextField fontSizeField; JComboBox fontSizeField; JComboBox consoleSizeField; JCheckBox inputMethodBox; @@ -131,13 +130,9 @@ public class Preferences { JCheckBox importSuggestionsBox; JCheckBox codeCompletionTriggerBox; - //JRadioButton bitsThirtyTwoButton; - //JRadioButton bitsSixtyFourButton; - JComboBox displaySelectionBox; int displayCount; - //Font[] monoFontList; String[] monoFontFamilies; JComboBox fontSelectionBox; @@ -168,16 +163,6 @@ public class Preferences { // check for platform-specific properties in the defaults String platformExt = "." + PConstants.platformNames[PApplet.platform]; //$NON-NLS-1$ int platformExtLength = platformExt.length(); -// Enumeration e = table.keys(); -// while (e.hasMoreElements()) { -// String key = (String) e.nextElement(); -// if (key.endsWith(platformExt)) { -// // this is a key specific to a particular platform -// String actualKey = key.substring(0, key.length() - platformExtLength); -// String value = get(key); -// table.put(actualKey, value); -// } -// } // Get a list of keys that are specific to this platform ArrayList platformKeys = new ArrayList(); @@ -201,17 +186,6 @@ public class Preferences { // other things that have to be set explicitly for the defaults setColor("run.window.bgcolor", SystemColor.control); //$NON-NLS-1$ - // Load a prefs file if specified on the command line -// if (commandLinePrefs != null) { -// try { -// load(new FileInputStream(commandLinePrefs)); -// -// } catch (Exception poe) { -// Base.showError("Error", -// "Could not read preferences from " + -// commandLinePrefs, poe); -// } -// } else if (!Base.isCommandLine()) { // next load user preferences file preferencesFile = Base.getSettingsFile(PREFS_FILE); if (!preferencesFile.exists()) { @@ -232,7 +206,6 @@ public class Preferences { preferencesFile.getAbsolutePath() + " and restart Processing.", ex); } -// } } PApplet.useNativeSelect = @@ -257,11 +230,6 @@ public class Preferences { dialog = new JFrame("Preferences"); dialog.setResizable(false); -// GroupLayout layout = new GroupLayout(getContentPane()); -// dialog.getContentPane().setLayout(layout); -// layout.setAutoCreateGaps(true); -// layout.setAutoCreateContainerGaps(true); - Container pain = dialog.getContentPane(); pain.setLayout(null); @@ -296,11 +264,6 @@ public class Preferences { PApplet.selectFolder("Select new sketchbook location", "sketchbookCallback", dflt, Preferences.this, dialog); -// File file = -// Base.selectFolder("Select new sketchbook location", dflt, dialog); -// if (file != null) { -// sketchbookLocationField.setText(file.getAbsolutePath()); -// } } }); pain.add(button); @@ -357,12 +320,9 @@ public class Preferences { label = new JLabel("Editor font size: "); box.add(label); - //fontSizeField = new JTextField(4); fontSizeField = new JComboBox(FONT_SIZES); fontSizeField.setEditable(true); box.add(fontSizeField); -// label = new JLabel(" (requires restart of Processing)"); -// box.add(label); box.add(Box.createHorizontalStrut(GUI_BETWEEN)); label = new JLabel("Console font size: "); @@ -374,9 +334,6 @@ public class Preferences { pain.add(box); d = box.getPreferredSize(); box.setBounds(left, top, d.width, d.height); -// Font editorFont = Preferences.getFont("editor.font"); - //fontSizeField.setText(String.valueOf(editorFont.getSize())); -// fontSizeField.setSelectedItem(editorFont.getSize()); fontSizeField.setSelectedItem(Preferences.getFont("editor.font.size")); top += d.height + GUI_BETWEEN; @@ -509,8 +466,6 @@ public class Preferences { // [ ] Use smooth text in editor window editorAntialiasBox = new JCheckBox("Use smooth text in editor window"); -// new JCheckBox("Use smooth text in editor window " + -// "(requires restart of Processing)"); pain.add(editorAntialiasBox); d = editorAntialiasBox.getPreferredSize(); // adding +10 because ubuntu + jre 1.5 truncating items @@ -585,19 +540,6 @@ public class Preferences { top += d.height + GUI_BETWEEN; -// // [ ] Use multiple .jar files when exporting applets -// -// exportSeparateBox = -// new JCheckBox("Use multiple .jar files when exporting applets " + -// "(ignored when using libraries)"); -// pain.add(exportSeparateBox); -// d = exportSeparateBox.getPreferredSize(); -// // adding +10 because ubuntu + jre 1.5 truncating items -// exportSeparateBox.setBounds(left, top, d.width + 10, d.height); -// right = Math.max(right, left + d.width); -// top += d.height + GUI_BETWEEN; - - // [ ] Delete previous application folder on export deletePreviousBox = @@ -609,17 +551,7 @@ public class Preferences { top += d.height + GUI_BETWEEN; -// // [ ] Use external editor -// -// externalEditorBox = new JCheckBox("Use external editor"); -// pain.add(externalEditorBox); -// d = externalEditorBox.getPreferredSize(); -// externalEditorBox.setBounds(left, top, d.width + 10, d.height); -// right = Math.max(right, left + d.width); -// top += d.height + GUI_BETWEEN; - - - // [ ] Use external editor + // [ ] Hide tab/toolbar background image whinyBox = new JCheckBox("Hide tab/toolbar background image (requires restart)"); pain.add(whinyBox); @@ -672,30 +604,6 @@ public class Preferences { } - // Launch programs as [ ] 32-bit [ ] 64-bit (Mac OS X only) - - /* - if (Base.isMacOS()) { - box = Box.createHorizontalBox(); - label = new JLabel("Launch programs in "); - box.add(label); - bitsThirtyTwoButton = new JRadioButton("32-bit mode "); - box.add(bitsThirtyTwoButton); - bitsSixtyFourButton = new JRadioButton("64-bit mode"); - box.add(bitsSixtyFourButton); - - ButtonGroup bg = new ButtonGroup(); - bg.add(bitsThirtyTwoButton); - bg.add(bitsSixtyFourButton); - - pain.add(box); - d = box.getPreferredSize(); - box.setBounds(left, top, d.width, d.height); - top += d.height + GUI_BETWEEN; - } - */ - - // More preferences are in the ... label = new JLabel("More preferences can be edited directly in the file"); @@ -889,52 +797,12 @@ public class Preferences { System.err.println("Ignoring bad memory setting"); } - /* - // was gonna use this to check memory settings, - // but it quickly gets much too messy - if (getBoolean("run.options.memory")) { - Process process = Runtime.getRuntime().exec(new String[] { - "java", "-Xms" + memoryMin + "m", "-Xmx" + memoryMax + "m" - }); - processInput = new SystemOutSiphon(process.getInputStream()); - processError = new MessageSiphon(process.getErrorStream(), this); - } - */ - - /* - // If a change has been made between 32- and 64-bit, the libraries need - // to be reloaded so that their native paths are set correctly. - if (Base.isMacOS()) { - String oldBits = get("run.options.bits"); //$NON-NLS-1$ - String newBits = bitsThirtyTwoButton.isSelected() ? "32" : "64"; //$NON-NLS-1$ //$NON-NLS-2$ - if (!oldBits.equals(newBits)) { - set("run.options.bits", newBits); //$NON-NLS-1$ - for (Mode m : base.getModeList()) { - m.rebuildLibraryList(); - } - } - } - */ - // Don't change anything if the user closes the window before fonts load if (fontSelectionBox.isEnabled()) { String fontFamily = (String) fontSelectionBox.getSelectedItem(); set("editor.font.family", fontFamily); } - /* - String newSizeText = fontSizeField.getText(); - try { - int newSize = Integer.parseInt(newSizeText.trim()); - //String pieces[] = PApplet.split(get("editor.font"), ','); //$NON-NLS-1$ - //pieces[2] = String.valueOf(newSize); - //set("editor.font", PApplet.join(pieces, ',')); //$NON-NLS-1$ - set("editor.font.size", String.valueOf(newSize)); - - } catch (Exception e) { - Base.log("Ignoring invalid font size " + newSizeText); //$NON-NLS-1$ - } - */ try { Object selection = fontSizeField.getSelectedItem(); if (selection instanceof String) { @@ -988,23 +856,11 @@ public class Preferences { warningsCheckerBox.setSelected(getBoolean("pdex.warningsEnabled")); codeCompletionBox.setSelected(getBoolean("pdex.ccEnabled")); codeCompletionTriggerBox.setSelected(getBoolean("pdex.ccTriggerEnabled")); - // set all settings entry boxes to their actual status -// exportSeparateBox. -// setSelected(getBoolean("export.applet.separate_jar_files")); deletePreviousBox. setSelected(getBoolean("export.delete_target_folder")); //$NON-NLS-1$ - //closingLastQuitsBox. - // setSelected(getBoolean("sketchbook.closing_last_window_quits")); - //sketchPromptBox. - // setSelected(getBoolean("sketchbook.prompt")); - //sketchCleanBox. - // setSelected(getBoolean("sketchbook.auto_clean")); - sketchbookLocationField. setText(get("sketchbook.path")); //$NON-NLS-1$ -// externalEditorBox. -// setSelected(getBoolean("editor.external")); checkUpdatesBox. setSelected(getBoolean("update.check")); //$NON-NLS-1$ @@ -1013,9 +869,7 @@ public class Preferences { updateDisplayList(); int displayNum = getInteger("run.display"); //$NON-NLS-1$ -// System.out.println("display is " + displayNum + ", d count is " + displayCount); if (displayNum >= 0 && displayNum < displayCount) { -// System.out.println("setting num to " + displayNum); displaySelectionBox.setSelectedIndex(displayNum); } @@ -1037,22 +891,6 @@ public class Preferences { memoryField. setText(get("run.options.memory.maximum")); //$NON-NLS-1$ - /* - if (Base.isMacOS()) { - String bits = Preferences.get("run.options.bits"); //$NON-NLS-1$ - if (bits.equals("32")) { //$NON-NLS-1$ - bitsThirtyTwoButton.setSelected(true); - } else if (bits.equals("64")) { //$NON-NLS-1$ - bitsSixtyFourButton.setSelected(true); - } - // in case we go back and support OS X 10.5... - if (System.getProperty("os.version").startsWith("10.5")) { //$NON-NLS-1$ //$NON-NLS-2$ - bitsSixtyFourButton.setSelected(true); - bitsThirtyTwoButton.setEnabled(false); - } - } - */ - if (autoAssociateBox != null) { autoAssociateBox. setSelected(getBoolean("platform.auto_file_type_associations")); //$NON-NLS-1$ @@ -1080,37 +918,11 @@ public class Preferences { void initFontList() { - /* - if (monoFontList == null) { - monoFontList = Toolkit.getMonoFontList().toArray(new Font[0]); - fontSelectionBox.setModel(new DefaultComboBoxModel(monoFontList)); - fontSelectionBox.setRenderer(new FontNamer()); - - // Preferred size just makes it extend to the container - //fontSelectionBox.setSize(fontSelectionBox.getPreferredSize()); - // Minimum size is better, but cuts things off (on OS X), so we add 20 - //Dimension minSize = fontSelectionBox.getMinimumSize(); - //Dimension minSize = fontSelectionBox.getPreferredSize(); - //fontSelectionBox.setSize(minSize.width + 20, minSize.height); - fontSelectionBox.setEnabled(true); - } - */ if (monoFontFamilies == null) { monoFontFamilies = Toolkit.getMonoFontFamilies(); fontSelectionBox.setModel(new DefaultComboBoxModel(monoFontFamilies)); String family = get("editor.font.family"); -// System.out.println("family is " + family); -// System.out.println("font sel items = " + fontSelectionBox.getItemCount()); -// for (int i = 0; i < fontSelectionBox.getItemCount(); i++) { -// String item = (String) fontSelectionBox.getItemAt(i); -// if (fontSelectionBox.getItemAt(i) == family) { -// System.out.println("found at index " + i); -// } else if (item.equals(family)) { -// System.out.println("equals at index " + i); -// } else { -// System.out.println("nothing doing: " + item); -// } -// } + // Set a reasonable default, in case selecting the family fails fontSelectionBox.setSelectedItem("Monospaced"); fontSelectionBox.setSelectedItem(family); @@ -1134,22 +946,6 @@ public class Preferences { } - // Workaround for Apple bullsh*t caused by their not releasing a 32-bit - // version of Java for Mac OS X 10.5. -// static public String checkBits() { -// String bits = Preferences.get("run.options.bits"); -// if (bits == null) { -// if (System.getProperty("os.version").startsWith("10.5")) { -// bits = "64"; -// } else { -// bits = "32"; -// } -// Preferences.set("run.options.bits", bits); -// } -// return bits; -// } - - // ................................................................. @@ -1208,20 +1004,8 @@ public class Preferences { // all the information from preferences.txt - //static public String get(String attribute) { - //return get(attribute, null); - //} - static public String get(String attribute /*, String defaultValue */) { return table.get(attribute); - /* - //String value = (properties != null) ? - //properties.getProperty(attribute) : applet.getParameter(attribute); - String value = properties.getProperty(attribute); - - return (value == null) ? - defaultValue : value; - */ } @@ -1359,28 +1143,4 @@ public class Preferences { } return new Font("Dialog", Font.PLAIN, 12); } - - - /* - static public SyntaxStyle getStyle(String what) { - String str = get("editor." + what + ".style"); //, dflt); //$NON-NLS-1$ //$NON-NLS-2$ - - StringTokenizer st = new StringTokenizer(str, ","); //$NON-NLS-1$ - - String s = st.nextToken(); - if (s.indexOf("#") == 0) s = s.substring(1); //$NON-NLS-1$ - Color color = Color.DARK_GRAY; - try { - color = new Color(Integer.parseInt(s, 16)); - } catch (Exception e) { } - - s = st.nextToken(); - boolean bold = (s.indexOf("bold") != -1); //$NON-NLS-1$ -// boolean italic = (s.indexOf("italic") != -1); //$NON-NLS-1$ - //System.out.println(what + " = " + str + " " + bold + " " + italic); - -// return new SyntaxStyle(color, italic, bold); - return new SyntaxStyle(color, bold); - } - */ } diff --git a/app/src/processing/mode/java/runner/Runner.java b/app/src/processing/mode/java/runner/Runner.java index 8812627c9..4fbf5f8f1 100644 --- a/app/src/processing/mode/java/runner/Runner.java +++ b/app/src/processing/mode/java/runner/Runner.java @@ -63,19 +63,6 @@ public class Runner implements MessageConsumer { // Thread transferring remote output stream to our output stream protected Thread outThread = null; - // Mode for tracing the Trace program (default= 0 off) -// protected int debugTraceMode = 0; - - // Do we want to watch assignments to fields -// protected boolean watchFields = false; - -// // Class patterns for which we don't want events -// protected String[] excludes = { -// "java.*", "javax.*", "sun.*", "com.sun.*", -// "apple.*", -// "processing.*" -// }; - protected SketchException exception; protected Editor editor; protected JavaBuild build; @@ -138,60 +125,6 @@ public class Runner implements MessageConsumer { // Everyone works the same under Java 7 (also on OS X) String[] commandArgs = new String[] { Base.getJavaPath(), jdwpArg }; - /* - String[] commandArgs = null; - if (!Base.isMacOS()) { - commandArgs = new String[] { - Base.getJavaPath(), - jdwpArg - }; - } else { - // Decided to just set this to 1.6 only, because otherwise it's gonna - // be a shitshow if folks are getting Apple's 1.6 with 32-bit and - // Oracle's 1.7 when run in 64-bit mode. ("Why does my sketch suck in - // 64-bit? Why is retina broken?) - // The --request flag will prompt to install Apple's 1.6 JVM if none is - // available. We're specifying 1.6 so that we can get support for both - // 32- and 64-bit, because Oracle won't be releasing Java 1.7 in 32-bit. - // Helpfully, the --request flag is not present on Mac OS X 10.6 - // (luckily it is also not needed, because 1.6 is installed by default) - // but it requires an additional workaround to not use that flag, - // otherwise will see an error about an unsupported option. The flag is - // available with 10.7 and 10.8, the only other supported versions of - // OS X at this point, because we require 10.6.8 and higher. That also - // means we don't need to check for any other OS versions, the user is - // a douchebag and modifies Info.plist to get around the restriction. - if (false) { - if (System.getProperty("os.version").startsWith("10.6")) { - commandArgs = new String[] { - "/usr/libexec/java_home", - "--version", "1.6", - "--exec", "java", - "-d" + Base.getNativeBits(), - jdwpArg - }; - } else { // for 10.7, 10.8, etc - commandArgs = new String[] { - "/usr/libexec/java_home", - "--request", // install on-demand - "--version", "1.6", - "--exec", "java", - "-d" + Base.getNativeBits(), -// debugArg, - jdwpArg - }; - } - } else { - // testing jdk-7u40 - commandArgs = new String[] { - //"/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/bin/java", - Base.getJavaPath(), - jdwpArg - }; - } - } - */ - commandArgs = PApplet.concat(commandArgs, vmParams); commandArgs = PApplet.concat(commandArgs, sketchParams); // PApplet.println(commandArgs); @@ -482,153 +415,6 @@ public class Runner implements MessageConsumer { } - /* - protected VirtualMachine launchVirtualMachine(String[] vmParams, - String[] classParams) { - //vm = launchTarget(sb.toString()); - LaunchingConnector connector = (LaunchingConnector) - findConnector("com.sun.jdi.RawCommandLineLaunch"); - //PApplet.println(connector); // gets the defaults - - //Map arguments = connectorArguments(connector, mainArgs); - Map arguments = connector.defaultArguments(); - - Connector.Argument commandArg = - (Connector.Argument)arguments.get("command"); - // Using localhost instead of 127.0.0.1 sometimes causes a - // "Transport Error 202" error message when trying to run. - // http://dev.processing.org/bugs/show_bug.cgi?id=895 - // String addr = "127.0.0.1:" + (8000 + (int) (Math.random() * 1000)); - //String addr = "localhost:" + (8000 + (int) (Math.random() * 1000)); - // Better yet, host is not needed, so using just the port for the address - String addr = "" + (8000 + (int) (Math.random() * 1000)); - - String commandArgs = - "java -Xrunjdwp:transport=dt_socket,address=" + addr + ",suspend=y "; - if (Base.isMacOS()) { - // Decided to just set this to 1.6 only, because otherwise it's gonna - // be a shitshow if folks are getting Apple's 1.6 with 32-bit and - // Oracle's 1.7 when run in 64-bit mode. ("Why does my sketch suck in - // 64-bit? Why is retina broken?) - // The --request flag will prompt to install Apple's 1.6 JVM if none is - // available. We're specifying 1.6 so that we can get support for both - // 32- and 64-bit, because Oracle won't be releasing Java 1.7 in 32-bit. - // Helpfully, the --request flag is not present on Mac OS X 10.6 - // (luckily it is also not needed, because 1.6 is installed by default) - // but it requires an additional workaround to not use that flag, - // otherwise will see an error about an unsupported option. The flag is - // available with 10.7 and 10.8, the only other supported versions of - // OS X at this point, because we require 10.6.8 and higher. That also - // means we don't need to check for any other OS versions, unless - // is a douchebag and modifies Info.plist to get around the restriction. - addr = "" + (8000 + (int) (Math.random() * 1000)); - commandArgs = - "/usr/libexec/java_home " + - (System.getProperty("os.version").startsWith("10.6") ? "" : "--request ") + - "--version 1.6 " + - "--exec java " + - "-d" + Base.getNativeBits() + " " + - "-Xrunjdwp:transport=dt_socket,address=" + addr + ",suspend=y "; - } - - for (int i = 0; i < vmParams.length; i++) { - commandArgs = addArgument(commandArgs, vmParams[i], ' '); - } - if (classParams != null) { - for (int i = 0; i < classParams.length; i++) { - commandArgs = addArgument(commandArgs, classParams[i], ' '); - } - } - System.out.println("commandArgs is " + commandArgs); - commandArg.setValue(commandArgs); - - Connector.Argument addressArg = - (Connector.Argument)arguments.get("address"); - addressArg.setValue(addr); - - //PApplet.println(connector); // prints the current - //com.sun.tools.jdi.AbstractLauncher al; - //com.sun.tools.jdi.RawCommandLineLauncher rcll; - - //System.out.println(PApplet.javaVersion); - // http://java.sun.com/j2se/1.5.0/docs/guide/jpda/conninv.html#sunlaunch - try { - return connector.launch(arguments); - } catch (IOException exc) { - throw new Error("Unable to launch target VM: " + exc); - } catch (IllegalConnectorArgumentsException exc) { - throw new Error("Internal error: " + exc); - } catch (VMStartException exc) { - Process p = exc.process(); - //System.out.println(p); - String[] errorStrings = PApplet.loadStrings(p.getErrorStream()); - //String[] inputStrings = - PApplet.loadStrings(p.getInputStream()); - - if (errorStrings != null && errorStrings.length > 1) { - if (errorStrings[0].indexOf("Invalid maximum heap size") != -1) { - Base.showWarning("Way Too High", - "Please lower the value for \u201Cmaximum available memory\u201D in the\n" + - "Preferences window. For more information, read Help \u2192 Troubleshooting.", - exc); - } else { - PApplet.println(errorStrings); - System.err.println("Using startup command:"); - PApplet.println(arguments); - } - } else { - exc.printStackTrace(); - System.err.println("Could not run the sketch (Target VM failed to initialize)."); - if (Preferences.getBoolean("run.options.memory")) { - // Only mention this if they've even altered the memory setup - System.err.println("Make sure that you haven't set the maximum available memory too high."); - } - System.err.println("For more information, read revisions.txt and Help \u2192 Troubleshooting."); - } - // changing this to separate editor and listener [091124] - //if (editor != null) { - listener.statusError("Could not run the sketch."); - //} - return null; - } - } - - - private static boolean hasWhitespace(String string) { - int length = string.length(); - for (int i = 0; i < length; i++) { - if (Character.isWhitespace(string.charAt(i))) { - return true; - } - } - return false; - } - - - private static String addArgument(String string, String argument, char sep) { - if (hasWhitespace(argument) || argument.indexOf(',') != -1) { - // Quotes were stripped out for this argument, add 'em back. - StringBuffer buffer = new StringBuffer(string); - buffer.append('"'); - for (int i = 0; i < argument.length(); i++) { - char c = argument.charAt(i); - if (c == '"') { - buffer.append('\\'); -// buffer.append("\\\\"); - } - buffer.append(c); - } - buffer.append('"'); - buffer.append(sep); - return buffer.toString(); - - } else { - return string + argument + String.valueOf(sep); - } - } - */ - - /** * Generate the trace. * Enable events, start thread to display events, diff --git a/core/todo.txt b/core/todo.txt index 21c48b082..c7549f51a 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -11,10 +11,6 @@ X move to native OS X full screen (gets rid of native code) X https://github.com/processing/processing/issues/2641 _ sometimes causes placement to temporarily be in the wrong spot -_ need a better method for "missing" data in Table -_ if missing int is zero, can't just remove those values from saving a table -_ but for NaN values, it's a necessity - pulls X implement A and a (elliptical arcs) @@ -30,7 +26,13 @@ applet removal _ remove Applet as base class _ performance issues on OS X (might be threading due to Applet) _ https://github.com/processing/processing/issues/2423 +_ play with improvements to full screen here + +processing.data +_ need a better method for "missing" data in Table +_ if missing int is zero, can't just remove those values from saving a table +_ but for NaN values, it's a necessity _ fix for maxValue() and minValue() when all entries are bad _ on FloatDict it was NaN, check across the lists and other dict types _ StringDict should always put NaN values at the end on sort @@ -40,11 +42,21 @@ _ get() methods in List/Dict shouldn't allow you to get bad values _ but set() methods can automatically resize the arrays _ though that means insert() should allow you to insert past the end _ should we allow negative indices so that we can work relative to the end? +_ add print() method to other data types (not just IntList) +_ 'collector' class.. Dict that points to a list +_ String as a key, int/float/string list as values +_ addRow() is not efficient, probably need to do the doubling +o or have a setIncrement() function? +_ it would default to 1 on tables loaded from a file +_ and default to doubling when created with "new Table" +_ row count and array size are combined.. need to break apart +_ match and iterators +_ add match version that returns table that's only a pointer to original +_ save the constructor for the version that actually copies data +_ the table pointer version will be speedy and allow chaining -_ better full screen mode for OS X -_ https://github.com/processing/processing/issues/2641 -_ http://stackoverflow.com/questions/6873568/fullscreen-feature-for-java-apps-on-osx-lion +later _ bring back chaining in JSON (and add to XML) _ maybe once we make the PVector change @@ -54,8 +66,6 @@ _ Closing opengl sketch from the PDE doesn't stop java process on windows _ https://github.com/processing/processing/issues/2335 _ StingList.insert() error (should be an easy fix) _ https://github.com/processing/processing/issues/2548 -_ pull for image resize and alpha issues -_ https://github.com/processing/processing/pull/2324 _ dataPath() not working when app is not run from app dir on Linux _ https://github.com/processing/processing/issues/2195 _ "Buffers have not been created" error for sketches w/o draw() @@ -66,6 +76,7 @@ _ some sort of threading issue happening here _ https://github.com/processing/processing/issues/1672 _ https://github.com/processing/processing/issues/2039 (dupe) _ https://github.com/processing/processing/issues/2294 (dupe) +_ also check this out with the new full screen code on OS X _ point() rendering differently in 2.0.3 and 2.1 _ https://github.com/processing/processing/issues/2278 _ internally, we probably have to call set() if it's a 1 pixel point @@ -75,13 +86,10 @@ _ https://github.com/processing/processing/issues/2428 _ default font fixes _ https://github.com/processing/processing/issues/2331 _ https://github.com/processing/processing/pull/2338 -_ add print() method to other data types (not just IntList) _ Sort out blending differences with P2D/P3D _ might be that compatible images not setting alpha mode correctly _ image = gc.createCompatibleVolatileImage(source.width, source.height, Transparency.TRANSLUCENT); _ https://github.com/processing/processing/issues/1844 -_ 'collector' class.. Dict that points to a list -_ String as a key, int/float/string list as values _ add option to have full screen span across screens _ display=all in cmd line _ sketchDisplay() -> 0 for all, or 1, 2, 3... @@ -93,6 +101,7 @@ _ draw(s) doesn't work on the returned PShape _ TGA files writing strangely _ https://github.com/processing/processing/issues/2096 + hidpi _ saveFrame() with retina render is making black images _ zero alpha values still a problem with retina renderer @@ -109,21 +118,13 @@ _ https://github.com/processing/processing/issues/2411 _ retina sketches slow to start _ https://github.com/processing/processing/issues/2357 + cantfix _ crash on startup when "Mirror Displays" selected _ suspect that this is a specific chipset since Oracle didn't reproduce _ https://github.com/processing/processing/issues/2186 +_ test with JG's 13" retina laptop -table -_ addRow() is not efficient, probably need to do the doubling -_ or have a setIncrement() function? -_ it would default to 1 on tables loaded from a file -_ and default to doubling when created with "new Table" -_ row count and array size are combined.. need to break apart -_ match and iterators -_ add match version that returns table that's only a pointer to original -_ save the constructor for the version that actually copies data -_ the table pointer version will be speedy and allow chaining decisions/misc _ make join() work with Iterable? diff --git a/todo.txt b/todo.txt index fee146299..87a8cd030 100644 --- a/todo.txt +++ b/todo.txt @@ -11,6 +11,8 @@ X possible to open a sketch multiple times X by double-clicking one of its files instead of the main pde file X user opens non-main pde of already open sketch, it'll open again X https://github.com/processing/processing/issues/2506 +X remove the prefs for 32/64-bit from Preferences +X also remove the extra OS X cruft inside Runner.java gsoc X clear status messages in the Contribution Manager @@ -41,15 +43,6 @@ o https://github.com/processing/processing/issues/2639 X moving p5 examples to the web repo X remove reference.zip from main repo -_ SOCKS proxy not working: -_ https://github.com/processing/processing/issues/2643 -_ detect proxy settings? -_ old issue: https://github.com/processing/processing/issues/1476 -_ http://docs.oracle.com/javase/7/docs/technotes/guides/net/proxies.html -_ http://docs.oracle.com/javase/1.5.0/docs/guide/net/proxies.html -_ http://stackoverflow.com/questions/4933677/detecting-windows-ie-proxy-setting-using-java -_ http://www.java2s.com/Code/Java/Network-Protocol/DetectProxySettingsforInternetConnection.htm - _ huge i18n patch _ https://github.com/processing/processing/pull/2084 @@ -85,6 +78,7 @@ _ make reference and examples build process part of dist _ separate ant targets, but only require them for dist _ as separate targets, folks can build explicitly if they'd like + gsoc/help me _ `return` keyword not treated as such when followed by a bracket _ https://github.com/processing/processing/issues/2099 @@ -97,6 +91,7 @@ _ https://github.com/processing/processing/issues/2531 _ closing the color selector makes things freeze (only Linux and Windows?) _ https://github.com/processing/processing/issues/2381 + medium _ check on why 2x core.jar inside the Java folder _ maybe OS X Java can't look in subfolders? (just auto-adds things) @@ -146,9 +141,19 @@ _ PDE and sketches are 2x smaller on high-res Windows 8 machines _ https://github.com/processing/processing/issues/2411 +lower +_ SOCKS proxy not working: +_ https://github.com/processing/processing/issues/2643 +_ the code that gets/sets the pref is in Preferences +_ detect proxy settings? +_ old issue: https://github.com/processing/processing/issues/1476 +_ http://docs.oracle.com/javase/7/docs/technotes/guides/net/proxies.html +_ http://docs.oracle.com/javase/1.5.0/docs/guide/net/proxies.html +_ http://stackoverflow.com/questions/4933677/detecting-windows-ie-proxy-setting-using-java +_ http://www.java2s.com/Code/Java/Network-Protocol/DetectProxySettingsforInternetConnection.htm + + post 2.1 cleaning -_ remove the prefs for 32/64-bit from Preferences -_ remove the extra OS X cruft inside Runner.java _ exclude 'fonts' folder from build (since it's going into the JRE) From e279fa2e47bb123ce4a77c44e8f0441a1dafe5ac Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 16:20:52 -0400 Subject: [PATCH 26/44] build cleanups to die when files not present, remove duplicate fonts --- app/src/processing/app/Toolkit.java | 13 +++++-- build/build.xml | 16 +++++---- core/build.xml | 2 ++ todo.txt | 54 ++++++++++++++--------------- 4 files changed, 47 insertions(+), 38 deletions(-) diff --git a/app/src/processing/app/Toolkit.java b/app/src/processing/app/Toolkit.java index 34aa23834..83ead7661 100644 --- a/app/src/processing/app/Toolkit.java +++ b/app/src/processing/app/Toolkit.java @@ -40,8 +40,8 @@ import java.awt.font.TextLayout; import java.awt.geom.AffineTransform; import java.io.BufferedInputStream; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; -import java.io.InputStream; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashSet; @@ -453,9 +453,16 @@ public class Toolkit { } + /** + * Get a font from the JRE lib/fonts folder. Our default fonts are also + * installed there so that the monospace (and others) can be used by other + * font listing calls (i.e. it appears in the list of monospace fonts in + * the Preferences window). + */ static private Font createFont(String filename, int size) throws IOException, FontFormatException { - InputStream is = Base.getLibStream("fonts/" + filename); - BufferedInputStream input = new BufferedInputStream(is); + //InputStream is = Base.getLibStream("fonts/" + filename); + File fontFile = new File(System.getProperty("java.home"), "lib/fonts/" + filename); + BufferedInputStream input = new BufferedInputStream(new FileInputStream(fontFile)); Font font = Font.createFont(Font.TRUETYPE_FONT, input); input.close(); return font.deriveFont((float) size); diff --git a/build/build.xml b/build/build.xml index 9433bf858..016115911 100755 --- a/build/build.xml +++ b/build/build.xml @@ -275,7 +275,7 @@ - + @@ -471,7 +471,7 @@ - + @@ -500,7 +500,7 @@ - + @@ -599,7 +599,7 @@ - + @@ -621,7 +621,7 @@ - + @@ -768,7 +768,7 @@ - + @@ -788,7 +788,7 @@ tofile="${launch4j.dir}/bin/ld.exe" /> - + @@ -949,7 +949,9 @@ remove the spaces for depth since it should be double dash, but screws up commen + diff --git a/core/build.xml b/core/build.xml index 8bb8b3a2c..3d24eae76 100755 --- a/core/build.xml +++ b/core/build.xml @@ -38,8 +38,10 @@ + diff --git a/todo.txt b/todo.txt index 87a8cd030..8959aa7c4 100644 --- a/todo.txt +++ b/todo.txt @@ -13,6 +13,14 @@ X user opens non-main pde of already open sketch, it'll open again X https://github.com/processing/processing/issues/2506 X remove the prefs for 32/64-bit from Preferences X also remove the extra OS X cruft inside Runner.java +X OS X export button not disabled on other platforms +X https://github.com/processing/processing/issues/2642 +o try new syntax package +X exclude 'fonts' folder from build (since it's going into the JRE) +X was storing our fonts in both ./lib/fonts and jre/lib/fonts +X now gets the jre folder and loads from there +X make ant fail when trying to delete JRE files that don't exist +X some aren't being removed properly gsoc X clear status messages in the Contribution Manager @@ -41,42 +49,29 @@ X https://github.com/processing/processing/issues/2141 o double-clicking a .pde file doesn't open properly on OS X o https://github.com/processing/processing/issues/2639 X moving p5 examples to the web repo -X remove reference.zip from main repo - -_ huge i18n patch -_ https://github.com/processing/processing/pull/2084 +X move examples into web repo _ add a new pref for the 3.0 sketchbook location +_ make reference and examples build process part of dist +_ separate ant targets, but only require them for dist +_ as separate targets, folks can build explicitly if they'd like +_ remove reference.zip from main repo _ fix the build scripts to include the examples _ https://github.com/processing/processing/issues/2652 _ all examples are out of "processing/java" and are now in "processing-docs/content/". The Book examples have been removed entirely from our repositories. _ reference wasn't included either _ https://github.com/processing/processing/issues/2656 _ processing-web/java_generate/ReferenceGenerator +_ "Platform is ${platform}" message during 'ant clean' +_ on OS X, but not Windows (haven't checked Linux) -_ make ant fail when trying to delete JRE files that don't exist -_ some aren't being removed properly -_ "Platform is ${platform}" message during 'ant clean' - -_ OS X export button not disabled on other platforms -_ https://github.com/processing/processing/issues/2642 +pending +_ huge i18n patch +_ https://github.com/processing/processing/pull/2084 _ look at the sound library https://github.com/wirsing/ProcessingSound -_ appears that sound is not yet supported on Windows - -_ try new syntax package -_ possibility of libraries folder inside a particular sketch? -_ incorporate new preproc -_ https://github.com/fjenett/processing-preprocessor-antlr4 +_ sound is not yet supported on Windows _ glw? lwjgl? retina jogl? -_ move sketchbook into its own window -_ move recent into the sketchbook menu -_ needs to recognize the p5 app folder -_ also should recognize the user's home dir -_ move examples into web repo -_ make reference and examples build process part of dist -_ separate ant targets, but only require them for dist -_ as separate targets, folks can build explicitly if they'd like gsoc/help me @@ -90,9 +85,16 @@ _ shouldn't write sketch.properties unless it's a non-default mode _ https://github.com/processing/processing/issues/2531 _ closing the color selector makes things freeze (only Linux and Windows?) _ https://github.com/processing/processing/issues/2381 +_ move sketchbook into its own window +_ move recent into the sketchbook menu +_ needs to recognize the p5 app folder +_ also should recognize the user's home dir +_ incorporate new preproc +_ https://github.com/fjenett/processing-preprocessor-antlr4 medium +_ possibility of libraries folder inside a particular sketch? _ check on why 2x core.jar inside the Java folder _ maybe OS X Java can't look in subfolders? (just auto-adds things) _ display "1" is not correct in 2.1.2 @@ -153,10 +155,6 @@ _ http://stackoverflow.com/questions/4933677/detecting-windows-ie-proxy-settin _ http://www.java2s.com/Code/Java/Network-Protocol/DetectProxySettingsforInternetConnection.htm -post 2.1 cleaning -_ exclude 'fonts' folder from build (since it's going into the JRE) - - . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . From e6bfc23741a9d8da84e1327e395eb648baf5be74 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 17:23:18 -0400 Subject: [PATCH 27/44] add examples to the build, remove pdex platform chatter --- build/build.xml | 27 +++++++++++++++------------ pdex/build.xml | 2 +- todo.txt | 13 +++++++------ 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/build/build.xml b/build/build.xml index 016115911..808195bde 100755 --- a/build/build.xml +++ b/build/build.xml @@ -31,6 +31,9 @@ + + @@ -205,6 +208,10 @@ + + + + @@ -229,6 +236,9 @@ + + + @@ -261,23 +271,16 @@ - + - - - - - - + + + + - + diff --git a/todo.txt b/todo.txt index 8959aa7c4..0fa521317 100644 --- a/todo.txt +++ b/todo.txt @@ -21,6 +21,12 @@ X was storing our fonts in both ./lib/fonts and jre/lib/fonts X now gets the jre folder and loads from there X make ant fail when trying to delete JRE files that don't exist X some aren't being removed properly +X fix the build scripts to include the examples +X https://github.com/processing/processing/issues/2652 +X all examples are out of "processing/java" and are now in "processing-docs/content/". The Book examples have been removed entirely from our repositories. +o "Platform is ${platform}" message during 'ant clean' +o on OS X, but not Windows (haven't checked Linux) +X this was in pdex/build.xml gsoc X clear status messages in the Contribution Manager @@ -55,15 +61,10 @@ _ add a new pref for the 3.0 sketchbook location _ make reference and examples build process part of dist _ separate ant targets, but only require them for dist _ as separate targets, folks can build explicitly if they'd like -_ remove reference.zip from main repo -_ fix the build scripts to include the examples -_ https://github.com/processing/processing/issues/2652 -_ all examples are out of "processing/java" and are now in "processing-docs/content/". The Book examples have been removed entirely from our repositories. _ reference wasn't included either _ https://github.com/processing/processing/issues/2656 _ processing-web/java_generate/ReferenceGenerator -_ "Platform is ${platform}" message during 'ant clean' -_ on OS X, but not Windows (haven't checked Linux) +_ remove reference.zip from main repo pending From 62d76f588da861c59554ab100b4d9c72518dfbd7 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 17:25:58 -0400 Subject: [PATCH 28/44] remove welcome chatter; not recommded for libraries, never part of core libs --- java/libraries/sound/src/processing/sound/Engine.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/libraries/sound/src/processing/sound/Engine.java b/java/libraries/sound/src/processing/sound/Engine.java index 51a04a40f..9d03657b9 100644 --- a/java/libraries/sound/src/processing/sound/Engine.java +++ b/java/libraries/sound/src/processing/sound/Engine.java @@ -32,7 +32,7 @@ public class Engine { private static int m_bufferSize=512; private Engine() { - welcome(); + //welcome(); methCla = new MethClaInterface(); methCla.engineNew(m_sampleRate, m_bufferSize); methCla.engineStart(); From d0f9c90c12b701e2e44c3172cc0f1f9aa5d36173 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 18:40:36 -0400 Subject: [PATCH 29/44] add separate preference for 3.0 sketchbook location, other prefs cleanups --- app/src/processing/app/Base.java | 34 +--------- app/src/processing/app/Preferences.java | 89 +++++++++++++++++-------- app/src/processing/app/Sketch.java | 4 +- build/shared/revisions.txt | 10 ++- todo.txt | 40 ++++++----- 5 files changed, 93 insertions(+), 84 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 57d893c88..90b54a103 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -1859,41 +1859,15 @@ public class Base { } -// static public String getExamplesPath() { -// return examplesFolder.getAbsolutePath(); -// } - -// public File getExamplesFolder() { -// return examplesFolder; -// } - - -// static public String getLibrariesPath() { -// return librariesFolder.getAbsolutePath(); -// } - - -// public File getLibrariesFolder() { -// return librariesFolder; -// } - - -// static public File getToolsFolder() { static public File getToolsFolder() { -// return toolsFolder; return getContentFile("tools"); } -// static public String getToolsPath() { -// return toolsFolder.getAbsolutePath(); -// } - - static public void locateSketchbookFolder() { // If a value is at least set, first check to see if the folder exists. // If it doesn't, warn the user that the sketchbook folder is being reset. - String sketchbookPath = Preferences.get("sketchbook.path"); //$NON-NLS-1$ + String sketchbookPath = Preferences.getSketchbookPath(); if (sketchbookPath != null) { sketchbookFolder = new File(sketchbookPath); if (!sketchbookFolder.exists()) { @@ -1910,7 +1884,7 @@ public class Base { // If no path is set, get the default sketchbook folder for this platform if (sketchbookFolder == null) { sketchbookFolder = getDefaultSketchbookFolder(); - Preferences.set("sketchbook.path", sketchbookFolder.getAbsolutePath()); + Preferences.setSketchbookPath(sketchbookFolder.getAbsolutePath()); if (!sketchbookFolder.exists()) { sketchbookFolder.mkdirs(); } @@ -1925,19 +1899,17 @@ public class Base { public void setSketchbookFolder(File folder) { sketchbookFolder = folder; - Preferences.set("sketchbook.path", folder.getAbsolutePath()); + Preferences.setSketchbookPath(folder.getAbsolutePath()); rebuildSketchbookMenus(); } static public File getSketchbookFolder() { -// return new File(Preferences.get("sketchbook.path")); return sketchbookFolder; } static public File getSketchbookLibrariesFolder() { -// return new File(getSketchbookFolder(), "libraries"); return new File(sketchbookFolder, "libraries"); } diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index e8ae91d75..b03a9b991 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -3,7 +3,7 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2004-12 Ben Fry and Casey Reas + Copyright (c) 2004-14 Ben Fry and Casey Reas Copyright (c) 2001-04 Massachusetts Institute of Technology This program is free software; you can redistribute it and/or modify @@ -100,7 +100,7 @@ public class Preferences { // and linux is all over the map static final int GUI_BIG = 13; - static final int GUI_BETWEEN = 10; + static final int GUI_BETWEEN = 8; static final int GUI_SMALL = 6; // gui elements @@ -185,17 +185,10 @@ public class Preferences { // other things that have to be set explicitly for the defaults setColor("run.window.bgcolor", SystemColor.control); //$NON-NLS-1$ - + // next load user preferences file preferencesFile = Base.getSettingsFile(PREFS_FILE); - if (!preferencesFile.exists()) { - // create a new preferences file if none exists - // saves the defaults out to the file - save(); - - } else { - // load the previous preferences file - + if (preferencesFile.exists()) { try { load(new FileInputStream(preferencesFile)); @@ -206,6 +199,12 @@ public class Preferences { preferencesFile.getAbsolutePath() + " and restart Processing.", ex); } + } + + if (checkSketchbookPref() || !preferencesFile.exists()) { + // create a new preferences file if none exists + // saves the defaults out to the file + save(); } PApplet.useNativeSelect = @@ -485,24 +484,25 @@ public class Preferences { right = Math.max(right, left + d.width); top += d.height + GUI_BETWEEN; - // [ ] Enable Error Checking - PDE X + // [ ] Continuously check for errors - PDE X errorCheckerBox = - new JCheckBox("Enable error checking"); + new JCheckBox("Continuously check for errors"); pain.add(errorCheckerBox); d = errorCheckerBox.getPreferredSize(); errorCheckerBox.setBounds(left, top, d.width + 10, d.height); - right = Math.max(right, left + d.width); - top += d.height + GUI_BETWEEN; + //right = Math.max(right, left + d.width); + //top += d.height + GUI_BETWEEN; + int warningLeft = left + d.width; - // [ ] Enable Warnings - PDE X + // [ ] Show Warnings - PDE X warningsCheckerBox = - new JCheckBox("Enable warnings"); + new JCheckBox("Show warnings"); pain.add(warningsCheckerBox); d = warningsCheckerBox.getPreferredSize(); - warningsCheckerBox.setBounds(left, top, d.width + 10, d.height); - right = Math.max(right, left + d.width); + warningsCheckerBox.setBounds(warningLeft, top, d.width + 10, d.height); + right = Math.max(right, warningLeft + d.width); top += d.height + GUI_BETWEEN; // [ ] Enable Code Completion - PDE X @@ -512,17 +512,17 @@ public class Preferences { pain.add(codeCompletionBox); d = codeCompletionBox.getPreferredSize(); codeCompletionBox.setBounds(left, top, d.width + 10, d.height); - right = Math.max(right, left + d.width); - top += d.height + GUI_BETWEEN; + int toggleLeft = left + d.width; // [ ] Toggle Code Completion Trigger - PDE X + final String modifier = Base.isMacOS() ? "\u2318" : "Ctrl"; codeCompletionTriggerBox = - new JCheckBox("Trigger code completion on Ctrl(Cmd) + Space"); + new JCheckBox("Trigger with " + modifier + "-space"); pain.add(codeCompletionTriggerBox); d = codeCompletionTriggerBox.getPreferredSize(); - codeCompletionTriggerBox.setBounds(left, top, d.width + 10, d.height); - right = Math.max(right, left + d.width); + codeCompletionTriggerBox.setBounds(toggleLeft, top, d.width + 10, d.height); + right = Math.max(right, toggleLeft + d.width); top += d.height + GUI_BETWEEN; @@ -762,7 +762,7 @@ public class Preferences { // each platform, and nobody wants to debug/support that. // if the sketchbook path has changed, rebuild the menus - String oldPath = get("sketchbook.path"); //$NON-NLS-1$ + String oldPath = getSketchbookPath(); String newPath = sketchbookLocationField.getText(); if (!newPath.equals(oldPath)) { base.setSketchbookFolder(new File(newPath)); @@ -859,10 +859,8 @@ public class Preferences { deletePreviousBox. setSelected(getBoolean("export.delete_target_folder")); //$NON-NLS-1$ - sketchbookLocationField. - setText(get("sketchbook.path")); //$NON-NLS-1$ - checkUpdatesBox. - setSelected(getBoolean("update.check")); //$NON-NLS-1$ + sketchbookLocationField.setText(getSketchbookPath()); + checkUpdatesBox.setSelected(getBoolean("update.check")); //$NON-NLS-1$ whinyBox.setSelected(getBoolean("header.hide.image") || //$NON-NLS-1$ getBoolean("buttons.hide.image")); //$NON-NLS-1$ @@ -1143,4 +1141,37 @@ public class Preferences { } return new Font("Dialog", Font.PLAIN, 12); } + + + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + + + /** + * Check for a 3.0 sketchbook location, and if none exists, + * try to grab it from the 2.0 sketchbook location. + * @return true if a location was found and the pref didn't exist + */ + static protected boolean checkSketchbookPref() { + // If a 3.0 sketchbook location has never been inited + if (getSketchbookPath() == null) { + String twoPath = get("sketchbook.path"); + // If they've run the 2.0 version, start with that location + if (twoPath != null) { + setSketchbookPath(twoPath); + return true; // save the sketchbook right away + } + // Otherwise it'll be null, and reset properly by Base + } + return false; + } + + + static protected String getSketchbookPath() { + return get("sketchbook.path.three"); //$NON-NLS-1$ + } + + + static protected void setSketchbookPath(String path) { + set("sketchbook.path.three", path); //$NON-NLS-1$ + } } diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 4cfc3f81f..33c803ecc 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -816,7 +816,7 @@ public class Sketch { FileDialog fd = new FileDialog(editor, PROMPT, FileDialog.SAVE); if (isReadOnly() || isUntitled()) { // default to the sketchbook folder - fd.setDirectory(Preferences.get("sketchbook.path")); + fd.setDirectory(Preferences.getSketchbookPath()); } else { // default to the parent folder of where this was fd.setDirectory(folder.getParent()); @@ -831,7 +831,7 @@ public class Sketch { fc.setDialogTitle(PROMPT); if (isReadOnly() || isUntitled()) { // default to the sketchbook folder - fc.setCurrentDirectory(new File(Preferences.get("sketchbook.path"))); + fc.setCurrentDirectory(new File(Preferences.getSketchbookPath())); } else { // default to the parent folder of where this was fc.setCurrentDirectory(folder.getParentFile()); diff --git a/build/shared/revisions.txt b/build/shared/revisions.txt index 30acaafcc..d76ae25ee 100644 --- a/build/shared/revisions.txt +++ b/build/shared/revisions.txt @@ -3,12 +3,20 @@ PROCESSING 3.0a2 (REV 0229) - ?? August 2014 [ fixes ] -+ The Examples and Reference weren't included in 3.0a1. Oops. ++ The Examples weren't included in 3.0a1. Oops. https://github.com/processing/processing/issues/2652 [ changes ] ++ Added a new sketchbook location, so that you can have separate sketchbooks + with 2.0 and 3.0 releases. The downside is that they won't stay in sync, + but the upside is that sketches that haven't been updated, or conflicting + Libraries, Modes, or Tools won't cause trouble with the other version. + The new preference is called sketchbook.location.three (the old preference + was sketchbook.location). If you already have a 2.0 sketchbook, that will + be used by default with 3.0 until you change it in the Preferences window. + + Neglected to mention with the previous release that the video library has been removed from the default download. This decreases the size of the Processing download by about 20%. In addition, it was only the video diff --git a/todo.txt b/todo.txt index 0fa521317..4e00313c8 100644 --- a/todo.txt +++ b/todo.txt @@ -27,6 +27,10 @@ X all examples are out of "processing/java" and are now in "processing-docs/co o "Platform is ${platform}" message during 'ant clean' o on OS X, but not Windows (haven't checked Linux) X this was in pdex/build.xml +X remove welcome message from the sound library +X URL opening problem fixed by use of getCanonicalPath() on Windows +X https://github.com/processing/processing/issues/2656 +X add a new pref for the 3.0 sketchbook location gsoc X clear status messages in the Contribution Manager @@ -57,15 +61,6 @@ o https://github.com/processing/processing/issues/2639 X moving p5 examples to the web repo X move examples into web repo -_ add a new pref for the 3.0 sketchbook location -_ make reference and examples build process part of dist -_ separate ant targets, but only require them for dist -_ as separate targets, folks can build explicitly if they'd like -_ reference wasn't included either -_ https://github.com/processing/processing/issues/2656 -_ processing-web/java_generate/ReferenceGenerator -_ remove reference.zip from main repo - pending _ huge i18n patch @@ -73,6 +68,12 @@ _ https://github.com/processing/processing/pull/2084 _ look at the sound library https://github.com/wirsing/ProcessingSound _ sound is not yet supported on Windows _ glw? lwjgl? retina jogl? +_ make reference build process part of dist +_ https://github.com/processing/processing-docs/issues/85 +_ separate ant target, but only require them for dist +_ as separate targets, folks can build explicitly if they'd like +_ processing-docs/java_generate/ReferenceGenerator/processingrefBuild.sh +_ remove reference.zip from main repo gsoc/help me @@ -92,6 +93,15 @@ _ needs to recognize the p5 app folder _ also should recognize the user's home dir _ incorporate new preproc _ https://github.com/fjenett/processing-preprocessor-antlr4 +_ SOCKS proxy not working: +_ https://github.com/processing/processing/issues/2643 +_ the current code that gets/sets the pref is in Preferences +_ instead of current implementation, can we auto-detect proxy settings? +_ old issue: https://github.com/processing/processing/issues/1476 +_ http://docs.oracle.com/javase/7/docs/technotes/guides/net/proxies.html +_ http://docs.oracle.com/javase/1.5.0/docs/guide/net/proxies.html +_ http://stackoverflow.com/questions/4933677/detecting-windows-ie-proxy-setting-using-java +_ http://www.java2s.com/Code/Java/Network-Protocol/DetectProxySettingsforInternetConnection.htm medium @@ -144,18 +154,6 @@ _ PDE and sketches are 2x smaller on high-res Windows 8 machines _ https://github.com/processing/processing/issues/2411 -lower -_ SOCKS proxy not working: -_ https://github.com/processing/processing/issues/2643 -_ the code that gets/sets the pref is in Preferences -_ detect proxy settings? -_ old issue: https://github.com/processing/processing/issues/1476 -_ http://docs.oracle.com/javase/7/docs/technotes/guides/net/proxies.html -_ http://docs.oracle.com/javase/1.5.0/docs/guide/net/proxies.html -_ http://stackoverflow.com/questions/4933677/detecting-windows-ie-proxy-setting-using-java -_ http://www.java2s.com/Code/Java/Network-Protocol/DetectProxySettingsforInternetConnection.htm - - . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . From 2002a05029b93db0ace12d8000014e96dd04a5a1 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 18:44:45 -0400 Subject: [PATCH 30/44] updates and remove joke that used to be just lame but now it's ghoulish given Israel's current activity in Palestine --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 22f7e1966..05729409f 100644 --- a/README.md +++ b/README.md @@ -17,18 +17,18 @@ changes made by [processing-bugs](https://github.com/processing-bugs), it may be Over time this will clean itself up as bugs are fixed and new issues are added from within Github. Help speed this process along by helping us! -The [processing-web](https://github.com/processing/processing-web/) repository -contains reference, examples, and the site. +The [processing-docs](https://github.com/processing/processing-docs/) repository contains reference, examples, and the site. (Please use that link to file issues regarding the web site, the examples, or the reference.) The instructions for building the source [are here](https://github.com/processing/processing/wiki/Build-Instructions). Someday we'll also write code style guidelines, fix all these bugs, -throw together hundreds of unit tests, and solve the Israeli-Palestinian conflict. +throw together hundreds of unit tests, +and get rich off all this volunteer work. But in the meantime, I ask for your patience, [participation](https://github.com/processing/processing/wiki/Project-List), and [patches](https://github.com/processing/processing/pulls). Ben Fry, 3 February 2013 -Last updated 8 June 2014 +Last updated 30 July 2014 From 20e3f0d3c3e47cf0d7644ec508b2985f282f2480 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 18:45:42 -0400 Subject: [PATCH 31/44] clarifications --- README.md | 2 +- core/todo.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 05729409f..0746ca999 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ The instructions for building the source [are here](https://github.com/processin Someday we'll also write code style guidelines, fix all these bugs, throw together hundreds of unit tests, -and get rich off all this volunteer work. +and get rich off all this stuff that we're giving away for free. But in the meantime, I ask for your patience, [participation](https://github.com/processing/processing/wiki/Project-List), diff --git a/core/todo.txt b/core/todo.txt index c7549f51a..0131b6dc4 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -9,7 +9,6 @@ X https://github.com/processing/processing/issues/2228 X https://github.com/processing/processing/pull/2324 X move to native OS X full screen (gets rid of native code) X https://github.com/processing/processing/issues/2641 -_ sometimes causes placement to temporarily be in the wrong spot pulls @@ -27,6 +26,7 @@ _ remove Applet as base class _ performance issues on OS X (might be threading due to Applet) _ https://github.com/processing/processing/issues/2423 _ play with improvements to full screen here +_ new full screen sometimes causes sketch to temporarily be in the wrong spot processing.data From 26b60b4a69e2c2fff283ad007141e459f0bcb7b0 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 20:42:27 -0400 Subject: [PATCH 32/44] disable ant build, problematic with Eclipse --- pdex/.externalToolBuilders/Ant_Builder.launch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pdex/.externalToolBuilders/Ant_Builder.launch b/pdex/.externalToolBuilders/Ant_Builder.launch index 9b95f0090..2f93ff37a 100644 --- a/pdex/.externalToolBuilders/Ant_Builder.launch +++ b/pdex/.externalToolBuilders/Ant_Builder.launch @@ -12,7 +12,7 @@ - + From 76dedb1d5bccbcef1da518174e30732244370a44 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 20:42:40 -0400 Subject: [PATCH 33/44] move NaN values to the end of the list when sorting --- core/src/processing/data/FloatDict.java | 17 ++++++++++++++++- core/src/processing/data/FloatList.java | 15 ++++++++++++++- core/src/processing/data/Sort.java | 4 ++-- core/todo.txt | 23 +++++++++++++---------- todo.txt | 1 + 5 files changed, 46 insertions(+), 14 deletions(-) diff --git a/core/src/processing/data/FloatDict.java b/core/src/processing/data/FloatDict.java index 71ea99ffd..cccfc17da 100644 --- a/core/src/processing/data/FloatDict.java +++ b/core/src/processing/data/FloatDict.java @@ -668,7 +668,22 @@ public class FloatDict { Sort s = new Sort() { @Override public int size() { - return count; + if (useKeys) { + return count; // don't worry about NaN values + + } else { // first move NaN values to the end of the list + int right = count - 1; + while (values[right] != values[right]) { + right--; + } + for (int i = right; i >= 0; --i) { + if (Float.isNaN(values[i])) { + swap(i, right); + --right; + } + } + return right + 1; + } } @Override diff --git a/core/src/processing/data/FloatList.java b/core/src/processing/data/FloatList.java index 7d2f6a28d..3a00bbe05 100644 --- a/core/src/processing/data/FloatList.java +++ b/core/src/processing/data/FloatList.java @@ -566,7 +566,20 @@ public class FloatList implements Iterable { new Sort() { @Override public int size() { - return count; + // move NaN values to the end of the list and don't sort them + int right = count - 1; + while (data[right] != data[right]) { + right--; + } + for (int i = right; i >= 0; --i) { + float v = data[i]; + if (v != v) { + data[i] = data[right]; + data[right] = v; + --right; + } + } + return right + 1; } @Override diff --git a/core/src/processing/data/Sort.java b/core/src/processing/data/Sort.java index d205edb12..b42e0f141 100644 --- a/core/src/processing/data/Sort.java +++ b/core/src/processing/data/Sort.java @@ -31,8 +31,8 @@ public abstract class Sort implements Runnable { protected int partition(int left, int right) { int pivot = right; do { - while (compare(++left, pivot) < 0) ; - while ((right != 0) && (compare(--right, pivot) > 0)) ; + while (compare(++left, pivot) < 0) { } + while ((right != 0) && (compare(--right, pivot) > 0)) { } swap(left, right); } while (left < right); swap(left, right); diff --git a/core/todo.txt b/core/todo.txt index 0131b6dc4..72637a8b7 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -1,15 +1,22 @@ 0229 core (3.0a2) -X add copy() method to Table -X return null from getString() on NaN float and double values -X affects how saveTable() works (writes blank entries instead of NaN) -X get(5) with an empty Int/Float/StringList was returning 0 -X https://github.com/processing/processing/pull/2343 X PImage resize() causes images to not draw X https://github.com/processing/processing/issues/2228 X https://github.com/processing/processing/pull/2324 X move to native OS X full screen (gets rid of native code) X https://github.com/processing/processing/issues/2641 +data +X add copy() method to Table +X return null from getString() on NaN float and double values +X affects how saveTable() works (writes blank entries instead of NaN) +X get(5) with an empty Int/Float/StringList was returning 0 +X https://github.com/processing/processing/pull/2343 +o fix for maxValue() and minValue() when all entries are bad +o on FloatDict it was NaN, check across the lists and other dict types +X nothing else to do here +X FloatDict and FloatList should always put NaN values at the end on sort +X same for the other list and dict classes +X (this is part of the point of having these easier versions) pulls X implement A and a (elliptical arcs) @@ -33,11 +40,6 @@ processing.data _ need a better method for "missing" data in Table _ if missing int is zero, can't just remove those values from saving a table _ but for NaN values, it's a necessity -_ fix for maxValue() and minValue() when all entries are bad -_ on FloatDict it was NaN, check across the lists and other dict types -_ StringDict should always put NaN values at the end on sort -_ same for the other list and dict classes -_ (this is part of the point of having these easier versions) _ get() methods in List/Dict shouldn't allow you to get bad values _ but set() methods can automatically resize the arrays _ though that means insert() should allow you to insert past the end @@ -54,6 +56,7 @@ _ match and iterators _ add match version that returns table that's only a pointer to original _ save the constructor for the version that actually copies data _ the table pointer version will be speedy and allow chaining +_ add Double and Long versions of the classes? later diff --git a/todo.txt b/todo.txt index 4e00313c8..ee31ded1c 100644 --- a/todo.txt +++ b/todo.txt @@ -31,6 +31,7 @@ X remove welcome message from the sound library X URL opening problem fixed by use of getCanonicalPath() on Windows X https://github.com/processing/processing/issues/2656 X add a new pref for the 3.0 sketchbook location +_ when renaming a tab, include the previous name to be edited gsoc X clear status messages in the Contribution Manager From 2943469482386c8f9341e1a520d58b8e5ddd586b Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 21:22:10 -0400 Subject: [PATCH 34/44] add print method to the Dict and List classes --- core/src/processing/data/FloatDict.java | 11 +++++------ core/src/processing/data/FloatList.java | 7 +++++++ core/src/processing/data/IntDict.java | 7 +++++++ core/src/processing/data/StringDict.java | 7 +++++++ core/src/processing/data/StringList.java | 9 +++++---- core/todo.txt | 11 ++++++----- 6 files changed, 37 insertions(+), 15 deletions(-) diff --git a/core/src/processing/data/FloatDict.java b/core/src/processing/data/FloatDict.java index cccfc17da..d300afc1d 100644 --- a/core/src/processing/data/FloatDict.java +++ b/core/src/processing/data/FloatDict.java @@ -744,12 +744,11 @@ public class FloatDict { } -// /** -// * Write tab-delimited entries out to the console. -// */ -// public void print() { -// write(new PrintWriter(System.out)); -// } + public void print() { + for (int i = 0; i < size(); i++) { + System.out.println(keys[i] + " = " + values[i]); + } + } /** diff --git a/core/src/processing/data/FloatList.java b/core/src/processing/data/FloatList.java index 3a00bbe05..1e4a85f19 100644 --- a/core/src/processing/data/FloatList.java +++ b/core/src/processing/data/FloatList.java @@ -779,6 +779,13 @@ public class FloatList implements Iterable { } + public void print() { + for (int i = 0; i < size(); i++) { + System.out.format("[%d] %f%n", i, data[i]); + } + } + + @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/core/src/processing/data/IntDict.java b/core/src/processing/data/IntDict.java index b581eaecf..022d9195f 100644 --- a/core/src/processing/data/IntDict.java +++ b/core/src/processing/data/IntDict.java @@ -663,6 +663,13 @@ public class IntDict { } + public void print() { + for (int i = 0; i < size(); i++) { + System.out.println(keys[i] + " = " + values[i]); + } + } + + @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/core/src/processing/data/StringDict.java b/core/src/processing/data/StringDict.java index 38b2175eb..becc5ee51 100644 --- a/core/src/processing/data/StringDict.java +++ b/core/src/processing/data/StringDict.java @@ -428,6 +428,13 @@ public class StringDict { } + public void print() { + for (int i = 0; i < size(); i++) { + System.out.println(keys[i] + " = " + values[i]); + } + } + + @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/core/src/processing/data/StringList.java b/core/src/processing/data/StringList.java index 10f564476..67e58a9ee 100644 --- a/core/src/processing/data/StringList.java +++ b/core/src/processing/data/StringList.java @@ -705,10 +705,11 @@ public class StringList implements Iterable { } -// static public StringList split(String value, char delim) { -// String[] array = PApplet.split(value, delim); -// return new StringList(array); -// } + public void print() { + for (int i = 0; i < size(); i++) { + System.out.format("[%d] %s%n", i, data[i]); + } + } @Override diff --git a/core/todo.txt b/core/todo.txt index 72637a8b7..815e493fb 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -17,6 +17,10 @@ X nothing else to do here X FloatDict and FloatList should always put NaN values at the end on sort X same for the other list and dict classes X (this is part of the point of having these easier versions) +o 'collector' class.. Dict that points to a list +o String as a key, int/float/string list as values +X seems too much like a better place for HashMap +X add print() method to other data types (not just IntList) pulls X implement A and a (elliptical arcs) @@ -43,10 +47,6 @@ _ but for NaN values, it's a necessity _ get() methods in List/Dict shouldn't allow you to get bad values _ but set() methods can automatically resize the arrays _ though that means insert() should allow you to insert past the end -_ should we allow negative indices so that we can work relative to the end? -_ add print() method to other data types (not just IntList) -_ 'collector' class.. Dict that points to a list -_ String as a key, int/float/string list as values _ addRow() is not efficient, probably need to do the doubling o or have a setIncrement() function? _ it would default to 1 on tables loaded from a file @@ -56,7 +56,6 @@ _ match and iterators _ add match version that returns table that's only a pointer to original _ save the constructor for the version that actually copies data _ the table pointer version will be speedy and allow chaining -_ add Double and Long versions of the classes? later @@ -225,6 +224,8 @@ _ is this still true? _ decide how disconnectEvent should actually be handled (and name?) _ was disconnect always there? _ will need documentation +_ negative indices so that we can work relative to the end in data classes? +_ add Double and Long versions of the classes? From bff235dcb9bc97d6b37bd810adda734a805e1ac4 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 21:37:12 -0400 Subject: [PATCH 35/44] throw exception if Server constructor fails --- core/todo.txt | 29 ++++++++++--------- .../net/src/processing/net/Server.java | 3 +- todo.txt | 2 ++ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/core/todo.txt b/core/todo.txt index 815e493fb..3ee3c95b7 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -30,14 +30,26 @@ X https://github.com/processing/processing/pull/2659 X done with an approximation, if re-saving this will destroy data (docs) X fix typo in StringList.insert() X https://github.com/processing/processing/pull/2672 +X StingList.insert() error (should be an easy fix) +X https://github.com/processing/processing/issues/2548 + +earlier +X default font fixes (merged for 2.2.1 or earlier) +X https://github.com/processing/processing/issues/2331 +X https://github.com/processing/processing/pull/2338 -applet removal +applet/component _ remove Applet as base class _ performance issues on OS X (might be threading due to Applet) _ https://github.com/processing/processing/issues/2423 _ play with improvements to full screen here _ new full screen sometimes causes sketch to temporarily be in the wrong spot +_ add option to have full screen span across screens +_ display=all in cmd line +_ sketchDisplay() -> 0 for all, or 1, 2, 3... +_ clean up requestFocus() stuff +_ make sure it works with retina/canvas/strategy as well processing.data @@ -66,8 +78,6 @@ _ maybe once we make the PVector change high _ Closing opengl sketch from the PDE doesn't stop java process on windows _ https://github.com/processing/processing/issues/2335 -_ StingList.insert() error (should be an easy fix) -_ https://github.com/processing/processing/issues/2548 _ dataPath() not working when app is not run from app dir on Linux _ https://github.com/processing/processing/issues/2195 _ "Buffers have not been created" error for sketches w/o draw() @@ -85,23 +95,13 @@ _ internally, we probably have to call set() if it's a 1 pixel point _ but that's going to be a mess.. need to first check the CTM _ tint() not working in PDF (regression between 2.0.3 and 2.1) _ https://github.com/processing/processing/issues/2428 -_ default font fixes -_ https://github.com/processing/processing/issues/2331 -_ https://github.com/processing/processing/pull/2338 _ Sort out blending differences with P2D/P3D _ might be that compatible images not setting alpha mode correctly _ image = gc.createCompatibleVolatileImage(source.width, source.height, Transparency.TRANSLUCENT); _ https://github.com/processing/processing/issues/1844 -_ add option to have full screen span across screens -_ display=all in cmd line -_ sketchDisplay() -> 0 for all, or 1, 2, 3... -_ clean up requestFocus() stuff -_ make sure it works with retina/canvas/strategy as well _ finish PFont.getShape() implementation _ needs to have a way to set width/height properly _ draw(s) doesn't work on the returned PShape -_ TGA files writing strangely -_ https://github.com/processing/processing/issues/2096 hidpi @@ -366,6 +366,9 @@ _ https://github.com/processing/processing/issues/1727 CORE / PImage +_ TGA files writing strangely +_ https://github.com/processing/processing/issues/2096 + _ 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 diff --git a/java/libraries/net/src/processing/net/Server.java b/java/libraries/net/src/processing/net/Server.java index 4cfeb784d..05addd256 100644 --- a/java/libraries/net/src/processing/net/Server.java +++ b/java/libraries/net/src/processing/net/Server.java @@ -107,8 +107,9 @@ public class Server implements Runnable { } } catch (IOException e) { - e.printStackTrace(); + //e.printStackTrace(); thread = null; + throw new RuntimeException(e); //errorMessage("", e); } } diff --git a/todo.txt b/todo.txt index ee31ded1c..5b314b368 100644 --- a/todo.txt +++ b/todo.txt @@ -31,6 +31,8 @@ X remove welcome message from the sound library X URL opening problem fixed by use of getCanonicalPath() on Windows X https://github.com/processing/processing/issues/2656 X add a new pref for the 3.0 sketchbook location +X if Server constructor fails, throw an exception +X https://github.com/processing/processing/issues/2604 _ when renaming a tab, include the previous name to be edited gsoc From b7756bcb1fcba7d3b239bedfb322424d85116837 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 21:43:55 -0400 Subject: [PATCH 36/44] bounds check with setVertex(PVector) (fixes #2556) --- core/src/processing/core/PShape.java | 7 ++++++- core/todo.txt | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/core/src/processing/core/PShape.java b/core/src/processing/core/PShape.java index 8420f72f6..d0db5006b 100644 --- a/core/src/processing/core/PShape.java +++ b/core/src/processing/core/PShape.java @@ -2065,7 +2065,12 @@ public class PShape implements PConstants { vertices[index][X] = vec.x; vertices[index][Y] = vec.y; - vertices[index][Z] = vec.z; + + if (vertices[index].length > 2) { + vertices[index][Z] = vec.z; + } else if (vec.z != 0 && vec.z == vec.z) { + throw new IllegalArgumentException("Cannot set a z-coordinate on a 2D shape"); + } } diff --git a/core/todo.txt b/core/todo.txt index 3ee3c95b7..99af134bb 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -4,6 +4,8 @@ X https://github.com/processing/processing/issues/2228 X https://github.com/processing/processing/pull/2324 X move to native OS X full screen (gets rid of native code) X https://github.com/processing/processing/issues/2641 +X do bounds check on setVertex(PVector) +X https://github.com/processing/processing/issues/2556 data X add copy() method to Table From 828cef7fd1a194b738a9c8c9e89287f0c59de336 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 22:03:51 -0400 Subject: [PATCH 37/44] add special case for image() with degenerate PGraphics (fixes #2208) --- core/src/processing/core/PGraphicsJava2D.java | 5 +++++ core/todo.txt | 2 ++ todo.txt | 7 +++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/core/src/processing/core/PGraphicsJava2D.java b/core/src/processing/core/PGraphicsJava2D.java index a2828d08a..a42f1ea3f 100644 --- a/core/src/processing/core/PGraphicsJava2D.java +++ b/core/src/processing/core/PGraphicsJava2D.java @@ -1301,6 +1301,11 @@ public class PGraphicsJava2D extends PGraphics { } if (who.modified) { + if (who.pixels == null) { + // This might be a PGraphics that hasn't been drawn to yet, bail out. + // https://github.com/processing/processing/issues/2208 + return; + } cash.update(who, tint, tintColor); who.modified = false; } diff --git a/core/todo.txt b/core/todo.txt index 99af134bb..5b83b8774 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -6,6 +6,8 @@ X move to native OS X full screen (gets rid of native code) X https://github.com/processing/processing/issues/2641 X do bounds check on setVertex(PVector) X https://github.com/processing/processing/issues/2556 +X using createGraphics() w/o begin/endDraw(), don't attempt drawing w/ image() +X https://github.com/processing/processing/issues/2208 data X add copy() method to Table diff --git a/todo.txt b/todo.txt index 5b314b368..d9f249bb2 100644 --- a/todo.txt +++ b/todo.txt @@ -33,6 +33,11 @@ X https://github.com/processing/processing/issues/2656 X add a new pref for the 3.0 sketchbook location X if Server constructor fails, throw an exception X https://github.com/processing/processing/issues/2604 +o check on why 2x core.jar inside the Java folder +o maybe OS X Java can't look in subfolders? (just auto-adds things) +o https://github.com/processing/processing/issues/2344 +X one is used by the PDE, the other is used as a library +_ changing the mode on an untitled, unmodified sketch removes untitled status _ when renaming a tab, include the previous name to be edited gsoc @@ -109,8 +114,6 @@ _ http://www.java2s.com/Code/Java/Network-Protocol/DetectProxySettingsforInter medium _ possibility of libraries folder inside a particular sketch? -_ check on why 2x core.jar inside the Java folder -_ maybe OS X Java can't look in subfolders? (just auto-adds things) _ display "1" is not correct in 2.1.2 _ https://github.com/processing/processing/issues/2502 _ re/move things from Google Code downloads From aec46f25cf3b35f46705a93b97ddbccc92235f03 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 22:07:44 -0400 Subject: [PATCH 38/44] better fix for 2208 --- core/src/processing/core/PGraphicsJava2D.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/processing/core/PGraphicsJava2D.java b/core/src/processing/core/PGraphicsJava2D.java index a42f1ea3f..af906a6dd 100644 --- a/core/src/processing/core/PGraphicsJava2D.java +++ b/core/src/processing/core/PGraphicsJava2D.java @@ -1302,9 +1302,10 @@ public class PGraphicsJava2D extends PGraphics { if (who.modified) { if (who.pixels == null) { - // This might be a PGraphics that hasn't been drawn to yet, bail out. + // This might be a PGraphics that hasn't been drawn to yet. + // Can't just bail because the cache has been created above. // https://github.com/processing/processing/issues/2208 - return; + who.pixels = new int[who.width * who.height]; } cash.update(who, tint, tintColor); who.modified = false; From d2c28b78b01ca4febeb39d7cfc6271bf2aeddcf1 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 22:13:40 -0400 Subject: [PATCH 39/44] get 'modified' indicator working on document windows again (fixes #2194) --- app/src/processing/app/Sketch.java | 3 ++- todo.txt | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 33c803ecc..98e55bd88 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -749,7 +749,8 @@ public class Sketch { if (Base.isMacOS()) { // http://developer.apple.com/qa/qa2001/qa1146.html Object modifiedParam = modified ? Boolean.TRUE : Boolean.FALSE; - editor.getRootPane().putClientProperty("windowModified", modifiedParam); + // https://developer.apple.com/library/mac/technotes/tn2007/tn2196.html#WINDOW_DOCUMENTMODIFIED + editor.getRootPane().putClientProperty("Window.documentModified", modifiedParam); } } diff --git a/todo.txt b/todo.txt index d9f249bb2..7adb7561b 100644 --- a/todo.txt +++ b/todo.txt @@ -37,6 +37,8 @@ o check on why 2x core.jar inside the Java folder o maybe OS X Java can't look in subfolders? (just auto-adds things) o https://github.com/processing/processing/issues/2344 X one is used by the PDE, the other is used as a library +X get 'modified' indicator working on document windows again +X https://github.com/processing/processing/issues/2194 _ changing the mode on an untitled, unmodified sketch removes untitled status _ when renaming a tab, include the previous name to be edited From 35942d8f906fd786ded2f8041b00200627a81874 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 22:19:12 -0400 Subject: [PATCH 40/44] remove menubar hack to work around Oracle wankery --- .../app/platform/ThinkDifferent.java | 42 +++++++++---------- todo.txt | 9 ++-- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/app/src/processing/app/platform/ThinkDifferent.java b/app/src/processing/app/platform/ThinkDifferent.java index aba1ed4ba..e13db6f0b 100644 --- a/app/src/processing/app/platform/ThinkDifferent.java +++ b/app/src/processing/app/platform/ThinkDifferent.java @@ -22,7 +22,6 @@ package processing.app.platform; -import java.awt.Dimension; import java.awt.event.*; import javax.swing.*; @@ -30,7 +29,6 @@ import javax.swing.*; import processing.app.About; import processing.app.Base; import processing.app.Toolkit; -import processing.core.PApplet; import com.apple.eawt.*; @@ -84,27 +82,27 @@ public class ThinkDifferent implements ApplicationListener { // This is kind of a gross way to do this, but the alternatives? Hrm. Base.defaultFileMenu = fileMenu; - if (PApplet.javaVersion <= 1.6f) { // doesn't work on Oracle's Java - try { - application.setDefaultMenuBar(defaultMenuBar); - - } catch (Exception e) { - e.printStackTrace(); // oh well nevermind - } - } else { - // The douchebags at Oracle didn't feel that a working f*king menubar - // on OS X was important enough to make it into the 7u40 release. - //http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8007267 - // It languished in the JDK 8 source and has been backported for 7u60: - //http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8022667 - - JFrame offscreen = new JFrame(); - offscreen.setUndecorated(true); - offscreen.setJMenuBar(defaultMenuBar); - Dimension screen = Toolkit.getScreenSize(); - offscreen.setLocation(screen.width, screen.height); - offscreen.setVisible(true); +// if (PApplet.javaVersion <= 1.6f) { // doesn't work on Oracle's Java + try { + application.setDefaultMenuBar(defaultMenuBar); + + } catch (Exception e) { + e.printStackTrace(); // oh well, never mind } +// } else { +// // The douchebags at Oracle didn't feel that a working f*king menubar +// // on OS X was important enough to make it into the 7u40 release. +// //http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8007267 +// // It languished in the JDK 8 source and has been backported for 7u60: +// //http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8022667 +// +// JFrame offscreen = new JFrame(); +// offscreen.setUndecorated(true); +// offscreen.setJMenuBar(defaultMenuBar); +// Dimension screen = Toolkit.getScreenSize(); +// offscreen.setLocation(screen.width, screen.height); +// offscreen.setVisible(true); +// } } diff --git a/todo.txt b/todo.txt index 7adb7561b..bf0cb4afd 100644 --- a/todo.txt +++ b/todo.txt @@ -39,6 +39,8 @@ o https://github.com/processing/processing/issues/2344 X one is used by the PDE, the other is used as a library X get 'modified' indicator working on document windows again X https://github.com/processing/processing/issues/2194 +X remove default menu bar hack when 7u60 arrives +X http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8022667 _ changing the mode on an untitled, unmodified sketch removes untitled status _ when renaming a tab, include the previous name to be edited @@ -70,7 +72,7 @@ o double-clicking a .pde file doesn't open properly on OS X o https://github.com/processing/processing/issues/2639 X moving p5 examples to the web repo X move examples into web repo - +o OS X not opening a sketch at all on pde double-click? (though opening the app) pending _ huge i18n patch @@ -879,14 +881,13 @@ _ http://code.google.com/p/processing/issues/detail?id=632 DIST / Mac OS X +_ more OS X-specific hackery for improved appearance +_ https://developer.apple.com/library/mac/technotes/tn2007/tn2196.html _ possible better option for doing retina? _ g.getFontRenderContext().getTransform().equals(AffineTransform.getScaleInstance(2.0, 2.0)) _ appbundler improvements _ don't re-copy JRE into work folder if already exists _ implement a splash screen -_ remove default menu bar hack when 7u60 arrives -_ http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8022667 -_ OS X not opening a sketch at all on pde double-click? (though opening the app) _ LWJGL forum discussion _ http://lwjgl.org/forum/index.php/topic,4711.225.html _ change cmd line for OS X to use symlink? From 0a1f67a6b2990917ab5a80cdd4044a736ffa5c51 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 22:25:39 -0400 Subject: [PATCH 41/44] include old name of tab when renaming --- app/src/processing/app/Sketch.java | 67 ++++++++++++++---------------- todo.txt | 2 +- 2 files changed, 32 insertions(+), 37 deletions(-) diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 98e55bd88..7c00152a3 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -340,27 +340,26 @@ public class Sketch { * @param oldName */ protected void promptForTabName(String prompt, String oldName) { - final JTextField txtTabName = new JTextField(); - txtTabName.addKeyListener(new KeyAdapter() { + final JTextField field = new JTextField(oldName); + + field.addKeyListener(new KeyAdapter() { // Forget ESC, the JDialog should handle it. - - // Use keyTyped to catch when the feller is actually - // added to the text field. With keyTyped, as opposed to - // keyPressed, the keyCode will be zero, even if it's - // enter or backspace or whatever, so the keychar should - // be used instead. Grr. + // Use keyTyped to catch when the feller is actually added to the text + // field. With keyTyped, as opposed to keyPressed, the keyCode will be + // zero, even if it's enter or backspace or whatever, so the keychar + // should be used instead. Grr. public void keyTyped(KeyEvent event) { //System.out.println("got event " + event); char ch = event.getKeyChar(); if ((ch == '_') || (ch == '.') || // allow.pde and .java - (('A' <= ch) && (ch <= 'Z')) || (('a' <= ch) && (ch <= 'z'))) { + (('A' <= ch) && (ch <= 'Z')) || (('a' <= ch) && (ch <= 'z'))) { // These events are allowed straight through. } else if (ch == ' ') { - String t = txtTabName.getText(); - int start = txtTabName.getSelectionStart(); - int end = txtTabName.getSelectionEnd(); - txtTabName.setText(t.substring(0, start) + "_" + t.substring(end)); - txtTabName.setCaretPosition(start + 1); + String t = field.getText(); + int start = field.getSelectionStart(); + int end = field.getSelectionEnd(); + field.setText(t.substring(0, start) + "_" + t.substring(end)); + field.setCaretPosition(start + 1); event.consume(); } else if ((ch >= '0') && (ch <= '9')) { // getCaretPosition == 0 means that it's the first char @@ -368,31 +367,29 @@ public class Sketch { // getSelectionStart means that it *will be* the first // char, because the selection is about to be replaced // with whatever is typed. - if ((txtTabName.getCaretPosition() == 0) - || (txtTabName.getSelectionStart() == 0)) { + if (field.getCaretPosition() == 0 || + field.getSelectionStart() == 0) { // number not allowed as first digit - //System.out.println("bad number bad"); event.consume(); } } else if (ch == KeyEvent.VK_ENTER) { - // Slightly ugly hack that ensures OK button of the dialog - // consumes the Enter key event. Since the text field is the - // default component in the dialog(see below), OK button doesn't - // consume Enter key event, by default. - Container parent = txtTabName.getParent(); + // Slightly ugly hack that ensures OK button of the dialog consumes + // the Enter key event. Since the text field is the default component + // in the dialog, OK doesn't consume Enter key event, by default. + Container parent = field.getParent(); while (!(parent instanceof JOptionPane)) { parent = parent.getParent(); } JOptionPane pane = (JOptionPane) parent; - final JPanel pnlBottom = (JPanel) pane.getComponent(pane - .getComponentCount() - 1); + final JPanel pnlBottom = (JPanel) + pane.getComponent(pane.getComponentCount() - 1); for (int i = 0; i < pnlBottom.getComponents().length; i++) { Component component = pnlBottom.getComponents()[i]; if (component instanceof JButton) { - final JButton okButton = ((JButton) component); + final JButton okButton = (JButton) component; if (okButton.getText().equalsIgnoreCase("OK")) { - ActionListener[] actionListeners = okButton - .getActionListeners(); + ActionListener[] actionListeners = + okButton.getActionListeners(); if (actionListeners.length > 0) { actionListeners[0].actionPerformed(null); event.consume(); @@ -400,26 +397,24 @@ public class Sketch { } } } - } - else { + } else { event.consume(); } } }); int userReply = JOptionPane.showOptionDialog(editor, new Object[] { - prompt, txtTabName }, - "Tab Name", + prompt, field }, + "New Name", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, new Object[] { - Preferences.PROMPT_OK, - Preferences.PROMPT_CANCEL }, - txtTabName); + Preferences.PROMPT_OK, + Preferences.PROMPT_CANCEL }, + field); if (userReply == JOptionPane.OK_OPTION) { - String answer = txtTabName.getText(); - nameCode(answer); + nameCode(field.getText()); } } diff --git a/todo.txt b/todo.txt index bf0cb4afd..dd90e7178 100644 --- a/todo.txt +++ b/todo.txt @@ -41,8 +41,8 @@ X get 'modified' indicator working on document windows again X https://github.com/processing/processing/issues/2194 X remove default menu bar hack when 7u60 arrives X http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8022667 +X when renaming a tab, include the previous name to be edited _ changing the mode on an untitled, unmodified sketch removes untitled status -_ when renaming a tab, include the previous name to be edited gsoc X clear status messages in the Contribution Manager From cbca68e57f11e4d887c2b9515060720cd66eb990 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 22:31:06 -0400 Subject: [PATCH 42/44] fix loophole with untitled sketches and mode changes --- app/src/processing/app/Base.java | 45 ++++++++++++++++++-------------- todo.txt | 2 +- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 90b54a103..db6ed2383 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -602,32 +602,37 @@ public class Base { } + /** + * The call has already checked to make sure this sketch is not modified, + * now change the mode. + */ protected void changeMode(Mode mode) { if (activeEditor.getMode() != mode) { Sketch sketch = activeEditor.getSketch(); nextMode = mode; - - // If the current editor contains file extensions that the new mode can handle, then - // write a sketch.properties file with the new mode specified, and reopen. - boolean newModeCanHandleCurrentSource = true; - for (final SketchCode code: sketch.getCode()) { - if (!mode.validExtension(code.getExtension())) { - newModeCanHandleCurrentSource = false; - break; - } - } - if (newModeCanHandleCurrentSource) { - final File props = new File(sketch.getCodeFolder(), "sketch.properties"); - saveModeSettings(props, nextMode); + + if (sketch.isUntitled()) { + // If no changes have been made, just close and start fresh. + // (Otherwise the editor would lose its 'untitled' status.) handleClose(activeEditor, true); - handleOpen(sketch.getMainFilePath()); - } else { - // If you're changing modes, and there's nothing in the current sketch, you probably - // don't intend to keep the old, wrong-mode editor around. - if (sketch.isUntitled()) { - handleClose(activeEditor, true); - } handleNew(); + + } else { + // If the current editor contains file extensions that the new mode can handle, then + // write a sketch.properties file with the new mode specified, and reopen. + boolean newModeCanHandleCurrentSource = true; + for (final SketchCode code: sketch.getCode()) { + if (!mode.validExtension(code.getExtension())) { + newModeCanHandleCurrentSource = false; + break; + } + } + if (newModeCanHandleCurrentSource) { + final File props = new File(sketch.getCodeFolder(), "sketch.properties"); + saveModeSettings(props, nextMode); + handleClose(activeEditor, true); + handleOpen(sketch.getMainFilePath()); + } } } } diff --git a/todo.txt b/todo.txt index dd90e7178..929f36f12 100644 --- a/todo.txt +++ b/todo.txt @@ -42,7 +42,7 @@ X https://github.com/processing/processing/issues/2194 X remove default menu bar hack when 7u60 arrives X http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8022667 X when renaming a tab, include the previous name to be edited -_ changing the mode on an untitled, unmodified sketch removes untitled status +X changing the mode on an untitled, unmodified sketch removes untitled status gsoc X clear status messages in the Contribution Manager From e13510e7a9b1b2c852c3af2671cecaaae6ecd986 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 23:14:28 -0400 Subject: [PATCH 43/44] cleaning up a bit while culling old bugs --- todo.txt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/todo.txt b/todo.txt index 929f36f12..c7e49d2d7 100644 --- a/todo.txt +++ b/todo.txt @@ -73,6 +73,15 @@ o https://github.com/processing/processing/issues/2639 X moving p5 examples to the web repo X move examples into web repo o OS X not opening a sketch at all on pde double-click? (though opening the app) +X Chinese text is overlapped in Processing 2.1 editor +X https://github.com/processing/processing/issues/2173 +o type cut off in dialog boxes on OS X retina machines +o https://github.com/processing/processing/issues/2116 +o add spaces to the end of the text? +X seems to have fixed itself in newer Java releases +X implement Windows menu in the PDE +X https://github.com/processing/processing/issues/584 + pending _ huge i18n patch @@ -114,6 +123,8 @@ _ http://docs.oracle.com/javase/7/docs/technotes/guides/net/proxies.html _ http://docs.oracle.com/javase/1.5.0/docs/guide/net/proxies.html _ http://stackoverflow.com/questions/4933677/detecting-windows-ie-proxy-setting-using-java _ http://www.java2s.com/Code/Java/Network-Protocol/DetectProxySettingsforInternetConnection.htm +_ problems with non-US keyboards and some shortcuts +_ https://github.com/processing/processing/issues/2199 medium @@ -341,9 +352,6 @@ PDE - Processing Development Environment PDE / Dialogs -_ type cut off in dialog boxes on OS X retina machines -_ https://github.com/processing/processing/issues/2116 -_ add spaces to the end of the text? _ dialog box icon is fuzzy on OS X retina machines _ https://github.com/processing/processing/issues/2117 _ solution might be our own dialog boxes From 5d0e2e0f32913fbdaf7c679026db32588a60d86a Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 23:32:04 -0400 Subject: [PATCH 44/44] culling the list --- core/todo.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/todo.txt b/core/todo.txt index 5b83b8774..ee3902ee8 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -41,6 +41,9 @@ earlier X default font fixes (merged for 2.2.1 or earlier) X https://github.com/processing/processing/issues/2331 X https://github.com/processing/processing/pull/2338 +X image resize() takes oddly long time +X https://github.com/processing/processing/issues/5 +X the problem was confirmed to have fixed itself applet/component