Gregg Williams <greg...@innerpaths.net> writes:

> Now I'm working on
> the "Graph Editor" program described at 
> http://www.piccolo2d.org/learn/grapheditor.html
> .
>
> In this sample program (which you don't really need to look at) I need
> to subclass a Piccolo2D class to create a class named GraphEditor ,
> but unlike the last time (see "Java interop question: proxy or gen-
> class?" in this group), I can't subclass using proxy because *this*
> subclass, GraphEditor, adds a new method. This means I have to use gen-
> class.

Actually looking at the sample code, GraphEditor doesn't appear to
override any methods of PCanvas, so why does it need to be a subclass at
all?  I'd just create a regular instance of PCanvas and work with that
instead:

(defn create-graph-editor [width height]
  (let [canvas (doto (PCanvas.)
                 (.setPreferredSize width height))
        node-layer (.getLayer canvas)
        edge-layer (PLayer.)
        random (Random.)]
    (-> canvas (.getRoot) (.addChild edgeLayer))
    (-> canvas (.getCamera) (.addLayer 0 edgeLayer))
    ;;
    ;; ... and so on.  I'd actually probably break the
    ;; constructor up into multiple functions, it's
    ;; rather large.
    ;;
    canvas))

-- 
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

Reply via email to