use of blue.components.lines.Line 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.Line in project blue by kunstmusik.
the class ZakLineObject method loadFromXML.
/* SERIALIZATION */
/**
* Load object's state from XML
*/
public static SoundObject loadFromXML(Element data, Map<String, Object> objRefMap) throws Exception {
ZakLineObject lObj = new ZakLineObject();
SoundObjectUtilities.initBasicFromXML(data, lObj);
Elements lines = data.getElements();
while (lines.hasMoreElements()) {
Element node = lines.next();
if (node.getName().equals("zakline")) {
Line l = Line.loadFromXML(node);
lObj.getLines().add(l);
}
}
return lObj;
}
use of blue.components.lines.Line in project blue by kunstmusik.
the class TempoEditor method paintComponent.
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (this.tempo == null) {
return;
}
Graphics2D g2d = (Graphics2D) g;
g2d.setStroke(STROKE2);
RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHints(hints);
Color currentColor = null;
ModeManager modeManager = ModeManager.getInstance();
Line tempoLine = this.tempo.getLine();
boolean enabled = this.tempo.isEnabled();
if (enabled) {
if (tempo.isVisible()) {
g2d.setColor(Color.GREEN);
} else {
g2d.setColor(Color.GREEN.darker().darker());
}
drawLine(g2d, tempoLine, this.tempo.isVisible());
} else {
g2d.setColor(Color.DARK_GRAY);
drawLine(g2d, tempoLine, false);
g2d.setColor(Color.WHITE);
g2d.drawLine(0, getHeight() - 1, getWidth(), getHeight() - 1);
return;
}
if (enabled && selectedPoint != null) {
double min = tempoLine.getMin();
double max = tempoLine.getMax();
int x = doubleToScreenX(selectedPoint.getX());
int y = doubleToScreenY(selectedPoint.getY(), min, max);
g2d.setColor(Color.red);
paintPoint(g2d, x, y);
drawPointInformation(g2d, x, y);
}
g2d.setColor(Color.WHITE);
g2d.drawLine(0, getHeight() - 1, getWidth(), getHeight() - 1);
}
use of blue.components.lines.Line in project blue by kunstmusik.
the class TempoEditor method setBoundaryXValues.
public void setBoundaryXValues() {
Line currentLine = tempo.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 CSDRender method appendParameterScore.
private void appendParameterScore(Parameter param, int instrId, StrBuilder paramScore, double renderStart, double renderEnd) {
Line line = param.getLine();
if (line.size() < 2) {
return;
}
// TODO - re-evaluate this strategy for generating values
double resolution = param.getResolution().doubleValue();
double startAdj = 0;
double durationAdj = 1.0;
boolean adjustPoints = (line instanceof SoundObjectParameterLine);
if (adjustPoints) {
SoundObjectParameterLine paramLine = (SoundObjectParameterLine) line;
startAdj = paramLine.getSourceStart();
durationAdj = paramLine.getSourceDuration();
}
if (resolution > 0.0f) {
for (int i = 1; i < line.size(); i++) {
LinePoint p1 = line.getLinePoint(i - 1);
LinePoint p2 = line.getLinePoint(i);
double startTime = p1.getX();
double endTime = p2.getX();
if (adjustPoints) {
startTime = (startTime * durationAdj) + startAdj;
endTime = (endTime * durationAdj) + startAdj;
}
if (renderEnd > 0 && startTime >= renderEnd) {
return;
}
if (endTime <= renderStart) {
continue;
}
double startVal = p1.getY();
double endVal = p2.getY();
// to skip points that don't contribute to end value
if (startTime == endTime) {
if (i == line.size() - 1) {
createParamNote(paramScore, instrId, endTime, .0001f, p2.getY(), p2.getY());
}
continue;
}
if (startVal == endVal) {
continue;
}
double dur = endTime - startTime;
double currentVal = startVal;
int numSteps = (int) Math.abs(Math.round((endVal - startVal) / resolution));
double step = dur / numSteps;
double start = startTime;
double valStep = resolution;
if (endVal < startVal) {
valStep = -valStep;
}
// skip the first value as it will be already defined
for (int j = 0; j < numSteps - 1; j++) {
currentVal += valStep;
start += step;
if (start <= renderStart) {
continue;
}
if (renderEnd > 0 && start >= renderEnd) {
return;
}
paramScore.append("i");
paramScore.append(instrId).append("\t");
paramScore.append(NumberUtilities.formatDouble(start - renderStart)).append("\t");
paramScore.append(".0001\t");
paramScore.append(NumberUtilities.formatDouble(currentVal)).append("\n");
}
start += step;
if (renderEnd > 0 && start >= renderEnd) {
return;
}
paramScore.append("i");
paramScore.append(instrId).append("\t");
paramScore.append(NumberUtilities.formatDouble(start - renderStart)).append("\t");
paramScore.append(".0001\t");
paramScore.append(NumberUtilities.formatDouble(endVal)).append("\n");
}
} else {
double lastValue = line.getLinePoint(0).getY();
for (int i = 1; i < line.size(); i++) {
LinePoint p1 = line.getLinePoint(i - 1);
LinePoint p2 = line.getLinePoint(i);
double startTime = p1.getX();
double endTime = p2.getX();
if (adjustPoints) {
startTime = (startTime * durationAdj) + startAdj;
endTime = (endTime * durationAdj) + startAdj;
}
if (renderEnd > 0 && startTime >= renderEnd) {
return;
}
if (endTime <= renderStart) {
lastValue = p2.getY();
continue;
}
if (p1.getX() == p2.getX()) {
if (i == line.size() - 1) {
createParamNote(paramScore, instrId, p2.getX(), .0001f, p2.getY(), p2.getY());
}
continue;
}
// if (p1.getY() == p2.getY() && p1.getY() == lastValue) {
// continue;
// }
double startVal = p1.getY();
double endVal = p2.getY();
if (startTime < renderStart) {
startVal = line.getValue(renderStart);
startTime = renderStart;
}
if (renderEnd > 0 && endTime > renderEnd) {
endVal = line.getValue(renderEnd);
endTime = renderEnd;
}
lastValue = endVal;
double dur;
if (p1.getY() == p2.getY()) {
dur = .0001f;
} else {
dur = endTime - startTime;
}
startTime -= renderStart;
createParamNote(paramScore, instrId, startTime, dur, startVal, endVal);
if (i == line.size() - 1) {
createParamNote(paramScore, instrId, startTime + dur, .0001f, endVal, endVal);
}
}
}
}
Aggregations