jAlbum / SystemConsole

ToolsSystemConsole.png

This window is mainly a tool to assist developers but it can also be used by end users to run simple scripts, there are some example code snippets that can be used here.

For developers, system console provides more detailed error information and allows you to try out, and play with, scripts that you may later on use in your jAlbum skins. Note logging errors to the the system console can be controlled by setting the logging level in Preferences/General or by skin developers sending their own diagnostic messages directly to the console.
The menu bar will show a 'Tools' menu when the System console is open.

SystemConsoleToolsMenu.png

You can select Evaluate to run a script in the selected language, Dump threads to provide a thread file for help with tracking down any 'hangs' that may occur or Print profiling data to show what processes have been called and the time taken. an example of a profile output is shown below:

                                CustomScaler.scale:   158 calls     22.695s
                       Process compiled expression:    21 calls     13.512s
                                 predir processing:    18 calls     13.225s
                        Writing: AVIF Image Writer:   132 calls     11.684s
                            Scale to fit 1600x1200:    24 calls      7.029s
                              Scale to fit 824x824:    25 calls      5.819s
                              Scale to fit 800x600:    26 calls      5.053s
                  AlbumImage Scale to fit 1200x900:    10 calls      3.248s
                              Scale to fit 412x412:    27 calls      2.492s
                   AlbumImage Scale to fit 620x465:    13 calls      2.164s
                   AlbumImage Scale to fit 800x360:    13 calls      1.931s
                AlbumImage Scale to fit 100000x465:     9 calls      1.466s
                  AlbumImage Scale to fit 1600x720:     3 calls      1.158s
                AlbumImage Scale to fit 620x100000:     5 calls      1.147s
            Writing: GeoSolutions TurboJPEG Writer:   178 calls      0.617s
                                              init:     1 calls      0.588s
                  AlbumImage Scale to fit 1880x360:     3 calls      0.545s
                      Executing compiled scriptlet:   163 calls      0.397s
            Reading: GeoSolutions TurboJPEG Reader:    69 calls      0.299s
                                  Compiling script:     4 calls      0.292s
                Writing: Standard PNG image writer:     3 calls      0.213s
                                        Make views:     1 calls      0.198s
                     AlbumObjectImpl.getProperties:   313 calls      0.191s
                          AlbumBean.makeIndexPages:    18 calls      0.185s
                        AlbumObjectProperties.load:   315 calls      0.178s
                       AlbumBean.registerVariables:   134 calls       0.13s
                                       Clone image:   107 calls      0.076s
                                 AlbumBean.popVars:   320 calls      0.067s
                 Reading: jAlbum Mac Native Reader:    15 calls      0.058s
                              Compiling scriptlets:    61 calls      0.056s
                           JSONMaker.makeDataPages:    18 calls      0.043s
                                   Create MediaRSS:     5 calls      0.041s
                          AlbumBean.processFilters:   388 calls      0.031s
                   Executing interpreted scriptlet:   231 calls      0.029s
                     AlbumObjectImpl.getXmpManager:    75 calls      0.026s
                                AlbumBean.pushVars:   321 calls      0.025s
                       RecoveryTool.createLifeboat:     1 calls      0.024s
                   JAlbumUtilities.countCategories:   165 calls      0.021s
                       AlbumObjectImpl.getMetadata:    47 calls      0.021s
                JAlbumUtilities.getDeepCameraDates:    18 calls       0.02s
                     FileFilters.getBasicImageInfo:    47 calls      0.018s
                                     Writing pages:    44 calls      0.018s
                                    Copy res files:     1 calls      0.016s
                           Reading file attributes:    97 calls      0.015s
        JAlbumUtilities.countWebLocationCategories:    25 calls      0.015s
                             Making deep-data.json:     1 calls       0.01s
                                Process expression:     1 calls      0.006s
                                JSONMaker.makeTree:     1 calls      0.003s
                         AlbumBean.countTotalFiles:     1 calls      0.002s
                                      Icon loading:     2 calls      0.001s
                     AlbumBean.getFolderProperties:    57 calls      0.001s
                 RotationSupport.adjustOrientation:    84 calls          0s
                                             Total:  3819 calls  1m 37.099s
SystemConsoleEditMenu.png

The system console has its own 'Edit' menu comprising of two sections 'cut, copy, paste' and 'find, find next, replace'. Cut, copy and paste have the universal keyboard shortcuts of CMD/CNTRL + 'X, C and V' whilst find and replace have CMD/CNTRL + 'F, R' and find next uses the F3 key.

SystemConsoleEditMenuReplace.png

The replace tool is only available for the top section of the system console window. The replace window is as shown right, which gives you choices on what to find and what to replace with, find the next occurrence, replace all instances of the found text. You can match using case or whole words, search up or down code and use regular expressions in the find/replace fields.

Read about Java’s regular expressions


SystemConsole.png
  • The upper panel is best used for scripts to be entered and evaluated, the results appear in the lower panel. Click on the SystemConsole Evaluate.png button or press CTRL+E (⌘+E on Mac) to evaluate an expression. (Evaluates selected text if selection is active)
  • The lower panel can also execute code but results will only be printed to this panel. It also captures debug prints sent to System.out and System.err


SystemConsole Scripting.png

jAlbum has three scripting engines under the hood that enables developers to extend jAlbum's functionality in various ways. You can either script in a Java-like scripting languages called Groovy and BeanShell, or use JavaScript. Other languages can be added by adding the .jar file for the relevant language to jAlbum's "lib" or "ext" folder.

Scripts are executed when skins are loaded (onload scripts), when album making starts (init scripts) and during album making (scriptlets inside the template pages of skins). Scripts are also executed whenever the user selects an external tool (see Tools->External tools)

You have access to the basic jAlbum implicit objects such as engine and window

Sample expressions (Java/BeanShell):

4*(3+2); // Basic calculations 
engine.getSkin(); // Use of implicit object
for (AlbumObject ao : selectedObjects) System.out.println(ao); // Iterate over selected objects
window.messageBox("You can interact with any Java object");


Read more on extending jAlbum in our Developer centre.


SystemConsole Threads.png

The Thread selection option is an aid in testing out Java Swing and JavaFX based user interfaces. JavaFX requires that all interaction with JavaFX UI components happen on the JavaFX thread.

SystemConsole Dump.png

If jAlbum ever seems to hang in a CPU consuming state then open the system console and hit the "Dump threads" button. Then press CMD/Cntrl + C, to open jAlbum's 'config' folder and look for a file called 'thread-dump.txt'. Post a bug in the bugs forum and attach the thread-dump.txt file, along with any other relevant information - like jAlbum and OS versions, skin being used and what you last did.