// (c): Tuomas J. Lukka package gzz.view; import gzz.media.*; import gzz.gfx.gl.*; import gzz.vob.*; import java.awt.Dimension; import java.awt.Point; /** A cellview that shows pagespan pages placed next to each other. * Due to the use of coordinate system keys and coordinate systems, * this is the ONLY class that needs to know about the mapping * of enfilade to xy locations! *

* XXX Doesn't work in AWT -- maybe should be in gzz.view.gl? */ public class PageSpanCellView { public static final float scale = 72 * 6; public boolean useBg = true; /** Place the pages into the given coordinate system at the default scale, * centered at the given location. */ /* public void placeCentered(Cell c, VobScene vs, int into, ViewContext context, PageSpan center) { placeCentered( cell.space.cellTexter.getEnfilade(cell, None), vs, into, context, center); } */ /** Place the given enfilade in the coordinate system. * @param center The pagespan which defines where the origin will be * @param importance The importance to be given to the image requests * @param pixelscale The pixel scale at which the image requests are made */ public void placeCentered(Enfilade1D enf, VobScene vs, int into, ViewContext context, PageSpan center, float importance, float pixelscale) { int npages = enf.length(); PageSpan[] pages = new PageSpan[npages]; PageSpanPaper[] psps = new PageSpanPaper[npages]; float[] xywh = new float[npages * 4]; // x, y, w, h in PAPER coordinates float w = 0; boolean foundCenter = false; float xoffs = 0; float yoffs = 0; for(int p = 0; p < npages; p++) { pages[p] = (PageSpan)enf.sub(p, p+1).getList().get(0); // XXX INEFFICIENT! GLSpanner.SpanRect rect = GLSpanner.getSpanRect(pages[p]); 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(!foundCenter && center != null && center.intersects(pages[p])) { foundCenter = true; Point l_c = center.getLocation(); // XXX Center? xoffs = w + scale * (psps[p].getX(l_c.x) - xywh[4*p + 0]); yoffs = scale * (psps[p].getY(l_c.y) - xywh[4*p + 1]); } w += scale * xywh[4*p + 2]; } // Now we can draw the pages. float curx = -xoffs; for(int p = 0; p < npages; p++) { int around = vs.orthoBoxCS(into, pages[p], 0, curx, -yoffs, scale, scale, xywh[4*p+2], xywh[4*p+3]); int tr = vs.translateCS(around, "T", -xywh[4*p+0], -xywh[4*p+1]); curx += scale * xywh[4*p + 2]; psps[p].request(importance, scale * pixelscale); vs.map.put(GLRen.createPaperQuad(psps[p].getPaper(useBg), xywh[4*p + 0], xywh[4*p + 1], xywh[4*p + 2], xywh[4*p + 3], 0), tr, 0); } } }