Diverse wijzigingen mbt loggen en activate/deactivate aangebracht. jlgui player wordt niet gebruikt, dus verwijderd.

This commit is contained in:
Bram Veenboer
2011-06-03 12:37:02 +00:00
parent 84fb300464
commit c0e4c10b07
122 changed files with 221 additions and 18449 deletions

View File

@@ -1,102 +0,0 @@
/*
* BasicController.
*
* 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.basicplayer;
import java.io.File;
import java.io.InputStream;
import java.net.URL;
/**
* This interface defines player controls available.
*/
public interface BasicController
{
/**
* Open inputstream to play.
* @param in
* @throws BasicPlayerException
*/
public void open(InputStream in) throws BasicPlayerException;
/**
* Open file to play.
* @param file
* @throws BasicPlayerException
*/
public void open(File file) throws BasicPlayerException;
/**
* Open URL to play.
* @param url
* @throws BasicPlayerException
*/
public void open(URL url) throws BasicPlayerException;
/**
* Skip bytes.
* @param bytes
* @return bytes skipped according to audio frames constraint.
* @throws BasicPlayerException
*/
public long seek(long bytes) throws BasicPlayerException;
/**
* Start playback.
* @throws BasicPlayerException
*/
public void play() throws BasicPlayerException;
/**
* Stop playback.
* @throws BasicPlayerException
*/
public void stop() throws BasicPlayerException;
/**
* Pause playback.
* @throws BasicPlayerException
*/
public void pause() throws BasicPlayerException;
/**
* Resume playback.
* @throws BasicPlayerException
*/
public void resume() throws BasicPlayerException;
/**
* Sets Pan (Balance) value.
* Linear scale : -1.0 <--> +1.0
* @param pan value from -1.0 to +1.0
* @throws BasicPlayerException
*/
public void setPan(double pan) throws BasicPlayerException;
/**
* Sets Gain value.
* Linear scale 0.0 <--> 1.0
* @param gain value from 0.0 to 1.0
* @throws BasicPlayerException
*/
public void setGain(double gain) throws BasicPlayerException;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,121 +0,0 @@
/*
* BasicPlayerEvent.
*
* 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.basicplayer;
/**
* This class implements player events.
*/
public class BasicPlayerEvent
{
public static final int UNKNOWN = -1;
public static final int OPENING = 0;
public static final int OPENED = 1;
public static final int PLAYING = 2;
public static final int STOPPED = 3;
public static final int PAUSED = 4;
public static final int RESUMED = 5;
public static final int SEEKING = 6;
public static final int SEEKED = 7;
public static final int EOM = 8;
public static final int PAN = 9;
public static final int GAIN = 10;
private int code = UNKNOWN;
private int position = -1;
private double value = -1.0;
private Object source = null;
private Object description = null;
/**
* Constructor
* @param source of the event
* @param code of the envent
* @param position optional stream position
* @param value opitional control value
* @param desc optional description
*/
public BasicPlayerEvent(Object source, int code, int position, double value, Object desc)
{
this.value = value;
this.position = position;
this.source = source;
this.code = code;
this.description = desc;
}
/**
* Return code of the event triggered.
* @return
*/
public int getCode()
{
return code;
}
/**
* Return position in the stream when event occured.
* @return
*/
public int getPosition()
{
return position;
}
/**
* Return value related to event triggered.
* @return
*/
public double getValue()
{
return value;
}
/**
* Return description.
* @return
*/
public Object getDescription()
{
return description;
}
public Object getSource()
{
return source;
}
public String toString()
{
if (code == OPENED) return "OPENED:" + position;
else if (code == OPENING) return "OPENING:" + position + ":" + description;
else if (code == PLAYING) return "PLAYING:" + position;
else if (code == STOPPED) return "STOPPED:" + position;
else if (code == PAUSED) return "PAUSED:" + position;
else if (code == RESUMED) return "RESUMED:" + position;
else if (code == SEEKING) return "SEEKING:" + position;
else if (code == SEEKED) return "SEEKED:" + position;
else if (code == EOM) return "EOM:" + position;
else if (code == PAN) return "PAN:" + value;
else if (code == GAIN) return "GAIN:" + value;
else return "UNKNOWN:" + position;
}
}

View File

@@ -1,73 +0,0 @@
/*
* BasicPlayerEventLauncher.
*
* 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.basicplayer;
import java.util.Collection;
import java.util.Iterator;
/**
* This class implements a threaded events launcher.
*/
public class BasicPlayerEventLauncher extends Thread
{
private int code = -1;
private int position = -1;
private double value = 0.0;
private Object description = null;
private Collection listeners = null;
private Object source = null;
/**
* Contructor.
* @param code
* @param position
* @param value
* @param description
* @param listeners
* @param source
*/
public BasicPlayerEventLauncher(int code, int position, double value, Object description, Collection listeners, Object source)
{
super();
this.code = code;
this.position = position;
this.value = value;
this.description = description;
this.listeners = listeners;
this.source = source;
}
public void run()
{
if (listeners != null)
{
Iterator it = listeners.iterator();
while (it.hasNext())
{
BasicPlayerListener bpl = (BasicPlayerListener) it.next();
BasicPlayerEvent event = new BasicPlayerEvent(source, code, position, value, description);
bpl.stateUpdated(event);
}
}
}
}

View File

@@ -1,107 +0,0 @@
/*
* BasicPlayerException.
*
* 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.basicplayer;
import java.io.PrintStream;
import java.io.PrintWriter;
/**
* This class implements custom exception for basicplayer.
*/
public class BasicPlayerException extends Exception
{
public static final String GAINCONTROLNOTSUPPORTED = "Gain control not supported";
public static final String PANCONTROLNOTSUPPORTED = "Pan control not supported";
public static final String WAITERROR = "Wait error";
public static final String CANNOTINITLINE = "Cannot init line";
public static final String SKIPNOTSUPPORTED = "Skip not supported";
private Throwable cause = null;
public BasicPlayerException()
{
super();
}
public BasicPlayerException(String msg)
{
super(msg);
}
public BasicPlayerException(Throwable cause)
{
super();
this.cause = cause;
}
public BasicPlayerException(String msg, Throwable cause)
{
super(msg);
this.cause = cause;
}
public Throwable getCause()
{
return cause;
}
/**
* Returns the detail message string of this throwable. If it was
* created with a null message, returns the following:
* (cause==null ? null : cause.toString()).
*/
public String getMessage()
{
if (super.getMessage() != null)
{
return super.getMessage();
}
else if (cause != null)
{
return cause.toString();
}
else
{
return null;
}
}
public void printStackTrace()
{
printStackTrace(System.err);
}
public void printStackTrace(PrintStream out)
{
synchronized (out)
{
PrintWriter pw = new PrintWriter(out, false);
printStackTrace(pw);
pw.flush();
}
}
public void printStackTrace(PrintWriter out)
{
if (cause != null) cause.printStackTrace(out);
}
}

View File

@@ -1,72 +0,0 @@
/*
* BasicPlayerListener.
*
* 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.basicplayer;
import java.util.Map;
/**
* This interface defines callbacks methods that will be notified
* for all registered BasicPlayerListener of BasicPlayer.
*/
public interface BasicPlayerListener
{
/**
* Open callback, stream is ready to play.
*
* properties map includes audio format dependant features such as
* bitrate, duration, frequency, channels, number of frames, vbr flag,
* id3v2/id3v1 (for MP3 only), comments (for Ogg Vorbis), ...
*
* @param stream could be File, URL or InputStream
* @param properties audio stream properties.
*/
public void opened(Object stream, Map properties);
/**
* Progress callback while playing.
*
* This method is called severals time per seconds while playing.
* properties map includes audio format features such as
* instant bitrate, microseconds position, current frame number, ...
*
* @param bytesread from encoded stream.
* @param microseconds elapsed (<b>reseted after a seek !</b>).
* @param pcmdata PCM samples.
* @param properties audio stream parameters.
*/
public void progress(int bytesread, long microseconds, byte[] pcmdata, Map properties);
/**
* Notification callback for basicplayer events such as opened, eom ...
*
* @param event
*/
public void stateUpdated(BasicPlayerEvent event);
/**
* A handle to the BasicPlayer, plugins may control the player through
* the controller (play, stop, ...)
* @param controller : a handle to the player
*/
public void setController(BasicController controller);
}

View File

@@ -1,40 +0,0 @@
/*
* Loader.
*
* 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;
import java.awt.Point;
public interface Loader
{
public void loaded();
public void close();
public void minimize();
public Point getLocation();
public void togglePlaylist(boolean enabled);
public void toggleEqualizer(boolean enabled);
}

View File

@@ -1,99 +0,0 @@
/*
* PlayerActionEvent.
*
* 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;
import java.awt.event.ActionEvent;
public class PlayerActionEvent extends ActionEvent
{
public static final String ACPREVIOUS = "Previous";
public static final String ACPLAY = "Play";
public static final String ACPAUSE = "Pause";
public static final String ACSTOP = "Stop";
public static final String ACNEXT = "Next";
public static final String ACEJECT = "Eject";
public static final String ACEQUALIZER = "EqualizerUI";
public static final String ACPLAYLIST = "Playlist";
public static final String ACSHUFFLE = "Shuffle";
public static final String ACREPEAT = "Repeat";
public static final String ACVOLUME = "Volume";
public static final String ACBALANCE = "Balance";
public static final String ACTITLEBAR = "TitleBar";
public static final String ACEXIT = "Exit";
public static final String ACMINIMIZE = "Minimize";
public static final String ACPOSBAR = "Seek";
public static final String MIPLAYFILE = "PlayFileMI";
public static final String MIPLAYLOCATION = "PlayLocationMI";
public static final String MIPLAYLIST = "PlaylistMI";
public static final String MIEQUALIZER = "EqualizerMI";
public static final String MIPREFERENCES = "PreferencesMI";
public static final String MISKINBROWSER = "SkinBrowserMI";
public static final String MILOADSKIN = "LoadSkinMI";
public static final String MIJUMPFILE = "JumpFileMI";
public static final String MISTOP = "StopMI";
public static final String EQSLIDER = "SliderEQ";
public static final String ACEQPRESETS = "PresetsEQ";
public static final String ACEQONOFF = "OnOffEQ";
public static final String ACEQAUTO = "AutoEQ";
public static final String ACPLUP = "ScrollUpPL";
public static final String ACPLDOWN = "ScrollDownPL";
public static final String ACPLINFO = "InfoPL";
public static final String ACPLPLAY = "PlayPL";
public static final String ACPLREMOVE = "RemovePL";
public static final String ACPLADDPOPUP = "AddPopupPL";
public static final String ACPLADDFILE = "AddFilePL";
public static final String ACPLADDDIR = "AddDirPL";
public static final String ACPLADDURL = "AddURLPL";
public static final String ACPLREMOVEPOPUP = "RemovePopupPL";
public static final String ACPLREMOVEMISC = "RemoveMiscPL";
public static final String ACPLREMOVESEL = "RemoveSelPL";
public static final String ACPLREMOVEALL = "RemoveAllPL";
public static final String ACPLREMOVECROP = "RemoveCropPL";
public static final String ACPLSELPOPUP = "SelectPopupPL";
public static final String ACPLSELALL = "SelectAllPL";
public static final String ACPLSELZERO = "SelectZeroPL";
public static final String ACPLSELINV = "SelectInvPL";
public static final String ACPLMISCPOPUP = "MiscPopupPL";
public static final String ACPLMISCOPTS = "MiscOptsPL";
public static final String ACPLMISCFILE = "MiscFilePL";
public static final String ACPLMISCSORT = "MiscSortPL";
public static final String ACPLLISTPOPUP = "ListPopupPL";
public static final String ACPLLISTLOAD = "ListLoadPL";
public static final String ACPLLISTSAVE = "ListSavePL";
public static final String ACPLLISTNEW = "ListNewPL";
public PlayerActionEvent(Object source, int id, String command)
{
super(source, id, command);
}
public PlayerActionEvent(Object source, int id, String command, int modifiers)
{
super(source, id, command, modifiers);
}
public PlayerActionEvent(Object source, int id, String command, long when, int modifiers)
{
super(source, id, command, when, modifiers);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,500 +0,0 @@
/*
* StandalonePlayer.
*
* 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;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.net.URL;
import java.util.Iterator;
import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JWindow;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javazoom.jlgui.basicplayer.BasicPlayer;
import javazoom.jlgui.player.amp.skin.DragAdapter;
import javazoom.jlgui.player.amp.skin.Skin;
import javazoom.jlgui.player.amp.util.Config;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class StandalonePlayer extends JFrame implements Loader
{
private static Log log = LogFactory.getLog(StandalonePlayer.class);
/*-- Run parameters --*/
private String initConfig = "jlgui.ini";
private String initSong = null;
private String showPlaylist = null;
private String showEqualizer = null;
private String showDsp = null;
private String skinPath = null;
private String skinVersion = "1"; // 1, 2, for different Volume.bmp
private boolean autoRun = false;
/*-- Front-end --*/
private PlayerUI mp = null;
private JWindow eqWin = null;
private JWindow plWin = null;
private int eqFactor = 2;
private Config config = null;
private boolean playlistfound = false;
public StandalonePlayer()
{
super();
}
/**
* @param args
*/
public static void main(String[] args)
{
final StandalonePlayer player = new StandalonePlayer();
player.parseParameters(args);
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
player.loadUI();
player.loadJS();
player.loadPlaylist();
player.boot();
}
});
}
/**
* Initialize the player front-end.
* @param args
*/
private void parseParameters(String[] args)
{
String currentArg = null;
String currentValue = null;
for (int i = 0; i < args.length; i++)
{
currentArg = args[i];
if (currentArg.startsWith("-"))
{
if (currentArg.toLowerCase().equals("-init"))
{
i++;
if (i >= args.length) usage("init value missing");
currentValue = args[i];
if (Config.startWithProtocol(currentValue)) initConfig = currentValue;
else initConfig = currentValue.replace('\\', '/').replace('/', java.io.File.separatorChar);
}
else if (currentArg.toLowerCase().equals("-song"))
{
i++;
if (i >= args.length) usage("song value missing");
currentValue = args[i];
if (Config.startWithProtocol(currentValue)) initSong = currentValue;
else initSong = currentValue.replace('\\', '/').replace('/', java.io.File.separatorChar);
}
else if (currentArg.toLowerCase().equals("-start"))
{
autoRun = true;
}
else if (currentArg.toLowerCase().equals("-showplaylist"))
{
showPlaylist = "true";
}
else if (currentArg.toLowerCase().equals("-showequalizer"))
{
showEqualizer = "true";
}
else if (currentArg.toLowerCase().equals("-disabledsp"))
{
showDsp = "false";
}
else if (currentArg.toLowerCase().equals("-skin"))
{
i++;
if (i >= args.length) usage("skin value missing");
currentValue = args[i];
if (Config.startWithProtocol(currentValue)) skinPath = currentValue;
else skinPath = currentValue.replace('\\', '/').replace('/', java.io.File.separatorChar);
}
else if (currentArg.toLowerCase().equals("-v"))
{
i++;
if (i >= args.length) usage("skin version value missing");
skinVersion = args[i];
}
else usage("Unknown parameter : " + currentArg);
}
else
{
usage("Invalid parameter :" + currentArg);
}
}
}
private void boot()
{
// Go to playlist begining if needed.
/*if ((playlist != null) && (playlistfound == true))
{
if (playlist.getPlaylistSize() > 0) mp.pressNext();
} */
// Start playing if needed.
if (autoRun == true)
{
mp.pressStart();
}
}
/**
* Instantiate low-level player.
*/
public void loadJS()
{
BasicPlayer bplayer = new BasicPlayer();
List mixers = bplayer.getMixers();
if (mixers != null)
{
Iterator it = mixers.iterator();
String mixer = config.getAudioDevice();
boolean mixerFound = false;
if ((mixer != null) && (mixer.length() > 0))
{
// Check if mixer is valid.
while (it.hasNext())
{
if (((String) it.next()).equals(mixer))
{
bplayer.setMixerName(mixer);
mixerFound = true;
break;
}
}
}
if (mixerFound == false)
{
// Use first mixer available.
it = mixers.iterator();
if (it.hasNext())
{
mixer = (String) it.next();
bplayer.setMixerName(mixer);
}
}
}
// Register the front-end to low-level player events.
bplayer.addBasicPlayerListener(mp);
// Adds controls for front-end to low-level player.
mp.setController(bplayer);
}
/**
* Load playlist.
*/
public void loadPlaylist()
{
if ((initSong != null) && (!initSong.equals(""))) playlistfound = mp.loadPlaylist(initSong);
else playlistfound = mp.loadPlaylist(config.getPlaylistFilename());
}
/**
* Load player front-end.
*/
public void loadUI()
{
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception ex)
{
log.debug(ex);
}
config = Config.getInstance();
config.load(initConfig);
//config.setTopParent(this);
if (showPlaylist != null)
{
if (showPlaylist.equalsIgnoreCase("true"))
{
config.setPlaylistEnabled(true);
}
else
{
config.setPlaylistEnabled(false);
}
}
if (showEqualizer != null)
{
if (showEqualizer.equalsIgnoreCase("true"))
{
config.setEqualizerEnabled(true);
}
else
{
config.setEqualizerEnabled(false);
}
}
if (config.isPlaylistEnabled()) eqFactor = 2;
else eqFactor = 1;
setTitle(Skin.TITLETEXT);
ClassLoader cl = this.getClass().getClassLoader();
URL iconURL = cl.getResource("javazoom/jlgui/player/amp/jlguiicon.gif");
if (iconURL != null)
{
ImageIcon jlguiIcon = new ImageIcon(iconURL);
setIconImage(jlguiIcon.getImage());
config.setIconParent(jlguiIcon);
}
setUndecorated(true);
mp = new PlayerUI();
if ((showDsp != null) && (showDsp.equalsIgnoreCase("false")))
{
mp.getSkin().setDspEnabled(false);
}
if (skinPath != null)
{
mp.getSkin().setPath(skinPath);
}
mp.getSkin().setSkinVersion(skinVersion);
mp.loadUI(this);
setContentPane(mp);
setSize(new Dimension(mp.getSkin().getMainWidth(), mp.getSkin().getMainHeight()));
/*eqWin = new JWindow(this);
eqWin.setContentPane(mp.getEqualizerUI());
eqWin.setSize(new Dimension(mp.getSkin().getMainWidth(), mp.getSkin().getMainHeight()));
eqWin.setVisible(false);
plWin = new JWindow(this);
plWin.setContentPane(mp.getPlaylistUI());
plWin.setSize(new Dimension(mp.getSkin().getMainWidth(), mp.getSkin().getMainHeight()));
plWin.setVisible(false);*/
// Window listener
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
// Closing window (Alt+F4 under Win32)
close();
}
});
// Keyboard shortcut
//setKeyBoardShortcut();
// Display front-end
setLocation(config.getXLocation(), config.getYLocation());
setVisible(true);
//if (config.isPlaylistEnabled()) plWin.setVisible(true);
//if (config.isEqualizerEnabled()) eqWin.setVisible(true);
}
/**
* Install keyboard shortcuts.
*/
/*public void setKeyBoardShortcut()
{
KeyStroke jKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_J, 0, false);
KeyStroke ctrlPKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_MASK, false);
KeyStroke altSKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.ALT_MASK, false);
KeyStroke vKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_V, 0, false);
String searchID = "TAGSEARCH";
String preferenceID = "PREFERENCES";
String skinbrowserID = "SKINBROWSER";
String stopplayerID = "STOPPLAYER";
Action searchAction = new AbstractAction()
{
public void actionPerformed(ActionEvent e)
{
if (mp != null) mp.processJumpToFile(e.getModifiers());
}
};
Action preferencesAction = new AbstractAction()
{
public void actionPerformed(ActionEvent e)
{
if (mp != null) mp.processPreferences(e.getModifiers());
}
};
Action skinbrowserAction = new AbstractAction()
{
public void actionPerformed(ActionEvent e)
{
if (mp != null) mp.processSkinBrowser(e.getModifiers());
}
};
Action stopplayerAction = new AbstractAction()
{
public void actionPerformed(ActionEvent e)
{
if (mp != null) mp.processStop(MouseEvent.BUTTON1_MASK);
}
};
setKeyboardAction(searchID, jKeyStroke, searchAction);
setKeyboardAction(preferenceID, ctrlPKeyStroke, preferencesAction);
setKeyboardAction(skinbrowserID, altSKeyStroke, skinbrowserAction);
setKeyboardAction(stopplayerID, vKeyStroke, stopplayerAction);
}*/
/**
* Set keyboard key shortcut for the whole player.
* @param id
* @param key
* @param action
*/
/*public void setKeyboardAction(String id, KeyStroke key, Action action)
{
mp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(key, id);
mp.getActionMap().put(id, action);
mp.getPlaylistUI().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(key, id);
mp.getPlaylistUI().getActionMap().put(id, action);
mp.getEqualizerUI().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(key, id);
mp.getEqualizerUI().getActionMap().put(id, action);
}*/
public void loaded()
{
/*DragAdapter dragAdapter = new DragAdapter(this);
mp.getSkin().getAcTitleBar().addMouseListener(dragAdapter);
mp.getSkin().getAcTitleBar().addMouseMotionListener(dragAdapter);*/
}
public void close()
{
log.info("Close player");
config.setLocation(getLocation().x, getLocation().y);
config.save();
dispose();
exit(0);
}
/* (non-Javadoc)
* @see javazoom.jlgui.player.amp.skin.Loader#togglePlaylist(boolean)
*/
/*public void togglePlaylist(boolean enabled)
{
if (plWin != null)
{
if (enabled)
{
if (config.isEqualizerEnabled())
{
eqFactor = 2;
eqWin.setLocation(getLocation().x, getLocation().y + mp.getSkin().getMainHeight() * eqFactor);
}
plWin.setVisible(true);
}
else
{
plWin.setVisible(false);
if (config.isEqualizerEnabled())
{
eqFactor = 1;
eqWin.setLocation(getLocation().x, getLocation().y + mp.getSkin().getMainHeight() * eqFactor);
}
}
}
}*/
public void toggleEqualizer(boolean enabled)
{
if (eqWin != null)
{
if (enabled)
{
if (config.isPlaylistEnabled()) eqFactor = 2;
else eqFactor = 1;
eqWin.setLocation(getLocation().x, getLocation().y + mp.getSkin().getMainHeight() * eqFactor);
eqWin.setVisible(true);
}
else
{
eqWin.setVisible(false);
}
}
}
public void minimize()
{
setState(JFrame.ICONIFIED);
}
public void setLocation(int x, int y)
{
super.setLocation(x, y);
if (plWin != null)
{
plWin.setLocation(getLocation().x, getLocation().y + getHeight());
}
if (eqWin != null)
{
eqWin.setLocation(getLocation().x, getLocation().y + eqFactor * getHeight());
}
}
public Point getLocation()
{
return super.getLocation();
}
/**
* Kills the player.
* @param status
*/
public void exit(int status)
{
System.exit(status);
}
/**
* Displays usage.
* @param msg
*/
protected static void usage(String msg)
{
System.out.println(Skin.TITLETEXT + " : " + msg);
System.out.println("");
System.out.println(Skin.TITLETEXT + " : Usage");
System.out.println(" java javazoom.jlgui.player.amp.Player [-skin skinFilename] [-song audioFilename] [-start] [-showplaylist] [-showequalizer] [-disabledsp] [-init configFilename] [-v skinversion]");
System.out.println("");
System.out.println(" skinFilename : Filename or URL to a Winamp Skin2.x");
System.out.println(" audioFilename : Filename or URL to initial song or playlist");
System.out.println(" start : Starts playing song (from the playlist)");
System.out.println(" showplaylist : Show playlist");
System.out.println(" showequalizer : Show equalizer");
System.out.println(" disabledsp : Disable spectrum/time visual");
System.out.println("");
System.out.println(" Advanced parameters :");
System.out.println(" skinversion : 1 or 2 (default 1)");
System.out.println(" configFilename : Filename or URL to jlGui initial configuration (playlist,skin,parameters ...)");
System.out.println(" Initial configuration won't be overriden by -skin and -song arguments");
System.out.println("");
System.out.println("Homepage : http://www.javazoom.net");
System.exit(0);
}
}

View File

@@ -1,139 +0,0 @@
/*
* ControlCurve.
*
* 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.equalizer.ui;
import java.awt.Polygon;
public abstract class ControlCurve
{
static final int EPSILON = 36; /* square of distance for picking */
protected Polygon pts;
protected int selection = -1;
int maxHeight = -1;
int minHeight = -1;
public ControlCurve()
{
pts = new Polygon();
}
public int boundY(int y)
{
int ny = y;
if ((minHeight >= 0) && (y < minHeight))
{
ny = 0;
}
if ((maxHeight >= 0) && (y >= maxHeight))
{
ny = maxHeight - 1;
}
return ny;
}
public void setMaxHeight(int h)
{
maxHeight = h;
}
public void setMinHeight(int h)
{
minHeight = h;
}
/**
* Return index of control point near to (x,y) or -1 if nothing near.
* @param x
* @param y
* @return
*/
public int selectPoint(int x, int y)
{
int mind = Integer.MAX_VALUE;
selection = -1;
for (int i = 0; i < pts.npoints; i++)
{
int d = sqr(pts.xpoints[i] - x) + sqr(pts.ypoints[i] - y);
if (d < mind && d < EPSILON)
{
mind = d;
selection = i;
}
}
return selection;
}
/**
* Square of an int.
* @param x
* @return
*/
static int sqr(int x)
{
return x * x;
}
/**
* Add a control point, return index of new control point.
* @param x
* @param y
* @return
*/
public int addPoint(int x, int y)
{
pts.addPoint(x, y);
return selection = pts.npoints - 1;
}
/**
* Set selected control point.
* @param x
* @param y
*/
public void setPoint(int x, int y)
{
if (selection >= 0)
{
pts.xpoints[selection] = x;
pts.ypoints[selection] = y;
}
}
/**
* Remove selected control point.
*/
public void removePoint()
{
if (selection >= 0)
{
pts.npoints--;
for (int i = selection; i < pts.npoints; i++)
{
pts.xpoints[i] = pts.xpoints[i + 1];
pts.ypoints[i] = pts.ypoints[i + 1];
}
}
}
public abstract Polygon getPolyline();
}

View File

@@ -1,46 +0,0 @@
/*
* Cubic.
*
* 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.equalizer.ui;
public class Cubic
{
float a, b, c, d; /* a + b*u + c*u^2 +d*u^3 */
public Cubic(float a, float b, float c, float d)
{
this.a = a;
this.b = b;
this.c = c;
this.d = d;
}
/**
* Evaluate cubic.
* @param u
* @return
*/
public float eval(float u)
{
return (((d * u) + c) * u + b) * u + a;
}
}

View File

@@ -1,441 +0,0 @@
/*
* EqualizerUI.
*
* 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.equalizer.ui;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javazoom.jlgui.player.amp.PlayerActionEvent;
import javazoom.jlgui.player.amp.PlayerUI;
import javazoom.jlgui.player.amp.skin.AbsoluteLayout;
import javazoom.jlgui.player.amp.skin.DropTargetAdapter;
import javazoom.jlgui.player.amp.skin.ImageBorder;
import javazoom.jlgui.player.amp.skin.Skin;
import javazoom.jlgui.player.amp.util.Config;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* This class implements an equalizer UI.
* <p/>
* The equalizer consists of 32 band-pass filters.
* Each band of the equalizer can take on a fractional value between
* -1.0 and +1.0.
* At -1.0, the input signal is attenuated by 6dB, at +1.0 the signal is
* amplified by 6dB.
*/
public class EqualizerUI extends JPanel implements ActionListener, ChangeListener
{
private static Log log = LogFactory.getLog(EqualizerUI.class);
private int minGain = 0;
private int maxGain = 100;
private int[] gainValue = { 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50 };
private int[] PRESET_NORMAL = { 50, 50, 50, 50, 50, 50, 50, 50, 50, 50 };
private int[] PRESET_CLASSICAL = { 50, 50, 50, 50, 50, 50, 70, 70, 70, 76 };
private int[] PRESET_CLUB = { 50, 50, 42, 34, 34, 34, 42, 50, 50, 50 };
private int[] PRESET_DANCE = { 26, 34, 46, 50, 50, 66, 70, 70, 50, 50 };
private int[] PRESET_FULLBASS = { 26, 26, 26, 36, 46, 62, 76, 78, 78, 78 };
private int[] PRESET_FULLBASSTREBLE = { 34, 34, 50, 68, 62, 46, 28, 22, 18, 18 };
private int[] PRESET_FULLTREBLE = { 78, 78, 78, 62, 42, 24, 8, 8, 8, 8 };
private int[] PRESET_LAPTOP = { 38, 22, 36, 60, 58, 46, 38, 24, 16, 14 };
private int[] PRESET_LIVE = { 66, 50, 40, 36, 34, 34, 40, 42, 42, 42 };
private int[] PRESET_PARTY = { 32, 32, 50, 50, 50, 50, 50, 50, 32, 32 };
private int[] PRESET_POP = { 56, 38, 32, 30, 38, 54, 56, 56, 54, 54 };
private int[] PRESET_REGGAE = { 48, 48, 50, 66, 48, 34, 34, 48, 48, 48 };
private int[] PRESET_ROCK = { 32, 38, 64, 72, 56, 40, 28, 24, 24, 24 };
private int[] PRESET_TECHNO = { 30, 34, 48, 66, 64, 48, 30, 24, 24, 28 };
private Config config = null;
private PlayerUI player = null;
private Skin ui = null;
private JPopupMenu mainpopup = null;
public static final int LINEARDIST = 1;
public static final int OVERDIST = 2;
private float[] bands = null;
private int[] eqgains = null;
private int eqdist = OVERDIST;
public EqualizerUI()
{
super();
setDoubleBuffered(true);
config = Config.getInstance();
eqgains = new int[10];
setLayout(new AbsoluteLayout());
int[] vals = config.getLastEqualizer();
if (vals != null)
{
for (int h = 0; h < vals.length; h++)
{
gainValue[h] = vals[h];
}
}
// DnD support disabled.
DropTargetAdapter dnd = new DropTargetAdapter()
{
public void processDrop(Object data)
{
return;
}
};
DropTarget dt = new DropTarget(this, DnDConstants.ACTION_COPY, dnd, false);
}
/**
* Return skin.
* @return
*/
public Skin getSkin()
{
return ui;
}
/**
* Set skin.
* @param ui
*/
public void setSkin(Skin ui)
{
this.ui = ui;
}
/**
* Set parent player.
* @param mp
*/
public void setPlayer(PlayerUI mp)
{
player = mp;
}
public void loadUI()
{
log.info("Load EqualizerUI (EDT=" + SwingUtilities.isEventDispatchThread() + ")");
removeAll();
// Background
ImageBorder border = new ImageBorder();
border.setImage(ui.getEqualizerImage());
setBorder(border);
// On/Off
add(ui.getAcEqOnOff(), ui.getAcEqOnOff().getConstraints());
ui.getAcEqOnOff().removeActionListener(this);
ui.getAcEqOnOff().addActionListener(this);
// Auto
add(ui.getAcEqAuto(), ui.getAcEqAuto().getConstraints());
ui.getAcEqAuto().removeActionListener(this);
ui.getAcEqAuto().addActionListener(this);
// Sliders
add(ui.getAcEqPresets(), ui.getAcEqPresets().getConstraints());
for (int i = 0; i < ui.getAcEqSliders().length; i++)
{
add(ui.getAcEqSliders()[i], ui.getAcEqSliders()[i].getConstraints());
ui.getAcEqSliders()[i].setValue(maxGain - gainValue[i]);
ui.getAcEqSliders()[i].removeChangeListener(this);
ui.getAcEqSliders()[i].addChangeListener(this);
}
if (ui.getSpline() != null)
{
ui.getSpline().setValues(gainValue);
add(ui.getSpline(), ui.getSpline().getConstraints());
}
// Popup menu on TitleBar
mainpopup = new JPopupMenu();
String[] presets = { "Normal", "Classical", "Club", "Dance", "Full Bass", "Full Bass & Treble", "Full Treble", "Laptop", "Live", "Party", "Pop", "Reggae", "Rock", "Techno" };
JMenuItem mi;
for (int p = 0; p < presets.length; p++)
{
mi = new JMenuItem(presets[p]);
mi.removeActionListener(this);
mi.addActionListener(this);
mainpopup.add(mi);
}
ui.getAcEqPresets().removeActionListener(this);
ui.getAcEqPresets().addActionListener(this);
validate();
}
/* (non-Javadoc)
* @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent)
*/
public void stateChanged(ChangeEvent e)
{
for (int i = 0; i < ui.getAcEqSliders().length; i++)
{
gainValue[i] = maxGain - ui.getAcEqSliders()[i].getValue();
}
if (ui.getSpline() != null) ui.getSpline().repaint();
// Apply equalizer values.
synchronizeEqualizer();
}
/**
* Set bands array for equalizer.
*
* @param bands
*/
public void setBands(float[] bands)
{
this.bands = bands;
}
/**
* Apply equalizer function.
*
* @param gains
* @param min
* @param max
*/
public void updateBands(int[] gains, int min, int max)
{
if ((gains != null) && (bands != null))
{
int j = 0;
float gvalj = (gains[j] * 2.0f / (max - min) * 1.0f) - 1.0f;
float gvalj1 = (gains[j + 1] * 2.0f / (max - min) * 1.0f) - 1.0f;
// Linear distribution : 10 values => 32 values.
if (eqdist == LINEARDIST)
{
float a = (gvalj1 - gvalj) * 1.0f;
float b = gvalj * 1.0f - (gvalj1 - gvalj) * j;
// x=s*x'
float s = (gains.length - 1) * 1.0f / (bands.length - 1) * 1.0f;
for (int i = 0; i < bands.length; i++)
{
float ind = s * i;
if (ind > (j + 1))
{
j++;
gvalj = (gains[j] * 2.0f / (max - min) * 1.0f) - 1.0f;
gvalj1 = (gains[j + 1] * 2.0f / (max - min) * 1.0f) - 1.0f;
a = (gvalj1 - gvalj) * 1.0f;
b = gvalj * 1.0f - (gvalj1 - gvalj) * j;
}
// a*x+b
bands[i] = a * i * 1.0f * s + b;
}
}
// Over distribution : 10 values => 10 first value of 32 values.
else if (eqdist == OVERDIST)
{
for (int i = 0; i < gains.length; i++)
{
bands[i] = (gains[i] * 2.0f / (max - min) * 1.0f) - 1.0f;
}
}
}
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent e)
{
String cmd = e.getActionCommand();
log.debug("Action=" + cmd + " (EDT=" + SwingUtilities.isEventDispatchThread() + ")");
// On/Off
if (cmd.equals(PlayerActionEvent.ACEQONOFF))
{
if (ui.getAcEqOnOff().isSelected())
{
config.setEqualizerOn(true);
}
else
{
config.setEqualizerOn(false);
}
synchronizeEqualizer();
}
// Auto
else if (cmd.equals(PlayerActionEvent.ACEQAUTO))
{
if (ui.getAcEqAuto().isSelected())
{
config.setEqualizerAuto(true);
}
else
{
config.setEqualizerAuto(false);
}
}
// Presets
else if (cmd.equals(PlayerActionEvent.ACEQPRESETS))
{
if (e.getModifiers() == MouseEvent.BUTTON1_MASK)
{
mainpopup.show(this, ui.getAcEqPresets().getLocation().x, ui.getAcEqPresets().getLocation().y);
}
}
else if (cmd.equals("Normal"))
{
updateSliders(PRESET_NORMAL);
synchronizeEqualizer();
}
else if (cmd.equals("Classical"))
{
updateSliders(PRESET_CLASSICAL);
synchronizeEqualizer();
}
else if (cmd.equals("Club"))
{
updateSliders(PRESET_CLUB);
synchronizeEqualizer();
}
else if (cmd.equals("Dance"))
{
updateSliders(PRESET_DANCE);
synchronizeEqualizer();
}
else if (cmd.equals("Full Bass"))
{
updateSliders(PRESET_FULLBASS);
synchronizeEqualizer();
}
else if (cmd.equals("Full Bass & Treble"))
{
updateSliders(PRESET_FULLBASSTREBLE);
synchronizeEqualizer();
}
else if (cmd.equals("Full Treble"))
{
updateSliders(PRESET_FULLTREBLE);
synchronizeEqualizer();
}
else if (cmd.equals("Laptop"))
{
updateSliders(PRESET_LAPTOP);
synchronizeEqualizer();
}
else if (cmd.equals("Live"))
{
updateSliders(PRESET_LIVE);
synchronizeEqualizer();
}
else if (cmd.equals("Party"))
{
updateSliders(PRESET_PARTY);
synchronizeEqualizer();
}
else if (cmd.equals("Pop"))
{
updateSliders(PRESET_POP);
synchronizeEqualizer();
}
else if (cmd.equals("Reggae"))
{
updateSliders(PRESET_REGGAE);
synchronizeEqualizer();
}
else if (cmd.equals("Rock"))
{
updateSliders(PRESET_ROCK);
synchronizeEqualizer();
}
else if (cmd.equals("Techno"))
{
updateSliders(PRESET_TECHNO);
synchronizeEqualizer();
}
}
/**
* Update sliders from gains array.
*
* @param gains
*/
public void updateSliders(int[] gains)
{
if (gains != null)
{
for (int i = 0; i < gains.length; i++)
{
gainValue[i + 1] = gains[i];
ui.getAcEqSliders()[i + 1].setValue(maxGain - gainValue[i + 1]);
}
}
}
/**
* Apply equalizer values.
*/
public void synchronizeEqualizer()
{
config.setLastEqualizer(gainValue);
if (config.isEqualizerOn())
{
for (int j = 0; j < eqgains.length; j++)
{
eqgains[j] = -gainValue[j + 1] + maxGain;
}
updateBands(eqgains, minGain, maxGain);
}
else
{
for (int j = 0; j < eqgains.length; j++)
{
eqgains[j] = (maxGain - minGain) / 2;
}
updateBands(eqgains, minGain, maxGain);
}
}
/**
* Return equalizer bands distribution.
* @return
*/
public int getEqdist()
{
return eqdist;
}
/**
* Set equalizer bands distribution.
* @param i
*/
public void setEqdist(int i)
{
eqdist = i;
}
/**
* Simulates "On/Off" selection.
*/
public void pressOnOff()
{
ui.getAcEqOnOff().doClick();
}
/**
* Simulates "Auto" selection.
*/
public void pressAuto()
{
ui.getAcEqAuto().doClick();
}
}

View File

@@ -1,108 +0,0 @@
/*
* NaturalSpline.
*
* 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.equalizer.ui;
import java.awt.Polygon;
public class NaturalSpline extends ControlCurve
{
public final int STEPS = 12;
public NaturalSpline()
{
super();
}
/*
* calculates the natural cubic spline that interpolates y[0], y[1], ...
* y[n] The first segment is returned as C[0].a + C[0].b*u + C[0].c*u^2 +
* C[0].d*u^3 0<=u <1 the other segments are in C[1], C[2], ... C[n-1]
*/
Cubic[] calcNaturalCubic(int n, int[] x)
{
float[] gamma = new float[n + 1];
float[] delta = new float[n + 1];
float[] D = new float[n + 1];
int i;
/*
* We solve the equation [2 1 ] [D[0]] [3(x[1] - x[0]) ] |1 4 1 | |D[1]|
* |3(x[2] - x[0]) | | 1 4 1 | | . | = | . | | ..... | | . | | . | | 1 4
* 1| | . | |3(x[n] - x[n-2])| [ 1 2] [D[n]] [3(x[n] - x[n-1])]
*
* by using row operations to convert the matrix to upper triangular and
* then back sustitution. The D[i] are the derivatives at the knots.
*/
gamma[0] = 1.0f / 2.0f;
for (i = 1; i < n; i++)
{
gamma[i] = 1 / (4 - gamma[i - 1]);
}
gamma[n] = 1 / (2 - gamma[n - 1]);
delta[0] = 3 * (x[1] - x[0]) * gamma[0];
for (i = 1; i < n; i++)
{
delta[i] = (3 * (x[i + 1] - x[i - 1]) - delta[i - 1]) * gamma[i];
}
delta[n] = (3 * (x[n] - x[n - 1]) - delta[n - 1]) * gamma[n];
D[n] = delta[n];
for (i = n - 1; i >= 0; i--)
{
D[i] = delta[i] - gamma[i] * D[i + 1];
}
/* now compute the coefficients of the cubics */
Cubic[] C = new Cubic[n];
for (i = 0; i < n; i++)
{
C[i] = new Cubic((float) x[i], D[i], 3 * (x[i + 1] - x[i]) - 2 * D[i] - D[i + 1], 2 * (x[i] - x[i + 1]) + D[i] + D[i + 1]);
}
return C;
}
/**
* Return a cubic spline.
*/
public Polygon getPolyline()
{
Polygon p = new Polygon();
if (pts.npoints >= 2)
{
Cubic[] X = calcNaturalCubic(pts.npoints - 1, pts.xpoints);
Cubic[] Y = calcNaturalCubic(pts.npoints - 1, pts.ypoints);
// very crude technique - just break each segment up into steps lines
int x = (int) Math.round(X[0].eval(0));
int y = (int) Math.round(Y[0].eval(0));
p.addPoint(x, boundY(y));
for (int i = 0; i < X.length; i++)
{
for (int j = 1; j <= STEPS; j++)
{
float u = j / (float) STEPS;
x = Math.round(X[i].eval(u));
y = Math.round(Y[i].eval(u));
p.addPoint(x, boundY(y));
}
}
}
return p;
}
}

View File

@@ -1,133 +0,0 @@
/*
* SplinePanel.
*
* 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.equalizer.ui;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Polygon;
import javax.swing.JPanel;
import javazoom.jlgui.player.amp.skin.AbsoluteConstraints;
public class SplinePanel extends JPanel
{
private AbsoluteConstraints constraints = null;
private Image backgroundImage = null;
private Image barImage = null;
private int[] values = null;
private Color[] gradient = null;
public SplinePanel()
{
super();
setDoubleBuffered(true);
setLayout(null);
}
public Color[] getGradient()
{
return gradient;
}
public void setGradient(Color[] gradient)
{
this.gradient = gradient;
}
public void setConstraints(AbsoluteConstraints cnts)
{
constraints = cnts;
}
public AbsoluteConstraints getConstraints()
{
return constraints;
}
public Image getBarImage()
{
return barImage;
}
public void setBarImage(Image barImage)
{
this.barImage = barImage;
}
public Image getBackgroundImage()
{
return backgroundImage;
}
public void setBackgroundImage(Image backgroundImage)
{
this.backgroundImage = backgroundImage;
}
public int[] getValues()
{
return values;
}
public void setValues(int[] values)
{
this.values = values;
}
/* (non-Javadoc)
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
*/
public void paintComponent(Graphics g)
{
if (backgroundImage != null) g.drawImage(backgroundImage, 0, 0, null);
if (barImage != null) g.drawImage(barImage, 0, getHeight()/2, null);
if ((values != null) && (values.length > 0))
{
NaturalSpline curve = new NaturalSpline();
float dx = 1.0f * getWidth() / (values.length - 2);
int h = getHeight();
curve.setMaxHeight(h);
curve.setMinHeight(0);
for (int i = 1; i < values.length; i++)
{
int x1 = (int) Math.round(dx * (i - 1));
int y1 = ((int) Math.round((h * values[i] / 100)));
y1 = curve.boundY(y1);
curve.addPoint(x1, y1);
}
Polygon spline = curve.getPolyline();
if (gradient != null)
{
for (int i=0;i<(spline.npoints-1);i++)
{
g.setColor(gradient[spline.ypoints[i]]);
g.drawLine(spline.xpoints[i], spline.ypoints[i],spline.xpoints[i+1], spline.ypoints[i+1]);
}
}
else
{
g.drawPolyline(spline.xpoints, spline.ypoints, spline.npoints);
}
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 566 B

View File

@@ -1,586 +0,0 @@
/*
* BasePlaylist.
*
* 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.playlist;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Collection;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.Vector;
import javazoom.jlgui.player.amp.util.Config;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* BasePlaylist implementation.
* This class implements Playlist interface using a Vector.
* It support .m3u and .pls playlist format.
*/
public class BasePlaylist implements Playlist
{
protected Vector _playlist = null;
protected int _cursorPos = -1;
protected boolean isModified;
protected String M3UHome = null;
protected String PLSHome = null;
private static Log log = LogFactory.getLog(BasePlaylist.class);
/**
* Constructor.
*/
public BasePlaylist()
{
_playlist = new Vector();
}
public boolean isModified()
{
return isModified;
}
/**
* Loads playlist as M3U format.
*/
public boolean load(String filename)
{
setModified(true);
boolean loaded = false;
if ((filename != null) && (filename.toLowerCase().endsWith(".m3u")))
{
loaded = loadM3U(filename);
}
else if ((filename != null) && (filename.toLowerCase().endsWith(".pls")))
{
loaded = loadPLS(filename);
}
return loaded;
}
/**
* Load playlist from M3U format.
*
* @param filename
* @return
*/
protected boolean loadM3U(String filename)
{
Config config = Config.getInstance();
_playlist = new Vector();
boolean loaded = false;
BufferedReader br = null;
try
{
// Playlist from URL ? (http:, ftp:, file: ....)
if (Config.startWithProtocol(filename))
{
br = new BufferedReader(new InputStreamReader((new URL(filename)).openStream()));
}
else
{
br = new BufferedReader(new FileReader(filename));
}
String line = null;
String songName = null;
String songFile = null;
String songLength = null;
while ((line = br.readLine()) != null)
{
if (line.trim().length() == 0) continue;
if (line.startsWith("#"))
{
if (line.toUpperCase().startsWith("#EXTINF"))
{
int indA = line.indexOf(",", 0);
if (indA != -1)
{
songName = line.substring(indA + 1, line.length());
}
int indB = line.indexOf(":", 0);
if (indB != -1)
{
if (indB < indA) songLength = (line.substring(indB + 1, indA)).trim();
}
}
}
else
{
songFile = line;
if (songName == null) songName = songFile;
if (songLength == null) songLength = "-1";
PlaylistItem pli = null;
if (Config.startWithProtocol(songFile))
{
// URL.
pli = new PlaylistItem(songName, songFile, Long.parseLong(songLength), false);
}
else
{
// File.
File f = new File(songFile);
if (f.exists())
{
pli = new PlaylistItem(songName, songFile, Long.parseLong(songLength), true);
}
else
{
// Try relative path.
f = new File(config.getLastDir() + songFile);
if (f.exists())
{
pli = new PlaylistItem(songName, config.getLastDir() + songFile, Long.parseLong(songLength), true);
}
else
{
// Try optional M3U home.
if (M3UHome != null)
{
if (Config.startWithProtocol(M3UHome))
{
pli = new PlaylistItem(songName, M3UHome + songFile, Long.parseLong(songLength), false);
}
else
{
pli = new PlaylistItem(songName, M3UHome + songFile, Long.parseLong(songLength), true);
}
}
}
}
}
if (pli != null) this.appendItem(pli);
songFile = null;
songName = null;
songLength = null;
}
}
loaded = true;
}
catch (Exception e)
{
log.debug("Can't load .m3u playlist", e);
}
finally
{
try
{
if (br != null)
{
br.close();
}
}
catch (Exception ioe)
{
log.info("Can't close .m3u playlist", ioe);
}
}
return loaded;
}
/**
* Load playlist in PLS format.
*
* @param filename
* @return
*/
protected boolean loadPLS(String filename)
{
Config config = Config.getInstance();
_playlist = new Vector();
boolean loaded = false;
BufferedReader br = null;
try
{
// Playlist from URL ? (http:, ftp:, file: ....)
if (Config.startWithProtocol(filename))
{
br = new BufferedReader(new InputStreamReader((new URL(filename)).openStream()));
}
else
{
br = new BufferedReader(new FileReader(filename));
}
String line = null;
String songName = null;
String songFile = null;
String songLength = null;
while ((line = br.readLine()) != null)
{
if (line.trim().length() == 0) continue;
if ((line.toLowerCase().startsWith("file")))
{
StringTokenizer st = new StringTokenizer(line, "=");
st.nextToken();
songFile = st.nextToken().trim();
}
else if ((line.toLowerCase().startsWith("title")))
{
StringTokenizer st = new StringTokenizer(line, "=");
st.nextToken();
songName = st.nextToken().trim();
}
else if ((line.toLowerCase().startsWith("length")))
{
StringTokenizer st = new StringTokenizer(line, "=");
st.nextToken();
songLength = st.nextToken().trim();
}
// New entry ?
if (songFile != null)
{
PlaylistItem pli = null;
if (songName == null) songName = songFile;
if (songLength == null) songLength = "-1";
if (Config.startWithProtocol(songFile))
{
// URL.
pli = new PlaylistItem(songName, songFile, Long.parseLong(songLength), false);
}
else
{
// File.
File f = new File(songFile);
if (f.exists())
{
pli = new PlaylistItem(songName, songFile, Long.parseLong(songLength), true);
}
else
{
// Try relative path.
f = new File(config.getLastDir() + songFile);
if (f.exists())
{
pli = new PlaylistItem(songName, config.getLastDir() + songFile, Long.parseLong(songLength), true);
}
else
{
// Try optional PLS home.
if (PLSHome != null)
{
if (Config.startWithProtocol(PLSHome))
{
pli = new PlaylistItem(songName, PLSHome + songFile, Long.parseLong(songLength), false);
}
else
{
pli = new PlaylistItem(songName, PLSHome + songFile, Long.parseLong(songLength), true);
}
}
}
}
}
if (pli != null) this.appendItem(pli);
songName = null;
songFile = null;
songLength = null;
}
}
loaded = true;
}
catch (Exception e)
{
log.debug("Can't load .pls playlist", e);
}
finally
{
try
{
if (br != null)
{
br.close();
}
}
catch (Exception ioe)
{
log.info("Can't close .pls playlist", ioe);
}
}
return loaded;
}
/**
* Saves playlist in M3U format.
*/
public boolean save(String filename)
{
// Implemented by C.K
if (_playlist != null)
{
BufferedWriter bw = null;
try
{
bw = new BufferedWriter(new FileWriter(filename));
bw.write("#EXTM3U");
bw.newLine();
Iterator it = _playlist.iterator();
while (it.hasNext())
{
PlaylistItem pli = (PlaylistItem) it.next();
bw.write("#EXTINF:" + pli.getM3UExtInf());
bw.newLine();
bw.write(pli.getLocation());
bw.newLine();
}
return true;
}
catch (IOException e)
{
log.info("Can't save playlist", e);
}
finally
{
try
{
if (bw != null)
{
bw.close();
}
}
catch (IOException ioe)
{
log.info("Can't close playlist", ioe);
}
}
}
return false;
}
/**
* Adds item at a given position in the playlist.
*/
public void addItemAt(PlaylistItem pli, int pos)
{
_playlist.insertElementAt(pli, pos);
setModified(true);
}
/**
* Searchs and removes item from the playlist.
*/
public void removeItem(PlaylistItem pli)
{
_playlist.remove(pli);
setModified(true);
}
/**
* Removes item at a given position from the playlist.
*/
public void removeItemAt(int pos)
{
_playlist.removeElementAt(pos);
setModified(true);
}
/**
* Removes all items from the playlist.
*/
public void removeAllItems()
{
_playlist.removeAllElements();
_cursorPos = -1;
setModified(true);
}
/**
* Append item at the end of the playlist.
*/
public void appendItem(PlaylistItem pli)
{
_playlist.addElement(pli);
setModified(true);
}
/**
* Sorts items of the playlist.
*/
public void sortItems(int sortmode)
{
// TODO
}
/**
* Shuffles items in the playlist randomly
*/
public void shuffle()
{
int size = _playlist.size();
if (size < 2) { return; }
Vector v = _playlist;
_playlist = new Vector(size);
while ((size = v.size()) > 0)
{
_playlist.addElement(v.remove((int) (Math.random() * size)));
}
begin();
}
/**
* Moves the cursor at the top of the playlist.
*/
public void begin()
{
_cursorPos = -1;
if (getPlaylistSize() > 0)
{
_cursorPos = 0;
}
setModified(true);
}
/**
* Returns item at a given position from the playlist.
*/
public PlaylistItem getItemAt(int pos)
{
PlaylistItem pli = null;
pli = (PlaylistItem) _playlist.elementAt(pos);
return pli;
}
/**
* Returns a collection of playlist items.
*/
public Collection getAllItems()
{
// TODO
return null;
}
/**
* Returns then number of items in the playlist.
*/
public int getPlaylistSize()
{
return _playlist.size();
}
// Next methods will be used by the Player
/**
* Returns item matching to the cursor.
*/
public PlaylistItem getCursor()
{
if ((_cursorPos < 0) || (_cursorPos >= _playlist.size())) { return null; }
return getItemAt(_cursorPos);
}
/**
* Computes cursor position (next).
*/
public void nextCursor()
{
_cursorPos++;
}
/**
* Computes cursor position (previous).
*/
public void previousCursor()
{
_cursorPos--;
if (_cursorPos < 0)
{
_cursorPos = 0;
}
}
public boolean setModified(boolean set)
{
isModified = set;
return isModified;
}
public void setCursor(int index)
{
_cursorPos = index;
}
/**
* Returns selected index.
*/
public int getSelectedIndex()
{
return _cursorPos;
}
/**
* Returns index of playlist item.
*/
public int getIndex(PlaylistItem pli)
{
int pos = -1;
for (int i = 0; i < _playlist.size(); i++)
{
pos = i;
PlaylistItem p = (PlaylistItem) _playlist.elementAt(i);
if (p.equals(pli)) break;
}
return pos;
}
/**
* Get M3U home for relative playlist.
*
* @return
*/
public String getM3UHome()
{
return M3UHome;
}
/**
* Set optional M3U home for relative playlist.
*
* @param string
*/
public void setM3UHome(String string)
{
M3UHome = string;
}
/**
* Get PLS home for relative playlist.
*
* @return
*/
public String getPLSHome()
{
return PLSHome;
}
/**
* Set optional PLS home for relative playlist.
*
* @param string
*/
public void setPLSHome(String string)
{
PLSHome = string;
}
}

View File

@@ -1,138 +0,0 @@
/*
* Playlist.
*
* 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.playlist;
import java.util.Collection;
/**
* Playlist.
* This interface defines method that a playlist should implement.<br>
* A playlist provides a collection of item to play and a cursor to know
* which item is playing.
*/
public interface Playlist
{
// Next methods will be called by the Playlist UI.
/**
* Loads playlist.
*/
public boolean load(String filename);
/**
* Saves playlist.
*/
public boolean save(String filename);
/**
* Adds item at a given position in the playlist.
*/
public void addItemAt(PlaylistItem pli, int pos);
/**
* Searchs and removes item from the playlist.
*/
public void removeItem(PlaylistItem pli);
/**
* Removes item at a given position from the playlist.
*/
public void removeItemAt(int pos);
/**
* Removes all items in the playlist.
*/
public void removeAllItems();
/**
* Append item at the end of the playlist.
*/
public void appendItem(PlaylistItem pli);
/**
* Sorts items of the playlist.
*/
public void sortItems(int sortmode);
/**
* Returns item at a given position from the playlist.
*/
public PlaylistItem getItemAt(int pos);
/**
* Returns a collection of playlist items.
*/
public Collection getAllItems();
/**
* Returns then number of items in the playlist.
*/
public int getPlaylistSize();
// Next methods will be used by the Player
/**
* Randomly re-arranges the playlist.
*/
public void shuffle();
/**
* Returns item matching to the cursor.
*/
public PlaylistItem getCursor();
/**
* Moves the cursor at the begining of the Playlist.
*/
public void begin();
/**
* Returns item matching to the cursor.
*/
public int getSelectedIndex();
/**
* Returns index of playlist item.
*/
public int getIndex(PlaylistItem pli);
/**
* Computes cursor position (next).
*/
public void nextCursor();
/**
* Computes cursor position (previous).
*/
public void previousCursor();
/**
* Set the modification flag for the playlist
*/
boolean setModified(boolean set);
/**
* Checks the modification flag
*/
public boolean isModified();
void setCursor(int index);
}

View File

@@ -1,107 +0,0 @@
/*
* PlaylistFactory.
*
* 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.playlist;
import java.lang.reflect.Constructor;
import javazoom.jlgui.player.amp.util.Config;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* PlaylistFactory.
*/
public class PlaylistFactory
{
private static PlaylistFactory _instance = null;
private Playlist _playlistInstance = null;
private Config _config = null;
private static Log log = LogFactory.getLog(PlaylistFactory.class);
/**
* Constructor.
*/
private PlaylistFactory()
{
_config = Config.getInstance();
}
/**
* Returns instance of PlaylistFactory.
*/
public synchronized static PlaylistFactory getInstance()
{
if (_instance == null)
{
_instance = new PlaylistFactory();
}
return _instance;
}
/**
* Returns Playlist instantied from full qualified class name.
*/
public Playlist getPlaylist()
{
if (_playlistInstance == null)
{
String classname = _config.getPlaylistClassName();
boolean interfaceFound = false;
try
{
Class aClass = Class.forName(classname);
Class superClass = aClass;
// Looking for Playlist interface implementation.
while (superClass != null)
{
Class[] interfaces = superClass.getInterfaces();
for (int i = 0; i < interfaces.length; i++)
{
if ((interfaces[i].getName()).equals("javazoom.jlgui.player.amp.playlist.Playlist"))
{
interfaceFound = true;
break;
}
}
if (interfaceFound == true) break;
superClass = superClass.getSuperclass();
}
if (interfaceFound == false)
{
log.error("Error : Playlist implementation not found in " + classname + " hierarchy");
}
else
{
Class[] argsClass = new Class[] {};
Constructor c = aClass.getConstructor(argsClass);
_playlistInstance = (Playlist) (c.newInstance(null));
log.info(classname + " loaded");
}
}
catch (Exception e)
{
log.error("Error : " + classname + " : " + e.getMessage());
}
}
return _playlistInstance;
}
}

View File

@@ -1,302 +0,0 @@
/*
* PlaylistItem.
*
* 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.playlist;
import javazoom.jlgui.player.amp.tag.TagInfo;
import javazoom.jlgui.player.amp.tag.TagInfoFactory;
import javazoom.jlgui.player.amp.util.Config;
import javazoom.jlgui.player.amp.util.FileUtil;
/**
* This class implements item for playlist.
*/
public class PlaylistItem
{
protected String _name = null;
protected String _displayName = null;
protected String _location = null;
protected boolean _isFile = true;
protected long _seconds = -1;
protected boolean _isSelected = false; // add by JOHN YANG
protected TagInfo _taginfo = null;
protected PlaylistItem()
{
}
/**
* Contructor for playlist item.
*
* @param name Song name to be displayed
* @param location File or URL
* @param seconds Time length
* @param isFile true for File instance
*/
public PlaylistItem(String name, String location, long seconds, boolean isFile)
{
_name = name;
_seconds = seconds;
_isFile = isFile;
Config config = Config.getInstance();
if (config.getTaginfoPolicy().equals(Config.TAGINFO_POLICY_ALL))
{
// Read tag info for any File or URL. It could take time.
setLocation(location, true);
}
else if (config.getTaginfoPolicy().equals(Config.TAGINFO_POLICY_FILE))
{
// Read tag info for any File only not for URL.
if (_isFile) setLocation(location, true);
else setLocation(location, false);
}
else
{
// Do not read tag info.
setLocation(location, false);
}
}
/**
* Returns item name such as (hh:mm:ss) Title - Artist if available.
*
* @return
*/
public String getFormattedName()
{
if (_displayName == null)
{
if (_seconds > 0)
{
String length = getFormattedLength();
return "(" + length + ") " + _name;
}
else return _name;
}
// Name extracted from TagInfo or stream title.
else return _displayName;
}
public String getName()
{
return _name;
}
public String getLocation()
{
return _location;
}
/**
* Returns true if item to play is coming for a file.
*
* @return
*/
public boolean isFile()
{
return _isFile;
}
/**
* Set File flag for playslit item.
*
* @param b
*/
public void setFile(boolean b)
{
_isFile = b;
}
/**
* Returns playtime in seconds. If tag info is available then its playtime will be returned.
*
* @return playtime
*/
public long getLength()
{
if ((_taginfo != null) && (_taginfo.getPlayTime() > 0)) return _taginfo.getPlayTime();
else return _seconds;
}
public int getBitrate()
{
if (_taginfo != null) return _taginfo.getBitRate();
else return -1;
}
public int getSamplerate()
{
if (_taginfo != null) return _taginfo.getSamplingRate();
else return -1;
}
public int getChannels()
{
if (_taginfo != null) return _taginfo.getChannels();
else return -1;
}
public void setSelected(boolean mode)
{
_isSelected = mode;
}
public boolean isSelected()
{
return _isSelected;
}
/**
* Reads file comments/tags.
*
* @param l
*/
public void setLocation(String l)
{
setLocation(l, false);
}
/**
* Reads (or not) file comments/tags.
*
* @param l input location
* @param readInfo
*/
public void setLocation(String l, boolean readInfo)
{
_location = l;
if (readInfo == true)
{
// Read Audio Format and read tags/comments.
if ((_location != null) && (!_location.equals("")))
{
TagInfoFactory factory = TagInfoFactory.getInstance();
_taginfo = factory.getTagInfo(l);
}
}
_displayName = getFormattedDisplayName();
}
/**
* Returns item lenght such as hh:mm:ss
*
* @return formatted String.
*/
public String getFormattedLength()
{
long time = getLength();
String length = "";
if (time > -1)
{
int minutes = (int) Math.floor(time / 60);
int hours = (int) Math.floor(minutes / 60);
minutes = minutes - hours * 60;
int seconds = (int) (time - minutes * 60 - hours * 3600);
// Hours.
if (hours > 0)
{
length = length + FileUtil.rightPadString(hours + "", '0', 2) + ":";
}
length = length + FileUtil.rightPadString(minutes + "", '0', 2) + ":" + FileUtil.rightPadString(seconds + "", '0', 2);
}
else length = "" + time;
return length;
}
/**
* Returns item name such as (hh:mm:ss) Title - Artist
*
* @return formatted String.
*/
public String getFormattedDisplayName()
{
if (_taginfo == null) return null;
else
{
String length = getFormattedLength();
if ((_taginfo.getTitle() != null) && (!_taginfo.getTitle().equals("")) && (_taginfo.getArtist() != null) && (!_taginfo.getArtist().equals("")))
{
if (getLength() > 0) return ("(" + length + ") " + _taginfo.getTitle() + " - " + _taginfo.getArtist());
else return (_taginfo.getTitle() + " - " + _taginfo.getArtist());
}
else if ((_taginfo.getTitle() != null) && (!_taginfo.getTitle().equals("")))
{
if (getLength() > 0) return ("(" + length + ") " + _taginfo.getTitle());
else return (_taginfo.getTitle());
}
else
{
if (getLength() > 0) return ("(" + length + ") " + _name);
else return (_name);
}
}
}
public void setFormattedDisplayName(String fname)
{
_displayName = fname;
}
/**
* Return item name such as hh:mm:ss,Title,Artist
*
* @return formatted String.
*/
public String getM3UExtInf()
{
if (_taginfo == null)
{
return (_seconds + "," + _name);
}
else
{
if ((_taginfo.getTitle() != null) && (_taginfo.getArtist() != null))
{
return (getLength() + "," + _taginfo.getTitle() + " - " + _taginfo.getArtist());
}
else if (_taginfo.getTitle() != null)
{
return (getLength() + "," + _taginfo.getTitle());
}
else
{
return (_seconds + "," + _name);
}
}
}
/**
* Return TagInfo.
*
* @return
*/
public TagInfo getTagInfo()
{
if (_taginfo == null)
{
// Inspect location
setLocation(_location, true);
}
return _taginfo;
}
}

View File

@@ -1,882 +0,0 @@
/*
* PlaylistUI.
*
* 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.playlist.ui;
import java.awt.Graphics;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import java.util.StringTokenizer;
import java.util.Vector;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javazoom.jlgui.player.amp.PlayerActionEvent;
import javazoom.jlgui.player.amp.PlayerUI;
import javazoom.jlgui.player.amp.playlist.Playlist;
import javazoom.jlgui.player.amp.playlist.PlaylistItem;
import javazoom.jlgui.player.amp.skin.AbsoluteLayout;
import javazoom.jlgui.player.amp.skin.ActiveJButton;
import javazoom.jlgui.player.amp.skin.DropTargetAdapter;
import javazoom.jlgui.player.amp.skin.Skin;
import javazoom.jlgui.player.amp.skin.UrlDialog;
import javazoom.jlgui.player.amp.tag.TagInfo;
import javazoom.jlgui.player.amp.tag.TagInfoFactory;
import javazoom.jlgui.player.amp.tag.ui.TagInfoDialog;
import javazoom.jlgui.player.amp.util.Config;
import javazoom.jlgui.player.amp.util.FileSelector;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class PlaylistUI extends JPanel implements ActionListener, ChangeListener
{
private static Log log = LogFactory.getLog(PlaylistUI.class);
public static int MAXDEPTH = 4;
private Config config = null;
private Skin ui = null;
private Playlist playlist = null;
private PlayerUI player = null;
private int topIndex = 0;
private int currentSelection = -1;
private Vector exts = null;
private boolean isSearching = false;
private JPopupMenu fipopup = null;
public PlaylistUI()
{
super();
setDoubleBuffered(true);
setLayout(new AbsoluteLayout());
config = Config.getInstance();
addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
handleMouseClick(e);
}
});
// DnD support.
DropTargetAdapter dnd = new DropTargetAdapter()
{
public void processDrop(Object data)
{
processDnD(data);
}
};
DropTarget dt = new DropTarget(this, DnDConstants.ACTION_COPY, dnd, true);
}
public void setPlayer(PlayerUI mp)
{
player = mp;
}
public void setSkin(Skin skin)
{
ui = skin;
}
public Skin getSkin()
{
return ui;
}
public Playlist getPlaylist()
{
return playlist;
}
public void setPlaylist(Playlist playlist)
{
this.playlist = playlist;
}
public int getTopIndex()
{
return topIndex;
}
public void loadUI()
{
removeAll();
ui.getPlaylistPanel().setParent(this);
add(ui.getAcPlSlider(), ui.getAcPlSlider().getConstraints());
ui.getAcPlSlider().setValue(100);
ui.getAcPlSlider().removeChangeListener(this);
ui.getAcPlSlider().addChangeListener(this);
add(ui.getAcPlUp(), ui.getAcPlUp().getConstraints());
ui.getAcPlUp().removeActionListener(this);
ui.getAcPlUp().addActionListener(this);
add(ui.getAcPlDown(), ui.getAcPlDown().getConstraints());
ui.getAcPlDown().removeActionListener(this);
ui.getAcPlDown().addActionListener(this);
// Add menu
add(ui.getAcPlAdd(), ui.getAcPlAdd().getConstraints());
ui.getAcPlAdd().removeActionListener(this);
ui.getAcPlAdd().addActionListener(this);
add(ui.getAcPlAddPopup(), ui.getAcPlAddPopup().getConstraints());
ui.getAcPlAddPopup().setVisible(false);
ActiveJButton[] items = ui.getAcPlAddPopup().getItems();
for (int i = 0; i < items.length; i++)
{
items[i].addActionListener(this);
}
// Remove menu
add(ui.getAcPlRemove(), ui.getAcPlRemove().getConstraints());
ui.getAcPlRemove().removeActionListener(this);
ui.getAcPlRemove().addActionListener(this);
add(ui.getAcPlRemovePopup(), ui.getAcPlRemovePopup().getConstraints());
ui.getAcPlRemovePopup().setVisible(false);
items = ui.getAcPlRemovePopup().getItems();
for (int i = 0; i < items.length; i++)
{
items[i].removeActionListener(this);
items[i].addActionListener(this);
}
// Select menu
add(ui.getAcPlSelect(), ui.getAcPlSelect().getConstraints());
ui.getAcPlSelect().removeActionListener(this);
ui.getAcPlSelect().addActionListener(this);
add(ui.getAcPlSelectPopup(), ui.getAcPlSelectPopup().getConstraints());
ui.getAcPlSelectPopup().setVisible(false);
items = ui.getAcPlSelectPopup().getItems();
for (int i = 0; i < items.length; i++)
{
items[i].removeActionListener(this);
items[i].addActionListener(this);
}
// Misc menu
add(ui.getAcPlMisc(), ui.getAcPlMisc().getConstraints());
ui.getAcPlMisc().removeActionListener(this);
ui.getAcPlMisc().addActionListener(this);
add(ui.getAcPlMiscPopup(), ui.getAcPlMiscPopup().getConstraints());
ui.getAcPlMiscPopup().setVisible(false);
items = ui.getAcPlMiscPopup().getItems();
for (int i = 0; i < items.length; i++)
{
items[i].removeActionListener(this);
items[i].addActionListener(this);
}
// List menu
add(ui.getAcPlList(), ui.getAcPlList().getConstraints());
ui.getAcPlList().removeActionListener(this);
ui.getAcPlList().addActionListener(this);
add(ui.getAcPlListPopup(), ui.getAcPlListPopup().getConstraints());
ui.getAcPlListPopup().setVisible(false);
items = ui.getAcPlListPopup().getItems();
for (int i = 0; i < items.length; i++)
{
items[i].removeActionListener(this);
items[i].addActionListener(this);
}
// Popup menu
fipopup = new JPopupMenu();
JMenuItem mi = new JMenuItem(ui.getResource("playlist.popup.info"));
mi.setActionCommand(PlayerActionEvent.ACPLINFO);
mi.removeActionListener(this);
mi.addActionListener(this);
fipopup.add(mi);
fipopup.addSeparator();
mi = new JMenuItem(ui.getResource("playlist.popup.play"));
mi.setActionCommand(PlayerActionEvent.ACPLPLAY);
mi.removeActionListener(this);
mi.addActionListener(this);
fipopup.add(mi);
fipopup.addSeparator();
mi = new JMenuItem(ui.getResource("playlist.popup.remove"));
mi.setActionCommand(PlayerActionEvent.ACPLREMOVE);
mi.removeActionListener(this);
mi.addActionListener(this);
fipopup.add(mi);
validate();
repaint();
}
/**
* Initialize playlist.
*/
public void initPlayList()
{
topIndex = 0;
nextCursor();
}
/**
* Repaint the file list area and scroll it if necessary
*/
public void nextCursor()
{
currentSelection = playlist.getSelectedIndex();
int n = playlist.getPlaylistSize();
int nlines = ui.getPlaylistPanel().getLines();
while (currentSelection - topIndex > nlines - 1)
topIndex += 2;
if (topIndex >= n) topIndex = n - 1;
while (currentSelection < topIndex)
topIndex -= 2;
if (topIndex < 0) topIndex = 0;
resetScrollBar();
repaint();
}
/**
* Get the item index according to the mouse y position
* @param y
* @return
*/
protected int getIndex(int y)
{
int n0 = playlist.getPlaylistSize();
if (n0 == 0) return -1;
for (int n = 0; n < 100; n++)
{
if (ui.getPlaylistPanel().isIndexArea(y, n))
{
if (topIndex + n > n0 - 1) return -1;
return topIndex + n;
}
}
return -1;
}
/* (non-Javadoc)
* @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent)
*/
public void stateChanged(ChangeEvent e)
{
Object src = e.getSource();
//log.debug("State (EDT=" + SwingUtilities.isEventDispatchThread() + ")");
if (src == ui.getAcPlSlider())
{
int n = playlist.getPlaylistSize();
float dx = (100 - ui.getAcPlSlider().getValue()) / 100.0f;
int index = (int) (dx * (n - 1));
if (index != topIndex)
{
topIndex = index;
paintList();
}
}
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent e)
{
final ActionEvent evt = e;
new Thread("PlaylistUIActionEvent")
{
public void run()
{
processActionEvent(evt);
}
}.start();
}
/**
* Process action event.
* @param e
*/
public void processActionEvent(ActionEvent e)
{
String cmd = e.getActionCommand();
log.debug("Action=" + cmd + " (EDT=" + SwingUtilities.isEventDispatchThread() + ")");
int n = playlist.getPlaylistSize();
if (cmd.equals(PlayerActionEvent.ACPLUP))
{
topIndex--;
if (topIndex < 0) topIndex = 0;
resetScrollBar();
paintList();
}
else if (cmd.equals(PlayerActionEvent.ACPLDOWN))
{
topIndex++;
if (topIndex > n - 1) topIndex = n - 1;
resetScrollBar();
paintList();
}
else if (cmd.equals(PlayerActionEvent.ACPLADDPOPUP))
{
ui.getAcPlAdd().setVisible(false);
ui.getAcPlAddPopup().setVisible(true);
}
else if (cmd.equals(PlayerActionEvent.ACPLREMOVEPOPUP))
{
ui.getAcPlRemove().setVisible(false);
ui.getAcPlRemovePopup().setVisible(true);
}
else if (cmd.equals(PlayerActionEvent.ACPLSELPOPUP))
{
ui.getAcPlSelect().setVisible(false);
ui.getAcPlSelectPopup().setVisible(true);
}
else if (cmd.equals(PlayerActionEvent.ACPLMISCPOPUP))
{
ui.getAcPlMisc().setVisible(false);
ui.getAcPlMiscPopup().setVisible(true);
}
else if (cmd.equals(PlayerActionEvent.ACPLLISTPOPUP))
{
ui.getAcPlList().setVisible(false);
ui.getAcPlListPopup().setVisible(true);
}
else if (cmd.equals(PlayerActionEvent.ACPLINFO))
{
popupFileInfo();
}
else if (cmd.equals(PlayerActionEvent.ACPLPLAY))
{
int n0 = playlist.getPlaylistSize();
PlaylistItem pli = null;
for (int i = n0 - 1; i >= 0; i--)
{
pli = playlist.getItemAt(i);
if (pli.isSelected()) break;
}
// Play.
if ((pli != null) && (pli.getTagInfo() != null))
{
player.pressStop();
player.setCurrentSong(pli);
playlist.setCursor(playlist.getIndex(pli));
player.pressStart();
}
}
else if (cmd.equals(PlayerActionEvent.ACPLREMOVE))
{
delSelectedItems();
}
else if (cmd.equals(PlayerActionEvent.ACPLADDFILE))
{
ui.getAcPlAddPopup().setVisible(false);
ui.getAcPlAdd().setVisible(true);
File[] file = FileSelector.selectFile(player.getLoader(), FileSelector.OPEN, true, config.getExtensions(), ui.getResource("playlist.popup.add.file"), new File(config.getLastDir()));
if (FileSelector.getInstance().getDirectory() != null) config.setLastDir(FileSelector.getInstance().getDirectory().getPath());
addFiles(file);
}
else if (cmd.equals(PlayerActionEvent.ACPLADDURL))
{
ui.getAcPlAddPopup().setVisible(false);
ui.getAcPlAdd().setVisible(true);
UrlDialog UD = new UrlDialog(config.getTopParent(), ui.getResource("playlist.popup.add.url"), player.getLoader().getLocation().x, player.getLoader().getLocation().y + player.getHeight(), null);
UD.show();
if (UD.getFile() != null)
{
PlaylistItem pli = new PlaylistItem(UD.getFile(), UD.getURL(), -1, false);
playlist.appendItem(pli);
resetScrollBar();
repaint();
}
}
else if (cmd.equals(PlayerActionEvent.ACPLADDDIR))
{
ui.getAcPlAddPopup().setVisible(false);
ui.getAcPlAdd().setVisible(true);
File[] file = FileSelector.selectFile(player.getLoader(), FileSelector.DIRECTORY, false, "", ui.getResource("playlist.popup.add.dir"), new File(config.getLastDir()));
if (FileSelector.getInstance().getDirectory() != null) config.setLastDir(FileSelector.getInstance().getDirectory().getPath());
if (file == null || !file[0].isDirectory()) return;
// TODO - add message box for wrong filename
addDir(file[0]);
}
else if (cmd.equals(PlayerActionEvent.ACPLREMOVEALL))
{
ui.getAcPlRemovePopup().setVisible(false);
ui.getAcPlRemove().setVisible(true);
delAllItems();
}
else if (cmd.equals(PlayerActionEvent.ACPLREMOVESEL))
{
ui.getAcPlRemovePopup().setVisible(false);
ui.getAcPlRemove().setVisible(true);
delSelectedItems();
}
else if (cmd.equals(PlayerActionEvent.ACPLREMOVEMISC))
{
ui.getAcPlRemovePopup().setVisible(false);
ui.getAcPlRemove().setVisible(true);
// TODO
}
else if (cmd.equals(PlayerActionEvent.ACPLREMOVECROP))
{
ui.getAcPlRemovePopup().setVisible(false);
ui.getAcPlRemove().setVisible(true);
// TODO
}
else if (cmd.equals(PlayerActionEvent.ACPLSELALL))
{
ui.getAcPlSelectPopup().setVisible(false);
ui.getAcPlSelect().setVisible(true);
selFunctions(1);
}
else if (cmd.equals(PlayerActionEvent.ACPLSELINV))
{
ui.getAcPlSelectPopup().setVisible(false);
ui.getAcPlSelect().setVisible(true);
selFunctions(-1);
}
else if (cmd.equals(PlayerActionEvent.ACPLSELZERO))
{
ui.getAcPlSelectPopup().setVisible(false);
ui.getAcPlSelect().setVisible(true);
selFunctions(0);
}
else if (cmd.equals(PlayerActionEvent.ACPLMISCOPTS))
{
ui.getAcPlMiscPopup().setVisible(false);
ui.getAcPlMisc().setVisible(true);
// TODO
}
else if (cmd.equals(PlayerActionEvent.ACPLMISCFILE))
{
ui.getAcPlMiscPopup().setVisible(false);
ui.getAcPlMisc().setVisible(true);
popupFileInfo();
}
else if (cmd.equals(PlayerActionEvent.ACPLMISCSORT))
{
ui.getAcPlMiscPopup().setVisible(false);
ui.getAcPlMisc().setVisible(true);
// TODO
}
else if (cmd.equals(PlayerActionEvent.ACPLLISTLOAD))
{
ui.getAcPlListPopup().setVisible(false);
ui.getAcPlList().setVisible(true);
File[] file = FileSelector.selectFile(player.getLoader(), FileSelector.OPEN, true, config.getExtensions(), ui.getResource("playlist.popup.list.load"), new File(config.getLastDir()));
if (FileSelector.getInstance().getDirectory() != null) config.setLastDir(FileSelector.getInstance().getDirectory().getPath());
if ((file != null) && (file[0] != null))
{
String fsFile = file[0].getName();
if ((fsFile.toLowerCase().endsWith(ui.getResource("playlist.extension.m3u"))) || (fsFile.toLowerCase().endsWith(ui.getResource("playlist.extension.pls"))))
{
if (player.loadPlaylist(config.getLastDir() + fsFile))
{
config.setPlaylistFilename(config.getLastDir() + fsFile);
playlist.begin();
playlist.setCursor(-1);
// TODO
topIndex = 0;
}
resetScrollBar();
repaint();
}
}
}
else if (cmd.equals(PlayerActionEvent.ACPLLISTSAVE))
{
ui.getAcPlListPopup().setVisible(false);
ui.getAcPlList().setVisible(true);
// TODO
}
else if (cmd.equals(PlayerActionEvent.ACPLLISTNEW))
{
ui.getAcPlListPopup().setVisible(false);
ui.getAcPlList().setVisible(true);
// TODO
}
}
/**
* Display file info.
*/
public void popupFileInfo()
{
int n0 = playlist.getPlaylistSize();
PlaylistItem pli = null;
for (int i = n0 - 1; i >= 0; i--)
{
pli = playlist.getItemAt(i);
if (pli.isSelected()) break;
}
// Display Tag Info.
if (pli != null)
{
TagInfo taginfo = pli.getTagInfo();
TagInfoFactory factory = TagInfoFactory.getInstance();
TagInfoDialog dialog = factory.getTagInfoDialog(taginfo);
dialog.setLocation(player.getLoader().getLocation().x, player.getLoader().getLocation().y + player.getHeight());
dialog.show();
}
}
/**
* Selection operation in pledit window
* @param mode -1 : inverse selected items, 0 : select none, 1 : select all
*/
private void selFunctions(int mode)
{
int n0 = playlist.getPlaylistSize();
if (n0 == 0) return;
for (int i = 0; i < n0; i++)
{
PlaylistItem pli = playlist.getItemAt(i);
if (pli == null) break;
if (mode == -1)
{ // inverse selection
pli.setSelected(!pli.isSelected());
}
else if (mode == 0)
{ // select none
pli.setSelected(false);
}
else if (mode == 1)
{ // select all
pli.setSelected(true);
}
}
repaint();
}
/**
* Remove all items in playlist.
*/
private void delAllItems()
{
int n0 = playlist.getPlaylistSize();
if (n0 == 0) return;
playlist.removeAllItems();
topIndex = 0;
ui.getAcPlSlider().setValue(100);
repaint();
}
/**
* Remove selected items in playlist.
*/
private void delSelectedItems()
{
int n0 = playlist.getPlaylistSize();
boolean brepaint = false;
for (int i = n0 - 1; i >= 0; i--)
{
if (playlist.getItemAt(i).isSelected())
{
playlist.removeItemAt(i);
brepaint = true;
}
}
if (brepaint)
{
int n = playlist.getPlaylistSize();
if (topIndex >= n) topIndex = n - 1;
if (topIndex < 0) topIndex = 0;
resetScrollBar();
repaint();
}
}
/**
* Add file(s) to playlist.
* @param file
*/
public void addFiles(File[] file)
{
if (file != null)
{
for (int i = 0; i < file.length; i++)
{
String fsFile = file[i].getName();
if ((!fsFile.toLowerCase().endsWith(ui.getResource("skin.extension"))) && (!fsFile.toLowerCase().endsWith(ui.getResource("playlist.extension.m3u"))) && (!fsFile.toLowerCase().endsWith(ui.getResource("playlist.extension.pls"))))
{
PlaylistItem pli = new PlaylistItem(fsFile, file[i].getAbsolutePath(), -1, true);
playlist.appendItem(pli);
resetScrollBar();
repaint();
}
}
}
}
/**
* Handle mouse clicks on playlist.
* @param evt
*/
protected void handleMouseClick(MouseEvent evt)
{
int x = evt.getX();
int y = evt.getY();
ui.getAcPlAddPopup().setVisible(false);
ui.getAcPlAdd().setVisible(true);
ui.getAcPlRemovePopup().setVisible(false);
ui.getAcPlRemove().setVisible(true);
ui.getAcPlSelectPopup().setVisible(false);
ui.getAcPlSelect().setVisible(true);
ui.getAcPlMiscPopup().setVisible(false);
ui.getAcPlMisc().setVisible(true);
ui.getAcPlListPopup().setVisible(false);
ui.getAcPlList().setVisible(true);
// Check select action
if (ui.getPlaylistPanel().isInSelectArea(x, y))
{
int index = getIndex(y);
if (index != -1)
{
// PopUp
if (javax.swing.SwingUtilities.isRightMouseButton(evt))
{
if (fipopup != null) fipopup.show(this, x, y);
}
else
{
PlaylistItem pli = playlist.getItemAt(index);
if (pli != null)
{
pli.setSelected(!pli.isSelected());
if ((evt.getClickCount() == 2) && (evt.getModifiers() == MouseEvent.BUTTON1_MASK))
{
player.pressStop();
player.setCurrentSong(pli);
playlist.setCursor(index);
player.pressStart();
}
}
}
repaint();
}
}
}
/**
* Process Drag&Drop
* @param data
*/
public void processDnD(Object data)
{
log.debug("Playlist DnD");
// Looking for files to drop.
if (data instanceof List)
{
List al = (List) data;
if ((al != null) && (al.size() > 0))
{
ArrayList fileList = new ArrayList();
ArrayList folderList = new ArrayList();
ListIterator li = al.listIterator();
while (li.hasNext())
{
File f = (File) li.next();
if ((f.exists()) && (f.canRead()))
{
if (f.isFile()) fileList.add(f);
else if (f.isDirectory()) folderList.add(f);
}
}
addFiles(fileList);
addDirs(folderList);
}
}
else if (data instanceof String)
{
String files = (String) data;
if ((files.length() > 0))
{
ArrayList fileList = new ArrayList();
ArrayList folderList = new ArrayList();
StringTokenizer st = new StringTokenizer(files, System.getProperty("line.separator"));
// Transfer files dropped.
while (st.hasMoreTokens())
{
String path = st.nextToken();
if (path.startsWith("file://"))
{
path = path.substring(7, path.length());
if (path.endsWith("\r")) path = path.substring(0, (path.length() - 1));
}
File f = new File(path);
if ((f.exists()) && (f.canRead()))
{
if (f.isFile()) fileList.add(f);
else if (f.isDirectory()) folderList.add(f);
}
}
addFiles(fileList);
addDirs(folderList);
}
}
else
{
log.info("Unknown dropped objects");
}
}
/**
* Add files to playlistUI.
* @param fileList
*/
public void addFiles(List fileList)
{
if (fileList.size() > 0)
{
File[] file = (File[]) fileList.toArray(new File[fileList.size()]);
addFiles(file);
}
}
/**
* Add directories to playlistUI.
* @param folderList
*/
public void addDirs(List folderList)
{
if (folderList.size() > 0)
{
ListIterator it = folderList.listIterator();
while (it.hasNext())
{
addDir((File) it.next());
}
}
}
/**
* Compute slider value.
*/
private void resetScrollBar()
{
int n = playlist.getPlaylistSize();
float dx = (n < 1) ? 0 : ((float) topIndex / (n - 1)) * (100);
ui.getAcPlSlider().setValue(100 - (int) dx);
}
public void paintList()
{
if (!isVisible()) return;
else repaint();
}
/* (non-Javadoc)
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
*/
public void paintComponent(Graphics g)
{
ui.getPlaylistPanel().paintBackground(g);
ui.getPlaylistPanel().paintList(g);
}
/**
* Add all files under this directory to play list.
* @param fsFile
*/
private void addDir(File fsFile)
{
// Put all music file extension in a Vector
String ext = config.getExtensions();
StringTokenizer st = new StringTokenizer(ext, ", ");
if (exts == null)
{
exts = new Vector();
while (st.hasMoreTokens())
{
exts.add("." + st.nextElement());
}
}
// recursive
Thread addThread = new AddThread(fsFile);
addThread.start();
// Refresh thread
Thread refresh = new Thread("Refresh")
{
public void run()
{
while (isSearching)
{
resetScrollBar();
repaint();
try
{
Thread.sleep(4000);
}
catch (Exception ex)
{
}
}
}
};
refresh.start();
}
class AddThread extends Thread
{
private File fsFile;
public AddThread(File fsFile)
{
super("Add");
this.fsFile = fsFile;
}
public void run()
{
isSearching = true;
addMusicRecursive(fsFile, 0);
isSearching = false;
resetScrollBar();
repaint();
}
}
private void addMusicRecursive(File rootDir, int depth)
{
// We do not want waste time
if (rootDir == null || depth > MAXDEPTH) return;
String[] list = rootDir.list();
if (list == null) return;
for (int i = 0; i < list.length; i++)
{
File ff = new File(rootDir, list[i]);
if (ff.isDirectory()) addMusicRecursive(ff, depth + 1);
else
{
if (isMusicFile(list[i]))
{
PlaylistItem pli = new PlaylistItem(list[i], rootDir + File.separator + list[i], -1, true);
playlist.appendItem(pli);
}
}
}
}
private boolean isMusicFile(String ff)
{
int sz = exts.size();
for (int i = 0; i < sz; i++)
{
String ext = exts.elementAt(i).toString().toLowerCase();
// TODO : Improve
if (ext.equalsIgnoreCase(".wsz") || ext.equalsIgnoreCase(".m3u") || ext.equalsIgnoreCase(".pls")) continue;
if (ff.toLowerCase().endsWith(exts.elementAt(i).toString().toLowerCase())) return true;
}
return false;
}
}

View File

@@ -1,151 +0,0 @@
/*
* AbsoluteConstraints.
*
* 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.skin;
import java.awt.Dimension;
import java.awt.Point;
/**
* An object that encapsulates position and (optionally) size for
* Absolute positioning of components.
*/
public class AbsoluteConstraints implements java.io.Serializable
{
/**
* generated Serialized Version UID
*/
static final long serialVersionUID = 5261460716622152494L;
/**
* The X position of the component
*/
public int x;
/**
* The Y position of the component
*/
public int y;
/**
* The width of the component or -1 if the component's preferred width should be used
*/
public int width = -1;
/**
* The height of the component or -1 if the component's preferred height should be used
*/
public int height = -1;
/**
* Creates a new AbsoluteConstraints for specified position.
*
* @param pos The position to be represented by this AbsoluteConstraints
*/
public AbsoluteConstraints(Point pos)
{
this(pos.x, pos.y);
}
/**
* Creates a new AbsoluteConstraints for specified position.
*
* @param x The X position to be represented by this AbsoluteConstraints
* @param y The Y position to be represented by this AbsoluteConstraints
*/
public AbsoluteConstraints(int x, int y)
{
this.x = x;
this.y = y;
}
/**
* Creates a new AbsoluteConstraints for specified position and size.
*
* @param pos The position to be represented by this AbsoluteConstraints
* @param size The size to be represented by this AbsoluteConstraints or null
* if the component's preferred size should be used
*/
public AbsoluteConstraints(Point pos, Dimension size)
{
this.x = pos.x;
this.y = pos.y;
if (size != null)
{
this.width = size.width;
this.height = size.height;
}
}
/**
* Creates a new AbsoluteConstraints for specified position and size.
*
* @param x The X position to be represented by this AbsoluteConstraints
* @param y The Y position to be represented by this AbsoluteConstraints
* @param width The width to be represented by this AbsoluteConstraints or -1 if the
* component's preferred width should be used
* @param height The height to be represented by this AbsoluteConstraints or -1 if the
* component's preferred height should be used
*/
public AbsoluteConstraints(int x, int y, int width, int height)
{
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
/**
* @return The X position represented by this AbsoluteConstraints
*/
public int getX()
{
return x;
}
/**
* @return The Y position represented by this AbsoluteConstraints
*/
public int getY()
{
return y;
}
/**
* @return The width represented by this AbsoluteConstraints or -1 if the
* component's preferred width should be used
*/
public int getWidth()
{
return width;
}
/**
* @return The height represented by this AbsoluteConstraints or -1 if the
* component's preferred height should be used
*/
public int getHeight()
{
return height;
}
public String toString()
{
return super.toString() + " [x=" + x + ", y=" + y + ", width=" + width + ", height=" + height + "]";
}
}

View File

@@ -1,196 +0,0 @@
/*
* AbsoluteLayout.
*
* 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.skin;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.LayoutManager;
import java.awt.LayoutManager2;
/**
* AbsoluteLayout is a LayoutManager that works as a replacement for "null" layout to
* allow placement of components in absolute positions.
*/
public class AbsoluteLayout implements LayoutManager2, java.io.Serializable
{
/**
* generated Serialized Version UID
*/
static final long serialVersionUID = -1919857869177070440L;
/**
* Adds the specified component with the specified name to
* the layout.
*
* @param name the component name
* @param comp the component to be added
*/
public void addLayoutComponent(String name, Component comp)
{
throw new IllegalArgumentException();
}
/**
* Removes the specified component from the layout.
*
* @param comp the component to be removed
*/
public void removeLayoutComponent(Component comp)
{
constraints.remove(comp);
}
/**
* Calculates the preferred dimension for the specified
* panel given the components in the specified parent container.
*
* @param parent the component to be laid out
* @see #minimumLayoutSize
*/
public Dimension preferredLayoutSize(Container parent)
{
int maxWidth = 0;
int maxHeight = 0;
for (java.util.Enumeration e = constraints.keys(); e.hasMoreElements();)
{
Component comp = (Component) e.nextElement();
AbsoluteConstraints ac = (AbsoluteConstraints) constraints.get(comp);
Dimension size = comp.getPreferredSize();
int width = ac.getWidth();
if (width == -1) width = size.width;
int height = ac.getHeight();
if (height == -1) height = size.height;
if (ac.x + width > maxWidth) maxWidth = ac.x + width;
if (ac.y + height > maxHeight) maxHeight = ac.y + height;
}
return new Dimension(maxWidth, maxHeight);
}
/**
* Calculates the minimum dimension for the specified
* panel given the components in the specified parent container.
*
* @param parent the component to be laid out
* @see #preferredLayoutSize
*/
public Dimension minimumLayoutSize(Container parent)
{
int maxWidth = 0;
int maxHeight = 0;
for (java.util.Enumeration e = constraints.keys(); e.hasMoreElements();)
{
Component comp = (Component) e.nextElement();
AbsoluteConstraints ac = (AbsoluteConstraints) constraints.get(comp);
Dimension size = comp.getMinimumSize();
int width = ac.getWidth();
if (width == -1) width = size.width;
int height = ac.getHeight();
if (height == -1) height = size.height;
if (ac.x + width > maxWidth) maxWidth = ac.x + width;
if (ac.y + height > maxHeight) maxHeight = ac.y + height;
}
return new Dimension(maxWidth, maxHeight);
}
/**
* Lays out the container in the specified panel.
*
* @param parent the component which needs to be laid out
*/
public void layoutContainer(Container parent)
{
for (java.util.Enumeration e = constraints.keys(); e.hasMoreElements();)
{
Component comp = (Component) e.nextElement();
AbsoluteConstraints ac = (AbsoluteConstraints) constraints.get(comp);
Dimension size = comp.getPreferredSize();
int width = ac.getWidth();
if (width == -1) width = size.width;
int height = ac.getHeight();
if (height == -1) height = size.height;
comp.setBounds(ac.x, ac.y, width, height);
}
}
/**
* Adds the specified component to the layout, using the specified
* constraint object.
*
* @param comp the component to be added
* @param constr where/how the component is added to the layout.
*/
public void addLayoutComponent(Component comp, Object constr)
{
if (!(constr instanceof AbsoluteConstraints)) throw new IllegalArgumentException();
constraints.put(comp, constr);
}
/**
* Returns the maximum size of this component.
*
* @see java.awt.Component#getMinimumSize()
* @see java.awt.Component#getPreferredSize()
* @see LayoutManager
*/
public Dimension maximumLayoutSize(Container target)
{
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
}
/**
* Returns the alignment along the x axis. This specifies how
* the component would like to be aligned relative to other
* components. The value should be a number between 0 and 1
* where 0 represents alignment along the origin, 1 is aligned
* the furthest away from the origin, 0.5 is centered, etc.
*/
public float getLayoutAlignmentX(Container target)
{
return 0;
}
/**
* Returns the alignment along the y axis. This specifies how
* the component would like to be aligned relative to other
* components. The value should be a number between 0 and 1
* where 0 represents alignment along the origin, 1 is aligned
* the furthest away from the origin, 0.5 is centered, etc.
*/
public float getLayoutAlignmentY(Container target)
{
return 0;
}
/**
* Invalidates the layout, indicating that if the layout manager
* has cached information it should be discarded.
*/
public void invalidateLayout(Container target)
{
}
/**
* A mapping <Component, AbsoluteConstraints>
*/
protected java.util.Hashtable constraints = new java.util.Hashtable();
}

View File

@@ -1,88 +0,0 @@
/*
* ActiveFont.
*
* 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.skin;
import java.awt.Image;
public class ActiveFont
{
private Image image = null;
private String index = null;
private int width = -1;
private int height = -1;
public ActiveFont()
{
super();
}
public ActiveFont(Image image, String index, int width, int height)
{
super();
this.image=image;
this.index=index;
this.width=width;
this.height=height;
}
public int getHeight()
{
return height;
}
public void setHeight(int height)
{
this.height = height;
}
public Image getImage()
{
return image;
}
public void setImage(Image image)
{
this.image = image;
}
public String getIndex()
{
return index;
}
public void setIndex(String index)
{
this.index = index;
}
public int getWidth()
{
return width;
}
public void setWidth(int width)
{
this.width = width;
}
}

View File

@@ -1,45 +0,0 @@
/*
* ActiveJBar.
*
* 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.skin;
import javax.swing.JPanel;
public class ActiveJBar extends JPanel
{
private AbsoluteConstraints constraints = null;
public ActiveJBar()
{
super();
}
public void setConstraints(AbsoluteConstraints cnts)
{
constraints = cnts;
}
public AbsoluteConstraints getConstraints()
{
return constraints;
}
}

View File

@@ -1,48 +0,0 @@
/*
* ActiveJButton.
*
* 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.skin;
import javax.swing.JButton;
public class ActiveJButton extends JButton
{
private AbsoluteConstraints constraints = null;
public ActiveJButton()
{
super();
setBorder(null);
setDoubleBuffered(true);
setFocusPainted(false);
}
public void setConstraints(AbsoluteConstraints cnts)
{
constraints = cnts;
}
public AbsoluteConstraints getConstraints()
{
return constraints;
}
}

View File

@@ -1,62 +0,0 @@
/*
* ActiveJIcon.
*
* 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.skin;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
public class ActiveJIcon extends JLabel
{
private AbsoluteConstraints constraints = null;
private ImageIcon[] icons = null;
public ActiveJIcon()
{
super();
this.setBorder(null);
this.setDoubleBuffered(true);
}
public void setIcons(ImageIcon[] icons)
{
this.icons = icons;
}
public void setIcon(int id)
{
if ((id >= 0) && (id < icons.length))
{
setIcon(icons[id]);
}
}
public void setConstraints(AbsoluteConstraints cnts)
{
constraints = cnts;
}
public AbsoluteConstraints getConstraints()
{
return constraints;
}
}

View File

@@ -1,104 +0,0 @@
/*
* ActiveJLabel.
*
* 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.skin;
import java.awt.Rectangle;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
public class ActiveJLabel extends JLabel
{
private AbsoluteConstraints constraints = null;
private ActiveFont acFont = null;
private Rectangle cropRectangle = null;
private String acText = null;
public ActiveJLabel()
{
super();
setBorder(null);
setDoubleBuffered(true);
}
public void setConstraints(AbsoluteConstraints cnts)
{
constraints = cnts;
}
public AbsoluteConstraints getConstraints()
{
return constraints;
}
public ActiveFont getAcFont()
{
return acFont;
}
public void setAcFont(ActiveFont acFont)
{
this.acFont = acFont;
}
public Rectangle getCropRectangle()
{
return cropRectangle;
}
public void setCropRectangle(Rectangle cropRectangle)
{
this.cropRectangle = cropRectangle;
}
public String getAcText()
{
return acText;
}
public void setAcText(String txt)
{
acText = txt;
acText = acText.replace('<27>','E');
acText = acText.replace('<27>','E');
acText = acText.replace('<27>','E');
acText = acText.replace('<27>','A');
acText = acText.replace('<27>','A');
acText = acText.replace('<27>','C');
acText = acText.replace('<27>','U');
acText = acText.replace('<27>','U');
acText = acText.replace('<27>','I');
if (acFont != null)
{
Taftb parser = new Taftb(acFont.getIndex(), acFont.getImage(), acFont.getWidth(), acFont.getHeight(), 0, acText);
if (cropRectangle != null)
{
setIcon(new ImageIcon(parser.getBanner(cropRectangle.x, cropRectangle.y, cropRectangle.width, cropRectangle.height)));
}
else
{
setIcon(new ImageIcon(parser.getBanner()));
}
}
}
}

View File

@@ -1,61 +0,0 @@
/*
* ActiveJNumberLabel.
*
* 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.skin;
import javax.swing.ImageIcon;
public class ActiveJNumberLabel extends ActiveJLabel
{
private ImageIcon[] numbers = null;
public ActiveJNumberLabel()
{
super();
}
public ImageIcon[] getNumbers()
{
return numbers;
}
public void setNumbers(ImageIcon[] numbers)
{
this.numbers = numbers;
}
public void setAcText(String numberStr)
{
int number = 10;
try
{
number = Integer.parseInt(numberStr);
}
catch (NumberFormatException e)
{
}
if ((number >= 0) && (number < numbers.length))
{
setIcon(numbers[number]);
}
}
}

View File

@@ -1,70 +0,0 @@
/*
* ActiveJPopup.
*
* 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.skin;
import java.awt.GridLayout;
import javax.swing.JPanel;
public class ActiveJPopup extends JPanel
{
private AbsoluteConstraints constraints = null;
private ActiveJButton[] items = null;
public ActiveJPopup()
{
super();
setBorder(null);
setDoubleBuffered(true);
}
public void setConstraints(AbsoluteConstraints cnts)
{
constraints = cnts;
}
public AbsoluteConstraints getConstraints()
{
return constraints;
}
public ActiveJButton[] getItems()
{
return items;
}
public void setItems(ActiveJButton[] items)
{
this.items = items;
if (items != null)
{
setLayout(new GridLayout(items.length, 1, 0, 0));
for (int i=0;i<items.length;i++)
{
add(items[i]);
}
}
}
}

View File

@@ -1,58 +0,0 @@
/*
* ActiveJSlider.
*
* 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.skin;
import javax.swing.JSlider;
public class ActiveJSlider extends JSlider
{
private AbsoluteConstraints constraints = null;
public ActiveJSlider()
{
super();
setDoubleBuffered(true);
}
public void setConstraints(AbsoluteConstraints cnts)
{
constraints = cnts;
}
public AbsoluteConstraints getConstraints()
{
return constraints;
}
public boolean isRequestFocusEnabled()
{
setValueIsAdjusting(true);
repaint();
return super.isRequestFocusEnabled();
}
public void setHideThumb(boolean hide)
{
((ActiveSliderUI) getUI()).setHideThumb(hide);
}
}

View File

@@ -1,47 +0,0 @@
/*
* ActiveJToggleButton.
*
* 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.skin;
import javax.swing.JToggleButton;
public class ActiveJToggleButton extends JToggleButton
{
private AbsoluteConstraints constraints = null;
public ActiveJToggleButton()
{
super();
this.setBorder(null);
this.setDoubleBuffered(true);
this.setFocusPainted(false);
}
public void setConstraints(AbsoluteConstraints cnts)
{
constraints = cnts;
}
public AbsoluteConstraints getConstraints()
{
return constraints;
}
}

View File

@@ -1,146 +0,0 @@
/*
* ActiveSliderUI.
*
* 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.skin;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JSlider;
import javax.swing.plaf.basic.BasicSliderUI;
public class ActiveSliderUI extends BasicSliderUI
{
private Image thumbImage = null;
private Image thumbPressedImage = null;
private Image[] backgroundImages = null;
private JSlider parentSlider = null;
private Dimension thumbDim = null;
private int newThumbHeight = -1;
private int thumbXOffset = 0;
private int thumbYOffset = 0;
private boolean hideThumb = false;
public ActiveSliderUI(JSlider slider)
{
super(slider);
parentSlider = slider;
}
public void setThumbImage(Image img)
{
thumbImage = img;
thumbDim = new Dimension(thumbImage.getWidth(null), thumbImage.getHeight(null));
}
public void setThumbPressedImage(Image img)
{
thumbPressedImage = img;
}
protected Dimension getThumbSize()
{
return thumbDim;
}
public void forceThumbHeight(int h)
{
newThumbHeight = h;
}
public void setThumbXOffset(int x)
{
thumbXOffset = x;
}
public void setThumbYOffset(int y)
{
thumbYOffset = y;
}
public void setHideThumb(boolean hide)
{
hideThumb = hide;
}
public void setBackgroundImages(Image[] img)
{
backgroundImages = img;
}
public void paintFocus(Graphics g)
{
}
public void paintThumb(Graphics g)
{
if (hideThumb == true) return;
Image img = thumbImage;
if (img != null)
{
if (thumbPressedImage != null)
{
if (parentSlider.getValueIsAdjusting())
{
img = thumbPressedImage;
}
}
if (newThumbHeight >= 0)
{
if (parentSlider.getOrientation() == JSlider.HORIZONTAL)
{
g.drawImage(img, thumbRect.x + thumbXOffset, thumbYOffset, img.getWidth(null), newThumbHeight, null);
}
else
{
g.drawImage(img, thumbXOffset, thumbRect.y + thumbYOffset, img.getWidth(null), newThumbHeight, null);
}
}
else
{
if (parentSlider.getOrientation() == JSlider.HORIZONTAL)
{
g.drawImage(img, thumbRect.x + thumbXOffset, thumbYOffset, img.getWidth(null), img.getHeight(null), null);
}
else
{
g.drawImage(img, thumbXOffset, thumbRect.y + thumbYOffset, img.getWidth(null), img.getHeight(null), null);
}
}
}
}
public void paintTrack(Graphics g)
{
if (backgroundImages != null)
{
int id = (int) Math.round(((double) Math.abs(parentSlider.getValue()) / (double) parentSlider.getMaximum()) * (backgroundImages.length - 1));
g.drawImage(backgroundImages[id], 0, 0, backgroundImages[id].getWidth(null), backgroundImages[id].getHeight(null), null);
}
}
public void setThumbLocation(int x, int y)
{
super.setThumbLocation(x, y);
parentSlider.repaint();
}
}

View File

@@ -1,68 +0,0 @@
/*
* DragAdapter.
*
* 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.skin;
import java.awt.Component;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
public class DragAdapter extends MouseAdapter implements MouseMotionListener
{
private int mousePrevX = 0;
private int mousePrevY = 0;
private Component component = null;
public DragAdapter(Component component)
{
super();
this.component = component;
}
public void mousePressed(MouseEvent me)
{
super.mousePressed(me);
mousePrevX = me.getX();
mousePrevY = me.getY();
}
public void mouseDragged(MouseEvent me)
{
int mX = me.getX();
int mY = me.getY();
int cX = component.getX();
int cY = component.getY();
int moveX = mX - mousePrevX; // Negative if move left
int moveY = mY - mousePrevY; // Negative if move down
if (moveX == 0 && moveY == 0) return;
mousePrevX = mX - moveX;
mousePrevY = mY - moveY;
int newX = cX + moveX;
int newY = cY + moveY;
component.setLocation(newX, newY);
}
public void mouseMoved(MouseEvent e)
{
}
}

View File

@@ -1,163 +0,0 @@
/*
* DropTargetAdapter.
*
* 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.skin;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.awt.dnd.DropTargetListener;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class DropTargetAdapter implements DropTargetListener
{
private static Log log = LogFactory.getLog(DropTargetAdapter.class);
public DropTargetAdapter()
{
super();
}
public void dragEnter(DropTargetDragEvent e)
{
if (isDragOk(e) == false)
{
e.rejectDrag();
}
}
public void dragOver(DropTargetDragEvent e)
{
if (isDragOk(e) == false)
{
e.rejectDrag();
}
}
public void dropActionChanged(DropTargetDragEvent e)
{
if (isDragOk(e) == false)
{
e.rejectDrag();
}
}
public void dragExit(DropTargetEvent dte)
{
}
protected boolean isDragOk(DropTargetDragEvent e)
{
// Check DataFlavor
DataFlavor[] dfs = e.getCurrentDataFlavors();
DataFlavor tdf = null;
for (int i = 0; i < dfs.length; i++)
{
if (DataFlavor.javaFileListFlavor.equals(dfs[i]))
{
tdf = dfs[i];
break;
}
else if (DataFlavor.stringFlavor.equals(dfs[i]))
{
tdf = dfs[i];
break;
}
}
// Only file list allowed.
if (tdf != null)
{
// Only DnD COPY allowed.
if ((e.getSourceActions() & DnDConstants.ACTION_COPY) != 0)
{
return true;
}
else return false;
}
else return false;
}
public void drop(DropTargetDropEvent e)
{
// Check DataFlavor
DataFlavor[] dfs = e.getCurrentDataFlavors();
DataFlavor tdf = null;
for (int i = 0; i < dfs.length; i++)
{
if (DataFlavor.javaFileListFlavor.equals(dfs[i]))
{
tdf = dfs[i];
break;
}
else if (DataFlavor.stringFlavor.equals(dfs[i]))
{
tdf = dfs[i];
break;
}
}
// Data Flavor available ?
if (tdf != null)
{
// Accept COPY DnD only.
if ((e.getSourceActions() & DnDConstants.ACTION_COPY) != 0)
{
e.acceptDrop(DnDConstants.ACTION_COPY);
}
else return;
try
{
Transferable t = e.getTransferable();
Object data = t.getTransferData(tdf);
processDrop(data);
}
catch (IOException ioe)
{
log.info("Drop error", ioe);
e.dropComplete(false);
return;
}
catch (UnsupportedFlavorException ufe)
{
log.info("Drop error", ufe);
e.dropComplete(false);
return;
}
catch (Exception ex)
{
log.info("Drop error", ex);
e.dropComplete(false);
return;
}
e.dropComplete(true);
}
}
public void processDrop(Object data)
{
}
}

View File

@@ -1,65 +0,0 @@
/*
* ImageBorder.
*
* 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.skin;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Insets;
import javax.swing.border.Border;
public class ImageBorder implements Border
{
private Insets insets = new Insets(0, 0, 0, 0);
private Image image = null;
public ImageBorder()
{
super();
}
public void setImage(Image image)
{
this.image = image;
}
public boolean isBorderOpaque()
{
return true;
}
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
{
if (image != null)
{
int x0 = x + (width - image.getWidth(null)) / 2;
int y0 = y + (height - image.getHeight(null)) / 2;
g.drawImage(image, x0, y0, null);
}
}
public Insets getBorderInsets(Component c)
{
return insets;
}
}

View File

@@ -1,276 +0,0 @@
/*
* PlaylistUIDelegate.
*
* 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.skin;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import javazoom.jlgui.player.amp.playlist.PlaylistItem;
import javazoom.jlgui.player.amp.playlist.ui.PlaylistUI;
public class PlaylistUIDelegate
{
private AbsoluteConstraints constraints = null;
private Image titleLeftImage = null;
private Image titleRightImage = null;
private Image titleCenterImage = null;
private Image titleStretchImage = null;
private Image leftImage = null;
private Image rightImage = null;
private Image bottomLeftImage = null;
private Image bottomRightImage = null;
private Image bottomStretchImage = null;
private Color backgroundColor = null;
private Color selectedBackgroundColor = null;
private Color normalColor = null;
private Color currentColor = null;
private Font font = null;
private int listarea[] = { 12, 24 - 4, 256, 78 };
private PlaylistUI parent = null;
public PlaylistUIDelegate()
{
super();
currentColor = new Color(102, 204, 255);
normalColor = new Color(0xb2, 0xe4, 0xf6);
selectedBackgroundColor = Color.black;
backgroundColor = Color.black;
font = new Font("Dialog", Font.PLAIN, 10);
}
public void setParent(PlaylistUI playlist)
{
parent = playlist;
}
public Color getBackgroundColor()
{
return backgroundColor;
}
public void setBackgroundColor(Color backgroundColor)
{
this.backgroundColor = backgroundColor;
}
public Color getSelectedBackgroundColor()
{
return selectedBackgroundColor;
}
public Color getCurrentColor()
{
return currentColor;
}
public void setCurrentColor(Color currentColor)
{
this.currentColor = currentColor;
}
public Color getNormalColor()
{
return normalColor;
}
public void setNormalColor(Color normalColor)
{
this.normalColor = normalColor;
}
public void setSelectedBackgroundColor(Color selectedColor)
{
this.selectedBackgroundColor = selectedColor;
}
public Image getBottomLeftImage()
{
return bottomLeftImage;
}
public void setBottomLeftImage(Image bottomLeftImage)
{
this.bottomLeftImage = bottomLeftImage;
}
public Image getBottomRightImage()
{
return bottomRightImage;
}
public void setBottomRightImage(Image bottomRightImage)
{
this.bottomRightImage = bottomRightImage;
}
public Image getBottomStretchImage()
{
return bottomStretchImage;
}
public void setBottomStretchImage(Image bottomStretchImage)
{
this.bottomStretchImage = bottomStretchImage;
}
public Image getLeftImage()
{
return leftImage;
}
public void setLeftImage(Image leftImage)
{
this.leftImage = leftImage;
}
public Image getRightImage()
{
return rightImage;
}
public void setRightImage(Image rightImage)
{
this.rightImage = rightImage;
}
public Image getTitleCenterImage()
{
return titleCenterImage;
}
public void setTitleCenterImage(Image titleCenterImage)
{
this.titleCenterImage = titleCenterImage;
}
public Image getTitleLeftImage()
{
return titleLeftImage;
}
public void setTitleLeftImage(Image titleLeftImage)
{
this.titleLeftImage = titleLeftImage;
}
public Image getTitleRightImage()
{
return titleRightImage;
}
public void setTitleRightImage(Image titleRightImage)
{
this.titleRightImage = titleRightImage;
}
public Image getTitleStretchImage()
{
return titleStretchImage;
}
public void setTitleStretchImage(Image titleStretchImage)
{
this.titleStretchImage = titleStretchImage;
}
public void setConstraints(AbsoluteConstraints cnts)
{
constraints = cnts;
}
public AbsoluteConstraints getConstraints()
{
return constraints;
}
public int getLines()
{
return ((listarea[3] - listarea[1]) / 12);
}
public boolean isInSelectArea(int x, int y)
{
return (x >= listarea[0] && x <= listarea[2] && y >= listarea[1] && y <= listarea[3]);
}
public boolean isIndexArea(int y, int n)
{
return (y >= listarea[1] + 12 - 10 + n * 12 && y < listarea[1] + 12 - 10 + n * 12 + 14);
}
public void paintBackground(Graphics g)
{
g.drawImage(titleLeftImage, 0, 0, null);
g.drawImage(titleStretchImage, 25, 0, null);
g.drawImage(titleStretchImage, 50, 0, null);
g.drawImage(titleStretchImage, 62, 0, null);
g.drawImage(titleCenterImage, 87, 0, null);
g.drawImage(titleStretchImage, 187, 0, null);
g.drawImage(titleStretchImage, 200, 0, null);
g.drawImage(titleStretchImage, 225, 0, null);
g.drawImage(titleRightImage, 250, 0, null);
g.drawImage(leftImage, 0, 20, null);
g.drawImage(leftImage, 0, 48, null);
g.drawImage(leftImage, 0, 50, null);
//g.drawImage(rightImage, parent.getWidth() - 20, 20, null);
//g.drawImage(rightImage, parent.getWidth() - 20, 48, null);
//g.drawImage(rightImage, parent.getWidth() - 20, 50, null);
g.drawImage(bottomLeftImage, 0, parent.getHeight() - 38, null);
g.drawImage(bottomRightImage, 125, parent.getHeight() - 38, null);
}
public void paintList(Graphics g)
{
g.setColor(backgroundColor);
g.fillRect(listarea[0], listarea[1], listarea[2] - listarea[0], listarea[3] - listarea[1]);
if (font != null) g.setFont(font);
if (parent.getPlaylist() != null)
{
int currentSelection = parent.getPlaylist().getSelectedIndex();
g.setColor(normalColor);
int n = parent.getPlaylist().getPlaylistSize();
for (int i = 0; i < n; i++)
{
if (i < parent.getTopIndex()) continue;
int k = i - parent.getTopIndex();
if (listarea[1] + 12 + k * 12 > listarea[3]) break;
PlaylistItem pli = parent.getPlaylist().getItemAt(i);
String name = pli.getFormattedName();
if (pli.isSelected())
{
g.setColor(selectedBackgroundColor);
g.fillRect(listarea[0] + 4, listarea[1] + 12 - 10 + k * 12, listarea[2] - listarea[0] - 4, 14);
}
if (i == currentSelection) g.setColor(currentColor);
else g.setColor(normalColor);
if (i + 1 >= 10) g.drawString((i + 1) + ". " + name, listarea[0] + 12, listarea[1] + 12 + k * 12);
else g.drawString("0" + (i + 1) + ". " + name, listarea[0] + 12, listarea[1] + 12 + k * 12);
if (i == currentSelection) g.setColor(normalColor);
}
//g.drawImage(rightImage, parent.getWidth() - 20, 20, null);
//g.drawImage(rightImage, parent.getWidth() - 20, 48, null);
//g.drawImage(rightImage, parent.getWidth() - 20, 50, null);
}
}
}

View File

@@ -1,61 +0,0 @@
/*
* PopupAdapter.
*
* 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.skin;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JPopupMenu;
public class PopupAdapter extends MouseAdapter
{
private JPopupMenu popup = null;
public PopupAdapter(JPopupMenu popup)
{
super();
this.popup=popup;
}
public void mousePressed(MouseEvent e)
{
checkPopup(e);
}
public void mouseClicked(MouseEvent e)
{
checkPopup(e);
}
public void mouseReleased(MouseEvent e)
{
checkPopup(e);
}
private void checkPopup(MouseEvent e)
{
if (e.isPopupTrigger())
{
popup.show(e.getComponent(), e.getX(), e.getY());
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,124 +0,0 @@
/*
* SkinLoader.
*
* 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.skin;
import java.awt.Image;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.net.URL;
import java.util.Hashtable;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import javazoom.jlgui.player.amp.util.BMPLoader;
import javazoom.jlgui.player.amp.util.Config;
/**
* This class implements a Skin Loader.
* WinAmp 2.x javazoom.jlgui.player.amp.skins compliant.
*/
public class SkinLoader
{
private Hashtable _images = null;
private ZipInputStream _zis = null;
/**
* Contructs a SkinLoader from a skin file.
*/
public SkinLoader(String filename)
{
_images = new Hashtable();
try
{
if (Config.startWithProtocol(filename)) _zis = new ZipInputStream((new URL(filename)).openStream());
else _zis = new ZipInputStream(new FileInputStream(filename));
}
catch (Exception e)
{
// Try to load included default skin.
ClassLoader cl = this.getClass().getClassLoader();
InputStream sis = cl.getResourceAsStream("javazoom/jlgui/player/amp/metrix.wsz");
if (sis != null) _zis = new ZipInputStream(sis);
}
}
/**
* Contructs a SkinLoader from any input stream.
*/
public SkinLoader(InputStream inputstream)
{
_images = new Hashtable();
_zis = new ZipInputStream(inputstream);
}
/**
* Loads data (images + info) from skin.
*/
public void loadImages() throws Exception
{
ZipEntry entry = _zis.getNextEntry();
String name;
BMPLoader bmp = new BMPLoader();
int pos;
while (entry != null)
{
name = entry.getName().toLowerCase();
pos = name.lastIndexOf("/");
if (pos != -1) name = name.substring(pos + 1);
if (name.endsWith("bmp"))
{
_images.put(name, bmp.getBMPImage(_zis));
}
else if (name.endsWith("txt"))
{
InputStreamReader reader = new InputStreamReader(_zis, "US-ASCII");
StringWriter writer = new StringWriter();
char buffer[] = new char[256];
int charsRead;
while ((charsRead = reader.read(buffer)) != -1)
writer.write(buffer, 0, charsRead);
_images.put(name, writer.toString());
}
entry = _zis.getNextEntry();
}
_zis.close();
}
/**
* Return Image from name.
*/
public Image getImage(String name)
{
return (Image) _images.get(name);
}
// Added by John Yang - 02/05/2001
/**
* Return skin content (Image or String) from name.
*/
public Object getContent(String name)
{
return _images.get(name);
}
}

View File

@@ -1,153 +0,0 @@
/*
* Taftb.
*
* 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.skin;
import java.awt.Image;
import java.awt.image.CropImageFilter;
import java.awt.image.FilteredImageSource;
import java.awt.image.MemoryImageSource;
import java.awt.image.PixelGrabber;
import javax.swing.JComponent;
/**
* Taftb is used to build gif image from graphical fonts.
*/
public class Taftb extends JComponent
{
public Image theFonts;
private int imageW;
private int fontWidth;
private int fontHeight;
private int Yspacing;
protected Image theBanner;
protected int pixels[];
private PixelGrabber pg;
private String theText;
/**
* Text banner building according to the alphabet index, font size and Y spacing.
*/
public Taftb(String alphaIndex, Image fontFile, int fontW, int fontH, int Yspc, String theTxt/*, Color BgValue*/)
{
fontWidth = fontW;
fontHeight = fontH;
Yspacing = Yspc;
theText = theTxt;
theFonts = fontFile;
imageW = theFonts.getWidth(this);
/*-- We create the TextBanner by grabbing font letters in the image fonts --*/
pixels = new int[theText.length() * fontW * fontH];
int SpacePosition = 0;
int offsetSp = 0;
/*-- We search the space position in the Alphabet index --*/
while ((offsetSp < alphaIndex.length()) && (alphaIndex.charAt(offsetSp) != ' '))
{
offsetSp++;
}
if (offsetSp < alphaIndex.length()) SpacePosition = offsetSp;
for (int offsetT = 0; offsetT < theText.length(); offsetT++)
{
int xPos = 0;
int yPos = 0;
int reste = 0;
int entie = 0;
int offsetA = 0;
int FontPerLine = (int) Math.rint((imageW / fontW));
/*-- We search the letter's position in the Alphabet index --*/
while ((offsetA < alphaIndex.length()) && (theText.charAt(offsetT) != alphaIndex.charAt(offsetA)))
{
offsetA++;
}
/*-- We deduce its image's position (Int forced) --*/
if (offsetA < alphaIndex.length())
{
reste = offsetA % FontPerLine;
entie = (offsetA - reste);
xPos = reste * fontW;
yPos = ((entie / FontPerLine) * fontH) + ((entie / FontPerLine) * Yspacing);
}
else
/*-- If the letter is not indexed the space (if available) is selected --*/
{
reste = SpacePosition % FontPerLine;
entie = (SpacePosition - reste);
xPos = reste * fontW;
yPos = ((entie / FontPerLine) * fontH) + ((entie / FontPerLine) * Yspacing);
}
/*-- We grab the letter in the font image and put it in a pixel array --*/
pg = new PixelGrabber(theFonts, xPos, yPos, fontW, fontH, pixels, offsetT * fontW, theText.length() * fontW);
try
{
pg.grabPixels();
}
catch (InterruptedException e)
{
}
}
/*-- We create the final Image Banner throught an Image --*/
theBanner = createImage(new MemoryImageSource(theText.length() * fontW, fontH, pixels, 0, theText.length() * fontW));
}
/**
* Returns final banner as an image.
*/
public Image getBanner()
{
return theBanner;
}
/**
* Returns final banner as cropped image.
*/
public Image getBanner(int x, int y, int sx, int sy)
{
Image cropBanner = null;
CropImageFilter cif = new CropImageFilter(x, y, sx, sy);
cropBanner = createImage(new FilteredImageSource(theBanner.getSource(), cif));
return cropBanner;
}
/**
* Returns final banner as a pixels array.
*/
public int[] getPixels()
{
return pixels;
}
/**
* Returns banner's length.
*/
public int getPixelsW()
{
return theText.length() * fontWidth;
}
/**
* Returns banner's height.
*/
public int getPixelsH()
{
return fontHeight;
}
}

View File

@@ -1,148 +0,0 @@
/*
* UrlDialog.
*
* 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.skin;
import javax.swing.JDialog;
import javax.swing.JFrame;
/**
* UrlDialog class implements a DialogBox to get an URL.
*/
public class UrlDialog extends JDialog
{
private String _url = null;
/**
* Creates new form ud
*/
public UrlDialog(JFrame parent, String title, int x, int y, String url)
{
super(parent, title, true);
_url = url;
initComponents();
if (_url != null) textField.setText(_url);
this.setLocation(x, y);
}
/**
* Returns URL.
*/
public String getURL()
{
return _url;
}
/**
* Returns filename.
*/
public String getFile()
{
return _url;
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents()
{//GEN-BEGIN:initComponents
java.awt.GridBagConstraints gridBagConstraints;
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
textField = new javax.swing.JTextField();
jPanel1 = new javax.swing.JPanel();
openButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
getContentPane().setLayout(new java.awt.GridBagLayout());
jLabel1.setText("Enter an Internet location to open here :");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
getContentPane().add(jLabel1, gridBagConstraints);
jLabel2.setText("\"For example : http://www.server.com:8000\"");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
getContentPane().add(jLabel2, gridBagConstraints);
textField.setColumns(10);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
getContentPane().add(textField, gridBagConstraints);
openButton.setMnemonic('O');
openButton.setText("Open");
openButton.setToolTipText("Open");
openButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
openHandler(evt);
}
});
jPanel1.add(openButton);
cancelButton.setMnemonic('C');
cancelButton.setText("Cancel");
cancelButton.setToolTipText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
cancelHandler(evt);
}
});
jPanel1.add(cancelButton);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
getContentPane().add(jPanel1, gridBagConstraints);
pack();
}//GEN-END:initComponents
private void cancelHandler(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_cancelHandler
_url = null;
this.dispose();
}//GEN-LAST:event_cancelHandler
private void openHandler(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_openHandler
_url = textField.getText();
this.dispose();
}//GEN-LAST:event_openHandler
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancelButton;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel1;
private javax.swing.JButton openButton;
private javax.swing.JTextField textField;
// End of variables declaration//GEN-END:variables
}

View File

@@ -1,65 +0,0 @@
button.previous=Previous
button.play=Play
button.pause=Pause
button.stop=Stop
button.next=Next
button.eject=Open file(s)
button.eject.filedialog.filtername=File, playlist or skin
button.eject.urldialog.title=Open location
title.loading=PLEASE WAIT ... LOADING ...
title.buffering=PLEASE WAIT ... BUFFERING ...
title.invalidfile=INVALID FILE
button.exit=Close
button.minimize=Minimize
toggle.equalizer=Toggle Graphical Equalizer
toggle.playlist=Toggle Playlist Editor
toggle.shuffle=Toggle Shuffle
toggle.repeat=Toggle Repeat
slider.volume=Volume Bar
slider.volume.text=VOLUME: {0}%
slider.balance=Panning Bar
slider.balance.text.right=BALANCE: {0}% RIGHT
slider.balance.text.left=BALANCE: {0}% LEFT
slider.balance.text.center=BALANCE: CENTER
slider.seek=Seeking Bar
panel.analyzer=Spectrum/Time analyzer
popup.title=Setup
popup.play=Play
popup.play.file=File...
popup.play.location=Location...
popup.playlist=Playlist Editor
popup.equalizer=Equalizer
popup.preferences=Preferences
popup.skins=Skins
popup.skins.browser=Skin Browser
popup.skins.load=Load Skin
popup.playback=Playback
popup.playback.jump=Jump to file
popup.playback.stop=Stop
popup.exit=Exit
popup.eject.openfile=Open file...
popup.eject.openlocation=Open location...
loadskin.dialog.filtername=Skin files
skin.extension=wsz
playlist.extension.m3u=m3u
playlist.extension.pls=pls
equalizer.toggle.onoff=On/Off
equalizer.toggle.auto=Auto
equalizer.button.presets=Presets
playlist.popup.info=File Info
playlist.popup.play=Play Item
playlist.popup.remove=Remove Item(s)
playlist.popup.add.file=Music files
playlist.popup.add.url=Open location
playlist.popup.add.dir=Directories
playlist.popup.list.load=PLS or M3U Playlist

View File

@@ -1,340 +0,0 @@
/*
* 21.04.2004 Original verion. davagin@udm.ru.
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU 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.tag;
import org.tritonus.share.sampled.TAudioFormat;
import org.tritonus.share.sampled.file.TAudioFileFormat;
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
import java.util.Vector;
/**
* This class gives information (audio format and comments) about APE file or URL.
*/
public class APEInfo implements TagInfo
{
protected int channels = -1;
protected int bitspersample = -1;
protected int samplerate = -1;
protected int bitrate = -1;
protected int version = -1;
protected String compressionlevel = null;
protected int totalframes = -1;
protected int blocksperframe = -1;
protected int finalframeblocks = -1;
protected int totalblocks = -1;
protected int peaklevel = -1;
protected long duration = -1;
protected String author = null;
protected String title = null;
protected String copyright = null;
protected Date date = null;
protected String comment = null;
protected String track = null;
protected String genre = null;
protected String album = null;
protected long size = 0;
protected String location = null;
/**
* Constructor.
*/
public APEInfo()
{
super();
}
/**
* Load and parse APE info from File.
*
* @param input
* @throws IOException
*/
public void load(File input) throws IOException, UnsupportedAudioFileException
{
size = input.length();
location = input.getPath();
loadInfo(input);
}
/**
* Load and parse APE info from URL.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
public void load(URL input) throws IOException, UnsupportedAudioFileException
{
location = input.toString();
loadInfo(input);
}
/**
* Load and parse APE info from InputStream.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
public void load(InputStream input) throws IOException, UnsupportedAudioFileException
{
loadInfo(input);
}
/**
* Load APE info from input stream.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(InputStream input) throws IOException, UnsupportedAudioFileException
{
AudioFileFormat aff = AudioSystem.getAudioFileFormat(input);
loadInfo(aff);
}
/**
* Load APE info from file.
*
* @param file
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(File file) throws IOException, UnsupportedAudioFileException
{
AudioFileFormat aff = AudioSystem.getAudioFileFormat(file);
loadInfo(aff);
}
/**
* Load APE info from AudioFileFormat.
*
* @param aff
*/
protected void loadInfo(AudioFileFormat aff) throws UnsupportedAudioFileException
{
String type = aff.getType().toString();
if (!type.equalsIgnoreCase("Monkey's Audio (ape)") && !type.equalsIgnoreCase("Monkey's Audio (mac)")) throw new UnsupportedAudioFileException("Not APE audio format");
if (aff instanceof TAudioFileFormat)
{
Map props = ((TAudioFileFormat) aff).properties();
if (props.containsKey("duration")) duration = ((Long) props.get("duration")).longValue();
if (props.containsKey("author")) author = (String) props.get("author");
if (props.containsKey("title")) title = (String) props.get("title");
if (props.containsKey("copyright")) copyright = (String) props.get("copyright");
if (props.containsKey("date")) date = (Date) props.get("date");
if (props.containsKey("comment")) comment = (String) props.get("comment");
if (props.containsKey("album")) album = (String) props.get("album");
if (props.containsKey("track")) track = (String) props.get("track");
if (props.containsKey("genre")) genre = (String) props.get("genre");
AudioFormat af = aff.getFormat();
channels = af.getChannels();
samplerate = (int) af.getSampleRate();
bitspersample = af.getSampleSizeInBits();
if (af instanceof TAudioFormat)
{
props = ((TAudioFormat) af).properties();
if (props.containsKey("bitrate")) bitrate = ((Integer) props.get("bitrate")).intValue();
if (props.containsKey("ape.version")) version = ((Integer) props.get("ape.version")).intValue();
if (props.containsKey("ape.compressionlevel"))
{
int cl = ((Integer) props.get("ape.compressionlevel")).intValue();
switch (cl)
{
case 1000:
compressionlevel = "Fast";
break;
case 2000:
compressionlevel = "Normal";
break;
case 3000:
compressionlevel = "High";
break;
case 4000:
compressionlevel = "Extra High";
break;
case 5000:
compressionlevel = "Insane";
break;
}
}
if (props.containsKey("ape.totalframes")) totalframes = ((Integer) props.get("ape.totalframes")).intValue();
if (props.containsKey("ape.blocksperframe")) totalframes = ((Integer) props.get("ape.blocksperframe")).intValue();
if (props.containsKey("ape.finalframeblocks")) finalframeblocks = ((Integer) props.get("ape.finalframeblocks")).intValue();
if (props.containsKey("ape.totalblocks")) totalblocks = ((Integer) props.get("ape.totalblocks")).intValue();
if (props.containsKey("ape.peaklevel")) peaklevel = ((Integer) props.get("ape.peaklevel")).intValue();
}
}
}
/**
* Load APE info from URL.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(URL input) throws IOException, UnsupportedAudioFileException
{
AudioFileFormat aff = AudioSystem.getAudioFileFormat(input);
loadInfo(aff);
}
public long getSize()
{
return size;
}
public String getLocation()
{
return location;
}
public int getVersion()
{
return version;
}
public String getCompressionlevel()
{
return compressionlevel;
}
public int getTotalframes()
{
return totalframes;
}
public int getBlocksperframe()
{
return blocksperframe;
}
public int getFinalframeblocks()
{
return finalframeblocks;
}
public int getChannels()
{
return channels;
}
public int getSamplingRate()
{
return samplerate;
}
public int getBitsPerSample()
{
return bitspersample;
}
public int getTotalblocks()
{
return totalblocks;
}
public long getPlayTime()
{
return duration / 1000;
}
public int getBitRate()
{
return bitrate * 1000;
}
public int getPeaklevel()
{
return peaklevel;
}
public int getTrack()
{
int t;
try
{
t = Integer.parseInt(track);
}
catch (Exception e)
{
t = -1;
}
return t;
}
public String getYear()
{
if (date != null)
{
Calendar c = Calendar.getInstance();
c.setTime(date);
return String.valueOf(c.get(Calendar.YEAR));
}
return null;
}
public String getGenre()
{
return genre;
}
public String getTitle()
{
return title;
}
public String getArtist()
{
return author;
}
public String getAlbum()
{
return album;
}
public Vector getComment()
{
if (comment != null)
{
Vector c = new Vector();
c.add(comment);
return c;
}
return null;
}
public String getCopyright()
{
return copyright;
}
}

View File

@@ -1,189 +0,0 @@
/*
* 21.04.2004 Original verion. davagin@udm.ru.
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU 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.tag;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Vector;
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
/**
* This class gives information (audio format and comments) about Flac file or URL.
*/
public class FlacInfo implements TagInfo {
protected int channels = -1;
protected int bitspersample = -1;
protected int samplerate = -1;
protected long size = 0;
protected String location = null;
/**
* Constructor.
*/
public FlacInfo() {
super();
}
/**
* Load and parse Flac info from File.
*
* @param input
* @throws IOException
*/
public void load(File input) throws IOException, UnsupportedAudioFileException {
size = input.length();
location = input.getPath();
loadInfo(input);
}
/**
* Load and parse Flac info from URL.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
public void load(URL input) throws IOException, UnsupportedAudioFileException {
location = input.toString();
loadInfo(input);
}
/**
* Load and parse Flac info from InputStream.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
public void load(InputStream input) throws IOException, UnsupportedAudioFileException {
loadInfo(input);
}
/**
* Load Flac info from input stream.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(InputStream input) throws IOException, UnsupportedAudioFileException {
AudioFileFormat aff = AudioSystem.getAudioFileFormat(input);
loadInfo(aff);
}
/**
* Load Flac info from file.
*
* @param file
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(File file) throws IOException, UnsupportedAudioFileException {
AudioFileFormat aff = AudioSystem.getAudioFileFormat(file);
loadInfo(aff);
}
/**
* Load Flac info from AudioFileFormat.
*
* @param aff
*/
protected void loadInfo(AudioFileFormat aff) throws UnsupportedAudioFileException {
String type = aff.getType().toString();
if (!type.equalsIgnoreCase("flac")) throw new UnsupportedAudioFileException("Not Flac audio format");
AudioFormat af = aff.getFormat();
channels = af.getChannels();
samplerate = (int) af.getSampleRate();
bitspersample = af.getSampleSizeInBits();
}
/**
* Load Flac info from URL.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(URL input) throws IOException, UnsupportedAudioFileException {
AudioFileFormat aff = AudioSystem.getAudioFileFormat(input);
loadInfo(aff);
}
public long getSize() {
return size;
}
public String getLocation() {
return location;
}
public int getChannels() {
return channels;
}
public int getSamplingRate() {
return samplerate;
}
public int getBitsPerSample() {
return bitspersample;
}
public Vector getComment() {
return null;
}
public String getYear() {
return null;
}
public String getGenre() {
return null;
}
public int getTrack() {
return -1;
}
public String getAlbum() {
return null;
}
public String getArtist() {
return null;
}
public String getTitle() {
return null;
}
public long getPlayTime() {
return -1;
}
public int getBitRate() {
return -1;
}
}

View File

@@ -1,315 +0,0 @@
/*
* MpegInfo.
*
* 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.tag;
import org.tritonus.share.sampled.file.TAudioFileFormat;
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;
/**
* This class gives information (audio format and comments) about MPEG file or URL.
*/
public class MpegInfo implements TagInfo {
protected int channels = -1;
protected String channelsMode = null;
protected String version = null;
protected int rate = 0;
protected String layer = null;
protected String emphasis = null;
protected int nominalbitrate = 0;
protected long total = 0;
protected String vendor = null;
protected String location = null;
protected long size = 0;
protected boolean copyright = false;
protected boolean crc = false;
protected boolean original = false;
protected boolean priv = false;
protected boolean vbr = false;
protected int track = -1;
protected String year = null;
protected String genre = null;
protected String title = null;
protected String artist = null;
protected String album = null;
protected Vector comments = null;
/**
* Constructor.
*/
public MpegInfo() {
super();
}
/**
* Load and parse MPEG info from File.
*
* @param input
* @throws IOException
*/
public void load(File input) throws IOException, UnsupportedAudioFileException {
size = input.length();
location = input.getPath();
loadInfo(input);
}
/**
* Load and parse MPEG info from URL.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
public void load(URL input) throws IOException, UnsupportedAudioFileException {
location = input.toString();
loadInfo(input);
}
/**
* Load and parse MPEG info from InputStream.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
public void load(InputStream input) throws IOException, UnsupportedAudioFileException {
loadInfo(input);
}
/**
* Load info from input stream.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(InputStream input) throws IOException, UnsupportedAudioFileException {
AudioFileFormat aff = AudioSystem.getAudioFileFormat(input);
loadInfo(aff);
}
/**
* Load MP3 info from file.
*
* @param file
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(File file) throws IOException, UnsupportedAudioFileException {
AudioFileFormat aff = AudioSystem.getAudioFileFormat(file);
loadInfo(aff);
}
/**
* Load info from AudioFileFormat.
*
* @param aff
*/
protected void loadInfo(AudioFileFormat aff) throws UnsupportedAudioFileException {
String type = aff.getType().toString();
if (!type.equalsIgnoreCase("mp3")) throw new UnsupportedAudioFileException("Not MP3 audio format");
if (aff instanceof TAudioFileFormat) {
Map props = ((TAudioFileFormat) aff).properties();
if (props.containsKey("mp3.channels")) channels = ((Integer) props.get("mp3.channels")).intValue();
if (props.containsKey("mp3.frequency.hz")) rate = ((Integer) props.get("mp3.frequency.hz")).intValue();
if (props.containsKey("mp3.bitrate.nominal.bps")) nominalbitrate = ((Integer) props.get("mp3.bitrate.nominal.bps")).intValue();
if (props.containsKey("mp3.version.layer")) layer = "Layer " + props.get("mp3.version.layer");
if (props.containsKey("mp3.version.mpeg")) {
version = (String) props.get("mp3.version.mpeg");
if (version.equals("1")) version = "MPEG1";
else if (version.equals("2")) version = "MPEG2-LSF";
else if (version.equals("2.5")) version = "MPEG2.5-LSF";
}
if (props.containsKey("mp3.mode")) {
int mode = ((Integer) props.get("mp3.mode")).intValue();
if (mode == 0) channelsMode = "Stereo";
else if (mode == 1) channelsMode = "Joint Stereo";
else if (mode == 2) channelsMode = "Dual Channel";
else if (mode == 3) channelsMode = "Single Channel";
}
if (props.containsKey("mp3.crc")) crc = ((Boolean) props.get("mp3.crc")).booleanValue();
if (props.containsKey("mp3.vbr")) vbr = ((Boolean) props.get("mp3.vbr")).booleanValue();
if (props.containsKey("mp3.copyright")) copyright = ((Boolean) props.get("mp3.copyright")).booleanValue();
if (props.containsKey("mp3.original")) original = ((Boolean) props.get("mp3.original")).booleanValue();
emphasis = "none";
if (props.containsKey("title")) title = (String) props.get("title");
if (props.containsKey("author")) artist = (String) props.get("author");
if (props.containsKey("album")) album = (String) props.get("album");
if (props.containsKey("date")) year = (String) props.get("date");
if (props.containsKey("duration")) total = (long) Math.round((((Long) props.get("duration")).longValue()) / 1000000);
if (props.containsKey("mp3.id3tag.genre")) genre = (String) props.get("mp3.id3tag.genre");
if (props.containsKey("mp3.id3tag.track")) {
try {
track = Integer.parseInt((String) props.get("mp3.id3tag.track"));
}
catch (NumberFormatException e1) {
// Not a number
}
}
}
}
/**
* Load MP3 info from URL.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(URL input) throws IOException, UnsupportedAudioFileException {
AudioFileFormat aff = AudioSystem.getAudioFileFormat(input);
loadInfo(aff);
loadShoutastInfo(aff);
}
/**
* Load Shoutcast info from AudioFileFormat.
*
* @param aff
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadShoutastInfo(AudioFileFormat aff) throws IOException, UnsupportedAudioFileException {
String type = aff.getType().toString();
if (!type.equalsIgnoreCase("mp3")) throw new UnsupportedAudioFileException("Not MP3 audio format");
if (aff instanceof TAudioFileFormat) {
Map props = ((TAudioFileFormat) aff).properties();
// Try shoutcast meta data (if any).
Iterator it = props.keySet().iterator();
comments = new Vector();
while (it.hasNext()) {
String key = (String) it.next();
if (key.startsWith("mp3.shoutcast.metadata.")) {
String value = (String) props.get(key);
key = key.substring(23, key.length());
if (key.equalsIgnoreCase("icy-name")) {
title = value;
} else if (key.equalsIgnoreCase("icy-genre")) {
genre = value;
} else {
comments.add(key + "=" + value);
}
}
}
}
}
public boolean getVBR() {
return vbr;
}
public int getChannels() {
return channels;
}
public String getVersion() {
return version;
}
public String getEmphasis() {
return emphasis;
}
public boolean getCopyright() {
return copyright;
}
public boolean getCRC() {
return crc;
}
public boolean getOriginal() {
return original;
}
public String getLayer() {
return layer;
}
public long getSize() {
return size;
}
public String getLocation() {
return location;
}
/*-- TagInfo Implementation --*/
public int getSamplingRate() {
return rate;
}
public int getBitRate() {
return nominalbitrate;
}
public long getPlayTime() {
return total;
}
public String getTitle() {
return title;
}
public String getArtist() {
return artist;
}
public String getAlbum() {
return album;
}
public int getTrack() {
return track;
}
public String getGenre() {
return genre;
}
public Vector getComment() {
return comments;
}
public String getYear() {
return year;
}
/**
* Get channels mode.
*
* @return channels mode
*/
public String getChannelsMode() {
return channelsMode;
}
}

View File

@@ -1,307 +0,0 @@
/*
* OggVorbisInfo.
*
* 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.tag;
import org.tritonus.share.sampled.file.TAudioFileFormat;
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Map;
import java.util.Vector;
/**
* This class gives information (audio format and comments) about Ogg Vorbis file or URL.
*/
public class OggVorbisInfo implements TagInfo
{
protected int serial = 0;
protected int channels = 0;
protected int version = 0;
protected int rate = 0;
protected int minbitrate = 0;
protected int maxbitrate = 0;
protected int averagebitrate = 0;
protected int nominalbitrate = 0;
protected long totalms = 0;
protected String vendor = "";
protected String location = null;
protected long size = 0;
protected int track = -1;
protected String year = null;
protected String genre = null;
protected String title = null;
protected String artist = null;
protected String album = null;
protected Vector comments = new Vector();
/**
* Constructor.
*/
public OggVorbisInfo()
{
super();
}
/**
* Load and parse Ogg Vorbis info from File.
*
* @param input
* @throws IOException
*/
public void load(File input) throws IOException, UnsupportedAudioFileException
{
size = input.length();
location = input.getPath();
loadInfo(input);
}
/**
* Load and parse Ogg Vorbis info from URL.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
public void load(URL input) throws IOException, UnsupportedAudioFileException
{
location = input.toString();
loadInfo(input);
}
/**
* Load and parse Ogg Vorbis info from InputStream.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
public void load(InputStream input) throws IOException, UnsupportedAudioFileException
{
loadInfo(input);
}
/**
* Load info from input stream.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(InputStream input) throws IOException, UnsupportedAudioFileException
{
AudioFileFormat aff = AudioSystem.getAudioFileFormat(input);
loadInfo(aff);
}
/**
* Load Ogg Vorbis info from file.
*
* @param file
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(File file) throws IOException, UnsupportedAudioFileException
{
AudioFileFormat aff = AudioSystem.getAudioFileFormat(file);
loadInfo(aff);
}
/**
* Load Ogg Vorbis info from URL.
*
* @param input
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(URL input) throws IOException, UnsupportedAudioFileException
{
AudioFileFormat aff = AudioSystem.getAudioFileFormat(input);
loadInfo(aff);
loadExtendedInfo(aff);
}
/**
* Load info from AudioFileFormat.
*
* @param aff
* @throws UnsupportedAudioFileException
*/
protected void loadInfo(AudioFileFormat aff) throws UnsupportedAudioFileException
{
String type = aff.getType().toString();
if (!type.equalsIgnoreCase("ogg")) throw new UnsupportedAudioFileException("Not Ogg Vorbis audio format");
if (aff instanceof TAudioFileFormat)
{
Map props = ((TAudioFileFormat) aff).properties();
if (props.containsKey("ogg.channels")) channels = ((Integer) props.get("ogg.channels")).intValue();
if (props.containsKey("ogg.frequency.hz")) rate = ((Integer) props.get("ogg.frequency.hz")).intValue();
if (props.containsKey("ogg.bitrate.nominal.bps")) nominalbitrate = ((Integer) props.get("ogg.bitrate.nominal.bps")).intValue();
averagebitrate = nominalbitrate;
if (props.containsKey("ogg.bitrate.max.bps")) maxbitrate = ((Integer) props.get("ogg.bitrate.max.bps")).intValue();
if (props.containsKey("ogg.bitrate.min.bps")) minbitrate = ((Integer) props.get("ogg.bitrate.min.bps")).intValue();
if (props.containsKey("ogg.version")) version = ((Integer) props.get("ogg.version")).intValue();
if (props.containsKey("ogg.serial")) serial = ((Integer) props.get("ogg.serial")).intValue();
if (props.containsKey("ogg.comment.encodedby")) vendor = (String) props.get("ogg.comment.encodedby");
if (props.containsKey("copyright")) comments.add((String) props.get("copyright"));
if (props.containsKey("title")) title = (String) props.get("title");
if (props.containsKey("author")) artist = (String) props.get("author");
if (props.containsKey("album")) album = (String) props.get("album");
if (props.containsKey("date")) year = (String) props.get("date");
if (props.containsKey("comment")) comments.add((String) props.get("comment"));
if (props.containsKey("duration")) totalms = (long) Math.round((((Long) props.get("duration")).longValue()) / 1000000);
if (props.containsKey("ogg.comment.genre")) genre = (String) props.get("ogg.comment.genre");
if (props.containsKey("ogg.comment.track"))
{
try
{
track = Integer.parseInt((String) props.get("ogg.comment.track"));
}
catch (NumberFormatException e1)
{
// Not a number
}
}
if (props.containsKey("ogg.comment.ext.1")) comments.add((String) props.get("ogg.comment.ext.1"));
if (props.containsKey("ogg.comment.ext.2")) comments.add((String) props.get("ogg.comment.ext.2"));
if (props.containsKey("ogg.comment.ext.3")) comments.add((String) props.get("ogg.comment.ext.3"));
}
}
/**
* Load extended info from AudioFileFormat.
*
* @param aff
* @throws IOException
* @throws UnsupportedAudioFileException
*/
protected void loadExtendedInfo(AudioFileFormat aff) throws IOException, UnsupportedAudioFileException
{
String type = aff.getType().toString();
if (!type.equalsIgnoreCase("ogg")) throw new UnsupportedAudioFileException("Not Ogg Vorbis audio format");
if (aff instanceof TAudioFileFormat)
{
//Map props = ((TAudioFileFormat) aff).properties();
// How to load icecast meta data (if any) ??
}
}
public int getSerial()
{
return serial;
}
public int getChannels()
{
return channels;
}
public int getVersion()
{
return version;
}
public int getMinBitrate()
{
return minbitrate;
}
public int getMaxBitrate()
{
return maxbitrate;
}
public int getAverageBitrate()
{
return averagebitrate;
}
public long getSize()
{
return size;
}
public String getVendor()
{
return vendor;
}
public String getLocation()
{
return location;
}
/*-- TagInfo Implementation --*/
public int getSamplingRate()
{
return rate;
}
public int getBitRate()
{
return nominalbitrate;
}
public long getPlayTime()
{
return totalms;
}
public String getTitle()
{
return title;
}
public String getArtist()
{
return artist;
}
public String getAlbum()
{
return album;
}
public int getTrack()
{
return track;
}
public String getGenre()
{
return genre;
}
public Vector getComment()
{
return comments;
}
public String getYear()
{
return year;
}
}

View File

@@ -1,120 +0,0 @@
/*
* TagInfo.
*
* 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.tag;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Vector;
import javax.sound.sampled.UnsupportedAudioFileException;
/**
* This interface define needed features for song information.
* Adapted from Scott Pennell interface.
*/
public interface TagInfo
{
public void load(InputStream input) throws IOException, UnsupportedAudioFileException;
public void load(URL input) throws IOException, UnsupportedAudioFileException;
public void load(File input) throws IOException, UnsupportedAudioFileException;
/**
* Get Sampling Rate
*
* @return sampling rate
*/
public int getSamplingRate();
/**
* Get Nominal Bitrate
*
* @return bitrate in bps
*/
public int getBitRate();
/**
* Get channels.
*
* @return channels
*/
public int getChannels();
/**
* Get play time in seconds.
*
* @return play time in seconds
*/
public long getPlayTime();
/**
* Get the title of the song.
*
* @return the title of the song
*/
public String getTitle();
/**
* Get the artist that performed the song
*
* @return the artist that performed the song
*/
public String getArtist();
/**
* Get the name of the album upon which the song resides
*
* @return the album name
*/
public String getAlbum();
/**
* Get the track number of this track on the album
*
* @return the track number
*/
public int getTrack();
/**
* Get the genre string of the music
*
* @return the genre string
*/
public String getGenre();
/**
* Get the year the track was released
*
* @return the year the track was released
*/
public String getYear();
/**
* Get any comments provided about the song
*
* @return the comments
*/
public Vector getComment();
}

View File

@@ -1,399 +0,0 @@
/*
* TagInfoFactory.
*
* 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.tag;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.net.MalformedURLException;
import java.net.URL;
import javax.sound.sampled.UnsupportedAudioFileException;
import javazoom.jlgui.player.amp.tag.ui.APEDialog;
import javazoom.jlgui.player.amp.tag.ui.EmptyDialog;
import javazoom.jlgui.player.amp.tag.ui.FlacDialog;
import javazoom.jlgui.player.amp.tag.ui.MpegDialog;
import javazoom.jlgui.player.amp.tag.ui.OggVorbisDialog;
import javazoom.jlgui.player.amp.tag.ui.TagInfoDialog;
import javazoom.jlgui.player.amp.util.Config;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* This class is a factory for TagInfo and TagInfoDialog.
* It allows to any plug custom TagIngfo parser matching to TagInfo
* interface.
*/
public class TagInfoFactory
{
private static Log log = LogFactory.getLog(TagInfoFactory.class);
private static TagInfoFactory instance = null;
private Class MpegTagInfoClass = null;
private Class VorbisTagInfoClass = null;
private Class APETagInfoClass = null;
private Class FlacTagInfoClass = null;
private Config conf = null;
private TagInfoFactory()
{
super();
conf = Config.getInstance();
String classname = conf.getMpegTagInfoClassName();
MpegTagInfoClass = getTagInfoImpl(classname);
if (MpegTagInfoClass == null)
{
log.error("Error : TagInfo implementation not found in " + classname + " hierarchy");
MpegTagInfoClass = getTagInfoImpl("javazoom.jlgui.player.amp.tag.MpegInfo");
}
classname = conf.getOggVorbisTagInfoClassName();
VorbisTagInfoClass = getTagInfoImpl(classname);
if (VorbisTagInfoClass == null)
{
log.error("Error : TagInfo implementation not found in " + classname + " hierarchy");
VorbisTagInfoClass = getTagInfoImpl("javazoom.jlgui.player.amp.tag.OggVorbisInfo");
}
classname = conf.getAPETagInfoClassName();
APETagInfoClass = getTagInfoImpl(classname);
if (APETagInfoClass == null)
{
log.error("Error : TagInfo implementation not found in " + classname + " hierarchy");
APETagInfoClass = getTagInfoImpl("javazoom.jlgui.player.amp.tag.APEInfo");
}
classname = conf.getFlacTagInfoClassName();
FlacTagInfoClass = getTagInfoImpl(classname);
if (FlacTagInfoClass == null)
{
log.error("Error : TagInfo implementation not found in " + classname + " hierarchy");
FlacTagInfoClass = getTagInfoImpl("javazoom.jlgui.player.amp.tag.FlacInfo");
}
}
public static synchronized TagInfoFactory getInstance()
{
if (instance == null)
{
instance = new TagInfoFactory();
}
return instance;
}
/**
* Return tag info from a given URL.
*
* @param location
* @return TagInfo structure for given URL
*/
public TagInfo getTagInfo(URL location)
{
TagInfo taginfo;
try
{
taginfo = getTagInfoImplInstance(MpegTagInfoClass);
taginfo.load(location);
}
catch (IOException ex)
{
log.debug(ex);
taginfo = null;
}
catch (UnsupportedAudioFileException ex)
{
// Not Mpeg Format
taginfo = null;
}
if (taginfo == null)
{
// Check Ogg Vorbis format.
try
{
taginfo = getTagInfoImplInstance(VorbisTagInfoClass);
taginfo.load(location);
}
catch (UnsupportedAudioFileException ex)
{
// Not Ogg Vorbis Format
taginfo = null;
}
catch (IOException ex)
{
log.debug(ex);
taginfo = null;
}
}
if (taginfo == null)
{
// Check APE format.
try
{
taginfo = getTagInfoImplInstance(APETagInfoClass);
taginfo.load(location);
}
catch (UnsupportedAudioFileException ex)
{
// Not APE Format
taginfo = null;
}
catch (IOException ex)
{
log.debug(ex);
taginfo = null;
}
}
if (taginfo == null)
{
// Check Flac format.
try
{
taginfo = getTagInfoImplInstance(FlacTagInfoClass);
taginfo.load(location);
}
catch (UnsupportedAudioFileException ex)
{
// Not Flac Format
taginfo = null;
}
catch (IOException ex)
{
log.debug(ex);
taginfo = null;
}
}
return taginfo;
}
/**
* Return tag info from a given String.
*
* @param location
* @return TagInfo structure for given location
*/
public TagInfo getTagInfo(String location)
{
if (Config.startWithProtocol(location))
{
try
{
return getTagInfo(new URL(location));
}
catch (MalformedURLException e)
{
return null;
}
}
else
{
return getTagInfo(new File(location));
}
}
/**
* Get TagInfo for given file.
*
* @param location
* @return TagInfo structure for given location
*/
public TagInfo getTagInfo(File location)
{
TagInfo taginfo;
// Check Mpeg format.
try
{
taginfo = getTagInfoImplInstance(MpegTagInfoClass);
taginfo.load(location);
}
catch (IOException ex)
{
log.debug(ex);
taginfo = null;
}
catch (UnsupportedAudioFileException ex)
{
// Not Mpeg Format
taginfo = null;
}
if (taginfo == null)
{
// Check Ogg Vorbis format.
try
{
//taginfo = new OggVorbisInfo(location);
taginfo = getTagInfoImplInstance(VorbisTagInfoClass);
taginfo.load(location);
}
catch (UnsupportedAudioFileException ex)
{
// Not Ogg Vorbis Format
taginfo = null;
}
catch (IOException ex)
{
log.debug(ex);
taginfo = null;
}
}
if (taginfo == null)
{
// Check APE format.
try
{
taginfo = getTagInfoImplInstance(APETagInfoClass);
taginfo.load(location);
}
catch (UnsupportedAudioFileException ex)
{
// Not APE Format
taginfo = null;
}
catch (IOException ex)
{
log.debug(ex);
taginfo = null;
}
}
if (taginfo == null)
{
// Check Flac format.
try
{
taginfo = getTagInfoImplInstance(FlacTagInfoClass);
taginfo.load(location);
}
catch (UnsupportedAudioFileException ex)
{
// Not Flac Format
taginfo = null;
}
catch (IOException ex)
{
log.debug(ex);
taginfo = null;
}
}
return taginfo;
}
/**
* Return dialog (graphical) to display tag info.
*
* @param taginfo
* @return TagInfoDialog for given TagInfo
*/
public TagInfoDialog getTagInfoDialog(TagInfo taginfo)
{
TagInfoDialog dialog;
if (taginfo != null)
{
if (taginfo instanceof OggVorbisInfo)
{
dialog = new OggVorbisDialog(conf.getTopParent(), "OggVorbis info", (OggVorbisInfo) taginfo);
}
else if (taginfo instanceof MpegInfo)
{
dialog = new MpegDialog(conf.getTopParent(), "Mpeg info", (MpegInfo) taginfo);
}
else if (taginfo instanceof APEInfo)
{
dialog = new APEDialog(conf.getTopParent(), "Ape info", (APEInfo) taginfo);
}
else if (taginfo instanceof FlacInfo)
{
dialog = new FlacDialog(conf.getTopParent(), "Flac info", (FlacInfo) taginfo);
}
else
{
dialog = new EmptyDialog(conf.getTopParent(), "No info", taginfo);
}
}
else
{
dialog = new EmptyDialog(conf.getTopParent(), "No info", null);
}
return dialog;
}
/**
* Load and check class implementation from classname.
*
* @param classname
* @return TagInfo implementation for given class name
*/
public Class getTagInfoImpl(String classname)
{
Class aClass = null;
boolean interfaceFound = false;
if (classname != null)
{
try
{
aClass = Class.forName(classname);
Class superClass = aClass;
// Looking for TagInfo interface implementation.
while (superClass != null)
{
Class[] interfaces = superClass.getInterfaces();
for (int i = 0; i < interfaces.length; i++)
{
if ((interfaces[i].getName()).equals("javazoom.jlgui.player.amp.tag.TagInfo"))
{
interfaceFound = true;
break;
}
}
if (interfaceFound) break;
superClass = superClass.getSuperclass();
}
if (interfaceFound) log.info(classname + " loaded");
else log.info(classname + " not loaded");
}
catch (ClassNotFoundException e)
{
log.error("Error : " + classname + " : " + e.getMessage());
}
}
return aClass;
}
/**
* Return new instance of given class.
*
* @param aClass
* @return TagInfo for given class
*/
public TagInfo getTagInfoImplInstance(Class aClass)
{
TagInfo instance = null;
if (aClass != null)
{
try
{
Class[] argsClass = new Class[] {};
Constructor c = aClass.getConstructor(argsClass);
instance = (TagInfo) (c.newInstance(null));
}
catch (Exception e)
{
log.error("Cannot Instanciate : " + aClass.getName() + " : " + e.getMessage());
}
}
return instance;
}
}

View File

@@ -1,187 +0,0 @@
/*
* APEDialog.
*
* 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.tag.ui;
import java.text.DecimalFormat;
import javax.swing.JFrame;
import javazoom.jlgui.player.amp.tag.APEInfo;
/**
* APEDialog class implements a DialogBox to diplay APE info.
*/
public class APEDialog extends TagInfoDialog
{
private APEInfo _apeinfo = null;
/**
* Creates new form ApeDialog
*/
public APEDialog(JFrame parent, String title, APEInfo mi)
{
super(parent, title);
initComponents();
_apeinfo = mi;
int size = _apeinfo.getLocation().length();
locationLabel.setText(size > 50 ? ("..." + _apeinfo.getLocation().substring(size - 50)) : _apeinfo.getLocation());
if ((_apeinfo.getTitle() != null) && (!_apeinfo.getTitle().equals(""))) textField.append("Title=" + _apeinfo.getTitle() + "\n");
if ((_apeinfo.getArtist() != null) && (!_apeinfo.getArtist().equals(""))) textField.append("Artist=" + _apeinfo.getArtist() + "\n");
if ((_apeinfo.getAlbum() != null) && (!_apeinfo.getAlbum().equals(""))) textField.append("Album=" + _apeinfo.getAlbum() + "\n");
if (_apeinfo.getTrack() > 0) textField.append("Track=" + _apeinfo.getTrack() + "\n");
if ((_apeinfo.getYear() != null) && (!_apeinfo.getYear().equals(""))) textField.append("Year=" + _apeinfo.getYear() + "\n");
if ((_apeinfo.getGenre() != null) && (!_apeinfo.getGenre().equals(""))) textField.append("Genre=" + _apeinfo.getGenre() + "\n");
java.util.List comments = _apeinfo.getComment();
if (comments != null)
{
for (int i = 0; i < comments.size(); i++)
textField.append(comments.get(i) + "\n");
}
int secondsAmount = Math.round(_apeinfo.getPlayTime());
if (secondsAmount < 0) secondsAmount = 0;
int minutes = secondsAmount / 60;
int seconds = secondsAmount - (minutes * 60);
lengthLabel.setText("Length : " + minutes + ":" + seconds);
DecimalFormat df = new DecimalFormat("#,###,###");
sizeLabel.setText("Size : " + df.format(_apeinfo.getSize()) + " bytes");
versionLabel.setText("Version: " + df.format(_apeinfo.getVersion()));
compressionLabel.setText("Compression: " + _apeinfo.getCompressionlevel());
channelsLabel.setText("Channels: " + _apeinfo.getChannels());
bitspersampleLabel.setText("Bits Per Sample: " + _apeinfo.getBitsPerSample());
bitrateLabel.setText("Average Bitrate: " + (_apeinfo.getBitRate() / 1000) + " kbps");
samplerateLabel.setText("Sample Rate: " + _apeinfo.getSamplingRate() + " Hz");
peaklevelLabel.setText("Peak Level: " + (_apeinfo.getPeaklevel() > 0 ? String.valueOf(_apeinfo.getPeaklevel()) : ""));
copyrightLabel.setText("Copyrighted: " + (_apeinfo.getCopyright() != null ? _apeinfo.getCopyright() : ""));
buttonsPanel.add(_close);
pack();
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents()
{
java.awt.GridBagConstraints gridBagConstraints;
jPanel3 = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
locationLabel = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
textField = new javax.swing.JTextArea();
jPanel2 = new javax.swing.JPanel();
lengthLabel = new javax.swing.JLabel();
sizeLabel = new javax.swing.JLabel();
versionLabel = new javax.swing.JLabel();
compressionLabel = new javax.swing.JLabel();
channelsLabel = new javax.swing.JLabel();
bitspersampleLabel = new javax.swing.JLabel();
bitrateLabel = new javax.swing.JLabel();
samplerateLabel = new javax.swing.JLabel();
peaklevelLabel = new javax.swing.JLabel();
copyrightLabel = new javax.swing.JLabel();
buttonsPanel = new javax.swing.JPanel();
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);
jPanel3.setLayout(new java.awt.GridBagLayout());
jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
jLabel1.setText("File/URL :");
jPanel1.add(jLabel1);
jPanel1.add(locationLabel);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jPanel1, gridBagConstraints);
jLabel2.setText("Standard Tags");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jLabel2, gridBagConstraints);
jLabel3.setText("File/Stream info");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jLabel3, gridBagConstraints);
textField.setColumns(20);
textField.setRows(10);
jScrollPane1.setViewportView(textField);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jScrollPane1, gridBagConstraints);
jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS));
jPanel2.add(lengthLabel);
jPanel2.add(sizeLabel);
jPanel2.add(versionLabel);
jPanel2.add(compressionLabel);
jPanel2.add(channelsLabel);
jPanel2.add(bitspersampleLabel);
jPanel2.add(bitrateLabel);
jPanel2.add(samplerateLabel);
jPanel2.add(peaklevelLabel);
jPanel2.add(copyrightLabel);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jPanel2, gridBagConstraints);
getContentPane().add(jPanel3);
getContentPane().add(buttonsPanel);
//pack();
}
// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel bitrateLabel;
private javax.swing.JLabel bitspersampleLabel;
private javax.swing.JPanel buttonsPanel;
private javax.swing.JLabel channelsLabel;
private javax.swing.JLabel compressionLabel;
private javax.swing.JLabel copyrightLabel;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel lengthLabel;
private javax.swing.JLabel locationLabel;
private javax.swing.JLabel peaklevelLabel;
private javax.swing.JLabel samplerateLabel;
private javax.swing.JLabel sizeLabel;
private javax.swing.JTextArea textField;
private javax.swing.JLabel versionLabel;
// End of variables declaration//GEN-END:variables
}

View File

@@ -1,75 +0,0 @@
/*
* EmptyDialog.
*
* 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.tag.ui;
import javax.swing.JFrame;
import javazoom.jlgui.player.amp.tag.TagInfo;
/**
* OggVorbisDialog class implements a DialogBox to diplay OggVorbis info.
*/
public class EmptyDialog extends TagInfoDialog
{
private TagInfo _info = null;
/**
* Creates new form MpegDialog
*/
public EmptyDialog(JFrame parent, String title, TagInfo mi)
{
super(parent, title);
initComponents();
_info = mi;
buttonsPanel.add(_close);
pack();
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents()
{
jPanel3 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
buttonsPanel = new javax.swing.JPanel();
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("No Information Available");
jPanel3.add(jLabel1);
getContentPane().add(jPanel3);
getContentPane().add(buttonsPanel);
//pack();
}
// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel buttonsPanel;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel3;
// End of variables declaration//GEN-END:variables
}

View File

@@ -1,165 +0,0 @@
/*
* FlacDialog.
*
* 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.tag.ui;
import java.text.DecimalFormat;
import javax.swing.JFrame;
import javazoom.jlgui.player.amp.tag.FlacInfo;
/**
* FlacDialog class implements a DialogBox to diplay Flac info.
*/
public class FlacDialog extends TagInfoDialog
{
private FlacInfo _flacinfo = null;
/**
* Creates new form FlacDialog
*/
public FlacDialog(JFrame parent, String title, FlacInfo mi)
{
super(parent, title);
initComponents();
_flacinfo = mi;
int size = _flacinfo.getLocation().length();
locationLabel.setText(size > 50 ? ("..." + _flacinfo.getLocation().substring(size - 50)) : _flacinfo.getLocation());
if ((_flacinfo.getTitle() != null) && (!_flacinfo.getTitle().equals(""))) textField.append("Title=" + _flacinfo.getTitle() + "\n");
if ((_flacinfo.getArtist() != null) && (!_flacinfo.getArtist().equals(""))) textField.append("Artist=" + _flacinfo.getArtist() + "\n");
if ((_flacinfo.getAlbum() != null) && (!_flacinfo.getAlbum().equals(""))) textField.append("Album=" + _flacinfo.getAlbum() + "\n");
if (_flacinfo.getTrack() > 0) textField.append("Track=" + _flacinfo.getTrack() + "\n");
if ((_flacinfo.getYear() != null) && (!_flacinfo.getYear().equals(""))) textField.append("Year=" + _flacinfo.getYear() + "\n");
if ((_flacinfo.getGenre() != null) && (!_flacinfo.getGenre().equals(""))) textField.append("Genre=" + _flacinfo.getGenre() + "\n");
java.util.List comments = _flacinfo.getComment();
if (comments != null)
{
for (int i = 0; i < comments.size(); i++)
textField.append(comments.get(i) + "\n");
}
DecimalFormat df = new DecimalFormat("#,###,###");
sizeLabel.setText("Size : " + df.format(_flacinfo.getSize()) + " bytes");
channelsLabel.setText("Channels: " + _flacinfo.getChannels());
bitspersampleLabel.setText("Bits Per Sample: " + _flacinfo.getBitsPerSample());
samplerateLabel.setText("Sample Rate: " + _flacinfo.getSamplingRate() + " Hz");
buttonsPanel.add(_close);
pack();
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents()
{
java.awt.GridBagConstraints gridBagConstraints;
jPanel3 = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
locationLabel = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
textField = new javax.swing.JTextArea();
jPanel2 = new javax.swing.JPanel();
lengthLabel = new javax.swing.JLabel();
sizeLabel = new javax.swing.JLabel();
channelsLabel = new javax.swing.JLabel();
bitspersampleLabel = new javax.swing.JLabel();
bitrateLabel = new javax.swing.JLabel();
samplerateLabel = new javax.swing.JLabel();
buttonsPanel = new javax.swing.JPanel();
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);
jPanel3.setLayout(new java.awt.GridBagLayout());
jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
jLabel1.setText("File/URL :");
jPanel1.add(jLabel1);
jPanel1.add(locationLabel);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jPanel1, gridBagConstraints);
jLabel2.setText("Standard Tags");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jLabel2, gridBagConstraints);
jLabel3.setText("File/Stream info");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jLabel3, gridBagConstraints);
textField.setColumns(20);
textField.setRows(10);
jScrollPane1.setViewportView(textField);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jScrollPane1, gridBagConstraints);
jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS));
jPanel2.add(lengthLabel);
jPanel2.add(sizeLabel);
jPanel2.add(channelsLabel);
jPanel2.add(bitspersampleLabel);
jPanel2.add(bitrateLabel);
jPanel2.add(samplerateLabel);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jPanel2, gridBagConstraints);
getContentPane().add(jPanel3);
getContentPane().add(buttonsPanel);
//pack();
}
// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel bitrateLabel;
private javax.swing.JLabel bitspersampleLabel;
private javax.swing.JPanel buttonsPanel;
private javax.swing.JLabel channelsLabel;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel lengthLabel;
private javax.swing.JLabel locationLabel;
private javax.swing.JLabel samplerateLabel;
private javax.swing.JLabel sizeLabel;
private javax.swing.JTextArea textField;
// End of variables declaration//GEN-END:variables
}

View File

@@ -1,194 +0,0 @@
/*
* MpegDialog.
*
* 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.tag.ui;
import java.text.DecimalFormat;
import javax.swing.JFrame;
import javazoom.jlgui.player.amp.tag.MpegInfo;
/**
* OggVorbisDialog class implements a DialogBox to diplay OggVorbis info.
*/
public class MpegDialog extends TagInfoDialog
{
private MpegInfo _mpeginfo = null;
/**
* Creates new form MpegDialog
*/
public MpegDialog(JFrame parent, String title, MpegInfo mi)
{
super(parent, title);
initComponents();
_mpeginfo = mi;
int size = _mpeginfo.getLocation().length();
locationLabel.setText(size > 50 ? ("..." + _mpeginfo.getLocation().substring(size - 50)) : _mpeginfo.getLocation());
if ((_mpeginfo.getTitle() != null) && ((!_mpeginfo.getTitle().equals("")))) textField.append("Title=" + _mpeginfo.getTitle() + "\n");
if ((_mpeginfo.getArtist() != null) && ((!_mpeginfo.getArtist().equals("")))) textField.append("Artist=" + _mpeginfo.getArtist() + "\n");
if ((_mpeginfo.getAlbum() != null) && ((!_mpeginfo.getAlbum().equals("")))) textField.append("Album=" + _mpeginfo.getAlbum() + "\n");
if (_mpeginfo.getTrack() > 0) textField.append("Track=" + _mpeginfo.getTrack() + "\n");
if ((_mpeginfo.getYear() != null) && ((!_mpeginfo.getYear().equals("")))) textField.append("Year=" + _mpeginfo.getYear() + "\n");
if ((_mpeginfo.getGenre() != null) && ((!_mpeginfo.getGenre().equals("")))) textField.append("Genre=" + _mpeginfo.getGenre() + "\n");
java.util.List comments = _mpeginfo.getComment();
if (comments != null)
{
for (int i = 0; i < comments.size(); i++)
textField.append(comments.get(i) + "\n");
}
int secondsAmount = Math.round(_mpeginfo.getPlayTime());
if (secondsAmount < 0) secondsAmount = 0;
int minutes = secondsAmount / 60;
int seconds = secondsAmount - (minutes * 60);
lengthLabel.setText("Length : " + minutes + ":" + seconds);
DecimalFormat df = new DecimalFormat("#,###,###");
sizeLabel.setText("Size : " + df.format(_mpeginfo.getSize()) + " bytes");
versionLabel.setText(_mpeginfo.getVersion() + " " + _mpeginfo.getLayer());
bitrateLabel.setText((_mpeginfo.getBitRate() / 1000) + " kbps");
samplerateLabel.setText(_mpeginfo.getSamplingRate() + " Hz " + _mpeginfo.getChannelsMode());
vbrLabel.setText("VBR : " + _mpeginfo.getVBR());
crcLabel.setText("CRCs : " + _mpeginfo.getCRC());
copyrightLabel.setText("Copyrighted : " + _mpeginfo.getCopyright());
originalLabel.setText("Original : " + _mpeginfo.getOriginal());
emphasisLabel.setText("Emphasis : " + _mpeginfo.getEmphasis());
buttonsPanel.add(_close);
pack();
}
/**
* Returns VorbisInfo.
*/
public MpegInfo getOggVorbisInfo()
{
return _mpeginfo;
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents()
{
java.awt.GridBagConstraints gridBagConstraints;
jPanel3 = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
locationLabel = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
textField = new javax.swing.JTextArea();
jPanel2 = new javax.swing.JPanel();
lengthLabel = new javax.swing.JLabel();
sizeLabel = new javax.swing.JLabel();
versionLabel = new javax.swing.JLabel();
bitrateLabel = new javax.swing.JLabel();
samplerateLabel = new javax.swing.JLabel();
vbrLabel = new javax.swing.JLabel();
crcLabel = new javax.swing.JLabel();
copyrightLabel = new javax.swing.JLabel();
originalLabel = new javax.swing.JLabel();
emphasisLabel = new javax.swing.JLabel();
buttonsPanel = new javax.swing.JPanel();
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);
jPanel3.setLayout(new java.awt.GridBagLayout());
jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
jLabel1.setText("File/URL :");
jPanel1.add(jLabel1);
jPanel1.add(locationLabel);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jPanel1, gridBagConstraints);
jLabel2.setText("Standard Tags");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jLabel2, gridBagConstraints);
jLabel3.setText("File/Stream info");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jLabel3, gridBagConstraints);
textField.setColumns(20);
textField.setRows(10);
jScrollPane1.setViewportView(textField);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jScrollPane1, gridBagConstraints);
jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS));
jPanel2.add(lengthLabel);
jPanel2.add(sizeLabel);
jPanel2.add(versionLabel);
jPanel2.add(bitrateLabel);
jPanel2.add(samplerateLabel);
jPanel2.add(vbrLabel);
jPanel2.add(crcLabel);
jPanel2.add(copyrightLabel);
jPanel2.add(originalLabel);
jPanel2.add(emphasisLabel);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jPanel2, gridBagConstraints);
getContentPane().add(jPanel3);
getContentPane().add(buttonsPanel);
//pack();
}
// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel bitrateLabel;
private javax.swing.JPanel buttonsPanel;
private javax.swing.JLabel copyrightLabel;
private javax.swing.JLabel crcLabel;
private javax.swing.JLabel emphasisLabel;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel lengthLabel;
private javax.swing.JLabel locationLabel;
private javax.swing.JLabel originalLabel;
private javax.swing.JLabel samplerateLabel;
private javax.swing.JLabel sizeLabel;
private javax.swing.JTextArea textField;
private javax.swing.JLabel vbrLabel;
private javax.swing.JLabel versionLabel;
// End of variables declaration//GEN-END:variables
}

View File

@@ -1,196 +0,0 @@
/*
* OggVorbisDialog.
*
* 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.tag.ui;
import java.text.DecimalFormat;
import javax.swing.JFrame;
import javazoom.jlgui.player.amp.tag.OggVorbisInfo;
/**
* OggVorbisDialog class implements a DialogBox to diplay OggVorbis info.
*/
public class OggVorbisDialog extends TagInfoDialog
{
private OggVorbisInfo _vorbisinfo = null;
/**
* Creates new form MpegDialog
*/
public OggVorbisDialog(JFrame parent, String title, OggVorbisInfo mi)
{
super(parent, title);
initComponents();
_vorbisinfo = mi;
int size = _vorbisinfo.getLocation().length();
locationLabel.setText(size > 50 ? ("..." + _vorbisinfo.getLocation().substring(size - 50)) : _vorbisinfo.getLocation());
if ((_vorbisinfo.getTitle() != null) && ((!_vorbisinfo.getTitle().equals("")))) textField.append("Title=" + _vorbisinfo.getTitle() + "\n");
if ((_vorbisinfo.getArtist() != null) && ((!_vorbisinfo.getArtist().equals("")))) textField.append("Artist=" + _vorbisinfo.getArtist() + "\n");
if ((_vorbisinfo.getAlbum() != null) && ((!_vorbisinfo.getAlbum().equals("")))) textField.append("Album=" + _vorbisinfo.getAlbum() + "\n");
if (_vorbisinfo.getTrack() > 0) textField.append("Track=" + _vorbisinfo.getTrack() + "\n");
if ((_vorbisinfo.getYear() != null) && ((!_vorbisinfo.getYear().equals("")))) textField.append("Year=" + _vorbisinfo.getYear() + "\n");
if ((_vorbisinfo.getGenre() != null) && ((!_vorbisinfo.getGenre().equals("")))) textField.append("Genre=" + _vorbisinfo.getGenre() + "\n");
java.util.List comments = _vorbisinfo.getComment();
for (int i = 0; i < comments.size(); i++)
textField.append(comments.get(i) + "\n");
int secondsAmount = Math.round(_vorbisinfo.getPlayTime());
if (secondsAmount < 0) secondsAmount = 0;
int minutes = secondsAmount / 60;
int seconds = secondsAmount - (minutes * 60);
lengthLabel.setText("Length : " + minutes + ":" + seconds);
bitrateLabel.setText("Average bitrate : " + _vorbisinfo.getAverageBitrate() / 1000 + " kbps");
DecimalFormat df = new DecimalFormat("#,###,###");
sizeLabel.setText("File size : " + df.format(_vorbisinfo.getSize()) + " bytes");
nominalbitrateLabel.setText("Nominal bitrate : " + (_vorbisinfo.getBitRate() / 1000) + " kbps");
maxbitrateLabel.setText("Max bitrate : " + _vorbisinfo.getMaxBitrate() / 1000 + " kbps");
minbitrateLabel.setText("Min bitrate : " + _vorbisinfo.getMinBitrate() / 1000 + " kbps");
channelsLabel.setText("Channel : " + _vorbisinfo.getChannels());
samplerateLabel.setText("Sampling rate : " + _vorbisinfo.getSamplingRate() + " Hz");
serialnumberLabel.setText("Serial number : " + _vorbisinfo.getSerial());
versionLabel.setText("Version : " + _vorbisinfo.getVersion());
vendorLabel.setText("Vendor : " + _vorbisinfo.getVendor());
buttonsPanel.add(_close);
pack();
}
/**
* Returns VorbisInfo.
*/
public OggVorbisInfo getOggVorbisInfo()
{
return _vorbisinfo;
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents()
{
java.awt.GridBagConstraints gridBagConstraints;
jPanel3 = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
locationLabel = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
textField = new javax.swing.JTextArea();
jPanel2 = new javax.swing.JPanel();
lengthLabel = new javax.swing.JLabel();
bitrateLabel = new javax.swing.JLabel();
sizeLabel = new javax.swing.JLabel();
nominalbitrateLabel = new javax.swing.JLabel();
maxbitrateLabel = new javax.swing.JLabel();
minbitrateLabel = new javax.swing.JLabel();
channelsLabel = new javax.swing.JLabel();
samplerateLabel = new javax.swing.JLabel();
serialnumberLabel = new javax.swing.JLabel();
versionLabel = new javax.swing.JLabel();
vendorLabel = new javax.swing.JLabel();
buttonsPanel = new javax.swing.JPanel();
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);
jPanel3.setLayout(new java.awt.GridBagLayout());
jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
jLabel1.setText("File/URL :");
jPanel1.add(jLabel1);
jPanel1.add(locationLabel);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jPanel1, gridBagConstraints);
jLabel2.setText("Standard Tags");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jLabel2, gridBagConstraints);
jLabel3.setText("File/Stream info");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jLabel3, gridBagConstraints);
textField.setColumns(20);
textField.setRows(10);
jScrollPane1.setViewportView(textField);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jScrollPane1, gridBagConstraints);
jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS));
jPanel2.add(lengthLabel);
jPanel2.add(bitrateLabel);
jPanel2.add(sizeLabel);
jPanel2.add(nominalbitrateLabel);
jPanel2.add(maxbitrateLabel);
jPanel2.add(minbitrateLabel);
jPanel2.add(channelsLabel);
jPanel2.add(samplerateLabel);
jPanel2.add(serialnumberLabel);
jPanel2.add(versionLabel);
jPanel2.add(vendorLabel);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel3.add(jPanel2, gridBagConstraints);
getContentPane().add(jPanel3);
getContentPane().add(buttonsPanel);
//pack();
}
// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel bitrateLabel;
private javax.swing.JPanel buttonsPanel;
private javax.swing.JLabel channelsLabel;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel lengthLabel;
private javax.swing.JLabel locationLabel;
private javax.swing.JLabel maxbitrateLabel;
private javax.swing.JLabel minbitrateLabel;
private javax.swing.JLabel nominalbitrateLabel;
private javax.swing.JLabel samplerateLabel;
private javax.swing.JLabel serialnumberLabel;
private javax.swing.JLabel sizeLabel;
private javax.swing.JTextArea textField;
private javax.swing.JLabel vendorLabel;
private javax.swing.JLabel versionLabel;
// End of variables declaration//GEN-END:variables
}

View File

@@ -1,60 +0,0 @@
/*
* TagInfoDialog.
*
* 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.tag.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
/**
* This class define a Dialog for TagiInfo to display.
*/
public class TagInfoDialog extends JDialog implements ActionListener
{
protected JButton _close = null;
/**
* Constructor.
* @param parent
* @param title
*/
public TagInfoDialog(JFrame parent, String title)
{
super(parent, title, true);
_close = new JButton("Close");
_close.addActionListener(this);
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == _close)
{
this.dispose();
}
}
}

View File

@@ -1,434 +0,0 @@
/*
* TagSearch.
*
* 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.tag.ui;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ResourceBundle;
import java.util.Vector;
import javax.swing.ButtonGroup;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.WindowConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javazoom.jlgui.player.amp.PlayerUI;
import javazoom.jlgui.player.amp.playlist.Playlist;
import javazoom.jlgui.player.amp.playlist.PlaylistItem;
import javazoom.jlgui.player.amp.tag.TagInfo;
/**
* This class allows to search and play for a particular track in the current playlist.
*/
public class TagSearch extends JFrame
{
private static String sep = System.getProperty("file.separator");
private JTextField searchField;
private JList list;
private DefaultListModel m;
private PlayerUI player;
private Vector _playlist, restrictedPlaylist;
private String lastSearch = null;
private JScrollPane scroll;
private ResourceBundle bundle;
private JRadioButton all, artist, album, title;
public TagSearch(PlayerUI ui)
{
super();
player = ui;
_playlist = null;
restrictedPlaylist = null;
bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/tag/ui/tag");
initComponents();
}
public void display()
{
if (list.getModel().getSize() != 0)
{
setVisible(true);
}
else
{
JOptionPane.showMessageDialog(player.getParent(), bundle.getString("emptyPlaylistMsg"), bundle.getString("emptyPlaylistTitle"), JOptionPane.OK_OPTION);
}
}
/**
* Initialises the User Interface.
*/
private void initComponents()
{
setLayout(new GridLayout(1, 1));
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setTitle(bundle.getString("title"));
this.setLocation(player.getX() + player.getWidth(), player.getY());
JPanel main = new JPanel(new BorderLayout(0, 1));
main.setBorder(new EmptyBorder(10, 10, 10, 10));
main.setMinimumSize(new java.awt.Dimension(0, 0));
main.setPreferredSize(new java.awt.Dimension(300, 400));
JPanel searchPane = new JPanel(new GridLayout(4, 1, 10, 2));
JLabel searchLabel = new JLabel(bundle.getString("searchLabel"));
searchField = new JTextField();
searchField.addKeyListener(new KeyboardListener());
searchPane.add(searchLabel);
searchPane.add(searchField);
all = new JRadioButton(bundle.getString("radioAll"), true);
artist = new JRadioButton(bundle.getString("radioArtist"), false);
album = new JRadioButton(bundle.getString("radioAlbum"), false);
title = new JRadioButton(bundle.getString("radioTitle"), false);
all.addChangeListener(new RadioListener());
ButtonGroup filters = new ButtonGroup();
filters.add(all);
filters.add(artist);
filters.add(album);
filters.add(title);
JPanel topButtons = new JPanel(new GridLayout(1, 2));
JPanel bottomButtons = new JPanel(new GridLayout(1, 2));
topButtons.add(all);
topButtons.add(artist);
bottomButtons.add(album);
bottomButtons.add(title);
searchPane.add(topButtons);
searchPane.add(bottomButtons);
list = new JList();
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
initList();
list.addMouseListener(new ClickListener());
list.addKeyListener(new KeyboardListener());
scroll = new JScrollPane(list);
main.add(searchPane, BorderLayout.NORTH);
main.add(scroll, BorderLayout.CENTER);
add(main);
pack();
}
/**
* Initialises the list so that it displays the details of all songs in the playlist.
*/
private void initList()
{
Playlist playlist = player.getPlaylist();
int c = player.getPlaylist().getPlaylistSize();
_playlist = new Vector();
for (int i = 0; i < c; i++)
{
_playlist.addElement(playlist.getItemAt(i));
}
restrictedPlaylist = _playlist;
m = new DefaultListModel();
for (int i = 0; i < _playlist.size(); i++)
{
PlaylistItem plItem = (PlaylistItem) _playlist.get(i);
if (plItem.isFile()) m.addElement(getDisplayString(plItem));
}
list.setModel(m);
}
public String getDisplayString(PlaylistItem pi)
{
TagInfo song = pi.getTagInfo();
String element;
String location = pi.getLocation();
location = location.substring(location.lastIndexOf(sep) + 1, location.lastIndexOf("."));
if (song == null)
{
element = location;
}
else
{
if (song.getArtist() == null || song.getArtist().equals(""))
{
element = location;
}
else
{
element = song.getArtist().trim();
if (song.getTitle() == null || song.getTitle().equals(""))
{
element += " - " + location;
}
else
{
element += " - " + song.getTitle().trim();
}
}
}
return element;
}
/**
* Searches the playlist for a song containing the words in the given search string.
* It searches on the title, artist, album and filename of each song in the playlist.
*
* @param searchString The string to search for in all songs in the playlist
**/
private void searchList(String searchString)
{
String[] s = searchString.split(" ");
String lastS = "";
if (s.length > 0) lastS = s[s.length - 1];
if (lastS.equals(""))
{
list.setModel(m);
restrictedPlaylist = _playlist;
}
else
{
DefaultListModel newModel = new DefaultListModel();
if (lastSearch != null)
{
if (searchString.length() <= 1 || !searchString.substring(searchString.length() - 2).equals(lastSearch))
{
list.setModel(m);
restrictedPlaylist = _playlist;
}
}
Vector pI = restrictedPlaylist;
restrictedPlaylist = new Vector();
for (int a = 0; a < s.length; a++)
{
String currentS = s[a];
int size = list.getModel().getSize();
boolean[] remove = new boolean[size];
for (int i = 0; i < size; i++)
{
final int TITLE_SEARCH = 0;
final int ARTIST_SEARCH = 1;
final int ALBUM_SEARCH = 2;
final int FILENAME_SEARCH = 3;
TagInfo pli = ((PlaylistItem) pI.get(i)).getTagInfo();
remove[i] = false;
boolean found = false;
int searchType;
if (artist.isSelected())
{
searchType = ARTIST_SEARCH;
}
else if (album.isSelected())
{
searchType = ALBUM_SEARCH;
}
else if (title.isSelected())
{
searchType = TITLE_SEARCH;
}
else
{
searchType = -1;
}
for (int j = 0; j <= FILENAME_SEARCH; j++)
{
String listString = "";
if (pli == null)
{
if (searchType != -1)
{
break;
}
j = FILENAME_SEARCH;
}
else if (searchType != -1)
{
j = searchType;
}
switch (j)
{
case (TITLE_SEARCH):
if (pli.getTitle() != null) listString = pli.getTitle().toLowerCase();
break;
case (ARTIST_SEARCH):
if (pli.getArtist() != null) listString = pli.getArtist().toLowerCase();
break;
case (ALBUM_SEARCH):
if (pli.getAlbum() != null) listString = pli.getAlbum().toLowerCase();
break;
case (FILENAME_SEARCH):
String location = ((PlaylistItem) pI.get(i)).getLocation().toLowerCase();
listString = location.substring(location.lastIndexOf(sep) + 1, location.lastIndexOf("."));
break;
}
currentS = currentS.toLowerCase();
if (found = search(currentS, listString))
{
break;
}
if (searchType != -1)
{
break;
}
}
//if(found)foundAt[a] = i;
if (found && a == 0)
{
//todo new
newModel.addElement(getDisplayString((PlaylistItem) pI.get(i)));
restrictedPlaylist.add(pI.get(i));
}
if (!found && a != 0)
{
remove[i] = true;
}
}
//remove all unmatching items
for (int x = size - 1; x >= 0; x--)
{
if (remove[x])
{
newModel.remove(x);
restrictedPlaylist.remove(x);
}
}
pI = restrictedPlaylist;
list.setModel(newModel);
}
list.setModel(newModel);
lastSearch = searchField.getText();
}
if (list.getModel().getSize() > 0) list.setSelectedIndex(0);
}
/**
* Searches to see if a particular string exists within another string
*
* @param pattern The string to search for
* @param text The string in which to search for the pattern string
* @return True if the pattern string exists in the text string
*/
private boolean search(String pattern, String text)
{
int pStart = 0;
int tStart = 0;
char[] pChar = pattern.toCharArray();
char[] tChar = text.toCharArray();
while (pStart < pChar.length && tStart < tChar.length)
{
if (pChar[pStart] == tChar[tStart])
{
pStart++;
tStart++;
}
else
{
pStart = 0;
if (pChar[pStart] != tChar[tStart])
{
tStart++;
}
}
}
return pStart == pChar.length;
}
/**
* Calls the relavent methods in the player class to play a song.
*/
private void playSong()
{
Playlist playlist = player.getPlaylist();
player.pressStop();
player.setCurrentSong((PlaylistItem) restrictedPlaylist.get(list.getSelectedIndex()));
playlist.setCursor(playlist.getIndex((PlaylistItem) restrictedPlaylist.get(list.getSelectedIndex())));
player.pressStart();
dispose();
}
/**
* Class to handle keyboard presses.
*/
class KeyboardListener implements KeyListener
{
public void keyReleased(KeyEvent e)
{
if (e.getSource().equals(searchField))
{
if (e.getKeyCode() != KeyEvent.VK_DOWN && e.getKeyCode() != KeyEvent.VK_UP)
{
searchList(searchField.getText()); // Search for current search string
}
}
}
public void keyTyped(KeyEvent e)
{
if (list.getSelectedIndex() != -1)
{
if (e.getKeyChar() == KeyEvent.VK_ENTER)
{
playSong();
}
}
}
public void keyPressed(KeyEvent e)
{
int index = list.getSelectedIndex();
if (e.getKeyCode() == KeyEvent.VK_DOWN && index < list.getModel().getSize() - 1)
{
//list.setSelectedIndex(index+1);
JScrollBar vBar = scroll.getVerticalScrollBar();
vBar.setValue(vBar.getValue() + vBar.getUnitIncrement() * 5);
}
else if (e.getKeyCode() == KeyEvent.VK_UP && index >= 0)
{
JScrollBar vBar = scroll.getVerticalScrollBar();
vBar.setValue(vBar.getValue() - vBar.getUnitIncrement() * 5);
//list.setSelectedIndex(index-1);
}
}
}
/**
* Class to play a song if one is double-clicked on on the search list.
*/
class ClickListener extends MouseAdapter
{
public void mouseClicked(MouseEvent e)
{
if (e.getClickCount() == 2 && list.getSelectedIndex() != -1)
{
playSong();
}
}
}
class RadioListener implements ChangeListener
{
public void stateChanged(ChangeEvent e)
{
searchList(searchField.getText());
}
}
}

View File

@@ -1,8 +0,0 @@
emptyPlaylistMsg = No files in playlist
emptyPlaylistTitle = No files in playlist
title = Jump to song...
searchLabel = Search for songs containing...
radioAll = Anywhere
radioArtist = Artist
radioAlbum = Album
radioTitle = Song Title

View File

@@ -1,301 +0,0 @@
/*
* BMPLoader.
*
* 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.awt.Image;
import java.awt.Toolkit;
import java.awt.image.ColorModel;
import java.awt.image.IndexColorModel;
import java.awt.image.MemoryImageSource;
import java.io.IOException;
import java.io.InputStream;
/**
* A decoder for Windows bitmap (.BMP) files.
* Compression not supported.
*/
public class BMPLoader
{
private InputStream is;
private int curPos = 0;
private int bitmapOffset; // starting position of image data
private int width; // image width in pixels
private int height; // image height in pixels
private short bitsPerPixel; // 1, 4, 8, or 24 (no color map)
private int compression; // 0 (none), 1 (8-bit RLE), or 2 (4-bit RLE)
private int actualSizeOfBitmap;
private int scanLineSize;
private int actualColorsUsed;
private byte r[], g[], b[]; // color palette
private int noOfEntries;
private byte[] byteData; // Unpacked data
private int[] intData; // Unpacked data
public BMPLoader()
{
}
public Image getBMPImage(InputStream stream) throws Exception
{
read(stream);
return Toolkit.getDefaultToolkit().createImage(getImageSource());
}
protected int readInt() throws IOException
{
int b1 = is.read();
int b2 = is.read();
int b3 = is.read();
int b4 = is.read();
curPos += 4;
return ((b4 << 24) + (b3 << 16) + (b2 << 8) + (b1 << 0));
}
protected short readShort() throws IOException
{
int b1 = is.read();
int b2 = is.read();
curPos += 4;
return (short) ((b2 << 8) + b1);
}
protected void getFileHeader() throws IOException, Exception
{
// Actual contents (14 bytes):
short fileType = 0x4d42;// always "BM"
int fileSize; // size of file in bytes
short reserved1 = 0; // always 0
short reserved2 = 0; // always 0
fileType = readShort();
if (fileType != 0x4d42) throw new Exception("Not a BMP file"); // wrong file type
fileSize = readInt();
reserved1 = readShort();
reserved2 = readShort();
bitmapOffset = readInt();
}
protected void getBitmapHeader() throws IOException
{
// Actual contents (40 bytes):
int size; // size of this header in bytes
short planes; // no. of color planes: always 1
int sizeOfBitmap; // size of bitmap in bytes (may be 0: if so, calculate)
int horzResolution; // horizontal resolution, pixels/meter (may be 0)
int vertResolution; // vertical resolution, pixels/meter (may be 0)
int colorsUsed; // no. of colors in palette (if 0, calculate)
int colorsImportant; // no. of important colors (appear first in palette) (0 means all are important)
boolean topDown;
int noOfPixels;
size = readInt();
width = readInt();
height = readInt();
planes = readShort();
bitsPerPixel = readShort();
compression = readInt();
sizeOfBitmap = readInt();
horzResolution = readInt();
vertResolution = readInt();
colorsUsed = readInt();
colorsImportant = readInt();
topDown = (height < 0);
noOfPixels = width * height;
// Scan line is padded with zeroes to be a multiple of four bytes
scanLineSize = ((width * bitsPerPixel + 31) / 32) * 4;
if (sizeOfBitmap != 0) actualSizeOfBitmap = sizeOfBitmap;
else
// a value of 0 doesn't mean zero - it means we have to calculate it
actualSizeOfBitmap = scanLineSize * height;
if (colorsUsed != 0) actualColorsUsed = colorsUsed;
else
// a value of 0 means we determine this based on the bits per pixel
if (bitsPerPixel < 16) actualColorsUsed = 1 << bitsPerPixel;
else actualColorsUsed = 0; // no palette
}
protected void getPalette() throws IOException
{
noOfEntries = actualColorsUsed;
//IJ.write("noOfEntries: " + noOfEntries);
if (noOfEntries > 0)
{
r = new byte[noOfEntries];
g = new byte[noOfEntries];
b = new byte[noOfEntries];
int reserved;
for (int i = 0; i < noOfEntries; i++)
{
b[i] = (byte) is.read();
g[i] = (byte) is.read();
r[i] = (byte) is.read();
reserved = is.read();
curPos += 4;
}
}
}
protected void unpack(byte[] rawData, int rawOffset, int[] intData, int intOffset, int w)
{
int j = intOffset;
int k = rawOffset;
int mask = 0xff;
for (int i = 0; i < w; i++)
{
int b0 = (((int) (rawData[k++])) & mask);
int b1 = (((int) (rawData[k++])) & mask) << 8;
int b2 = (((int) (rawData[k++])) & mask) << 16;
intData[j] = 0xff000000 | b0 | b1 | b2;
j++;
}
}
protected void unpack(byte[] rawData, int rawOffset, int bpp, byte[] byteData, int byteOffset, int w) throws Exception
{
int j = byteOffset;
int k = rawOffset;
byte mask;
int pixPerByte;
switch (bpp)
{
case 1:
mask = (byte) 0x01;
pixPerByte = 8;
break;
case 4:
mask = (byte) 0x0f;
pixPerByte = 2;
break;
case 8:
mask = (byte) 0xff;
pixPerByte = 1;
break;
default:
throw new Exception("Unsupported bits-per-pixel value");
}
for (int i = 0;;)
{
int shift = 8 - bpp;
for (int ii = 0; ii < pixPerByte; ii++)
{
byte br = rawData[k];
br >>= shift;
byteData[j] = (byte) (br & mask);
//System.out.println("Setting byteData[" + j + "]=" + Test.byteToHex(byteData[j]));
j++;
i++;
if (i == w) return;
shift -= bpp;
}
k++;
}
}
protected int readScanLine(byte[] b, int off, int len) throws IOException
{
int bytesRead = 0;
int l = len;
int r = 0;
while (len > 0)
{
bytesRead = is.read(b, off, len);
if (bytesRead == -1) return r == 0 ? -1 : r;
if (bytesRead == len) return l;
len -= bytesRead;
off += bytesRead;
r += bytesRead;
}
return l;
}
protected void getPixelData() throws IOException, Exception
{
byte[] rawData; // the raw unpacked data
// Skip to the start of the bitmap data (if we are not already there)
long skip = bitmapOffset - curPos;
if (skip > 0)
{
is.skip(skip);
curPos += skip;
}
int len = scanLineSize;
if (bitsPerPixel > 8) intData = new int[width * height];
else byteData = new byte[width * height];
rawData = new byte[actualSizeOfBitmap];
int rawOffset = 0;
int offset = (height - 1) * width;
for (int i = height - 1; i >= 0; i--)
{
int n = readScanLine(rawData, rawOffset, len);
if (n < len) throw new Exception("Scan line ended prematurely after " + n + " bytes");
if (bitsPerPixel > 8)
{
// Unpack and create one int per pixel
unpack(rawData, rawOffset, intData, offset, width);
}
else
{
// Unpack and create one byte per pixel
unpack(rawData, rawOffset, bitsPerPixel, byteData, offset, width);
}
rawOffset += len;
offset -= width;
}
}
public void read(InputStream is) throws IOException, Exception
{
this.is = is;
getFileHeader();
getBitmapHeader();
if (compression != 0) throw new Exception("BMP Compression not supported");
getPalette();
getPixelData();
}
public MemoryImageSource getImageSource()
{
ColorModel cm;
MemoryImageSource mis;
if (noOfEntries > 0)
{
// There is a color palette; create an IndexColorModel
cm = new IndexColorModel(bitsPerPixel, noOfEntries, r, g, b);
}
else
{
// There is no palette; use the default RGB color model
cm = ColorModel.getRGBdefault();
}
// Create MemoryImageSource
if (bitsPerPixel > 8)
{
// use one int per pixel
mis = new MemoryImageSource(width, height, cm, intData, 0, width);
}
else
{
// use one byte per pixel
mis = new MemoryImageSource(width, height, cm, byteData, 0, width);
}
return mis; // this can be used by JComponent.createImage()
}
}

View File

@@ -1,711 +0,0 @@
/*
* 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;
}
/**
* Returns X location.
*/
public int getXLocation()
{
return _x;
}
/**
* Returns Y location.
*/
public int getYLocation()
{
return _y;
}
/**
* Sets X,Y location.
*/
public void setLocation(int x, int y)
{
_x = x;
_y = y;
}
/**
* Sets Proxy info.
*/
public void setProxy(String url, int port, String login, String password)
{
_proxyServer = url;
_proxyPort = port;
_proxyLogin = login;
_proxyPassword = password;
}
/**
* Enables Proxy.
*/
public boolean enableProxy()
{
if ((_proxyServer != null) && (!_proxyServer.equals("")))
{
System.getProperties().put("proxySet", "true");
System.getProperties().put("proxyHost", _proxyServer);
System.getProperties().put("proxyPort", "" + _proxyPort);
return true;
}
else return false;
}
/**
* Returns PlaylistUI state.
*/
public boolean isPlaylistEnabled()
{
return _playlistEnabled;
}
/**
* Sets PlaylistUI state.
*/
public void setPlaylistEnabled(boolean ena)
{
_playlistEnabled = ena;
}
/**
* Returns ShuffleUI state.
*/
public boolean isShuffleEnabled()
{
return _shuffleEnabled;
}
/**
* Sets ShuffleUI state.
*/
public void setShuffleEnabled(boolean ena)
{
_shuffleEnabled = ena;
}
/**
* Returns RepeatUI state.
*/
public boolean isRepeatEnabled()
{
return _repeatEnabled;
}
/**
* Sets RepeatUI state.
*/
public void setRepeatEnabled(boolean ena)
{
_repeatEnabled = ena;
}
/**
* Returns EqualizerUI state.
*/
public boolean isEqualizerEnabled()
{
return _equalizerEnabled;
}
/**
* Sets EqualizerUI state.
*/
public void setEqualizerEnabled(boolean ena)
{
_equalizerEnabled = ena;
}
/**
* Returns default skin.
*/
public String getDefaultSkin()
{
return _defaultSkin;
}
/**
* Sets default skin.
*/
public void setDefaultSkin(String skin)
{
_defaultSkin = skin;
}
/**
* Returns playlist classname implementation.
*/
public String getPlaylistClassName()
{
return _playlist;
}
/**
* Set playlist classname implementation.
*/
public void setPlaylistClassName(String s)
{
_playlist = s;
}
/**
* Returns Mpeg TagInfo classname implementation.
*/
public String getMpegTagInfoClassName()
{
return _taginfoMpeg;
}
/**
* Returns Ogg Vorbis TagInfo classname implementation.
*/
public String getOggVorbisTagInfoClassName()
{
return _taginfoOggVorbis;
}
/**
* Returns APE TagInfo classname implementation.
*/
public String getAPETagInfoClassName()
{
return _taginfoAPE;
}
/**
* Returns Ogg Vorbis TagInfo classname implementation.
*/
public String getFlacTagInfoClassName()
{
return _taginfoFlac;
}
/**
* Loads configuration for the specified file.
*/
public void load(String configfile)
{
CONFIG_FILE_NAME = configfile;
load();
}
/**
* Loads configuration.
*/
public void load()
{
_config = new Configuration(CONFIG_FILE_NAME);
// Creates config entries if needed.
if (_config.get(AUDIO_DEVICE) == null) _config.add(AUDIO_DEVICE, _audioDevice);
if (_config.get(VISUAL_MODE) == null) _config.add(VISUAL_MODE, _visualMode);
if (_config.get(LAST_URL) == null) _config.add(LAST_URL, _lastUrl);
if (_config.get(LAST_EQUALIZER) == null) _config.add(LAST_EQUALIZER, _lastEqualizer);
if (_config.get(LAST_DIR) == null) _config.add(LAST_DIR, _lastDir);
if (_config.get(LAST_SKIN_DIR) == null) _config.add(LAST_SKIN_DIR, _lastSkinDir);
if (_config.get(TAGINFO_POLICY) == null) _config.add(TAGINFO_POLICY, _taginfoPolicy);
if (_config.getInt(ORIGINE_X) == -1) _config.add(ORIGINE_X, _x);
if (_config.getInt(ORIGINE_Y) == -1) _config.add(ORIGINE_Y, _y);
if (_config.get(LAST_SKIN) == null) _config.add(LAST_SKIN, _defaultSkin);
if (_config.get(LAST_PLAYLIST) == null) _config.add(LAST_PLAYLIST, _playlistFilename);
if (_config.get(PLAYLIST_IMPL) == null) _config.add(PLAYLIST_IMPL, _playlist);
if (_config.get(TAGINFO_MPEG_IMPL) == null) _config.add(TAGINFO_MPEG_IMPL, _taginfoMpeg);
if (_config.get(TAGINFO_OGGVORBIS_IMPL) == null) _config.add(TAGINFO_OGGVORBIS_IMPL, _taginfoOggVorbis);
if (_config.get(TAGINFO_APE_IMPL) == null) _config.add(TAGINFO_APE_IMPL, _taginfoAPE);
if (_config.get(TAGINFO_FLAC_IMPL) == null) _config.add(TAGINFO_FLAC_IMPL, _taginfoFlac);
if (_config.get(EXTENSIONS) == null) _config.add(EXTENSIONS, _extensions);
if (_config.get(PROXY_SERVER) == null) _config.add(PROXY_SERVER, _proxyServer);
if (_config.getInt(PROXY_PORT) == -1) _config.add(PROXY_PORT, _proxyPort);
if (_config.getInt(VOLUME_VALUE) == -1) _config.add(VOLUME_VALUE, _volume);
if (_config.get(PROXY_LOGIN) == null) _config.add(PROXY_LOGIN, _proxyLogin);
if (_config.get(PROXY_PASSWORD) == null) _config.add(PROXY_PASSWORD, _proxyPassword);
if (!_config.getBoolean(PLAYLIST_ENABLED)) _config.add(PLAYLIST_ENABLED, _playlistEnabled);
if (!_config.getBoolean(SHUFFLE_ENABLED)) _config.add(SHUFFLE_ENABLED, _shuffleEnabled);
if (!_config.getBoolean(REPEAT_ENABLED)) _config.add(REPEAT_ENABLED, _repeatEnabled);
if (!_config.getBoolean(EQUALIZER_ENABLED)) _config.add(EQUALIZER_ENABLED, _equalizerEnabled);
if (!_config.getBoolean(EQUALIZER_ON)) _config.add(EQUALIZER_ON, _equalizerOn);
if (!_config.getBoolean(EQUALIZER_AUTO)) _config.add(EQUALIZER_AUTO, _equalizerAuto);
if (!_config.getBoolean(SCREEN_LIMIT)) _config.add(SCREEN_LIMIT, _screenLimit);
// Reads config entries
_audioDevice = _config.get(AUDIO_DEVICE, _audioDevice);
_visualMode = _config.get(VISUAL_MODE, _visualMode);
_lastUrl = _config.get(LAST_URL, _lastUrl);
_lastEqualizer = _config.get(LAST_EQUALIZER, _lastEqualizer);
_lastDir = _config.get(LAST_DIR, _lastDir);
_lastSkinDir = _config.get(LAST_SKIN_DIR, _lastSkinDir);
_x = _config.getInt(ORIGINE_X, _x);
_y = _config.getInt(ORIGINE_Y, _y);
_defaultSkin = _config.get(LAST_SKIN, _defaultSkin);
_playlistFilename = _config.get(LAST_PLAYLIST, _playlistFilename);
_taginfoPolicy = _config.get(TAGINFO_POLICY, _taginfoPolicy);
_extensions = _config.get(EXTENSIONS, _extensions);
_playlist = _config.get(PLAYLIST_IMPL, _playlist);
_taginfoMpeg = _config.get(TAGINFO_MPEG_IMPL, _taginfoMpeg);
_taginfoOggVorbis = _config.get(TAGINFO_OGGVORBIS_IMPL, _taginfoOggVorbis);
_taginfoAPE = _config.get(TAGINFO_APE_IMPL, _taginfoAPE);
_taginfoFlac = _config.get(TAGINFO_FLAC_IMPL, _taginfoFlac);
_proxyServer = _config.get(PROXY_SERVER, _proxyServer);
_proxyPort = _config.getInt(PROXY_PORT, _proxyPort);
_volume = _config.getInt(VOLUME_VALUE, _volume);
_proxyLogin = _config.get(PROXY_LOGIN, _proxyLogin);
_proxyPassword = _config.get(PROXY_PASSWORD, _proxyPassword);
_playlistEnabled = _config.getBoolean(PLAYLIST_ENABLED, _playlistEnabled);
_shuffleEnabled = _config.getBoolean(SHUFFLE_ENABLED, _shuffleEnabled);
_repeatEnabled = _config.getBoolean(REPEAT_ENABLED, _repeatEnabled);
_equalizerEnabled = _config.getBoolean(EQUALIZER_ENABLED, _equalizerEnabled);
_equalizerOn = _config.getBoolean(EQUALIZER_ON, _equalizerOn);
_equalizerAuto = _config.getBoolean(EQUALIZER_AUTO, _equalizerAuto);
_screenLimit = _config.getBoolean(SCREEN_LIMIT, _screenLimit);
}
/**
* Saves configuration.
*/
public void save()
{
if (_config != null)
{
_config.add(ORIGINE_X, _x);
_config.add(ORIGINE_Y, _y);
if (_lastDir != null) _config.add(LAST_DIR, _lastDir);
if (_lastSkinDir != null) _config.add(LAST_SKIN_DIR, _lastSkinDir);
if (_audioDevice != null) _config.add(AUDIO_DEVICE, _audioDevice);
if (_visualMode != null) _config.add(VISUAL_MODE, _visualMode);
if (_lastUrl != null) _config.add(LAST_URL, _lastUrl);
if (_lastEqualizer != null) _config.add(LAST_EQUALIZER, _lastEqualizer);
if (_playlistFilename != null) _config.add(LAST_PLAYLIST, _playlistFilename);
if (_playlist != null) _config.add(PLAYLIST_IMPL, _playlist);
if (_defaultSkin != null) _config.add(LAST_SKIN, _defaultSkin);
if (_taginfoPolicy != null) _config.add(TAGINFO_POLICY, _taginfoPolicy);
if (_volume != -1) _config.add(VOLUME_VALUE, _volume);
_config.add(PLAYLIST_ENABLED, _playlistEnabled);
_config.add(SHUFFLE_ENABLED, _shuffleEnabled);
_config.add(REPEAT_ENABLED, _repeatEnabled);
_config.add(EQUALIZER_ENABLED, _equalizerEnabled);
_config.add(EQUALIZER_ON, _equalizerOn);
_config.add(EQUALIZER_AUTO, _equalizerAuto);
_config.add(SCREEN_LIMIT, _screenLimit);
_config.save();
}
}
/**
* @return equalizer auto flag
*/
public boolean isEqualizerAuto()
{
return _equalizerAuto;
}
/**
* @return equalizer on flag
*/
public boolean isEqualizerOn()
{
return _equalizerOn;
}
/**
* @param b
*/
public void setEqualizerAuto(boolean b)
{
_equalizerAuto = b;
}
/**
* @param b
*/
public void setEqualizerOn(boolean b)
{
_equalizerOn = b;
}
public static boolean startWithProtocol(String input)
{
boolean ret = false;
if (input != null)
{
input = input.toLowerCase();
for (int i = 0; i < protocols.length; i++)
{
if (input.startsWith(protocols[i]))
{
ret = true;
break;
}
}
}
return ret;
}
/**
* @return tag info policy
*/
public String getTaginfoPolicy()
{
return _taginfoPolicy;
}
/**
* @param string
*/
public void setTaginfoPolicy(String string)
{
_taginfoPolicy = string;
}
}

View File

@@ -1,108 +0,0 @@
/*
* FileNameFilter.
*
* 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.ArrayList;
import java.util.StringTokenizer;
/**
* FileName filter that works for both javax.swing.filechooser and java.io.
*/
public class FileNameFilter extends javax.swing.filechooser.FileFilter implements java.io.FileFilter
{
protected java.util.List extensions = new ArrayList();
protected String default_extension = null;
protected String description;
protected boolean allowDir = true;
/**
* Constructs the list of extensions out of a string of comma-separated
* elements, each of which represents one extension.
*
* @param ext the list of comma-separated extensions
*/
public FileNameFilter(String ext, String description)
{
this(ext, description, true);
}
public FileNameFilter(String ext, String description, boolean allowDir)
{
this.description = description;
this.allowDir = allowDir;
StringTokenizer st = new StringTokenizer(ext, ", ");
String extension;
while (st.hasMoreTokens())
{
extension = st.nextToken();
extensions.add(extension);
if (default_extension == null) default_extension = extension;
}
}
/**
* determines if the filename is an acceptable one. If a
* filename ends with one of the extensions the filter was
* initialized with, then the function returns true. if not,
* the function returns false.
*
* @param dir the directory the file is in
* @return true if the filename has a valid extension, false otherwise
*/
public boolean accept(File dir)
{
for (int i = 0; i < extensions.size(); i++)
{
if (allowDir)
{
if (dir.isDirectory() || dir.getName().endsWith("." + (String) extensions.get(i))) return true;
}
else
{
if (dir.getName().endsWith("." + (String) extensions.get(i))) return true;
}
}
return extensions.size() == 0;
}
/**
* Returns the default extension.
*
* @return the default extension
*/
public String getDefaultExtension()
{
return default_extension;
}
public void setDefaultExtension(String ext)
{
default_extension = ext;
}
public String getDescription()
{
return description;
}
}

View File

@@ -1,156 +0,0 @@
/*
* FileSelector.
*
* 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 javax.swing.JFileChooser;
import javax.swing.JFrame;
import javazoom.jlgui.player.amp.Loader;
/**
* This class is used to select a file or directory for loading or saving.
*/
public class FileSelector
{
public static final int OPEN = 1;
public static final int SAVE = 2;
public static final int SAVE_AS = 3;
public static final int DIRECTORY = 4;
private File[] files = null;
private File directory = null;
private static FileSelector instance = null;
public File[] getFiles()
{
return files;
}
public File getDirectory()
{
return directory;
}
public static final FileSelector getInstance()
{
if (instance == null) instance = new FileSelector();
return instance;
}
/**
* Opens a dialog box so that the user can search for a file
* with the given extension and returns the filename selected.
*
* @param extensions the extension of the filename to be selected,
* or "" if any filename can be used
* @param directory the folder to be put in the starting directory
* @param mode the action that will be performed on the file, used to tell what
* files are valid
* @return the selected file
*/
public static File[] selectFile(Loader loader, int mode, boolean multiple, String extensions, String description, File directory)
{
return selectFile(loader, mode, multiple, null, extensions, description, null, directory);
}
/**
* Opens a dialog box so that the user can search for a file
* with the given extension and returns the filename selected.
*
* @param extensions the extension of the filename to be selected,
* or "" if any filename can be used
* @param titlePrefix the string to be put in the title, followed by : SaveAs
* @param mode the action that will be performed on the file, used to tell what
* files are valid
* @param defaultFile the default file
* @param directory the string to be put in the starting directory
* @return the selected filename
*/
public static File[] selectFile(Loader loader, int mode, boolean multiple, File defaultFile, String extensions, String description, String titlePrefix, File directory)
{
JFrame mainWindow = null;
if (loader instanceof JFrame)
{
mainWindow = (JFrame) loader;
}
JFileChooser filePanel = new JFileChooser();
StringBuffer windowTitle = new StringBuffer();
if (titlePrefix != null && titlePrefix.length() > 0) windowTitle.append(titlePrefix).append(": ");
switch (mode)
{
case OPEN:
windowTitle.append("Open");
break;
case SAVE:
windowTitle.append("Save");
break;
case SAVE_AS:
windowTitle.append("Save As");
break;
case DIRECTORY:
windowTitle.append("Choose Directory");
break;
}
filePanel.setDialogTitle(windowTitle.toString());
FileNameFilter filter = new FileNameFilter(extensions, description);
filePanel.setFileFilter(filter);
if (defaultFile != null) filePanel.setSelectedFile(defaultFile);
if (directory != null) filePanel.setCurrentDirectory(directory);
filePanel.setMultiSelectionEnabled(multiple);
int retVal = -1;
switch (mode)
{
case OPEN:
filePanel.setDialogType(JFileChooser.OPEN_DIALOG);
retVal = filePanel.showOpenDialog(mainWindow);
break;
case SAVE:
filePanel.setDialogType(JFileChooser.SAVE_DIALOG);
retVal = filePanel.showSaveDialog(mainWindow);
break;
case SAVE_AS:
filePanel.setDialogType(JFileChooser.SAVE_DIALOG);
retVal = filePanel.showSaveDialog(mainWindow);
break;
case DIRECTORY:
filePanel.setDialogType(JFileChooser.SAVE_DIALOG);
filePanel.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
retVal = filePanel.showDialog(mainWindow, "Select");
break;
}
if (retVal == JFileChooser.APPROVE_OPTION)
{
if (multiple) getInstance().files = filePanel.getSelectedFiles();
else
{
getInstance().files = new File[1];
getInstance().files[0] = filePanel.getSelectedFile();
}
getInstance().directory = filePanel.getCurrentDirectory();
}
else
{
getInstance().files = null;
}
return getInstance().files;
}
}

View File

@@ -1,167 +0,0 @@
/*
* FileUtil.
*
* 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.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;
/**
* @author Scott Pennell
*/
public class FileUtil
{
private static List supportedExtensions = null;
public static File[] findFilesRecursively(File directory)
{
if (directory.isFile())
{
File[] f = new File[1];
f[0] = directory;
return f;
}
List list = new ArrayList();
addSongsRecursive(list, directory);
return ((File[]) list.toArray(new File[list.size()]));
}
private static void addSongsRecursive(List found, File rootDir)
{
if (rootDir == null) return; // we do not want waste time
File[] files = rootDir.listFiles();
if (files == null) return;
for (int i = 0; i < files.length; i++)
{
File file = new File(rootDir, files[i].getName());
if (file.isDirectory()) addSongsRecursive(found, file);
else
{
if (isMusicFile(files[i]))
{
found.add(file);
}
}
}
}
public static boolean isMusicFile(File f)
{
List exts = getSupportedExtensions();
int sz = exts.size();
String ext;
String name = f.getName();
for (int i = 0; i < sz; i++)
{
ext = (String) exts.get(i);
if (ext.equals(".wsz") || ext.equals(".m3u")) continue;
if (name.endsWith(ext)) return true;
}
return false;
}
public static List getSupportedExtensions()
{
if (supportedExtensions == null)
{
String ext = Config.getInstance().getExtensions();
StringTokenizer st = new StringTokenizer(ext, ",");
supportedExtensions = new ArrayList();
while (st.hasMoreTokens())
supportedExtensions.add("." + st.nextElement());
}
return (supportedExtensions);
}
public static String getSupprtedExtensions()
{
List exts = getSupportedExtensions();
StringBuffer s = new StringBuffer();
int sz = exts.size();
String ext;
for (int i = 0; i < sz; i++)
{
ext = (String) exts.get(i);
if (ext.equals(".wsz") || ext.equals(".m3u")) continue;
if (i == 0) s.append(ext);
else s.append(";").append(ext);
}
return s.toString();
}
public static String padString(String s, int length)
{
return padString(s, ' ', length);
}
public static String padString(String s, char padChar, int length)
{
int slen, numPads = 0;
if (s == null)
{
s = "";
numPads = length;
}
else if ((slen = s.length()) > length)
{
s = s.substring(0, length);
}
else if (slen < length)
{
numPads = length - slen;
}
if (numPads == 0) return s;
char[] c = new char[numPads];
Arrays.fill(c, padChar);
return s + new String(c);
}
public static String rightPadString(String s, int length)
{
return (rightPadString(s, ' ', length));
}
public static String rightPadString(String s, char padChar, int length)
{
int slen, numPads = 0;
if (s == null)
{
s = "";
numPads = length;
}
else if ((slen = s.length()) > length)
{
s = s.substring(length);
}
else if (slen < length)
{
numPads = length - slen;
}
if (numPads == 0) return (s);
char[] c = new char[numPads];
Arrays.fill(c, padChar);
return new String(c) + s;
}
}

View File

@@ -1,79 +0,0 @@
/*
* Alphabetizer.
*
* 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.ini;
/**
* This class alphabetizes strings.
*
* @author Matt "Spiked Bat" Segur
*/
public class Alphabetizer
{
public static boolean lessThan(String str1, String str2)
{
return compare(str1, str2) < 0;
}
public static boolean greaterThan(String str1, String str2)
{
return compare(str1, str2) > 0;
}
public static boolean equalTo(String str1, String str2)
{
return compare(str1, str2) == 0;
}
/**
* Performs a case-insensitive comparison of the two strings.
*/
public static int compare(String s1, String s2)
{
if (s1 == null && s2 == null) return 0;
else if (s1 == null) return -1;
else if (s2 == null) return +1;
int len1 = s1.length();
int len2 = s2.length();
int len = Math.min(len1, len2);
for (int i = 0; i < len; i++)
{
int comparison = compare(s1.charAt(i), s2.charAt(i));
if (comparison != 0) return comparison;
}
if (len1 < len2) return -1;
else if (len1 > len2) return +1;
else return 0;
}
/**
* Performs a case-insensitive comparison of the two characters.
*/
public static int compare(char c1, char c2)
{
if (65 <= c1 && c1 <= 91) c1 += 32;
if (65 <= c2 && c2 <= 91) c2 += 32;
if (c1 < c2) return -1;
else if (c1 > c2) return +1;
else return 0;
}
}

View File

@@ -1,114 +0,0 @@
/*
* Array.
*
* 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.ini;
/**
* This class represents an array of objects.
*
* @author Jeremy Cloud
* @version 1.0.0
*/
public class Array
{
public static Object[] copy(Object[] sors, Object[] dest)
{
System.arraycopy(sors, 0, dest, 0, sors.length);
return dest;
}
public static String[] doubleArray(String[] sors)
{
System.out.print("** doubling string array... ");
int new_size = (sors.length <= 8 ? 16 : sors.length << 1);
String[] dest = new String[new_size];
System.arraycopy(sors, 0, dest, 0, sors.length);
System.out.println("done **.");
return dest;
}
public static int[] doubleArray(int[] sors)
{
int new_size = (sors.length < 8 ? 16 : sors.length << 1);
int[] dest = new int[new_size];
System.arraycopy(sors, 0, dest, 0, sors.length);
return dest;
}
public static int[] grow(int[] sors, double growth_rate)
{
int new_size = Math.max((int) (sors.length * growth_rate), sors.length + 1);
int[] dest = new int[new_size];
System.arraycopy(sors, 0, dest, 0, sors.length);
return dest;
}
public static boolean[] grow(boolean[] sors, double growth_rate)
{
int new_size = Math.max((int) (sors.length * growth_rate), sors.length + 1);
boolean[] dest = new boolean[new_size];
System.arraycopy(sors, 0, dest, 0, sors.length);
return dest;
}
public static Object[] grow(Object[] sors, double growth_rate)
{
int new_size = Math.max((int) (sors.length * growth_rate), sors.length + 1);
Object[] dest = new Object[new_size];
System.arraycopy(sors, 0, dest, 0, sors.length);
return dest;
}
public static String[] grow(String[] sors, double growth_rate)
{
int new_size = Math.max((int) (sors.length * growth_rate), sors.length + 1);
String[] dest = new String[new_size];
System.arraycopy(sors, 0, dest, 0, sors.length);
return dest;
}
/**
* @param start - inclusive
* @param end - exclusive
*/
public static void shiftUp(Object[] array, int start, int end)
{
int count = end - start;
if (count > 0) System.arraycopy(array, start, array, start + 1, count);
}
/**
* @param start - inclusive
* @param end - exclusive
*/
public static void shiftDown(Object[] array, int start, int end)
{
int count = end - start;
if (count > 0) System.arraycopy(array, start, array, start - 1, count);
}
public static void shift(Object[] array, int start, int amount)
{
int count = array.length - start - (amount > 0 ? amount : 0);
System.arraycopy(array, start, array, start + amount, count);
}
}

View File

@@ -1,50 +0,0 @@
/*
* CRC32OutputStream.
*
* 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.ini;
import java.io.OutputStream;
import java.util.zip.CRC32;
/**
* @author Jeremy Cloud
* @version 1.0.0
*/
public class CRC32OutputStream extends OutputStream
{
private CRC32 crc;
public CRC32OutputStream()
{
crc = new CRC32();
}
public void write(int new_byte)
{
crc.update(new_byte);
}
public long getValue()
{
return crc.getValue();
}
}

View File

@@ -1,441 +0,0 @@
/*
* Configuration.
*
* 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.ini;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.util.Enumeration;
import java.util.Hashtable;
import javazoom.jlgui.player.amp.util.Config;
/**
* A Configuration is used to save a set of configuration
* properties. The properties can be written out to disk
* in "name=value" form, and read back in.
*
* @author Jeremy Cloud
* @version 1.2.0
*/
public class Configuration
{
private File config_file = null;
private URL config_url = null;
private Hashtable props = new Hashtable(64);
/**
* Constructs a new Configuration object that stores
* it's properties in the file with the given name.
*/
public Configuration(String file_name)
{
// E.B - URL support
if (Config.startWithProtocol(file_name))
{
try
{
this.config_url = new URL(file_name);
}
catch (Exception e)
{
e.printStackTrace();
}
load();
}
else
{
this.config_file = new File(file_name);
load();
}
}
/**
* Constructs a new Configuration object that stores
* it's properties in the given file.
*/
public Configuration(File config_file)
{
this.config_file = config_file;
load();
}
/**
* Constructs a new Configuration object that stores
* it's properties in the given file.
*/
public Configuration(URL config_file)
{
this.config_url = config_file;
load();
}
/**
* Constructs a new Configuration object that doesn't
* have a file associated with it.
*/
public Configuration()
{
this.config_file = null;
}
/**
* @return The config file.
*/
public File getConfigFile()
{
return config_file;
}
/**
* Adds a the property with the given name and value.
*
* @param name The name of the property.
* @param value The value of the property.
*/
public void add(String name, String value)
{
props.put(name, value);
}
/**
* Adds the boolean property.
*
* @param name The name of the property.
* @param value The value of the property.
*/
public void add(String name, boolean value)
{
props.put(name, value ? "true" : "false");
}
/**
* Adds the integer property.
*
* @param name The name of the property.
* @param value The value of the property.
*/
public void add(String name, int value)
{
props.put(name, Integer.toString(value));
}
/**
* Adds the double property.
*
* @param name The name of the property.
* @param value The value of the property.
*/
public void add(String name, double value)
{
props.put(name, Double.toString(value));
}
/**
* Returns the value of the property with the
* given name. Null is returned if the named
* property is not found.
*
* @param The name of the desired property.
* @return The value of the property.
*/
public String get(String name)
{
return (String) props.get(name);
}
/**
* Returns the value of the property with the
* given name. 'default_value' is returned if the
* named property is not found.
*
* @param The name of the desired property.
* @param default_value The default value of the property which is returned
* if the property does not have a specified value.
* @return The value of the property.
*/
public String get(String name, String default_value)
{
Object value = props.get(name);
return value != null ? (String) value : default_value;
}
/**
* Returns the value of the property with the given name.
* 'false' is returned if the property does not have a
* specified value.
*
* @param name The name of the desired property.
* @param return The value of the property.
*/
public boolean getBoolean(String name)
{
Object value = props.get(name);
return value != null ? value.equals("true") : false;
}
/**
* Returns the value of the property with the given name.
*
* @param name The name of the desired property.
* @param default_value The default value of the property which is returned
* if the property does not have a specified value.
* @param return The value of the property.
*/
public boolean getBoolean(String name, boolean default_value)
{
Object value = props.get(name);
return value != null ? value.equals("true") : default_value;
}
/**
* Returns the value of the property with the given name.
* '0' is returned if the property does not have a
* specified value.
*
* @param name The name of the desired property.
* @param return The value of the property.
*/
public int getInt(String name)
{
try
{
return Integer.parseInt((String) props.get(name));
}
catch (Exception e)
{
}
return -1;
}
/**
* Returns the value of the property with the given name.
*
* @param name The name of the desired property.
* @param default_value The default value of the property which is returned
* if the property does not have a specified value.
* @param return The value of the property.
*/
public int getInt(String name, int default_value)
{
try
{
return Integer.parseInt((String) props.get(name));
}
catch (Exception e)
{
}
return default_value;
}
/**
* Returns the value of the property with the given name.
* '0' is returned if the property does not have a
* specified value.
*
* @param name The name of the desired property.
* @param return The value of the property.
*/
public double getDouble(String name)
{
try
{
return new Double((String) props.get(name)).doubleValue();
}
catch (Exception e)
{
}
return -1d;
}
/**
* Returns the value of the property with the given name.
*
* @param name The name of the desired property.
* @param default_value The default value of the property which is returned
* if the property does not have a specified value.
* @param return The value of the property.
*/
public double getDouble(String name, double default_value)
{
try
{
return new Double((String) props.get(name)).doubleValue();
}
catch (Exception e)
{
}
return default_value;
}
/**
* Removes the property with the given name.
*
* @param name The name of the property to remove.
*/
public void remove(String name)
{
props.remove(name);
}
/**
* Removes all the properties.
*/
public void removeAll()
{
props.clear();
}
/**
* Loads the property list from the configuration file.
*
* @return True if the file was loaded successfully, false if
* the file does not exists or an error occurred reading
* the file.
*/
public boolean load()
{
if ((config_file == null) && (config_url == null)) return false;
// Loads from URL.
if (config_url != null)
{
try
{
return load(new BufferedReader(new InputStreamReader(config_url.openStream())));
}
catch (IOException e)
{
e.printStackTrace();
return false;
}
}
// Loads from file.
else
{
if (!config_file.exists()) return false;
try
{
return load(new BufferedReader(new FileReader(config_file)));
}
catch (IOException e)
{
e.printStackTrace();
return false;
}
}
}
public boolean load(BufferedReader buffy) throws IOException
{
Hashtable props = this.props;
String line = null;
while ((line = buffy.readLine()) != null)
{
int eq_idx = line.indexOf('=');
if (eq_idx > 0)
{
String name = line.substring(0, eq_idx).trim();
String value = line.substring(eq_idx + 1).trim();
props.put(name, value);
}
}
buffy.close();
return true;
}
/**
* Saves the property list to the config file.
*
* @return True if the save was successful, false othewise.
*/
public boolean save()
{
if (config_url != null) return false;
try
{
PrintWriter out = new PrintWriter(new FileWriter(config_file));
return save(out);
}
catch (IOException e)
{
e.printStackTrace();
return false;
}
}
public boolean save(PrintWriter out) throws IOException
{
Hashtable props = this.props;
Enumeration names = props.keys();
SortedStrings sorter = new SortedStrings();
while (names.hasMoreElements())
{
sorter.add((String) names.nextElement());
}
for (int i = 0; i < sorter.stringCount(); i++)
{
String name = sorter.stringAt(i);
String value = (String) props.get(name);
out.print(name);
out.print("=");
out.println(value);
}
out.close();
return true;
}
public void storeCRC()
{
add("crc", generateCRC());
}
public boolean isValidCRC()
{
String crc = generateCRC();
String stored_crc = (String) props.get("crc");
if (stored_crc == null) return false;
return stored_crc.equals(crc);
}
private String generateCRC()
{
Hashtable props = this.props;
CRC32OutputStream crc = new CRC32OutputStream();
PrintWriter pr = new PrintWriter(crc);
Enumeration names = props.keys();
while (names.hasMoreElements())
{
String name = (String) names.nextElement();
if (!name.equals("crc"))
{
pr.println((String) props.get(name));
}
}
pr.flush();
return "" + crc.getValue();
}
}

View File

@@ -1,338 +0,0 @@
/*
* SortedStrings.
* 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.ini;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
/**
* An object that represents an array of alpabetized Strings. Implemented
* with an String array that grows as appropriate.
*/
public class SortedStrings extends Alphabetizer implements Cloneable
{
public static final int DEFAULT_SIZE = 32;
private String[] strings;
private int string_count;
private double growth_rate = 2.0;
/**
* Constructor creates a new SortedStrings object of default
* size.
*/
public SortedStrings()
{
clear();
}
/**
* Constructor creates a new SortedStrings object of size passed.
*/
public SortedStrings(int initial_size)
{
clear(initial_size);
}
/**
* Contructor creates a new SortedStrings object using a DataInput
* object. The first int in the DataInput object is assumed to be
* the size wanted for the SortedStrings object.
*/
public SortedStrings(DataInput in) throws IOException
{
int count = string_count = in.readInt();
String[] arr = strings = new String[count];
for (int i = 0; i < count; i++)
arr[i] = in.readUTF();
}
/**
* Contructor creates a new SortedStrings object, initializing it
* with the String[] passed.
*/
public SortedStrings(String[] array)
{
this(array.length);
int new_size = array.length;
for (int i = 0; i < new_size; i++)
add(array[i]);
}
/**
* Clones the SortedStrings object.
*/
public Object clone()
{
try
{
SortedStrings clone = (SortedStrings) super.clone();
clone.strings = (String[]) strings.clone();
return clone;
}
catch (CloneNotSupportedException e)
{
return null;
}
}
/**
* Writes a the SortedStrings object to the DataOutput object.
*/
public void emit(DataOutput out) throws IOException
{
int count = string_count;
String[] arr = strings;
out.writeInt(count);
for (int i = 0; i < count; i++)
out.writeUTF(arr[i]);
}
/**
* Merge two sorted lists of integers. The time complexity of
* the merge is O(n).
*/
public SortedStrings merge(SortedStrings that)
{
int count1 = this.string_count;
int count2 = that.string_count;
String[] ints1 = this.strings;
String[] ints2 = that.strings;
String num1, num2;
int i1 = 0, i2 = 0;
SortedStrings res = new SortedStrings(count1 + count2);
while (i1 < count1 && i2 < count2)
{
num1 = ints1[i1];
num2 = ints2[i2];
if (compare(num1, num2) < 0)
{
res.add(num1);
i1++;
}
else if (compare(num2, num1) < 0)
{
res.add(num2);
i2++;
}
else
{
res.add(num1);
i1++;
i2++;
}
}
if (i1 < count1)
{
for (; i1 < count1; i1++)
res.add(ints1[i1]);
}
else for (; i2 < count2; i2++)
res.add(ints2[i2]);
return res;
}
/**
* Returns a SortedStrings object that has the Strings
* from this object that are not in the one passed.
*/
public SortedStrings diff(SortedStrings that)
{
int count1 = this.string_count;
int count2 = that.string_count;
String[] ints1 = this.strings;
String[] ints2 = that.strings;
String num1, num2;
int i1 = 0, i2 = 0;
SortedStrings res = new SortedStrings(count1);
while (i1 < count1 && i2 < count2)
{
num1 = ints1[i1];
num2 = ints2[i2];
if (compare(num1, num2) < 0)
{
res.add(num1);
i1++;
}
else if (compare(num2, num1) < 0) i2++;
else
{
i1++;
i2++;
}
}
if (i1 < count1)
{
for (; i1 < count1; i1++)
res.add(ints1[i1]);
}
return res;
}
/**
* Clears the Strings from the object and creates a new one
* of the default size.
*/
public void clear()
{
clear(DEFAULT_SIZE);
}
/**
* Clears the Strings from the object and creates a new one
* of the size passed.
*/
public void clear(int initial_size)
{
strings = new String[initial_size];
string_count = 0;
}
/**
* Adds the String passed to the array in its proper place -- sorted.
*/
public void add(String num)
{
if (string_count == 0 || greaterThan(num, strings[string_count - 1]))
{
if (string_count == strings.length) strings = (String[]) Array.grow(strings, growth_rate);
strings[string_count] = num;
string_count++;
}
else insert(search(num), num);
}
/**
* Inserts the String passed to the array at the index passed.
*/
private void insert(int index, String num)
{
if (strings[index] == num) return;
else
{
if (string_count == strings.length) strings = (String[]) Array.grow(strings, growth_rate);
System.arraycopy(strings, index, strings, index + 1, string_count - index);
strings[index] = num;
string_count++;
}
}
/**
* Removes the String passed from the array.
*/
public void remove(String num)
{
int index = search(num);
if (index < string_count && equalTo(strings[index], num)) removeIndex(index);
}
/**
* Removes the String from the beginning of the array to the
* index passed.
*/
public void removeIndex(int index)
{
if (index < string_count)
{
System.arraycopy(strings, index + 1, strings, index, string_count - index - 1);
string_count--;
}
}
/**
* Returns true flag if the String passed is in the array.
*/
public boolean contains(String num)
{
int index = search(num);
return index < string_count && equalTo(strings[search(num)], num);
}
/**
* Returns the number of Strings in the array.
*/
public int stringCount()
{
return string_count;
}
/**
* Returns String index of the int passed.
*/
public int indexOf(String num)
{
int index = search(num);
return index < string_count && equalTo(strings[index], num) ? index : -1;
}
/**
* Returns the String value at the index passed.
*/
public String stringAt(int index)
{
return strings[index];
}
/**
* Returns the index where the String value passed is located
* or where it should be sorted to if it is not present.
*/
protected int search(String num)
{
String[] strings = this.strings;
int lb = 0, ub = string_count, index;
String index_key;
while (true)
{
if (lb >= ub - 1)
{
if (lb < string_count && !greaterThan(num, strings[lb])) return lb;
else return lb + 1;
}
index = (lb + ub) / 2;
index_key = strings[index];
if (greaterThan(num, index_key)) lb = index + 1;
else if (lessThan(num, index_key)) ub = index;
else return index;
}
}
/**
* Returns an String[] that contains the value in the SortedStrings
* object.
*/
public String[] toStringArray()
{
String[] array = new String[string_count];
System.arraycopy(strings, 0, array, 0, string_count);
return array;
}
/**
* Returns a sorted String[] from the String[] passed.
*/
public static String[] sort(String[] input)
{
SortedStrings new_strings = new SortedStrings(input);
return new_strings.toStringArray();
}
}

View File

@@ -1,120 +0,0 @@
/*
* DevicePreference.
*
* 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.ui;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.MessageFormat;
import java.util.Iterator;
import java.util.List;
import java.util.ResourceBundle;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javazoom.jlgui.basicplayer.BasicController;
import javazoom.jlgui.basicplayer.BasicPlayer;
public class DevicePreference extends PreferenceItem implements ActionListener
{
private BasicPlayer bplayer = null;
private static DevicePreference instance = null;
private DevicePreference()
{
}
public static DevicePreference getInstance()
{
if (instance == null)
{
instance = new DevicePreference();
}
return instance;
}
public void loadUI()
{
removeAll();
bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/device");
setBorder(new TitledBorder(getResource("title")));
BoxLayout layout = new BoxLayout(this, BoxLayout.Y_AXIS);
setLayout(layout);
BasicController controller = null;
if (player != null) controller = player.getController();
if ((controller != null) && (controller instanceof BasicPlayer))
{
bplayer = (BasicPlayer) controller;
List devices = bplayer.getMixers();
String mixer = bplayer.getMixerName();
ButtonGroup group = new ButtonGroup();
Iterator it = devices.iterator();
while (it.hasNext())
{
String name = (String) it.next();
JRadioButton radio = new JRadioButton(name);
if (name.equals(mixer))
{
radio.setSelected(true);
}
else
{
radio.setSelected(false);
}
group.add(radio);
radio.addActionListener(this);
radio.setAlignmentX(Component.LEFT_ALIGNMENT);
add(radio);
}
JPanel lineInfo = new JPanel();
lineInfo.setLayout(new BoxLayout(lineInfo, BoxLayout.Y_AXIS));
lineInfo.setAlignmentX(Component.LEFT_ALIGNMENT);
lineInfo.setBorder(new EmptyBorder(4, 6, 0, 0));
if (getResource("line.buffer.size") != null)
{
Object[] args = { new Integer(bplayer.getLineCurrentBufferSize()) };
String str = MessageFormat.format(getResource("line.buffer.size"), args);
JLabel lineBufferSizeLabel = new JLabel(str);
lineInfo.add(lineBufferSizeLabel);
}
if (getResource("help") != null)
{
lineInfo.add(Box.createRigidArea(new Dimension(0, 30)));
JLabel helpLabel = new JLabel(getResource("help"));
lineInfo.add(helpLabel);
}
add(lineInfo);
}
}
public void actionPerformed(ActionEvent ev)
{
if (bplayer != null) bplayer.setMixerName(ev.getActionCommand());
}
}

View File

@@ -1,52 +0,0 @@
/*
* EmptyPreference.
*
* 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.ui;
import javax.swing.border.TitledBorder;
public class EmptyPreference extends PreferenceItem
{
private static EmptyPreference instance = null;
private EmptyPreference()
{
}
public static EmptyPreference getInstance()
{
if (instance == null)
{
instance = new EmptyPreference();
}
return instance;
}
public void loadUI()
{
if (loaded == false)
{
setBorder(new TitledBorder(""));
loaded = true;
}
}
}

View File

@@ -1,46 +0,0 @@
/*
* NodeItem.
*
* 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.ui;
public class NodeItem
{
private String name = null;
private String impl = null;
public NodeItem(String name, String impl)
{
super();
this.name = name;
this.impl = impl;
}
public String getImpl()
{
return impl;
}
public String toString()
{
return name;
}
}

View File

@@ -1,54 +0,0 @@
/*
* OutputPreference.
*
* 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.ui;
import java.util.ResourceBundle;
import javax.swing.border.TitledBorder;
public class OutputPreference extends PreferenceItem
{
private static OutputPreference instance = null;
private OutputPreference()
{
}
public static OutputPreference getInstance()
{
if (instance == null)
{
instance = new OutputPreference();
}
return instance;
}
public void loadUI()
{
if (loaded == false)
{
bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/output");
setBorder(new TitledBorder(getResource("title")));
loaded = true;
}
}
}

View File

@@ -1,78 +0,0 @@
/*
* PreferenceItem.
*
* 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.ui;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javazoom.jlgui.player.amp.PlayerUI;
public abstract class PreferenceItem extends JPanel
{
protected PlayerUI player = null;
protected ResourceBundle bundle = null;
protected boolean loaded = false;
protected JFrame parent = null;
/**
* Return I18N value of a given key.
* @param key
* @return
*/
public String getResource(String key)
{
String value = null;
if (key != null)
{
try
{
value = bundle.getString(key);
}
catch (MissingResourceException e)
{
}
}
return value;
}
public void setPlayer(PlayerUI player)
{
this.player = player;
}
public JFrame getParentFrame()
{
return parent;
}
public void setParentFrame(JFrame parent)
{
this.parent = parent;
}
public abstract void loadUI();
}

View File

@@ -1,279 +0,0 @@
/*
* Preferences.
*
* 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.ui;
import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.Method;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.border.EmptyBorder;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import javazoom.jlgui.player.amp.PlayerUI;
import javazoom.jlgui.player.amp.util.Config;
public class Preferences extends JFrame implements TreeSelectionListener, ActionListener
{
private static Preferences instance = null;
private JTree tree = null;
private ResourceBundle bundle = null;
private DefaultMutableTreeNode options = null;
private DefaultMutableTreeNode filetypes = null;
private DefaultMutableTreeNode device = null;
private DefaultMutableTreeNode proxy = null;
private DefaultMutableTreeNode plugins = null;
private DefaultMutableTreeNode visual = null;
private DefaultMutableTreeNode visuals = null;
private DefaultMutableTreeNode output = null;
//private DefaultMutableTreeNode drm = null;
private DefaultMutableTreeNode skins = null;
private DefaultMutableTreeNode browser = null;
private JScrollPane treePane = null;
private JScrollPane workPane = null;
private JButton close = null;
private PlayerUI player = null;
public Preferences(PlayerUI player)
{
super();
this.player = player;
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
ImageIcon icon = Config.getInstance().getIconParent();
if (icon != null) setIconImage(icon.getImage());
}
public static synchronized Preferences getInstance(PlayerUI player)
{
if (instance == null)
{
instance = new Preferences(player);
instance.loadUI();
}
return instance;
}
private void loadUI()
{
bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/preferences");
setTitle(getResource("title"));
DefaultMutableTreeNode root = new DefaultMutableTreeNode();
// Options
if (getResource("tree.options") != null)
{
options = new DefaultMutableTreeNode(getResource("tree.options"));
if (getResource("tree.options.device") != null)
{
device = new DefaultMutableTreeNode();
device.setUserObject(new NodeItem(getResource("tree.options.device"), getResource("tree.options.device.impl")));
options.add(device);
}
if (getResource("tree.options.visual") != null)
{
visual = new DefaultMutableTreeNode();
visual.setUserObject(new NodeItem(getResource("tree.options.visual"), getResource("tree.options.visual.impl")));
options.add(visual);
}
if (getResource("tree.options.filetypes") != null)
{
filetypes = new DefaultMutableTreeNode();
filetypes.setUserObject(new NodeItem(getResource("tree.options.filetypes"), getResource("tree.options.filetypes.impl")));
options.add(filetypes);
}
if (getResource("tree.options.system") != null)
{
proxy = new DefaultMutableTreeNode();
proxy.setUserObject(new NodeItem(getResource("tree.options.system"), getResource("tree.options.system.impl")));
options.add(proxy);
}
root.add(options);
}
// Plugins
if (getResource("tree.plugins") != null)
{
plugins = new DefaultMutableTreeNode(getResource("tree.plugins"));
if (getResource("tree.plugins.visualization") != null)
{
visuals = new DefaultMutableTreeNode();
visuals.setUserObject(new NodeItem(getResource("tree.plugins.visualization"), getResource("tree.plugins.visualization.impl")));
plugins.add(visuals);
}
if (getResource("tree.plugins.output") != null)
{
output = new DefaultMutableTreeNode();
output.setUserObject(new NodeItem(getResource("tree.plugins.output"), getResource("tree.plugins.output.impl")));
plugins.add(output);
}
/*if (getResource("tree.plugins.drm") != null)
{
drm = new DefaultMutableTreeNode();
drm.setUserObject(new NodeItem(getResource("tree.plugins.drm"), getResource("tree.plugins.drm.impl")));
plugins.add(drm);
}*/
root.add(plugins);
}
// Skins
if (getResource("tree.skins") != null)
{
skins = new DefaultMutableTreeNode(getResource("tree.skins"));
if (getResource("tree.skins.browser") != null)
{
browser = new DefaultMutableTreeNode();
browser.setUserObject(new NodeItem(getResource("tree.skins.browser"), getResource("tree.skins.browser.impl")));
skins.add(browser);
}
root.add(skins);
}
tree = new JTree(root);
tree.setRootVisible(false);
DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
renderer.setLeafIcon(null);
renderer.setClosedIcon(null);
renderer.setOpenIcon(null);
tree.setCellRenderer(renderer);
tree.addTreeSelectionListener(this);
int i = 0;
while (i < tree.getRowCount())
{
tree.expandRow(i++);
}
tree.setBorder(new EmptyBorder(1, 4, 1, 2));
GridBagLayout layout = new GridBagLayout();
getContentPane().setLayout(layout);
GridBagConstraints cnts = new GridBagConstraints();
cnts.fill = GridBagConstraints.BOTH;
cnts.weightx = 0.3;
cnts.weighty = 1.0;
cnts.gridx = 0;
cnts.gridy = 0;
treePane = new JScrollPane(tree);
JPanel leftPane = new JPanel();
leftPane.setLayout(new BorderLayout());
leftPane.add(treePane, BorderLayout.CENTER);
if (getResource("button.close") != null)
{
close = new JButton(getResource("button.close"));
close.addActionListener(this);
leftPane.add(close, BorderLayout.SOUTH);
}
getContentPane().add(leftPane, cnts);
cnts.weightx = 1.0;
cnts.gridx = 1;
cnts.gridy = 0;
workPane = new JScrollPane(new JPanel());
getContentPane().add(workPane, cnts);
}
public void valueChanged(TreeSelectionEvent e)
{
DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
if (node == null) return;
if (node.isLeaf())
{
Object nodeItem = node.getUserObject();
if ((nodeItem != null) && (nodeItem instanceof NodeItem))
{
PreferenceItem pane = getPreferenceItem(((NodeItem) nodeItem).getImpl());
if (pane != null)
{
pane.setPlayer(player);
pane.loadUI();
pane.setParentFrame(this);
workPane.setViewportView(pane);
}
}
}
}
public void selectSkinBrowserPane()
{
TreeNode[] path = browser.getPath();
tree.setSelectionPath(new TreePath(path));
}
public void actionPerformed(ActionEvent ev)
{
if (ev.getSource() == close)
{
if (player != null)
{
Config config = player.getConfig();
config.save();
}
dispose();
}
}
/**
* Return I18N value of a given key.
* @param key
* @return
*/
public String getResource(String key)
{
String value = null;
if (key != null)
{
try
{
value = bundle.getString(key);
}
catch (MissingResourceException e)
{
}
}
return value;
}
public PreferenceItem getPreferenceItem(String impl)
{
PreferenceItem item = null;
if (impl != null)
{
try
{
Class aClass = Class.forName(impl);
Method method = aClass.getMethod("getInstance", null);
item = (PreferenceItem) method.invoke(null, null);
}
catch (Exception e)
{
// TODO
}
}
return item;
}
}

View File

@@ -1,185 +0,0 @@
/*
* SkinPreference.
*
* 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.ui;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.ResourceBundle;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ListSelectionModel;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javazoom.jlgui.player.amp.util.FileNameFilter;
import javazoom.jlgui.player.amp.util.FileSelector;
public class SkinPreference extends PreferenceItem implements ActionListener, ListSelectionListener
{
public static final String DEFAULTSKIN = "<Default Skin>";
public static final String SKINEXTENSION = "wsz";
private DefaultListModel listModel = null;
private JList skins = null;
private JTextArea info = null;
private JPanel listPane = null;
private JPanel infoPane = null;
private JPanel browsePane = null;
private JButton selectSkinDir = null;
private static SkinPreference instance = null;
private SkinPreference()
{
listModel = new DefaultListModel();
}
public static SkinPreference getInstance()
{
if (instance == null)
{
instance = new SkinPreference();
}
return instance;
}
public void loadUI()
{
if (loaded == false)
{
bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/skin");
setBorder(new TitledBorder(getResource("title")));
File dir = null;
if (player != null)
{
dir = new File(player.getConfig().getLastSkinDir());
}
loadSkins(dir);
skins = new JList(listModel);
skins.setBorder(new EmptyBorder(1, 2, 1, 1));
skins.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
skins.setLayoutOrientation(JList.VERTICAL);
skins.setVisibleRowCount(12);
skins.addListSelectionListener(this);
JScrollPane listScroller = new JScrollPane(skins);
listScroller.setPreferredSize(new Dimension(300, 140));
listPane = new JPanel();
listPane.add(listScroller);
infoPane = new JPanel();
info = new JTextArea(4, 35);
info.setEditable(false);
info.setCursor(null);
JScrollPane infoScroller = new JScrollPane(info);
infoScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
infoScroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
infoPane.add(infoScroller);
browsePane = new JPanel();
selectSkinDir = new JButton(getResource("browser.directory.button"));
selectSkinDir.addActionListener(this);
browsePane.add(selectSkinDir);
GridBagLayout layout = new GridBagLayout();
setLayout(layout);
GridBagConstraints cnts = new GridBagConstraints();
cnts.fill = GridBagConstraints.BOTH;
cnts.gridwidth = 1;
cnts.weightx = 1.0;
cnts.weighty = 0.60;
cnts.gridx = 0;
cnts.gridy = 0;
add(listPane, cnts);
cnts.gridwidth = 1;
cnts.weightx = 1.0;
cnts.weighty = 0.30;
cnts.gridx = 0;
cnts.gridy = 1;
add(infoPane, cnts);
cnts.weightx = 1.0;
cnts.weighty = 0.10;
cnts.gridx = 0;
cnts.gridy = 2;
add(browsePane, cnts);
loaded = true;
}
}
public void actionPerformed(ActionEvent ev)
{
if (ev.getActionCommand().equalsIgnoreCase(getResource("browser.directory.button")))
{
File[] file = FileSelector.selectFile(player.getLoader(), FileSelector.DIRECTORY, false, "", "Directories", new File(player.getConfig().getLastSkinDir()));
if ((file != null) && (file[0].isDirectory()))
{
player.getConfig().setLastSkinDir(file[0].getAbsolutePath());
loadSkins(file[0]);
}
}
}
public void valueChanged(ListSelectionEvent e)
{
if (e.getValueIsAdjusting() == false)
{
if (skins.getSelectedIndex() == -1)
{
}
else
{
String name = (String) listModel.get(skins.getSelectedIndex());
String filename = player.getConfig().getLastSkinDir() + name + "." + SKINEXTENSION;
player.getSkin().setPath(filename);
player.loadSkin();
player.getConfig().setDefaultSkin(filename);
String readme = player.getSkin().getReadme();
if (readme == null) readme = "";
info.setText(readme);
info.setCaretPosition(0);
}
}
}
private void loadSkins(File dir)
{
listModel.clear();
listModel.addElement(DEFAULTSKIN);
if ((dir != null) && (dir.exists()))
{
File[] files = dir.listFiles(new FileNameFilter(SKINEXTENSION, "Skins", false));
if ((files != null) && (files.length > 0))
{
for (int i = 0; i < files.length; i++)
{
String filename = files[i].getName();
listModel.addElement(filename.substring(0, filename.length() - 4));
}
}
}
}
}

View File

@@ -1,91 +0,0 @@
/*
* SystemPreference.
*
* 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.ui;
import java.awt.BorderLayout;
import java.awt.Font;
import java.util.Iterator;
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.TreeMap;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
public class SystemPreference extends PreferenceItem
{
private JTextArea info = null;
private boolean loaded = false;
private static SystemPreference instance = null;
private SystemPreference()
{
}
public static SystemPreference getInstance()
{
if (instance == null)
{
instance = new SystemPreference();
}
return instance;
}
public void loadUI()
{
if (loaded == false)
{
bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/system");
setBorder(new TitledBorder(getResource("title")));
setLayout(new BorderLayout());
info = new JTextArea(16,35);
info.setFont(new Font("Dialog", Font.PLAIN, 11));
info.setEditable(false);
info.setCursor(null);
info.setBorder(new EmptyBorder(1,2,1,1));
Properties props = System.getProperties();
Iterator it = props.keySet().iterator();
TreeMap map = new TreeMap();
while (it.hasNext())
{
String key = (String) it.next();
String value = props.getProperty(key);
map.put(key, value);
}
it = map.keySet().iterator();
while (it.hasNext())
{
String key = (String) it.next();
String value = (String) map.get(key);
info.append(key + "=" + value + "\r\n");
}
JScrollPane infoScroller = new JScrollPane(info);
infoScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
infoScroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
add(infoScroller, BorderLayout.CENTER);
info.setCaretPosition(0);
loaded = true;
}
}
}

View File

@@ -1,129 +0,0 @@
/*
* TypePreference.
*
* 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.ui;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
public class TypePreference extends PreferenceItem implements ActionListener, ListSelectionListener
{
private DefaultListModel listModel = null;
private JList types = null;
private JPanel listPane = null;
private JPanel extensionPane = null;
private static TypePreference instance = null;
private TypePreference()
{
listModel = new DefaultListModel();
}
public static TypePreference getInstance()
{
if (instance == null)
{
instance = new TypePreference();
}
return instance;
}
public void loadUI()
{
if (loaded == false)
{
bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/type");
setBorder(new TitledBorder(getResource("title")));
loadTypes();
types = new JList(listModel);
types.setBorder(new EmptyBorder(1, 2, 1, 1));
types.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
types.setLayoutOrientation(JList.VERTICAL);
types.setVisibleRowCount(12);
types.addListSelectionListener(this);
JScrollPane listScroller = new JScrollPane(types);
listScroller.setPreferredSize(new Dimension(80, 240));
listPane = new JPanel();
listPane.add(listScroller);
extensionPane = new JPanel();
GridBagLayout layout = new GridBagLayout();
setLayout(layout);
GridBagConstraints cnts = new GridBagConstraints();
cnts.fill = GridBagConstraints.BOTH;
cnts.gridwidth = 1;
cnts.weightx = 0.30;
cnts.weighty = 1.0;
cnts.gridx = 0;
cnts.gridy = 0;
add(listPane, cnts);
cnts.gridwidth = 1;
cnts.weightx = 0.70;
cnts.weighty = 1.0;
cnts.gridx = 1;
cnts.gridy = 0;
add(extensionPane, cnts);
loaded = true;
}
}
public void actionPerformed(ActionEvent ev)
{
}
public void valueChanged(ListSelectionEvent e)
{
if (e.getValueIsAdjusting() == false)
{
if (types.getSelectedIndex() == -1)
{
}
else
{
}
}
}
private void loadTypes()
{
String extensions = player.getConfig().getExtensions();
StringTokenizer st = new StringTokenizer(extensions, ",");
while (st.hasMoreTokens())
{
String type = st.nextToken();
listModel.addElement(type);
}
}
}

View File

@@ -1,292 +0,0 @@
/*
* VisualPreference.
*
* 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.ui;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Hashtable;
import java.util.ResourceBundle;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JSlider;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javazoom.jlgui.player.amp.visual.ui.SpectrumTimeAnalyzer;
public class VisualPreference extends PreferenceItem implements ActionListener, ChangeListener
{
private JPanel modePane = null;
private JPanel spectrumPane = null;
private JPanel oscilloPane = null;
private JRadioButton spectrumMode = null;
private JRadioButton oscilloMode = null;
private JRadioButton offMode = null;
private JCheckBox peaksBox = null;
private JSlider analyzerFalloff = null;
private JSlider peaksFalloff = null;
private static VisualPreference instance = null;
private VisualPreference()
{
}
public static VisualPreference getInstance()
{
if (instance == null)
{
instance = new VisualPreference();
}
return instance;
}
public void loadUI()
{
if (loaded == false)
{
bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/visual");
setBorder(new TitledBorder(getResource("title")));
modePane = new JPanel();
modePane.setBorder(new TitledBorder(getResource("mode.title")));
modePane.setLayout(new FlowLayout());
spectrumMode = new JRadioButton(getResource("mode.spectrum"));
spectrumMode.addActionListener(this);
oscilloMode = new JRadioButton(getResource("mode.oscilloscope"));
oscilloMode.addActionListener(this);
offMode = new JRadioButton(getResource("mode.off"));
offMode.addActionListener(this);
SpectrumTimeAnalyzer analyzer = null;
if (player != null)
{
analyzer = player.getSkin().getAcAnalyzer();
int displayMode = SpectrumTimeAnalyzer.DISPLAY_MODE_OFF;
if (analyzer != null)
{
displayMode = analyzer.getDisplayMode();
}
if (displayMode == SpectrumTimeAnalyzer.DISPLAY_MODE_SPECTRUM_ANALYSER)
{
spectrumMode.setSelected(true);
}
else if (displayMode == SpectrumTimeAnalyzer.DISPLAY_MODE_SCOPE)
{
oscilloMode.setSelected(true);
}
else if (displayMode == SpectrumTimeAnalyzer.DISPLAY_MODE_OFF)
{
offMode.setSelected(true);
}
}
ButtonGroup modeGroup = new ButtonGroup();
modeGroup.add(spectrumMode);
modeGroup.add(oscilloMode);
modeGroup.add(offMode);
modePane.add(spectrumMode);
modePane.add(oscilloMode);
modePane.add(offMode);
spectrumPane = new JPanel();
spectrumPane.setLayout(new BoxLayout(spectrumPane, BoxLayout.Y_AXIS));
peaksBox = new JCheckBox(getResource("spectrum.peaks"));
peaksBox.setAlignmentX(Component.LEFT_ALIGNMENT);
peaksBox.addActionListener(this);
if ((analyzer != null) && (analyzer.isPeaksEnabled())) peaksBox.setSelected(true);
else peaksBox.setSelected(false);
spectrumPane.add(peaksBox);
// Analyzer falloff.
JLabel analyzerFalloffLabel = new JLabel(getResource("spectrum.analyzer.falloff"));
analyzerFalloffLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
spectrumPane.add(analyzerFalloffLabel);
int minDecay = (int) (SpectrumTimeAnalyzer.MIN_SPECTRUM_ANALYSER_DECAY * 100);
int maxDecay = (int) (SpectrumTimeAnalyzer.MAX_SPECTRUM_ANALYSER_DECAY * 100);
int decay = (maxDecay + minDecay) / 2;
if (analyzer != null)
{
decay = (int) (analyzer.getSpectrumAnalyserDecay() * 100);
}
analyzerFalloff = new JSlider(JSlider.HORIZONTAL, minDecay, maxDecay, decay);
analyzerFalloff.setMajorTickSpacing(1);
analyzerFalloff.setPaintTicks(true);
analyzerFalloff.setMaximumSize(new Dimension(150, analyzerFalloff.getPreferredSize().height));
analyzerFalloff.setAlignmentX(Component.LEFT_ALIGNMENT);
analyzerFalloff.setSnapToTicks(true);
analyzerFalloff.addChangeListener(this);
spectrumPane.add(analyzerFalloff);
// Peaks falloff.
JLabel peaksFalloffLabel = new JLabel(getResource("spectrum.peaks.falloff"));
peaksFalloffLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
spectrumPane.add(peaksFalloffLabel);
int peakDelay = SpectrumTimeAnalyzer.DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY;
int fps = SpectrumTimeAnalyzer.DEFAULT_FPS;
if (analyzer != null)
{
fps = analyzer.getFps();
peakDelay = analyzer.getPeakDelay();
}
peaksFalloff = new JSlider(JSlider.HORIZONTAL, 0, 4, computeSliderValue(peakDelay, fps));
peaksFalloff.setMajorTickSpacing(1);
peaksFalloff.setPaintTicks(true);
peaksFalloff.setSnapToTicks(true);
Hashtable labelTable = new Hashtable();
labelTable.put(new Integer(0), new JLabel("Slow"));
labelTable.put(new Integer(4), new JLabel("Fast"));
peaksFalloff.setLabelTable(labelTable);
peaksFalloff.setPaintLabels(true);
peaksFalloff.setMaximumSize(new Dimension(150, peaksFalloff.getPreferredSize().height));
peaksFalloff.setAlignmentX(Component.LEFT_ALIGNMENT);
peaksFalloff.addChangeListener(this);
spectrumPane.add(peaksFalloff);
// Spectrum pane
spectrumPane.setBorder(new TitledBorder(getResource("spectrum.title")));
if (getResource("oscilloscope.title") != null)
{
oscilloPane = new JPanel();
oscilloPane.setBorder(new TitledBorder(getResource("oscilloscope.title")));
}
GridBagLayout layout = new GridBagLayout();
setLayout(layout);
GridBagConstraints cnts = new GridBagConstraints();
cnts.fill = GridBagConstraints.BOTH;
cnts.gridwidth = 2;
cnts.weightx = 2.0;
cnts.weighty = 0.25;
cnts.gridx = 0;
cnts.gridy = 0;
add(modePane, cnts);
cnts.gridwidth = 1;
cnts.weightx = 1.0;
cnts.weighty = 1.0;
cnts.gridx = 0;
cnts.gridy = 1;
add(spectrumPane, cnts);
cnts.weightx = 1.0;
cnts.weighty = 1.0;
cnts.gridx = 1;
cnts.gridy = 1;
if (oscilloPane != null) add(oscilloPane, cnts);
if (analyzer == null)
{
disablePane(modePane);
disablePane(spectrumPane);
disablePane(oscilloPane);
}
loaded = true;
}
}
private void disablePane(JPanel pane)
{
if (pane != null)
{
Component[] cpns = pane.getComponents();
if (cpns != null)
{
for (int i = 0; i < cpns.length; i++)
{
cpns[i].setEnabled(false);
}
}
}
}
public void actionPerformed(ActionEvent ev)
{
if (player != null)
{
SpectrumTimeAnalyzer analyzer = player.getSkin().getAcAnalyzer();
if (analyzer != null)
{
if (ev.getSource().equals(spectrumMode))
{
analyzer.setDisplayMode(SpectrumTimeAnalyzer.DISPLAY_MODE_SPECTRUM_ANALYSER);
analyzer.startDSP(null);
}
else if (ev.getSource().equals(oscilloMode))
{
analyzer.setDisplayMode(SpectrumTimeAnalyzer.DISPLAY_MODE_SCOPE);
analyzer.startDSP(null);
}
else if (ev.getSource().equals(offMode))
{
analyzer.setDisplayMode(SpectrumTimeAnalyzer.DISPLAY_MODE_OFF);
analyzer.closeDSP();
analyzer.repaint();
}
else if (ev.getSource().equals(peaksBox))
{
if (peaksBox.isSelected()) analyzer.setPeaksEnabled(true);
else analyzer.setPeaksEnabled(false);
}
}
}
}
public void stateChanged(ChangeEvent ce)
{
if (player != null)
{
SpectrumTimeAnalyzer analyzer = player.getSkin().getAcAnalyzer();
if (analyzer != null)
{
if (ce.getSource() == analyzerFalloff)
{
if (!analyzerFalloff.getValueIsAdjusting())
{
analyzer.setSpectrumAnalyserDecay(analyzerFalloff.getValue() * 1.0f / 100.0f);
}
}
else if (ce.getSource() == peaksFalloff)
{
if (!peaksFalloff.getValueIsAdjusting())
{
analyzer.setPeakDelay(computeDelay(peaksFalloff.getValue(), analyzer.getFps()));
}
}
}
}
}
private int computeDelay(int slidervalue, int fps)
{
float p = SpectrumTimeAnalyzer.DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO;
float n = SpectrumTimeAnalyzer.DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO_RANGE;
int delay = Math.round(((-n * slidervalue * 1.0f / 2.0f) + p + n) * fps);
return delay;
}
private int computeSliderValue(int delay, int fps)
{
float p = SpectrumTimeAnalyzer.DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO;
float n = SpectrumTimeAnalyzer.DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO_RANGE;
int value = (int) Math.round((((p - (delay * 1.0 / fps * 1.0f)) * 2 / n) + 2));
return value;
}
}

View File

@@ -1,54 +0,0 @@
/*
* VisualizationPreference.
*
* 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.ui;
import java.util.ResourceBundle;
import javax.swing.border.TitledBorder;
public class VisualizationPreference extends PreferenceItem
{
private static VisualizationPreference instance = null;
private VisualizationPreference()
{
}
public static VisualizationPreference getInstance()
{
if (instance == null)
{
instance = new VisualizationPreference();
}
return instance;
}
public void loadUI()
{
if (loaded == false)
{
bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/visualization");
setBorder(new TitledBorder(getResource("title")));
loaded = true;
}
}
}

View File

@@ -1,6 +0,0 @@
title=JavaSound Device
line.buffer.size=Line buffer size : {0} bytes
help=Note : Device update will occur on player restart only.

View File

@@ -1,2 +0,0 @@
title=Output plugins

View File

@@ -1,27 +0,0 @@
title=Preferences
tree.options=Options
tree.options.device=Device
tree.options.device.impl=javazoom.jlgui.player.amp.util.ui.DevicePreference
tree.options.visual=Visual
tree.options.visual.impl=javazoom.jlgui.player.amp.util.ui.VisualPreference
tree.options.system=System
tree.options.system.impl=javazoom.jlgui.player.amp.util.ui.SystemPreference
tree.options.filetypes=File Types
tree.options.filetypes.impl=javazoom.jlgui.player.amp.util.ui.TypePreference
#tree.plugins=Plugins
#tree.plugins.visualization=Visualization
#tree.plugins.visualization.impl=javazoom.jlgui.player.amp.util.ui.VisualizationPreference
#tree.plugins.output=Output
#tree.plugins.output.impl=javazoom.jlgui.player.amp.util.ui.OutputPreference
#tree.plugins.drm=DRM
#tree.plugins.drm.impl=javazoom.jlgui.player.amp.util.ui.EmptyPreference
tree.skins=Skins
tree.skins.browser=Browser
tree.skins.browser.impl=javazoom.jlgui.player.amp.util.ui.SkinPreference
button.close=Close

View File

@@ -1,4 +0,0 @@
title=Skins
browser.directory.button=Set skins directory ...

View File

@@ -1,3 +0,0 @@
title=System properties

View File

@@ -1,2 +0,0 @@
title=Supported File types

View File

@@ -1,15 +0,0 @@
title=Built-in visual options
mode.title=Mode
mode.spectrum=Spectrum analyzer
mode.oscilloscope=Oscilloscope
mode.off=Off
mode.refresh.rate=50
spectrum.title=Spectrum analyzer
spectrum.peaks=Peaks
spectrum.analyzer.falloff=Analyzer falloff :
spectrum.peaks.falloff=Peaks falloff :
#oscilloscope.title=Oscilloscope

View File

@@ -1,2 +0,0 @@
title=Visualization plugins

View File

@@ -1,775 +0,0 @@
/*
* SpectrumTimeAnalyzer.
*
* 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.visual.ui;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;
import javax.sound.sampled.SourceDataLine;
import javax.swing.JPanel;
import javazoom.jlgui.player.amp.skin.AbsoluteConstraints;
import kj.dsp.KJDigitalSignalProcessingAudioDataConsumer;
import kj.dsp.KJDigitalSignalProcessor;
import kj.dsp.KJFFT;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class SpectrumTimeAnalyzer extends JPanel implements KJDigitalSignalProcessor
{
private static Log log = LogFactory.getLog(SpectrumTimeAnalyzer.class);
public static final int DISPLAY_MODE_SCOPE = 0;
public static final int DISPLAY_MODE_SPECTRUM_ANALYSER = 1;
public static final int DISPLAY_MODE_OFF = 2;
public static final int DEFAULT_WIDTH = 256;
public static final int DEFAULT_HEIGHT = 128;
public static final int DEFAULT_FPS = 50;
public static final int DEFAULT_SPECTRUM_ANALYSER_FFT_SAMPLE_SIZE = 512;
public static final int DEFAULT_SPECTRUM_ANALYSER_BAND_COUNT = 19;
public static final float DEFAULT_SPECTRUM_ANALYSER_DECAY = 0.05f;
public static final int DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY = 20;
public static final float DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO = 0.4f;
public static final float DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO_RANGE = 0.1f;
public static final float MIN_SPECTRUM_ANALYSER_DECAY = 0.02f;
public static final float MAX_SPECTRUM_ANALYSER_DECAY = 0.08f;
public static final Color DEFAULT_BACKGROUND_COLOR = new Color(0, 0, 128);
public static final Color DEFAULT_SCOPE_COLOR = new Color(255, 192, 0);
public static final float DEFAULT_VU_METER_DECAY = 0.02f;
private Image bi;
private int displayMode = DISPLAY_MODE_SCOPE;
private Color scopeColor = DEFAULT_SCOPE_COLOR;
private Color[] spectrumAnalyserColors = getDefaultSpectrumAnalyserColors();
private KJDigitalSignalProcessingAudioDataConsumer dsp = null;
private boolean dspStarted = false;
private Color peakColor = null;
private int[] peaks = new int[DEFAULT_SPECTRUM_ANALYSER_BAND_COUNT];
private int[] peaksDelay = new int[DEFAULT_SPECTRUM_ANALYSER_BAND_COUNT];
private int peakDelay = DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY;
private boolean peaksEnabled = true;
private List visColors = null;
private int barOffset = 1;
private int width;
private int height;
private int height_2;
// -- Spectrum analyser variables.
private KJFFT fft;
private float[] old_FFT;
private int saFFTSampleSize;
private int saBands;
private float saColorScale;
private float saMultiplier;
private float saDecay = DEFAULT_SPECTRUM_ANALYSER_DECAY;
private float sad;
private SourceDataLine m_line = null;
// -- VU Meter
private float oldLeft;
private float oldRight;
// private float vuAverage;
// private float vuSamples;
private float vuDecay = DEFAULT_VU_METER_DECAY;
private float vuColorScale;
// -- FPS calulations.
private long lfu = 0;
private int fc = 0;
private int fps = DEFAULT_FPS;
private boolean showFPS = false;
private AbsoluteConstraints constraints = null;
// private Runnable PAINT_SYNCHRONIZER = new AWTPaintSynchronizer();
public SpectrumTimeAnalyzer()
{
setOpaque(false);
initialize();
}
public void setConstraints(AbsoluteConstraints cnts)
{
constraints = cnts;
}
public AbsoluteConstraints getConstraints()
{
return constraints;
}
public boolean isPeaksEnabled()
{
return peaksEnabled;
}
public void setPeaksEnabled(boolean peaksEnabled)
{
this.peaksEnabled = peaksEnabled;
}
public int getFps()
{
return fps;
}
public void setFps(int fps)
{
this.fps = fps;
}
/**
* Starts DSP.
* @param line
*/
public void startDSP(SourceDataLine line)
{
if (displayMode == DISPLAY_MODE_OFF) return;
if (line != null) m_line = line;
if (dsp == null)
{
dsp = new KJDigitalSignalProcessingAudioDataConsumer(2048, fps);
dsp.add(this);
}
if ((dsp != null) && (m_line != null))
{
if (dspStarted == true)
{
stopDSP();
}
dsp.start(m_line);
dspStarted = true;
log.debug("DSP started");
}
}
/**
* Stop DSP.
*/
public void stopDSP()
{
if (dsp != null)
{
dsp.stop();
dspStarted = false;
log.debug("DSP stopped");
}
}
/**
* Close DSP
*/
public void closeDSP()
{
if (dsp != null)
{
stopDSP();
dsp = null;
log.debug("DSP closed");
}
}
/**
* Setup DSP.
* @param line
*/
public void setupDSP(SourceDataLine line)
{
if (dsp != null)
{
int channels = line.getFormat().getChannels();
if (channels == 1) dsp.setChannelMode(KJDigitalSignalProcessingAudioDataConsumer.CHANNEL_MODE_MONO);
else dsp.setChannelMode(KJDigitalSignalProcessingAudioDataConsumer.CHANNEL_MODE_STEREO);
int bits = line.getFormat().getSampleSizeInBits();
if (bits == 8) dsp.setSampleType(KJDigitalSignalProcessingAudioDataConsumer.SAMPLE_TYPE_EIGHT_BIT);
else dsp.setSampleType(KJDigitalSignalProcessingAudioDataConsumer.SAMPLE_TYPE_SIXTEEN_BIT);
}
}
/**
* Write PCM data to DSP.
* @param pcmdata
*/
public void writeDSP(byte[] pcmdata)
{
if ((dsp != null) && (dspStarted == true)) dsp.writeAudioData(pcmdata);
}
/**
* Return DSP.
* @return
*/
public KJDigitalSignalProcessingAudioDataConsumer getDSP()
{
return dsp;
}
/**
* Set visual colors from skin.
* @param viscolor
*/
public void setVisColor(String viscolor)
{
ArrayList visColors = new ArrayList();
viscolor = viscolor.toLowerCase();
ByteArrayInputStream in = new ByteArrayInputStream(viscolor.getBytes());
BufferedReader bin = new BufferedReader(new InputStreamReader(in));
try
{
String line = null;
while ((line = bin.readLine()) != null)
{
visColors.add(getColor(line));
}
Color[] colors = new Color[visColors.size()];
visColors.toArray(colors);
Color[] specColors = new Color[15];
System.arraycopy(colors, 2, specColors, 0, 15);
List specList = Arrays.asList(specColors);
Collections.reverse(specList);
specColors = (Color[]) specList.toArray(specColors);
setSpectrumAnalyserColors(specColors);
setBackground((Color) visColors.get(0));
if (visColors.size()>23) setPeakColor((Color) visColors.get(23));
if (visColors.size()>18) setScopeColor((Color) visColors.get(18));
}
catch (IOException ex)
{
log.warn("Cannot parse viscolors", ex);
}
finally
{
try
{
if (bin != null) bin.close();
}
catch (IOException e)
{
}
}
}
/**
* Set visual peak color.
* @param c
*/
public void setPeakColor(Color c)
{
peakColor = c;
}
/**
* Set peak falloff delay.
* @param framestowait
*/
public void setPeakDelay(int framestowait)
{
int min = (int) Math.round((DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO - DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO_RANGE) * fps);
int max = (int) Math.round((DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO + DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO_RANGE) * fps);
if ((framestowait >= min) && (framestowait <= max))
{
peakDelay = framestowait;
}
else
{
peakDelay = (int) Math.round(DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO * fps);
}
}
/**
* Return peak falloff delay
* @return int framestowait
*/
public int getPeakDelay()
{
return peakDelay;
}
/**
* Convert string to color.
* @param linecolor
* @return
*/
public Color getColor(String linecolor)
{
Color color = Color.BLACK;
StringTokenizer st = new StringTokenizer(linecolor, ",");
int red = 0, green = 0, blue = 0;
try
{
if (st.hasMoreTokens()) red = Integer.parseInt(st.nextToken().trim());
if (st.hasMoreTokens()) green = Integer.parseInt(st.nextToken().trim());
if (st.hasMoreTokens())
{
String blueStr = st.nextToken().trim();
if (blueStr.length() > 3) blueStr = (blueStr.substring(0, 3)).trim();
blue = Integer.parseInt(blueStr);
}
color = new Color(red, green, blue);
}
catch (NumberFormatException e)
{
log.debug("Cannot parse viscolor : "+e.getMessage());
}
return color;
}
private void computeColorScale()
{
saColorScale = ((float) spectrumAnalyserColors.length / height) * barOffset * 1.0f;
vuColorScale = ((float) spectrumAnalyserColors.length / (width - 32)) * 2.0f;
}
private void computeSAMultiplier()
{
saMultiplier = (saFFTSampleSize / 2) / saBands;
}
private void drawScope(Graphics pGrp, float[] pSample)
{
pGrp.setColor(scopeColor);
int wLas = (int) (pSample[0] * (float) height_2) + height_2;
int wSt = 2;
for (int a = wSt, c = 0; c < width; a += wSt, c++)
{
int wAs = (int) (pSample[a] * (float) height_2) + height_2;
pGrp.drawLine(c, wLas, c + 1, wAs);
wLas = wAs;
}
}
private void drawSpectrumAnalyser(Graphics pGrp, float[] pSample, float pFrrh)
{
float c = 0;
float[] wFFT = fft.calculate(pSample);
float wSadfrr = (saDecay * pFrrh);
float wBw = ((float) width / (float) saBands);
for (int a = 0, bd = 0; bd < saBands; a += saMultiplier, bd++)
{
float wFs = 0;
// -- Average out nearest bands.
for (int b = 0; b < saMultiplier; b++)
{
wFs += wFFT[a + b];
}
// -- Log filter.
wFs = (wFs * (float) Math.log(bd + 2));
if (wFs > 1.0f)
{
wFs = 1.0f;
}
// -- Compute SA decay...
if (wFs >= (old_FFT[a] - wSadfrr))
{
old_FFT[a] = wFs;
}
else
{
old_FFT[a] -= wSadfrr;
if (old_FFT[a] < 0)
{
old_FFT[a] = 0;
}
wFs = old_FFT[a];
}
drawSpectrumAnalyserBar(pGrp, (int) c, height, (int) wBw - 1, (int) (wFs * height), bd);
c += wBw;
}
}
private void drawVUMeter(Graphics pGrp, float[] pLeft, float[] pRight, float pFrrh)
{
if (displayMode == DISPLAY_MODE_OFF) return;
float wLeft = 0.0f;
float wRight = 0.0f;
float wSadfrr = (vuDecay * pFrrh);
for (int a = 0; a < pLeft.length; a++)
{
wLeft += Math.abs(pLeft[a]);
wRight += Math.abs(pRight[a]);
}
wLeft = ((wLeft * 2.0f) / (float) pLeft.length);
wRight = ((wRight * 2.0f) / (float) pRight.length);
if (wLeft > 1.0f)
{
wLeft = 1.0f;
}
if (wRight > 1.0f)
{
wRight = 1.0f;
}
// vuAverage += ( ( wLeft + wRight ) / 2.0f );
// vuSamples++;
//
// if ( vuSamples > 128 ) {
// vuSamples /= 2.0f;
// vuAverage /= 2.0f;
// }
if (wLeft >= (oldLeft - wSadfrr))
{
oldLeft = wLeft;
}
else
{
oldLeft -= wSadfrr;
if (oldLeft < 0)
{
oldLeft = 0;
}
}
if (wRight >= (oldRight - wSadfrr))
{
oldRight = wRight;
}
else
{
oldRight -= wSadfrr;
if (oldRight < 0)
{
oldRight = 0;
}
}
int wHeight = (height >> 1) - 24;
drawVolumeMeterBar(pGrp, 16, 16, (int) (oldLeft * (float) (width - 32)), wHeight);
// drawVolumeMeterBar( pGrp, 16, wHeight + 22, (int)( ( vuAverage / vuSamples ) * (float)( width - 32 ) ), 4 );
drawVolumeMeterBar(pGrp, 16, wHeight + 32, (int) (oldRight * (float) (width - 32)), wHeight);
// pGrp.fillRect( 16, 16, (int)( oldLeft * (float)( width - 32 ) ), wHeight );
// pGrp.fillRect( 16, 64, (int)( oldRight * (float)( width - 32 ) ), wHeight );
}
private void drawSpectrumAnalyserBar(Graphics pGraphics, int pX, int pY, int pWidth, int pHeight, int band)
{
float c = 0;
for (int a = pY; a >= pY - pHeight; a -= barOffset)
{
c += saColorScale;
if (c < spectrumAnalyserColors.length)
{
pGraphics.setColor(spectrumAnalyserColors[(int) c]);
}
pGraphics.fillRect(pX, a, pWidth, 1);
}
if ((peakColor != null) && (peaksEnabled == true))
{
pGraphics.setColor(peakColor);
if (pHeight > peaks[band])
{
peaks[band] = pHeight;
peaksDelay[band] = peakDelay;
}
else
{
peaksDelay[band]--;
if (peaksDelay[band] < 0) peaks[band]--;
if (peaks[band] < 0) peaks[band] = 0;
}
pGraphics.fillRect(pX, pY - peaks[band], pWidth, 1);
}
}
private void drawVolumeMeterBar(Graphics pGraphics, int pX, int pY, int pWidth, int pHeight)
{
float c = 0;
for (int a = pX; a <= pX + pWidth; a += 2)
{
c += vuColorScale;
if (c < 256.0f)
{
pGraphics.setColor(spectrumAnalyserColors[(int) c]);
}
pGraphics.fillRect(a, pY, 1, pHeight);
}
}
private synchronized Image getDoubleBuffer()
{
if (bi == null || (bi.getWidth(null) != getSize().width || bi.getHeight(null) != getSize().height))
{
width = getSize().width;
height = getSize().height;
height_2 = height >> 1;
computeColorScale();
bi = getGraphicsConfiguration().createCompatibleVolatileImage(width, height);
}
return bi;
}
public static Color[] getDefaultSpectrumAnalyserColors()
{
Color[] wColors = new Color[256];
for (int a = 0; a < 128; a++)
{
wColors[a] = new Color(0, (a >> 1) + 192, 0);
}
for (int a = 0; a < 64; a++)
{
wColors[a + 128] = new Color(a << 2, 255, 0);
}
for (int a = 0; a < 64; a++)
{
wColors[a + 192] = new Color(255, 255 - (a << 2), 0);
}
return wColors;
}
/**
* @return Returns the current display mode, DISPLAY_MODE_SCOPE or DISPLAY_MODE_SPECTRUM_ANALYSER.
*/
public int getDisplayMode()
{
return displayMode;
}
/**
* @return Returns the current number of bands displayed by the spectrum analyser.
*/
public int getSpectrumAnalyserBandCount()
{
return saBands;
}
/**
* @return Returns the decay rate of the spectrum analyser's bands.
*/
public float getSpectrumAnalyserDecay()
{
return saDecay;
}
/**
* @return Returns the color the scope is rendered in.
*/
public Color getScopeColor()
{
return scopeColor;
}
/**
* @return Returns the color scale used to render the spectrum analyser bars.
*/
public Color[] getSpectrumAnalyserColors()
{
return spectrumAnalyserColors;
}
private void initialize()
{
setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
setBackground(DEFAULT_BACKGROUND_COLOR);
prepareDisplayToggleListener();
setSpectrumAnalyserBandCount(DEFAULT_SPECTRUM_ANALYSER_BAND_COUNT);
setSpectrumAnalyserFFTSampleSize(DEFAULT_SPECTRUM_ANALYSER_FFT_SAMPLE_SIZE);
}
/**
* @return Returns 'true' if "Frames Per Second" are being calculated and displayed.
*/
public boolean isShowingFPS()
{
return showFPS;
}
public void paintComponent(Graphics pGraphics)
{
if (displayMode == DISPLAY_MODE_OFF) return;
if (dspStarted)
{
pGraphics.drawImage(getDoubleBuffer(), 0, 0, null);
}
else
{
super.paintComponent(pGraphics);
}
}
private void prepareDisplayToggleListener()
{
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent pEvent)
{
if (pEvent.getButton() == MouseEvent.BUTTON1)
{
if (displayMode + 1 > 1)
{
displayMode = 0;
}
else
{
displayMode++;
}
}
}
});
}
/* (non-Javadoc)
* @see kj.dsp.KJDigitalSignalProcessor#process(float[], float[], float)
*/
public synchronized void process(float[] pLeft, float[] pRight, float pFrameRateRatioHint)
{
if (displayMode == DISPLAY_MODE_OFF) return;
Graphics wGrp = getDoubleBuffer().getGraphics();
wGrp.setColor(getBackground());
wGrp.fillRect(0, 0, getSize().width, getSize().height);
switch (displayMode)
{
case DISPLAY_MODE_SCOPE:
drawScope(wGrp, stereoMerge(pLeft, pRight));
break;
case DISPLAY_MODE_SPECTRUM_ANALYSER:
drawSpectrumAnalyser(wGrp, stereoMerge(pLeft, pRight), pFrameRateRatioHint);
break;
case DISPLAY_MODE_OFF:
drawVUMeter(wGrp, pLeft, pRight, pFrameRateRatioHint);
break;
}
// -- Show FPS if necessary.
if (showFPS)
{
// -- Calculate FPS.
if (System.currentTimeMillis() >= lfu + 1000)
{
lfu = System.currentTimeMillis();
fps = fc;
fc = 0;
}
fc++;
wGrp.setColor(Color.yellow);
wGrp.drawString("FPS: " + fps + " (FRRH: " + pFrameRateRatioHint + ")", 0, height - 1);
}
if (getGraphics() != null) getGraphics().drawImage(getDoubleBuffer(), 0, 0, null);
// repaint();
// try {
// EventQueue.invokeLater( new AWTPaintSynchronizer() );
// } catch ( Exception pEx ) {
// // -- Ignore exception.
// pEx.printStackTrace();
// }
}
/**
* Sets the current display mode.
*
* @param pMode Must be either DISPLAY_MODE_SCOPE or DISPLAY_MODE_SPECTRUM_ANALYSER.
*/
public synchronized void setDisplayMode(int pMode)
{
displayMode = pMode;
}
/**
* Sets the color of the scope.
*
* @param pColor
*/
public synchronized void setScopeColor(Color pColor)
{
scopeColor = pColor;
}
/**
* When 'true' is passed as a parameter, will overlay the "Frames Per Seconds"
* achieved by the component.
*
* @param pState
*/
public synchronized void setShowFPS(boolean pState)
{
showFPS = pState;
}
/**
* Sets the numbers of bands rendered by the spectrum analyser.
*
* @param pCount Cannot be more than half the "FFT sample size".
*/
public synchronized void setSpectrumAnalyserBandCount(int pCount)
{
saBands = pCount;
peaks = new int[saBands];
peaksDelay = new int[saBands];
computeSAMultiplier();
}
/**
* Sets the spectrum analyser band decay rate.
*
* @param pDecay Must be a number between 0.0 and 1.0 exclusive.
*/
public synchronized void setSpectrumAnalyserDecay(float pDecay)
{
if ((pDecay >= MIN_SPECTRUM_ANALYSER_DECAY) && (pDecay <= MAX_SPECTRUM_ANALYSER_DECAY))
{
saDecay = pDecay;
}
else saDecay = DEFAULT_SPECTRUM_ANALYSER_DECAY;
}
/**
* Sets the spectrum analyser color scale.
*
* @param pColors Any amount of colors may be used. Must not be null.
*/
public synchronized void setSpectrumAnalyserColors(Color[] pColors)
{
spectrumAnalyserColors = pColors;
computeColorScale();
}
/**
* Sets the FFT sample size to be just for calculating the spectrum analyser
* values. The default is 512.
*
* @param pSize Cannot be more than the size of the sample provided by the DSP.
*/
public synchronized void setSpectrumAnalyserFFTSampleSize(int pSize)
{
saFFTSampleSize = pSize;
fft = new KJFFT(saFFTSampleSize);
old_FFT = new float[saFFTSampleSize];
computeSAMultiplier();
}
private float[] stereoMerge(float[] pLeft, float[] pRight)
{
for (int a = 0; a < pLeft.length; a++)
{
pLeft[a] = (pLeft[a] + pRight[a]) / 2.0f;
}
return pLeft;
}
/*public void update(Graphics pGraphics)
{
// -- Prevent AWT from clearing background.
paint(pGraphics);
}*/
}

View File

@@ -1,6 +1,7 @@
package mimis;
import mimis.event.EventHandler;
import mimis.exception.worker.DeactivateException;
import mimis.manager.Titled;
public abstract class Application extends EventHandler implements Titled, Exitable {
@@ -16,10 +17,14 @@ public abstract class Application extends EventHandler implements Titled, Exitab
return title;
}
public void exit() {
public void stop() {
if (active()) {
deactivate();
try {
deactivate();
} catch (DeactivateException e) {
log.error(e);
}
}
stop();
super.stop();
}
}

View File

@@ -6,7 +6,6 @@ import mimis.device.jintellitype.JIntellitypeDevice;
import mimis.device.lirc.LircDevice;
import mimis.device.network.NetworkDevice;
import mimis.device.panel.PanelDevice;
import mimis.device.player.PlayerDevice;
import mimis.device.wiimote.WiimoteDevice;
import mimis.event.EventRouter;
import mimis.event.router.GlobalRouter;
@@ -36,7 +35,6 @@ public class Client {
new WiimoteDevice(),
new PanelDevice(),
new JIntellitypeDevice(),
new PlayerDevice(),
new RumblepadDevice(),
new Extreme3DDevice(),
new NetworkDevice()};

View File

@@ -4,6 +4,7 @@ import mimis.event.EventHandler;
import mimis.event.Task;
import mimis.event.task.Continuous;
import mimis.event.task.Stopper;
import mimis.exception.worker.DeactivateException;
import mimis.macro.Sequence;
import mimis.macro.SequenceListener;
import mimis.macro.State;
@@ -23,8 +24,11 @@ public abstract class Device extends EventHandler implements Titled, Exitable {
public Device(String title) {
this.title = title;
active = false;
}
public void start() {
sequenceListener = new SequenceListener(this);
super.start();
}
/* Register macro's */
@@ -84,9 +88,13 @@ public abstract class Device extends EventHandler implements Titled, Exitable {
return title;
}
public void exit() {
public void stop() {
if (active()) {
deactivate();
try {
deactivate();
} catch (DeactivateException e) {
log.error(e);
}
}
stop();
}

View File

@@ -1,5 +1,5 @@
package mimis;
public interface Exitable {
public void exit();
public void stop();
}

View File

@@ -72,7 +72,7 @@ public class GUI extends JFrame {
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
log.debug("Window closing");
exit();
mimis.exit();
mimis.stop();
}
}

View File

@@ -12,10 +12,10 @@ import mimis.device.jintellitype.JIntellitypeDevice;
import mimis.device.lirc.LircDevice;
import mimis.device.network.NetworkDevice;
import mimis.device.panel.PanelDevice;
import mimis.device.player.PlayerDevice;
import mimis.device.wiimote.WiimoteDevice;
import mimis.event.EventRouter;
import mimis.event.router.LocalRouter;
import mimis.exception.worker.ActivateException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -42,7 +42,6 @@ public class Main {
new WiimoteDevice(),
new PanelDevice(),
new JIntellitypeDevice(),
new PlayerDevice(),
new RumblepadDevice(),
new Extreme3DDevice(),
new NetworkDevice()};
@@ -51,7 +50,11 @@ public class Main {
public void start() {
log.debug("Main");
Mimis mimis = new Mimis(eventRouter, applicationArray, deviceArray);
mimis.activate();
try {
mimis.activate();
} catch (ActivateException e) {
log.fatal(e);
}
}
public static void main(String[] args) {

View File

@@ -33,7 +33,7 @@ public class Manager<T extends Worker & Titled & Exitable> extends Worker {
public void stop() {
super.stop();
for (T manageable : manageableArray) {
manageable.exit();
manageable.stop();
}
super.stop();
}

View File

@@ -2,13 +2,13 @@ package mimis;
import mimis.event.EventHandler;
import mimis.event.EventRouter;
import mimis.exception.worker.ActivateException;
import mimis.util.ArrayCycle;
import mimis.value.Action;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class Mimis extends EventHandler {
protected Log log = LogFactory.getLog(getClass());
@@ -19,11 +19,11 @@ public class Mimis extends EventHandler {
protected Manager<Application> applicationManager;
protected Manager<Device> deviceManager;
public Mimis(EventRouter eventRouter) {
this(eventRouter, new Application[0], new Device[0]);
}
public Mimis(EventRouter eventRouter, Application[] applicationArray) {
this(eventRouter, applicationArray, new Device[0]);
}
@@ -36,20 +36,20 @@ public class Mimis extends EventHandler {
EventHandler.initialise(eventRouter);
applicationManager = new Manager<Application>(applicationArray);
deviceManager = new Manager<Device>(deviceArray);
this.applicationArray = applicationArray;
this.deviceArray = deviceArray;
applicationCycle = new ArrayCycle<Application>(applicationArray);
}
public void activate() {
public void activate() throws ActivateException {
log.debug("Activate managers");
applicationManager.activate();
deviceManager.start();
deviceManager.activate();
log.debug("Create gui");
gui = new GUI(this, applicationManager, deviceManager);
if (applicationCycle.size() > 0) {
log.debug("Initialise application cycle");
eventRouter.set(applicationCycle.current());
@@ -57,15 +57,14 @@ public class Mimis extends EventHandler {
super.activate(false);
}
public void exit() {
public void stop() {
log.debug("Stop event router");
eventRouter.stop();
log.debug("Stop managers");
applicationManager.stop();
deviceManager.stop();
stop();
deviceManager.stop();
super.stop();
}
protected void action(Action action) {
@@ -80,7 +79,7 @@ public class Mimis extends EventHandler {
System.out.println(applicationCycle.current());
break;
case EXIT:
exit();
stop();
break;
}
}

View File

@@ -1,5 +1,8 @@
package mimis;
import mimis.exception.worker.ActivateException;
import mimis.exception.worker.DeactivateException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -31,7 +34,11 @@ public abstract class Worker implements Runnable {
public void stop() {
log.trace("Stop");
if (active()) {
deactivate();
try {
deactivate();
} catch (DeactivateException e) {
log.error(e);
}
}
running = false;
synchronized (this) {
@@ -57,7 +64,7 @@ public abstract class Worker implements Runnable {
return active;
}
public void activate() {
public void activate() throws ActivateException {
activate(THREAD);
}
@@ -71,7 +78,7 @@ public abstract class Worker implements Runnable {
}
}
public void deactivate() {
public void deactivate() throws DeactivateException {
active = false;
}

View File

@@ -3,6 +3,8 @@ package mimis.application.cmd;
import java.io.IOException;
import mimis.Application;
import mimis.exception.worker.ActivateException;
import mimis.exception.worker.DeactivateException;
import mimis.util.Native;
import mimis.util.VBScript;
@@ -20,7 +22,7 @@ public abstract class CMDApplication extends Application {
this.title = title;
}
public void activate() {
public void activate() throws ActivateException {
String key = String.format("%s\\%s", REGISTRY, program);
// Check of naam is gevonden in register
String path = Native.getValue(key);
@@ -29,8 +31,7 @@ public abstract class CMDApplication extends Application {
command = Native.replaceVariables(command);
process = Runtime.getRuntime().exec(command);
} catch (IOException e) {
e.printStackTrace();
//throw new ApplicationInitialiseException();
throw new ActivateException();
}
super.activate();
}
@@ -39,11 +40,11 @@ public abstract class CMDApplication extends Application {
try {
return active = VBScript.isRunning(program);
} catch (IOException e) {
return false;
return active = false;
}
}
public void deactivate() {
public void deactivate() throws DeactivateException {
if (process != null) {
process.destroy();
}

View File

@@ -1,6 +1,7 @@
package mimis.application.cmd.windows;
import mimis.application.cmd.CMDApplication;
import mimis.exception.worker.ActivateException;
import mimis.util.Windows;
import mimis.value.Command;
import mimis.value.Key;
@@ -21,15 +22,16 @@ public abstract class WindowsApplication extends CMDApplication {
handle = -1;
}
public void initialise() {
public void activate() throws ActivateException {
handle = Windows.findWindow(name, null);
if (handle < 1) {
super.initialise();
super.activate();
sleep(START_SLEEP);
handle = Windows.findWindow(name, null);
}
active = handle > 0;
if (handle < 1) {
//throw new ApplicationInitialiseException();
throw new ActivateException();
}
}

View File

@@ -13,7 +13,7 @@ public class GomPlayerApplication extends WindowsApplication {
}
public void action(Action action) {
System.out.println("GomPlayerApplication: " + action);
log.trace("GomPlayerApplication: " + action);
switch (action) {
case PLAY:
command(0x800C);

Some files were not shown because too many files have changed in this diff Show More