Search in sources :

Example 16 with LinePoint

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

the class LineView method setBoundaryXValues.

private void setBoundaryXValues() {
    if (selectedPoint == null || getSelectedLine() == null) {
        return;
    }
    int size = getSelectedLine().size();
    if (selectedPoint == getSelectedLine().getLinePoint(0)) {
        leftBoundaryX = 0.0;
        rightBoundaryX = 0.0;
        return;
    } else if (selectedPoint == getSelectedLine().getLinePoint(size - 1)) {
        leftBoundaryX = getWidth();
        rightBoundaryX = getWidth();
        return;
    }
    for (int i = 0; i < size; i++) {
        if (getSelectedLine().getLinePoint(i) == selectedPoint) {
            LinePoint p1 = getSelectedLine().getLinePoint(i - 1);
            LinePoint p2 = getSelectedLine().getLinePoint(i + 1);
            leftBoundaryX = p1.getX() * getWidth();
            rightBoundaryX = p2.getX() * getWidth();
            return;
        }
    }
}
Also used : LinePoint(blue.components.lines.LinePoint) LinePoint(blue.components.lines.LinePoint) Paint(javafx.scene.paint.Paint)

Example 17 with LinePoint

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

the class LineView method drawPoints.

private void drawPoints(Line line, GraphicsContext gc, double w, double h) {
    double min = line.getMin();
    double max = line.getMax();
    gc.setFill(Color.BLACK);
    for (int i = 0; i < line.size(); i++) {
        LinePoint lp = line.getLinePoint(i);
        double x = Math.floor(lp.getX() * w);
        double y = Math.floor(yToScreen(lp.getY(), min, max));
        gc.fillOval(x - 3, y - 3, 7, 7);
        gc.strokeOval(x - 3, y - 3, 7, 7);
    }
}
Also used : LinePoint(blue.components.lines.LinePoint) LinePoint(blue.components.lines.LinePoint) Paint(javafx.scene.paint.Paint)

Example 18 with LinePoint

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

the class LineView method mousePressed.

private void mousePressed(MouseEvent me) {
    if (getSelectedLine() == null) {
        return;
    }
    pressX = me.getX();
    pressY = me.getY();
    me.consume();
    if (selectedPoint != null) {
        if (me.isSecondaryButtonDown()) {
            if (isLocked()) {
                return;
            }
            LinePoint first = getSelectedLine().getLinePoint(0);
            LinePoint last = getSelectedLine().getLinePoint(getSelectedLine().size() - 1);
            if (selectedPoint != first && selectedPoint != last) {
                getSelectedLine().removeLinePoint(selectedPoint);
                selectedPoint = null;
                repaint();
            }
        } else {
            setBoundaryXValues();
        }
    } else {
        if (me.isSecondaryButtonDown()) {
            editPointsMenu.show(LineView.this, me.getScreenX(), me.getScreenY());
        } else if (me.isPrimaryButtonDown()) {
            if (!isLocked()) {
                selectedPoint = insertGraphPoint(me.getX(), me.getY());
                repaint();
                setBoundaryXValues();
            }
        }
    }
}
Also used : LinePoint(blue.components.lines.LinePoint)

Example 19 with LinePoint

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

the class LineView method insertGraphPoint.

private LinePoint insertGraphPoint(double x, double y) {
    if (x < 0 || x > getWidth() || y < 0 || y > getHeight()) {
        return null;
    }
    double min = getSelectedLine().getMin();
    double max = getSelectedLine().getMax();
    LinePoint point = new LinePoint();
    point.setLocation(x / getWidth(), screenToY(y, min, max));
    int index = 1;
    for (int i = 0; i < getSelectedLine().size() - 1; i++) {
        LinePoint p1 = getSelectedLine().getLinePoint(i);
        LinePoint p2 = getSelectedLine().getLinePoint(i + 1);
        if (point.getX() >= p1.getX() && point.getX() <= p2.getX()) {
            index = i + 1;
            break;
        }
    }
    getSelectedLine().addLinePoint(index, point);
    return point;
}
Also used : LinePoint(blue.components.lines.LinePoint) LinePoint(blue.components.lines.LinePoint) Paint(javafx.scene.paint.Paint)

Example 20 with LinePoint

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

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