use of blue.orchestra.blueSynthBuilder.BSBObject in project blue by kunstmusik.
the class SubChannelListPanel method reconcileNameChangeInBlueArrangement.
/**
* A hack to explicitly walk the current blue orchestra to find any
* BlueSynthBuilder's that contain BSBSubChannelDropdown's and to reconcile
* the name change.
*
* @param oldName
* @param newName
*/
private void reconcileNameChangeInBlueArrangement(String oldName, String newName) {
BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
if (data == null) {
return;
}
Arrangement arr = data.getArrangement();
for (int i = 0; i < arr.size(); i++) {
Instrument instr = arr.getInstrument(i);
if (instr instanceof BlueSynthBuilder) {
BlueSynthBuilder bsb = (BlueSynthBuilder) instr;
BSBGraphicInterface bsbInterface = bsb.getGraphicInterface();
for (BSBObject bsbObj : bsbInterface.getAllSet()) {
if (bsbObj instanceof BSBSubChannelDropdown) {
BSBSubChannelDropdown bsbSubDrop = (BSBSubChannelDropdown) bsbObj;
if (bsbSubDrop.getChannelOutput().equals(oldName)) {
bsbSubDrop.setChannelOutput(newName);
}
}
}
}
}
}
use of blue.orchestra.blueSynthBuilder.BSBObject in project blue by kunstmusik.
the class BSBObjectViewHolder method getContextMenu.
private static ContextMenu getContextMenu() {
if (MENU == null) {
MENU = new ContextMenu();
MenuItem cut = new MenuItem("Cut");
cut.setOnAction(e -> {
MenuData data = (MenuData) MENU.getUserData();
BSBEditSelection selection = data.selection;
selection.cut();
});
MenuItem copy = new MenuItem("Copy");
copy.setOnAction(e -> {
MenuData data = (MenuData) MENU.getUserData();
BSBEditSelection selection = data.selection;
selection.copy();
});
MenuItem remove = new MenuItem("Remove");
remove.setOnAction(e -> {
MenuData data = (MenuData) MENU.getUserData();
BSBEditSelection selection = data.selection;
selection.remove();
});
MenuItem makeGroup = new MenuItem("Make Group");
makeGroup.setOnAction(e -> {
MenuData data = (MenuData) MENU.getUserData();
BSBEditSelection selection = data.selection;
List<BSBGroup> groupsList = data.groupsList;
List<BSBObject> bsbObjs = selection.selection.stream().map(b -> b.deepCopy()).collect(Collectors.toList());
int x = Integer.MAX_VALUE;
int y = Integer.MAX_VALUE;
for (BSBObject bsbObj : bsbObjs) {
x = Math.min(x, bsbObj.getX());
y = Math.min(y, bsbObj.getY());
}
for (BSBObject bsbObj : bsbObjs) {
bsbObj.setX(bsbObj.getX() - x + 10);
bsbObj.setY(bsbObj.getY() - y + 10);
}
selection.remove();
BSBGroup group = new BSBGroup();
group.interfaceItemsProperty().addAll(bsbObjs);
group.setX(x);
group.setY(y);
groupsList.get(groupsList.size() - 1).addBSBObject(group);
});
MenuItem breakGroup = new MenuItem("Break Group");
breakGroup.setOnAction((ActionEvent e) -> {
MenuData data = (MenuData) MENU.getUserData();
BSBEditSelection selection = data.selection;
List<BSBGroup> groupsList = data.groupsList;
BSBGroup group = (BSBGroup) selection.selection.toArray()[0];
int x = group.getX();
int y = group.getY();
selection.remove();
BSBGroup rootGroup = groupsList.get(groupsList.size() - 1);
for (BSBObject bsbObj : group) {
BSBObject temp = bsbObj.deepCopy();
temp.setX(temp.getX() + x);
temp.setY(temp.getY() + y);
rootGroup.addBSBObject(temp);
}
;
});
final Menu align = new Menu("Align");
final Menu distribute = new Menu("Distribute");
EventHandler<ActionEvent> alignListener = ae -> {
MenuItem source = (MenuItem) ae.getSource();
Alignment alignment = (Alignment) source.getUserData();
MenuData data = (MenuData) MENU.getUserData();
BSBEditSelection selection = data.selection;
AlignmentUtils.align(selection.getSelectedNodes(), alignment);
};
EventHandler<ActionEvent> distributeListener = ae -> {
MenuItem source = (MenuItem) ae.getSource();
Alignment alignment = (Alignment) source.getUserData();
MenuData data = (MenuData) MENU.getUserData();
BSBEditSelection selection = data.selection;
AlignmentUtils.distribute(selection.getSelectedNodes(), alignment);
};
for (Alignment alignment : Alignment.values()) {
MenuItem a = new MenuItem(alignment.toString());
a.setUserData(alignment);
a.setOnAction(alignListener);
MenuItem d = new MenuItem(alignment.toString());
d.setUserData(alignment);
d.setOnAction(distributeListener);
align.getItems().add(a);
distribute.getItems().add(d);
}
MENU.getItems().addAll(cut, copy, remove);
MENU.getItems().addAll(new SeparatorMenuItem(), makeGroup, breakGroup);
MENU.getItems().addAll(new SeparatorMenuItem(), align, distribute);
MENU.setOnHidden(e -> MENU.setUserData(null));
MENU.setOnShowing(e -> {
MenuData data = (MenuData) MENU.getUserData();
BSBEditSelection selection = data.selection;
align.setDisable(selection.selection.size() < 2);
distribute.setDisable(selection.selection.size() < 2);
breakGroup.setDisable(selection.selection.size() != 1 || selection.selection.stream().noneMatch((x) -> x instanceof BSBGroup));
});
}
return MENU;
}
use of blue.orchestra.blueSynthBuilder.BSBObject 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);
}
}
use of blue.orchestra.blueSynthBuilder.BSBObject in project blue by kunstmusik.
the class BSBEditSelection method initiateMove.
public void initiateMove(BSBObject sourceDragObject) {
startPositions.clear();
minX = Double.MAX_VALUE;
minY = Double.MAX_VALUE;
for (BSBObject bsbObj : selection) {
double x = bsbObj.getX();
double y = bsbObj.getY();
startPositions.put(bsbObj, new Point(x, y));
minX = Math.min(minX, x);
minY = Math.min(minY, y);
}
if (gridSettings != null && gridSettings.isSnapEnabled()) {
gridOffsetX = sourceDragObject.getX() % gridSettings.getWidth();
gridOffsetY = sourceDragObject.getY() % gridSettings.getHeight();
} else {
gridOffsetX = gridOffsetY = 0;
}
processingMove = true;
}
use of blue.orchestra.blueSynthBuilder.BSBObject 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);
}
}
Aggregations