|
@@ -9,11 +9,9 @@ import javax.swing.ImageIcon;
|
|
|
public class Controls extends JPanel implements Observer
|
|
|
{
|
|
|
private Model model;
|
|
|
- private playSlider playback;
|
|
|
- private JButton play;
|
|
|
- private JButton rewind;
|
|
|
- private JButton reset;
|
|
|
- private JButton clear;
|
|
|
+ private starSlider rating;
|
|
|
+ private JButton grid;
|
|
|
+ private JButton list;
|
|
|
|
|
|
// Bob the Builder this shit
|
|
|
public Controls(Model model)
|
|
@@ -21,91 +19,48 @@ public class Controls extends JPanel implements Observer
|
|
|
// Hook up this observer so that it will be notified when the model
|
|
|
// changes.
|
|
|
this.model = model;
|
|
|
+ this.setBackground(Color.cyan);
|
|
|
this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
|
|
|
this.setPreferredSize(new Dimension(1280,75));
|
|
|
this.setMinimumSize(new Dimension(320, 75));
|
|
|
- this.play = new JButton("Play");
|
|
|
- play.addActionListener(new ActionListener()
|
|
|
+
|
|
|
+ this.grid = new JButton("Grid");
|
|
|
+ grid.addActionListener(new ActionListener()
|
|
|
{
|
|
|
public void actionPerformed(ActionEvent e)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
});
|
|
|
- this.rewind = new JButton("Rewind");
|
|
|
- rewind.addActionListener(new ActionListener()
|
|
|
+
|
|
|
+ this.list = new JButton("List");
|
|
|
+ list.addActionListener(new ActionListener()
|
|
|
{
|
|
|
public void actionPerformed(ActionEvent e)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
});
|
|
|
- this.playback = new playSlider(0, 0, 0);
|
|
|
- playback.addChangeListener(new ChangeListener()
|
|
|
+
|
|
|
+ this.rating = new starSlider(0, 5, 0);
|
|
|
+ rating.addChangeListener(new ChangeListener()
|
|
|
{
|
|
|
public void stateChanged(ChangeEvent e)
|
|
|
{
|
|
|
- if (!playback.getSettingLen())
|
|
|
- {
|
|
|
- }
|
|
|
+ model.changeFilter(rating.getValue());
|
|
|
}
|
|
|
});
|
|
|
- this.playback.setPreferredSize(new Dimension(280, 75));
|
|
|
- this.reset = new JButton("End");
|
|
|
- reset.addActionListener(new ActionListener()
|
|
|
- {
|
|
|
- public void actionPerformed(ActionEvent e)
|
|
|
- {
|
|
|
- //playback.setValue(playback.getMaximum());
|
|
|
- }
|
|
|
- });
|
|
|
- this.clear = new JButton("Start");
|
|
|
- clear.addActionListener(new ActionListener()
|
|
|
- {
|
|
|
- public void actionPerformed(ActionEvent e)
|
|
|
- {
|
|
|
- //playback.setValue(playback.getMinimum());
|
|
|
- }
|
|
|
- });
|
|
|
- this.add(play);
|
|
|
- this.add(rewind);
|
|
|
- this.add(playback);
|
|
|
- this.add(clear);
|
|
|
- this.add(reset);
|
|
|
+ this.rating.setPreferredSize(new Dimension(280, 75));
|
|
|
+
|
|
|
+ this.add(grid);
|
|
|
+ this.add(list);
|
|
|
+ this.add(rating);
|
|
|
model.addObserver(this);
|
|
|
}
|
|
|
|
|
|
public void update(Object observable)
|
|
|
{
|
|
|
- int len = 0;
|
|
|
- if (len > 0)
|
|
|
- {
|
|
|
- playback.toggleSettingLen();
|
|
|
- playback.setMaximum(len);
|
|
|
- playback.toggleSettingLen();
|
|
|
- }
|
|
|
revalidate();
|
|
|
repaint();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-class playSlider extends JSlider
|
|
|
-{
|
|
|
- private boolean settingLen;
|
|
|
-
|
|
|
- public playSlider(int min, int max, int val)
|
|
|
- {
|
|
|
- super(min, max, val);
|
|
|
- this.settingLen = false;
|
|
|
- }
|
|
|
-
|
|
|
- public void toggleSettingLen()
|
|
|
- {
|
|
|
- this.settingLen = !settingLen;
|
|
|
- }
|
|
|
-
|
|
|
- public boolean getSettingLen()
|
|
|
- {
|
|
|
- return settingLen;
|
|
|
- }
|
|
|
-}
|