Search in sources :

Example 6 with BSBObject

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

the class BSBEditPane method setupPopupMenus.

private void setupPopupMenus(BSBObjectEntry[] bsbObjectEntries) {
    popupMenu = new ContextMenu();
    EventHandler<ActionEvent> al = e -> {
        MenuItem m = (MenuItem) e.getSource();
        Class<? extends BSBObject> clazz = (Class<? extends BSBObject>) m.getUserData();
        try {
            BSBObject bsbObj = clazz.newInstance();
            bsbObj.setX(addX);
            bsbObj.setY(addY);
            currentBSBGroup.addBSBObject(bsbObj);
        } catch (InstantiationException | IllegalAccessException ex) {
            Exceptions.printStackTrace(ex);
        }
    };
    for (BSBObjectEntry entry : bsbObjectEntries) {
        MenuItem m = new MenuItem("Add " + entry.label);
        m.setUserData(entry.bsbObjectClass);
        m.setOnAction(al);
        popupMenu.getItems().add(m);
    }
    MenuItem paste = new MenuItem("Paste");
    paste.setOnAction(ae -> paste(addX, addY));
    paste.disableProperty().bind(Bindings.createBooleanBinding(() -> selection.copyBufferProperty().size() == 0, selection.copyBufferProperty()));
    popupMenu.getItems().addAll(new SeparatorMenuItem(), paste);
    nonEditPopupMenu = new ContextMenu();
    MenuItem randomize = new MenuItem("Randomize");
    randomize.setOnAction(ae -> {
        if (bsbInterface != null) {
            bsbInterface.getRootGroup().randomize();
        }
    });
    nonEditPopupMenu.getItems().add(randomize);
}
Also used : EventHandler(javafx.event.EventHandler) SetChangeListener(javafx.collections.SetChangeListener) FXCollections(javafx.collections.FXCollections) Bindings(javafx.beans.binding.Bindings) InvalidationListener(javafx.beans.InvalidationListener) HashSet(java.util.HashSet) BSBGroup(blue.orchestra.blueSynthBuilder.BSBGroup) ListChangeListener(javafx.collections.ListChangeListener) ContextMenu(javafx.scene.control.ContextMenu) Exceptions(org.openide.util.Exceptions) EditModeOnly(blue.orchestra.editor.blueSynthBuilder.EditModeOnly) BSBGraphicInterface(blue.orchestra.blueSynthBuilder.BSBGraphicInterface) BSBObject(blue.orchestra.blueSynthBuilder.BSBObject) Pane(javafx.scene.layout.Pane) Color(javafx.scene.paint.Color) MenuItem(javafx.scene.control.MenuItem) GraphicsContext(javafx.scene.canvas.GraphicsContext) Collection(java.util.Collection) Node(javafx.scene.Node) GridSettings(blue.orchestra.blueSynthBuilder.GridSettings) Set(java.util.Set) Canvas(javafx.scene.canvas.Canvas) Rectangle(javafx.scene.shape.Rectangle) KeyEvent(javafx.scene.input.KeyEvent) Collectors(java.util.stream.Collectors) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) List(java.util.List) BooleanProperty(javafx.beans.property.BooleanProperty) ActionEvent(javafx.event.ActionEvent) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) Region(javafx.scene.layout.Region) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) ChangeListener(javafx.beans.value.ChangeListener) BSBObjectEntry(blue.orchestra.blueSynthBuilder.BSBObjectEntry) Bounds(javafx.geometry.Bounds) ActionEvent(javafx.event.ActionEvent) BSBObject(blue.orchestra.blueSynthBuilder.BSBObject) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) BSBObjectEntry(blue.orchestra.blueSynthBuilder.BSBObjectEntry) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem)

Example 7 with BSBObject

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

the class BSBEditPane method updateMarquee.

protected void updateMarquee(double newMouseX, double newMouseY) {
    double left, right, top, bottom;
    if (newMouseX < startMarqueeX) {
        left = newMouseX;
        right = startMarqueeX;
    } else {
        left = startMarqueeX;
        right = newMouseX;
    }
    if (newMouseY < startMarqueeY) {
        top = newMouseY;
        bottom = startMarqueeY;
    } else {
        bottom = newMouseY;
        top = startMarqueeY;
    }
    top = Math.max(0.0, top);
    left = Math.max(0.0, left);
    double width = right - left;
    double height = bottom - top;
    marquee.setX(left);
    marquee.setY(top);
    marquee.setWidth(width);
    marquee.setHeight(height);
    selecting.clear();
    for (Node n : interfaceItemsPane.getChildren()) {
        Bounds b = n.getBoundsInParent();
        if (n != marquee && marquee.intersects(b)) {
            Object obj = n.getUserData();
            if (obj instanceof BSBObject) {
                BSBObject bsbObj = (BSBObject) obj;
                if (currentBSBGroup.contains(bsbObj)) {
                    selecting.add((BSBObject) obj);
                }
            }
        }
    }
    selecting.addAll(startSet);
    selection.selection.addAll(selecting);
    selection.selection.retainAll(selecting);
}
Also used : Node(javafx.scene.Node) Bounds(javafx.geometry.Bounds) BSBObject(blue.orchestra.blueSynthBuilder.BSBObject) BSBObject(blue.orchestra.blueSynthBuilder.BSBObject)

Example 8 with BSBObject

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

the class BSBEditSelection method move.

public void move(double xDiff, double yDiff) {
    if (!processingMove) {
        return;
    }
    if (gridSettings != null && gridSettings.isSnapEnabled()) {
        int w = gridSettings.getWidth();
        int h = gridSettings.getHeight();
        xDiff = (Math.round(xDiff / w) * w) - gridOffsetX;
        yDiff = (Math.round(yDiff / h) * h) - gridOffsetY;
    }
    double xDiffAdj = Math.max(-minX, xDiff);
    double yDiffAdj = Math.max(-minY, yDiff);
    for (Map.Entry<BSBObject, Point> entry : startPositions.entrySet()) {
        BSBObject obj = entry.getKey();
        Point pt = entry.getValue();
        obj.setX((int) Math.round(pt.x + xDiffAdj));
        obj.setY((int) Math.round(pt.y + yDiffAdj));
    }
}
Also used : BSBObject(blue.orchestra.blueSynthBuilder.BSBObject) HashMap(java.util.HashMap) Map(java.util.Map)

Example 9 with BSBObject

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

the class BSBGroupView method initialize.

public void initialize(BooleanProperty editEnabledProperty, BSBEditSelection selection, ObservableList<BSBGroup> groupsList) {
    this.editEnabledProperty = editEnabledProperty;
    this.selection = selection;
    this.groupsList = groupsList;
    for (BSBObject bsbObj : bsbGroup) {
        addBSBObject(bsbObj);
    }
}
Also used : BSBObject(blue.orchestra.blueSynthBuilder.BSBObject)

Example 10 with BSBObject

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

the class BSBObjectViewHolder method recordMouseOrigin.

protected void recordMouseOrigin(MouseEvent evt) {
    final BSBObject bsbObj = (BSBObject) getUserData();
    Rectangle r = (Rectangle) evt.getSource();
    mouseOrigin = r.localToParent(evt.getX(), evt.getY());
    mouseOrigin = localToParent(mouseOrigin);
    originBounds = new BoundingBox(bsbObj.getX(), bsbObj.getY(), rView.getWidgetWidth(), rView.getWidgetHeight());
    evt.consume();
}
Also used : BSBObject(blue.orchestra.blueSynthBuilder.BSBObject) BoundingBox(javafx.geometry.BoundingBox) Rectangle(javafx.scene.shape.Rectangle)

Aggregations

BSBObject (blue.orchestra.blueSynthBuilder.BSBObject)13 GridSettings (blue.orchestra.blueSynthBuilder.GridSettings)4 Pane (javafx.scene.layout.Pane)4 BSBGraphicInterface (blue.orchestra.blueSynthBuilder.BSBGraphicInterface)3 Rectangle (javafx.scene.shape.Rectangle)3 Arrangement (blue.Arrangement)2 BlueData (blue.BlueData)2 BlueSynthBuilder (blue.orchestra.BlueSynthBuilder)2 Instrument (blue.orchestra.Instrument)2 BSBGroup (blue.orchestra.blueSynthBuilder.BSBGroup)2 BSBSubChannelDropdown (blue.orchestra.blueSynthBuilder.BSBSubChannelDropdown)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Bindings (javafx.beans.binding.Bindings)2 BooleanProperty (javafx.beans.property.BooleanProperty)2 ChangeListener (javafx.beans.value.ChangeListener)2 ObservableList (javafx.collections.ObservableList)2 ActionEvent (javafx.event.ActionEvent)2 EventHandler (javafx.event.EventHandler)2 BoundingBox (javafx.geometry.BoundingBox)2