Developers Howto
(Redirected from Developers howto)
How to get tracks for a given artist, album, year or genre ?
Use:
TrackManager.getAssociatedTracks()
How to get playable files for any item (logical or physical)?
- Use methods
Util.getPlayableFiles()
How to filter a list of items ?
- Use method
Filter.filterItems(<list>,<property name>,<value>)
How to get the number of items (track, files...) ?
- Use this method from ItemManager? public int getElementCount()
- Exemple : to get number of tracks in the collection, use:
TrackManager.getInstance().getElementCount()
How to add a new option ?
- Add the option name in org.jajuk.util.Const:
public static final String CONF_AUDIOSCROBBLER_ENABLE = "jajuk.network.audioscrobbler";
- don't forget to set a default value in org.jajuk.util.Conf :
properties.put(CONF_AUDIOSCROBBLER_ENABLE, FALSE);
- Use setProperty() method to set it in the program and getBoolean, getProperty(), getInt()... methods to retrieve it. Options are automatically saved to the conf.properties file at shutdown and loaded at startup.
How are managed window startup sizes and positions ?
- Default size is set using this algorithm:
begin width = screen width if width > 1400 width = 1200 //deal with dual heads else width = screen width - 120 height = screen height if height > 1200 height = 1000 //deal with dual heads else height = screen height - 120 end
- Then size is set at each startup using:
begin
if we find a forced position in conf.properties (jajuk.frame.forced_position entry)
use this position/size (used to allow XGL users to force a position)
else
if window manager buggy
Apply (60,60,screen width - 120, screen height - 120)
else
if stored position (jajuk.window_position) contains "max" (maximalize)
if window manager supports expand
expand (the window manager then deal with task bars)
else
Apply (60,60,screen width - 120, screen height - 120)
else
int x = configurated x
int y = configurated y
int width = configurated width
int height = configurated height
if x < 0 or x > screen width
x = 60
if y < 0 or y > screen height
y = 60
if width <= 0 or width > screen width
width = window width - 120
if height <= 0 or height > screen height
height = screen height - 120
Apply (x,y,width,height)
end
How to manage mouse events and right clicks ?
- Do not override directly MouseAdapter to manage mouse clicks but use JajukMouseAdapter class instead (see its detailed javadoc for reasons, handling right click on every OS is a bit complicated)
- Note that what makes all this so complexe is the fact that most items can throw at the same time popup on right click and realize an action when the left click is recognized.
How to use the font manager ?
- Please always use the FontManager class to deal with fonts for code mutualization and performance
- If you don't find a required font in JajukFont enum, please create a new one (set its properties in the registerFonts() method)
- Fonts are accessed using :
FontManager.getInstance().getFont(<a JajukFont>)
How to format dates ?
- Use UtilString.getLocaleDateFormatter() and UtilString.getAdditionDateFormatter() date formatters. The first method return the default date formatter for the current user and is intended for human display purpose. The second is used to store dates to be stored, it is the format used to store the date when tracks have been discovered (YYYYMMDD format)
How to get good random value ?
- Use only this method to get random value :
UtilSystem.getRandom()

