Search in sources :

Example 6 with CGraphPoint

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

the class Grapher method generateRandomGraph.

public void generateRandomGraph() {
    if (currentGraph == null) {
        return;
    }
    ArrayList points = currentGraph.getPoints();
    points.clear();
    for (int i = 0; i < NOISE_POINTS; i++) {
        CGraphPoint point = new CGraphPoint();
        point.time = (double) Math.random();
        point.value = (double) Math.random();
        points.add(point);
    }
    Collections.sort(points);
    ((CGraphPoint) points.get(0)).time = 0.0f;
    ((CGraphPoint) points.get(points.size() - 1)).time = 1.0f;
    repaint();
}
Also used : CGraphPoint(blue.soundObject.ceciliaModule.CGraphPoint) ArrayList(java.util.ArrayList) CGraphPoint(blue.soundObject.ceciliaModule.CGraphPoint)

Example 7 with CGraphPoint

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

the class Grapher method generateSineGraph.

public void generateSineGraph() {
    if (currentGraph == null) {
        return;
    }
    ArrayList points = currentGraph.getPoints();
    points.clear();
    for (int i = 0; i < NOISE_POINTS; i++) {
        CGraphPoint point = new CGraphPoint();
        double percent = (double) i / (NOISE_POINTS - 1);
        point.time = percent;
        point.value = (double) Math.sin(percent * 2 * Math.PI);
        point.value = (point.value * .5f) + .5f;
        points.add(point);
    }
    repaint();
}
Also used : CGraphPoint(blue.soundObject.ceciliaModule.CGraphPoint) ArrayList(java.util.ArrayList) CGraphPoint(blue.soundObject.ceciliaModule.CGraphPoint)

Example 8 with CGraphPoint

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

the class Grapher method moveDownGraph.

public void moveDownGraph() {
    if (currentGraph == null) {
        return;
    }
    for (Iterator iter = currentGraph.getPoints().iterator(); iter.hasNext(); ) {
        CGraphPoint point = (CGraphPoint) iter.next();
        int val = doubleToScreenY(point.value);
        val += 1;
        if (val > this.getHeight() - 5) {
            val = this.getHeight() - 5;
        }
        point.value = screenToDoubleY(val);
    }
    repaint();
}
Also used : CGraphPoint(blue.soundObject.ceciliaModule.CGraphPoint) Iterator(java.util.Iterator) CGraphPoint(blue.soundObject.ceciliaModule.CGraphPoint)

Example 9 with CGraphPoint

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

the class Grapher method setBoundaryXValues.

public void setBoundaryXValues() {
    ArrayList points = currentGraph.getPoints();
    if (selectedPoint == points.get(0)) {
        leftBoundaryX = 5;
        rightBoundaryX = 5;
        return;
    } else if (selectedPoint == points.get(points.size() - 1)) {
        leftBoundaryX = this.getWidth() - 5;
        rightBoundaryX = this.getWidth() - 5;
        return;
    }
    for (int i = 0; i < points.size(); i++) {
        if (points.get(i) == selectedPoint) {
            CGraphPoint p1 = (CGraphPoint) points.get(i - 1);
            CGraphPoint p2 = (CGraphPoint) points.get(i + 1);
            leftBoundaryX = doubleToScreenX(p1.time);
            rightBoundaryX = doubleToScreenX(p2.time);
            return;
        }
    }
}
Also used : CGraphPoint(blue.soundObject.ceciliaModule.CGraphPoint) ArrayList(java.util.ArrayList) CGraphPoint(blue.soundObject.ceciliaModule.CGraphPoint)

Aggregations

CGraphPoint (blue.soundObject.ceciliaModule.CGraphPoint)9 ArrayList (java.util.ArrayList)5 Iterator (java.util.Iterator)4