gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz/gzz media/impl/SimpleImageScroll.java gfx/g...


From: Tuukka Hastrup
Subject: [Gzz-commits] gzz/gzz media/impl/SimpleImageScroll.java gfx/g...
Date: Mon, 04 Nov 2002 13:41:00 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuukka Hastrup <address@hidden> 02/11/04 13:40:59

Modified files:
        gzz/media/impl : SimpleImageScroll.java 
        gzz/gfx/gl     : GLSpans.java 

Log message:
        Added support for ImageSpans to GLSpans

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/media/impl/SimpleImageScroll.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/GLSpans.java.diff?tr1=1.7&tr2=1.8&r1=text&r2=text

Patches:
Index: gzz/gzz/gfx/gl/GLSpans.java
diff -u gzz/gzz/gfx/gl/GLSpans.java:1.7 gzz/gzz/gfx/gl/GLSpans.java:1.8
--- gzz/gzz/gfx/gl/GLSpans.java:1.7     Tue Sep 24 03:26:48 2002
+++ gzz/gzz/gfx/gl/GLSpans.java Mon Nov  4 13:40:59 2002
@@ -62,6 +62,7 @@
     /** Span to rect, by LOD.
      */
     static HashMap[] pages = new HashMap[] { new HashMap(), new HashMap() } ;
+    static HashMap[] images = new HashMap[] { new HashMap(), new HashMap() } ;
 
     static class LoadedTexRect {
        LoadedTexRect(String file) {
@@ -145,13 +146,53 @@
     }
 
 
+    /** Return a Rect containing the image span
+     */
+    static public Rect getRect(ImageSpan span) {
+       return getRect(span, 0);
+    }
+    /** Return a Rect containing the image span
+     * @param lod The level of detail. Currently, only 0 is known
+     */
+    static public Rect getRect(ImageSpan span, int lod) {
+       if(lod < 0) lod = 0;
+       if(lod > 0) lod = 0;
+       Rect r = (Rect)images[lod].get(span);
+       if(r == null) {
+           // ScrollBlockManager.PageSpanBase span = 
+           //  (ScrollBlockManager.PageSpanBase)span0;
+           SimpleImageScroll sb = (SimpleImageScroll)span.getScrollBlock();
+           Point p = span.getLocation();
+           Dimension d = span.getSize();
+           String file = sb.imageFilename();
+           /*      float resmult = sb.imageFileResolution(page)  /
+                   sb.coordinateResolution() ;*/
+           float resmult = 1;
+
+           LoadedTexRect rect = getImage(file);
+           r = new Rect();
+           Rect ltr = (lod == 0 ? rect.rect : rect.rectLR);
+           r.texId = ltr.texId;
+           r.x0 = (float)ltr.getTexCoord(0, resmult * p.x / rect.w);
+           r.x1 = (float)ltr.getTexCoord(0, resmult * (p.x+d.width) / rect.w);
+           r.y0 = (float)ltr.getTexCoord(1, resmult * p.y / rect.h);
+           r.y1 = (float)ltr.getTexCoord(1, resmult * (p.y+d.height) / rect.h);
+           r.w = d.width;
+           r.h = d.height;
+
+           images[lod].put(span, r);
+       }
+       return r;
+    }
+
+
     // Temporary imagecache-like thing XXX
-    static HashMap images = new HashMap();
+    static HashMap imagefiles = new HashMap();
     static public LoadedTexRect getImage(String file) {
-       LoadedTexRect res = (LoadedTexRect) images.get(file);
+       LoadedTexRect res = (LoadedTexRect) imagefiles.get(file);
        if(res == null) {
            res = new LoadedTexRect(file);
-           images.put(file, res);
+           imagefiles.put(file, res);
        }
        return res;
     }
Index: gzz/gzz/media/impl/SimpleImageScroll.java
diff -u gzz/gzz/media/impl/SimpleImageScroll.java:1.4 
gzz/gzz/media/impl/SimpleImageScroll.java:1.5
--- gzz/gzz/media/impl/SimpleImageScroll.java:1.4       Tue Aug 13 19:01:27 2002
+++ gzz/gzz/media/impl/SimpleImageScroll.java   Mon Nov  4 13:40:59 2002
@@ -37,7 +37,9 @@
 
 public class SimpleImageScroll
        implements ScrollBlockManager.MediaserverScrollBlock {
-String rcsid = "$Id: SimpleImageScroll.java,v 1.4 2002/08/13 23:01:27 benja 
Exp $";
+String rcsid = "$Id: SimpleImageScroll.java,v 1.5 2002/11/04 18:40:59 tuukkah 
Exp $";
+
+    final static String DIR="../mstmpimg/"; // XXX Platform dependent!
 
     Image im;
     int width, height;
@@ -71,6 +73,10 @@
     }
     public int hashCode() {
        return getID().hashCode();
+    }
+
+    public String imageFilename() {
+       return new String(DIR+getID());
     }
 
     private void loadImage() {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]