📄 config.java
字号:
/*
* Config.
*
* JavaZOOM : jlgui@javazoom.net
* http://www.javazoom.net
*
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jlgui.player.amp.util;
import java.io.File;
import java.util.StringTokenizer;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javazoom.jlgui.player.amp.util.ini.Configuration;
/**
* This class provides all parameters for jlGui coming from a file.
*/
public class Config
{
public static String[] protocols = { "http:", "file:", "ftp:", "https:", "ftps:", "jar:" };
public static String TAGINFO_POLICY_FILE = "file";
public static String TAGINFO_POLICY_ALL = "all";
public static String TAGINFO_POLICY_NONE = "none";
private static String CONFIG_FILE_NAME = "jlgui.ini";
private Configuration _config = null;
// configuration keys
private static final String LAST_URL = "last_url",
LAST_DIR = "last_dir",
ORIGINE_X = "origine_x",
ORIGINE_Y = "origine_y",
LAST_SKIN = "last_skin",
LAST_SKIN_DIR = "last_skin_dir",
EXTENSIONS = "allowed_extensions",
PLAYLIST_IMPL = "playlist_impl",
TAGINFO_MPEG_IMPL = "taginfo_mpeg_impl",
TAGINFO_OGGVORBIS_IMPL = "taginfo_oggvorbis_impl",
TAGINFO_APE_IMPL = "taginfo_ape_impl",
TAGINFO_FLAC_IMPL = "taginfo_flac_impl",
LAST_PLAYLIST = "last_playlist",
PROXY_SERVER = "proxy_server",
PROXY_PORT = "proxy_port",
PROXY_LOGIN = "proxy_login",
PROXY_PASSWORD = "proxy_password",
PLAYLIST_ENABLED = "playlist_enabled",
SHUFFLE_ENABLED = "shuffle_enabled",
REPEAT_ENABLED = "repeat_enabled",
EQUALIZER_ENABLED = "equalizer_enabled",
EQUALIZER_ON = "equalizer_on",
EQUALIZER_AUTO = "equalizer_auto",
LAST_EQUALIZER = "last_equalizer",
SCREEN_LIMIT = "screen_limit",
TAGINFO_POLICY = "taginfo_policy",
VOLUME_VALUE = "volume_value",
AUDIO_DEVICE = "audio_device",
VISUAL_MODE = "visual_mode";
private static Config _instance = null;
private String _audioDevice = "";
private String _visualMode = "";
private String _extensions = "m3u,pls,wsz,snd,aifc,aif,wav,au,mp1,mp2,mp3,ogg,spx,flac,ape,mac";
private String _lastUrl = "";
private String _lastDir = "";
private String _lastSkinDir = "";
private String _lastEqualizer = "";
private String _defaultSkin = "";
private String _playlist = "javazoom.jlgui.player.amp.playlist.BasePlaylist";
private String _taginfoMpeg = "javazoom.jlgui.player.amp.tag.MpegInfo";
private String _taginfoOggVorbis = "javazoom.jlgui.player.amp.tag.OggVorbisInfo";
private String _taginfoAPE = "javazoom.jlgui.player.amp.tag.APEInfo";
private String _taginfoFlac = "javazoom.jlgui.player.amp.tag.FlacInfo";
private String _playlistFilename = "";
private int _x = 0;
private int _y = 0;
private String _proxyServer = "";
private String _proxyLogin = "";
private String _proxyPassword = "";
private int _proxyPort = -1;
private int _volume = -1;
private boolean _playlistEnabled = false;
private boolean _shuffleEnabled = false;
private boolean _repeatEnabled = false;
private boolean _equalizerEnabled = false;
private boolean _equalizerOn = false;
private boolean _equalizerAuto = false;
private boolean _screenLimit = false;
private String _taginfoPolicy = TAGINFO_POLICY_FILE;
private JFrame topParent = null;
private ImageIcon iconParent = null;
private Config()
{
}
/**
* Returns Config instance.
*/
public synchronized static Config getInstance()
{
if (_instance == null)
{
_instance = new Config();
}
return _instance;
}
public void setTopParent(JFrame frame)
{
topParent = frame;
}
public JFrame getTopParent()
{
if (topParent == null)
{
topParent = new JFrame();
}
return topParent;
}
public void setIconParent(ImageIcon icon)
{
iconParent = icon;
}
public ImageIcon getIconParent()
{
return iconParent;
}
/**
* Returns JavaSound audio device.
* @return String
*/
public String getAudioDevice()
{
return _audioDevice;
}
/**
* Set JavaSound audio device.
* @param dev String
*/
public void setAudioDevice(String dev)
{
_audioDevice = dev;
}
/**
* Return visual mode.
* @return
*/
public String getVisualMode()
{
return _visualMode;
}
/**
* Set visual mode.
* @param mode
*/
public void setVisualMode(String mode)
{
_visualMode = mode;
}
/**
* Returns playlist filename.
*/
public String getPlaylistFilename()
{
return _playlistFilename;
}
/**
* Sets playlist filename.
*/
public void setPlaylistFilename(String pl)
{
_playlistFilename = pl;
}
/**
* Returns last equalizer values.
*/
public int[] getLastEqualizer()
{
int[] vals = null;
if ((_lastEqualizer != null) && (!_lastEqualizer.equals("")))
{
vals = new int[11];
int i = 0;
StringTokenizer st = new StringTokenizer(_lastEqualizer, ",");
while (st.hasMoreTokens())
{
String v = st.nextToken();
vals[i++] = Integer.parseInt(v);
}
}
return vals;
}
/**
* Sets last equalizer values.
*/
public void setLastEqualizer(int[] vals)
{
if (vals != null)
{
String dump = "";
for (int i = 0; i < vals.length; i++)
{
dump = dump + vals[i] + ",";
}
_lastEqualizer = dump.substring(0, (dump.length() - 1));
}
}
/**
* Return screen limit flag.
*
* @return is screen limit flag
*/
public boolean isScreenLimit()
{
return _screenLimit;
}
/**
* Set screen limit flag.
*
* @param b
*/
public void setScreenLimit(boolean b)
{
_screenLimit = b;
}
/**
* Returns last URL.
*/
public String getLastURL()
{
return _lastUrl;
}
/**
* Sets last URL.
*/
public void setLastURL(String url)
{
_lastUrl = url;
}
/**
* Returns last Directory.
*/
public String getLastDir()
{
if ((_lastDir != null) && (!_lastDir.endsWith(File.separator)))
{
_lastDir = _lastDir + File.separator;
}
return _lastDir;
}
/**
* Sets last Directory.
*/
public void setLastDir(String dir)
{
_lastDir = dir;
if ((_lastDir != null) && (!_lastDir.endsWith(File.separator)))
{
_lastDir = _lastDir + File.separator;
}
}
/**
* Returns last skin directory.
*/
public String getLastSkinDir()
{
if ((_lastSkinDir != null) && (!_lastSkinDir.endsWith(File.separator)))
{
_lastSkinDir = _lastSkinDir + File.separator;
}
return _lastSkinDir;
}
/**
* Sets last skin directory.
*/
public void setLastSkinDir(String dir)
{
_lastSkinDir = dir;
if ((_lastSkinDir != null) && (!_lastSkinDir.endsWith(File.separator)))
{
_lastSkinDir = _lastSkinDir + File.separator;
}
}
/**
* Returns audio extensions.
*/
public String getExtensions()
{
return _extensions;
}
/**
* Returns proxy server.
*/
public String getProxyServer()
{
return _proxyServer;
}
/**
* Returns proxy port.
*/
public int getProxyPort()
{
return _proxyPort;
}
/**
* Returns volume value.
*/
public int getVolume()
{
return _volume;
}
/**
* Returns volume value.
*/
public void setVolume(int vol)
{
_volume = vol;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -