Tweaks needed to make a custom Java-based mode?

I am currently trying to develop my first Processing mode.
This mode will be java-based and the code conversion would look like this:

void build(){
//some code
}
//some other methods,global variables etc.

would be converted to

public class SketchClass extends CustomClass{
@Override
public void build(){
//some code
}
//some other methods,global variables etc.

public SketchClass(){
super();
}

public static void main(String args[]){
  new SketchClass();
}
}

In hope to find some place to start I took a look at the following template:

soir20/processing-mode-template: Template to create new modes for the Processing IDE (github.com)

In this template the JavaMode is extended so when compiling the “empty” mode it basicly is the same as Java mode.

The question is: What do I need to to make the changes I need for my custom mode.

Here s what I think to have found out. To load your new core library you have to override the JavaMode.getCoreLibrary method.
Next you have to Override the JavaMode.handleLaunch and basicly copy the original code but replacing JavaBuild with a custom class extending JavaBuild.

In that class your implemenations needs to Override
JavaBuild.preprocess(File,boolean) to also just replace PdePreprocessor with a custom class (also extending PdePreprocessor)

In this class I need to override PdePreprocessor.buildFor(String) wich returns a PdePreprocessorBuilder wich I tried to replace with a custom implementation:

And at that point I hit a wall.

I need to implement the constructor however can’t call the superconstructor as it’s not visible.

I’m sure (or I hope) it’s possible to cut of this chain somewhere, I’m just not sure where.

Any help would be appreciated!

1 Like