樹脂が固まる前に

AndroidとWebフロントエンドを主にいじっている学生のメモ

Create original Mode for Processing 3.0.2

Original Mode extends Java Mode (Default Mode)
similar when create Tool

pvcresin.hatenablog.com

refer: ProcessingのModeを作る - gutugutu3030

Environment

  • Windows 10 (64 bit)
  • Eclipse (Mars)
  • Processing 3.0.2
  • JDK 1.8 (Java SE 8)
  • Mode Template for Processing 2.0 (for 2.0...)

github.com

Step

Download the zip

TemplateMode-master.zip (=archive file) from github

Create new project

Eclipse: new Java Project ("testMode": my case) -> import archive file (zip)

Copy jar files

Copy core.jar & pde.jar & many jar files(JavaMode.jar, jdi.jar, ...) -> Paste in : {your project name}>src>TemplateMode-master>lib - core.jar (Processing-3.0.2>core>library) - pde.jar (Processing-3.0.2>lib) - *.jar (Processing-3.0.2>modes>java>mode) = (18 jar files)

Add to Build Path

  1. select all jar files(TemplateMode-master>lib)
  2. right click
  3. Build Path>Add to Build Path (seemed to move)

f:id:pvcresin:20160317202945p:plain

Edit build.xml (src>TemplateMode-master)

path is my case

Edit at least

  • JDK version
  • core.jar path
  • pde.jar path
  • processing.exe path (Processing-3.0.2)
  • (if you want) Mode name, Version ...
<!-- java version -->
<property name="java.target.version" value="1.8" />

<!-- location of processing jars (core.jar, pde.jar, ..) -->
<property name="processing.classes.core" location="${user.home}\\Downloads\\PROGRAM\\Processing\\processing-3.0.2\\core\\library" />
<property name="processing.classes.pde" location="${user.home}\\Downloads\\PROGRAM\\Processing\\processing-3.0.2\\lib" />

<!-- folder to install modes in (probably a folder called "modes" inside your sketchbook folder) -->
<property name="processing.modes" location="${user.home}\\Documents\\Processing3\\modes"/>

<!-- path to your processing executable. -->
<property name="processing.executable" location="${user.home}\\Downloads\\PROGRAM\\Processing\\processing-3.0.2\\processing.exe"/>

Change import statements

Edit TemplateMode.java (src>TemplateMode-master>src>com>mydomain>mymode)

//package com.mydomain.mymode;

import java.io.File;
import processing.app.Base;
//import processing.app.Editor;  // 2.x
import processing.app.ui.Editor;  // 3.0.2
//import processing.app.EditorState;  // 2.x
import processing.app.ui.EditorState;  // 3.0.2
import processing.app.Mode;
import processing.mode.java.JavaMode;

public class TemplateMode extends JavaMode { 
    public TemplateMode(Base base, File folder) {
        super(base, folder);
    }

    /**
     * Return the pretty/printable/menu name for this mode. This is separate
     * from the single word name of the folder that contains this mode. It could
     * even have spaces, though that might result in sheer madness or total
     * mayhem.
     */
    @Override
    public String getTitle() {
        return "Mode Template";
    }    
    // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
   
    // Create a new editor associated with this mode.
//    @Override
//    public Editor createEditor(Base base, String path, EditorState state) {
//         return null;
//    }    

    // Returns the default extension for this editor setup.
//    @Override
//    public String getDefaultExtension() {
//        return null;
//    }

    // Returns a String[] array of proper extensions.    
//    @Override
//    public String[] getExtensions() {
//        return null;
//    }

    // Get array of file/directory names that needn't be copied during "Save As".    
//    @Override
//    public String[] getIgnorable() {
//        return null;
//    }
    
    /**
     * Retrieve the ClassLoader for JavaMode. This is used by Compiler to load
     * ECJ classes. Thanks to Ben Fry.
     * @return the class loader from java mode
     */
//    @Override
//    public ClassLoader getClassLoader() {
//        for (Mode m : base.getModeList()) {
//            if (m.getClass() == JavaMode.class) {
//                JavaMode jMode = (JavaMode) m;
//                return jMode.getClassLoader();
//            }
//        }
//        return null;  // badness
//    }

}

Ant build (Eclipse)

  1. show Ant tab
    • Eclipse: Window>show View>other -> click Ant -> Ant tab appear (int the lower window)
  2. build.xml (src>resources) -> drag & drop on Ant tab -> close Processing (while building)
  3. push Run button in Ant tab -> watch console (build finished in about 2 sec)
  4. if (BUILD SUCCESSFUL) -> Template Mode is in your Processing (PDE), else check build.xml and .jar file f:id:pvcresin:20160317202214p:plain