use of blue.soundObject.pattern.Pattern in project blue by kunstmusik.
the class PatternCanvasMouseListener method getPatternValue.
public boolean getPatternValue(int x, int y) {
if (this.patternObj == null) {
return false;
}
int patternNum = y / PatternsConstants.patternViewHeight;
if (patternNum >= this.patternObj.size() || patternNum < 0) {
return false;
}
Pattern p = patternObj.getPattern(patternNum);
int measureNum = x / PatternsConstants.patternViewHeight;
if (measureNum >= p.values.length || measureNum < 0) {
return false;
}
return p.values[measureNum];
}
use of blue.soundObject.pattern.Pattern in project blue by kunstmusik.
the class PatternCanvasMouseListener method setPatternValue.
public void setPatternValue(int x, int y, boolean val) {
if (this.patternObj == null) {
return;
}
int patternNum = y / PatternsConstants.patternViewHeight;
if (patternNum >= this.patternObj.size() || patternNum < 0) {
return;
}
Pattern p = patternObj.getPattern(patternNum);
int measureNum = x / PatternsConstants.patternViewHeight;
if (measureNum >= p.values.length || measureNum < 0) {
return;
}
p.values[measureNum] = val;
}
use of blue.soundObject.pattern.Pattern in project blue by kunstmusik.
the class PatternCanvasMouseListener method paintComponent.
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (patObj == null) {
return;
}
g.setColor(Color.black);
g.fillRect(0, 0, this.getWidth(), this.getHeight());
if (patObj.size() == 0) {
return;
}
// draw patternBoxes in
int x1, y1;
int subDivisions = patObj.getSubDivisions();
int steps = patObj.getBeats() * subDivisions;
int h = PatternsConstants.patternViewHeight;
int patternWidth = steps * h;
int patternHeight = (patObj.size()) * h;
g.setColor(PATTERN_COLOR);
for (int i = 0; i < patObj.size(); i++) {
Pattern p = patObj.getPattern(i);
for (int j = 0; j < steps; j++) {
if (p.values[j]) {
x1 = j * h;
y1 = i * h;
g.fillRect(x1, y1, h, h);
}
}
}
// draw horizontal lines
g.setColor(Color.darkGray);
for (int i = 0; i < patObj.size(); i++) {
g.drawLine(0, (i + 1) * h, patternWidth, (i + 1) * h);
}
for (int i = 0; i < steps; i++) {
if (i % subDivisions == 0) {
g.setColor(Color.gray);
} else {
g.setColor(Color.darkGray);
}
g.drawLine(i * h, 0, i * h, patternHeight);
}
g.setColor(Color.gray);
g.drawLine(steps * h, 0, steps * h, patternHeight);
}
use of blue.soundObject.pattern.Pattern in project blue by kunstmusik.
the class PatternObject method addPattern.
public void addPattern(int index) {
Pattern pattern = new Pattern(beats * subDivisions);
pattern.setPatternName(pattern.getPatternName() + patterns.size());
patterns.add(index, pattern);
fireTableDataChanged();
}
use of blue.soundObject.pattern.Pattern in project blue by kunstmusik.
the class PatternObject method pushDownPatternLayers.
public void pushDownPatternLayers(int[] rows) {
Pattern a = patterns.remove(rows[rows.length - 1] + 1);
patterns.add(rows[0], a);
this.fireTableDataChanged();
}
Aggregations