/[gzz]/gzz/gzz/gfx/gl/GLSpans.java
ViewVC logotype

Diff of /gzz/gzz/gfx/gl/GLSpans.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by tjl, Tue Sep 24 07:26:48 2002 UTC revision 1.8 by tuukkah, Mon Nov 4 18:40:59 2002 UTC
# Line 62  public class GLSpans { Line 62  public class GLSpans {
62      /** Span to rect, by LOD.      /** Span to rect, by LOD.
63       */       */
64      static HashMap[] pages = new HashMap[] { new HashMap(), new HashMap() } ;      static HashMap[] pages = new HashMap[] { new HashMap(), new HashMap() } ;
65        static HashMap[] images = new HashMap[] { new HashMap(), new HashMap() } ;
66    
67      static class LoadedTexRect {      static class LoadedTexRect {
68          LoadedTexRect(String file) {          LoadedTexRect(String file) {
# Line 145  public class GLSpans { Line 146  public class GLSpans {
146      }      }
147    
148    
149        /** Return a Rect containing the image span
150         */
151        static public Rect getRect(ImageSpan span) {
152            return getRect(span, 0);
153        }
154        /** Return a Rect containing the image span
155         * @param lod The level of detail. Currently, only 0 is known
156         */
157        static public Rect getRect(ImageSpan span, int lod) {
158            if(lod < 0) lod = 0;
159            if(lod > 0) lod = 0;
160            Rect r = (Rect)images[lod].get(span);
161            if(r == null) {
162                // ScrollBlockManager.PageSpanBase span =
163                //  (ScrollBlockManager.PageSpanBase)span0;
164                SimpleImageScroll sb = (SimpleImageScroll)span.getScrollBlock();
165                Point p = span.getLocation();
166                Dimension d = span.getSize();
167                String file = sb.imageFilename();
168                /*      float resmult = sb.imageFileResolution(page)  /
169                        sb.coordinateResolution() ;*/
170                float resmult = 1;
171    
172                LoadedTexRect rect = getImage(file);
173                r = new Rect();
174                Rect ltr = (lod == 0 ? rect.rect : rect.rectLR);
175                r.texId = ltr.texId;
176                r.x0 = (float)ltr.getTexCoord(0, resmult * p.x / rect.w);
177                r.x1 = (float)ltr.getTexCoord(0, resmult * (p.x+d.width) / rect.w);
178                r.y0 = (float)ltr.getTexCoord(1, resmult * p.y / rect.h);
179                r.y1 = (float)ltr.getTexCoord(1, resmult * (p.y+d.height) / rect.h);
180                r.w = d.width;
181                r.h = d.height;
182    
183                images[lod].put(span, r);
184            }
185            return r;
186        }
187    
188    
189      // Temporary imagecache-like thing XXX      // Temporary imagecache-like thing XXX
190      static HashMap images = new HashMap();      static HashMap imagefiles = new HashMap();
191      static public LoadedTexRect getImage(String file) {      static public LoadedTexRect getImage(String file) {
192          LoadedTexRect res = (LoadedTexRect) images.get(file);          LoadedTexRect res = (LoadedTexRect) imagefiles.get(file);
193          if(res == null) {          if(res == null) {
194              res = new LoadedTexRect(file);              res = new LoadedTexRect(file);
195              images.put(file, res);              imagefiles.put(file, res);
196          }          }
197          return res;          return res;
198      }      }

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26