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 centralBeaTunesinstance will be injected during startup via the methodApplicationComponent.setApplication(com.tagtraum.core.app.ApplicationComponent). Correspondingly, an instance ofBeaTunesis available viaApplicationComponent.getApplication().To access the
AudioSong-library, usegetMediaLibrary().- Author:
- Hendrik Schreiber
-
-
Field Summary
Fields Modifier and Type Field Description static BeaTunesPropertiesBEATUNES_PROPERTIESEssential properties (special folders, user-agent, ...).static LocaleDEFAULT_LOCALEstatic VersionREQUIRED_ITUNES_VERSIONstatic LocaleSTRINGS_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 voidaddPropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)Add aPropertyChangeListener.voidaddShutdownHook(Callable<Boolean> shutdownHook)Allows you to register some code that is to be executed before the actual shut down of the software.ActionManagergetActionManager()The centralActionManagerallows registration and retrieval of theBaseActions used throughout the application.AmazongetAmazon()Component that allows accessing Amazon.AnalysisQueuegetAnalysisQueue()TheAnalysisQueueis the central component for queue based analysis of songs.BeaTunesgetApplication()Returns the main application component.static longgetBuildDate()Returns the build date in ms since 1970.IcongetDisabledIcon(String resourceName)UsesgetResource(String)to look up anImageIconand transform it to a light gray.GeneralPreferencesgetGeneralPreferences()Get the general preferences (instance ofConfigurableComponent).IcongetGrayIcon(String resourceName)UsesgetResource(String)to look up anImageIconand transform it to gray.IcongetIcon(PlayList playList)Provides aPlayListicon.IcongetIcon(String resourceName)UsesgetResource(String)to look up anImageIcon.static IcongetIcon(String resourceName, Theme theme)StringgetId()Unique id for each instance of this object.static ImagegetImage(String resourceName)Loads an image fromBeaTunes's package (or the resource folder in a Mac App Bundle).InspectionPreferencesgetInspectionPreferences()Get the inspection preferences (instance ofConfigurableComponent).MediaLibrarygetiTunesMusicLibrary()Deprecated.IcongetLightnessAdjustedIcon(PlayList playList)Provides aPlayListicon that has been adjusted to the theme's lightness.IcongetLightnessAdjustedIcon(String resourceName)UsesgetResource(String)to look up anImageIcon.IcongetLightnessAdjustedSmallIcon(PlayList playList)Provides aPlayListicon that has been adjusted to the theme's lightness.LocalegetLocale()The application locale.MainWindowgetMainWindow()Returns beaTunes' main application window, which provides access to other (visual) sub-components.static intgetMajorVersion()Major application version.MediaLibrarygetMediaLibrary()Access to beaTunes' central internal database.static intgetMicroVersion()Minor application version.static intgetMinorVersion()Minor application version.IcongetNegativeIcon(String resourceName)UsesgetResource(String)to look up anImageIconand transform it to an inverted (negative) version.longgetNewPlaylistParentId()PlaybackPreferencesgetPlaybackPreferences()Get the playback preferences (instance ofConfigurableComponent).PlayListPlayergetPlayer()Current playlist player.PluginManager<BeaTunes>getPluginManager()Provides access to all dynamically loaded components.PreferencesDialoggetPreferencesDialog()The preferences dialog features different preference panes.static StringgetREmail()intgetRemainingTrialDays()URLgetResource(String resourceName)Resolves a resource name to a URL.static StringgetRKey()static StringgetRName()IcongetSmallIcon(PlayList playList)Provides a smallPlayListicon.ThemegetTheme()Get the UI customization theme.ITunesgetTunes()Remote access to theITunesapplications.static longgetUserId()Persistent and unique user id.static StringgetVersion()beaTunes version (seeTimestamp.V).static voidhandleOutOfMemoryError()React toOutOfMemoryError, i.e.static voidhandleOutOfMemoryError(OutOfMemoryError e)React toOutOfMemoryError, i.e.voidinit()Initializes this component and its sub-components.static booleanisEarlyAccess()Are we in early-access mode?voidloadPreferences()Re-loads the application component's preferences.Stringlocalize(String key, Object... objects)UsesResourceBundle.getString(String)to look up localized strings.static StringlocalizeWithoutTheme(String key, Object... objects)UsesResourceBundle.getString(String)to look up localized strings.static voidmain(String[] args)Starts this application in the Swing UI thread.voidplay(AudioSongLocation location)Start playing the given file/resource.voidremovePropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)Remove aPropertyChangeListener.voidsetApplication(BeaTunes beaTunes)Sets the main application component.voidsetLocale(Locale locale)Sets the application locale.voidsetPlayer(PlayListPlayer player)Sets a new playlist player.voidsetTheme(Theme theme)Sets the UI customization scheme.voidshutdown()Shuts down this component and its sub-components.voidstorePreferences()Stores the application component's preferences asynchronously.booleanx()booleanz(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:
trueorfalse
-
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:ApplicationComponentReturns the main application component.- Specified by:
getApplicationin interfaceApplicationComponent<BeaTunes>- Returns:
- application object
-
setApplication
public void setApplication(BeaTunes beaTunes)
Description copied from interface:ApplicationComponentSets the main application component.- Specified by:
setApplicationin interfaceApplicationComponent<BeaTunes>- Parameters:
beaTunes- main application component
-
getResource
public URL getResource(String resourceName)
Resolves a resource name to a URL. If aThemeis set, the theme is asked first to resolve it. If that fails the resource is resolved relative to theBeaTunesclass.- 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 aPlayListicon.- Parameters:
playList- playlist- Returns:
- icon
-
getSmallIcon
public Icon getSmallIcon(PlayList playList)
Provides a smallPlayListicon.- Parameters:
playList- playlist- Returns:
- icon
-
getLightnessAdjustedIcon
public Icon getLightnessAdjustedIcon(PlayList playList)
Provides aPlayListicon 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 aPlayListicon 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 anImageIconand 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 anImageIconand transform it to a light gray.- Parameters:
resourceName- resource name- Returns:
- Icon or
nullif the resource can't be found
-
getNegativeIcon
public Icon getNegativeIcon(String resourceName)
UsesgetResource(String)to look up anImageIconand transform it to an inverted (negative) version.- Parameters:
resourceName- resource name- Returns:
- Icon or
nullif 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
nullif 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
nullif 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 theMessageFormatescaping 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 theMessageFormatescaping 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:ApplicationComponentUnique id for each instance of this object.- Specified by:
getIdin interfaceApplicationComponent<BeaTunes>- Returns:
- id
-
init
public void init()
Description copied from interface:ApplicationComponentInitializes this component and its sub-components.- Specified by:
initin 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:ApplicationComponentShuts down this component and its sub-components.- Specified by:
shutdownin 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 centralActionManagerallows registration and retrieval of theBaseActions 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.xmlmechanism described inPluginManager.- Returns:
- action manager
- See Also:
getPluginManager()
-
getPluginManager
public PluginManager<BeaTunes> getPluginManager()
Provides access to all dynamically loaded components. See
PluginManagerfor details.As an example, to access the
LastFMcomponent/plugin, simply callgetPluginManager().getImplmentation(LastFM.class).- Returns:
- plugin manager
- See Also:
getActionManager()
-
getAnalysisQueue
public AnalysisQueue getAnalysisQueue()
TheAnalysisQueueis the central component for queue based analysis of songs.- Returns:
- queue
-
getTunes
public ITunes getTunes()
Remote access to theITunesapplications.- 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.
-
-