use of blue.components.lines.LinePoint in project blue by kunstmusik.
the class SoundEditor method editScoreObject.
@Override
public final void editScoreObject(ScoreObject sObj) {
if (sObj == null) {
this.sObj = null;
editorLabel.setText("no editor available");
editor.editInstrument(null);
return;
}
if (!(sObj instanceof Sound)) {
this.sObj = null;
editorLabel.setText("no editor available");
editor.editInstrument(null);
return;
}
if (this.sObj != null) {
final Sound temp = this.sObj;
BlueFX.runOnFXThread(() -> {
temp.commentProperty().unbind();
temp.removeScoreObjectListener(sObjListener);
});
}
this.sObj = (Sound) sObj;
editor.editInstrument(this.sObj.getBlueSynthBuilder());
BlueFX.runOnFXThread(() -> {
lineList.clear();
int colorCount = 0;
for (Parameter p : this.sObj.getBlueSynthBuilder().getParameterList().sorted()) {
if (p.isAutomationEnabled()) {
p.getLine().setVarName(p.getName());
p.getLine().setColor(LineColors.getColor(colorCount++));
List<LinePoint> points = p.getLine().getObservableList();
if (points.size() < 2) {
LinePoint lp = new LinePoint();
lp.setLocation(1.0, points.get(0).getY());
points.add(lp);
}
lineList.add(p.getLine());
}
}
lineView.setStartTime(this.sObj.getStartTime());
lineView.setDuration(this.sObj.getSubjectiveDuration());
commentTextArea.setText(this.sObj.getComment());
this.sObj.commentProperty().bind(commentTextArea.textProperty());
this.sObj.addScoreObjectListener(sObjListener);
});
}
use of blue.components.lines.LinePoint in project blue by kunstmusik.
the class ParameterLinePanel method findGraphPoint.
public LinePoint findGraphPoint(int x) {
Line currentLine = currentParameter.getLine();
for (int i = 0; i < currentLine.size(); i++) {
LinePoint point = currentLine.getLinePoint(i);
int tempX = doubleToScreenX(point.getX());
if (tempX >= x - 2 && tempX <= x + 2) {
return point;
}
}
return null;
}
use of blue.components.lines.LinePoint in project blue by kunstmusik.
the class TempoEditor method insertGraphPoint.
/**
* Use by the MouseListener to add points
*
* @param x
* @param y
* @return
*/
protected LinePoint insertGraphPoint(int x, int y) {
LinePoint point = new LinePoint();
Line currentLine = tempo.getLine();
double min = currentLine.getMin();
double max = currentLine.getMax();
point.setLocation(screenToDoubleX(x), screenToDoubleY(y, min, max, -1));
int index = 1;
LinePoint last = currentLine.getLinePoint(currentLine.size() - 1);
if (point.getX() > last.getX()) {
currentLine.addLinePoint(point);
return point;
}
for (int i = 0; i < currentLine.size(); i++) {
LinePoint p1 = currentLine.getLinePoint(i);
LinePoint p2 = currentLine.getLinePoint(i + 1);
if (point.getX() >= p1.getX() && point.getX() <= p2.getX()) {
index = i + 1;
break;
}
}
currentLine.addLinePoint(index, point);
return point;
}
use of blue.components.lines.LinePoint in project blue by kunstmusik.
the class TempoEditor method findGraphPoint.
public LinePoint findGraphPoint(int x, int y) {
Line currentLine = tempo.getLine();
double min = currentLine.getMin();
double max = currentLine.getMax();
for (int i = 0; i < currentLine.size(); i++) {
LinePoint point = currentLine.getLinePoint(i);
int tempX = doubleToScreenX(point.getX());
int tempY = doubleToScreenY(point.getY(), min, max);
if (tempX >= x - 2 && tempX <= x + 2 && tempY >= y - 2 && tempY <= y + 2) {
return point;
}
}
return null;
}
use of blue.components.lines.LinePoint in project blue by kunstmusik.
the class ParameterLineView method mouseMoved.
private void mouseMoved(MouseEvent me) {
if (getSelectedLine() == null) {
return;
}
me.consume();
double x = me.getX();
double y = me.getY();
LinePoint foundPoint = findGraphPoint(x, y);
if (foundPoint != null) {
if (selectedPoint != foundPoint) {
selectedPoint = foundPoint;
repaint();
}
} else if (selectedPoint != null) {
selectedPoint = null;
repaint();
}
}
Aggregations