// (c) Tuomas J. Lukka and Benja Fallenstein package org.fenfire.view.buoy; import org.fenfire.view.View2D; import org.fenfire.util.Pair; import org.nongnu.libvob.*; import org.nongnu.libvob.impl.DefaultVobMatcher; import org.nongnu.libvob.buoy.*; import java.awt.Rectangle; import java.awt.Color; import java.awt.event.MouseEvent; /** A buoy view node type showing the entire view2d * in a buoy. */ public class NodeType2DFull extends AbstractNodeType2D { public static boolean dbg = false; private static void pa(String s) { System.out.println(s); } public static int effigy = 0; public NodeType2DFull(View2D view2d) { super(view2d); } public Object getSize(Object linkId, Object anchor, float wh[]) { Pair p = (Pair)anchor; Object plane = p.first; view2d.getSize(plane, wh); return null; } float [] tmpSize = new float[2]; float [] tmpSqSize = new float[2]; public int renderBuoy(VobScene vs, int into, Object linkId, Object anchor, Object cachedSize) { if(effigy != 0) { Vob eff = org.nongnu.libvob.gl.GLRen.createQuad(effigy-1); vs.map.put( eff, into); return into; } Pair p = (Pair)anchor; Object plane = p.first; Rectangle rect = (Rectangle)p.second; view2d.getSize(plane, tmpSize); vs.coords.getSqSize(into, tmpSqSize); float scale1 = tmpSize[0] / tmpSqSize[0]; float scale2 = tmpSize[1] / tmpSqSize[1]; float scale = (scale1 < scale2 ? scale1 : scale2); int box2paper = vs.coords.orthoBox(0, 0, 0, 0, scale, scale, tmpSqSize[0], tmpSqSize[1]); vs.matcher.add(into, box2paper, "BOX2PAPER"); view2d.render(vs, plane, into, into, box2paper); return vs.coords.translate(into, rect.x / scale, rect.y / scale); } }