Search in sources :

Example 1 with CSlider

use of blue.soundObject.ceciliaModule.CSlider in project blue by kunstmusik.

the class SliderPanel method stateChanged.

/*
     * (non-Javadoc)
     * 
     * @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent)
     */
@Override
public void stateChanged(ChangeEvent e) {
    if (!updating) {
        FloatSlider fSlider = (FloatSlider) e.getSource();
        String name = fSlider.getName();
        CSlider slider = (CSlider) dataValues.get(name);
        DisplayLabel label = (DisplayLabel) displayLabelMap.get(name);
        if (slider != null) {
            float newValue = fSlider.getValueFromRange();
            float truncatedValue = newValue - (newValue % slider.getResolution());
            // System.out.println(newValue + " : " + truncatedValue);
            slider.setValue(truncatedValue);
            label.setText(Float.toString(truncatedValue));
        }
    }
}
Also used : CSlider(blue.soundObject.ceciliaModule.CSlider)

Example 2 with CSlider

use of blue.soundObject.ceciliaModule.CSlider in project blue by kunstmusik.

the class CeciliaModuleEditor method createDefaultStateData.

/**
 * @param moduleDefinition
 * @return
 */
private HashMap createDefaultStateData(ModuleDefinition moduleDefinition) {
    String tk_interface = moduleDefinition.tk_interface;
    StringTokenizer st = new StringTokenizer(tk_interface, "\n");
    String line;
    HashMap stateData = new HashMap();
    while (st.hasMoreTokens()) {
        line = st.nextToken().trim();
        if (line.length() == 0) {
            continue;
        }
        String[] tokens = TextUtilities.splitStringWithQuotes(line);
        String objectType = tokens[0];
        if (!objectType.equals("csepar") && tokens.length == 1) {
            // show some error
            continue;
        }
        if (objectType.equals("csepar")) {
            continue;
        }
        String objectName = tokens[1];
        CeciliaObject cObj = null;
        switch(objectType) {
            case "cfilein":
                CeciliaObject fileIn = new CFileIn();
                cObj = fileIn;
                break;
            case "cpopup":
                CPopup popup = new CPopup();
                cObj = popup;
                break;
            case "ctoggle":
                CToggle toggle = new CToggle();
                cObj = toggle;
                break;
            case "cslider":
                CSlider slider = new CSlider();
                cObj = slider;
                break;
            case "cgraph":
                CGraph graph = new CGraph();
                cObj = graph;
                break;
            default:
                break;
        }
        cObj.initialize(tokens);
        stateData.put(objectName, cObj);
    // ObjectUtilities.printMembers(cObj);
    }
    return stateData;
}
Also used : StringTokenizer(java.util.StringTokenizer) CToggle(blue.soundObject.ceciliaModule.CToggle) CSlider(blue.soundObject.ceciliaModule.CSlider) HashMap(java.util.HashMap) CeciliaObject(blue.soundObject.ceciliaModule.CeciliaObject) CPopup(blue.soundObject.ceciliaModule.CPopup) CGraph(blue.soundObject.ceciliaModule.CGraph) CFileIn(blue.soundObject.ceciliaModule.CFileIn)

Example 3 with CSlider

use of blue.soundObject.ceciliaModule.CSlider in project blue by kunstmusik.

the class SliderPanel method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    FloatSlider fSlider = (FloatSlider) e.getSource();
    String name = fSlider.getName();
    CSlider slider = (CSlider) dataValues.get(name);
    DisplayLabel label = (DisplayLabel) displayLabelMap.get(name);
    String command = e.getActionCommand();
    if (slider != null) {
        float val = slider.getValue();
        if (command.equals("nudgeLeft")) {
            val -= slider.getResolution();
        } else if (command.equals("nudgeRight")) {
            val += slider.getResolution();
        }
        slider.setValue(val);
        label.setText(Float.toString(val));
        float max = slider.getMax();
        float min = slider.getMin();
        float sliderVal = (val - min) / (max - min);
        fSlider.setValue(sliderVal);
    }
}
Also used : CSlider(blue.soundObject.ceciliaModule.CSlider)

Example 4 with CSlider

use of blue.soundObject.ceciliaModule.CSlider in project blue by kunstmusik.

the class SliderPanel method editCeciliaModule.

/**
 * @param ceciliaModule
 */
public void editCeciliaModule(CeciliaModule ceciliaModule) {
    updating = true;
    HashMap map = ceciliaModule.getStateData();
    if (map.size() == 0) {
        return;
    }
    for (Iterator iter = map.values().iterator(); iter.hasNext(); ) {
        CeciliaObject element = (CeciliaObject) iter.next();
        if (element instanceof CSlider) {
            CSlider slider = (CSlider) element;
            setupCslider(slider);
        }
    }
    updating = false;
}
Also used : CSlider(blue.soundObject.ceciliaModule.CSlider) HashMap(java.util.HashMap) CeciliaObject(blue.soundObject.ceciliaModule.CeciliaObject) Iterator(java.util.Iterator)

Aggregations

CSlider (blue.soundObject.ceciliaModule.CSlider)4 CeciliaObject (blue.soundObject.ceciliaModule.CeciliaObject)2 HashMap (java.util.HashMap)2 CFileIn (blue.soundObject.ceciliaModule.CFileIn)1 CGraph (blue.soundObject.ceciliaModule.CGraph)1 CPopup (blue.soundObject.ceciliaModule.CPopup)1 CToggle (blue.soundObject.ceciliaModule.CToggle)1 Iterator (java.util.Iterator)1 StringTokenizer (java.util.StringTokenizer)1