Search in sources :

Example 21 with LinePoint

use of blue.components.lines.LinePoint in project blue by kunstmusik.

the class SoundEditor method editScoreObject.

@Override
public final void editScoreObject(ScoreObject sObj) {
    if (sObj == null) {
        this.sObj = null;
        editorLabel.setText("no editor available");
        editor.editInstrument(null);
        return;
    }
    if (!(sObj instanceof Sound)) {
        this.sObj = null;
        editorLabel.setText("no editor available");
        editor.editInstrument(null);
        return;
    }
    if (this.sObj != null) {
        final Sound temp = this.sObj;
        BlueFX.runOnFXThread(() -> {
            temp.commentProperty().unbind();
            temp.removeScoreObjectListener(sObjListener);
        });
    }
    this.sObj = (Sound) sObj;
    editor.editInstrument(this.sObj.getBlueSynthBuilder());
    BlueFX.runOnFXThread(() -> {
        lineList.clear();
        int colorCount = 0;
        for (Parameter p : this.sObj.getBlueSynthBuilder().getParameterList().sorted()) {
            if (p.isAutomationEnabled()) {
                p.getLine().setVarName(p.getName());
                p.getLine().setColor(LineColors.getColor(colorCount++));
                List<LinePoint> points = p.getLine().getObservableList();
                if (points.size() < 2) {
                    LinePoint lp = new LinePoint();
                    lp.setLocation(1.0, points.get(0).getY());
                    points.add(lp);
                }
                lineList.add(p.getLine());
            }
        }
        lineView.setStartTime(this.sObj.getStartTime());
        lineView.setDuration(this.sObj.getSubjectiveDuration());
        commentTextArea.setText(this.sObj.getComment());
        this.sObj.commentProperty().bind(commentTextArea.textProperty());
        this.sObj.addScoreObjectListener(sObjListener);
    });
}
Also used : LinePoint(blue.components.lines.LinePoint) Parameter(blue.automation.Parameter) Sound(blue.soundObject.Sound) LinePoint(blue.components.lines.LinePoint)

Example 22 with LinePoint

use of blue.components.lines.LinePoint in project blue by kunstmusik.

the class ParameterLinePanel method findGraphPoint.

public LinePoint findGraphPoint(int x) {
    Line currentLine = currentParameter.getLine();
    for (int i = 0; i < currentLine.size(); i++) {
        LinePoint point = currentLine.getLinePoint(i);
        int tempX = doubleToScreenX(point.getX());
        if (tempX >= x - 2 && tempX <= x + 2) {
            return point;
        }
    }
    return null;
}
Also used : Line(blue.components.lines.Line) LinePoint(blue.components.lines.LinePoint) Point(java.awt.Point) LinePoint(blue.components.lines.LinePoint)

Example 23 with LinePoint

use of blue.components.lines.LinePoint in project blue by kunstmusik.

the class TempoEditor method insertGraphPoint.

/**
 * Use by the MouseListener to add points
 *
 * @param x
 * @param y
 * @return
 */
protected LinePoint insertGraphPoint(int x, int y) {
    LinePoint point = new LinePoint();
    Line currentLine = tempo.getLine();
    double min = currentLine.getMin();
    double max = currentLine.getMax();
    point.setLocation(screenToDoubleX(x), screenToDoubleY(y, min, max, -1));
    int index = 1;
    LinePoint last = currentLine.getLinePoint(currentLine.size() - 1);
    if (point.getX() > last.getX()) {
        currentLine.addLinePoint(point);
        return point;
    }
    for (int i = 0; i < currentLine.size(); i++) {
        LinePoint p1 = currentLine.getLinePoint(i);
        LinePoint p2 = currentLine.getLinePoint(i + 1);
        if (point.getX() >= p1.getX() && point.getX() <= p2.getX()) {
            index = i + 1;
            break;
        }
    }
    currentLine.addLinePoint(index, point);
    return point;
}
Also used : Line(blue.components.lines.Line) LinePoint(blue.components.lines.LinePoint) Point(java.awt.Point) LinePoint(blue.components.lines.LinePoint)

Example 24 with LinePoint

use of blue.components.lines.LinePoint in project blue by kunstmusik.

the class TempoEditor method findGraphPoint.

public LinePoint findGraphPoint(int x, int y) {
    Line currentLine = tempo.getLine();
    double min = currentLine.getMin();
    double max = currentLine.getMax();
    for (int i = 0; i < currentLine.size(); i++) {
        LinePoint point = currentLine.getLinePoint(i);
        int tempX = doubleToScreenX(point.getX());
        int tempY = doubleToScreenY(point.getY(), min, max);
        if (tempX >= x - 2 && tempX <= x + 2 && tempY >= y - 2 && tempY <= y + 2) {
            return point;
        }
    }
    return null;
}
Also used : Line(blue.components.lines.Line) LinePoint(blue.components.lines.LinePoint) Point(java.awt.Point) LinePoint(blue.components.lines.LinePoint)

Example 25 with LinePoint

use of blue.components.lines.LinePoint in project blue by kunstmusik.

the class ParameterLineView method mouseMoved.

private void mouseMoved(MouseEvent me) {
    if (getSelectedLine() == null) {
        return;
    }
    me.consume();
    double x = me.getX();
    double y = me.getY();
    LinePoint foundPoint = findGraphPoint(x, y);
    if (foundPoint != null) {
        if (selectedPoint != foundPoint) {
            selectedPoint = foundPoint;
            repaint();
        }
    } else if (selectedPoint != null) {
        selectedPoint = null;
        repaint();
    }
}
Also used : LinePoint(blue.components.lines.LinePoint)

Aggregations

LinePoint (blue.components.lines.LinePoint)43 Line (blue.components.lines.Line)18 Point (java.awt.Point)13 Paint (javafx.scene.paint.Paint)6 SoundObjectParameterLine (blue.components.lines.SoundObjectParameterLine)3 Rectangle (java.awt.Rectangle)3 MenuItem (javafx.scene.control.MenuItem)3 Parameter (blue.automation.Parameter)2 DragDirection (blue.components.DragDirection)2 LineList (blue.components.lines.LineList)2 BlueFX (blue.jfx.BlueFX)2 Sound (blue.soundObject.Sound)2 NumberUtilities (blue.utility.NumberUtilities)2 BigDecimal (java.math.BigDecimal)2 Optional (java.util.Optional)2 BooleanProperty (javafx.beans.property.BooleanProperty)2 ObjectProperty (javafx.beans.property.ObjectProperty)2 SimpleBooleanProperty (javafx.beans.property.SimpleBooleanProperty)2 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)2 ListChangeListener (javafx.collections.ListChangeListener)2