Basis gelegd voor PanelDevice, todo:
- knop icons cachen om echte togglers mogelijk te maken - rij if...elseif equals statements met een ButtonList loop korter maken? - sliders afhandelen - feedback terugsturen - naamgeving aanpassen
@@ -11,5 +11,6 @@
|
|||||||
<classpathentry kind="lib" path="lib/nativecall-0.4.1.jar"/>
|
<classpathentry kind="lib" path="lib/nativecall-0.4.1.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/nativeloader-200505172341.jar"/>
|
<classpathentry kind="lib" path="lib/nativeloader-200505172341.jar"/>
|
||||||
<classpathentry kind="lib" path="cfg"/>
|
<classpathentry kind="lib" path="cfg"/>
|
||||||
|
<classpathentry kind="lib" path="resource"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
BIN
java/resource/icons/camera.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
java/resource/icons/comment.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
java/resource/icons/connect.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
java/resource/icons/control_eject_blue.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
java/resource/icons/control_end_blue.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
java/resource/icons/control_fastforward_blue.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
java/resource/icons/control_pause_blue.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
java/resource/icons/control_play_blue.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
java/resource/icons/control_rewind_blue.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
java/resource/icons/control_start_blue.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
java/resource/icons/control_stop_blue.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
java/resource/icons/image.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
java/resource/icons/sound_mute.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
@@ -17,6 +17,7 @@ import pm.device.gui.GUIDevice;
|
|||||||
import pm.device.javainput.extreme3d.Extreme3DDevice;
|
import pm.device.javainput.extreme3d.Extreme3DDevice;
|
||||||
import pm.device.javainput.rumblepad.RumblepadDevice;
|
import pm.device.javainput.rumblepad.RumblepadDevice;
|
||||||
import pm.device.jintellitype.JIntellitypeDevice;
|
import pm.device.jintellitype.JIntellitypeDevice;
|
||||||
|
import pm.device.panel.PanelDevice;
|
||||||
import pm.device.player.PlayerDevice;
|
import pm.device.player.PlayerDevice;
|
||||||
import pm.device.text.TextDevice;
|
import pm.device.text.TextDevice;
|
||||||
import pm.device.text.lan.LanTextDevice;
|
import pm.device.text.lan.LanTextDevice;
|
||||||
@@ -51,22 +52,23 @@ public class Main extends EventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void initialise() throws DeviceInitialiseException {
|
public void initialise() throws DeviceInitialiseException {
|
||||||
//add(new JIntellitypeDevice());
|
add(new JIntellitypeDevice());
|
||||||
//add(new PlayerDevice());
|
//add(new PlayerDevice());
|
||||||
//add(new RumblepadDevice());
|
//add(new RumblepadDevice());
|
||||||
//add(new WiimoteDevice());
|
//add(new WiimoteDevice());
|
||||||
//add(new GUIDevice());
|
//add(new GUIDevice());
|
||||||
//add(new TextDevice());
|
//add(new TextDevice());
|
||||||
|
add(new PanelDevice());
|
||||||
//add(new LanTextDevice());
|
//add(new LanTextDevice());
|
||||||
//add(new Extreme3DDevice());
|
//add(new Extreme3DDevice());
|
||||||
startDevices();
|
startDevices();
|
||||||
|
|
||||||
//add(new ExampleApplication());
|
//add(new ExampleApplication());
|
||||||
//add(new WMPApplication());
|
//add(new WMPApplication());
|
||||||
add(new GomPlayerApplication());
|
//add(new GomPlayerApplication());
|
||||||
//add(new WinampApplication());
|
//add(new WinampApplication());
|
||||||
//add(new iTunesApplication());
|
add(new iTunesApplication());
|
||||||
add(new VLCApplication());
|
//add(new VLCApplication());
|
||||||
//add(new MPCApplication());
|
//add(new MPCApplication());
|
||||||
startApplications();
|
startApplications();
|
||||||
}
|
}
|
||||||
|
|||||||
33
java/src/pm/device/panel/HoldButton.java
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package pm.device.panel;
|
||||||
|
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.MouseListener;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
|
||||||
|
public class HoldButton extends JButton implements MouseListener {
|
||||||
|
protected static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
protected HoldButtonListener holdButtonListener;
|
||||||
|
|
||||||
|
public HoldButton(HoldButtonListener holdButtonListener) {
|
||||||
|
this.holdButtonListener = holdButtonListener;
|
||||||
|
addMouseListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mousePressed(MouseEvent event) {
|
||||||
|
if (event.getButton() == MouseEvent.BUTTON1) {
|
||||||
|
holdButtonListener.buttonPressed(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mouseReleased(MouseEvent event) {
|
||||||
|
if (event.getButton() == MouseEvent.BUTTON1) {
|
||||||
|
holdButtonListener.buttonReleased(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mouseClicked(MouseEvent event) {}
|
||||||
|
public void mouseEntered(MouseEvent event) {}
|
||||||
|
public void mouseExited(MouseEvent event) {}
|
||||||
|
}
|
||||||
6
java/src/pm/device/panel/HoldButtonListener.java
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
package pm.device.panel;
|
||||||
|
|
||||||
|
public interface HoldButtonListener {
|
||||||
|
public void buttonPressed(HoldButton button);
|
||||||
|
public void buttonReleased(HoldButton button);
|
||||||
|
}
|
||||||
216
java/src/pm/device/panel/Panel.java
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
package pm.device.panel;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
import java.awt.GridLayout;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JProgressBar;
|
||||||
|
import javax.swing.JSlider;
|
||||||
|
import javax.swing.event.ChangeEvent;
|
||||||
|
import javax.swing.event.ChangeListener;
|
||||||
|
|
||||||
|
import pm.Device;
|
||||||
|
import pm.macro.state.Press;
|
||||||
|
|
||||||
|
public class Panel extends JFrame implements ChangeListener, HoldButtonListener {
|
||||||
|
protected static final long serialVersionUID = 1L;
|
||||||
|
protected final static String TITLE = "MIMIS Panel Device";
|
||||||
|
|
||||||
|
protected PanelButtonListener panelButtonListener;
|
||||||
|
protected ClassLoader classLoader;
|
||||||
|
|
||||||
|
protected JLabel timeLabel;
|
||||||
|
protected JLabel chapterLabel;
|
||||||
|
|
||||||
|
protected JProgressBar positionProgressBar;
|
||||||
|
protected JSlider positionSlider;
|
||||||
|
protected JSlider volumeSlider;
|
||||||
|
|
||||||
|
protected JButton previousChapterButton;
|
||||||
|
protected JButton rewindButton;
|
||||||
|
protected JButton stopButton;
|
||||||
|
protected JButton pauseButton;
|
||||||
|
protected JButton playButton;
|
||||||
|
protected JButton fastForwardButton;
|
||||||
|
protected JButton nextChapterButton;
|
||||||
|
protected JButton toggleMuteButton;
|
||||||
|
protected boolean setPositionValue;
|
||||||
|
|
||||||
|
Panel(PanelButtonListener panelButtonListener) {
|
||||||
|
super(TITLE);
|
||||||
|
this.panelButtonListener = panelButtonListener;
|
||||||
|
classLoader = getClass().getClassLoader();
|
||||||
|
createControls();
|
||||||
|
layoutControls();
|
||||||
|
pack();
|
||||||
|
setResizable(false);
|
||||||
|
setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected URL getResource(String name) {
|
||||||
|
return classLoader.getResource(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ImageIcon getImageIcon(String name) {
|
||||||
|
return new ImageIcon(getResource(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected JButton getButton(String name, String text) {
|
||||||
|
JButton button = (JButton) new HoldButton(this);
|
||||||
|
button.setIcon(getImageIcon(name));
|
||||||
|
button.setToolTipText(text);
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void createControls() {
|
||||||
|
timeLabel = new JLabel("hh:mm:ss");
|
||||||
|
chapterLabel = new JLabel("00/00");
|
||||||
|
|
||||||
|
positionProgressBar = new JProgressBar();
|
||||||
|
positionProgressBar.setToolTipText("Time");
|
||||||
|
|
||||||
|
positionSlider = new JSlider();
|
||||||
|
positionSlider.setToolTipText("Position");
|
||||||
|
|
||||||
|
volumeSlider = new JSlider();
|
||||||
|
volumeSlider.setOrientation(JSlider.HORIZONTAL);
|
||||||
|
volumeSlider.setPreferredSize(new Dimension(100, 40));
|
||||||
|
volumeSlider.setToolTipText("Change volume");
|
||||||
|
|
||||||
|
previousChapterButton = getButton("icons/control_start_blue.png", "Go to previous chapter");
|
||||||
|
rewindButton = getButton("icons/control_rewind_blue.png", "Skip back");
|
||||||
|
stopButton = getButton("icons/control_stop_blue.png", "Stop");
|
||||||
|
pauseButton = getButton("icons/control_pause_blue.png", "Play/pause");
|
||||||
|
playButton = getButton("icons/control_play_blue.png", "Play");
|
||||||
|
fastForwardButton = getButton("icons/control_fastforward_blue.png", "Skip forward");
|
||||||
|
nextChapterButton = getButton("icons/control_end_blue.png", "Go to next chapter");
|
||||||
|
toggleMuteButton = getButton("icons/sound_mute.png", "Toggle Mute");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void layoutControls() {
|
||||||
|
setLayout(new BorderLayout());
|
||||||
|
|
||||||
|
JPanel positionPanel = new JPanel();
|
||||||
|
positionPanel.setLayout(new GridLayout(2, 1));
|
||||||
|
positionPanel.add(positionProgressBar);
|
||||||
|
positionPanel.add(positionSlider);
|
||||||
|
|
||||||
|
JPanel topPanel = new JPanel();
|
||||||
|
topPanel.setLayout(new BorderLayout(8, 0));
|
||||||
|
|
||||||
|
topPanel.add(timeLabel, BorderLayout.WEST);
|
||||||
|
topPanel.add(positionPanel, BorderLayout.CENTER);
|
||||||
|
topPanel.add(chapterLabel, BorderLayout.EAST);
|
||||||
|
add(topPanel, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
JPanel bottomPanel = new JPanel();
|
||||||
|
bottomPanel.setLayout(new FlowLayout());
|
||||||
|
|
||||||
|
bottomPanel.add(previousChapterButton);
|
||||||
|
bottomPanel.add(rewindButton);
|
||||||
|
bottomPanel.add(stopButton);
|
||||||
|
bottomPanel.add(pauseButton);
|
||||||
|
bottomPanel.add(playButton);
|
||||||
|
bottomPanel.add(fastForwardButton);
|
||||||
|
bottomPanel.add(nextChapterButton);
|
||||||
|
bottomPanel.add(volumeSlider);
|
||||||
|
bottomPanel.add(toggleMuteButton);
|
||||||
|
|
||||||
|
add(bottomPanel, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
positionSlider.addChangeListener(this);
|
||||||
|
volumeSlider.addChangeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Listeners */
|
||||||
|
public void stateChanged(ChangeEvent event) {
|
||||||
|
Object source = event.getSource();
|
||||||
|
if (positionSlider.equals(source)) {
|
||||||
|
if (!setPositionValue) {
|
||||||
|
float positionValue = (float) positionSlider.getValue() / 100.0f;
|
||||||
|
System.out.println(positionValue);
|
||||||
|
}
|
||||||
|
} else if (volumeSlider.equals(source)) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void buttonPressed(HoldButton button) {
|
||||||
|
if (button.equals(previousChapterButton)) {
|
||||||
|
panelButtonListener.buttonPressed(PanelButton.PREVIOUS_CHAPTER);
|
||||||
|
} else if (button.equals(rewindButton)) {
|
||||||
|
panelButtonListener.buttonPressed(PanelButton.REWIND);
|
||||||
|
} else if (button.equals(stopButton)) {
|
||||||
|
panelButtonListener.buttonPressed(PanelButton.STOP);
|
||||||
|
} else if (button.equals(pauseButton)) {
|
||||||
|
panelButtonListener.buttonPressed(PanelButton.PAUSE);
|
||||||
|
} else if (button.equals(playButton)) {
|
||||||
|
panelButtonListener.buttonPressed(PanelButton.PLAY);
|
||||||
|
} else if (button.equals(fastForwardButton)) {
|
||||||
|
panelButtonListener.buttonPressed(PanelButton.FAST_FORWARD);
|
||||||
|
} else if (button.equals(nextChapterButton)) {
|
||||||
|
panelButtonListener.buttonPressed(PanelButton.NEXT_CHAPTER);
|
||||||
|
} else if (button.equals(toggleMuteButton)) {
|
||||||
|
panelButtonListener.buttonPressed(PanelButton.TOGGLE_MUTE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void buttonReleased(HoldButton button) {
|
||||||
|
if (button.equals(previousChapterButton)) {
|
||||||
|
panelButtonListener.buttonReleased(PanelButton.PREVIOUS_CHAPTER);
|
||||||
|
} else if (button.equals(rewindButton)) {
|
||||||
|
panelButtonListener.buttonReleased(PanelButton.REWIND);
|
||||||
|
} else if (button.equals(stopButton)) {
|
||||||
|
panelButtonListener.buttonReleased(PanelButton.STOP);
|
||||||
|
} else if (button.equals(pauseButton)) {
|
||||||
|
panelButtonListener.buttonReleased(PanelButton.PAUSE);
|
||||||
|
} else if (button.equals(playButton)) {
|
||||||
|
panelButtonListener.buttonReleased(PanelButton.PLAY);
|
||||||
|
} else if (button.equals(fastForwardButton)) {
|
||||||
|
panelButtonListener.buttonReleased(PanelButton.FAST_FORWARD);
|
||||||
|
} else if (button.equals(nextChapterButton)) {
|
||||||
|
panelButtonListener.buttonReleased(PanelButton.NEXT_CHAPTER);
|
||||||
|
} else if (button.equals(toggleMuteButton)) {
|
||||||
|
panelButtonListener.buttonReleased(PanelButton.TOGGLE_MUTE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update */
|
||||||
|
public void updateTime(long millis) {
|
||||||
|
String s = String.format(
|
||||||
|
"%02d:%02d:%02d",
|
||||||
|
TimeUnit.MILLISECONDS.toHours(millis),
|
||||||
|
TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)),
|
||||||
|
TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)));
|
||||||
|
timeLabel.setText(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updatePosition(int value) {
|
||||||
|
positionProgressBar.setValue(value);
|
||||||
|
setPositionValue = true;
|
||||||
|
positionSlider.setValue(value);
|
||||||
|
setPositionValue = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateChapter(int chapter, int chapterCount) {
|
||||||
|
String s = chapterCount != -1 ? (chapter + 1) + "/" + chapterCount
|
||||||
|
: "-";
|
||||||
|
chapterLabel.setText(s);
|
||||||
|
chapterLabel.invalidate();
|
||||||
|
validate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateVolume(int value) {
|
||||||
|
volumeSlider.setValue(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
14
java/src/pm/device/panel/PanelButton.java
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package pm.device.panel;
|
||||||
|
|
||||||
|
import pm.Button;
|
||||||
|
|
||||||
|
public enum PanelButton implements Button {
|
||||||
|
PREVIOUS_CHAPTER,
|
||||||
|
REWIND,
|
||||||
|
STOP,
|
||||||
|
PAUSE,
|
||||||
|
PLAY,
|
||||||
|
FAST_FORWARD,
|
||||||
|
NEXT_CHAPTER,
|
||||||
|
TOGGLE_MUTE;
|
||||||
|
}
|
||||||
6
java/src/pm/device/panel/PanelButtonListener.java
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
package pm.device.panel;
|
||||||
|
|
||||||
|
public interface PanelButtonListener {
|
||||||
|
public void buttonPressed(PanelButton panelButton);
|
||||||
|
public void buttonReleased(PanelButton panelButton);
|
||||||
|
}
|
||||||
32
java/src/pm/device/panel/PanelDevice.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package pm.device.panel;
|
||||||
|
|
||||||
|
import pm.Device;
|
||||||
|
import pm.event.Task;
|
||||||
|
import pm.macro.state.Press;
|
||||||
|
import pm.macro.state.Release;
|
||||||
|
import pm.value.Action;
|
||||||
|
import pm.value.Target;
|
||||||
|
|
||||||
|
public class PanelDevice extends Device implements PanelButtonListener {
|
||||||
|
|
||||||
|
protected Panel panel;
|
||||||
|
|
||||||
|
public void initialise() {
|
||||||
|
panel = new Panel(this);
|
||||||
|
panel.updateTime(12342398);
|
||||||
|
panel.updatePosition(43);
|
||||||
|
add(new Press(PanelButton.PLAY), new Task(Action.PLAY, Target.APPLICATION));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void exit() {
|
||||||
|
panel.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void buttonPressed(PanelButton panelButton) {
|
||||||
|
add(new Press(panelButton));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void buttonReleased(PanelButton panelButton) {
|
||||||
|
add(new Release(panelButton));
|
||||||
|
}
|
||||||
|
}
|
||||||