Today should have been an easy day; I have conquered the major problems and am now ready to launch into new efforts. But already I have encountered YAJFU (Yet Another Java). Consider this screenshot of a page:
Looks nice, doesn’t it? Now, if I jump directly to the next page, I get this:
For some reason, the new image does not completely replace the old image. This despite the fact that the new image is precisely the same size as the old one: 650h x 460v. What’s going on? I come up with a clever scheme:
By inserting the upper line into the drawing method, I reduce the imageLabel to a tiny image only 16 pixels across. That should shrink the imageLabel so that the real image, added in the second line, will then replace the old image and there should be no overlap. But no! This doesn’t work!
OK, let’s try something else: the new image for Total Energy Production has a transparent background. What if I fill it with a solid background of the same color as the main display? This is definitely bad practice, because if I decide to change that background color, I’ll have to revise all the images in my image set. But I give it a whirl just to see. Here’s the result:
Not only is the problem still there, but the new color doesn’t match the actual background! What makes this truly confounding is the fact that the color specification (RGB: 153, 204, 255) is exactly the same as the specification in the Java program. I hate Java!
More problems: the remanent image from the Nuclear Energy Production is 649 pixels wide, but the image for Total Energy Production is displayed at only 607 pixels of width, even though the source image is 650 pixels in width. Java has decided to scrunch the Total Energy Production image, but not the Nuclear Energy Production image. Why?
Now it gets REALLY weird: I was switching through lots of images, trying to find some common thread, when I came across this:
Look closely. This is the Nuclear Energy Production image. But it has been shrunk: you can see on its right edge the remnants of the Total Energy Production image, which is now LARGER than the Nuclear Energy Production image! And on the extreme left edge, you can see the underlying remnants of the earlier Nuclear Energy Production image, which was LARGER than the Total Energy Production image. What the hell is going on here? Nothing else in the image is changing in any manner that could affect with widths of these images. Java is just arbitrarily shrinking them to meet its entirely capricious notions of how the screen should be laid out. I hate Java!
You are NOT going to believe this. Here are two lines of code from the drawing method:
I switched their order, like so:
And voila, it works! Once again, Java succeeds in producing utterly mystifying behavior. Why on earth would the order of these lines make any difference? The Layout Manager is not supposed to do its work until it has a complete specification of the entire image contents. Otherwise, how would it know which components to scrunch and which ones to stretch? Apparently the designers of Java decided to have the Layout Manager operate incrementally, making revisions each time something is added to the layout. That’s really stupid, because it means that the order of execution is crucial to the final result. There’s no obvious procedure that the programmer can follow to insure any desired result. It’s just a matter of experimenting with permutations of lines of code and hoping you’ll stumble upon one that works. What a shambles!
The next problem to tackle is the calculation of Economic Growth. This factor turns out to affect a great many other factors, so I decided that it was time to take this particular bull by the horns. What fuels economic growth? I mentioned this problem three days ago but had no answers then. The basic inputs should be population, supply of capital, supply of raw materials, and increases in productivity. Of these, only population exists in my factor set, and even that cannot be used directly, because the greatest population growth is in the areas least able to utilize the extra labor efficiently. The supply of raw materials covers a gigantic range of materials. I currently include only mining and energy sources as inputs; there are lots of others. Should I expand this list? I think it’s safe to sweep these inputs under the rug if they play no significant role in environmental considerations. And I can’t think of any major factors other than mining that have significant environmental and economic impact. So I’ll leave raw materials as it is.
What about the supply of capital? This is a crucial consideration, but again, it has little direct environmental impact. I think that I should therefore treat it as a constant factor that gets lumped into one of the coefficients.
Which leaves the last factor: productivity. It’s easy to assign this to technological advance, which in turn is affected by the Research Subsidy, but there are many other factors in productivity growth, education being a major one. New business methods (for example, eBay and Amazon.com) can be more important than technology. Again, however, this can all be lumped into the Research Subsidy. Perhaps I should change the name of that factor to something like “Intellectual Expansion of Humanity”, but that’s way too long. Perhaps “Intellectual Progress Subsidy” works. Yes, I like that.
OK, so Economic Growth is derived from Mining Production, Population, and Intellectual Progress. Perhaps I should make it Economic Growth per capita so that I don’t have to factor in Population. This, however, runs afoul of the use of Economic Growth in various supply and demand calculations. No, stick with Economic Growth as is and and a new factor for Economic Growth Per Capita.
I think that I should throw in Industrial Output to reflect, at least partially, the role of capitalization and the negative effects that regulation and taxes have on economic growth. Thus, the final formula for Economic Growth should look something like this:
Economic Growth = Mining Production * Industrial Production * Population Growth * Intellectual Progress
This doesn’t look right. I can subsume Mining Production into Industrial Production to simplify. But I think I need to look at differentials rather than absolute numbers:
Economic Growth = Industrial Production Growth * Population Growth * Intellectual Progress Growth
Nah, too clumsy. Let’s go one step back and consider Global GDP directly. It’s tempting, though, to equate Global GDP with Industrial Production. That is troublesome: there’s more to GDP than factories churning out widgets. Is the Internet the result of Industrial Production? We need more factors. Perhaps services? Perhaps a multiplier representing Intellectual Progress:
Global GDP = Industrial Production * Intellectual Progress
Hmm... maybe so. I’ll write it up this way for now.
More time wasted! I wrote up the new Economic Growth page and put in the equations and some explanatory text. Then I attempted to run the program. Kablooey! The program crashed hard in the section reading the XML document. So I closely examined the XML document -- no flaws were apparent. I used my backups to revert to an older version that I know worked just fine (while preserving the latest version). That didn’t fix the problem. I tried a bunch of other things. Eventually I decided that my copy of Eclipse (the huge development environment) had been corrupted, so I downloaded a later version (all 276 MB) and installed it. Still the problem remained. So I went back to the backups and tried an older XML file. It worked. Next, I transferred, line by line, XML code from the new document to the old document, running the program each time to see if it ran properly. By this means I was able to identify the problem: one line in the document referred to “R&D”. It turns out that the ampersand crashes Java. How very charming! Now the text reads “research and development” and Java is happy again.