]> ruin.nu Git - moosique.git/commitdiff
*** empty log message ***
authorEinar Pehrson <einarp@itstud.chalmers.se>
Fri, 16 May 2003 16:22:08 +0000 (16:22 +0000)
committerEinar Pehrson <einarp@itstud.chalmers.se>
Fri, 16 May 2003 16:22:08 +0000 (16:22 +0000)
MooDialog.java
MooMenu.java
report.txt

index 82305788c5220b897c4c1ca8e33db5ac0b3cd2d8..d4530bd6f8ae437e66f77a3da04e7b4b0cd7ee96 100644 (file)
@@ -2,6 +2,7 @@ import javax.swing.*;
 import java.awt.*;
 import java.awt.event.*;
 import javax.sound.midi.*;
+import java.io.*;
 import java.beans.*;
 
 /**
@@ -20,7 +21,8 @@ public class MooDialog extends JDialog {
                                DELETE_TRACK = 2,
                                COPY_TRACK = 3,
                                MOVE_TRACK = 4,
-                               JUMP = 5;
+                               JUMP = 5,
+                               CONTENTS = 6;
        
        /**
         * Constructor of the dialogs.
@@ -34,35 +36,12 @@ public class MooDialog extends JDialog {
                Track[] tracks = Moosique.getSequence().getTracks();
 
                switch (type) {
-                       case ADD_TRACK:
-                               
-                               makeAddDialog(pane, tracks);
-                               
-                               break;
-                               
-                       case DELETE_TRACK:
-                       
-                               makeDelDialog(pane, tracks);
-                               
-                               break;
-                               
-                       case COPY_TRACK:
-                               
-                               makeCopyDialog(pane, tracks);
-                       
-                               break;
-                       
-                       case MOVE_TRACK:
-                               
-                               makeMoveDialog(pane, tracks);
-                               
-                               break;
-                       
-                       case JUMP:
-                               
-                               makeJumpDialog(pane);
-                               
-                               break;
+                       case ADD_TRACK:         makeAddDialog(pane, tracks); break;
+                       case DELETE_TRACK:      makeDelDialog(pane, tracks); break;
+                       case COPY_TRACK:        makeCopyDialog(pane, tracks); break;
+                       case MOVE_TRACK:        makeMoveDialog(pane, tracks); break;
+                       case JUMP:              makeJumpDialog(pane); break;
+                       case CONTENTS:          makeTextDialog(pane, "Manual.txt"); break;
                }
         }
        
@@ -241,7 +220,31 @@ public class MooDialog extends JDialog {
                setSize(260,175);
                setVisible(true);
        }
-       
+
+       private void makeTextDialog(Container pane, String filename) {
+               setTitle("Contents");
+               File manual = new File(filename);
+               String s;
+               try {
+                       BufferedReader br = new BufferedReader(new FileReader(manual));
+                       char[] chars = new char[(int)manual.length()];
+                       br.read(chars, 0, (int)manual.length());
+                       s = new String(chars);
+               } catch (Exception ex) {
+                       s = "Manual not found";
+               }
+               JTextArea contents = new JTextArea(s, 30, 40);
+               contents.setAutoscrolls(true);
+               pane.add(contents);
+               contents.setBounds(10, 10, 500, 350);
+               setResizable(false);
+               pack();
+               setSize(600,400);
+               setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - this.getWidth()) / 2,
+               (Toolkit.getDefaultToolkit().getScreenSize().height - this.getHeight()) / 2);
+               setVisible(true);
+       }
+
        private MooNote note;
        private JOptionPane optionPane;
        private JTextField pitch;
index f51af1a28de19f14c5234bae9dd3f879eb2d7cc0..c4a01c1a42dd8a934e93fad4281124a43923f065 100644 (file)
@@ -55,10 +55,10 @@ public class MooMenu extends JMenuBar implements ActionListener {
                addItem(music, "Delete track...", KeyEvent.VK_D, ActionEvent.CTRL_MASK);
                addItem(music, "Copy track...", KeyEvent.VK_Y, ActionEvent.CTRL_MASK);
                addItem(music, "Move track...", KeyEvent.VK_M, ActionEvent.CTRL_MASK);
-               edit.addSeparator();
+               music.addSeparator();
                addItem(music, "Insert measure...");
                addItem(music, "Delete measure...");
-               edit.addSeparator();
+               music.addSeparator();
                addItem(music, "Set time signature...");
                addItem(music, "Set tempo...");
                addItem(music, "Scale velocity...");
@@ -213,13 +213,9 @@ public class MooMenu extends JMenuBar implements ActionListener {
                        seq.deleteTrack(seq.getTracks()[NUMBER]);
                        */
                } else if (command == "Copy track...") {
-               
                        MooDialog what = new MooDialog(MooDialog.COPY_TRACK);
-                       
                } else if (command == "Move track...") {
-               
                        MooDialog what = new MooDialog(MooDialog.MOVE_TRACK);
-
                } else if (command == "Insert measure...") {
                
                } else if (command == "Delete measure...") {
@@ -233,9 +229,7 @@ public class MooMenu extends JMenuBar implements ActionListener {
                } else if (command == "Transpose...") {
                
                } else if (command == "Contents") {
-       
-                       JOptionPane.showMessageDialog(this, "här kommer contents komma");
-               
+                       MooDialog contents = new MooDialog(MooDialog.CONTENTS);
                } else if (command == "Getting started") {
                        
                        JOptionPane.showMessageDialog(null, "här kommer getting started komma");
index 3711ef97b85a00458102d09706a403c7e0ccb2dd..8718d89039a619cbc94f351d8cc966fbe7fd89a5 100644 (file)
@@ -21,9 +21,9 @@ x MooSequence         The functional representation of a MIDI sequence. Was to extend J
 x MooTrack     The functional representation of a MIDI track. Was to extend Java's Track class.
 x MooNote      The functional representation of a MIDI note. Was to encompass the two MIDI events that constitute a note: NoteOn and NoteOff.
 
-The second part of the program was the graphical user interface, including all the graphical classes. The main class of the interface was named MooGUI. Since we had decided to use Swing in building the interface, this class was naturally to extend JFrame. Here, all other GUI components were to be created. Most of these components - maintaining different kinds of data, having listeners and requiring different methods for update their content - were to be quite complex, and were therefore given their own classes. Among these are graphical classes that construct the menu, the toolbart, the menu's popup dialogs and the view of the MIDI tracks. All these classes [...].
+The second part of the program was the graphical user interface, including all the graphical classes. The main class of the interface was named MooGUI. Since we had decided to use Swing in building the interface, this class was naturally to extend JFrame. Here, all other GUI components were to be created. Most of these components - maintaining different kinds of data, having listeners and requiring different methods for update their content - were to be quite complex, and were therefore given their own classes. Among these are graphical classes that construct the menu, the toolbar and the application's popup dialogs.
 
-Apart from the strictly graphical classes we decided to make a graphical representation of the functional classes, this to get an better overview of our work [...]. MooView (a graphical representation of MooSequence), MooTrackView and MooTrackTitle (MooTrack), and MooNoteElement (MooNote). Supporting these components, some other graphical classes were needed: MooViewCounter, representing a ruler that visualises the time signature of the MIDI file; MooTrackTitle, handling the properties of a track; and MooNoteElement, supplying a way of editing the properties of a note.
+Apart from the general GUI components, graphical representations of the functional classes were needed. MooView (a graphical representation of MooSequence), MooTrackView and MooTrackTitle (MooTrack), and MooNoteElement (MooNote) were therefore added. Supporting these components, some other graphical classes were needed: MooViewCounter, representing a ruler that visualises the time signature of the MIDI file; MooTrackTitle, handling the properties of a track; as well as MooNoteElement and MooNoteProp, supplying a way of editing the properties of a note.
 
 We put the application's design document together very quickly, perhaps a bit too quickly. We were not entirely certain of how the Java MIDI package worked. As our work with the project progressed, we were forced to reevaluate some of these design decisions and change the system design (see section [Major Decissions]). On the other hand, our interface design has barely needed any changes.
 ------------------------------
@@ -42,6 +42,9 @@ Implementing the strictly graphical classes has at some points been both tricky,
 In retrospect it maybe would have been better if we chose to work only with the Java AWT library (see section [Problems]).
 ------------------------------
 2.5 Testing
+When it comes to testing, we have not really 
+In most cases, it doesn't make sense to test the graphical container without its child components. The classes MooGUI, MooView and MooTrackView were all concerned by this.
+
 See section [Implemention and Problems]
 ------------------------------
 2.6 Major Decisions
@@ -55,7 +58,7 @@ x MooDialog           A dialog generator class for all the application's dialogs.
 x MooInstrumentList    A combo box with the 128 General MIDI instruments.
 x MooKeyboard          A keyboard listener emulating a synthesizer.
 
-One class, MooStatus, was also removed. It was reduced to a JLabel with a single method and was therefore merged inte the main GUI class.
+Two classes, MooStatus and MooNoteProp, were also removed. The status bar was reduced to a JLabel with a single method and was therefore merged inte the main GUI class. The note properties dialog was inserted into the new MooDialog class.
 ------------------------------
 2.7 Problems
 Of all the problems we have come across in our work with Moosique, only one persisted and was until very recently unresolved. As always when working with Java, we were aware that the visualisation performance leaves more to be desired. But we did not expect the extremely low performance the program displayed. During playback, a thread updates the view port of the main scroll pane (MooView). However, the update delay on low-end hardware exceeded one second. This obviously made the GUI unresponsive, but also affected synthesizer playback performance. In order for the application to work properly, this delay must at the very least fall below the time it takes the synthesizer to play a sixteenth note. In a sequence of standard tempo, 120 beats per minute, this would mean 1/8 of a second.