Search in sources :

Example 1 with CGraph

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

the class Grapher method paintComponent.

@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g;
    RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2d.setRenderingHints(hints);
    // g.setColor(bgColor);
    g2d.setColor(Color.black);
    g2d.fillRect(0, 0, this.getWidth(), this.getHeight());
    g2d.setColor(Color.DARK_GRAY.darker());
    // DRAW X-LINES
    int h = this.getHeight() - 10;
    int right = this.getWidth() - 5;
    for (int i = 0; i < 12; i++) {
        int y = (int) ((i / 12.0f) * h);
        g2d.drawLine(5, y, right, y);
    }
    // DRAW Y-LINES
    int w = this.getWidth() - 10;
    int bottom = this.getHeight() - 5;
    for (int i = 0; i < 12; i++) {
        int x = (int) ((i / 12.0f) * w);
        g2d.drawLine(x, 5, x, bottom);
    }
    // DRAW BORDER
    g2d.setColor(Color.lightGray);
    g2d.drawRect(5, 5, this.getWidth() - 10, this.getHeight() - 10);
    // g.setColor(Color.white);
    int colorIndex = 0;
    Color currentColor = null;
    // for(Iterator iter = graphs.values().iterator(); iter.hasNext();) {
    for (Iterator iter = graphOrder.iterator(); iter.hasNext(); ) {
        String objectName = (String) iter.next();
        CGraph tempGraph = (CGraph) graphs.get(objectName);
        if (tempGraph == currentGraph) {
            currentColor = LineColors.getColor(colorIndex);
            colorIndex++;
        } else {
            // if(tempGraph.getColor().equals("")) {
            g2d.setColor(LineColors.getLightColor(colorIndex));
            colorIndex++;
            // } else {
            // g2d.setColor(LineColors.getLightColor(tempGraph
            // .getColor()));
            // }
            drawGraph(g2d, tempGraph, false);
        }
    }
    if (currentColor != null) {
        g2d.setColor(currentColor);
        drawGraph(g2d, currentGraph, true);
    }
    if (selectedPoint != null) {
        int x = doubleToScreenX(selectedPoint.time);
        int y = doubleToScreenY(selectedPoint.value);
        g2d.setColor(Color.red);
        paintPoint(g2d, x, y);
        if (currentGraph != null) {
            drawPointInformation(g2d, x, y);
        }
    }
}
Also used : Color(java.awt.Color) Iterator(java.util.Iterator) CGraph(blue.soundObject.ceciliaModule.CGraph) RenderingHints(java.awt.RenderingHints) CGraphPoint(blue.soundObject.ceciliaModule.CGraphPoint) Graphics2D(java.awt.Graphics2D)

Example 2 with CGraph

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

the class Grapher method editCeciliaModule.

public void editCeciliaModule(CeciliaModule ceciliaModule) {
    this.ceciliaModule = ceciliaModule;
    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 CGraph) {
            CGraph graph = (CGraph) element;
            graphs.put(graph.getObjectName(), graph);
            if (currentGraph == null) {
                currentGraph = graph;
            }
        }
    }
    repaint();
}
Also used : HashMap(java.util.HashMap) CeciliaObject(blue.soundObject.ceciliaModule.CeciliaObject) Iterator(java.util.Iterator) CGraph(blue.soundObject.ceciliaModule.CGraph)

Example 3 with CGraph

use of blue.soundObject.ceciliaModule.CGraph 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 4 with CGraph

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

the class CybilCompiler method compileNode.

/**
 * @param node
 * @param pfield
 * @param nl
 * @return
 */
private static CybilArg compileNode(CybilNode node, CybilNoteList cybNoteList, CeciliaModule cm) {
    ArrayList args = node.args;
    CybilArg retArg = null;
    retArg = createCybilArg((String) args.get(0));
    if (retArg != null) {
        for (int i = 1; i < args.size(); i++) {
            Object obj = args.get(i);
            if (obj instanceof CybilNode) {
                retArg.args.add(compileNode((CybilNode) obj, cybNoteList, cm));
            } else {
                retArg.args.add(obj);
            }
        }
        if (retArg instanceof gr) {
            String graphName = (String) retArg.args.get(0);
            CGraph cGraph = (CGraph) cm.getStateData().get(graphName);
            ((gr) retArg).setCGraph(cGraph);
        }
    }
    return retArg;
}
Also used : ArrayList(java.util.ArrayList) CGraph(blue.soundObject.ceciliaModule.CGraph)

Aggregations

CGraph (blue.soundObject.ceciliaModule.CGraph)4 CeciliaObject (blue.soundObject.ceciliaModule.CeciliaObject)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 CFileIn (blue.soundObject.ceciliaModule.CFileIn)1 CGraphPoint (blue.soundObject.ceciliaModule.CGraphPoint)1 CPopup (blue.soundObject.ceciliaModule.CPopup)1 CSlider (blue.soundObject.ceciliaModule.CSlider)1 CToggle (blue.soundObject.ceciliaModule.CToggle)1 Color (java.awt.Color)1 Graphics2D (java.awt.Graphics2D)1 RenderingHints (java.awt.RenderingHints)1 ArrayList (java.util.ArrayList)1 StringTokenizer (java.util.StringTokenizer)1