/[gzz]/gzz/gzz/view/PageSpanCellView.java
ViewVC logotype

Diff of /gzz/gzz/view/PageSpanCellView.java

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

revision 1.11 by tjl, Wed Feb 5 14:09:03 2003 UTC revision 1.12 by tjl, Thu Feb 6 07:38:42 2003 UTC
# Line 28  public class PageSpanCellView extends Ce Line 28  public class PageSpanCellView extends Ce
28          return new Layout(enf);          return new Layout(enf);
29      }      }
30    
31        public Layout getLayout(ScrollBlock sb) {
32            return new Layout((PageSpan)sb.getCurrent()); // XXX Cache
33        }
34    
35      public void getSize(Enfilade1D enf, float[] out) {      public void getSize(Enfilade1D enf, float[] out) {
36          Layout l = getLayout(enf);          Layout l = getLayout(enf);
37          out[0] = l.w;          out[0] = l.w;
# Line 45  public class PageSpanCellView extends Ce Line 49  public class PageSpanCellView extends Ce
49          float w;          float w;
50          float h;          float h;
51    
52            /** Allocate the structure to hold a given number of pages.
53          public Layout(Enfilade1D enf) {           */
54              npages = enf.length();          private void alloc(int size) {
55                npages = size;
56              pages = new PageSpan[npages];              pages = new PageSpan[npages];
57              psps = new PageSpanPaper[npages];              psps = new PageSpanPaper[npages];
58              xywh = new float[npages * 4]; // x, y, w, h in PAPER coordinates              xywh = new float[npages * 4]; // x, y, w, h in PAPER coordinates
59              w = 0;              w = 0;
60              h = 0;              h = 0;
61            }
62    
63            /** (To be called with increasing p): add a page.
64             */
65            private void page(int p, PageSpan sp) {
66                pages[p] = sp;
67                GLSpanner.SpanRect rect = GLSpanner.getSpanRect(pages[p]);
68                psps[p] = new PageSpanPaper(null, rect.page);
69    
70                Point l_p = pages[p].getLocation();
71                Dimension d_p = pages[p].getSize();
72    
73                xywh[4*p + 0] = psps[p].getX(l_p.x);
74                xywh[4*p + 1] = psps[p].getY(l_p.y);
75                xywh[4*p + 2] = psps[p].getX(d_p.width);
76                xywh[4*p + 3] = psps[p].getY(d_p.height);
77    
78                if(dbg) pa("Page "+p+" "+
79                            xywh[4*p+0]+" "+
80                            xywh[4*p+1]+" "+
81                            xywh[4*p+2]+" "+
82                            xywh[4*p+3]+" "+
83                            pages[p]);
84    
85                w += scale * xywh[4*p + 2];
86                if(h < scale * xywh[4*p + 3])
87                    h = scale * xywh[4*p + 3];
88            }
89    
90              boolean foundCenter = false;          public Layout(Enfilade1D enf) {
91                alloc(enf.length());
92    
93              for(int p = 0; p < npages; p++) {              for(int p = 0; p < npages; p++) {
94                  pages[p] = (PageSpan)enf.sub(p, p+1).getList().get(0); // XXX INEFFICIENT!                  // XXX INEFFICIENT!
95                  GLSpanner.SpanRect rect = GLSpanner.getSpanRect(pages[p]);                  page(p, (PageSpan)enf.sub(p, p+1).getList().get(0));
                 psps[p] = new PageSpanPaper(null, rect.page);  
   
                 Point l_p = pages[p].getLocation();  
                 Dimension d_p = pages[p].getSize();  
   
                 xywh[4*p + 0] = psps[p].getX(l_p.x);  
                 xywh[4*p + 1] = psps[p].getY(l_p.y);  
                 xywh[4*p + 2] = psps[p].getX(d_p.width);  
                 xywh[4*p + 3] = psps[p].getY(d_p.height);  
   
                 if(dbg) pa("Page "+p+" "+  
                             xywh[4*p+0]+" "+  
                             xywh[4*p+1]+" "+  
                             xywh[4*p+2]+" "+  
                             xywh[4*p+3]+" "+  
                             pages[p]);  
   
                 w += scale * xywh[4*p + 2];  
                 if(h < scale * xywh[4*p + 3])  
                     h = scale * xywh[4*p + 3];  
96              }              }
97    
98            }
99    
100            public Layout(PageSpan sp) {
101                alloc(sp.length());
102    
103                for(int p = 0; p < npages; p++) {
104                    page(p, (PageSpan)sp.subSpan(p, p+1));
105                }
106    
107          }          }
108    
109    
110          /** Get the extents (in the output coordinates)          /** Get the extents (in the output coordinates)
111           * of a given page span.           * of a given page span.
112           * Currently, only the first intersecting page           * Currently, only the first intersecting page

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

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