- y = insets.top + (int)(mn.getTick() / 24) * NOTE_HEIGHT;
- height = NOTE_HEIGHT;
- // height = (mn.getDuration() / 24) * NOTE_HEIGHT;
- // System.out.println("Comp at: " + x + ", " + y + " is: " + findComponentAt(x + 10, y + 10));
- while(findComponentAt(x, y) instanceof MooNoteElement ||
- findComponentAt(x, y + height - 1) instanceof MooNoteElement) x += NOTE_WIDTH;
- elem.setBounds(x, y, NOTE_WIDTH, height);
+ y = insets.top + (int)(mn.getTick() / beatsPerSixteenth) * NOTE_HEIGHT;
+ height = (mn.getDuration() / beatsPerSixteenth) * NOTE_HEIGHT;
+ if (height == 0) height = NOTE_HEIGHT;
+ Rectangle r = new Rectangle(x, y, NOTE_WIDTH, height);
+ while(isOccupied(r)) r.translate(NOTE_WIDTH, 0);
+ elem.setBounds(r);
+ rects.add(r);
+ if (viewLength < (y + height)) viewLength = y + height;