use of blue.components.lines.Line in project blue by kunstmusik.
the class ParameterLinePanel method setBoundaryXValues.
public void setBoundaryXValues() {
Line currentLine = currentParameter.getLine();
if (selectedPoint == currentLine.getLinePoint(0)) {
leftBoundaryX = 0;
rightBoundaryX = 0;
return;
} else if (selectedPoint == currentLine.getLinePoint(currentLine.size() - 1)) {
LinePoint p1 = currentLine.getLinePoint(currentLine.size() - 2);
leftBoundaryX = doubleToScreenX(p1.getX());
rightBoundaryX = this.getWidth();
return;
}
for (int i = 0; i < currentLine.size(); i++) {
if (currentLine.getLinePoint(i) == selectedPoint) {
LinePoint p1 = currentLine.getLinePoint(i - 1);
LinePoint p2 = currentLine.getLinePoint(i + 1);
leftBoundaryX = doubleToScreenX(p1.getX());
rightBoundaryX = doubleToScreenX(p2.getX());
return;
}
}
}
use of blue.components.lines.Line in project blue by kunstmusik.
the class ParameterLinePanel method drawSelectionLine.
/* Draws line when in selection mode (MULTILINE, SCORE when SCALING) */
private final void drawSelectionLine(Graphics g, Parameter p) {
Line tempLine = p.getLine();
if (selectionList.size() > 0) {
tempLine = getSelectionSortedLine(tempLine);
} else if (newSelectionStartTime >= 0) {
tempLine = getSelectionScalingSortedLine(tempLine);
} else if (ModeManager.getInstance().getMode() == ScoreMode.SCORE) {
drawLine(g, p, false);
return;
}
Color currentColor = g.getColor();
Rectangle clipBounds = g.getClipBounds();
if (tempLine.size() == 0) {
return;
}
double pixelSecond = (double) timeState.getPixelSecond();
double selectionStart;
double selectionEnd;
if (newSelectionStartTime >= 0) {
selectionStart = newSelectionStartTime;
selectionEnd = newSelectionEndTime;
} else {
selectionStart = marquee.startTime;
selectionEnd = marquee.endTime;
}
if (tempLine.size() == 1) {
LinePoint lp = tempLine.getLinePoint(0);
double min = tempLine.getMin();
double max = tempLine.getMax();
int x = doubleToScreenX(lp.getX());
int y = doubleToScreenY(lp.getY(), min, max);
g.setColor(currentColor);
g.drawLine(0, y, getWidth(), y);
paintSelectionPoint(g, x, y, lp.getX(), selectionStart, selectionEnd);
return;
}
if (p.getResolution().doubleValue() <= 0) {
int[] xValues = new int[tempLine.size()];
int[] yValues = new int[tempLine.size()];
double[] pointX = new double[tempLine.size()];
double min = tempLine.getMin();
double max = tempLine.getMax();
for (int i = 0; i < tempLine.size(); i++) {
LinePoint point = tempLine.getLinePoint(i);
pointX[i] = point.getX();
xValues[i] = doubleToScreenX(pointX[i]);
yValues[i] = doubleToScreenY(point.getY(), min, max);
}
g.drawPolyline(xValues, yValues, xValues.length);
final int lastX = xValues[xValues.length - 1];
if (lastX < this.getWidth()) {
int lastY = yValues[yValues.length - 1];
g.drawLine(lastX, lastY, getWidth(), lastY);
}
for (int i = 0; i < xValues.length; i++) {
paintSelectionPoint(g, xValues[i], yValues[i], pointX[i], selectionStart, selectionEnd);
}
} else {
LinePoint previous = null;
int x, y;
double min = p.getMin();
double max = p.getMax();
BigDecimal resolution = p.getResolution();
for (int i = 0; i < tempLine.size(); i++) {
LinePoint point = tempLine.getLinePoint(i);
x = doubleToScreenX(point.getX());
y = doubleToScreenY(point.getY(), min, max);
if (previous != null) {
double startVal = previous.getY();
int startX = doubleToScreenX(previous.getX());
int startY = doubleToScreenY(startVal, min, max);
int endX = doubleToScreenX(point.getX());
int endY = doubleToScreenY(point.getY(), min, max);
if (startVal == point.getY()) {
g.setColor(currentColor);
g.drawLine(startX, startY, endX, startY);
previous = point;
continue;
}
if (previous.getX() == point.getX()) {
if (startY != endY) {
g.setColor(currentColor);
g.drawLine(startX, startY, startX, endY);
}
previous = point;
continue;
}
int lastY = startY;
int lastX = startX;
for (int j = startX; j <= endX; j++) {
double timeVal = screenToDoubleX(j);
double val = tempLine.getValue(timeVal);
int newY = doubleToScreenY(val, min, max);
if (endY > startY) {
if (newY < startY) {
newY = startY;
}
} else if (newY > startY) {
newY = startY;
}
if (newY != lastY) {
g.setColor(currentColor);
g.drawLine(lastX, lastY, j, lastY);
g.drawLine(j, lastY, j, newY);
lastX = j;
lastY = newY;
}
}
if (lastX != endX) {
g.setColor(currentColor);
g.drawLine(lastX, lastY, endX, lastY);
g.drawLine(endX, lastY, endX, endY);
}
}
paintSelectionPoint(g, x, y, point.getX(), selectionStart, selectionEnd);
previous = point;
}
if (previous.getX() < this.getWidth()) {
int lastX = doubleToScreenX(previous.getX());
int lastY = doubleToScreenY(previous.getY(), min, max);
g.setColor(currentColor);
g.drawLine(lastX, lastY, getWidth(), lastY);
}
}
}
use of blue.components.lines.Line in project blue by kunstmusik.
the class ParameterLinePanel method getSelectionSortedLine.
/**
* Returns a line that has the points sorted and those masked removed when
* handling SelectionMoving; not sure this will be good for long term as it
* doesn't seem performant but using for initial work and can reevaluate
* later.
*
* @param line
* @return
*/
private Line getSelectionSortedLine(Line line) {
Line retVal = new Line(line);
double[] selPoints = selectionList.get(0);
double selectionStartTime = selPoints[0];
double selectionEndTime = selPoints[1];
retVal.processLineForSelectionDrag(selectionStartTime, selectionEndTime, transTime);
return retVal;
}
use of blue.components.lines.Line in project blue by kunstmusik.
the class Send method setLevel.
public void setLevel(double level) {
if (levelParameter.isAutomationEnabled()) {
double time = ParameterTimeManagerFactory.getInstance().getTime();
if (time < 0) {
return;
}
updatingLine = true;
LinePoint found = null;
Line line = levelParameter.getLine();
for (int i = 0; i < line.size(); i++) {
LinePoint point = line.getLinePoint(i);
if (point.getX() == time) {
found = point;
break;
}
}
if (found != null) {
found.setLocation(found.getX(), level);
} else {
LinePoint lp = new LinePoint();
lp.setLocation(time, level);
line.insertLinePoint(lp);
}
updatingLine = false;
}
double oldVal = this.level;
this.level = level;
PropertyChangeEvent pce = new PropertyChangeEvent(this, "level", new Double(oldVal), new Double(level));
firePropertyChangeEvent(pce);
}
use of blue.components.lines.Line in project blue by kunstmusik.
the class BSBLineObject method getReplacementKeys.
// public BSBObjectView getBSBObjectView() {
// return new BSBLineObjectView(this);
// }
@Override
public String[] getReplacementKeys() {
String[] vals = new String[lines.size()];
String objName = getObjectName();
for (int i = 0; i < lines.size(); i++) {
Line l = lines.get(i);
vals[i] = objName + "_" + l.getVarName();
}
return vals;
}
Aggregations