I have gone ahead and made those changes (comments below) but still the problem remains. I'll try explaining it differently.
Let's say that the user wants the font size to be 16. It defaults at 14. They input 16. Now when they click 'Make album' in init.bsh if you print out that variable it is the default 14. So the change the user made has no effect whatever in the album. Similarly if the user ticks (or unticks) one of the checkboxes whatever the default is what is used in the album generation. Also if they change the colours the default colours are used instead.
The UI shows the changes made but it has no effect in the generated album.
As for colours in general the trouble is twofold:
- Changing the colours (using the colour selector) has no effect for the generated album (as above).
- In the past when choosing a different theme - say from the default black to green - the colours would be updated in the UI. Now however it's not displayed and instead it only is used in the generated album. So whereas if you were to pick the green theme in the UI the background colour would be a shade of green. Now however they all show black (in the UI!). But until I made the change that the CSS file has (it used to be empty and the .jap file was the one that was key) it used the default in the generated album (in fact white background). The colours were here also not updated in the UI (when selecting a different theme).
In other words it should be updated in the UI when the theme is changed but it does not. It used to work with the style.jap files.
Basically no matter what the user changes the generated album doesn't use anything but the defaults. Even when I just recompiled the skin and kept everything the same from the past the skin suddenly stopped working in that way. I have changed some things and same problem - it isn't updated (though in the UI it appears to be updated).
I don't really have the energy to wade into someone else's messy code, but a few quick observations....
Then I appreciate it more. It's messy because it's old and who knows what was going on then? Also I was less familiar with Java at the time. But now it's even more so because it's been so long. I have cleaned it up some but it still could use work.
First, I don't understand why you're intent upon "modularizing" any of this. It's a small skin with a small UI. All you need is Reflections.java and SkinModel.java.
Simple: it's easier to organise. But actually the UI is a slight bit more complicated than it seems. It's actually the attached file; it's just I felt to make it easier to read through it'd be not necessary to have the extra variables (since it does take time and energy etc. - and again I appreciate the time and energy).
The problem is the same for all variables: whatever is changed by the user when generating albums it goes back to the default (as if it was never changed).
Then, the first sign of trouble. In Album.java, you have this:
JTextField fontsize = new JTextField("14", 3);
But in SkinModel.java, we see this:
public int fontsize=14;
Does this set off any alarm bells? It certainly should.
Right. Actually I've fixed that already. At least I thought I had. Let's see. Yes I did on Thursday; I don't know why that isn't here. Anyway that part is fixed.
The quick fix is not to use a JTextField to allow the user to enter an integer. Use a JSpinner. That way, you don't have to do any validation to make sure the user hasn't entered 425983 as the font size, or worse, mydog as the font size. It will always be an int.
At the time I did not know about it is my belief. I probably also believed that having the maximum field length be part of it. Of course that wouldn't help with a very high number or as you say the strings. Thanks for the tip.
(I still haven't completely cured both David and Laza of making this mistake, and their stuff still includes text fields being used to accept integer inputs. It's always a bad idea.)
Yes well I find that even better since you said you didn't really understand the OO model (I think I saw that somewhere in the forum). Mind you I'm not big on OO but that's the way Java is anyway. I can see the appeal but I much prefer procedure programming / top-bottom / etc.
In C I would be doing this all and more and differently but I'm not as familiar with Java as I am C.
So, in
Reflections.java:
JSpinner fontsize = new JSpinner(new SpinnerNumberModel(14, 10, 48, 1));
I've gone ahead and made the change but as I said the change is still not registered for the generated album. Also I don't know if this is a problem on my end or more generally but I could type text in the field too.
Color fields are a little weird, however. For the UI, you want to be able to pull up the standard color selectors, so in
Reflections.java, you would have:
JColorSelector backgroundColour = new JColorSelector("Background", new JTextField(7));
But in the templates, it's easiest to deal with colors as simple strings, so in SkinModel.java:
public String backgroundColour;
or
public String backgroundColour = "#eeeeee";
If you don't specify a default, you could, for example, use an event listener to detect the selected style and use that to populate the field.
That's how I had it but it seems to not make any difference. However I think we're thinking of a different problem.
There are at least half a dozen different ways of passing style-specific things like colors to the album's CSS. For starters, stick to what you see in Minimal. A common.css template is automatically processed by the jAlbum core, with the result landing in res/common.css, so that's the place to put anything that isn't style-dependent. You can then use files like dark.css to add the style-specific stuff. No need for Java-style declarations there - again, just look at what Minimal is doing.
I think there's still some confusion in what I'm getting at; for the generated album after doing what I did in the css file it does use those colours. But when changing the theme it doesn't show up in the UI; and when the user changes the colours the default is still used just like all other variables. For the variables you can see in the UI the changes made but they aren't updated for the album itself.
And while you're perfectly free to keep banging your head against the wall when it comes to American English spelling, you're just setting yourself up for CSS problems, since this is going to fail:
body: {
colour: ${colour};
}
Yeah I know that
I just use both is all. Where I have to use the American spelling I do but where I don't I use the British way. Yes it's probably slightly more confusing but then it'd be more confusing to just use the American spelling full stop in my typing etc. Anyway thanks for the reminder (maybe I didn't know after all).