Search in sources :

Example 26 with Line

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

the class ParameterLinePanel method setBoundaryXValues.

public void setBoundaryXValues() {
    Line currentLine = currentParameter.getLine();
    if (selectedPoint == currentLine.getLinePoint(0)) {
        leftBoundaryX = 0;
        rightBoundaryX = 0;
        return;
    } else if (selectedPoint == currentLine.getLinePoint(currentLine.size() - 1)) {
        LinePoint p1 = currentLine.getLinePoint(currentLine.size() - 2);
        leftBoundaryX = doubleToScreenX(p1.getX());
        rightBoundaryX = this.getWidth();
        return;
    }
    for (int i = 0; i < currentLine.size(); i++) {
        if (currentLine.getLinePoint(i) == selectedPoint) {
            LinePoint p1 = currentLine.getLinePoint(i - 1);
            LinePoint p2 = currentLine.getLinePoint(i + 1);
            leftBoundaryX = doubleToScreenX(p1.getX());
            rightBoundaryX = doubleToScreenX(p2.getX());
            return;
        }
    }
}
Also used : Line(blue.components.lines.Line) LinePoint(blue.components.lines.LinePoint) Point(java.awt.Point) LinePoint(blue.components.lines.LinePoint)

Example 27 with Line

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

the class ParameterLinePanel method drawSelectionLine.

/* Draws line when in selection mode (MULTILINE, SCORE when SCALING) */
private final void drawSelectionLine(Graphics g, Parameter p) {
    Line tempLine = p.getLine();
    if (selectionList.size() > 0) {
        tempLine = getSelectionSortedLine(tempLine);
    } else if (newSelectionStartTime >= 0) {
        tempLine = getSelectionScalingSortedLine(tempLine);
    } else if (ModeManager.getInstance().getMode() == ScoreMode.SCORE) {
        drawLine(g, p, false);
        return;
    }
    Color currentColor = g.getColor();
    Rectangle clipBounds = g.getClipBounds();
    if (tempLine.size() == 0) {
        return;
    }
    double pixelSecond = (double) timeState.getPixelSecond();
    double selectionStart;
    double selectionEnd;
    if (newSelectionStartTime >= 0) {
        selectionStart = newSelectionStartTime;
        selectionEnd = newSelectionEndTime;
    } else {
        selectionStart = marquee.startTime;
        selectionEnd = marquee.endTime;
    }
    if (tempLine.size() == 1) {
        LinePoint lp = tempLine.getLinePoint(0);
        double min = tempLine.getMin();
        double max = tempLine.getMax();
        int x = doubleToScreenX(lp.getX());
        int y = doubleToScreenY(lp.getY(), min, max);
        g.setColor(currentColor);
        g.drawLine(0, y, getWidth(), y);
        paintSelectionPoint(g, x, y, lp.getX(), selectionStart, selectionEnd);
        return;
    }
    if (p.getResolution().doubleValue() <= 0) {
        int[] xValues = new int[tempLine.size()];
        int[] yValues = new int[tempLine.size()];
        double[] pointX = new double[tempLine.size()];
        double min = tempLine.getMin();
        double max = tempLine.getMax();
        for (int i = 0; i < tempLine.size(); i++) {
            LinePoint point = tempLine.getLinePoint(i);
            pointX[i] = point.getX();
            xValues[i] = doubleToScreenX(pointX[i]);
            yValues[i] = doubleToScreenY(point.getY(), min, max);
        }
        g.drawPolyline(xValues, yValues, xValues.length);
        final int lastX = xValues[xValues.length - 1];
        if (lastX < this.getWidth()) {
            int lastY = yValues[yValues.length - 1];
            g.drawLine(lastX, lastY, getWidth(), lastY);
        }
        for (int i = 0; i < xValues.length; i++) {
            paintSelectionPoint(g, xValues[i], yValues[i], pointX[i], selectionStart, selectionEnd);
        }
    } else {
        LinePoint previous = null;
        int x, y;
        double min = p.getMin();
        double max = p.getMax();
        BigDecimal resolution = p.getResolution();
        for (int i = 0; i < tempLine.size(); i++) {
            LinePoint point = tempLine.getLinePoint(i);
            x = doubleToScreenX(point.getX());
            y = doubleToScreenY(point.getY(), min, max);
            if (previous != null) {
                double startVal = previous.getY();
                int startX = doubleToScreenX(previous.getX());
                int startY = doubleToScreenY(startVal, min, max);
                int endX = doubleToScreenX(point.getX());
                int endY = doubleToScreenY(point.getY(), min, max);
                if (startVal == point.getY()) {
                    g.setColor(currentColor);
                    g.drawLine(startX, startY, endX, startY);
                    previous = point;
                    continue;
                }
                if (previous.getX() == point.getX()) {
                    if (startY != endY) {
                        g.setColor(currentColor);
                        g.drawLine(startX, startY, startX, endY);
                    }
                    previous = point;
                    continue;
                }
                int lastY = startY;
                int lastX = startX;
                for (int j = startX; j <= endX; j++) {
                    double timeVal = screenToDoubleX(j);
                    double val = tempLine.getValue(timeVal);
                    int newY = doubleToScreenY(val, min, max);
                    if (endY > startY) {
                        if (newY < startY) {
                            newY = startY;
                        }
                    } else if (newY > startY) {
                        newY = startY;
                    }
                    if (newY != lastY) {
                        g.setColor(currentColor);
                        g.drawLine(lastX, lastY, j, lastY);
                        g.drawLine(j, lastY, j, newY);
                        lastX = j;
                        lastY = newY;
                    }
                }
                if (lastX != endX) {
                    g.setColor(currentColor);
                    g.drawLine(lastX, lastY, endX, lastY);
                    g.drawLine(endX, lastY, endX, endY);
                }
            }
            paintSelectionPoint(g, x, y, point.getX(), selectionStart, selectionEnd);
            previous = point;
        }
        if (previous.getX() < this.getWidth()) {
            int lastX = doubleToScreenX(previous.getX());
            int lastY = doubleToScreenY(previous.getY(), min, max);
            g.setColor(currentColor);
            g.drawLine(lastX, lastY, getWidth(), lastY);
        }
    }
}
Also used : Line(blue.components.lines.Line) LinePoint(blue.components.lines.LinePoint) Color(java.awt.Color) Rectangle(java.awt.Rectangle) Point(java.awt.Point) LinePoint(blue.components.lines.LinePoint) BigDecimal(java.math.BigDecimal)

Example 28 with Line

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

the class ParameterLinePanel method getSelectionSortedLine.

/**
 * Returns a line that has the points sorted and those masked removed when
 * handling SelectionMoving; not sure this will be good for long term as it
 * doesn't seem performant but using for initial work and can reevaluate
 * later.
 *
 * @param line
 * @return
 */
private Line getSelectionSortedLine(Line line) {
    Line retVal = new Line(line);
    double[] selPoints = selectionList.get(0);
    double selectionStartTime = selPoints[0];
    double selectionEndTime = selPoints[1];
    retVal.processLineForSelectionDrag(selectionStartTime, selectionEndTime, transTime);
    return retVal;
}
Also used : Line(blue.components.lines.Line)

Example 29 with Line

use of blue.components.lines.Line 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 30 with Line

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

the class BSBLineObject method getReplacementKeys.

// public BSBObjectView getBSBObjectView() {
// return new BSBLineObjectView(this);
// }
@Override
public String[] getReplacementKeys() {
    String[] vals = new String[lines.size()];
    String objName = getObjectName();
    for (int i = 0; i < lines.size(); i++) {
        Line l = lines.get(i);
        vals[i] = objName + "_" + l.getVarName();
    }
    return vals;
}
Also used : Line(blue.components.lines.Line) LinePoint(blue.components.lines.LinePoint)

Aggregations

Line (blue.components.lines.Line)35 LinePoint (blue.components.lines.LinePoint)22 Point (java.awt.Point)11 SoundObjectParameterLine (blue.components.lines.SoundObjectParameterLine)4 Color (java.awt.Color)4 Iterator (java.util.Iterator)4 Graphics2D (java.awt.Graphics2D)3 RenderingHints (java.awt.RenderingHints)3 ModeManager (blue.ui.core.score.ModeManager)2 Element (electric.xml.Element)2 Elements (electric.xml.Elements)2 Rectangle (java.awt.Rectangle)2 BigDecimal (java.math.BigDecimal)2 GraphicsContext (javafx.scene.canvas.GraphicsContext)2 Color (javafx.scene.paint.Color)2 StrBuilder (org.apache.commons.lang3.text.StrBuilder)2 GenericInstrument (blue.orchestra.GenericInstrument)1 LineSelector (blue.orchestra.editor.blueSynthBuilder.jfx.LineSelector)1 ParameterLineView (blue.soundObject.editor.sound.ParameterLineView)1 TimeBar (blue.soundObject.editor.sound.TimeBar)1