Search in sources :

Example 16 with Line

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

the class SoundEditor method jbInit.

private void jbInit() throws Exception {
    this.setLayout(new BorderLayout());
    this.add(editor);
    editor.setLabelText("[ Sound ]");
    JFXPanel jfxPanel = new JFXPanel();
    CountDownLatch latch = new CountDownLatch(1);
    JFXPanel jfxCommentPanel = new JFXPanel();
    BlueFX.runOnFXThread(() -> {
        try {
            MenuButton btn = new MenuButton("Automations");
            BorderPane mainPane = new BorderPane();
            lineView = new ParameterLineView(lineList);
            lineSelector = new LineSelector(lineList);
            lineView.widthProperty().bind(mainPane.widthProperty());
            lineView.heightProperty().bind(mainPane.heightProperty().subtract(lineSelector.heightProperty()));
            lineSelector.getChildren().add(0, btn);
            lineSelector.setSpacing(5.0);
            lineView.selectedLineProperty().bind(lineSelector.selectedLineProperty());
            TimeBar tb = new TimeBar();
            tb.startTimeProperty().bind(lineView.startTimeProperty());
            tb.durationProperty().bind(lineView.durationProperty());
            Pane p = new Pane(lineView, tb);
            p.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY)));
            lineView.widthProperty().bind(p.widthProperty().subtract(20));
            lineView.heightProperty().bind(p.heightProperty().subtract(40));
            lineView.setLayoutX(10);
            lineView.setLayoutY(30);
            tb.widthProperty().bind(lineView.widthProperty());
            tb.setHeight(20);
            tb.setLayoutX(10);
            tb.setLayoutY(10);
            mainPane.setCenter(p);
            mainPane.setTop(lineSelector);
            btn.showingProperty().addListener((obs, old, newVal) -> {
                if (newVal) {
                    if (sObj != null) {
                        sObj.getBlueSynthBuilder().getParameterList().sorted().forEach((param) -> {
                            MenuItem m = new MenuItem(param.getName());
                            m.setOnAction(e -> {
                                param.setAutomationEnabled(!param.isAutomationEnabled());
                                if (param.isAutomationEnabled()) {
                                    Line line = param.getLine();
                                    line.setVarName(param.getName());
                                    List<LinePoint> points = line.getObservableList();
                                    if (points.size() < 2) {
                                        LinePoint lp = new LinePoint();
                                        lp.setLocation(1.0, points.get(0).getY());
                                        points.add(lp);
                                    }
                                    lineList.add(line);
                                } else {
                                    lineList.remove(param.getLine());
                                }
                                int colorCount = 0;
                                for (Line line : lineList) {
                                    line.setColor(LineColors.getColor(colorCount++));
                                }
                            });
                            if (param.isAutomationEnabled()) {
                                m.setStyle("-fx-text-fill: green;");
                            }
                            btn.getItems().add(m);
                        });
                    }
                } else {
                    btn.getItems().clear();
                }
            });
            final Scene scene = new Scene(mainPane);
            BlueFX.style(scene);
            jfxPanel.setScene(scene);
            commentTextArea = new TextArea();
            commentTextArea.setWrapText(true);
            final Scene scene2 = new Scene(commentTextArea);
            BlueFX.style(scene2);
            jfxCommentPanel.setScene(scene2);
        } finally {
            latch.countDown();
        }
    });
    try {
        latch.await();
    } catch (InterruptedException ex) {
        Exceptions.printStackTrace(ex);
    }
    editor.getTabs().insertTab("Automation", null, jfxPanel, "", 1);
    editor.getTabs().addTab("Comments", jfxCommentPanel);
}
Also used : TimeBar(blue.soundObject.editor.sound.TimeBar) JFXPanel(javafx.embed.swing.JFXPanel) BorderPane(javafx.scene.layout.BorderPane) ParameterLineView(blue.soundObject.editor.sound.ParameterLineView) Background(javafx.scene.layout.Background) TextArea(javafx.scene.control.TextArea) BackgroundFill(javafx.scene.layout.BackgroundFill) MenuButton(javafx.scene.control.MenuButton) LineSelector(blue.orchestra.editor.blueSynthBuilder.jfx.LineSelector) MenuItem(javafx.scene.control.MenuItem) CountDownLatch(java.util.concurrent.CountDownLatch) Scene(javafx.scene.Scene) Pane(javafx.scene.layout.Pane) BorderPane(javafx.scene.layout.BorderPane) LinePoint(blue.components.lines.LinePoint) Line(blue.components.lines.Line) LinePoint(blue.components.lines.LinePoint) BorderLayout(java.awt.BorderLayout)

Example 17 with Line

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

the class ZakLineListTableModel method addLine.

/**
 * Adds a Line object, appropriately flagged as a zak line
 */
@Override
public void addLine(int index) {
    if (lines == null) {
        return;
    }
    Line line = new Line();
    line.setZak(true);
    line.setChannel(1);
    line.setColor(LineColors.getColor(lines.size()));
    if (index < 0 || index == lines.size() - 1) {
        lines.add(line);
        int row = lines.size() - 1;
        fireTableRowsInserted(row, row);
    } else {
        lines.add(index, line);
        fireTableRowsInserted(index, index);
    }
}
Also used : Line(blue.components.lines.Line)

Example 18 with Line

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

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

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

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