Posted on September 29th, 2007 by headwedge
Bug: If you choose a large pixel space, say 500 x 500 pixels, then Pixel Viewer slows to a crawl as the paint method stupidly draws all 250000 flyweights! It’s odd, but when I wrote the prototype code I knew that the double nested loop was just a prototype to get it working and that [...]
Filed under: Java, code | No Comments »
Posted on September 23rd, 2007 by headwedge
This Pixel Viewer Applet [link] is intended to be a general purpose viewer for future cellular automata and mathematical programming excursions. I think it meets my specification [link].
The framework has been re-written to pass the parent in the child constructor as per ‘Do You Add The Child Or Pass The Parent?’. [link]
Filed under: Java, code, pixel | No Comments »
Posted on September 23rd, 2007 by headwedge
Uses the deep joy that is the Java 5 enum to create a stateful subclass of PixelGrid implementing MouseListener & MouseMotionListener to communicate zoom, centering & dragging to its specialised Stage.
Programming languages are like living languages, they grow and evolve. And for me at version 5 in 2004 is when Java truly entered adulthood with [...]
Filed under: Java, code, pixel | No Comments »
Posted on September 23rd, 2007 by headwedge
Unfortunately our consultancy service is working at 1/3 strength (i.e. me!) due to a poor combination of 1/3 being on holiday and the other 1/3 being suddenly indisposed due to a knee fracture, consequent upon running into their dog whilst playing silly buggers in the back garden! (Yes it is a BIG dog.) This means [...]
Filed under: Java, code, pixel | No Comments »
Posted on September 22nd, 2007 by headwedge
The CursorStash is a centralised resource sharing class for Cursors in much the same way that ImageStash is for BufferedImages.
Creating and initializing resources at the start of an application avoids duplication & unexpected slow downs when the resources are created on the fly during use. The user(s) will tolerate a degree of initial splash [...]
Filed under: Java, code, game | No Comments »
Posted on September 16th, 2007 by headwedge
At the moment the game & pixel frameworks follow, sensibly enough, the Java idiom of adding a child to a parent thus:
AConcreteParent.add(SomeChild);
Unfortunately, this has been frustrating in several ways:
Run Time Bugs: I produce annoying null pointer errors due to my mishandling of the construction order.
Multiple Parent Bugs: I can erroneously add a child to another [...]
Filed under: code, game framework | No Comments »
Posted on September 12th, 2007 by headwedge
I hate anti-ternarism and I would generally consider it pathognomonic for Time Wasting-Morons who have not been ratcheted up in its use.
The Ternary Operator offers a very concise and readable alternative to nested if-then-else constructs in assignment and imho should be preferred in the languages that implement its concise form.
it represents: a := if [...]
Filed under: Java, c++, code, rants | No Comments »
Posted on September 12th, 2007 by headwedge
I used to help out in the computer labs at Anon. University and by the time BSc comp. sci. students in the labs had gotten into SWING a very common question was: “How do I add scroll bars?”. My answer would be “You don’t, JScrollPane is your friend! Now go look in a book”. (Yeah [...]
Filed under: Java, code, game | No Comments »
Posted on September 10th, 2007 by headwedge
With the Dark-Overlord of capitalism that is work squeezing my Copious Free Time to a singularity I have little time at the moment for coding :(
So, with that get out clause covered here is a quick button bar to meet the spec. It uses the Swing goodness that is JToggleButton + ImageIcon added to [...]
Filed under: Java, code, pixel | No Comments »