annotate src/uk/ac/qmul/eecs/depic/daw/haptics/HaptificationPrefsPanel.java @ 4:473da40f3d39 tip

added html formatting to Daw/package-info.java
author Fiore Martin <f.martin@qmul.ac.uk>
date Thu, 25 Feb 2016 17:50:09 +0000
parents c0412c81d274
children
rev   line source
f@0 1 package uk.ac.qmul.eecs.depic.daw.haptics;
f@0 2
f@0 3
f@0 4 import java.awt.GridBagConstraints;
f@0 5 import java.awt.GridBagLayout;
f@0 6 import java.awt.Insets;
f@0 7 import java.util.prefs.Preferences;
f@0 8
f@0 9 import javax.swing.JLabel;
f@0 10
f@0 11 import uk.ac.qmul.eecs.depic.daw.gui.PreferencesPanel;
f@0 12 import uk.ac.qmul.eecs.depic.daw.referencesound.GridSound;
f@0 13
f@0 14 import javax.swing.JComboBox;
f@0 15
f@2 16 /**
f@2 17 *
f@2 18 * Preference panel for the haptic display of the DAW. It is in this package and not in
f@2 19 * the gui package because it's specific to this sonification. The gui package is more
f@2 20 * a general purpose set of graphical classes for the DAW, regardless of the sonification.
f@2 21 *
f@2 22 * However this class extends PreferencesPanel, which is an abstraction of a preference panel
f@2 23 * to allow other packages to plug in their custom preference settings panels,
f@2 24 * without making the gui package dependent on them.
f@2 25 *
f@2 26 */
f@0 27 public class HaptificationPrefsPanel extends PreferencesPanel {
f@0 28
f@0 29 public static GridSound.Type [] SOUND_TYPES = {
f@0 30 GridSound.Type.NONE,
f@0 31 GridSound.Type.PITCH,
f@0 32 GridSound.Type.PITCH_ONE_REF,
f@0 33 GridSound.Type.PITCH_MUL_REF
f@0 34 };
f@0 35
f@0 36 public static String [] GRID_TYPES = {
f@0 37 "freeform","grid0","grid1", "grid3"
f@0 38 };
f@0 39
f@0 40 private static String [] keys = new String [] {
f@0 41 "sound_type",
f@0 42 "grid_type",
f@0 43 };
f@0 44
f@0 45 private static final long serialVersionUID = 1L;
f@0 46
f@0 47
f@0 48 private static HaptificationPrefsPanel singleton;
f@0 49 private JComboBox<GridSound.Type> soundComboBox;
f@0 50 private JComboBox<String> gridComboBox;
f@0 51 public static HaptificationPrefsPanel getInstance(){
f@0 52 if(singleton == null)
f@0 53 singleton = new HaptificationPrefsPanel();
f@0 54 return singleton;
f@0 55 }
f@0 56
f@0 57 /**
f@0 58 * Create the panel.
f@0 59 */
f@0 60 private HaptificationPrefsPanel() {
f@0 61
f@0 62 GridBagLayout gridBagLayout = new GridBagLayout();
f@0 63 gridBagLayout.columnWidths = new int[]{30, 70, 78, 189, 0, 0};
f@0 64 gridBagLayout.rowHeights = new int[]{30, 18, 0, 0, 0, 0, 0};
f@0 65 gridBagLayout.columnWeights = new double[]{0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE};
f@0 66 gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
f@0 67 setLayout(gridBagLayout);
f@0 68
f@0 69 JLabel selectionFilterLabel = new JLabel("Sound Type:");
f@0 70 GridBagConstraints gbc_selectionFilterLabel = new GridBagConstraints();
f@0 71 gbc_selectionFilterLabel.anchor = GridBagConstraints.WEST;
f@0 72 gbc_selectionFilterLabel.insets = new Insets(0, 0, 5, 5);
f@0 73 gbc_selectionFilterLabel.gridx = 1;
f@0 74 gbc_selectionFilterLabel.gridy = 1;
f@0 75 add(selectionFilterLabel, gbc_selectionFilterLabel);
f@0 76
f@0 77 /* prefs are used to initialize the spinners and the grain ugens */
f@0 78 Preferences prefs = Preferences.userNodeForPackage(this.getClass());
f@0 79
f@0 80 soundComboBox = new JComboBox<>(SOUND_TYPES);
f@0 81 soundComboBox.setSelectedItem(prefs.get(keys[1], SOUND_TYPES[0].toString()));
f@0 82 GridBagConstraints gbc_soundComboBox = new GridBagConstraints();
f@0 83 gbc_soundComboBox.fill = GridBagConstraints.HORIZONTAL;
f@0 84 gbc_soundComboBox.insets = new Insets(0, 0, 5, 5);
f@0 85 gbc_soundComboBox.gridx = 3;
f@0 86 gbc_soundComboBox.gridy = 1;
f@0 87 add(soundComboBox, gbc_soundComboBox);
f@0 88
f@0 89 JLabel borderThreshLabel = new JLabel("Grid Type :"); // FIXME boudles
f@0 90 GridBagConstraints gbc_borderThreshLabel = new GridBagConstraints();
f@0 91 gbc_borderThreshLabel.anchor = GridBagConstraints.WEST;
f@0 92 gbc_borderThreshLabel.insets = new Insets(0, 0, 5, 5);
f@0 93 gbc_borderThreshLabel.gridx = 1;
f@0 94 gbc_borderThreshLabel.gridy = 2;
f@0 95 add(borderThreshLabel, gbc_borderThreshLabel);
f@0 96
f@0 97 gridComboBox = new JComboBox<>(GRID_TYPES);
f@0 98 gridComboBox.setSelectedItem(prefs.get(keys[1], GRID_TYPES[0]));
f@0 99 GridBagConstraints gbc_gridComboBox = new GridBagConstraints();
f@0 100 gbc_gridComboBox.insets = new Insets(0, 0, 5, 5);
f@0 101 gbc_gridComboBox.fill = GridBagConstraints.HORIZONTAL;
f@0 102 gbc_gridComboBox.gridx = 3;
f@0 103 gbc_gridComboBox.gridy = 2;
f@0 104 add(gridComboBox, gbc_gridComboBox);
f@0 105
f@0 106 /* sets all the strings for the screen reader */
f@0 107 configureAccessibleContext();
f@0 108 }
f@0 109
f@0 110
f@0 111 private void configureAccessibleContext(){
f@0 112 }
f@0 113
f@0 114 @Override
f@0 115 public void savePrefs() {
f@0 116 Preferences prefs = Preferences.userNodeForPackage(this.getClass());
f@0 117
f@0 118 prefs.put(getPrefsList()[0], soundComboBox.getItemAt(soundComboBox.getSelectedIndex()).toString());
f@0 119 prefs.put(getPrefsList()[1], gridComboBox.getItemAt(gridComboBox.getSelectedIndex()));
f@0 120
f@0 121 }
f@0 122
f@0 123 public Preferences getPrefs(){
f@0 124 Preferences prefs = Preferences.userNodeForPackage(this.getClass());
f@0 125
f@0 126 prefs.put(getPrefsList()[0], prefs.get(getPrefsList()[0], SOUND_TYPES[0].toString()));
f@0 127 prefs.put(getPrefsList()[1], prefs.get(getPrefsList()[1], GRID_TYPES[0]));
f@0 128
f@0 129 return prefs;
f@0 130 }
f@0 131
f@0 132 @Override
f@0 133 public String getTitle(){
f@0 134 return "Haptics";
f@0 135 }
f@0 136
f@0 137 @Override
f@0 138 public String[] getPrefsList() {
f@0 139 return keys;
f@0 140 }
f@0 141 }
f@0 142