changeset 41:75354c638975

Fix for Windows users: the GUI was previously covered by task bar. Now offers a full screen option which covers the task bar. Also a good option for less technical users as program will stay in full screen until closed - less chance for error.
author Carl Bussey <c.bussey@se10.qmul.ac.uk>
date Wed, 05 Jun 2013 19:22:31 +0100
parents af173212eb42
children d3977e825d91
files Experiment.java ExperimentGui.java MidiPlayer.java README SubjectDataPanel.java
diffstat 5 files changed, 45 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/Experiment.java	Mon Jun 03 18:33:31 2013 +0100
+++ b/Experiment.java	Wed Jun 05 19:22:31 2013 +0100
@@ -9,7 +9,6 @@
 import java.io.*;
 import javax.swing.UIManager; 
 import java.awt.*;
-import java.awt.Color;
 import javax.sound.midi.*;
 import java.util.Scanner;
 
@@ -39,7 +38,8 @@
 
 
     /* The GUI */ 
-    private ExperimentGui gui; 
+    private ExperimentGui gui;
+    private boolean fullScreen;
 
     /* whether to show the clock */
     private boolean showClock;
@@ -72,7 +72,7 @@
 
     /* the midi device */
     private int midiDevice;
-
+    
     /* debugging */ 
     private boolean debug;
 
@@ -105,7 +105,7 @@
     }
 
     /* Constructor */ 
-    public Experiment (int sc, int cu, int nu, int sl, int md, String la, String ha, String mfd, String inf, String rdr, int fam, int lik, int quest, int de) {
+    public Experiment (int sc, int cu, int nu, int sl, int md, String la, String ha, String mfd, String inf, String rdr, int fam, int lik, int quest, int fs, int de) {
         
         // Setup variables 
 	debug = (de != 0);
@@ -128,6 +128,10 @@
         SUBJECT_RESULTS_FILE = 
             RESULTS_DIRECTORY + "subjects" + RESULTS_EXTENSION;
         
+        if (fs == 0)
+            fullScreen = false;
+        else
+            fullScreen = true;
         if (fam == 0)
             askFamiliarity = false;
         else 
@@ -184,17 +188,36 @@
     } 
 
     /* Show the GUI */ 
-    public void showGUI(int width, int height) { 
+    public void showGUI(int width, int height) {
+        GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
+        if(fullScreen){
+            if (gd.isFullScreenSupported()) {
+                System.out.println("Entering full Screen... Press <enter> to continue.");
+                Scanner scanner = new Scanner(System.in);
+                scanner.nextLine();
+                gui.setUndecorated(true);
+                gd.setFullScreenWindow(gui);
+            } else {
+                System.out.println("Not Full Screen Supported :(");
+                showDefaultGUI(width, height);
+            }
+        }
+        else{
+            showDefaultGUI(width, height);
+        }
+    }
+    
+    public void showDefaultGUI(int width, int height) {
         gui.pack();
-        gui.setSize(width, height); 
+        gui.setSize(width, height);
         // UIManager.put("Button.focus", UIManager.get("Button.select"));
         gui.setVisible(true);
-    } 
+    }
 
-    /* Main method */ 
+    /* Main method */
     public static void main(String[] args) {
 	
-	if (args.length == 14) {
+	if (args.length == 15) {
 
         // Parse Arguments 
         int n = 0;
@@ -212,6 +235,7 @@
         int fam = Integer.parseInt(args[n++]);
         int lik = Integer.parseInt(args[n++]);
         int quest = Integer.parseInt(args[n++]);
+        int fs = Integer.parseInt(args[n++]);
         int de = Integer.parseInt(args[n++]);
 
     if(isBooleanFormat(mdInput)){
@@ -241,7 +265,7 @@
     }
 
         // Create experiment 
-        Experiment exp = new Experiment(sc, cu, nu, sl, md, la, ha, mfd, inf, rdr, fam, lik, quest, de);
+        Experiment exp = new Experiment(sc, cu, nu, sl, md, la, ha, mfd, inf, rdr, fam, lik, quest, fs, de);
         
         // Show the GUI 
         int width=(int)Toolkit.getDefaultToolkit().getScreenSize().getWidth();
@@ -258,8 +282,8 @@
                            "<show clock?> <clock units> <number of units> " +
                            "<default MIDI device?> " +
                            "<scale length> <low anchor> <high anchor> " +
-                           "<midi file directory> <instructions file> <results directory>" +
-                           "<familiarity>" + "<pleasantness>" + "<questionnaire>" + "<debug>");
+                           "<midi file directory> <instructions file> <results directory> " +
+                           " <familiarity> " + " <pleasantness> " + " <questionnaire> " + " <fullscreen> " + " <debug>");
         System.exit(1);
     }
 
--- a/ExperimentGui.java	Mon Jun 03 18:33:31 2013 +0100
+++ b/ExperimentGui.java	Wed Jun 05 19:22:31 2013 +0100
@@ -12,7 +12,7 @@
 import java.util.Iterator;
 
 public class ExperimentGui extends JFrame implements Runnable {
-
+    
     /* the Experiment */ 
     private Experiment exp; 
 
@@ -48,6 +48,8 @@
     /* Constructor */ 
     public ExperimentGui(Experiment experiment) {
 
+        
+        
         // initialise experiment 
         exp = experiment; 
         acceptingResponses = false; 
@@ -80,7 +82,7 @@
         mainPanel.add(stimulusPanel, "stimulus"); 
         mainPanel.add(subjectDataPanel, "subject"); 
 
-        this.add(mainPanel, BorderLayout.CENTER); 
+        this.add(mainPanel, BorderLayout.CENTER);
     }
 
     /* 
--- a/MidiPlayer.java	Mon Jun 03 18:33:31 2013 +0100
+++ b/MidiPlayer.java	Wed Jun 05 19:22:31 2013 +0100
@@ -96,7 +96,6 @@
         try {
             MidiDevice.Info msinfo[] = MidiSystem.getMidiDeviceInfo(); 
             for(int i = 0; i < msinfo.length; i++) { 
-		System.out.println("Carl: "+i);
 		MidiDevice.Info m = msinfo[i];
                  System.out.println("Name: " + m.getName() + 
                                     "; Vendor: " + m.getVendor() + 
--- a/README	Mon Jun 03 18:33:31 2013 +0100
+++ b/README	Wed Jun 05 19:22:31 2013 +0100
@@ -5,14 +5,14 @@
 
 USAGE 
 
-  java Experiment <show clock?> <multiple> <n> <midi device> <scale length> <low anchor> <high anchor> <midi file directory> <instructions file> <results directory> <familiarity> <pleasantness> <questionnaire> <debug>
+  java Experiment <show clock?> <multiple> <n> <midi device> <scale length> <low anchor> <high anchor> <midi file directory> <instructions file> <results directory> <familiarity> <pleasantness> <questionnaire> <fullscreen> <debug>
 
 where <show clock?> specifies whether to show the clock (0 = no; 1 =
 yes) and <multiple> and <n> are integers: the clock runs for <n> time
 units before a probed event where the time unit is a multiple of the
 tatum as specified by <multiple>.
 
-<midi device> is an integer specifying the midi device to use (usually 0).
+<midi device> is an integer specifying the midi device to use (usually 0) or a boolean String ("true" or "false") where "true" specifies that the program should use the default midi device and "false" specifies that the program should not use the default midi device, and should list the available midi devices on start up.
 
 <scale length> is the number of levels of the rating scale and <low
 anchor> and <high anchor> are its high and low anchors respectively
@@ -37,6 +37,8 @@
 questionnaire on age, sex, musical training etc.; if it is 0 the
 questionnaire is optional.
 
+If <fullscreen> is 1, the program will produce a fixed full screen GUI which can't be resized if the device allows this; if it is 0 then the program will produce a resizable full screen GUI.
+
 if <debug> is 1 debug information is written to the terminal, if 0 it is not.
 
 See runExperiment.bat for an example.
--- a/SubjectDataPanel.java	Mon Jun 03 18:33:31 2013 +0100
+++ b/SubjectDataPanel.java	Wed Jun 05 19:22:31 2013 +0100
@@ -189,7 +189,7 @@
             String[] goldMSI3_10o = {"", "0%", "25%", "50%", "75%", "100%"};
             goldMSI3_10 = new JComboBox(goldMSI3_10o);
             c.anchor = GridBagConstraints.EAST;
-            questionsPanel.add(new JLabel("I was familiar with approximately ------- of the study songs."), c);
+            questionsPanel.add(new JLabel("I was familiar with approximately ------- of the songs."), c);
             c.anchor = GridBagConstraints.WEST;
             questionsPanel.add(goldMSI3_10, c);
         }