Ok, so I adapted the code to try and simplify it for my purposes, and have this:
import g4p_controls.*;
OtherWindowData baseWindow;
void setup() {
size(400, 400);
println(width, height, displayWidth, displayHeight);
surface.setTitle("test!");
// surface.setResizable(true);
surface.setLocation(300, 100);
// surface.hideCursor();
surface.setCursor(0);
//println(surface.getLocation());
println(surface.getNative());
int a = 0;
a = 6;
/*
GWindow window;
// Then create the window(480x320 pixels) and show it at position [40,20]
window = GWindow.getWindow(this, 40, 20, 480, 320, JAVA2D);
*/
//baseWindow = new OtherWindow(-2d, -1.25d, 0.5d, 1.25d, 400, 400);
baseWindow = new OtherWindowData(new PVector(100, 100), new PVector(400, 400));
registerMethod("mouseEvent", this);
// makeNewWindow(new PVector(displayWidth - 200, 100), new PVector(300, 100));
}
void makeNewWindow(PVector pos, PVector size) {
GWindow window = null;
String title = "new window";
/*
float winPosX = pos.x;
float winPosY = pos.y;
*/
// OtherWindow w = new OtherWindow(nsx, nsy, nex, ney, w, h); // data
OtherWindowData wData = new OtherWindowData(pos, size); // data
window = GWindow.getWindow(this, title, (int)pos.x, (int)pos.y, (int)size.x, (int)size.y, JAVA2D); // this creates the window http://www.lagers.org.uk/g4p/ref/classg4p__controls_1_1_g_window.html#ae31d24b803de163948350db3d885b831
window.addData(wData);
window.addDrawHandler(this, "renderPlot");
window.addMouseHandler(this, "processMouseEvent");
window.setActionOnClose(G4P.CLOSE_WINDOW);
// new Thread(wData).start();
}
void draw() {
background(200, 200, 255);
}
void mouseEvent(MouseEvent event) {
processMouseEvent(this, baseWindow, event);
}
void processMouseEvent(PApplet appc, GWinData data, MouseEvent event) {
OtherWindowData md = (OtherWindowData)data;
switch(event.getAction()) {
case MouseEvent.PRESS:
break;
case MouseEvent.DRAG:
break;
case MouseEvent.RELEASE:
makeNewWindow(new PVector(displayWidth - 200, 100), new PVector(300, 100));
break;
}
}
class OtherWindowData extends GWinData {
// public int msx, msy, mex, mey;
// public final double sx, sy, ex, ey;
public final int w, h;
public PGraphics pg;
public boolean working = true;
// used to count iteration range used.
public int minC = 999, maxC = -999;
/**
* Create the Mandelbrot plot based on the complex plane
* coordinates provided
* @param sx minimum real value
* @param sy maximum real value
* @param ex minimum imaginary value
* @param ey maximum imaginary vale
* @param w pixel width for the plot
* @param h pixel height for the plot
*/
// public OtherWindowData(double sx, double sy, double ex, double ey, int w, int h) {
public OtherWindowData(PVector pos, PVector size) {
super();
/*
this.sx = sx;
this.sy = sy;
this.ex = ex;
this.ey = ey;
*/
this.w = (int)size.x;
this.h = (int)size.y;
pg = createGraphics(this.w, this.h, JAVA2D);
pg.beginDraw();
pg.background(60);
pg.textSize(24);
pg.textAlign(CENTER, CENTER);
pg.fill(0, 255, 0);
pg.text("Working ...", 0, 0, this.w, this.h);
pg.endDraw();
}
// This is a separate thread to calculate the Mandelbrot plot
public void draw() {
println("test");
}
public String toString() {
// overrides the name for the window
return super.toString();
}
}
So, it runs and I can click to open new ones. Going to test with more stuff soon (changing size and calling global functions from them and vice versa, but that seems simple enough); any glaring issues though?