Search in sources :

Example 1 with BSBObjectEntry

use of blue.orchestra.blueSynthBuilder.BSBObjectEntry 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)

Aggregations

BSBGraphicInterface (blue.orchestra.blueSynthBuilder.BSBGraphicInterface)1 BSBGroup (blue.orchestra.blueSynthBuilder.BSBGroup)1 BSBObject (blue.orchestra.blueSynthBuilder.BSBObject)1 BSBObjectEntry (blue.orchestra.blueSynthBuilder.BSBObjectEntry)1 GridSettings (blue.orchestra.blueSynthBuilder.GridSettings)1 EditModeOnly (blue.orchestra.editor.blueSynthBuilder.EditModeOnly)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 InvalidationListener (javafx.beans.InvalidationListener)1 Bindings (javafx.beans.binding.Bindings)1 BooleanProperty (javafx.beans.property.BooleanProperty)1 SimpleBooleanProperty (javafx.beans.property.SimpleBooleanProperty)1 ChangeListener (javafx.beans.value.ChangeListener)1 FXCollections (javafx.collections.FXCollections)1 ListChangeListener (javafx.collections.ListChangeListener)1 ObservableList (javafx.collections.ObservableList)1