use of blue.components.lines.LinePoint in project blue by kunstmusik.
the class ParameterLineView 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 ParameterLineView method drawLine.
private void drawLine(Line line, GraphicsContext gc, double w, double h) {
// TODO - replace with Affine transform
double min = line.getMin();
double max = line.getMax();
gc.beginPath();
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));
if (i == 0) {
gc.moveTo(x, y);
} else {
gc.lineTo(x, y);
gc.stroke();
}
}
gc.closePath();
}
use of blue.components.lines.LinePoint in project blue by kunstmusik.
the class ParameterLineView 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 drawLine.
private void drawLine(Line line, GraphicsContext gc, double w, double h) {
// TODO - replace with Affine transform
double min = line.getMin();
double max = line.getMax();
gc.beginPath();
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));
if (i == 0) {
gc.moveTo(x, y);
} else {
gc.lineTo(x, y);
gc.stroke();
}
}
gc.closePath();
}
use of blue.components.lines.LinePoint in project blue by kunstmusik.
the class LineView method editPoints.
private void editPoints() {
TableView<LinePoint> table = new TableView<>();
TableColumn<LinePoint, Double> xCol = new TableColumn<>("x");
TableColumn<LinePoint, Double> yCol = new TableColumn<>("y");
table.getColumns().setAll(xCol, yCol);
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
table.setItems(getSelectedLine().getObservableList());
table.setEditable(true);
xCol.setCellValueFactory(new PropertyValueFactory<LinePoint, Double>("x"));
xCol.setCellFactory(TextFieldTableCell.forTableColumn(new DoubleStringConverter()));
xCol.setOnEditCommit(te -> {
LinePoint lp = te.getRowValue();
if (getSelectedLine().getLinePoint(0) == lp || getSelectedLine().getLinePoint(getSelectedLine().size() - 1) == lp) {
return;
}
lp.setX(Utils.clamp(0.0, te.getNewValue(), 1.0));
});
xCol.setEditable(true);
yCol.setCellValueFactory(new PropertyValueFactory<LinePoint, Double>("y"));
yCol.setCellFactory(TextFieldTableCell.forTableColumn(new DoubleStringConverter()));
yCol.setOnEditCommit(te -> {
te.getRowValue().setY(Utils.clamp(getSelectedLine().getMin(), te.getNewValue(), getSelectedLine().getMax()));
});
yCol.setEditable(true);
Dialog<ButtonType> d = new Dialog<>();
d.initOwner(getScene().getWindow());
d.initModality(Modality.APPLICATION_MODAL);
d.getDialogPane().setContent(new ScrollPane(table));
d.getDialogPane().getStylesheets().add(BlueFX.getBlueFxCss());
d.getDialogPane().getButtonTypes().setAll(ButtonType.OK);
d.setTitle("Edit Points");
TableModelListener tml = tme -> {
repaint();
};
getSelectedLine().addTableModelListener(tml);
Optional<ButtonType> res = d.showAndWait();
getSelectedLine().removeTableModelListener(tml);
}
Aggregations