Search in sources :

Example 36 with LinePoint

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

the class LineCanvas method insertGraphPoint.

/**
 * Use by the MouseListener to add points
 *
 * @param i
 * @param j
 * @return
 */
protected LinePoint insertGraphPoint(int x, int y) {
    if (x < 5 || x > this.getWidth() - 5 || y < 5 || y > this.getHeight() - 5) {
        return null;
    }
    double min = currentLine.getMin();
    double max = currentLine.getMax();
    LinePoint point = new LinePoint();
    point.setLocation(screenToDoubleX(x), screenToDoubleY(y, min, max));
    int index = 1;
    for (int i = 0; i < currentLine.size() - 1; 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 : LinePoint(blue.components.lines.LinePoint) Point(java.awt.Point) LinePoint(blue.components.lines.LinePoint)

Example 37 with LinePoint

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

the class Send method setLevel.

public void setLevel(double level) {
    if (levelParameter.isAutomationEnabled()) {
        double time = ParameterTimeManagerFactory.getInstance().getTime();
        if (time < 0) {
            return;
        }
        updatingLine = true;
        LinePoint found = null;
        Line line = levelParameter.getLine();
        for (int i = 0; i < line.size(); i++) {
            LinePoint point = line.getLinePoint(i);
            if (point.getX() == time) {
                found = point;
                break;
            }
        }
        if (found != null) {
            found.setLocation(found.getX(), level);
        } else {
            LinePoint lp = new LinePoint();
            lp.setLocation(time, level);
            line.insertLinePoint(lp);
        }
        updatingLine = false;
    }
    double oldVal = this.level;
    this.level = level;
    PropertyChangeEvent pce = new PropertyChangeEvent(this, "level", new Double(oldVal), new Double(level));
    firePropertyChangeEvent(pce);
}
Also used : Line(blue.components.lines.Line) LinePoint(blue.components.lines.LinePoint) PropertyChangeEvent(java.beans.PropertyChangeEvent) LinePoint(blue.components.lines.LinePoint)

Example 38 with LinePoint

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

the class BSBLineObject method getLineString.

private String getLineString(Line line) {
    StrBuilder buffer = new StrBuilder();
    double[] xVals = new double[line.size()];
    double[] yVals = new double[line.size()];
    for (int i = 0; i < line.size(); i++) {
        LinePoint p = line.getLinePoint(i);
        xVals[i] = p.getX() * getXMax();
        yVals[i] = p.getY();
    }
    if (isRelativeXValues()) {
        for (int i = xVals.length - 1; i > 0; i--) {
            xVals[i] = xVals[i] - xVals[i - 1];
        }
    }
    String spacer = getSeparatorType().getSeparatorString();
    if (isLeadingZero()) {
        buffer.append("0.0").append(spacer);
    }
    buffer.append(yVals[0]);
    for (int i = 1; i < xVals.length; i++) {
        buffer.append(spacer).append(NumberUtilities.formatDouble(xVals[i]));
        buffer.append(spacer).append(NumberUtilities.formatDouble(yVals[i]));
    }
    return buffer.toString();
}
Also used : LinePoint(blue.components.lines.LinePoint) StrBuilder(org.apache.commons.lang3.text.StrBuilder) LinePoint(blue.components.lines.LinePoint)

Example 39 with LinePoint

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

the class Channel method setLevel.

public void setLevel(double level) {
    if (levelParameter.isAutomationEnabled()) {
        double time = ParameterTimeManagerFactory.getInstance().getTime();
        if (time < 0) {
            return;
        }
        updatingLine = true;
        LinePoint found = null;
        Line line = levelParameter.getLine();
        for (int i = 0; i < line.size(); i++) {
            LinePoint point = line.getLinePoint(i);
            if (point.getX() == time) {
                found = point;
                break;
            }
        }
        if (found != null) {
            found.setLocation(found.getX(), level);
        } else {
            LinePoint lp = new LinePoint();
            lp.setLocation(time, level);
            line.insertLinePoint(lp);
        }
        updatingLine = false;
    } else {
        levelParameter.setValue(level);
    }
    double oldVal = this.level;
    this.level = level;
    firePropertyChange(LEVEL, new Double(oldVal), new Double(level));
}
Also used : Line(blue.components.lines.Line) LinePoint(blue.components.lines.LinePoint) LinePoint(blue.components.lines.LinePoint)

Example 40 with LinePoint

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

the class TempoEditor method drawLine.

private final void drawLine(Graphics g, Line line, boolean drawPoints) {
    Rectangle clipBounds = g.getClipBounds();
    if (line.size() == 0) {
        return;
    }
    if (line.size() == 1) {
        LinePoint lp = line.getLinePoint(0);
        double min = line.getMin();
        double max = line.getMax();
        int x = doubleToScreenX(lp.getX());
        int y = doubleToScreenY(lp.getY(), min, max);
        g.drawLine(0, y, getWidth(), y);
        if (drawPoints) {
            paintPoint(g, x, y);
        }
        return;
    }
    int prevX = -1;
    int prevY = -1;
    int x, y;
    double min = line.getMin();
    double max = line.getMax();
    int[] xValues = new int[line.size()];
    int[] yValues = new int[line.size()];
    for (int i = 0; i < line.size(); i++) {
        LinePoint point = line.getLinePoint(i);
        x = doubleToScreenX(point.getX());
        y = doubleToScreenY(point.getY(), min, max);
        xValues[i] = x;
        yValues[i] = y;
        if (prevX != -1) {
            if ((prevX <= (clipBounds.x + clipBounds.width)) && (x >= clipBounds.x)) {
                g.drawLine(prevX, prevY, x, y);
            }
        }
        prevX = x;
        prevY = y;
    }
    if (prevX < this.getWidth()) {
        g.drawLine(prevX, prevY, getWidth(), prevY);
    }
    if (drawPoints) {
        for (int i = 0; i < xValues.length; i++) {
            paintPoint(g, xValues[i], yValues[i]);
        }
    }
}
Also used : LinePoint(blue.components.lines.LinePoint) Rectangle(java.awt.Rectangle) Point(java.awt.Point) 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