basically, how to create Processing 3.0.2 Tool is the same as 2.x
Environment
- Windows 10 (64 bit)
- Eclipse (Mars)
- Processing 3.0.2
- JDK 1.8 (Java SE 8)
- processing-tool-template(from GitHub)
Step
Download the zip: processing-tool-template (v3.0.2) https://github.com/processing/processing-tool-template/releases (version is 3.0.2 ...maybe go well !!!)
Eclipse: new Java Project ("testTools": my case) -> import archive file (zip)
Copy core.jar & pde.jar -> Paste in : {your project name}>src>processing-tool-templates-3.0.2>lib
- core.jar (Processing-3.0.2>core>library)
- pde.jar (Processing-3.0.2>lib)
right click on core.jar & pde.jar -> Build Path>Add to Build Path (seemed to move)
Edit build.properties (src>processing-tool-templates-3.0.2>resources)
path is my case- sketch book path (Default: ${user.home}\Documents\Processing)
- sketchbook.location=${user.home}\Documents\Processing3
- core.jar path
- classpath.local.location=${user.home}\Downloads\PROGRAM\Processing\processing-3.0.2\core\library
- libraies path (Default: ${sketchbook.location}/libraries)
- classpath.libraries.location=${sketchbook.location}/libraries
- java.target.version=1.8
- (if you want) other property: Tool name, Author, Your URL ...
- sketch book path (Default: ${user.home}\Documents\Processing)
Ant build (Eclipse)
- show Ant tab
- Eclipse: Window>show View>other -> click Ant -> Ant tab appear (int the lower window)
- build.xml (src>resources) -> drag & drop in Ant tab -> close Processing (while building)
- push Run button in Ant tab -> watch console (build finished in about 5 sec)
- if (BUILD SUCCESSFUL) -> HelloTool is in Processing (PDE), else check build.properties and .jar file
- show Ant tab
Let's edit
HelloTool.java (src>processing-tool...>src>template>tool>HelloTool.java)
example : when you select the HelloTool, print all your code in PDE
package template.tool; import processing.app.Base; import processing.app.tools.Tool; import processing.app.ui.Editor; public class HelloTool implements Tool { // class name = project.name (build.properties) Base base; public void init(Base base) { this.base = base; // Store a reference to the Processing application itself } public String getMenuTitle() { // displayed with tools list return "##tool.name##"; } public void run() { Editor editor = base.getActiveEditor(); // Get the currently active Editor to run the Tool on it System.out.println("Hello Tool. ##tool.name## ##tool.prettyVersion## by ##author##"); // <- build.property for (int i = 0; i < editor.getLineCount(); i++){ String s = editor.getLineText(i); System.out.println(i + " : " + s); } } }