/* BgVob.java * * Copyright (c) 1999-2001, Ted Nelson and Tuomas Lukka * * This file is part of Gzz. * * Gzz is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Gzz 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 GNU Lesser General * Public License for more details. * * You should have received a copy of the GNU Lesser General * Public License along with Gzz; if not, write to the Free * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * * */ /* * Written by Tuukka Hastrup */ package org.fenfire.modules.pp.vob; import org.fenfire.impl.*; import org.fenfire.*; import org.nongnu.libvob.*; import org.nongnu.libvob.gl.*; import org.nongnu.libvob.vobs.*; import org.nongnu.libvob.GraphicsAPI; import java.awt.*; import java.util.*; import com.hp.hpl.mesa.rdf.jena.model.*; /** A vob that is the background paper. * This vob stores the inside coordinates so clicks on it can be * used to pan pretty easily. */ public class BgVob extends org.nongnu.libvob.Vob { public static final String rcsid = "$Id: BgVob.java,v 1.1 2003/03/27 10:32:17 mudyc Exp $"; public static boolean dbg = false; private static void pa(String s) { System.err.println(s); } static HashMap bgvobs = new HashMap(); // public Rectangle clip; Color bgcolor; RDFNode papercode; GLRen.PaperQuad pq; public static BgVob create(RDFNode node, GraphicsAPI.Window w) { BgVob v = (BgVob)bgvobs.get(node); if(v == null) { v = new BgVob(node, w); bgvobs.put(node, v); } return v; } public BgVob(RDFNode node, GraphicsAPI.Window w) { papercode = node; pq = getPaperQuad(papercode, w); } static Rectangle rect = new Rectangle(); static Rectangle rect2 = new Rectangle(); public void render(Graphics g, boolean fast, Vob.RenderInfo info1, Vob.RenderInfo info2) { info1.getExtRect(rect); info2.getExtRect(rect2); if(dbg) pa("RectBg.render "+rect+" "+rect2); int x0, y0, x1, y1; x0 = rect2.x; x1 = rect2.x + rect2.width; y0 = rect2.y; y1 = rect2.y + rect2.height; Color old = g.getColor(); g.setColor(bgcolor != null ? bgcolor : Color.white); g.fillRect(rect.x, rect.y, rect.width, rect.height); g.setColor(old); } GLRen.PaperQuad getPaperQuad(RDFNode node, GraphicsAPI.Window win) { Paper pap; GLRen.PaperQuad pq; pap = PaperMill.getInstance().getOptimizedPaper(node.hashCode(), win); return GLRen.createPaperQuad(pap, 0, 0, 1, 1, 0, GLRen.PAPERQUAD_CS2_TO_SCREEN); } public void put(VobScene vs, int cs1, int cs2) { vs.map.put(this, cs1, cs2); if(dbg) pa("BgVob.put: "+papercode); } public int putGL(VobScene vs, int coordsys1, int coordsys2) { vs.map.put(pq, coordsys1, coordsys2); return 0; } }