Search in sources :

Example 6 with Pattern

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];
}
Also used : Pattern(blue.soundObject.pattern.Pattern)

Example 7 with Pattern

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;
}
Also used : Pattern(blue.soundObject.pattern.Pattern)

Example 8 with Pattern

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);
}
Also used : Pattern(blue.soundObject.pattern.Pattern)

Example 9 with Pattern

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();
}
Also used : Pattern(blue.soundObject.pattern.Pattern)

Example 10 with Pattern

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();
}
Also used : Pattern(blue.soundObject.pattern.Pattern)

Aggregations

Pattern (blue.soundObject.pattern.Pattern)11 Element (electric.xml.Element)2 Iterator (java.util.Iterator)2 NoteProcessorException (blue.noteProcessor.NoteProcessorException)1 Elements (electric.xml.Elements)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 ToStringBuilder (org.apache.commons.lang3.builder.ToStringBuilder)1