// (c) Tuomas J. Lukka package gzz.view; import gzz.*; import gzz.vob.*; import gzz.vob.buoy.*; /** 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. */ public class CoordinatePlaneView implements View { public static final String rcsid = "$Id: CoordinatePlaneView.java,v 1.1 2002/10/30 19:10:17 tjl Exp $"; public static boolean dbg = true; private static void pa(String s) { System.err.println(s); } private Dim d_rank; private Dim d_coords; private Box cursorBox; public CoordinatePlaneView(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 Box getCursorBox() { return cursorBox; } public void render(VobScene vs, int into, ViewContext context) { Cell cur = context.getAccursed(); Cell item = cur.h(d_rank); Cell head = item; Box b = new Box(); float[] bs = new float[2]; cursorBox = null; CellInBox cv = context.getCellView(); while(item != null) { // for every item: 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); cv.getSize(item, bs); int whc = vs.translateCS(into, item, place[0], place[1]); b.set(vs, whc, bs[0], bs[1]); cv.place(item, vs, b, context); if(item.equals(cur)) cursorBox = (Box)b.clone(); } item = item.s(d_rank); if(head.equals(item)) break; } } }