- class NoteArea extends JPanel {
- public static final int NOTE_HEIGHT = 10;
- public static final int NOTE_WIDTH = 40;
- private int trackLength;
-
- public NoteArea(Track track) {
- System.out.println("Creating track view...");
- setLayout(null);
- trackLength = 140;
- MidiEvent note;
- MooNoteElement elem;
- boolean isOccupied;
- int x, y, height;
- Insets insets = getInsets();
- for (int i = 0; i < track.size(); i++) {
- note = track.get(i);
- if (note instanceof MooNote) {
- // Adds the note element to the note area.
- MooNote mn = (MooNote)note;
- elem = new MooNoteElement(mn);
- add(elem);
-
- // Places the note element in the appropriate place.
- x = insets.left;
- 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);
- }
- }
- validate();
+ /**
+ * Adds a standard note to this track.
+ */
+ private void addStandardNote() {
+ int row = (popupY - insets.top) / NOTE_HEIGHT;
+ long timestamp = (long)(ticksPerSixteenth * row);
+ addNote(new MooNote(title.getChannel(), 60, 100, timestamp, Moosique.getSequence().getResolution() / 4));
+ }
+
+ /**
+ * Deselects all notes.
+ */
+ public void addSelected(MooNoteElement elem) {
+ selected.add(elem);
+ }
+
+ /**
+ * Deselects all notes.
+ */
+ public void removeSelected(MooNoteElement elem) {
+ selected.remove(selected.indexOf(elem));
+ }
+
+ /**
+ * Deselects all notes.
+ */
+ public void deselectAll() {
+ Iterator it = selected.iterator();
+ while(it.hasNext()) {
+ ((MooNoteElement)it.next()).deselect();