This is what Processing’s reference says about Java’s keyword static:
When a field is declared w/ that keyword, it means Java creates it once only, no matter how many times we instantiate its class.
Thus it is said such a field is shareable, b/c its value is the same across all instances of its class.
But the coolest thing about static is that any member of a class declared w/ that can be accessed directly w/o needing to create an instance of its class 1st!
However, considering a Processing sketch is never instantiated more than once (unless we hackishly force our hand to do it), declaring its fields and methods w/ static is moot; and we can safely remove such declaration if we prefer so.
I only do it as a way to document that such PApplet members (apart from nested classes) are stateless rather than any practical effect on the code.
This is what Processing’s reference says about Java’s keyword final:
When used on fields, local variables & parameters, it permanently seals the 1st value assigned to them.
But in this particular sketch of yours, final is also crucial to shorten the memory used by method calculateT1().
If we remove the 2nd keyword final declaration from where the pow()float fields are, the sketch still compiles & runs fine.
However, if we dare removing the 1st final declaration from the original float fields, we’ve got the compilation error back:
The code of method calculateT1(float, float) is exceeding the 65535 bytes limit.
Seems like the 2nd batch of float fields isn’t used as much as the 1st 1 to the point of exceeding the limit.
BtW, I always try to stick the keyword final everywhere as long as I can get away w/ it.
Actually, when I had already replaced about 4 or 5 pow() batch calls w/ final constants, the sketch was already able to compile & run!
I’ve continued to replace all pow() calls w/ final float constants just for completeness’ sake.
In short, both declaring the original float fields w/ final and replacing some of the batches of pow() calls w/ pre-calculated fields were the bare requirements in order to compile & run calculateT1().
But still, what kinda trick the final keyword does to the float fields which was crucial to shorten method calculateT1() barely enough?
Thanks, but how can I use multiple .pde files in that mode (ProcessingJs.org/tools/processing-helper.html)? Also, I tried installing JavaScript mode, but unfortunately not succeeded in doing so.
@GoToLoop , thank you for your patience with me If I open the .html file in Google Chrome I just see a white screen. Even if I download your files of Grumbo, it doesn’t work. Sorry, I’m new to all of this.
Edit: I tested with these files and I don’t see the cancas, only the header and paragraph:
index.html
<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
<script defer src=https://raw.githubusercontent.com/processing-js/processing-js/v1.4.8/processing.js></script>
<canvas data-processing-sources=
"test.pde">
</canvas>
If these are variables maybe the best work around is to use a statistical method like GAM or an ordination method like a CCA and reduce your data to only the important variables.