Java Code Examples for processing.core.PApplet#registerMethod()

The following examples show how to use processing.core.PApplet#registerMethod() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Spout.java    From haxademic with MIT License 6 votes vote down vote up
/**
 * Create a Spout Object.
 * 
 * A spout object is created within the JNI dll
 * and a pointer to it saved in this class for
 * use with all functions.
 * 
 * @param parent
 */
public Spout (PApplet parent) {

	// A pointer to the new spout object for this instance
	spoutPtr = JNISpout.init();
	
	if(spoutPtr == 0) 
		PGraphics.showWarning("Spout initialization failed");

	this.parent = parent;
	
	pgl = (PGraphicsOpenGL) parent.g;
	dim[0] = 0; // Sender width
	dim[1] = 0; // Sender height
	bSenderInitialized = false;
	bReceiverInitialized = false;
	senderName = "";
	invertMode = -1; // User has not set any mode - use function defaults
	
	parent.registerMethod("dispose", this);
	
}
 
Example 2
Source File: DwColorPicker.java    From PixelFlow with MIT License 5 votes vote down vote up
public DwColorPicker(PApplet papplet, int cp_x, int cp_y, int cp_w, int cp_h, int shades_y){
  this.papplet = papplet;
  papplet.registerMethod("pre", this);
  setAutoDraw(true);
  setAutoMouse(true);
  setDrawCanvas(papplet.g); 
  setPosition(cp_x, cp_y);
  setSize(cp_w, cp_h);
  createPallette(shades_y);
  LAST_USED = this;
}
 
Example 3
Source File: GifMaker.java    From gif-animation with GNU General Public License v3.0 5 votes vote down vote up
public GifMaker(PApplet parent, String filename, int quality, int bgColor) {
	this.parent = parent;
	parent.registerMethod("dispose", this);
	encoder = initEncoder(filename);
	setQuality(quality);
	setTransparent(bgColor);
}
 
Example 4
Source File: Engine.java    From processing-sound with GNU Lesser General Public License v2.1 4 votes vote down vote up
private Engine(PApplet theParent) {
	// only call initalisation steps if not already initialised
	if (Engine.singleton != null) {
		return;
	}

	// suppress JSyn's INFO log messages to stop them from showing
	// up as redtext in the Processing console
	Logger logger = Logger.getLogger(com.jsyn.engine.SynthesisEngine.class.getName());
	logger.setLevel(Level.WARNING);

	// create and start the synthesizer, and set this object as the singleton.
	this.synth = JSyn.createSynthesizer(Engine.getAudioManager());

	// select default devices
	for (int i = 0; i < Engine.getAudioManager().getDeviceCount(); i++) {
		if (Engine.checkDeviceHasOutputs(i)) {
			this.outputDevice = i;
			break;
		}
		if (i == Engine.getAudioManager().getDeviceCount()) {
			Engine.printError("library initalization failed: could not find any audio devices with a stereo output");
			return;
		}
	}
	for (int i = 0; i < Engine.getAudioManager().getDeviceCount(); i++) {
		if (Engine.checkDeviceHasInputs(i)) {
			this.inputDevice = i;
			break;
		}
		if (i == Engine.getAudioManager().getDeviceCount()) {
			Engine.printWarning("could not find any sound devices with input channels, you won't be able to use the AudioIn class");
		}
	}

	this.lineOut = new LineOut(); // stereo lineout by default
	this.synth.add(lineOut);
	this.lineOut.start();

	this.leftOut = new Multiply();
	this.rightOut = new Multiply();
	this.setVolume(1.0f);
	this.leftOut.output.connect(0, this.lineOut.input, 0);
	this.rightOut.output.connect(0, this.lineOut.input, 1);
	this.synth.add(this.leftOut);
	this.synth.add(this.rightOut);

	this.startSynth();
	Engine.singleton = this;

	// register Processing library callback methods
	Object callback = new Callback();
	theParent.registerMethod("dispose", callback);
	// Android only
	theParent.registerMethod("pause", callback);
	theParent.registerMethod("resume", callback);
}
 
Example 5
Source File: Camera.java    From PapARt with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setParent(PApplet applet) {
    this.parent = applet;
    applet.registerMethod("dispose", this);
}
 
Example 6
Source File: GifMaker.java    From gif-animation with GNU General Public License v3.0 4 votes vote down vote up
public GifMaker(PApplet parent, String filename) {
	this.parent = parent;
	parent.registerMethod("dispose", this);
	encoder = initEncoder(filename);
}
 
Example 7
Source File: GifMaker.java    From gif-animation with GNU General Public License v3.0 4 votes vote down vote up
public GifMaker(PApplet parent, String filename, int quality) {
	this.parent = parent;
	parent.registerMethod("dispose", this);
	encoder = initEncoder(filename);
	setQuality(quality);
}
 
Example 8
Source File: ProcessingTouchEvents.java    From Circle-Synth with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructor. Specify PApplet.
 * @param p PApplet
 */
ProcessingTouchEvents(PApplet p) {
	this.p = p;
	p.registerMethod("mouseEvent", this);
}