public class Config
extends java.lang.Object
This class handles configuration issues. It contains functionality to get and set config values and to read and write the config file.
It is not meant to instantiate any objects and contains only static methods.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AU_CHANNELS |
static java.lang.String |
AU_ENCODING |
static java.lang.String |
AU_IS_BIG_ENDIAN |
static java.lang.String |
AU_SAMPLE_RATE |
static java.lang.String |
AU_SAMPLE_SIZE_BITS |
private static java.util.HashMap<java.lang.String,java.lang.String> |
auDefaults |
static java.lang.String |
CBX_HALFTONE_ID_CIS |
static java.lang.String |
CBX_HALFTONE_ID_DIESIS |
static java.lang.String |
CBX_HALFTONE_ID_SHARP |
private static java.lang.String[] |
CBX_HALFTONE_IDENTIFIERS |
private static java.util.ArrayList<ComboboxStringOption> |
CBX_HALFTONE_OPTIONS |
static java.lang.String |
CBX_INSTR_DE_1 |
static java.lang.String |
CBX_INSTR_EN_1 |
private static java.lang.String[] |
CBX_INSTRUMENT_IDENTIFIERS |
private static java.util.ArrayList<ComboboxStringOption> |
CBX_INSTRUMENT_OPTIONS |
static java.lang.String |
CBX_LANG_ENGLISH |
static java.lang.String |
CBX_LANG_GERMAN |
static java.util.ArrayList<ComboboxStringOption> |
CBX_LANGUAGE_OPTIONS |
static java.lang.String[] |
CBX_LANGUAGES |
static java.lang.String |
CBX_NOTE_ID_GERMAN_LC |
static java.lang.String |
CBX_NOTE_ID_GERMAN_UC |
static java.lang.String |
CBX_NOTE_ID_INTERNATIONAL_LC |
static java.lang.String |
CBX_NOTE_ID_INTERNATIONAL_UC |
static java.lang.String |
CBX_NOTE_ID_ITALIAN_LC |
static java.lang.String |
CBX_NOTE_ID_ITALIAN_UC |
private static java.lang.String[] |
CBX_NOTE_IDENTIFIERS |
private static java.util.ArrayList<ComboboxStringOption> |
CBX_NOTE_OPTIONS |
static java.lang.String |
CBX_OCTAVE_GERMAN |
private static java.lang.String[] |
CBX_OCTAVE_IDENTIFIERS |
static java.lang.String |
CBX_OCTAVE_INTERNATIONAL |
private static java.util.ArrayList<ComboboxStringOption> |
CBX_OCTAVE_OPTIONS |
static java.lang.String |
CBX_OCTAVE_PLUS_MINUS |
static java.lang.String |
CBX_OCTAVE_PLUS_MINUS_N |
static java.lang.String |
CBX_PERC_DE_1 |
static java.lang.String |
CBX_PERC_EN_1 |
private static java.lang.String[] |
CBX_PERCUSSION_IDENTIFIERS |
private static java.util.ArrayList<ComboboxStringOption> |
CBX_PERCUSSION_OPTIONS |
static java.lang.String |
CBX_SHARPFLAT_FLAT |
private static java.lang.String[] |
CBX_SHARPFLAT_IDENTIFIERS |
private static java.util.ArrayList<ComboboxStringOption> |
CBX_SHARPFLAT_OPTIONS |
static java.lang.String |
CBX_SHARPFLAT_SHARP |
private static java.lang.String[] |
CBX_SYNTAX_IDENTIFIERS |
static java.lang.String |
CBX_SYNTAX_LOWER |
static java.lang.String |
CBX_SYNTAX_MIXED |
private static java.util.ArrayList<ComboboxStringOption> |
CBX_SYNTAX_OPTIONS |
static java.lang.String |
CBX_SYNTAX_UPPER |
static java.lang.String |
CHARSET_EXPORT_MID |
static java.lang.String |
CHARSET_EXPORT_MPL |
static java.lang.String |
CHARSET_MID |
static java.lang.String |
CHARSET_MPL |
private static java.util.TreeMap<java.lang.String,java.lang.String> |
config |
private static java.io.File |
configFile |
static java.lang.String |
DC_ALL_SYLLABLES_ORPHANED |
static java.lang.String |
DC_CHORD_NOTE_OFF_TOLERANCE |
static java.lang.String |
DC_CHORD_NOTE_ON_TOLERANCE |
static java.lang.String |
DC_CHORD_VELOCITY_TOLERANCE |
static java.lang.String |
DC_CTRL_CHANGE_MODE |
static java.lang.String |
DC_DURATION_RATIO_TOLERANCE |
static java.lang.String |
DC_ELEMENTS_PER_LINE |
static java.lang.String |
DC_EXTRA_GLOBALS_STR |
static java.lang.String |
DC_KARAOKE_ONE_CHANNEL |
static java.lang.String |
DC_LENGTH_STRATEGY |
static java.lang.String |
DC_LENGTH_TICK_TOLERANCE |
static java.lang.String |
DC_MAX_BARLINE_TOL |
static java.lang.String |
DC_MAX_DURATION_TO_KEEP |
static java.lang.String |
DC_MAX_TICKS_ON_AT_480 |
static java.lang.String |
DC_MIN_DURATION_TO_KEEP |
static java.lang.String |
DC_MIN_TICKS_ON_AT_480 |
static java.lang.String |
DC_MUST_ADD_CONFIG |
static java.lang.String |
DC_MUST_ADD_QUALITY_SCORE |
static java.lang.String |
DC_MUST_ADD_STATISTICS |
static java.lang.String |
DC_MUST_ADD_STRATEGY_STAT |
static java.lang.String |
DC_MUST_ADD_TICK_COMMENTS |
static java.lang.String |
DC_ORPHANED_SYLLABLES |
static java.lang.String |
DC_SYNTAX_TYPE |
static java.lang.String |
DC_USE_BARLINES |
static java.lang.String |
DC_USE_DOTTED_NOTES |
static java.lang.String |
DC_USE_DOTTED_RESTS |
static java.lang.String |
DC_USE_KARAOKE |
static java.lang.String |
DC_USE_PRE_DEFINED_CHORDS |
static java.lang.String |
DC_USE_TRIPLETTED_NOTES |
static java.lang.String |
DC_USE_TRIPLETTED_RESTS |
private static java.util.HashMap<java.lang.String,java.lang.String> |
dcDefaults |
static java.lang.String |
DEFAULT_CHARSET_EXPORT_MID |
static java.lang.String |
DEFAULT_CHARSET_EXPORT_MPL |
static java.lang.String |
DEFAULT_CHARSET_MID |
static java.lang.String |
DEFAULT_CHARSET_MPL |
private static java.util.TreeMap<java.lang.String,java.util.TreeSet<KeyBinding>> |
defaultBindings |
private static java.util.HashMap<java.lang.String,java.lang.String> |
defaults |
static java.lang.String |
DIRECTORY_ABC |
static java.lang.String |
DIRECTORY_ALDA |
static java.lang.String |
DIRECTORY_EXPORT_ABC |
static java.lang.String |
DIRECTORY_EXPORT_ALDA |
static java.lang.String |
DIRECTORY_EXPORT_AUDIO |
static java.lang.String |
DIRECTORY_EXPORT_LY |
static java.lang.String |
DIRECTORY_EXPORT_MID |
static java.lang.String |
DIRECTORY_EXPORT_MPL |
static java.lang.String |
DIRECTORY_EXPORT_MSCORE |
static java.lang.String |
DIRECTORY_LY |
static java.lang.String |
DIRECTORY_MID |
static java.lang.String |
DIRECTORY_MPL |
static java.lang.String |
DIRECTORY_MSCORE |
static java.lang.String |
DIRECTORY_SB |
static java.lang.String |
EXEC_PATH_EXP_ABC |
static java.lang.String |
EXEC_PATH_EXP_LY |
static java.lang.String |
EXEC_PATH_EXP_MSCORE |
static java.lang.String |
EXEC_PATH_IMP_ABC |
static java.lang.String |
EXEC_PATH_IMP_ALDA |
static java.lang.String |
EXEC_PATH_IMP_LY |
static java.lang.String |
EXEC_PATH_IMP_MSCORE |
static java.lang.String |
HALF_TONE |
static java.lang.String |
IMPORT_TYPE |
static java.lang.String |
INSTRUMENT |
private static java.util.TreeMap<java.lang.String,java.util.TreeSet<KeyBinding>> |
keyBindings |
static java.lang.String |
LANGUAGE |
static java.lang.String |
NOTE |
static java.lang.String |
OCTAVE |
static java.lang.String |
PATH_ABC |
static java.lang.String |
PATH_ALDA |
static java.lang.String |
PATH_LY |
static java.lang.String |
PATH_MIDI |
static java.lang.String |
PATH_MIDICAPL |
static java.lang.String |
PATH_MSCORE |
static java.lang.String |
PATH_SOUND |
static java.lang.String |
PERCUSSION |
static java.lang.String |
REMEMBER_IMPORT |
static java.lang.String |
REMEMBER_SOUND |
static java.lang.String |
SHARP_FLAT |
static java.lang.String |
SOUND_SOURCE |
static java.lang.String |
SOUND_URL |
static java.lang.String |
SYNTAX |
static java.lang.String |
TAB_FILE_EXPORT |
static java.lang.String |
TAB_FILE_IMPORT |
static java.lang.String |
TAB_FILE_SOUND |
Modifier | Constructor and Description |
---|---|
private |
Config()
This class is only used statically so a public constructor is not needed.
|
Modifier and Type | Method and Description |
---|---|
private static void |
addDefaultKeyBinding(java.lang.String id,
int keyCode,
int mods)
Adds a key binding to the default structures.
|
static void |
addKeyBinding(java.lang.String id,
KeyBinding binding)
Adds a new key binding.
|
static java.lang.String |
get(java.lang.String key)
Reads and returns the config value according to the given key.
|
static java.lang.String |
getConfiguredSharpOrFlat(boolean sharp)
Returns the currently configured sharp or flat symbol.
|
static java.util.HashMap<java.lang.String,java.lang.String> |
getDefaultAudioExportConfig()
Initializes all default audio export configuration values and copies them to the current config.
|
static java.util.HashMap<java.lang.String,java.lang.String> |
getDefaultDecompileConfig()
Initializes all default decompile configuration values and copies them to the current config.
|
static java.util.TreeSet<KeyBinding> |
getKeyBindings(java.lang.String id)
Reads and returns the configured key bindings according to the given identifier.
|
static MidicaTreeModel |
getKeyBindingTreeModel()
Creates and returns a tree model for the currently configured key bindings.
|
static void |
init()
Initializes the configuration on startup.
|
private static void |
initComboBoxes()
Fills the configuration comboboxes in the GUI.
|
static void |
initLocale()
Sets the localization according to the configured language.
|
static boolean |
isFlatConfigured()
Checks if the configured half tone symbol is sharp or flat.
|
private static void |
parseConfig(java.lang.String line)
Reads a line of the config file.
|
private static void |
readConfigFile()
Reads the config file and sets the current configuration accordingly.
|
static void |
removeKeyBinding(java.lang.String id,
java.lang.String bindingDesc)
Removes the given key binding.
|
static void |
resetAllKeyBindingsToDefault()
Resets all key bindings to the default value.
|
static void |
resetKeyBindingsToDefault(java.lang.String id)
Resets the key bindings belonging to the specified action to the default.
|
private static void |
restoreDefaultKeyBindings()
Initializes all key default key bindings and uses copies of them for the real key bindings
|
static void |
restoreDefaults(java.lang.String homeDir)
Sets the current configuration to the default configuration.
|
static void |
set(java.lang.String key,
java.lang.String value)
Sets a configuration element.
|
private static void |
setKeyBindingIdInConfig(java.lang.String id,
java.util.TreeSet<KeyBinding> bindings)
Creates and sets a config value for key bindings to be written into the config file later.
|
static void |
writeConfigFile()
Saves the current configuration to the config file.
|
public static final java.lang.String DEFAULT_CHARSET_MPL
public static final java.lang.String DEFAULT_CHARSET_MID
public static final java.lang.String DEFAULT_CHARSET_EXPORT_MPL
public static final java.lang.String DEFAULT_CHARSET_EXPORT_MID
public static final java.lang.String LANGUAGE
public static final java.lang.String HALF_TONE
public static final java.lang.String SHARP_FLAT
public static final java.lang.String NOTE
public static final java.lang.String OCTAVE
public static final java.lang.String SYNTAX
public static final java.lang.String PERCUSSION
public static final java.lang.String INSTRUMENT
public static final java.lang.String DIRECTORY_MPL
public static final java.lang.String DIRECTORY_MID
public static final java.lang.String DIRECTORY_ALDA
public static final java.lang.String DIRECTORY_ABC
public static final java.lang.String DIRECTORY_LY
public static final java.lang.String DIRECTORY_MSCORE
public static final java.lang.String DIRECTORY_SB
public static final java.lang.String DIRECTORY_EXPORT_MPL
public static final java.lang.String DIRECTORY_EXPORT_MID
public static final java.lang.String DIRECTORY_EXPORT_ALDA
public static final java.lang.String DIRECTORY_EXPORT_AUDIO
public static final java.lang.String DIRECTORY_EXPORT_ABC
public static final java.lang.String DIRECTORY_EXPORT_LY
public static final java.lang.String DIRECTORY_EXPORT_MSCORE
public static final java.lang.String PATH_SOUND
public static final java.lang.String SOUND_URL
public static final java.lang.String PATH_MIDICAPL
public static final java.lang.String PATH_MIDI
public static final java.lang.String PATH_ALDA
public static final java.lang.String PATH_ABC
public static final java.lang.String PATH_LY
public static final java.lang.String PATH_MSCORE
public static final java.lang.String EXEC_PATH_IMP_ALDA
public static final java.lang.String EXEC_PATH_IMP_ABC
public static final java.lang.String EXEC_PATH_IMP_LY
public static final java.lang.String EXEC_PATH_IMP_MSCORE
public static final java.lang.String EXEC_PATH_EXP_ABC
public static final java.lang.String EXEC_PATH_EXP_LY
public static final java.lang.String EXEC_PATH_EXP_MSCORE
public static final java.lang.String REMEMBER_SOUND
public static final java.lang.String REMEMBER_IMPORT
public static final java.lang.String IMPORT_TYPE
public static final java.lang.String SOUND_SOURCE
public static final java.lang.String TAB_FILE_IMPORT
public static final java.lang.String TAB_FILE_SOUND
public static final java.lang.String TAB_FILE_EXPORT
public static final java.lang.String CHARSET_MPL
public static final java.lang.String CHARSET_MID
public static final java.lang.String CHARSET_EXPORT_MPL
public static final java.lang.String CHARSET_EXPORT_MID
public static final java.lang.String CBX_LANG_ENGLISH
public static final java.lang.String CBX_LANG_GERMAN
public static final java.lang.String[] CBX_LANGUAGES
public static java.util.ArrayList<ComboboxStringOption> CBX_LANGUAGE_OPTIONS
public static final java.lang.String CBX_NOTE_ID_INTERNATIONAL_LC
public static final java.lang.String CBX_NOTE_ID_INTERNATIONAL_UC
public static final java.lang.String CBX_NOTE_ID_ITALIAN_LC
public static final java.lang.String CBX_NOTE_ID_ITALIAN_UC
public static final java.lang.String CBX_NOTE_ID_GERMAN_LC
public static final java.lang.String CBX_NOTE_ID_GERMAN_UC
private static final java.lang.String[] CBX_NOTE_IDENTIFIERS
private static java.util.ArrayList<ComboboxStringOption> CBX_NOTE_OPTIONS
public static final java.lang.String CBX_OCTAVE_PLUS_MINUS_N
public static final java.lang.String CBX_OCTAVE_PLUS_MINUS
public static final java.lang.String CBX_OCTAVE_INTERNATIONAL
public static final java.lang.String CBX_OCTAVE_GERMAN
private static final java.lang.String[] CBX_OCTAVE_IDENTIFIERS
private static java.util.ArrayList<ComboboxStringOption> CBX_OCTAVE_OPTIONS
public static final java.lang.String CBX_HALFTONE_ID_SHARP
public static final java.lang.String CBX_HALFTONE_ID_DIESIS
public static final java.lang.String CBX_HALFTONE_ID_CIS
private static final java.lang.String[] CBX_HALFTONE_IDENTIFIERS
private static java.util.ArrayList<ComboboxStringOption> CBX_HALFTONE_OPTIONS
public static final java.lang.String CBX_SHARPFLAT_SHARP
public static final java.lang.String CBX_SHARPFLAT_FLAT
private static final java.lang.String[] CBX_SHARPFLAT_IDENTIFIERS
private static java.util.ArrayList<ComboboxStringOption> CBX_SHARPFLAT_OPTIONS
public static final java.lang.String CBX_SYNTAX_MIXED
public static final java.lang.String CBX_SYNTAX_LOWER
public static final java.lang.String CBX_SYNTAX_UPPER
private static final java.lang.String[] CBX_SYNTAX_IDENTIFIERS
private static java.util.ArrayList<ComboboxStringOption> CBX_SYNTAX_OPTIONS
public static final java.lang.String CBX_PERC_EN_1
public static final java.lang.String CBX_PERC_DE_1
private static final java.lang.String[] CBX_PERCUSSION_IDENTIFIERS
private static java.util.ArrayList<ComboboxStringOption> CBX_PERCUSSION_OPTIONS
public static final java.lang.String CBX_INSTR_EN_1
public static final java.lang.String CBX_INSTR_DE_1
private static final java.lang.String[] CBX_INSTRUMENT_IDENTIFIERS
private static java.util.ArrayList<ComboboxStringOption> CBX_INSTRUMENT_OPTIONS
public static final java.lang.String DC_MUST_ADD_TICK_COMMENTS
public static final java.lang.String DC_MUST_ADD_CONFIG
public static final java.lang.String DC_MUST_ADD_QUALITY_SCORE
public static final java.lang.String DC_MUST_ADD_STATISTICS
public static final java.lang.String DC_MUST_ADD_STRATEGY_STAT
public static final java.lang.String DC_LENGTH_STRATEGY
public static final java.lang.String DC_MIN_TICKS_ON_AT_480
public static final java.lang.String DC_MAX_TICKS_ON_AT_480
public static final java.lang.String DC_MIN_DURATION_TO_KEEP
public static final java.lang.String DC_MAX_DURATION_TO_KEEP
public static final java.lang.String DC_LENGTH_TICK_TOLERANCE
public static final java.lang.String DC_DURATION_RATIO_TOLERANCE
public static final java.lang.String DC_USE_PRE_DEFINED_CHORDS
public static final java.lang.String DC_CHORD_NOTE_ON_TOLERANCE
public static final java.lang.String DC_CHORD_NOTE_OFF_TOLERANCE
public static final java.lang.String DC_CHORD_VELOCITY_TOLERANCE
public static final java.lang.String DC_USE_DOTTED_NOTES
public static final java.lang.String DC_USE_DOTTED_RESTS
public static final java.lang.String DC_USE_TRIPLETTED_NOTES
public static final java.lang.String DC_USE_TRIPLETTED_RESTS
public static final java.lang.String DC_USE_KARAOKE
public static final java.lang.String DC_ALL_SYLLABLES_ORPHANED
public static final java.lang.String DC_ORPHANED_SYLLABLES
public static final java.lang.String DC_KARAOKE_ONE_CHANNEL
public static final java.lang.String DC_CTRL_CHANGE_MODE
public static final java.lang.String DC_SYNTAX_TYPE
public static final java.lang.String DC_ELEMENTS_PER_LINE
public static final java.lang.String DC_USE_BARLINES
public static final java.lang.String DC_MAX_BARLINE_TOL
public static final java.lang.String DC_EXTRA_GLOBALS_STR
public static final java.lang.String AU_ENCODING
public static final java.lang.String AU_SAMPLE_SIZE_BITS
public static final java.lang.String AU_SAMPLE_RATE
public static final java.lang.String AU_CHANNELS
public static final java.lang.String AU_IS_BIG_ENDIAN
private static java.io.File configFile
private static java.util.HashMap<java.lang.String,java.lang.String> defaults
private static java.util.TreeMap<java.lang.String,java.util.TreeSet<KeyBinding>> defaultBindings
private static java.util.HashMap<java.lang.String,java.lang.String> dcDefaults
private static java.util.HashMap<java.lang.String,java.lang.String> auDefaults
private static java.util.TreeMap<java.lang.String,java.lang.String> config
private static java.util.TreeMap<java.lang.String,java.util.TreeSet<KeyBinding>> keyBindings
private Config()
This class is only used statically so a public constructor is not needed.
public static void init()
Initializes the configuration on startup. This includes:
public static void restoreDefaults(java.lang.String homeDir)
Sets the current configuration to the default configuration. Must be public because we must be able to call it from test classes as well.
homeDir
- Home directory of the current userpublic static java.util.HashMap<java.lang.String,java.lang.String> getDefaultDecompileConfig()
Initializes all default decompile configuration values and copies them to the current config.
public static java.util.HashMap<java.lang.String,java.lang.String> getDefaultAudioExportConfig()
Initializes all default audio export configuration values and copies them to the current config.
private static void restoreDefaultKeyBindings()
Initializes all key default key bindings and uses copies of them for the real key bindings
private static void addDefaultKeyBinding(java.lang.String id, int keyCode, int mods)
Adds a key binding to the default structures.
id
- Key binding identifier.keyCode
- Key code to be added.mods
- Modifiers to be added.private static void readConfigFile()
Reads the config file and sets the current configuration accordingly. Does not do anything, if the command line option –ignore-local-config has been used.
public static void writeConfigFile()
Saves the current configuration to the config file. Does not do anything, if the command line option –ignore-local-config has been used.
This is called if the main GUI window is closed.
private static void parseConfig(java.lang.String line)
Reads a line of the config file. Sets the according configuration element like it is configured in that line.
line
- The line of the config file to be parsedpublic static void set(java.lang.String key, java.lang.String value)
Sets a configuration element.
key
- config keyvalue
- config valuepublic static java.lang.String get(java.lang.String key)
Reads and returns the config value according to the given key.
key
- Config keypublic static java.util.TreeSet<KeyBinding> getKeyBindings(java.lang.String id)
Reads and returns the configured key bindings according to the given identifier. The key binding is the combination of a key code and a value for the used modifiers like SHIFT, CTRL, and so on.
id
- key binding identifierpublic static void initLocale()
Sets the localization according to the configured language.
public static MidicaTreeModel getKeyBindingTreeModel()
Creates and returns a tree model for the currently configured key bindings.
public static void addKeyBinding(java.lang.String id, KeyBinding binding)
Adds a new key binding. This is called when the user manually adds a new key binding.
id
- the ID describing the action for the key bindingbinding
- the key binding to be added to the actionpublic static void removeKeyBinding(java.lang.String id, java.lang.String bindingDesc)
Removes the given key binding. This is called when the user manually removes a key binding.
id
- the ID describing the action for the key bindingbindingDesc
- short string describing the key binding uniquelypublic static void resetKeyBindingsToDefault(java.lang.String id)
Resets the key bindings belonging to the specified action to the default.
id
- the ID describing the action for the key bindingpublic static void resetAllKeyBindingsToDefault()
Resets all key bindings to the default value.
private static void setKeyBindingIdInConfig(java.lang.String id, java.util.TreeSet<KeyBinding> bindings)
Creates and sets a config value for key bindings to be written into the config file later.
id
- the ID describing the action for the key bindingbindings
- key bindings of the action to be setprivate static void initComboBoxes()
Fills the configuration comboboxes in the GUI. This is done by initializing the data models (ConfigComboboxModel
) of the corresponding comboboxes.
public static java.lang.String getConfiguredSharpOrFlat(boolean sharp)
Returns the currently configured sharp or flat symbol.
sharp
- true for the sharp symbol, false for the flat symbolpublic static boolean isFlatConfigured()
Checks if the configured half tone symbol is sharp or flat. Only needed for some special cases when parsing the key signature.