FileDocCategorySizeDatePackage
BasicJMD.javaAPI DocJMF 2.1.1e9607Mon May 12 12:20:50 BST 2003com.sun.media

BasicJMD

public final class BasicJMD extends Panel implements JMD, WindowListener

Fields Summary
Vector
modList
Vector
conList
boolean
graphic
Panel
center
Label
status
Frame
frame
boolean
activated
Button
button
Dimension
preferredSize
int
ro
int
col
int
colMax
int
roMax
int
wrapWidth
int
wrapHeight
int
offX
int
offY
int
fill
int
cSize
Constructors Summary
public BasicJMD(String title)

    
       
	setLayout(new BorderLayout());
	setBackground(Color.lightGray);
	center = new Panel() {
	    public Dimension getPreferredSize() {
		return preferredSize;
	    }
	};
	center.setLayout(null);
	add("North", center);
	status = new Label();
	add("South", status);
	setSize(512, 200);
    
Methods Summary
public voidcreateModuleWrap(com.sun.media.BasicModule m, int row, int column, int h)

        //System.err.println(m + " " + row + " " + column);
        Object plugin = m;
        if (m instanceof BasicSourceModule)
            plugin = ((BasicSourceModule)m).getDemultiplexer();
        else if (m instanceof BasicFilterModule)
            plugin = ((BasicFilterModule)m).getCodec();
        else if (m instanceof BasicRendererModule)
            plugin = ((BasicRendererModule)m).getRenderer();
	else if (m instanceof BasicMuxModule)
	    plugin = ((BasicMuxModule)m).getMultiplexer();
	
        String name = ((PlugIn)plugin).getName();
        //name = name.substring(name.lastIndexOf(".") + 1);
        Button b = new ModButton(name, m, (PlugIn)plugin);
        b.setName("M" + m.hashCode());
        modList.addElement(b);
        b.setBackground(new Color(192, 192, 128));
        b.setForeground(Color.black);
        center.add(b);
        b.setBounds(offX + column * wrapWidth + fill, 
                    offY + row * wrapHeight + fill, 
                    wrapWidth - fill * 2, h * wrapHeight - fill * 2);
        b.setVisible(true);
        center.invalidate();
    
public synchronized voiddispose()

	if (frame != null) {
	    frame.dispose();
	    frame = null;
	}
    
public voiddrawGraph(com.sun.media.BasicModule source)

        Module m;
	OutputConnector oc;
	InputConnector ic;
	String names[];
        
	names = source.getOutputConnectorNames();
	int height = names.length;
	if (height == 0)
	    height = 1;
	createModuleWrap(source, ro, col, height);
	if (roMax < names.length)
	    roMax = names.length;
	for (int i = 0; i < names.length; i++) {
	    oc = source.getOutputConnector(names[i]);
	    if ((ic = oc.getInputConnector()) == null) {
		if (col == 0)
		    ro++;
		continue;
	    }
	    if ((m = ic.getModule()) == null) {
		if (col == 0)
		    ro++;
		continue;
	    }
	    col++;
	    if (col > colMax)
		colMax = col;
	    drawGraph((BasicModule)m);
	    col--;
	    if (col == 0)
		ro++;
	}
    
public com.sun.media.BasicJMD$ConfindConnector(com.sun.media.BasicModule bm, int index, int inOut)

        String name = "C" + bm.hashCode() + index + inOut;
        Enumeration e = conList.elements();
        while (e.hasMoreElements()) {
            Con c = (Con) e.nextElement();
            if (c.getName().equals(name))
                return c;
        }
	
	Component m = findModule(bm);
	if (m == null)
	    return null;
        Point p = m.getLocation();
        Con c = new Con();
        center.add(c);
        c.setBounds(p.x - fill + (wrapWidth - fill) * inOut, 
                    p.y + (wrapHeight-2*fill-cSize) / 2 + wrapHeight * index,
                    cSize, cSize);
        c.setName(name);
        conList.addElement(c);
        return c;
    
public java.awt.ComponentfindModule(com.sun.media.BasicModule bm)

        String name = "M" + bm.hashCode();
        Enumeration e = modList.elements();
        while (e.hasMoreElements()) {
            Component c = (Component) e.nextElement();
            if (c.getName().equals(name))
                return c;
        }
        return null;
    
public java.awt.ComponentgetControlComponent()

	if (button == null) {
	    button = new Button("PlugIn Viewer") {
		public void removeNotify() {
		    super.removeNotify();
		    dispose();
		}
	    };
	    button.setName("PlugIns");
	    button.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent ae) {
		    BasicJMD.this.setVisible( true );
		}
	    } );
	}
	return button;
    
public voidinitGraph(com.sun.media.BasicModule source)

    
        
        center.removeAll();
        modList = new Vector();
        conList = new Vector();
        drawGraph(source);
        ro = 0;
        col = 0;
	preferredSize = new Dimension((colMax + 1) * wrapWidth + offX * 2,
				      (roMax) * wrapHeight + offY * 2);
	//pack();
    
public voidmoduleIn(com.sun.media.BasicModule bm, int index, javax.media.Buffer d, boolean here)

        updateConnector(bm, index, d, here, 0);
    
public voidmoduleOut(com.sun.media.BasicModule bm, int index, javax.media.Buffer d, boolean here)

        updateConnector(bm, index, d, here, 1);
    
public synchronized voidsetVisible(boolean visible)

	if (getParent() == null) {
	    if (visible) {
		if (frame == null) {
		    frame = new Frame("PlugIn Viewer");
		    frame.setLayout( new BorderLayout() );
		    frame.add("Center", this);
		    frame.addWindowListener(this);
		    frame.pack();
		    frame.setVisible(true);
		}
	    }
	} else if (getParent() == frame) {
	    frame.setVisible(visible);
	} else
	    super.setVisible(visible);
    
public voidupdateConnector(com.sun.media.BasicModule bm, int index, javax.media.Buffer d, boolean here, int inOut)

	if (!activated)
	    return;
        Con c = findConnector(bm, index, inOut);
	if (c == null)
	    return;
        c.setData(d);
        // System.out.println("upd " + c.getName());
        if (true) {
            if (here) {
		if (d.isEOM())
                    c.flash(Color.red);
                else if (d.isDiscard())
                    c.flash(Color.yellow);
                else 
                    c.flash(Color.green);
            } else
                c.flash(Color.gray);
                
            // c.repaint();
        }
    
public voidwindowActivated(java.awt.event.WindowEvent we)

	activated = true;
    
public voidwindowClosed(java.awt.event.WindowEvent we)

    
public voidwindowClosing(java.awt.event.WindowEvent we)

	setVisible(false);
    
public voidwindowDeactivated(java.awt.event.WindowEvent we)

	activated = false;
    
public voidwindowDeiconified(java.awt.event.WindowEvent we)

    
public voidwindowIconified(java.awt.event.WindowEvent we)

    
public voidwindowOpened(java.awt.event.WindowEvent we)