]> ruin.nu Git - moosique.git/commitdiff
Fixed the scroll mode. Major performance issue.
authorEinar Pehrson <einarp@itstud.chalmers.se>
Fri, 16 May 2003 12:37:17 +0000 (12:37 +0000)
committerEinar Pehrson <einarp@itstud.chalmers.se>
Fri, 16 May 2003 12:37:17 +0000 (12:37 +0000)
Made empty tracks not be drawn.

MooGUI.java
MooView.java
Moosique.java
To Do.txt

index 78105be707d229b2743fae15323b1bebe879e6a8..71b14937a1f8f1a0e610a08b085a43727df50ff5 100644 (file)
@@ -18,7 +18,6 @@ public class MooGUI extends JFrame {
        private MooView view;
        private JLabel statusBar;
        private java.util.Timer timer;
-       private boolean drawEmptyTracks = false;
        public static final int statusResetDelay = 3000;
        public static final Font FONT = new Font("Helvetica", Font.PLAIN, 10);
        public static final Color bgColor = new Color(192, 224, 255);
@@ -140,22 +139,6 @@ public class MooGUI extends JFrame {
                toolbar.updateProgInd(tickPosition);
        }
 
-       /** 
-        * Shows the given message in the status bar.
-        * @param text  the message to show
-        */
-       public boolean drawEmptyTracks() {
-               return drawEmptyTracks;
-       }
-
-       /** 
-        * Shows the given message in the status bar.
-        * @param text  the message to show
-        */
-       public void setDrawEmptyTracks(boolean state) {
-               drawEmptyTracks = state;
-       }
-
        private Action createOctaveAction(final int octave) {
                Action octaveAction = new AbstractAction() {
                        public void actionPerformed(ActionEvent ae) {
index 5e25e02b46d046e6fa655f7eafb2a1a181c86abd..4ce6a8288987059901e29a52a98235bf275cd194 100644 (file)
@@ -24,6 +24,7 @@ public class MooView extends JScrollPane {
                super(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
                trackPanel = new JPanel(new GridLayout(1,3), true);
                setViewportView(trackPanel);
+               getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE);
 
                titlePanel = new JPanel(new GridLayout(1,3),true);
                JViewport columnHeader = new JViewport();
@@ -64,11 +65,19 @@ public class MooView extends JScrollPane {
                        progressDialog.setVisible(true);
        
                        // Starts filling the track panel with track views, while updating the progress bar.
-                       trackPanel.setLayout(new GridLayout(1,numberOfTracks));
+                       GridLayout gL = new GridLayout(1,numberOfTracks);
+                       trackPanel.setLayout(gL);
                        for (int i = 1; i < tracks.length; i++) {
-                               trackPanel.add(new MooTrackView(tracks[i]));
-                               titlePanel.add(new MooTrackTitle(tracks[i],i));
-                               progressBar.setValue(i);
+                               if (Moosique.shouldBeDrawn(tracks[i])) {
+                                       System.out.println("Draws track " + i);
+                                       trackPanel.add(new MooTrackView(tracks[i]));
+                                       titlePanel.add(new MooTrackTitle(tracks[i],i));
+                                       progressBar.setValue(i);
+                               } else {
+                                       System.out.println("Doesn't draw track " + i);
+                                       gL.setColumns(--numberOfTracks);
+                                       trackPanel.setLayout(gL);
+                               }
                        }
                        progressDialog.dispose();
                }
index 7eafb6c6ab17fd7852996930e4c4d64aec916819..c51336423b7d8297a27032b0c32d834429b44e13 100644 (file)
@@ -24,7 +24,7 @@ public class Moosique {
 
        private static String filename, fileArg;
        private static long editPosition;
-       private static boolean makeGUI = true, isEdited;
+       private static boolean makeGUI = true, isEdited = false, drawEmptyTracks = false;
        private static Thread player;
        public static final int DEFAULT_RESOLUTION = 96, DEFAULT_TRACKS = 4;
 
@@ -309,6 +309,24 @@ public class Moosique {
                editPosition += ticks;
        }
 
+       /** 
+        * Shows the given message in the status bar.
+        * @param text  the message to show
+        */
+       public static boolean shouldBeDrawn(Track track) {
+               if (drawEmptyTracks) return true;
+               else return (!emptyTracks.contains(track));
+       }
+
+
+       /** 
+        * Shows the given message in the status bar.
+        * @param text  the message to show
+        */
+       public static void setDrawEmptyTracks(boolean state) {
+               drawEmptyTracks = state;
+       }
+
        /** 
         * Loads the MooSequence in the given file.
         * @param filename      the filename to use
@@ -362,9 +380,11 @@ public class Moosique {
                        noteOffs.trimToSize();
                        boolean isEmpty = (noteOns.size() == 0);
                        String text = "Track " + i + " has " + noteOns.size() + "/" + noteOffs.size() + "/" + tracks[i].size();
-                       if (isEmpty) text += " and will not be removed.";
+                       if (isEmpty) {
+                               text += " and will be removed.";
+                               emptyTracks.add(tracks[i]);
+                       }
                        System.out.println(text);
-                       emptyTracks.add(tracks[i]);
                        
                        // Sorts the note lists by tick position.
                        Comparator c = new Comparator() {
index 5e8f4ae21fde2781e060df9c15dcacf2218fe1e9..1a6bc857398b10fc11ac702e351e43e7e2fe9f3a 100644 (file)
--- a/To Do.txt
+++ b/To Do.txt
@@ -4,8 +4,6 @@ Diverse
 
 x VIKTIGT!!! HUR LÄGGA TILL NOTER?!? 
 
-x Varför funkar inte lyssnarna på MooTrackView?!?
-
 x Spara konfiguration?
        Arbetskatalog
        Fem senast öppnade filerna