Commit 742429d147b36a41d70748e33329c49ac3adbb65

Authored by pfrison
1 parent 2b7b8e5c

VRGNYMusicLight beginning

Showing 36 changed files with 579 additions and 0 deletions   Show diff stats
VRGNYMusicLights/Librairies/Linux/i686-unknown-linux-gnu/librxtxParallel.so 0 → 100644
No preview for this file type
VRGNYMusicLights/Librairies/Linux/i686-unknown-linux-gnu/librxtxSerial.so 0 → 100644
No preview for this file type
VRGNYMusicLights/Librairies/Linux/ia64-unkown-linux-gnu/librxtxSerial.so 0 → 100644
No preview for this file type
VRGNYMusicLights/Librairies/Linux/x86_64-unknown-linux-gnu/librxtxSerial.so 0 → 100644
No preview for this file type
VRGNYMusicLights/Librairies/Mac_OS_X/README 0 → 100644
... ... @@ -0,0 +1,4 @@
  1 +Wed Mar 1 12:05:10 MST 2006
  2 +We forgot to update the Mac OS X binary. Previously, it was an old version
  3 +(RXTX-2.1-7pre20). This has now been corrected.
  4 +
... ...
VRGNYMusicLights/Librairies/Mac_OS_X/librxtxSerial.jnilib 0 → 100644
No preview for this file type
VRGNYMusicLights/Librairies/RXTXcomm.jar 0 → 100644
No preview for this file type
VRGNYMusicLights/Librairies/Solaris/sparc-solaris/sparc32-sun-solaris2.8/librxtxSerial-2.1-7.so 0 → 100644
No preview for this file type
VRGNYMusicLights/Librairies/Solaris/sparc-solaris/sparc32-sun-solaris2.8/librxtxSerial.so 0 → 100644
No preview for this file type
VRGNYMusicLights/Librairies/Solaris/sparc-solaris/sparc64-sun-solaris2.8/librxtxSerial-2.1-7.so 0 → 100644
No preview for this file type
VRGNYMusicLights/Librairies/Solaris/sparc-solaris/sparc64-sun-solaris2.8/librxtxSerial.so 0 → 100644
No preview for this file type
VRGNYMusicLights/Librairies/Windows/i368-mingw32/README 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +Wed Mar 1 12:01:05 MST 2006
  2 +rxtxSerial.dll had to be recomopiled to link in missing native methods.
  3 +
... ...
VRGNYMusicLights/Librairies/Windows/i368-mingw32/rxtxParallel.dll 0 → 100644
No preview for this file type
VRGNYMusicLights/Librairies/Windows/i368-mingw32/rxtxSerial.dll 0 → 100644
No preview for this file type
VRGNYMusicLights/RxTx INSTALL GUIDE 0 → 100644
... ... @@ -0,0 +1,57 @@
  1 +Trent Here. I do those ugly brown pages at rxtx.org. Documentation is not
  2 +what I do well :) So please help me when you see problems or something is
  3 +confusing.
  4 +
  5 +For more information provided by end users please visit the rxtx wiki at
  6 +http://rxtx.qbang.org/wiki. This is also where you can help.
  7 +
  8 +Short Install Instructions
  9 +
  10 +Windows
  11 +
  12 +RXTXcomm.jar goes in \jre\lib\ext (under java)
  13 +rxtxSerial.dll goes in \jre\bin
  14 +
  15 +Mac OS X (x86 and ppc) (there is an Installer with the source)
  16 +
  17 +RXTXcomm.jar goes in /Library/Java/Extensions
  18 +librxtxSerial.jnilib goes in /Library/Java/Extensions
  19 +Run fixperm.sh thats in the directory. Fix perms is in the Mac_OS_X
  20 +subdirectory.
  21 +
  22 +Linux (only x86, x86_64, ia64 here but more in the ToyBox)
  23 +
  24 +RXTXcomm.jar goes in /jre/lib/ext (under java)
  25 +librxtxSerial.so goes in /jre/lib/[machine type] (i386 for instance)
  26 +Make sure the user is in group lock or uucp so lockfiles work.
  27 +
  28 +Solaris (sparc only so far)
  29 +
  30 +RXTXcomm.jar goes in /jre/lib/ext (under java)
  31 +librxtxSerial.so goes in /jre/lib/[machine type]
  32 +Make sure the user is in group uucp so lockfiles work.
  33 +
  34 +
  35 +
  36 +
  37 +A person is added to group lock or uucp by editing /etc/groups. Distributions
  38 +have various tools but this works:
  39 +
  40 +lock:x:54: becomes:
  41 +lock:x:53:jarvi,taj
  42 +
  43 +Now jarvi and taj are in group lock.
  44 +
  45 +Also make sure jarvi and taj have read and write permissions on the port.
  46 +
  47 +
  48 +
  49 +
  50 +If there are problems please help each other on the wiki and ask questions
  51 +on the mail-list. User contributed changes will be used here in the next
  52 +release. If you don't like the documentation, you can improve it.
  53 +
  54 +
  55 +--
  56 +Trent Jarvi
  57 +tjarvi@qbang.org
... ...
VRGNYMusicLights/Sources/AnimationPlayer.java 0 → 100644
... ... @@ -0,0 +1,68 @@
  1 +import java.awt.event.ActionEvent;
  2 +import java.awt.event.ActionListener;
  3 +
  4 +import javax.swing.Box;
  5 +import javax.swing.BoxLayout;
  6 +import javax.swing.ImageIcon;
  7 +import javax.swing.JButton;
  8 +import javax.swing.JPanel;
  9 +
  10 +public class AnimationPlayer extends JPanel implements ActionListener {
  11 + private static final long serialVersionUID = 1L;
  12 +
  13 + private JButton backward;
  14 + private JButton stop;
  15 + private JButton play;
  16 + private JButton pause;
  17 + private JButton forward;
  18 +
  19 + public AnimationPlayer() { this(BoxLayout.LINE_AXIS); }
  20 + public AnimationPlayer(int direction) {
  21 + setLayout(new BoxLayout(this, direction));
  22 +
  23 + add(Box.createHorizontalGlue());
  24 +
  25 + // backward button
  26 + backward = new JButton(new ImageIcon(getClass().getResource("/icons/backward.png")));
  27 + backward.addActionListener(this);
  28 + add(backward);
  29 +
  30 + // stop button
  31 + stop = new JButton(new ImageIcon(getClass().getResource("/icons/stop.png")));
  32 + stop.addActionListener(this);
  33 + add(stop);
  34 +
  35 + // play button
  36 + play = new JButton(new ImageIcon(getClass().getResource("/icons/play.png")));
  37 + play.addActionListener(this);
  38 + add(play);
  39 +
  40 + // pause button
  41 + pause = new JButton(new ImageIcon(getClass().getResource("/icons/pause.png")));
  42 + pause.addActionListener(this);
  43 + add(pause);
  44 +
  45 + // forward button
  46 + forward = new JButton(new ImageIcon(getClass().getResource("/icons/forward.png")));
  47 + forward.addActionListener(this);
  48 + add(forward);
  49 +
  50 + add(Box.createHorizontalGlue());
  51 + }
  52 +
  53 + @Override
  54 + public void actionPerformed(ActionEvent e) {
  55 + // TODO player actions
  56 + if(e.getSource() == backward) {
  57 +
  58 + }else if(e.getSource() == stop) {
  59 +
  60 + }else if(e.getSource() == play) {
  61 +
  62 + }else if(e.getSource() == pause) {
  63 +
  64 + }else if(e.getSource() == forward) {
  65 +
  66 + }
  67 + }
  68 +}
... ...
VRGNYMusicLights/Sources/Interface.java 0 → 100644
... ... @@ -0,0 +1,58 @@
  1 +import java.awt.BorderLayout;
  2 +import java.awt.Font;
  3 +import java.awt.event.WindowAdapter;
  4 +import java.awt.event.WindowEvent;
  5 +
  6 +import javax.swing.BoxLayout;
  7 +import javax.swing.JFrame;
  8 +import javax.swing.JLabel;
  9 +import javax.swing.JPanel;
  10 +
  11 +public class Interface extends JFrame{
  12 + private static final long serialVersionUID = 1L;
  13 + private static final Font titleFont = new Font(new JLabel().getFont().getName(), Font.BOLD, 14);
  14 + private static final Font defaultFont = new Font(new JLabel().getFont().getName(), Font.PLAIN, new JLabel().getFont().getSize());
  15 +
  16 + public Interface(final Runnable executeOnClose) {
  17 + super("VRGNYMusicLights");
  18 + //this.actionList = actionList;
  19 + setResizable(false);
  20 + populateWindow();
  21 + pack();
  22 + setLocationRelativeTo(null); // center window
  23 +
  24 + addWindowListener(new WindowAdapter() {
  25 + @Override
  26 + public void windowClosing(WindowEvent e) {
  27 + if(executeOnClose != null)
  28 + executeOnClose.run();
  29 + dispose();
  30 + }
  31 + });
  32 + }
  33 +
  34 + private void populateWindow() {
  35 + JPanel mainPanel = new JPanel(new BorderLayout());
  36 + addPlayPanel(mainPanel);
  37 + add(mainPanel);
  38 + }
  39 +
  40 + private void addPlayPanel(JPanel parent) {
  41 + JPanel playPanel = new JPanel(new BorderLayout());
  42 +
  43 + // title
  44 + JLabel title = new JLabel("Player :");
  45 + title.setFont(titleFont);
  46 + playPanel.add(title, BorderLayout.NORTH);
  47 +
  48 + // lights
  49 + playPanel.add(new LightCanvasJPanel(), BorderLayout.CENTER);
  50 +
  51 + // controls
  52 + AnimationPlayer animPlayer = new AnimationPlayer();
  53 + animPlayer.setAlignmentX(CENTER_ALIGNMENT);
  54 + playPanel.add(animPlayer, BorderLayout.SOUTH);
  55 +
  56 + parent.add(playPanel, BorderLayout.SOUTH);
  57 + }
  58 +}
... ...
VRGNYMusicLights/Sources/InvalidPatternException.java 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +
  2 +public class InvalidPatternException extends RuntimeException {
  3 + private static final long serialVersionUID = 1L;
  4 +
  5 + public InvalidPatternException() {
  6 + super("Invalid pattern given. Length must be equal to 4.");
  7 + }
  8 +}
... ...
VRGNYMusicLights/Sources/LightCanvasJPanel.java 0 → 100644
... ... @@ -0,0 +1,51 @@
  1 +import java.awt.Color;
  2 +import java.awt.Dimension;
  3 +import java.awt.Graphics;
  4 +
  5 +import javax.swing.JPanel;
  6 +
  7 +public class LightCanvasJPanel extends JPanel {
  8 + public static final double[][] DEFAULT_LIGHT_COORDS = new double[][] {
  9 + {0, 0} , {0.2, 0} , {0.4, 0} , {0.6 , 0}, {0.8, 0} , {1, 0} ,
  10 + {0, 0.2}, {0.2, 0.2}, {0.4, 0.2}, {0.6, 0.2}, {0.8, 0.2}, {1, 0.2},
  11 + {0, 0.4}, {0.2, 0.4}, {0.4, 0.4}, {0.6, 0.4}, {0.8, 0.4}, {1, 0.4},
  12 + {0, 0.6}, {0.2, 0.6}, {0.4, 0.6}, {0.6, 0.6}, {0.8, 0.6}, {1, 0.6},
  13 + {0, 0.8}, {0.2, 0.8}, {0.4, 0.8}, {0.6, 0.8}, {0.8, 0.8}, {1, 0.8},
  14 + {0, 1} , {0.2, 1} , {0.4, 1} , {0.6, 1} , {0.8, 1} , {1, 1} ,
  15 + };
  16 +
  17 + private static final long serialVersionUID = 1L;
  18 + private static final int WIDTH = 320; // = 300 + padding * 2
  19 + private static final int HEIGHT = 220; // = 200 + padding * 2
  20 + private static final int LIGHT_RADIUS = 4;
  21 + private static final int PADDING = 10;
  22 + private double[][] lightsCoords;
  23 +
  24 + /**
  25 + * @param lightCoords : double[LightID][X = 0, Y = 1] = coordinates as a percentage [0, 1]
  26 + */
  27 + public LightCanvasJPanel() {this(DEFAULT_LIGHT_COORDS);}
  28 + public LightCanvasJPanel(double[][] lightsCoords) {
  29 + this.lightsCoords = lightsCoords;
  30 + setPreferredSize(new Dimension(WIDTH, HEIGHT));
  31 + }
  32 +
  33 + @Override
  34 + protected void paintComponent(Graphics g) {
  35 + // background
  36 + g.setColor(Color.WHITE);
  37 + g.fillRect(0, 0, WIDTH, HEIGHT);
  38 +
  39 + // lights
  40 + if(lightsCoords == null) return;
  41 + g.setColor(Color.BLACK);
  42 + for(double[] light : lightsCoords) {
  43 + if(light.length != 2)
  44 + throw new MalformedCoordinates();
  45 + int centerX = (int) (light[0] * (WIDTH - PADDING * 2)) + PADDING;
  46 + int centerY = (int) (light[1] * (HEIGHT - PADDING * 2)) + PADDING;
  47 +
  48 + g.fillOval(centerX - LIGHT_RADIUS, centerY - LIGHT_RADIUS, LIGHT_RADIUS * 2, LIGHT_RADIUS * 2);
  49 + }
  50 + }
  51 +}
... ...
VRGNYMusicLights/Sources/Main.java 0 → 100644
... ... @@ -0,0 +1,30 @@
  1 +
  2 +/* TODO list :
  3 + * - keyboard listener for animation player (play / pause = space, forward = semicolon, backward = comma, stop = backspace)
  4 + */
  5 +public class Main {
  6 + public static void main(String[] args) throws InterruptedException {
  7 + /* FIXME interface testing in progress
  8 +
  9 + String serialPort = null;
  10 + try {
  11 + serialPort = SerialPortChooserDialog.showSerialPortChooserDialog();
  12 + } catch (NoSerialPortException e) {
  13 + JOptionPane.showMessageDialog(null, "No serial port available !", "Error", JOptionPane.ERROR_MESSAGE);
  14 + System.exit(-1);
  15 + }
  16 + if(serialPort == null) System.exit(-1);
  17 +
  18 + final SerialCom serialCom = new SerialCom(serialPort);
  19 + // arduino need time before accepting serial data
  20 + Thread.sleep(1000);*/
  21 +
  22 + Interface i = new Interface(new Runnable() {
  23 + @Override
  24 + public void run() {
  25 + //serialCom.close();
  26 + }
  27 + });
  28 + i.setVisible(true);
  29 + }
  30 +}
... ...
VRGNYMusicLights/Sources/MalformedCoordinates.java 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +
  2 +public class MalformedCoordinates extends RuntimeException {
  3 + private static final long serialVersionUID = 1L;
  4 +
  5 + public MalformedCoordinates() {
  6 + super("Wrong format of coordinates given");
  7 + }
  8 +}
... ...
VRGNYMusicLights/Sources/Music.java 0 → 100644
... ... @@ -0,0 +1,16 @@
  1 +
  2 +public class Music {
  3 + private MusicPattern pattern;
  4 + private MusicPath path;
  5 + private long startDelai; // in ms
  6 + private long length; // in ms
  7 +
  8 + public Music(MusicPattern pattern, MusicPath path, long startDelai, long length) {
  9 + this.pattern = pattern;
  10 + this.path = path;
  11 + this.startDelai = startDelai;
  12 + this.length = length;
  13 +
  14 + //call MusicPath transform()
  15 + }
  16 +}
... ...
VRGNYMusicLights/Sources/MusicList.java 0 → 100644
... ... @@ -0,0 +1,11 @@
  1 +import java.util.ArrayList;
  2 +
  3 +public class MusicList {
  4 + private ArrayList<Music> musics;
  5 + private SerialCom serialCom;
  6 +
  7 + public MusicList(SerialCom serialCom) {
  8 + this.serialCom = serialCom;
  9 + musics = new ArrayList<>();
  10 + }
  11 +}
... ...
VRGNYMusicLights/Sources/MusicPath.java 0 → 100644
... ... @@ -0,0 +1,20 @@
  1 +
  2 +public class MusicPath {
  3 + private static final int VERTICAL_DOWN = 0;
  4 + private static final int VERTICAL_UP = 1;
  5 + private static final int HORIZONTAL_DOWN = 2;
  6 + private static final int HORIZONTAL_UP = 3;
  7 + private static final int DIAGONAL_TOP_RIGHT_DOWN_LEFT = 4;
  8 + private static final int DIAGONAL_TOP_LEFT_DOWN_RIGHT = 5;
  9 + private static final int CENTER_OUT = 6;
  10 + private static final int CENTER_IN = 7;
  11 +
  12 + private int animation;
  13 +
  14 + public MusicPath(int animation) {
  15 + this.animation = animation;
  16 + }
  17 +
  18 + // TODO transform music according to animation
  19 + // what format ? int[nled][pattern] (ms) ?
  20 +}
... ...
VRGNYMusicLights/Sources/MusicPattern.java 0 → 100644
... ... @@ -0,0 +1,16 @@
  1 +
  2 +public class MusicPattern {
  3 + /* Pattern definition :
  4 + * 0 : low time
  5 + * 1 : rise time
  6 + * 2 : high time
  7 + * 3 : fall time
  8 + */
  9 + private int[] pattern; // in ms
  10 +
  11 + public MusicPattern(int[] pattern) {
  12 + if(pattern.length != 4)
  13 + throw new InvalidPatternException();
  14 + this.pattern = pattern;
  15 + }
  16 +}
... ...
VRGNYMusicLights/Sources/NoSerialPortException.java 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +
  2 +public class NoSerialPortException extends Exception {
  3 + private static final long serialVersionUID = 1L;
  4 +
  5 + public NoSerialPortException() {
  6 + super("No serial port available !");
  7 + }
  8 +}
... ...
VRGNYMusicLights/Sources/SerialCom.java 0 → 100644
... ... @@ -0,0 +1,82 @@
  1 +import java.io.IOException;
  2 +import java.io.InputStream;
  3 +import java.io.OutputStream;
  4 +import java.util.Enumeration;
  5 +
  6 +import gnu.io.CommPortIdentifier;
  7 +import gnu.io.PortInUseException;
  8 +import gnu.io.SerialPort;
  9 +import gnu.io.UnsupportedCommOperationException;
  10 +
  11 +public class SerialCom {
  12 + private static final int DATA_RATE = 9600;
  13 + private static final int TIME_OUT = 2000;
  14 + private static final int BUFFER_SIZE = 1024;
  15 +
  16 + private SerialPort serialPort;
  17 + private InputStream input;
  18 + private OutputStream output;
  19 +
  20 + public SerialCom(int portNumberWindows) { this("COM" + String.valueOf(portNumberWindows)); }
  21 + public SerialCom(String portName) {
  22 + CommPortIdentifier portId = null;
  23 + Enumeration<?> portEnum = CommPortIdentifier.getPortIdentifiers();
  24 +
  25 + // Search for serial port
  26 + while (portEnum.hasMoreElements()) {
  27 + CommPortIdentifier currPortId = (CommPortIdentifier) portEnum.nextElement();
  28 + if (currPortId.getName().equals(portName)) {
  29 + portId = currPortId;
  30 + break;
  31 + }
  32 + }
  33 + if (portId == null)
  34 + throw new SerialComPortException(portName);
  35 +
  36 + // open connection
  37 + try {
  38 + serialPort = (SerialPort) portId.open(this.getClass().getName(), TIME_OUT);
  39 + serialPort.setSerialPortParams(DATA_RATE, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
  40 +
  41 + input = serialPort.getInputStream();
  42 + output = serialPort.getOutputStream();
  43 + } catch (IOException
  44 + | UnsupportedCommOperationException
  45 + | PortInUseException e) {
  46 + throw new SerialComPortException(portName);
  47 + }
  48 + }
  49 +
  50 + public void close() {
  51 + try {
  52 + input.close();
  53 + output.close();
  54 + } catch (IOException e) {
  55 + e.printStackTrace();
  56 + }
  57 + serialPort.removeEventListener();
  58 + serialPort.close();
  59 + }
  60 + public void send(byte[] bytes) {
  61 + try {
  62 + this.output.write(bytes);
  63 + } catch (IOException e) {
  64 + e.printStackTrace();
  65 + }
  66 + }
  67 +
  68 + public byte[] recieve() {
  69 + byte[] buffer = new byte[BUFFER_SIZE];
  70 + int len = -1;
  71 +
  72 + try { len = this.input.read(buffer); }
  73 + catch (IOException e) { return null; }
  74 +
  75 + if(len == -1 || len == 0)
  76 + return null;
  77 + byte[] data = new byte[len];
  78 + for(int i=0; i<len; i++)
  79 + data[i] = buffer[i];
  80 + return data;
  81 + }
  82 +}
... ...
VRGNYMusicLights/Sources/SerialComPortException.java 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +
  2 +public class SerialComPortException extends RuntimeException {
  3 + private static final long serialVersionUID = 1L;
  4 +
  5 + public SerialComPortException(String portName) {
  6 + super("Connection to port " + portName + " failed !");
  7 + }
  8 +}
... ...
VRGNYMusicLights/Sources/SerialComWrongCallbackMethod.java 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +
  2 +public class SerialComWrongCallbackMethod extends RuntimeException {
  3 + private static final long serialVersionUID = 1L;
  4 +
  5 + public SerialComWrongCallbackMethod() {
  6 + super("Wrong callback method format !");
  7 + }
  8 +}
... ...
VRGNYMusicLights/Sources/SerialCommands.java 0 → 100644
... ... @@ -0,0 +1,4 @@
  1 +
  2 +public class SerialCommands {
  3 + // TODO
  4 +}
... ...
VRGNYMusicLights/Sources/SerialPortChooserDialog.java 0 → 100644
... ... @@ -0,0 +1,119 @@
  1 +import java.awt.BorderLayout;
  2 +import java.awt.Dimension;
  3 +import java.awt.FlowLayout;
  4 +import java.awt.event.ActionEvent;
  5 +import java.awt.event.ActionListener;
  6 +import java.util.ArrayList;
  7 +import java.util.Enumeration;
  8 +
  9 +import javax.swing.DefaultListModel;
  10 +import javax.swing.JButton;
  11 +import javax.swing.JDialog;
  12 +import javax.swing.JLabel;
  13 +import javax.swing.JList;
  14 +import javax.swing.JPanel;
  15 +import javax.swing.JScrollPane;
  16 +import javax.swing.ListSelectionModel;
  17 +import javax.swing.event.ListSelectionEvent;
  18 +import javax.swing.event.ListSelectionListener;
  19 +
  20 +import gnu.io.CommPortIdentifier;
  21 +
  22 +public class SerialPortChooserDialog extends JDialog implements ActionListener, ListSelectionListener {
  23 + private static final long serialVersionUID = 1L;
  24 +
  25 + private boolean onlyOneChoice;
  26 + private boolean emptyChoice;
  27 + private ArrayList<String> portNames;
  28 + private String choosedPort = null;
  29 +
  30 + private JList<String> list;
  31 + private JButton ok;
  32 + private JButton cancel;
  33 +
  34 + private SerialPortChooserDialog() {
  35 + Enumeration<?> portEnum = CommPortIdentifier.getPortIdentifiers();
  36 + portNames = new ArrayList<>();
  37 +
  38 + while (portEnum.hasMoreElements()) {
  39 + CommPortIdentifier currPortId = (CommPortIdentifier) portEnum.nextElement();
  40 + portNames.add(currPortId.getName());
  41 + }
  42 +
  43 + onlyOneChoice = portNames.size() <= 1;
  44 + emptyChoice = portNames.size() == 0;
  45 + if(onlyOneChoice || emptyChoice)
  46 + return;
  47 +
  48 + // JDialog creation
  49 + JPanel mainPanel = new JPanel(new BorderLayout());
  50 + setModal(true);
  51 + setTitle("Serial port chooser");
  52 +
  53 + // title
  54 + mainPanel.add(new JLabel("Choose a serial port : "), BorderLayout.NORTH);
  55 +
  56 + // list ports
  57 + DefaultListModel<String> listModel = new DefaultListModel<>();
  58 + for(String str : portNames)
  59 + listModel.addElement(str);
  60 + list = new JList<>(listModel);
  61 + list.addListSelectionListener(this);
  62 + list.setVisibleRowCount(3);
  63 + list.setLayoutOrientation(JList.VERTICAL);
  64 + list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  65 +
  66 + JScrollPane scrollPane = new JScrollPane(list, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  67 + scrollPane.setPreferredSize(new Dimension(200, 100));
  68 + mainPanel.add(scrollPane, BorderLayout.CENTER);
  69 +
  70 + // buttons ok / cancel
  71 + JPanel borderLayoutPanel = new JPanel(new BorderLayout());
  72 + JPanel buttonsLayout = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 3));
  73 + ok = new JButton("Ok");
  74 + cancel = new JButton("Cancel");
  75 + ok.addActionListener(this);
  76 + cancel.addActionListener(this);
  77 + ok.setEnabled(false);
  78 + buttonsLayout.add(cancel);
  79 + buttonsLayout.add(ok);
  80 + borderLayoutPanel.add(buttonsLayout, BorderLayout.EAST);
  81 + mainPanel.add(borderLayoutPanel, BorderLayout.SOUTH);
  82 +
  83 + // padding
  84 + JPanel padding = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 5));
  85 + padding.add(mainPanel);
  86 + add(padding);
  87 +
  88 + setResizable(false);
  89 + pack();
  90 + setLocationRelativeTo(null);
  91 + setVisible(true);
  92 + }
  93 +
  94 + public static String showSerialPortChooserDialog() throws NoSerialPortException {
  95 + SerialPortChooserDialog dialog = new SerialPortChooserDialog();
  96 + if(dialog.emptyChoice)
  97 + throw new NoSerialPortException();
  98 + if(dialog.onlyOneChoice)
  99 + return dialog.portNames.get(0);
  100 + return dialog.choosedPort;
  101 + }
  102 +
  103 + @Override
  104 + public void actionPerformed(ActionEvent e) {
  105 + if(e.getSource() == ok) {
  106 + choosedPort = list.getSelectedValue();
  107 + dispose();
  108 + } else if(e.getSource() == cancel) {
  109 + dispose();
  110 + }
  111 + }
  112 +
  113 + @Override
  114 + public void valueChanged(ListSelectionEvent e) {
  115 + if(e.getSource() == list) {
  116 + ok.setEnabled(list.getSelectedIndex() != -1);
  117 + }
  118 + }
  119 +}
... ...
VRGNYMusicLights/Sources/icons/backward.png 0 → 100644

436 Bytes

VRGNYMusicLights/Sources/icons/forward.png 0 → 100644

412 Bytes

VRGNYMusicLights/Sources/icons/pause.png 0 → 100644

295 Bytes

VRGNYMusicLights/Sources/icons/play.png 0 → 100644

364 Bytes

VRGNYMusicLights/Sources/icons/stop.png 0 → 100644

320 Bytes