Mmstringmatrix

A simple demo to show the mechanism:

package net.mumie.mathlet.ethz.demo;

import java.awt.Color;
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.matrix.MMStringMatrixPanel;
import net.mumie.mathletfactory.mmobject.util.MMString;
import net.mumie.mathletfactory.mmobject.util.MMStringMatrix;
import net.mumie.mathletfactory.transformer.noc.StringMatrixTransformer;

/**
 * Simple demo of the use of a MMStringMatrix.
 * 
 * @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 MMStringMatrixDemo.
 * @mm.rating none
 * @mm.changelog
 * @mm.width 650
 * @mm.height 800
 */
public class MMStringMatrixDemo    extends NoCanvasApplet {

    private MMStringMatrixPanel mmstringMatrixPanel;
    private MMStringMatrix mmstringMatrix;
    private StringMatrixTransformer stringMatrixTransformer;
    private MMString mmstr;
    private ControlPanel controlPanel;

    public void init() {

            super.init();
            setTitle("Demo: Use of a MMStringMatrix");
            controlPanel = new ControlPanel();
            addControl(controlPanel);            

            mmstr = new MMString("?");

            mmstringMatrix = new MMStringMatrix(2,3);
            stringMatrixTransformer = new StringMatrixTransformer();

            mmstringMatrix.setEntry(1, 1, "-");
            mmstringMatrix.setObjectColor(new Color(255,0,0));
            mmstringMatrix.setVisible(true);
            mmstringMatrix.setEntry(1, 2, "");
            mmstringMatrix.setEntry(1, 3, "");
            mmstringMatrix.setEntry(2, 1, "a");
            mmstringMatrix.setEntry(2, 2, "b");
            mmstringMatrix.setEntry(2, 3, "c");            

            mmstringMatrixPanel = new MMStringMatrixPanel(mmstringMatrix, stringMatrixTransformer);
            mmstringMatrixPanel.setEditable(true);

                mmstringMatrixPanel.setEditable(1, 1, true);
            mmstringMatrixPanel.setEditable(1, 2, true);
            mmstringMatrixPanel.setEditable(1, 3, true);
            mmstringMatrixPanel.setEditable(2, 1, false);
            mmstringMatrixPanel.setEditable(2, 2, false);
            mmstringMatrixPanel.setEditable(2, 3, false);

            controlPanel.add(mmstringMatrixPanel);

            controlPanel.insertLineBreak();
            controlPanel.add(mmstr.getAsContainerContent());
            insertLineBreak();                        

            DependencyAdapter mmstringMatrixToMmstr = new DependencyAdapter() {
                public void doUpdate() {

                    mmstr.setValue(mmstringMatrix.getEntry(1, 1).toString());
                    mmstr.render();
                    mmstr.invokeUpdaters();

                }
            };             

            mmstr.dependsOn(mmstringMatrix, mmstringMatrixToMmstr);

    }

    public void reset() {

    }

}

Add picture from clipboard (Maximum size: 500 MB)