]> ruin.nu Git - moosique.git/blobdiff - MooTrackView.java
Changed window size and TrackView generation. Updated Toolbar listeners, and cleaned...
[moosique.git] / MooTrackView.java
index bcbfc09e1e2d8e5464c745d40cff1a6327af62a1..780e3c017521c0f3015e2fa91c819ad237502e8f 100644 (file)
@@ -17,61 +17,47 @@ public class MooTrackView extends JPanel implements ActionListener {
        private Rectangle box;
        private JPopupMenu popup;
        private JMenuItem menuItem;
-       private String newline = "\n";
+       
+       private static final int NOTEVIEW_HEIGHT = 200;
        
        public MooTrackView (Track track) {
                setLayout(new BorderLayout());
                this.setBorder(BorderFactory.createLineBorder(Color.black));
-               add(trackTitle(), BorderLayout.NORTH);
-               add(noteView(), BorderLayout.CENTER);
-       }
-       
-       private JPanel trackTitle () {
+
                title = new MooTrackTitle();
-               title.setPreferredSize(new Dimension(PANEL_WIDTH, TITLE_HEIGHT));
                title.setBorder(BorderFactory.createLineBorder(Color.black));
-               return title;
-       }
+               add(title, BorderLayout.NORTH);
 
-       private JPanel noteView () {
                notes = new NoteArea(); 
                notes.setBackground(Color.white);
                notes.setBorder(BorderFactory.createLineBorder(Color.black));
-               
+
                popup = new JPopupMenu();
-        menuItem = new JMenuItem("Add...");
-        menuItem.addActionListener(this);
-        popup.add(menuItem);
-        menuItem = new JMenuItem("Preferences...");
-        menuItem.addActionListener(this);
-        popup.add(menuItem);
+               menuItem = new JMenuItem("Add...");
+               menuItem.addActionListener(this);
+               popup.add(menuItem);
+               menuItem = new JMenuItem("Preferences...");
+               menuItem.addActionListener(this);
+               popup.add(menuItem);
 
-        MouseListener popupListener = new PopupListener();
-        notes.addMouseListener(popupListener);
-               
-               return notes;           
+               notes.addMouseListener(new PopupListener());
+               add(notes, BorderLayout.CENTER);
        }
        
-       public void actionPerformed(ActionEvent e) {
-        JMenuItem source = (JMenuItem)(e.getSource());
-        String s = "Action event detected."
-                   + newline
-                   + "    Event source: " + source.getText();
-     }
+       public void actionPerformed(ActionEvent e) {}
     
        class NoteArea extends JPanel {
                public void RectanglePanel() {
                        setPreferredSize(new Dimension(20, 20));
-                       
                }
                
                public void paintComponent(Graphics g) {
                        super.paintComponent(g);
                        Graphics2D g2 = (Graphics2D)g;
-                       for (int c=0;c<1000;c=c+20) {
+                       for (int c = 0; c < 1000; c += 20) {
                                int r=0;
-                               for (r=0;r<200;r=r+20) {
-                                       box = new Rectangle(r,c,20,20);
+                               for (r = 0; r < 200; r += 20) {
+                                       box = new Rectangle(r, c, 20, 20);
                                        g2.setColor(Color.gray);
                                        g2.draw(box);
                                }
@@ -80,23 +66,18 @@ public class MooTrackView extends JPanel implements ActionListener {
        }
        
        class PopupListener extends MouseAdapter {
-        public void mousePressed(MouseEvent e) {
-            maybeShowPopup(e);
-        }
-
-        public void mouseReleased(MouseEvent e) {
-            maybeShowPopup(e);
-        }
-
-        private void maybeShowPopup(MouseEvent e) {
-            if (e.isPopupTrigger()) {
-                popup.show(e.getComponent(),
-                           e.getX(), e.getY());
-            }
-        }
-    }
+               public void mousePressed(MouseEvent e) {
+                       maybeShowPopup(e);
+               }
        
-       private static final int PANEL_WIDTH = 60;
-       private static final int TITLE_HEIGHT = 55;
-       private static final int NOTEVIEW_HEIGHT = 200;
-}
+               public void mouseReleased(MouseEvent e) {
+                       maybeShowPopup(e);
+               }
+       
+               private void maybeShowPopup(MouseEvent e) {
+                       if (e.isPopupTrigger()) {
+                               popup.show(e.getComponent(), e.getX(), e.getY());
+                       }
+               }
+       }
+}
\ No newline at end of file