This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 7 - Pages: 1 - Last Post: 4 Oct 21, 10:21 Last Post By: RobM Threads: [ Previous | Next ]
AndreWolff

Posts: 2,186
Registered: 14-Dec-2007
How to calculate the largest used thumbnail width / height?
Posted: 3 Oct 21, 18:33
 
  Click to reply to this thread Reply
To calculated the largest used thumbnail width and height I tried this code in file common.css
<% maxThumbH=0;  maxThumbW=0; %>
<ja:fileiterator start="0" ><ja:if exists="folder"> </ja:if>
<ja:else>
<%  
if (compressPanoThumbs && (imageWidth / imageHeight > 2.2F) )  {
 if (2*maxThumbHeight>maxThumbW) maxThumbW=2*maxThumbHeight;
}
else if (thumbWidth>maxThumbW) maxThumbW=thumbWidth;
if (thumbHeight>maxThumbH) maxThumbH=thumbHeight;
%>
</ja:else></ja:fileiterator>
But this gives an error:
An unexpected error occurred. Please see detailed description below:
 
java.lang.NullPointerException
	at java.base/java.util.Arrays.stream(Unknown Source)
	at se.datadosen.jalbum.ast.IteratorNode.doEval(IteratorNode.java:52)
	at se.datadosen.jalbum.ast.ASTNode.eval(ASTNode.java:50)
	at se.datadosen.jalbum.ast.GroupNode.doEval(GroupNode.java:78)
	at se.datadosen.jalbum.ast.ASTNode.eval(ASTNode.java:50)
	at se.datadosen.jalbum.AST.eval(AST.java:68)
	at se.datadosen.jalbum.AlbumBean.processTemplateFile(AlbumBean.java:1450)
	at se.datadosen.jalbum.AlbumBean.makeAlbumForFolder(AlbumBean.java:1685)
	at se.datadosen.jalbum.AlbumBean.makeAlbum(AlbumBean.java:3047)
	at se.datadosen.jalbum.AlbumBean.smartMakeAlbum(AlbumBean.java:2943)
	at se.datadosen.jalbum.JAlbumFrame$6.run(JAlbumFrame.java:1138)
What is the correct pure JAVA code to claculate this?
Can use that in common.css or should it be added to init.bsh?

Edit:
I calculate these values and already in a module slidePagePar.htt, but apparently that module is processes after common.css is ready, because the variables maxThumbW and maxThumbH are undefinesd in common.css as I remove the code given above.

Is it possible to process slidePagePar.htt before common.css?

Edited by: AndreWolff on 3 Oct 2021, 19:03
RobM

Posts: 3,821
Registered: 4-Aug-2006
Re: How to calculate the largest used thumbnail width / height?
Posted: 3 Oct 21, 19:41   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
If you have a working code, just move it to init.bsh, and use a for loop instead of the file Iterator.
AndreWolff

Posts: 2,186
Registered: 14-Dec-2007
Re: How to calculate the largest used thumbnail width / height?
Posted: 3 Oct 21, 20:01   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
RobM wrote:
If you have a working code, just move it to init.bsh, and use a for loop instead of the file Iterator.
Sorry Rob, I am a very dumm Java programmer, so I have no idea how that for loop is coded, so please translate the code above to Java code which I can insert in init.bsh.
RobM

Posts: 3,821
Registered: 4-Aug-2006
Re: How to calculate the largest used thumbnail width / height?
Posted: 3 Oct 21, 20:20   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
AndreWolff

Posts: 2,186
Registered: 14-Dec-2007
Re: How to calculate the largest used thumbnail width / height?
Posted: 3 Oct 21, 20:31   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
That is still too complicated for me, I don’t understand that.

I think it is a good idea to give the correct code and add it there!
In such an example, you can omit the line with compressPanoThumbs, because that is too special.
RobM

Posts: 3,821
Registered: 4-Aug-2006
Re: How to calculate the largest used thumbnail width / height?
Posted: 3 Oct 21, 21:20   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
AndreWolff wrote:
That is still too complicated for me, I don’t understand that.

I think it is a good idea to give the correct code and add it there!
In such an example, you can omit the line with compressPanoThumbs, because that is too special.

You have to be joking, all you need is a basic for loop instead of the Iterator.
for (AlbumObject ao : rootFolder().getChildren()) {
 
}
You really need to learn some basic coding, I’m not a software engineer and I never worked in software development, as you did. Read the manuals, search the web, look in the forums, wiki and other skins for code examples. That’s what I do.
AndreWolff

Posts: 2,186
Registered: 14-Dec-2007
Re: How to calculate the largest used thumbnail width / height?
Posted: 3 Oct 21, 23:49   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
RobM wrote:
You have to be joking, all you need is a basic for loop instead of the Iterator.
for (AlbumObject ao : rootFolder().getChildren()) {
 
}
You really need to learn some basic coding, I’m not a software engineer and I never worked in software development, as you did. Read the manuals, search the web, look in the forums, wiki and other skins for code examples. That’s what I do.
The problem is not the loop but to find out how to get the thumbHeight, imageHeight and imageWidth values from ao!
RobM

Posts: 3,821
Registered: 4-Aug-2006
Re: How to calculate the largest used thumbnail width / height?
Posted: 4 Oct 21, 10:21   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
Look up AlbumObject in the API, or look in other skins or some of the external tools for details.

And before you ask, the first code I suggested does not require recursion but the latter does.
Legend
Forum admins
Helpful Answer
Correct Answer

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