Search in sources :

Example 1 with GridSettings

use of blue.orchestra.blueSynthBuilder.GridSettings in project blue by kunstmusik.

the class BSBObjectViewHolder method resizeDown.

protected void resizeDown(MouseEvent evt) {
    Rectangle r = (Rectangle) evt.getSource();
    Point2D curPoint = r.localToParent(evt.getX(), evt.getY());
    curPoint = localToParent(curPoint);
    GridSettings grid = selection.getGridSettings();
    int diff = (int) (curPoint.getY() - mouseOrigin.getY());
    int newHeight = (int) originBounds.getHeight() + diff;
    if (grid.isSnapEnabled()) {
        double top = getLayoutY();
        double bottom = top + newHeight;
        int h = grid.getHeight();
        newHeight = (int) ((Math.round(bottom / h) * h) - top);
    }
    newHeight = Math.max(newHeight, rView.getWidgetMinimumHeight());
    if (newHeight != rView.getWidgetHeight()) {
        rView.setWidgetHeight(newHeight);
    }
    evt.consume();
}
Also used : Point2D(javafx.geometry.Point2D) Rectangle(javafx.scene.shape.Rectangle) GridSettings(blue.orchestra.blueSynthBuilder.GridSettings)

Example 2 with GridSettings

use of blue.orchestra.blueSynthBuilder.GridSettings in project blue by kunstmusik.

the class BSBObjectViewHolder method resizeRight.

protected void resizeRight(MouseEvent evt) {
    Rectangle r = (Rectangle) evt.getSource();
    Point2D curPoint = r.localToParent(evt.getX(), evt.getY());
    curPoint = localToParent(curPoint);
    GridSettings grid = selection.getGridSettings();
    int diff = (int) (curPoint.getX() - mouseOrigin.getX());
    int newWidth = (int) originBounds.getWidth() + diff;
    if (grid.isSnapEnabled()) {
        double left = getLayoutX();
        double right = left + newWidth;
        int w = grid.getWidth();
        newWidth = (int) ((Math.round(right / w) * w) - left);
    }
    newWidth = Math.max(newWidth, rView.getWidgetMinimumWidth());
    if (newWidth != rView.getWidgetWidth()) {
        rView.setWidgetWidth(newWidth);
    }
    evt.consume();
}
Also used : Point2D(javafx.geometry.Point2D) Rectangle(javafx.scene.shape.Rectangle) GridSettings(blue.orchestra.blueSynthBuilder.GridSettings)

Example 3 with GridSettings

use of blue.orchestra.blueSynthBuilder.GridSettings in project blue by kunstmusik.

the class BSBEditPane method paste.

protected void paste(int x, int y) {
    int minX = Integer.MAX_VALUE;
    int minY = Integer.MAX_VALUE;
    GridSettings gridSettings = bsbInterface.getGridSettings();
    if (gridSettings.isSnapEnabled()) {
        x = x - (x % gridSettings.getWidth());
        y = y - (y % gridSettings.getHeight());
    }
    for (BSBObject bsbObj : selection.copyBufferProperty()) {
        minX = Math.min(minX, bsbObj.getX());
        minY = Math.min(minY, bsbObj.getY());
    }
    selection.selection.clear();
    for (BSBObject bsbObj : selection.copyBufferProperty()) {
        BSBObject copy = bsbObj.deepCopy();
        copy.setX(x + copy.getX() - minX);
        copy.setY(y + copy.getY() - minY);
        currentBSBGroup.addBSBObject(copy);
        selection.selection.add(copy);
    }
}
Also used : BSBObject(blue.orchestra.blueSynthBuilder.BSBObject) GridSettings(blue.orchestra.blueSynthBuilder.GridSettings)

Example 4 with GridSettings

use of blue.orchestra.blueSynthBuilder.GridSettings in project blue by kunstmusik.

the class BSBEditPane method redrawGrid.

private void redrawGrid() {
    int totalWidth = (int) getWidth();
    int totalHeight = (int) getHeight();
    GraphicsContext gc = gridCanvas.getGraphicsContext2D();
    gc.clearRect(0, 0, getWidth(), getHeight());
    if (this.bsbInterface == null) {
        return;
    }
    gc.setFill(GRID_COLOR);
    gc.setStroke(GRID_COLOR);
    GridSettings grid = bsbInterface.getGridSettings();
    int w = grid.getWidth();
    int h = grid.getHeight();
    if (w < 1 || h < 1) {
        return;
    }
    switch(grid.getGridStyle()) {
        case DOT:
            for (int x = 0; x < totalWidth; x += w) {
                for (int y = 0; y < totalHeight; y += h) {
                    gc.strokeRect(snap(x), snap(y), 1, 1);
                }
            }
            break;
        case LINE:
            for (int x = 0; x < totalWidth; x += w) {
                gc.strokeLine(snap(x), 0, snap(x), snap(totalHeight));
            }
            for (int y = 0; y < totalHeight; y += h) {
                gc.strokeLine(0, snap(y), totalWidth, snap(y));
            }
            break;
    }
}
Also used : GraphicsContext(javafx.scene.canvas.GraphicsContext) GridSettings(blue.orchestra.blueSynthBuilder.GridSettings)

Example 5 with GridSettings

use of blue.orchestra.blueSynthBuilder.GridSettings in project blue by kunstmusik.

the class BSBEditPane method pasteShortcut.

private void pasteShortcut() {
    int minX = Integer.MAX_VALUE;
    int minY = Integer.MAX_VALUE;
    for (BSBObject bsbObj : selection.copyBufferProperty()) {
        minX = Math.min(minX, bsbObj.getX());
        minY = Math.min(minY, bsbObj.getY());
    }
    int x = minX;
    int y = minY;
    GridSettings gridSettings = bsbInterface.getGridSettings();
    if (gridSettings.isSnapEnabled()) {
        x += gridSettings.getWidth();
        y += gridSettings.getHeight();
    } else {
        x += 10;
        y += 10;
    }
    selection.selection.clear();
    for (BSBObject bsbObj : selection.copyBufferProperty()) {
        BSBObject copy = bsbObj.deepCopy();
        copy.setX(x + copy.getX() - minX);
        copy.setY(y + copy.getY() - minY);
        currentBSBGroup.addBSBObject(copy);
        selection.selection.add(copy);
    }
}
Also used : BSBObject(blue.orchestra.blueSynthBuilder.BSBObject) GridSettings(blue.orchestra.blueSynthBuilder.GridSettings)

Aggregations

GridSettings (blue.orchestra.blueSynthBuilder.GridSettings)8 Point2D (javafx.geometry.Point2D)4 Rectangle (javafx.scene.shape.Rectangle)4 BSBObject (blue.orchestra.blueSynthBuilder.BSBObject)2 GraphicsContext (javafx.scene.canvas.GraphicsContext)1