Mercurial > hg > indyvon
changeset 107:5fdb0bb99f75
Updated dependencies: Clojure 1.3.0, Guava 10.0. Use new CacheBuilder API.
author | Mikhail Kryshen <mikhail@kryshen.net> |
---|---|
date | Thu, 06 Oct 2011 16:49:14 +0300 |
parents | f42e2b9e1ad9 |
children | 520aa5fa9286 |
files | project.clj src/net/kryshen/indyvon/layers.clj |
diffstat | 2 files changed, 10 insertions(+), 13 deletions(-) [+] |
line diff
1.1 --- a/project.clj Wed Sep 21 02:27:11 2011 +0300 1.2 +++ b/project.clj Thu Oct 06 16:49:14 2011 +0300 1.3 @@ -1,8 +1,8 @@ 1.4 (defproject indyvon "1.0.0-SNAPSHOT" 1.5 :description "INteractive DYnamic VisualizatiON library" 1.6 ;;:warn-on-reflection true 1.7 - :dependencies [[org.clojure/clojure "1.3.0-RC0"] 1.8 - [com.google.guava/guava "r09"]] 1.9 + :dependencies [[org.clojure/clojure "1.3.0"] 1.10 + [com.google.guava/guava "10.0"]] 1.11 ;;:aot [net.kryshen.indyvon.core 1.12 ;; net.kryshen.indyvon.async 1.13 ;; net.kryshen.indyvon.layers
2.1 --- a/src/net/kryshen/indyvon/layers.clj Wed Sep 21 02:27:11 2011 +0300 2.2 +++ b/src/net/kryshen/indyvon/layers.clj Thu Oct 06 16:49:14 2011 +0300 2.3 @@ -28,8 +28,7 @@ 2.4 (java.awt.geom AffineTransform Point2D$Double) 2.5 (java.awt.font FontRenderContext TextLayout) 2.6 java.util.concurrent.TimeUnit 2.7 - com.google.common.collect.MapMaker 2.8 - com.google.common.base.Function)) 2.9 + (com.google.common.cache Cache CacheBuilder CacheLoader))) 2.10 2.11 ;; Define as macro to avoid unnecessary calculation of inner and outer 2.12 ;; sizes in the first case. 2.13 @@ -169,19 +168,17 @@ 2.14 (defn- re-split [^java.util.regex.Pattern re s] 2.15 (seq (.split re s))) 2.16 2.17 -(def ^{:private true} text-layout-cache 2.18 - (-> (MapMaker.) 2.19 +(def ^:private ^Cache text-layout-cache 2.20 + (-> (CacheBuilder/newBuilder) 2.21 (.softValues) 2.22 (.expireAfterAccess (long 1) TimeUnit/SECONDS) 2.23 - (.makeComputingMap 2.24 - (reify Function 2.25 - (apply [_ k] 2.26 - (TextLayout. ^String (k 0) 2.27 - ^Font (k 1) 2.28 - ^FontRenderContext (k 2))))))) 2.29 + (.build 2.30 + (proxy [CacheLoader] [] 2.31 + (load [[^String s ^Font f ^FontRenderContext frc]] 2.32 + (TextLayout. s f frc)))))) 2.33 2.34 (defn- get-text-layout [line font font-context] 2.35 - (get text-layout-cache [line font font-context])) 2.36 + (.get text-layout-cache [line font font-context])) 2.37 2.38 (defn- layout-text 2.39 [lines ^Font font ^FontRenderContext font-context]