working find-by-class
This commit is contained in:
parent
465ef8c3d3
commit
0441e6cbec
1 changed files with 2 additions and 6 deletions
|
@ -144,7 +144,7 @@
|
||||||
|
|
||||||
;; ## Scene graph walker
|
;; ## Scene graph walker
|
||||||
(defn- has-method? [node method]
|
(defn- has-method? [node method]
|
||||||
(not (empty? (clojure.lang.Reflector/getMethods (class node) 0 method false))))
|
(and (not (nil? node)) (not (empty? (clojure.lang.Reflector/getMethods (class node) 0 method false)))))
|
||||||
|
|
||||||
(defn- graph-node-has-children? [node]
|
(defn- graph-node-has-children? [node]
|
||||||
;{:pre [(s/valid? ::node node)]
|
;{:pre [(s/valid? ::node node)]
|
||||||
|
@ -162,7 +162,6 @@
|
||||||
(defn- graph-node-get-children [node]
|
(defn- graph-node-get-children [node]
|
||||||
{:pre [(s/valid? ::node node)]
|
{:pre [(s/valid? ::node node)]
|
||||||
:post [coll?]}
|
:post [coll?]}
|
||||||
(debug "Getting children from" node)
|
|
||||||
(cond (has-method? node "getChildren") (.getChildren node)
|
(cond (has-method? node "getChildren") (.getChildren node)
|
||||||
(has-method? node "getGraphic") [(.getGraphic node)]
|
(has-method? node "getGraphic") [(.getGraphic node)]
|
||||||
(has-method? node "getMenus") (.getMenus node)
|
(has-method? node "getMenus") (.getMenus node)
|
||||||
|
@ -193,19 +192,16 @@
|
||||||
(defn- contains-class? [node clazz]
|
(defn- contains-class? [node clazz]
|
||||||
{:pre [(s/valid? ::node node) (string? clazz)]
|
{:pre [(s/valid? ::node node) (string? clazz)]
|
||||||
:post [boolean?]}
|
:post [boolean?]}
|
||||||
(debug "NODETEST:" node)
|
|
||||||
(s/valid? ::node node)
|
(s/valid? ::node node)
|
||||||
(if (instance? javafx.scene.Scene node)
|
(if (instance? javafx.scene.Scene node)
|
||||||
false
|
false
|
||||||
(> 0 (count (filter #(= % clazz) (.getStyleClass node))))))
|
(< 0 (count (filter #(= % clazz) (.getStyleClass node))))))
|
||||||
|
|
||||||
(defn find-child-by-class [node clazz]
|
(defn find-child-by-class [node clazz]
|
||||||
{:pre [(s/valid? ::node node)
|
{:pre [(s/valid? ::node node)
|
||||||
(string? clazz)]
|
(string? clazz)]
|
||||||
:post [#(or (s/valid? ::node node) nil?)]}
|
:post [#(or (s/valid? ::node node) nil?)]}
|
||||||
(debug "NODE:" node)
|
|
||||||
(let [zipper (scenegraph-zipper node)]
|
(let [zipper (scenegraph-zipper node)]
|
||||||
(debug "ZIPPER:" zipper)
|
|
||||||
(filter #(contains-class? % clazz) (flat-zipper zipper))))
|
(filter #(contains-class? % clazz) (flat-zipper zipper))))
|
||||||
|
|
||||||
;; ## Properties
|
;; ## Properties
|
||||||
|
|
Loading…
Reference in a new issue