From 8cd8f9859cc16a96be9565150361d2dc0c50453a Mon Sep 17 00:00:00 2001 From: A Pottinger Date: Sun, 20 Oct 2019 17:31:32 -0700 Subject: [PATCH 1/5] Add language support to modes after recent changes. Migrated changes from @codeanticode at https://github.com/processing/processing4/pull/14/commits/3de786689eb981931c159fc66d369c50f3b6d217 to lastest version of master with light testing. --- app/src/processing/app/Language.java | 13 ++++++++++++- .../processing/app/contrib/ModeContribution.java | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/processing/app/Language.java b/app/src/processing/app/Language.java index 06be82fc5a..c37837ceb5 100644 --- a/app/src/processing/app/Language.java +++ b/app/src/processing/app/Language.java @@ -170,6 +170,18 @@ static public Language init() { } + static public void addModeStrings(Mode mode) { + String baseFilename = "languages/mode.properties"; + String langFilename = "languages/mode_" + instance.language + ".properties"; + File modeBaseFile = new File(mode.getFolder(), baseFilename); + File modeLangFile = new File(mode.getFolder(), langFilename); + if (modeBaseFile.exists() && modeLangFile.exists()) { + instance.bundle.read(modeBaseFile); + instance.bundle.read(modeLangFile); + } + } + + static private String get(String key) { LanguageBundle bundle = init().bundle; @@ -183,7 +195,6 @@ static private String get(String key) { return null; } - /** Get translation from bundles. */ static public String text(String key) { String value = get(key); diff --git a/app/src/processing/app/contrib/ModeContribution.java b/app/src/processing/app/contrib/ModeContribution.java index 0005de2478..194a94d994 100644 --- a/app/src/processing/app/contrib/ModeContribution.java +++ b/app/src/processing/app/contrib/ModeContribution.java @@ -31,6 +31,7 @@ import java.util.List; import processing.app.Base; +import processing.app.Language; import processing.app.Messages; import processing.app.Mode; import processing.app.Util; @@ -89,6 +90,7 @@ public ModeContribution(Base base, File folder, Messages.log("Got mode class " + modeClass); Constructor con = modeClass.getConstructor(Base.class, File.class); mode = (Mode) con.newInstance(base, folder); + Language.addModeStrings(mode); mode.setClassLoader(loader); if (base != null) { mode.setupGUI(); From 649859e613200be9567f53cf4ee6fa571ea25f4c Mon Sep 17 00:00:00 2001 From: A Samuel Pottinger Date: Sun, 10 Nov 2019 20:57:27 -0800 Subject: [PATCH 2/5] Update README.md --- README.md | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 259aa164c8..f664feef5d 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,27 @@ -This is an experimental fork to attempt the move to JDK 11. Because that's a major, API-breaking change, it would be Processing 4. +Sam Pottinger Processing Branch +============================================================== +This is a fork of the [Processing 4](https://github.com/processing/processing4) project that conatins the preview of a possible Processing 4 beta. -I'm working with Sam Pottinger to incorporate [his changes](https://github.com/sampottinger/processing) to see if that can be the basis for this new release. Getting things moved to OpenJDK 11 will help the longevity of the project. +
-**It's not clear if we'll ship an actual Processing 4.0**, since I have less free time than ever, and very little development help. If you'd like to help, contribute bug fixes. +Usage +-------------------------------------------------------------- +Pre-built binaries are available for download! These are not sponsored or endorsed by the Processing Foundation and are only provided as a convenience for testing this branch. These are temporary and will go away as the review process continues. It is not meant to be a release. See [https://www.datadrivenempathy.com/processing](https://www.datadrivenempathy.com/processing). You can also clone this repo (`$ git clone git@github.com:sampottinger/processing.git`) and follow the build instructions below. -Ben Fry, 4 October 2019 +
---- +Build +-------------------------------------------------------------- +For building on your local machine, please see https://gist.github.com/sampottinger/939441d7277d318189ec81844e3ca516. -## API changes +
-As with all releases, I'll do everything possible to avoid breaking API. However, there will still be tweaks that have to be made. We'll try to keep them minor. +Development / Issues +-------------------------------------------------------------- +Please beta test! Until further dicussion at [Support for Java 11, OpenJDK, and OpenJFX](https://github.com/processing/processing/pull/5753), please report issues on this fork via comments on PRs. If you are offering code related tothe changes pending review (Java 11, OpenJDK, OpenJFX, ANTLR 4, or CI), feel free to open PRs here. Otherwise, please contribute back to the [main repo](https://github.com/processing/processing). -* `Base.defaultFileMenu` is now `protected` instead of `static public` \ No newline at end of file +
+ +Release +-------------------------------------------------------------- +CI is automated via Travis. Deployment is done via [a script](https://gist.github.com/sampottinger/946a070808ef32c4170f30b279407d1c). From 5b1f760a8b8b07bab7b7b483332fc9cd47a4b3c9 Mon Sep 17 00:00:00 2001 From: A Samuel Pottinger Date: Sun, 10 Nov 2019 20:58:50 -0800 Subject: [PATCH 3/5] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f664feef5d..3c5e8eaf56 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This is a fork of the [Processing 4](https://github.com/processing/processing4) Usage -------------------------------------------------------------- -Pre-built binaries are available for download! These are not sponsored or endorsed by the Processing Foundation and are only provided as a convenience for testing this branch. These are temporary and will go away as the review process continues. It is not meant to be a release. See [https://www.datadrivenempathy.com/processing](https://www.datadrivenempathy.com/processing). You can also clone this repo (`$ git clone git@github.com:sampottinger/processing.git`) and follow the build instructions below. +Pre-built binaries are available for download! These are not sponsored or endorsed by the Processing Foundation and are only provided as a convenience for testing this branch. These are temporary and will go away as the review process continues. It is not meant to be a release. See [https://www.datadrivenempathy.com/processing](https://www.datadrivenempathy.com/processing). You can also clone this repo (`$ git clone git@github.com:sampottinger/processing4.git`) and follow the build instructions below.
@@ -18,7 +18,7 @@ For building on your local machine, please see https://gist.github.com/sampottin Development / Issues -------------------------------------------------------------- -Please beta test! Until further dicussion at [Support for Java 11, OpenJDK, and OpenJFX](https://github.com/processing/processing/pull/5753), please report issues on this fork via comments on PRs. If you are offering code related tothe changes pending review (Java 11, OpenJDK, OpenJFX, ANTLR 4, or CI), feel free to open PRs here. Otherwise, please contribute back to the [main repo](https://github.com/processing/processing). +Please beta test and write issues back to the [main repo](https://github.com/processing/processing4).
From b7960cd3597c0b108e7a4f370173486341a7ba45 Mon Sep 17 00:00:00 2001 From: A Pottinger Date: Mon, 20 Jan 2020 10:11:29 -0800 Subject: [PATCH 4/5] Resolved dangling build issues. Resolved the use of deprecated and removed methods in PGraphicsPDF as well as migrated use of selectFolder to the shim. --- app/src/processing/app/tools/Archiver.java | 5 +++-- app/src/processing/app/ui/PreferencesFrame.java | 5 +++-- app/src/processing/app/ui/Welcome.java | 5 +++-- java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java | 4 +++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/src/processing/app/tools/Archiver.java b/app/src/processing/app/tools/Archiver.java index a3f63ab0d0..932da0e47e 100644 --- a/app/src/processing/app/tools/Archiver.java +++ b/app/src/processing/app/tools/Archiver.java @@ -26,6 +26,7 @@ import processing.app.*; import processing.app.ui.Editor; +import processing.awt.ShimAWT; import processing.core.PApplet; import java.io.*; @@ -97,8 +98,8 @@ public void run() { } while (newbie.exists()); // open up a prompt for where to save this fella - PApplet.selectOutput(Language.text("archive_sketch"), - "fileSelected", newbie, this, editor); + ShimAWT.selectOutput(Language.text("archive_sketch"), + "fileSelected", newbie, this); } diff --git a/app/src/processing/app/ui/PreferencesFrame.java b/app/src/processing/app/ui/PreferencesFrame.java index 91c077b537..824f37c8f3 100644 --- a/app/src/processing/app/ui/PreferencesFrame.java +++ b/app/src/processing/app/ui/PreferencesFrame.java @@ -38,6 +38,7 @@ import processing.app.Platform; import processing.app.Preferences; import processing.app.ui.ColorChooser; +import processing.awt.ShimAWT; import processing.core.*; @@ -115,9 +116,9 @@ public PreferencesFrame(Base base) { browseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { File dflt = new File(sketchbookLocationField.getText()); - PApplet.selectFolder(Language.text("preferences.sketchbook_location.popup"), + ShimAWT.selectFolder(Language.text("preferences.sketchbook_location.popup"), "sketchbookCallback", dflt, - PreferencesFrame.this, frame); + PreferencesFrame.this); } }); diff --git a/app/src/processing/app/ui/Welcome.java b/app/src/processing/app/ui/Welcome.java index 9de89a1db8..18efe85229 100644 --- a/app/src/processing/app/ui/Welcome.java +++ b/app/src/processing/app/ui/Welcome.java @@ -40,6 +40,7 @@ import processing.app.Language; import processing.app.Platform; import processing.app.Preferences; +import processing.awt.ShimAWT; import processing.core.PApplet; @@ -113,9 +114,9 @@ public void handleLink(String link) { // The link will already have the full URL prefix if (link.endsWith("#sketchbook")) { File folder = new File(Preferences.getSketchbookPath()).getParentFile(); - PApplet.selectFolder(Language.text("preferences.sketchbook_location.popup"), + ShimAWT.selectFolder(Language.text("preferences.sketchbook_location.popup"), "sketchbookCallback", folder, - this, this); + this); } else { super.handleLink(link); } diff --git a/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java b/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java index ce72d44a15..8c77e41eef 100644 --- a/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java +++ b/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java @@ -32,6 +32,7 @@ import com.lowagie.text.pdf.ByteBuffer; import processing.awt.PGraphicsJava2D; +import processing.awt.PImageAWT; import processing.core.*; @@ -427,8 +428,9 @@ protected void imageImpl(PImage image, int imageHeight = image.height; scale((x2 - x1) / imageWidth, (y2 - y1) / imageHeight); + PImageAWT pImageAWT = (PImageAWT) image; if (u2-u1 == imageWidth && v2-v1 == imageHeight) { - g2.drawImage(image.getImage(), 0, 0, null); + g2.drawImage((Image) pImageAWT.getNative(), 0, 0, null); } else { PImage tmp = image.get(u1, v1, u2-u1, v2-v1); g2.drawImage((Image) tmp.getNative(), 0, 0, null); From 0706a1b124c3b6a04e87cf122c9d5514f6c5b356 Mon Sep 17 00:00:00 2001 From: A Pottinger Date: Mon, 20 Jan 2020 10:54:28 -0800 Subject: [PATCH 5/5] Fixed moving PDF params to settings for PDF renderer. --- .../java/preproc/PdeParseTreeListener.java | 12 ++++- .../processing/mode/java/ParserTests.java | 5 +++ java/test/resources/pdfwrite.expected | 45 +++++++++++++++++++ java/test/resources/pdfwrite.pde | 14 ++++++ 4 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 java/test/resources/pdfwrite.expected create mode 100644 java/test/resources/pdfwrite.pde diff --git a/java/src/processing/mode/java/preproc/PdeParseTreeListener.java b/java/src/processing/mode/java/preproc/PdeParseTreeListener.java index 57c542e449..c28c7b1d56 100644 --- a/java/src/processing/mode/java/preproc/PdeParseTreeListener.java +++ b/java/src/processing/mode/java/preproc/PdeParseTreeListener.java @@ -72,7 +72,8 @@ public class PdeParseTreeListener extends ProcessingBaseListener { private String sketchWidth; private String sketchHeight; - private String sketchRenderer; + private String sketchRenderer = null; + private String sketchOutputFilename = null; private boolean sizeRequiresRewrite = false; private boolean sizeIsFullscreen = false; @@ -620,10 +621,15 @@ protected void handleSizeCall(ParserRuleContext ctx) { sketchRenderer.equals("P3D") || sketchRenderer.equals("OPENGL") || sketchRenderer.equals("JAVA2D") || + sketchRenderer.equals("PDF") || sketchRenderer.equals("FX2D"))) { thisRequiresRewrite = false; } } + + if (argsContext.getChildCount() > 5) { + sketchOutputFilename = argsContext.getChild(6).getText(); + } } if (isFullscreen) { @@ -1003,6 +1009,10 @@ protected void writeExtraFieldsAndMethods(PrintWriterWithEditGen classBodyWriter argJoiner.add(sketchRenderer); } + if (sketchOutputFilename != null) { + argJoiner.add(sketchOutputFilename); + } + settingsInner = String.format("size(%s);", argJoiner.toString()); } diff --git a/java/test/processing/mode/java/ParserTests.java b/java/test/processing/mode/java/ParserTests.java index 8fac2bcd62..08b7fa7d12 100644 --- a/java/test/processing/mode/java/ParserTests.java +++ b/java/test/processing/mode/java/ParserTests.java @@ -378,6 +378,11 @@ public void testPackage() { expectGood("packageTest", true, Optional.of("test.subtest")); } + @Test + public void testPdfWrite() { + expectGood("pdfwrite"); + } + private static boolean compile(String id, String program) { // Create compilable AST to get syntax problems CompilationUnit compilableCU = JdtCompilerUtil.makeAST( diff --git a/java/test/resources/pdfwrite.expected b/java/test/resources/pdfwrite.expected new file mode 100644 index 0000000000..ba2dd5d463 --- /dev/null +++ b/java/test/resources/pdfwrite.expected @@ -0,0 +1,45 @@ +import processing.core.*; +import processing.data.*; +import processing.event.*; +import processing.opengl.*; + +import processing.pdf.*; + +import java.util.HashMap; +import java.util.ArrayList; +import java.io.File; +import java.io.BufferedReader; +import java.io.PrintWriter; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.IOException; + +public class pdfwrite extends PApplet { + + + + public void setup() { + /* size commented out by preprocessor */; +} + + public void draw() { + // Draw something good here + line(0, 0, width/2, height); + + // Exit the program + println("Finished."); + exit(); +} + + + public void settings() { size(400,400,PDF,"filename.pdf"); } + + static public void main(String[] passedArgs) { + String[] appletArgs = new String[] { "pdfwrite" }; + if (passedArgs != null) { + PApplet.main(concat(appletArgs, passedArgs)); + } else { + PApplet.main(appletArgs); + } + } +} \ No newline at end of file diff --git a/java/test/resources/pdfwrite.pde b/java/test/resources/pdfwrite.pde new file mode 100644 index 0000000000..39879a1305 --- /dev/null +++ b/java/test/resources/pdfwrite.pde @@ -0,0 +1,14 @@ +import processing.pdf.*; + +void setup() { + size(400, 400, PDF, "filename.pdf"); +} + +void draw() { + // Draw something good here + line(0, 0, width/2, height); + + // Exit the program + println("Finished."); + exit(); +} \ No newline at end of file