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);
}
}
}
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();
}
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;
}
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;
}
Aggregations