Search in sources :

Example 26 with LinePoint

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

the class ParameterLineView 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)

Example 27 with LinePoint

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

the class ParameterLineView method drawLine.

private void drawLine(Line line, GraphicsContext gc, double w, double h) {
    // TODO - replace with Affine transform
    double min = line.getMin();
    double max = line.getMax();
    gc.beginPath();
    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));
        if (i == 0) {
            gc.moveTo(x, y);
        } else {
            gc.lineTo(x, y);
            gc.stroke();
        }
    }
    gc.closePath();
}
Also used : LinePoint(blue.components.lines.LinePoint) LinePoint(blue.components.lines.LinePoint)

Example 28 with LinePoint

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

the class ParameterLineView 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)

Example 29 with LinePoint

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

the class LineView method drawLine.

private void drawLine(Line line, GraphicsContext gc, double w, double h) {
    // TODO - replace with Affine transform
    double min = line.getMin();
    double max = line.getMax();
    gc.beginPath();
    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));
        if (i == 0) {
            gc.moveTo(x, y);
        } else {
            gc.lineTo(x, y);
            gc.stroke();
        }
    }
    gc.closePath();
}
Also used : LinePoint(blue.components.lines.LinePoint) LinePoint(blue.components.lines.LinePoint) Paint(javafx.scene.paint.Paint)

Example 30 with LinePoint

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

the class LineView method editPoints.

private void editPoints() {
    TableView<LinePoint> table = new TableView<>();
    TableColumn<LinePoint, Double> xCol = new TableColumn<>("x");
    TableColumn<LinePoint, Double> yCol = new TableColumn<>("y");
    table.getColumns().setAll(xCol, yCol);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    table.setItems(getSelectedLine().getObservableList());
    table.setEditable(true);
    xCol.setCellValueFactory(new PropertyValueFactory<LinePoint, Double>("x"));
    xCol.setCellFactory(TextFieldTableCell.forTableColumn(new DoubleStringConverter()));
    xCol.setOnEditCommit(te -> {
        LinePoint lp = te.getRowValue();
        if (getSelectedLine().getLinePoint(0) == lp || getSelectedLine().getLinePoint(getSelectedLine().size() - 1) == lp) {
            return;
        }
        lp.setX(Utils.clamp(0.0, te.getNewValue(), 1.0));
    });
    xCol.setEditable(true);
    yCol.setCellValueFactory(new PropertyValueFactory<LinePoint, Double>("y"));
    yCol.setCellFactory(TextFieldTableCell.forTableColumn(new DoubleStringConverter()));
    yCol.setOnEditCommit(te -> {
        te.getRowValue().setY(Utils.clamp(getSelectedLine().getMin(), te.getNewValue(), getSelectedLine().getMax()));
    });
    yCol.setEditable(true);
    Dialog<ButtonType> d = new Dialog<>();
    d.initOwner(getScene().getWindow());
    d.initModality(Modality.APPLICATION_MODAL);
    d.getDialogPane().setContent(new ScrollPane(table));
    d.getDialogPane().getStylesheets().add(BlueFX.getBlueFxCss());
    d.getDialogPane().getButtonTypes().setAll(ButtonType.OK);
    d.setTitle("Edit Points");
    TableModelListener tml = tme -> {
        repaint();
    };
    getSelectedLine().addTableModelListener(tml);
    Optional<ButtonType> res = d.showAndWait();
    getSelectedLine().removeTableModelListener(tml);
}
Also used : DoubleStringConverter(javafx.util.converter.DoubleStringConverter) NumberUtilities(blue.utility.NumberUtilities) ButtonType(javafx.scene.control.ButtonType) LineList(blue.components.lines.LineList) Glow(javafx.scene.effect.Glow) MouseEvent(javafx.scene.input.MouseEvent) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) TableModelListener(javax.swing.event.TableModelListener) LinePoint(blue.components.lines.LinePoint) TableColumn(javafx.scene.control.TableColumn) DragDirection(blue.components.DragDirection) Utils(org.controlsfx.tools.Utils) BlueFX(blue.jfx.BlueFX) ScrollPane(javafx.scene.control.ScrollPane) ListChangeListener(javafx.collections.ListChangeListener) ContextMenu(javafx.scene.control.ContextMenu) TableView(javafx.scene.control.TableView) Color(javafx.scene.paint.Color) ObjectProperty(javafx.beans.property.ObjectProperty) Modality(javafx.stage.Modality) Dialog(javafx.scene.control.Dialog) MenuItem(javafx.scene.control.MenuItem) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) GraphicsContext(javafx.scene.canvas.GraphicsContext) Canvas(javafx.scene.canvas.Canvas) Line(blue.components.lines.Line) BooleanProperty(javafx.beans.property.BooleanProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Paint(javafx.scene.paint.Paint) Optional(java.util.Optional) DoubleStringConverter(javafx.util.converter.DoubleStringConverter) TableColumn(javafx.scene.control.TableColumn) LinePoint(blue.components.lines.LinePoint) Dialog(javafx.scene.control.Dialog) ScrollPane(javafx.scene.control.ScrollPane) TableModelListener(javax.swing.event.TableModelListener) ButtonType(javafx.scene.control.ButtonType) TableView(javafx.scene.control.TableView)

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