changeset 89:54f6e6d196c3

Make the transform functions public.
author Mikhail Kryshen <mikhail@kryshen.net>
date Mon, 22 Nov 2010 16:02:27 +0300
parents 18abc7d66d49
children dd7b8dbb20bc
files src/net/kryshen/indyvon/core.clj
diffstat 1 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/net/kryshen/indyvon/core.clj	Wed Oct 06 18:45:51 2010 +0400
+++ b/src/net/kryshen/indyvon/core.clj	Mon Nov 22 16:02:27 2010 +0300
@@ -197,21 +197,26 @@
 ;; Rendering
 ;;
 
-(defn- relative-transform
-  "AffineTransform: layer context -> awt component."
+(defn relative-transform
+  "Returns AffineTransform: layer context -> AWT component."
   []
   (let [tr (.getTransform *graphics*)]
     (.preConcatenate tr *inverse-initial-transform*)
     tr))
 
-(defn- inverse-relative-transform
-  "AffineTransform: awt component -> layer context."
+(defn inverse-relative-transform
+  "Returns AffineTransform: AWT component -> layer context."
   []
   (let [tr (.getTransform *graphics*)]
     (.invert tr)                          ; absolute -> layer
     (.concatenate tr *initial-transform*) ; component -> absolute
     tr))
 
+(defn transform-point [^AffineTransform tr x y]
+  (let [p (Point2D$Double. x y)]
+    (.transform tr p p)
+    [(.x p) (.y p)]))
+
 ;; (defn- clip
 ;;   "Intersect clipping area with the specified shape or bounds.
 ;;    Returns new clip (Shape or nil if empty)."
@@ -471,14 +476,9 @@
 (defn- remove-all [coll1 coll2 pred]
   (filter #(not (some (partial pred %) coll2)) coll1))
 
-(defn- transform [^AffineTransform tr x y]
-  (let [p (Point2D$Double. x y)]
-    (.transform tr p p)
-    [(.x p) (.y p)]))
-
 (defn- translate-mouse-event [^java.awt.event.MouseEvent event
                               ^AffineTransform tr id]
-  (let [[x y] (transform tr (.getX event) (.getY event))]
+  (let [[x y] (transform-point tr (.getX event) (.getY event))]
     (MouseEvent. id (.getWhen event) x y
                  (.getXOnScreen event) (.getYOnScreen event)
                  (.getButton event))))