XML Feeds

.

[java-dev] Re: JitterGUI Family Documentation

jbmaxwell jbmaxwell at btinternet.com
Sat Jun 2 08:15:49 MDT 2007


Hello Ben,

I've been trying to wrap my head around gui stuff for the last couple of weeks, and it's giving me a really hard time. I'm sure most of this is simply due to the fact that graphics programming is *very* different from audio/midi - at least to my mind... Anyway, in poking around with your java-jitter gui stuff, I think I've managed to kind of get a sense of what's going on, but I'm still really unclear on how to do the things I need to do. What I want to do is "add" new objects to existing objects, and have those new objects "stick" to the existing (parent) objects, while maintaining the functionality of both child and parent. 
In messing around with this, I've been trying to add a "nested" slider to one of your JitterGuiSliders, to make a kind of "bank". 
I've done some hacking, but it's really not working:

// Created on 3-Sep-2005
import com.cycling74.max.*;
import java.util.*;

/**
 * @author bbn, @destroyed_by jbm
 *
 * Max object container for a single slider
 */
public class JitterGuiSliderBank extends MaxObject {

	private JitterGuiSliderElement s = null;
	private ArrayList<JitterGuiSliderElement> Sliders = null;
	private String context;
		
	public JitterGuiSliderBank(Atom args[])	// initialize with one slider
	{	
		if (args.length == 0)
			bail("gui.slider: need a context argument");
		context = args[0].toString();
		Sliders = new ArrayList<JitterGuiSliderElement>();
		s = new JitterGuiSliderElement(this, new Callback(this, "out"));
		s.init(context);
		Sliders.add(s);
		declareAttribute("color", null, "setColor");
		declareAttribute("rotate", null, "setRotate");
		declareAttribute("position", null, "setPosition");
		declareAttribute("scale", null, "setScale");
	}
	
	public void nestSlider()
	{
	JitterGuiSliderElement sliderOne = Sliders.get(0);
	float homePositionX = sliderOne.position[0];
	float homePositionY = sliderOne.position[1];
	float homePositionZ = sliderOne.position[2];
	post("home position x: " +homePositionX);
	JitterGuiSliderElement slider = new JitterGuiSliderElement(this, new Callback(this, "out"));
	Atom[] setup = new Atom[]{Atom.newAtom((float)homePositionX + 0.4f),
				Atom.newAtom((float)homePositionY + 0.6f), Atom.newAtom((float)homePositionZ)};
	slider.init(context);
	slider.setPosition(setup);
	Sliders.add(slider);
	}

	public void out()
	{
		for(int i=0;i < Sliders.size();i++)
		{
			JitterGuiSliderElement slider = Sliders.get(i);
			outlet(0, slider.val);
		}
	}
	
	public void notifyDeleted()
	{
		for(int i=0;i < Sliders.size();i++)
		{
			JitterGuiSliderElement slider = Sliders.get(i);
			slider.free();
		}
	}
	
	public void setColor(Atom a[]) {s.setColor(a);}
	public void setRotate(Atom a[]) {s.setRotate(a);}
	public void setPosition(Atom a[]) {s.setPosition(a);}
	public void setScale(Atom a[]) {s.setScale(a);}
}


It does create a new, functioning slider. But it then loses the ability to detect the old one with the mouse. Also, the nested slider doesn't move with the initial one. Is there any chance you could give me a quick run-down of how to best manage this? I'd thought about perhaps adding code to JitterGuiElement which would allow the creation of nested objects, but I'm not at all sure how I'd go about doing that. Even if you could outline for me how your js-based sliderrow would work with your java gui classes, that would be awesome. This is doing my head in right now, but I'm sure once I can get a model of it in my head, I'll be able to go from there.

Thanks in advance,

J.


More information about the java-dev mailing list