Since my last post, I've implemented and successfully run everything in this sample program except the ToggleShape class, and I absolutely cannot figure out how to use proxy correctly. Here's the Java code that I'm trying to re-create in Clojure:
class ToggleShape extends PPath { private static final long serialVersionUID = 1L; private boolean fIsPressed = false; public ToggleShape() { ; location (1) <<<<<<<<<<<<<<<<<<<<< setPathToEllipse(0, 0, 100, 80); addInputEventListener(new PBasicInputEventHandler() { public void mousePressed(final PInputEvent event) { super.mousePressed(event); fIsPressed = true; repaint(); } public void mouseReleased(final PInputEvent event) { super.mouseReleased(event); fIsPressed = false; repaint(); } }); } protected void paint(final PPaintContext paintContext) { if (fIsPressed) { final Graphics2D g2 = paintContext.getGraphics(); g2.setPaint(getPaint()); g2.fill(getBoundsReference()); } else { super.paint(paintContext); } } } Note that this subclass, ToggleShape, redefines its constructor (see the line marked "location (1)", above). The question is, what name do I put to the function that executes the Clojure equivalent of "setPathToEllipse(0, 0, 100, 80)"? Since proxy creates an anonymous subclass, the only function named that I could think to use is that of its superclass, PPath--but I can't get it to work (and the code below is just one of several variations I've tried). To eliminate other possible sources of error, I've taken out the event listeners in the Clojure code below, and all I'm trying to do is have the program display the %...@#! ellipse (I can get it to display a square just fine). I've also put a println statement in the code that creates an instance of ToggleShape (which does execute), and another println statement in the code that implements ToggleShape (which DOES NOT execute). I've searched the web for articles and source code that might give me some idea of how to proceed, and I've also consulted Java reference books, but I haven't found anything that explains what I need to do. Anyway, here's one version of the corresponding Clojure code: (defn create-toggle-shape "Creates an ellipse that changes shape when it is clicked." [] (let [fIsPressed? (ref false) serialVersionUID (long 1)] (proxy [PPath] [] ; ToggleShape is an extension of PPath ; I'm trying to create the constructor for ToggleShape--proxy ; requires that what follows is a sequence of superclass method- names- ; arguments-and-bodies. What do I call it here? Since the superclass is ; PPath, the name of its constructor is PPath, so that's what I'm ; trying here--but it doesn't seem to work: the println is ; never executed. (PPath [] ; ; super's constructor should execute automatically (println "Reached ToggleShape") (.setPathToEllipse 0 0 100 80) ;add input listeners here ) (paint [paintContext] (if (fIsPressed?) (let [g2 (.getGraphics paintContext)] (do (.. g2 setPaint getPaint) (.fill g2 (.getBoundsReference this)))) (proxy-super paint paintContext)))))) I can post the entire program if anyone wants to see it. As always, thanks for taking the time to help. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en To unsubscribe, reply using "remove me" as the subject.