X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=MooNoteElement.java;h=60808898339361e3b70a53b21b6ac03c325713d7;hb=4526e51b70110f7272b0c2a3a5f207657d690029;hp=459bf5bde05334adfd19919c7632c15289289831;hpb=2987fea4ec5854c2431e042f17daf5a923c438a1;p=moosique.git diff --git a/MooNoteElement.java b/MooNoteElement.java index 459bf5b..6080889 100644 --- a/MooNoteElement.java +++ b/MooNoteElement.java @@ -9,7 +9,7 @@ import java.awt.event.*; * @version 1 */ -public class MooNoteElement extends JPanel { +public class MooNoteElement extends JPanel implements Comparable{ private MooTrackView mtv; private MooNote note; @@ -65,6 +65,14 @@ public class MooNoteElement extends JPanel { return note; } + /** + * Compares the note of this element to that of another note. + * @return a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object + */ + public int compareTo(Object o) { + return note.compareTo(((MooNoteElement)o).getNote()); + } + /** * Selects the current NoteElement. */ @@ -227,7 +235,12 @@ public class MooNoteElement extends JPanel { } public void mouseReleased(MouseEvent e) { - if (!maybeShowPopup(e) && !mouseIn) mtv.maybeMoveSelectedNotes(getY(), getY() + e.getY()); + if (!maybeShowPopup(e) && !mouseIn) { + int y = e.getY(); + if (y < 0) mtv.maybeMoveSelectedNotes((int)Math.floor((double)y / MooTrackView.NOTE_HEIGHT) * MooTrackView.NOTE_HEIGHT); + if (y > getHeight()) mtv.maybeMoveSelectedNotes((int)Math.ceil(((double)y - getHeight()) / MooTrackView.NOTE_HEIGHT) * MooTrackView.NOTE_HEIGHT); + + } } /** @@ -250,8 +263,11 @@ public class MooNoteElement extends JPanel { public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (source == popupProp) { + System.out.println("Duration: " + note.getDuration()); new MooDialog(note); + System.out.println("Duration: " + note.getDuration()); newLayout(); + repaint(); } else if (source == popupRemove) { remove(); } else if (source == popupTranspOctUp) {