Class BeaTunes
- java.lang.Object
-
- com.tagtraum.beatunes.BeaTunes
-
- All Implemented Interfaces:
ApplicationComponent<BeaTunes>
public class BeaTunes extends Object implements ApplicationComponent<BeaTunes>
Central application class providing access to all other important objects. If you are implementing a
Plugin
, consider implementingApplicationComponent
, as a reference to the centralBeaTunes
instance will be injected during startup via the methodApplicationComponent.setApplication(com.tagtraum.core.app.ApplicationComponent)
. Correspondingly, an instance ofBeaTunes
is available viaApplicationComponent.getApplication()
.To access the
AudioSong
-library, usegetMediaLibrary()
.- Author:
- Hendrik Schreiber
-
-
Field Summary
Fields Modifier and Type Field Description static BeaTunesProperties
BEATUNES_PROPERTIES
Essential properties (special folders, user-agent, ...).static Locale
DEFAULT_LOCALE
static Version
REQUIRED_ITUNES_VERSION
static Locale
STRINGS_LOCALE
-
Constructor Summary
Constructors Constructor Description BeaTunes()
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addPropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)
Add aPropertyChangeListener
.void
addShutdownHook(Callable<Boolean> shutdownHook)
Allows you to register some code that is to be executed before the actual shut down of the software.ActionManager
getActionManager()
The centralActionManager
allows registration and retrieval of theBaseAction
s used throughout the application.Amazon
getAmazon()
Component that allows accessing Amazon.AnalysisQueue
getAnalysisQueue()
TheAnalysisQueue
is the central component for queue based analysis of songs.BeaTunes
getApplication()
Returns the main application component.static long
getBuildDate()
Returns the build date in ms since 1970.Icon
getDisabledIcon(String resourceName)
UsesgetResource(String)
to look up anImageIcon
and transform it to a light gray.GeneralPreferences
getGeneralPreferences()
Get the general preferences (instance ofConfigurableComponent
).Icon
getGrayIcon(String resourceName)
UsesgetResource(String)
to look up anImageIcon
and transform it to gray.Icon
getIcon(PlayList playList)
Provides aPlayList
icon.Icon
getIcon(String resourceName)
UsesgetResource(String)
to look up anImageIcon
.static Icon
getIcon(String resourceName, Theme theme)
String
getId()
Unique id for each instance of this object.static Image
getImage(String resourceName)
Loads an image fromBeaTunes
's package (or the resource folder in a Mac App Bundle).InspectionPreferences
getInspectionPreferences()
Get the inspection preferences (instance ofConfigurableComponent
).MediaLibrary
getiTunesMusicLibrary()
Deprecated.Icon
getLightnessAdjustedIcon(PlayList playList)
Provides aPlayList
icon that has been adjusted to the theme's lightness.Icon
getLightnessAdjustedIcon(String resourceName)
UsesgetResource(String)
to look up anImageIcon
.Icon
getLightnessAdjustedSmallIcon(PlayList playList)
Provides aPlayList
icon that has been adjusted to the theme's lightness.Locale
getLocale()
The application locale.MainWindow
getMainWindow()
Returns beaTunes' main application window, which provides access to other (visual) sub-components.static int
getMajorVersion()
Major application version.MediaLibrary
getMediaLibrary()
Access to beaTunes' central internal database.static int
getMicroVersion()
Minor application version.static int
getMinorVersion()
Minor application version.Icon
getNegativeIcon(String resourceName)
UsesgetResource(String)
to look up anImageIcon
and transform it to an inverted (negative) version.long
getNewPlaylistParentId()
PlaybackPreferences
getPlaybackPreferences()
Get the playback preferences (instance ofConfigurableComponent
).PlayListPlayer
getPlayer()
Current playlist player.PluginManager<BeaTunes>
getPluginManager()
Provides access to all dynamically loaded components.PreferencesDialog
getPreferencesDialog()
The preferences dialog features different preference panes.static String
getREmail()
int
getRemainingTrialDays()
URL
getResource(String resourceName)
Resolves a resource name to a URL.static String
getRKey()
static String
getRName()
Icon
getSmallIcon(PlayList playList)
Provides a smallPlayList
icon.Theme
getTheme()
Get the UI customization theme.ITunes
getTunes()
Remote access to theITunes
applications.static long
getUserId()
Persistent and unique user id.static String
getVersion()
beaTunes version (seeTimestamp.V
).static void
handleOutOfMemoryError()
React toOutOfMemoryError
, i.e.static void
handleOutOfMemoryError(OutOfMemoryError e)
React toOutOfMemoryError
, i.e.void
init()
Initializes this component and its sub-components.static boolean
isEarlyAccess()
Are we in early-access mode?void
loadPreferences()
Re-loads the application component's preferences.String
localize(String key, Object... objects)
UsesResourceBundle.getString(String)
to look up localized strings.static String
localizeWithoutTheme(String key, Object... objects)
UsesResourceBundle.getString(String)
to look up localized strings.static void
main(String[] args)
Starts this application in the Swing UI thread.void
play(AudioSongLocation location)
Start playing the given file/resource.void
removePropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)
Remove aPropertyChangeListener
.void
setApplication(BeaTunes beaTunes)
Sets the main application component.void
setLocale(Locale locale)
Sets the application locale.void
setPlayer(PlayListPlayer player)
Sets a new playlist player.void
setTheme(Theme theme)
Sets the UI customization scheme.void
shutdown()
Shuts down this component and its sub-components.void
storePreferences()
Stores the application component's preferences asynchronously.boolean
x()
boolean
z(String registrationName, String registrationEmail, String licenseKey)
-
-
-
Field Detail
-
BEATUNES_PROPERTIES
public static BeaTunesProperties BEATUNES_PROPERTIES
Essential properties (special folders, user-agent, ...).
-
DEFAULT_LOCALE
public static final Locale DEFAULT_LOCALE
-
STRINGS_LOCALE
public static final Locale STRINGS_LOCALE
-
REQUIRED_ITUNES_VERSION
public static final Version REQUIRED_ITUNES_VERSION
-
-
Method Detail
-
play
public void play(AudioSongLocation location)
Start playing the given file/resource.- Parameters:
location
- location describing a file/stream or a playlist
-
isEarlyAccess
public static boolean isEarlyAccess()
Are we in early-access mode?- Returns:
true
orfalse
-
getGeneralPreferences
public GeneralPreferences getGeneralPreferences()
Get the general preferences (instance ofConfigurableComponent
).- Returns:
- general preferences
-
getPlaybackPreferences
public PlaybackPreferences getPlaybackPreferences()
Get the playback preferences (instance ofConfigurableComponent
).- Returns:
- playback preferences
-
getInspectionPreferences
public InspectionPreferences getInspectionPreferences()
Get the inspection preferences (instance ofConfigurableComponent
).- Returns:
- inspection preferences
-
getApplication
public BeaTunes getApplication()
Description copied from interface:ApplicationComponent
Returns the main application component.- Specified by:
getApplication
in interfaceApplicationComponent<BeaTunes>
- Returns:
- application object
-
setApplication
public void setApplication(BeaTunes beaTunes)
Description copied from interface:ApplicationComponent
Sets the main application component.- Specified by:
setApplication
in interfaceApplicationComponent<BeaTunes>
- Parameters:
beaTunes
- main application component
-
getResource
public URL getResource(String resourceName)
Resolves a resource name to a URL. If aTheme
is set, the theme is asked first to resolve it. If that fails the resource is resolved relative to theBeaTunes
class.- Parameters:
resourceName
- resource name- Returns:
- resource url or null
- See Also:
Class.getResource(String)
,Theme.getResource(String)
-
getImage
public static Image getImage(String resourceName)
Loads an image fromBeaTunes
's package (or the resource folder in a Mac App Bundle).- Parameters:
resourceName
- resource name- Returns:
- image, if found
-
getIcon
public Icon getIcon(PlayList playList)
Provides aPlayList
icon.- Parameters:
playList
- playlist- Returns:
- icon
-
getSmallIcon
public Icon getSmallIcon(PlayList playList)
Provides a smallPlayList
icon.- Parameters:
playList
- playlist- Returns:
- icon
-
getLightnessAdjustedIcon
public Icon getLightnessAdjustedIcon(PlayList playList)
Provides aPlayList
icon that has been adjusted to the theme's lightness.- Parameters:
playList
- playlist- Returns:
- icon
- See Also:
Theme.isLight()
-
getLightnessAdjustedSmallIcon
public Icon getLightnessAdjustedSmallIcon(PlayList playList)
Provides aPlayList
icon that has been adjusted to the theme's lightness.- Parameters:
playList
- playlist- Returns:
- icon
- See Also:
Theme.isLight()
-
getGrayIcon
public Icon getGrayIcon(String resourceName)
UsesgetResource(String)
to look up anImageIcon
and transform it to gray.- Parameters:
resourceName
- resource name- Returns:
- Icon or null if the resource can't be found
-
getDisabledIcon
public Icon getDisabledIcon(String resourceName)
UsesgetResource(String)
to look up anImageIcon
and transform it to a light gray.- Parameters:
resourceName
- resource name- Returns:
- Icon or
null
if the resource can't be found
-
getNegativeIcon
public Icon getNegativeIcon(String resourceName)
UsesgetResource(String)
to look up anImageIcon
and transform it to an inverted (negative) version.- Parameters:
resourceName
- resource name- Returns:
- Icon or
null
if the resource can't be found
-
getLightnessAdjustedIcon
public Icon getLightnessAdjustedIcon(String resourceName)
UsesgetResource(String)
to look up anImageIcon
. Depending onTheme.isLight()
the icon is automatically inverted or not.- Parameters:
resourceName
- resource name- Returns:
- icon
- See Also:
Theme.isLight()
-
getIcon
public static Icon getIcon(String resourceName, Theme theme)
- Parameters:
resourceName
- resource name- Returns:
- Icon or
null
if the resource can't be found
-
getIcon
public Icon getIcon(String resourceName)
UsesgetResource(String)
to look up anImageIcon
.- Parameters:
resourceName
- resource name- Returns:
- Icon or
null
if the resource can't be found
-
localizeWithoutTheme
public static String localizeWithoutTheme(String key, Object... objects)
UsesResourceBundle.getString(String)
to look up localized strings. The resulting string is then formatted usingMessageFormat.format(String, Object...)
. This means it has to follow theMessageFormat
escaping rules (').- Parameters:
key
- keyobjects
- objects to inject for placeholders- Returns:
- string or null
-
localize
public String localize(String key, Object... objects)
UsesResourceBundle.getString(String)
to look up localized strings. If a theme is set,Theme.getLocalizedString(String)
is consulted first, then the impl falls back to the default tables. The resulting string is then formatted usingMessageFormat.format(String, Object...)
. This means it has to follow theMessageFormat
escaping rules (').- Parameters:
key
- keyobjects
- objects to inject for placeholders- Returns:
- string or null
-
getTheme
public Theme getTheme()
Get the UI customization theme.- Returns:
- theme
- See Also:
setTheme(Theme)
-
setTheme
public void setTheme(Theme theme)
Sets the UI customization scheme. An existing old theme is deactivated viaTheme.deactivate()
, the new one is activated viaTheme.activate()
.- Parameters:
theme
- theme- See Also:
getTheme()
-
getId
public String getId()
Description copied from interface:ApplicationComponent
Unique id for each instance of this object.- Specified by:
getId
in interfaceApplicationComponent<BeaTunes>
- Returns:
- id
-
init
public void init()
Description copied from interface:ApplicationComponent
Initializes this component and its sub-components.- Specified by:
init
in interfaceApplicationComponent<BeaTunes>
-
addShutdownHook
public void addShutdownHook(Callable<Boolean> shutdownHook)
Allows you to register some code that is to be executed before the actual shut down of the software.- Parameters:
shutdownHook
- callable that returns a boolean -true
, if the shut down should continue,false
, if the shut down should be aborted.
-
shutdown
public void shutdown()
Description copied from interface:ApplicationComponent
Shuts down this component and its sub-components.- Specified by:
shutdown
in interfaceApplicationComponent<BeaTunes>
-
getUserId
public static long getUserId()
Persistent and unique user id.- Returns:
- id
-
getVersion
public static String getVersion()
beaTunes version (seeTimestamp.V
).- Returns:
- version string
-
getMajorVersion
public static int getMajorVersion()
Major application version. For beaTunes 4.5.6, this method would return4
.- Returns:
- major version
-
getMinorVersion
public static int getMinorVersion()
Minor application version. For beaTunes 4.5.6, this method would return5
.- Returns:
- minor version
-
getMicroVersion
public static int getMicroVersion()
Minor application version. For beaTunes 4.5.6, this method would return6
.- Returns:
- micro version
-
getBuildDate
public static long getBuildDate()
Returns the build date in ms since 1970.- Returns:
- build date in ms since 1970
-
getRName
public static String getRName()
-
getREmail
public static String getREmail()
-
getRKey
public static String getRKey()
-
getPlayer
public PlayListPlayer getPlayer()
Current playlist player.- Returns:
- current player of this instance of beaTunes.
-
setPlayer
public void setPlayer(PlayListPlayer player)
Sets a new playlist player.- Parameters:
player
- player, must not benull
-
getLocale
public Locale getLocale()
The application locale. This means the language the UI is localized to, not the system default locale.- Returns:
- current application locale
-
setLocale
public void setLocale(Locale locale)
Sets the application locale.- Parameters:
locale
- locale
-
loadPreferences
public void loadPreferences()
Re-loads the application component's preferences.- See Also:
ConfigurableComponent
-
storePreferences
public void storePreferences()
Stores the application component's preferences asynchronously.- See Also:
ConfigurableComponent
-
getActionManager
public ActionManager getActionManager()
The centralActionManager
allows registration and retrieval of theBaseAction
s used throughout the application. Actions are different from regular plugins (seegetPluginManager()
) as they can be bound into the UI viaApplicationAction.getActionLocations()
. Despite this difference, actions are registered just like regular plugins, e.g. vie the/META-INF/plugin.xml
mechanism described inPluginManager
.- Returns:
- action manager
- See Also:
getPluginManager()
-
getPluginManager
public PluginManager<BeaTunes> getPluginManager()
Provides access to all dynamically loaded components. See
PluginManager
for details.As an example, to access the
LastFM
component/plugin, simply callgetPluginManager().getImplmentation(LastFM.class)
.- Returns:
- plugin manager
- See Also:
getActionManager()
-
getAnalysisQueue
public AnalysisQueue getAnalysisQueue()
TheAnalysisQueue
is the central component for queue based analysis of songs.- Returns:
- queue
-
getTunes
public ITunes getTunes()
Remote access to theITunes
applications.- Returns:
- iTunes application
-
getAmazon
public Amazon getAmazon()
Component that allows accessing Amazon. This is basically the same as calling:
getPluginManager().getImplementation(Amazon.class); - Returns:
- amazon
-
getiTunesMusicLibrary
@Deprecated public MediaLibrary getiTunesMusicLibrary()
Deprecated.Access to beaTunes' central internal database. Changes may be propagated transparently to iTunes or the file system. UsegetMediaLibrary()
instead.- Returns:
- library
-
getMediaLibrary
public MediaLibrary getMediaLibrary()
Access to beaTunes' central internal database. Changes may be propagated transparently to iTunes or the file system.- Returns:
- library
-
getMainWindow
public MainWindow getMainWindow()
Returns beaTunes' main application window, which provides access to other (visual) sub-components.- Returns:
- main window
-
getPreferencesDialog
public PreferencesDialog getPreferencesDialog()
The preferences dialog features different preference panes. To show the dialog, simply call itsPreferencesDialog.setVisible(boolean)
method.- Returns:
- preference dialog
-
addPropertyChangeListener
public void addPropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)
Add aPropertyChangeListener
.- Parameters:
propertyName
- property namepropertyChangeListener
- listener
-
removePropertyChangeListener
public void removePropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)
Remove aPropertyChangeListener
.- Parameters:
propertyName
- namepropertyChangeListener
- listener
-
main
public static void main(String[] args) throws IOException
Starts this application in the Swing UI thread. Potential arguments are interpreted as audio files that should be played.- Parameters:
args
- audio files that should be played- Throws:
IOException
-
z
public boolean z(String registrationName, String registrationEmail, String licenseKey) throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
-
x
public boolean x()
-
getRemainingTrialDays
public int getRemainingTrialDays()
-
getNewPlaylistParentId
public long getNewPlaylistParentId()
-
handleOutOfMemoryError
public static void handleOutOfMemoryError(OutOfMemoryError e)
React toOutOfMemoryError
, i.e. logging etc.- Parameters:
e
- OutOfMemoryError
-
handleOutOfMemoryError
public static void handleOutOfMemoryError()
React toOutOfMemoryError
, i.e. logging etc. Heap memory correction.
-
-