Dependencies

A simple demo of the dependency mechanism:

package net.mumie.mathlet.ethz.demo;

import java.awt.event.InputMethodListener;
import javax.swing.JComponent;

import net.mumie.mathletfactory.action.updater.DependencyAdapter;
import net.mumie.mathletfactory.appletskeleton.NoCanvasApplet;
import net.mumie.mathletfactory.appletskeleton.util.ControlPanel;
import net.mumie.mathletfactory.display.noc.MMPanel;
import net.mumie.mathletfactory.mmobject.MMObjectIF;
import net.mumie.mathletfactory.mmobject.util.MMString;

/**
 * Simple demo of how the DependencyAdapter mechanism works. 
 * 
 * @author leiser 
 * @mm.type applet
 * @mm.section content/ethz/demo/media/applets/
 * @mm.copyright Copyright (c) by ETHZ
 * @mm.requireJar system/libraries/jar_mathlet_factory.meta.xml
 * @mm.docstatus
 * @mm.status devel_ok
 * @mm.description DependencyAdapterDemo.
 * @mm.rating none
 * @mm.changelog
 * @mm.width 550
 * @mm.height 300
 */
public class DependencyAdapterDemo    extends NoCanvasApplet {

    private MMString mmstrUpdating, mmstrBeingUpdated;
    private ControlPanel controlPanel;

    public void init() {

            super.init();
            setTitle("Demo: Dependency Adapter Mechanism");
            controlPanel = new ControlPanel();
            addControl(controlPanel);            

            mmstrUpdating = new MMString("a");
            mmstrUpdating.setLabel("String which will update the one below:");
            mmstrUpdating.setEditable(true);

            mmstrBeingUpdated = new MMString("b");
            mmstrBeingUpdated.setLabel("String that is updated by the one above:");

            controlPanel.add(mmstrUpdating.getAsContainerContent());
            controlPanel.insertLineBreak();
            controlPanel.add(mmstrBeingUpdated.getAsContainerContent());

            insertLineBreak();

            DependencyAdapter depAdapter = new DependencyAdapter() {
                public void doUpdate() {
                    mmstrBeingUpdated.setValue(mmstrUpdating.getValue());   
                    mmstrBeingUpdated.render();
                    mmstrBeingUpdated.invokeUpdaters();

                }
            };             

            mmstrBeingUpdated.dependsOn(new MMObjectIF[] {mmstrUpdating}, depAdapter);        

    }

    public void reset() {

    }
}

Add picture from clipboard (Maximum size: 500 MB)