From 2236a670e9f9c0a83c97b9cd4ae8ffaa0a051519 Mon Sep 17 00:00:00 2001 From: Einar Pehrson Date: Fri, 16 May 2003 12:37:17 +0000 Subject: [PATCH] Fixed the scroll mode. Major performance issue. Made empty tracks not be drawn. --- MooGUI.java | 17 ----------------- MooView.java | 17 +++++++++++++---- Moosique.java | 26 +++++++++++++++++++++++--- To Do.txt | 2 -- 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/MooGUI.java b/MooGUI.java index 78105be..71b1493 100644 --- a/MooGUI.java +++ b/MooGUI.java @@ -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) { diff --git a/MooView.java b/MooView.java index 5e25e02..4ce6a82 100644 --- a/MooView.java +++ b/MooView.java @@ -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(); } diff --git a/Moosique.java b/Moosique.java index 7eafb6c..c513364 100644 --- a/Moosique.java +++ b/Moosique.java @@ -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() { diff --git a/To Do.txt b/To Do.txt index 5e8f4ae..1a6bc85 100644 --- 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 -- 2.39.2