use of blue.components.lines.LinePoint in project blue by kunstmusik.
the class LineView method setBoundaryXValues.
private void setBoundaryXValues() {
if (selectedPoint == null || getSelectedLine() == null) {
return;
}
int size = getSelectedLine().size();
if (selectedPoint == getSelectedLine().getLinePoint(0)) {
leftBoundaryX = 0.0;
rightBoundaryX = 0.0;
return;
} else if (selectedPoint == getSelectedLine().getLinePoint(size - 1)) {
leftBoundaryX = getWidth();
rightBoundaryX = getWidth();
return;
}
for (int i = 0; i < size; i++) {
if (getSelectedLine().getLinePoint(i) == selectedPoint) {
LinePoint p1 = getSelectedLine().getLinePoint(i - 1);
LinePoint p2 = getSelectedLine().getLinePoint(i + 1);
leftBoundaryX = p1.getX() * getWidth();
rightBoundaryX = p2.getX() * getWidth();
return;
}
}
}
use of blue.components.lines.LinePoint in project blue by kunstmusik.
the class LineView method drawPoints.
private void drawPoints(Line line, GraphicsContext gc, double w, double h) {
double min = line.getMin();
double max = line.getMax();
gc.setFill(Color.BLACK);
for (int i = 0; i < line.size(); i++) {
LinePoint lp = line.getLinePoint(i);
double x = Math.floor(lp.getX() * w);
double y = Math.floor(yToScreen(lp.getY(), min, max));
gc.fillOval(x - 3, y - 3, 7, 7);
gc.strokeOval(x - 3, y - 3, 7, 7);
}
}
use of blue.components.lines.LinePoint in project blue by kunstmusik.
the class LineView method mousePressed.
private void mousePressed(MouseEvent me) {
if (getSelectedLine() == null) {
return;
}
pressX = me.getX();
pressY = me.getY();
me.consume();
if (selectedPoint != null) {
if (me.isSecondaryButtonDown()) {
if (isLocked()) {
return;
}
LinePoint first = getSelectedLine().getLinePoint(0);
LinePoint last = getSelectedLine().getLinePoint(getSelectedLine().size() - 1);
if (selectedPoint != first && selectedPoint != last) {
getSelectedLine().removeLinePoint(selectedPoint);
selectedPoint = null;
repaint();
}
} else {
setBoundaryXValues();
}
} else {
if (me.isSecondaryButtonDown()) {
editPointsMenu.show(LineView.this, me.getScreenX(), me.getScreenY());
} else if (me.isPrimaryButtonDown()) {
if (!isLocked()) {
selectedPoint = insertGraphPoint(me.getX(), me.getY());
repaint();
setBoundaryXValues();
}
}
}
}
use of blue.components.lines.LinePoint in project blue by kunstmusik.
the class LineView method insertGraphPoint.
private LinePoint insertGraphPoint(double x, double y) {
if (x < 0 || x > getWidth() || y < 0 || y > getHeight()) {
return null;
}
double min = getSelectedLine().getMin();
double max = getSelectedLine().getMax();
LinePoint point = new LinePoint();
point.setLocation(x / getWidth(), screenToY(y, min, max));
int index = 1;
for (int i = 0; i < getSelectedLine().size() - 1; i++) {
LinePoint p1 = getSelectedLine().getLinePoint(i);
LinePoint p2 = getSelectedLine().getLinePoint(i + 1);
if (point.getX() >= p1.getX() && point.getX() <= p2.getX()) {
index = i + 1;
break;
}
}
getSelectedLine().addLinePoint(index, point);
return point;
}
use of blue.components.lines.LinePoint in project blue by kunstmusik.
the class SoundEditor method jbInit.
private void jbInit() throws Exception {
this.setLayout(new BorderLayout());
this.add(editor);
editor.setLabelText("[ Sound ]");
JFXPanel jfxPanel = new JFXPanel();
CountDownLatch latch = new CountDownLatch(1);
JFXPanel jfxCommentPanel = new JFXPanel();
BlueFX.runOnFXThread(() -> {
try {
MenuButton btn = new MenuButton("Automations");
BorderPane mainPane = new BorderPane();
lineView = new ParameterLineView(lineList);
lineSelector = new LineSelector(lineList);
lineView.widthProperty().bind(mainPane.widthProperty());
lineView.heightProperty().bind(mainPane.heightProperty().subtract(lineSelector.heightProperty()));
lineSelector.getChildren().add(0, btn);
lineSelector.setSpacing(5.0);
lineView.selectedLineProperty().bind(lineSelector.selectedLineProperty());
TimeBar tb = new TimeBar();
tb.startTimeProperty().bind(lineView.startTimeProperty());
tb.durationProperty().bind(lineView.durationProperty());
Pane p = new Pane(lineView, tb);
p.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY)));
lineView.widthProperty().bind(p.widthProperty().subtract(20));
lineView.heightProperty().bind(p.heightProperty().subtract(40));
lineView.setLayoutX(10);
lineView.setLayoutY(30);
tb.widthProperty().bind(lineView.widthProperty());
tb.setHeight(20);
tb.setLayoutX(10);
tb.setLayoutY(10);
mainPane.setCenter(p);
mainPane.setTop(lineSelector);
btn.showingProperty().addListener((obs, old, newVal) -> {
if (newVal) {
if (sObj != null) {
sObj.getBlueSynthBuilder().getParameterList().sorted().forEach((param) -> {
MenuItem m = new MenuItem(param.getName());
m.setOnAction(e -> {
param.setAutomationEnabled(!param.isAutomationEnabled());
if (param.isAutomationEnabled()) {
Line line = param.getLine();
line.setVarName(param.getName());
List<LinePoint> points = line.getObservableList();
if (points.size() < 2) {
LinePoint lp = new LinePoint();
lp.setLocation(1.0, points.get(0).getY());
points.add(lp);
}
lineList.add(line);
} else {
lineList.remove(param.getLine());
}
int colorCount = 0;
for (Line line : lineList) {
line.setColor(LineColors.getColor(colorCount++));
}
});
if (param.isAutomationEnabled()) {
m.setStyle("-fx-text-fill: green;");
}
btn.getItems().add(m);
});
}
} else {
btn.getItems().clear();
}
});
final Scene scene = new Scene(mainPane);
BlueFX.style(scene);
jfxPanel.setScene(scene);
commentTextArea = new TextArea();
commentTextArea.setWrapText(true);
final Scene scene2 = new Scene(commentTextArea);
BlueFX.style(scene2);
jfxCommentPanel.setScene(scene2);
} finally {
latch.countDown();
}
});
try {
latch.await();
} catch (InterruptedException ex) {
Exceptions.printStackTrace(ex);
}
editor.getTabs().insertTab("Automation", null, jfxPanel, "", 1);
editor.getTabs().addTab("Comments", jfxCommentPanel);
}
Aggregations