Permlink Replies: 5 - Pages: 1 - Last Post: 19-Jun-2010 00:26 Last Post By: monkeyboy
monkeyboy

Posts: 89
Registered: 21-Jun-2008
SkinModel.java creation utility
Posted: 17-Jun-2010 20:01
  Click to reply to this thread Reply
Now that Jalbum 8.9 supports skin models, I've created the attached utility for skin developers to create a SkinModel.java file from a headless-settings.jap file (Tools -> Skin developer -> Prepare for online and console use).

The skin model is a method of data-typing (and initializing) skin variables without Jalbum guessing the data type from an entry in a *.jap file.
I realize that my utility also has to guess the data types from the *.jap file but it was created to simply take away some of the tediousness of manually creating a SkinModel.java file (either by editing a headless-settings.jap file or from scratch). (My skin has over 1,000 skin variables and I needed some kind of automation to get me started.)

Load the 'Create Jalbum Skin Model File' as a skin, feed it a headless-settings.jap file and click 'Create'. A SkinModel.java file will be created alongside the headless-settings.jap file.
It rifles through the selected headless-settings.jap file and looks for keys starting with "skin.". If the property value is 'true' or 'false' it'll define the variable as a boolean. If it looks like a number then it'll be defined as an int (unless there is a single decimal point in which case it'll be defined as a double). Anything else (including empty entries) will be defined as a String.
You'll probably need to check the resulting SkinModel.java file to make sure all data types are actually as you intend them to be. eg.
skin.var1=9
skin.var2=false
This utility cannot know whether you wish var1 and var2 to be treated as Strings or an int and boolean respectively.

The SkinModel.java file can then be put directly into the relevant skin's 'plugins' folder (or can be compiled into SkinModel.class first).
Skin developers who do not have the JDK installed might like to use this remote compiling service to compile their SkinModel.java file into SkinModel.class. (No need to upload any library files, don't bother selecting any checkboxes and select 1.5.0 as the JDK version.)

There should then be no need for a headless-settings.jap file in the skin and any skin variables set via hints.jap files can be removed. (Entries for Jalbum variables set in hints.jap files should be kept.)

Most skins are unlikely to have anywhere near the number of skin variables that I had to content with but for anyone who does, I hope this is somewhat helpful.
davidekholm

Posts: 3,401
Registered: 18-Oct-2002
Re: SkinModel.java creation utility
Posted: 18-Jun-2010 09:45   in response to: monkeyboy in response to: monkeyboy
  Click to reply to this thread Reply
That's a great addition. Thank you! Would you however consider implementing this as an external tool so it can be accessed easily no matter what skin is selected.
monkeyboy

Posts: 89
Registered: 21-Jun-2008
Re: SkinModel.java creation utility
Posted: 18-Jun-2010 12:07   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
Good idea! I'll see what I can come up with.
monkeyboy

Posts: 89
Registered: 21-Jun-2008
Re: SkinModel.java creation utility
Posted: 18-Jun-2010 18:43   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
Here it is as an external tool. Put the attached file in the Jalbum/tools folder and it can be accessed via Tools -> External Tools -> Create skin model file.

It now works from engine.getSkinVariables() instead of headless-settings.jap.
It creates a SkinModel.java file in the current skin's 'plugins' folder (creating the folder if necessary).

The tool should handle strings that contain \, tab, form feed, newline, and carriage return characters and characters less than 0x0020 or greater than 0x007E are escaped to their unicode equivalents (eg the string 'Copyright © 2010' will become 'Copyright \u00a9 2010').

Edited by: monkeyboy on 18-Jun-2010 23:19
Updated attached file.
It now lists the skin variables in alphabetical order.
davidekholm

Posts: 3,401
Registered: 18-Oct-2002
Re: SkinModel.java creation utility
Posted: 19-Jun-2010 00:18   in response to: monkeyboy in response to: monkeyboy
  Click to reply to this thread Reply
Well, that's progress! Thanks!
monkeyboy

Posts: 89
Registered: 21-Jun-2008
Re: SkinModel.java creation utility
Posted: 19-Jun-2010 00:26   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
I just updated the file attached to my previous post as you posted your last comment.
The tool now lists the skin variables in alphabetical order. It might be easier for any skin developer having to scan the resulting file to check that all data types are as intended.
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums