|
Replies:
16
-
Pages:
2
[
1
2
| Next
]
-
Last Post:
3 Dec 23, 19:59
Last Post By: davidekholm
|
|
|
Posts:
3,583
Registered:
18-Oct-2002
|
|
|
New APIs in jAlbum 33.2
Posted:
1 Dec 23, 18:10
|
|
|
|
jAlbum 33.2 has a few new APIs tailored to help skin developers:
- Skin developers can now add an "earlyinit" file that will be called at an earlier stage of album builds than "init". This allows skins to filter-out file types and categories that aren't supported.
- New classes " CategoryFilter ", " RejectCounterFilter " to support rejecting/ignoring certain file types
- The Paginator class now supports including/excluding distinct file types as well as categories
Examples speak louder than words. See the attached "MinimalTest" and its "earlyinit.bsh" and "init.bsh" files. This modifiation to Minimal is set to ignore PDF files, PNG files and any audio files, just to demonstrate this mechanism. If any such files are found within the project, they are ignored, and a warning notification pops up during the album build.
Let's focus on the most important parts of "earlyinit.bsh" and "init.bsh" here:
earylinit.bsh:
import se.datadosen.jalbum.*;
/**
* Demo of how to exclude certain (supposedly not supported) file types from the gallery
* In this demo we're excluding PDF, PNG and audio files
* This also demos how to count the number of unsupported (rejected) files
* In init.bsh, jAlbum has already done the counting, and the result is presented to the user
* as a notification, in case files has been rejected.
*/
CategoryFilter categoryFilter = new CategoryFilter().exclude("pdf", "png").exclude(Category.audio);
rejectCounter = new RejectCounterFilter(categoryFilter);
/**
* Install filter chain inside the engine's album object factory
*/
factory.setFilter(rejectCounter);
init.bsh:
/**
* Before calling init.bsh here, jAlbum has counted the number of objects in the gallery
* Prior to calling init.bsh, jAlbum has called earlyinit.bsh, where a filter
* and counter for unsupported file types was set up (rejectCounter).
* That counter can now be checked here, and user warned
*/
if (rejectCounter.getTotalCount() > 0) {
System.out.println("Skipped types: " + rejectCounter);
engine.fireWarning("PDF, PNG and audio files are not supported and have been skipped");
}
The CategoryFilter works in the same manner as the Paginator. Just chain calls to specify what files to include/exclude. To "simply" ignore PDF files and assuming that you don't care about informing the user about that, just put the following within earlyinit.bsh (or .js or .groovy):
factory.setFilter(new CategoryFilter().exclude("pdf"));
Let's assume that your skin only supports images, videos and the "PDF" "other" type but no folder support. Here's how to set that up:
factory.setFilter(new CategoryFilter().include(Category.image, Category.video).include("pdf"));
Here's a skin that supports everything but folders:
factory.setFilter(new CategoryFilter().exclude(Category.folder));
... or even shorter:
factory.setFilter(new CategoryFilter().nodirs();
The following variables ONLY are available in earlyinit:
engine, albumEngine, ctx, window, window, context, factory, root
|
|
|
Posts:
8,394
Registered:
31-Jan-2006
|
|
|
Re: New APIs in jAlbum 33.2
Posted:
1 Dec 23, 19:25
in response to: davidekholm
|
|
|
Worked like a champ on my very first attempt, in Atom. That's a "slide page" skin, which is where this really comes in handy, because of the reliance on core-provided things like "next page."
The warning mechanism is nice, too - not too obtrusive, but lets the user know that some of his precious objects have been kicked to the curb. ![;)](https://jalbum.net/forum/images/emoticons/wink.gif)
|
|
|
Posts:
3,949
Registered:
4-Aug-2006
|
|
|
Re: New APIs in jAlbum 33.2
Posted:
1 Dec 23, 21:16
in response to: davidekholm
|
|
|
Works well, tried changing skins and back, all ok.
It might be with updating the alert to say the objects are not supported by the 'skin name'. Just so some users don't think jAlbum doesn't support them.
|
|
|
Posts:
8,394
Registered:
31-Jan-2006
|
|
|
Re: New APIs in jAlbum 33.2
Posted:
1 Dec 23, 21:36
in response to: RobM
|
|
|
|
It might be with updating the alert to say the objects are not supported by the 'skin name'. Just so some users don't think jAlbum doesn't support them.
Easy enough - screenshot.
Tempting to have a little fun with that. "You miserable pile of parrot droppings! You cloth-eared bint! Have you lost your mind?!!"
|
|
|
Posts:
8,394
Registered:
31-Jan-2006
|
|
|
Re: New APIs in jAlbum 33.2
Posted:
1 Dec 23, 21:37
in response to: davidekholm
|
|
|
Now that we have earlyinit.groovy, when do we get latefinally.groovy? For symmetry. ![;)](https://jalbum.net/forum/images/emoticons/wink.gif)
|
|
|
Posts:
8,394
Registered:
31-Jan-2006
|
|
|
Re: New APIs in jAlbum 33.2
Posted:
2 Dec 23, 01:02
in response to: JeffTucker
|
|
|
I haven't done any rigorous testing, but getting rid of the tree traversal that looked for unsupported AO's has noticeably reduced the "initializing" time during the album build.
Now, if I could just eliminate the routine that tags all GIF's as "use original," things would really snap, crackle, and pop. ![;)](https://jalbum.net/forum/images/emoticons/wink.gif)
|
|
|
Posts:
3,583
Registered:
18-Oct-2002
|
|
|
Re: New APIs in jAlbum 33.2
Posted:
2 Dec 23, 13:11
in response to: JeffTucker
|
|
|
Great that you like it ![:-)](https://jalbum.net/forum/images/emoticons/happy.gif) . I shall look into the GIF issue pretty soon now. You're basically saying that we can simply "use original" for GIF files. I think that's reasonable.
|
|
|
Posts:
8,394
Registered:
31-Jan-2006
|
|
|
Re: New APIs in jAlbum 33.2
Posted:
2 Dec 23, 13:36
in response to: davidekholm
|
|
|
Great that you like it ![:-)](https://jalbum.net/forum/images/emoticons/happy.gif) .
I always like being able to hit the DEL key on chunks of clumsy, inefficient code.
I shall look into the GIF issue pretty soon now. You're basically saying that we can simply "use original" for GIF files. I think that's reasonable.
The argument for it is pretty basic. The only reason users add GIF's is for their animation. If there's a non-animated GIF, converting it to PNG sometimes actually produces a larger file, so that's pointless. There's never a penalty for using the original.
Still need JPG thumbnails, however. Animated GIF's tend to be on the large side - not a problem for a single slide image, but for a page full of thumbnails, that could be a real slow loader. ![](https://jefftucker.jalbum.net/eek.gif)
|
|
|
Posts:
8,394
Registered:
31-Jan-2006
|
|
|
Re: New APIs in jAlbum 33.2
Posted:
2 Dec 23, 15:32
in response to: JeffTucker
|
|
|
BTW, an interesting side-note. The WebP format allows for animation. I converted some of my animated GIF's to WebP (using an online converter), and the file sizes drop by about 50%, with no visible loss of image quality.
No way for the core or a skin to take care of that however. We can't do the conversion (AFAIK), and if the user adds an animated WebP to a project, we can't detect that it's animated, and should not be scaled. The user would still have to manually mark it as "use original."
ETA: There are ways to figure out if a WebP image is animated, but talk about adding a lot of overhead to the app! Yikes.
|
|
|
Posts:
3,583
Registered:
18-Oct-2002
|
|
|
Re: New APIs in jAlbum 33.2
Posted:
2 Dec 23, 16:05
in response to: JeffTucker
|
|
|
Yes, I'll leave animated WebP images for now.
Now there's a service update: 33.2.1 which sets "Use original" for GIFs. Check it out by doing a core update. Let me know if I've broken anything
This service release also fixes an old bug with "Use original" and Variants. Variants should basically not be used for the closeups of images that have "Use originals" checked. This broke "Minimal" for instance.
(Tiger and Plain used different APIs and have never been affected by this bug.)
|
|
|
Posts:
8,394
Registered:
31-Jan-2006
|
|
|
Re: New APIs in jAlbum 33.2
Posted:
2 Dec 23, 16:35
in response to: davidekholm
|
|
|
Now there's a service update: 33.2.1 which sets "Use original" for GIFs. Check it out by doing a core update. Let me know if I've broken anything ![;-)](https://jalbum.net/forum/images/emoticons/wink.gif)
Like this cat, I think you've nailed it.
This service release also fixes an old bug with "Use original" and Variants. Variants should basically not be used for the closeups of images that have "Use originals" checked. This broke "Minimal" for instance.
(Tiger and Plain used different APIs and have never been affected by this bug.)
Guess which other skins have never been affected by this bug.
My only complaint about the new "exclusion" and "GIF" routines is that I'll have to specify the minimum jAlbum version for my skins as 33.2.1. Aesthetically unpleasing. Less objectionable would be 33.3. Even better, 34. ![:)](https://jalbum.net/forum/images/emoticons/happy.gif)
|
|
|
Posts:
3,949
Registered:
4-Aug-2006
|
|
|
Re: New APIs in jAlbum 33.2
Posted:
2 Dec 23, 20:59
in response to: davidekholm
|
|
|
One place where gifs are not used is webLocations, the image is converted.
|
|
|
Posts:
8,394
Registered:
31-Jan-2006
|
|
|
Re: New APIs in jAlbum 33.2
Posted:
2 Dec 23, 21:35
in response to: RobM
|
|
|
One place where gifs are not used is webLocations, the image is converted.
But that's just a representing thumbnail, right? Thumbnails need to be converted. This change is about only the slide images.
|
|
|
Posts:
3,949
Registered:
4-Aug-2006
|
|
|
Re: New APIs in jAlbum 33.2
Posted:
2 Dec 23, 23:42
in response to: JeffTucker
|
|
|
One place where gifs are not used is webLocations, the image is converted.
But that's just a representing thumbnail, right? Thumbnails need to be converted. This change is about only the slide images.
I believe some skins, not mine, have webLocation objects show a slide page, which then links to the location. The slide image is converted as well as the thumbnail.
|
|
|
Posts:
8,394
Registered:
31-Jan-2006
|
|
|
Re: New APIs in jAlbum 33.2
Posted:
3 Dec 23, 00:00
in response to: RobM
|
|
|
I believe some skins, not mine, have webLocation objects show a slide page, which then links to the location. The slide image is converted as well as the thumbnail.
None of mine, either. I don't think any of Laza's skins commit that sin.
I think it's probably safe to overlook this "gap" in the implementation. ![;)](https://jalbum.net/forum/images/emoticons/wink.gif)
|
|
|
|
Legend
|
|
Forum admins
|
|
Helpful Answer
|
|
Correct Answer
|
|