/* CoordinatePlaneView.java * * Copyright (c) 2002, Tuomas J. Lukka * * You may use and distribute under the terms of either the GNU Lesser * General Public License, either version 2 of the license or, * at your choice, any later version. Alternatively, you may use and * distribute under the terms of the XPL. * * See the LICENSE.lgpl and LICENSE.xpl files for the specific terms of * the licenses. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the README * file for more details. * */ /* * Written by Tuomas J. Lukka and Matti Katila */ package gzz.view; import gzz.*; import gzz.vob.*; import gzz.vob.vobs.*; import gzz.view.*; import gzz.impl.SimpleVStreamTexter; import gzz.media.*; import gzz.media.impl.*; import gzz.gfx.gl.GLVobCoorder; /** A view which shows a single rank of cells, at coordinates given * in the structure. * For use in PP, but generalizable; possibly a step into floatingworld ideas. * Currently, most things are hardcoded but we can work on that later. * * mudyc> Might be a kludge i don't know yet */ public class CoordinatePlaneMultiView { public static final String rcsid = "$Id: CoordinatePlaneMultiView.java,v 1.1 2003/02/12 13:37:56 mudyc Exp $"; public static boolean dbg = false; private static void pa(String s) { System.out.println("CoordinatePlaneMultiView"+s); } private Dim d_rank; private Dim d_coords; private int cursorBox; public CoordinatePlaneMultiView(Dim d_rank, Dim d_coords) { this.d_rank = d_rank; this.d_coords = d_coords; } /** Get the box into which the cursor cell was placed. */ public int getCursorBox() { return cursorBox; } /** Render with culling. * @param cullCS is the clip cs or under zero if not used. */ public void render(VobScene vs, int into, AbstractViewContext context, int cullCS, Space space, CellPlacementHook hook) { Cell cur = context.getAccursed(); Cell item = cur.h(d_rank); Cell head = item; float[] bs = new float[2]; cursorBox = -1; CellView orig_cv = context.getCellView(); while(item != null) { // for every item: // space MUST have cellTexter SimpleVStreamTexter sct = (SimpleVStreamTexter)space.getCellTexter(); Enfilade1DImpl enf = (Enfilade1DImpl)sct.getEnfilade(item, null); java.util.List enfList= enf.getList(); Span1D span = (Span1D) enfList.get(0); pa("ENF LIST: " + enfList); if(hook != null) if (span instanceof TextSpan) context.setCellView(new CellViewPlugin(orig_cv, hook)); else context.setCellView( new CellViewPlugin(new PageSpanCellView(), hook)); else if (span instanceof TextSpan) context.setCellView(orig_cv); else context.setCellView(new PageSpanCellView()); CellView cv = context.getCellView(); Cell firstCoord = item.s(d_coords, 1); if(dbg) pa("CPV: "+item+" "+firstCoord); if(firstCoord != null) { int[] place = gzz.client.Params.getInts(firstCoord, d_coords, 2, null); if (cv == null) throw new Error("No CellViewContext defined"); cv.getSize(item, context, bs); if(dbg) pa("CPV PLACE: "+place[0]+" "+place[1]+" "+ bs[0]+" "+bs[1]); int box = vs.orthoBoxCS(into, item, 0, place[0], place[1], 1, 1, bs[0], bs[1]); if (vs.coords instanceof GLVobCoorder && cullCS > 0) { int cull = ((GLVobCoorder)vs.coords).cull(box, cullCS); vs.matcher.add(box, cull, item+"cull"); box = cull; } cv.place(item, vs, box, context); vs.activate(box); if(item.equals(cur)) cursorBox = box; } item = item.s(d_rank); if(dbg) pa("CPV STEP: "+item+" "+head); if(head.equals(item)) break; } } }