From cd7d6166d73969c1c811ac7153cc6eee59a6a685 Mon Sep 17 00:00:00 2001 From: Einar Pehrson Date: Sun, 11 May 2003 00:53:02 +0000 Subject: [PATCH] no message --- MooGUI.java | 63 +++++++++++++++++++++++++--------------------- MooMenu.java | 11 +++++--- MooToolbar.java | 14 +++++------ MooTrackTitle.java | 7 +++--- MooTrackView.java | 6 +++++ MooView.java | 63 ++++++++++++++++++++++++++++++++++++++++------ Moosique.java | 8 ++++-- To Do.txt | 25 ++++++++++++------ 8 files changed, 137 insertions(+), 60 deletions(-) diff --git a/MooGUI.java b/MooGUI.java index 7bcd6dd..97b4ad0 100644 --- a/MooGUI.java +++ b/MooGUI.java @@ -6,19 +6,18 @@ import java.awt.event.*; /** * Moosique's graphical user interface. * - * @author Mikael Andreen + * @author Einar Pehrson */ public class MooGUI extends JFrame { private Sequence seq; - + private MooMenu menu; private MooToolbar toolbar; - private JPanel trackPanel; - private MooTrackView[] trackViews; + private MooView view; private JLabel statusBar; - - public static Font standardFont = new Font("Helvetica", Font.PLAIN, 10); + public static final Font FONT = new Font("Helvetica", Font.PLAIN, 10); + public static final Color bgColor = new Color(192, 224, 255); /** * Creates the GUI. @@ -30,23 +29,33 @@ public class MooGUI extends JFrame { Container pane = getContentPane(); pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS)); - + // Adds menu bar. - setJMenuBar(new MooMenu()); + menu = new MooMenu(); + setJMenuBar(menu); // Adds toolbar. toolbar = new MooToolbar(); pane.add(toolbar, BorderLayout.NORTH); - // Adds tracks. - trackPanel = new JPanel(true); - createTrackViews(); - pane.add(trackPanel, BorderLayout.CENTER); + // Adds main view. + view = new MooView(seq.getTracks()); + pane.add(view, BorderLayout.CENTER); // Adds status bar. statusBar = new JLabel("Welcome to Moosique!", JLabel.CENTER); + statusBar.setFont(FONT); pane.add(statusBar, BorderLayout.SOUTH); + // Brings on the colors! + setBackground(pane); + setBackground(menu); + setBackground(toolbar); + setBackground(view); + statusBar.setBackground(bgColor); + view.setBackground(bgColor); + + // Configures window. addWindowListener(new MooGUICloser()); pack(); Dimension bounds = Toolkit.getDefaultToolkit().getScreenSize(); @@ -57,6 +66,15 @@ public class MooGUI extends JFrame { setVisible(true); show(); } + + private void setBackground(Container c) { + c.setBackground(bgColor); + Component[] comps = c.getComponents(); + System.out.println(comps.length); + for (int i = 0; i < comps.length; i++) { + comps[i].setBackground(bgColor); + } + } /** * Changes the sequence of the GUI. @@ -64,7 +82,7 @@ public class MooGUI extends JFrame { */ public void setSequence(Sequence sequence) { seq = sequence; - createTrackViews(); + view.update(seq.getTracks()); } /** @@ -75,22 +93,9 @@ public class MooGUI extends JFrame { statusBar.setText(text); } - /** - * Fills the track panel with track views for all tracks in the current sequence. - */ - private void createTrackViews() { - trackPanel.removeAll(); - Track[] tracks = seq.getTracks(); - trackPanel.setLayout(new GridLayout(1, tracks.length)); - trackViews = new MooTrackView[tracks.length]; - for (int i = 0; i < tracks.length; i++) { - trackViews[i] = new MooTrackView(tracks[i]); - trackPanel.add(new MooTrackView(tracks[i])); - } - trackPanel.validate(); - } - class MooGUICloser extends WindowAdapter { - public void windowClosing(WindowEvent e) {Moosique.quit();} + public void windowClosing(WindowEvent e) { + Moosique.quit(); + } } } \ No newline at end of file diff --git a/MooMenu.java b/MooMenu.java index 7a0785b..2403a37 100644 --- a/MooMenu.java +++ b/MooMenu.java @@ -1,3 +1,4 @@ +import javax.sound.midi.*; import javax.swing.*; import javax.swing.filechooser.*; import java.awt.event.*; @@ -120,6 +121,7 @@ public class MooMenu extends JMenuBar implements ActionListener { public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); + Sequence seq; if(command == "New") { Moosique.clearSequence(); @@ -171,9 +173,12 @@ public class MooMenu extends JMenuBar implements ActionListener { } else if (command == "Jump...") { } else if (command == "Add track...") { - + Moosique.getSequence().createTrack(); } else if (command == "Delete track...") { - + /* Let the user select a track from a list. + seq = Moosique.getSequence(); + seq.deleteTrack(seq.getTracks()[NUMBER]); + */ } else if (command == "Copy track...") { } else if (command == "Move track...") { @@ -203,7 +208,7 @@ public class MooMenu extends JMenuBar implements ActionListener { JOptionPane.showMessageDialog(null, "här kommer about att komma"); } } - + class MidiFileFilter extends javax.swing.filechooser.FileFilter { public boolean accept(File f) { if(f != null) { diff --git a/MooToolbar.java b/MooToolbar.java index 2a31842..c579aa8 100644 --- a/MooToolbar.java +++ b/MooToolbar.java @@ -20,22 +20,22 @@ public class MooToolbar extends JToolBar { */ public MooToolbar() { + setFloatable(false); mouseAdapter = new MooMouseAdapter(); + // Creates playback buttons rewind = createButton("images/rewind.gif", "Rewind"); add(rewind); - playpause = createButton("images/play.gif", "Play"); add(playpause); playIcon = new ImageIcon("images/play.gif"); pauseIcon = new ImageIcon("images/pause.gif"); - stop = createButton("images/stop.gif", "Stop"); add(stop); - fastforward = createButton("images/forward.gif", "Fast forward"); add(fastforward); + // Creates progress indicator JPanel progIndPanel = new JPanel(); progIndPanel.setBorder(BorderFactory.createLineBorder(Color.black)); progIndPanel.setMaximumSize(new Dimension(100,22)); @@ -43,9 +43,9 @@ public class MooToolbar extends JToolBar { measure = createLabel("Mrs",10); beats = createLabel("Beat",10); ticks = createLabel("Tick",10); - measurevalue = createLabel("1", 12); - beatsvalue = createLabel("1",12); - ticksvalue = createLabel("1",12); + measurevalue = createLabel("1", 16); + beatsvalue = createLabel("1",16); + ticksvalue = createLabel("1",16); progIndPanel.add(measure); progIndPanel.add(beats); progIndPanel.add(ticks); @@ -75,7 +75,7 @@ public class MooToolbar extends JToolBar { */ private JLabel createLabel(String title, int fontSize){ JLabel value = new JLabel(title,JLabel.CENTER); - value.setFont(new Font("Times New Roman", Font.BOLD, fontSize)); + value.setFont(new Font("Times New Roman", Font.PLAIN, fontSize)); return value; } diff --git a/MooTrackTitle.java b/MooTrackTitle.java index 0c04337..b32479f 100644 --- a/MooTrackTitle.java +++ b/MooTrackTitle.java @@ -24,6 +24,7 @@ public class MooTrackTitle extends JPanel { setLayout(new GridLayout(4,1)); title = new JTextField(); // JTextField(String text, int columns) + title.setFont(Moosique.getGUI().FONT); title.addFocusListener(new TitleFocusListener()); add(title); @@ -34,7 +35,7 @@ public class MooTrackTitle extends JPanel { checkboxes.setLayout(new GridLayout(1,3)); channel = new JComboBox(); - channel.setFont(new Font("Helvetica", Font.PLAIN, 10)); + channel.setFont(Moosique.getGUI().FONT); for (int i = 1; i <= 16; i++) channel.addItem(new Integer(i)); channel.addItemListener(new ItemListener(){ @@ -48,7 +49,7 @@ public class MooTrackTitle extends JPanel { mute = new JCheckBox("Mute"); - mute.setFont(new Font("Helvetica", Font.PLAIN, 10)); + mute.setFont(Moosique.getGUI().FONT); mute.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent event){ //setMute @@ -57,7 +58,7 @@ public class MooTrackTitle extends JPanel { checkboxes.add(mute); solo = new JCheckBox("Solo"); - solo.setFont(new Font("Helvetica", Font.PLAIN, 10)); + solo.setFont(Moosique.getGUI().FONT); solo.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent event){ //setSolo diff --git a/MooTrackView.java b/MooTrackView.java index 1e59ba4..ccaa105 100644 --- a/MooTrackView.java +++ b/MooTrackView.java @@ -12,6 +12,7 @@ import javax.sound.midi.*; public class MooTrackView extends JPanel implements ActionListener { + private Track track; private MooTrackTitle title; private NoteArea notes; private Rectangle box; @@ -19,6 +20,7 @@ public class MooTrackView extends JPanel implements ActionListener { private JMenuItem menuItem; public MooTrackView (Track track) { + this.track = track; setPreferredSize(new Dimension(200, 200)); setLayout(new BorderLayout()); this.setBorder(BorderFactory.createLineBorder(Color.black)); @@ -45,6 +47,10 @@ public class MooTrackView extends JPanel implements ActionListener { public void actionPerformed(ActionEvent e) {} + public Track getTrack() { + return track; + } + class NoteArea extends JPanel { public void RectanglePanel() { setPreferredSize(new Dimension(20, 20)); diff --git a/MooView.java b/MooView.java index 1cdbee8..620478c 100644 --- a/MooView.java +++ b/MooView.java @@ -1,18 +1,65 @@ +import javax.sound.midi.*; import javax.swing.*; +import java.awt.*; +import java.awt.event.*; /** + * The main view, the container of the track views. * - * - * @author Andersson, Andreen, Lanneskog, Pehrson - * @version 1 + * @author Einar Pehrson */ - -public class MooView { + +public class MooView extends JScrollPane { + + private Track[] tracks; + private MooTrackView[] trackViews; + private JPanel trackPanel; + + /** + * Creates the main view + */ + public MooView(Track[] tracks) { + super(VERTICAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED); + + this.tracks = tracks; + + trackPanel = new JPanel(new GridLayout(1,3), true); + createTrackViews(); + setViewportView(trackPanel); + } /** - * Creates + * Fills the track panel with track views for all tracks in the current sequence. */ - public MooView () { + private void createTrackViews() { + trackPanel.removeAll(); + ((GridLayout)trackPanel.getLayout()).setColumns(tracks.length); + trackViews = new MooTrackView[tracks.length]; + for (int i = 0; i < tracks.length; i++) { + trackViews[i] = new MooTrackView(tracks[i]); + trackPanel.add(new MooTrackView(tracks[i])); + } + trackPanel.validate(); + } + + public void update(Track[] tracks) { + this.tracks = tracks; + createTrackViews(); + } + /** + * Creates a view for the given track and adds it to the main view. + * @param track the track for which to add a view + */ + public void addTrackView(Track track) { + + } + + /** + * Removes the view for the given track. + * @param track the track for which to remove the view + */ + public void removeTrackView(Track track) { + } -} +} \ No newline at end of file diff --git a/Moosique.java b/Moosique.java index 9a19a53..13d7ce6 100644 --- a/Moosique.java +++ b/Moosique.java @@ -56,8 +56,12 @@ public class Moosique { //If a filename is given as the command-line argument, attempts to load a sequence from the file. if (fileArg != null) { System.out.print("Loading MIDI sequence from " + fileArg + "..."); - if (!load(fileArg)) clearSequence(); - System.out.println("Done"); + if (!load(fileArg)) { + System.out.println("Failed"); + clearSequence(); + } else { + System.out.println("Done"); + } } else { // Otherwise creates a new empty one. clearSequence(); diff --git a/To Do.txt b/To Do.txt index 9edff84..187541f 100644 --- a/To Do.txt +++ b/To Do.txt @@ -31,6 +31,22 @@ VIKTIGT! Implementera playfunktionens beteende. N x Fixa en progress indicator till filladdningen om den tänker ta så lång tid. +x Scrollningen?!? Horisontell behövs på både MooView och MooTrackView, men vertikal bara på MooView. Hur göra? +x Får Moosique vara statisk? Fult? + + +MIDI Messages + +FF 58 Time signature: [0] / [1], [2] MIDI clocks per metronome tick, [3] / 32 per 24 MIDI clocks +FF 51 Tempo +FF 03 Track Name String name = new String(getData()); +C0 Program change int pc = getData1(); + + +Sequence + private ShortMessage timeSignature, tempo; +Track + private ShortMessage trackName, programChange; MooMenu @@ -72,10 +88,6 @@ MooNote / MootrackView / MooNoteElement MooTrackTitle - * Behöver vi verkligen ha titel för tracks?? Tycker att TrackTitle tar upp mycket plats som det är.. - - - * Kanalinställning Hämta från det första Event i ett spår. @@ -86,9 +98,6 @@ MooTrackTitle boolean getTrackSolo(int track) Obtains the current solo state for a track. void setTrackMute(int track, boolean mute) Sets the mute state for a track. void setTrackSolo(int track, boolean solo) Sets the solo state for a track. - - * För att kunna använda dessa funktioner behöver vi TrackTitle veta - vilken int track den ska arbeta mot.. Skicka in som parameter till konstruktorn? När det gäller kanalerna velar jag lite. Antingen gör jag en mappningsmatris i Moosique som man får läsa och skriva ifrån (vilket blir FULT!), eller så tar man allt direkt genom @@ -131,4 +140,4 @@ Moosique * getPosition och setPosition - kvar? - + \ No newline at end of file -- 2.39.2