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);
}
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);
}
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));
}
}
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);
}
}
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();
}
Aggregations