use of blue.components.lines.LinePoint in project blue by kunstmusik.
the class LineCanvas method insertGraphPoint.
/**
* Use by the MouseListener to add points
*
* @param i
* @param j
* @return
*/
protected LinePoint insertGraphPoint(int x, int y) {
if (x < 5 || x > this.getWidth() - 5 || y < 5 || y > this.getHeight() - 5) {
return null;
}
double min = currentLine.getMin();
double max = currentLine.getMax();
LinePoint point = new LinePoint();
point.setLocation(screenToDoubleX(x), screenToDoubleY(y, min, max));
int index = 1;
for (int i = 0; i < currentLine.size() - 1; 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 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.LinePoint in project blue by kunstmusik.
the class BSBLineObject method getLineString.
private String getLineString(Line line) {
StrBuilder buffer = new StrBuilder();
double[] xVals = new double[line.size()];
double[] yVals = new double[line.size()];
for (int i = 0; i < line.size(); i++) {
LinePoint p = line.getLinePoint(i);
xVals[i] = p.getX() * getXMax();
yVals[i] = p.getY();
}
if (isRelativeXValues()) {
for (int i = xVals.length - 1; i > 0; i--) {
xVals[i] = xVals[i] - xVals[i - 1];
}
}
String spacer = getSeparatorType().getSeparatorString();
if (isLeadingZero()) {
buffer.append("0.0").append(spacer);
}
buffer.append(yVals[0]);
for (int i = 1; i < xVals.length; i++) {
buffer.append(spacer).append(NumberUtilities.formatDouble(xVals[i]));
buffer.append(spacer).append(NumberUtilities.formatDouble(yVals[i]));
}
return buffer.toString();
}
use of blue.components.lines.LinePoint in project blue by kunstmusik.
the class Channel 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;
} else {
levelParameter.setValue(level);
}
double oldVal = this.level;
this.level = level;
firePropertyChange(LEVEL, new Double(oldVal), new Double(level));
}
use of blue.components.lines.LinePoint in project blue by kunstmusik.
the class TempoEditor method drawLine.
private final void drawLine(Graphics g, Line line, boolean drawPoints) {
Rectangle clipBounds = g.getClipBounds();
if (line.size() == 0) {
return;
}
if (line.size() == 1) {
LinePoint lp = line.getLinePoint(0);
double min = line.getMin();
double max = line.getMax();
int x = doubleToScreenX(lp.getX());
int y = doubleToScreenY(lp.getY(), min, max);
g.drawLine(0, y, getWidth(), y);
if (drawPoints) {
paintPoint(g, x, y);
}
return;
}
int prevX = -1;
int prevY = -1;
int x, y;
double min = line.getMin();
double max = line.getMax();
int[] xValues = new int[line.size()];
int[] yValues = new int[line.size()];
for (int i = 0; i < line.size(); i++) {
LinePoint point = line.getLinePoint(i);
x = doubleToScreenX(point.getX());
y = doubleToScreenY(point.getY(), min, max);
xValues[i] = x;
yValues[i] = y;
if (prevX != -1) {
if ((prevX <= (clipBounds.x + clipBounds.width)) && (x >= clipBounds.x)) {
g.drawLine(prevX, prevY, x, y);
}
}
prevX = x;
prevY = y;
}
if (prevX < this.getWidth()) {
g.drawLine(prevX, prevY, getWidth(), prevY);
}
if (drawPoints) {
for (int i = 0; i < xValues.length; i++) {
paintPoint(g, xValues[i], yValues[i]);
}
}
}
Aggregations