/* PageScrollView2D.java * * Copyright (c) 2003 by Benja Fallenstein * * This file is part of Fenfire. * * Fenfire 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. * * Fenfire 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 Fenfire; if not, write to the Free * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * */ /* * Written by Benja Fallenstein */ package org.fenfire.view.buoy; import org.fenfire.view.View2D; import org.nongnu.libvob.*; import org.nongnu.libvob.buoy.*; /** A BuoyViewMainNode showing a 2D plane rendered through * a View2D. This class implements the keyboard and mouse * command for moving on the spatial plane. */ public class MainNode2D implements BuoyViewMainNode { protected Object plane; protected View2D view; protected float panX, panY; protected float zoom; private float tmp[] = new float[2]; /** Create a main node with a given plane, pan, and zoom. */ public MainNode2D(Object plane, View2D view, float panX, float panY, float zoom) { this.plane = plane; this.view = view; this.panX = panX; this.panY = panY; this.zoom = zoom; } /** Create a main node focused the center of a given plane. */ public MainNode2D(Object plane, View2D view) { this(plane, view, 0, 0, 1); view.getSize(plane, tmp); if(tmp[0] >= 0) { panX = tmp[0] / 2f; panY = tmp[1] / 2f; } } public void renderMain(VobScene vs, int into) { vs.coords.getSqSize(into, tmp); float w = tmp[0], h = tmp[1]; int box2paper = vs.coords.ortho(0, 0, panX-w/2, panY-h/2, zoom, zoom); view.render(vs, plane, into, into, box2paper); } public void keystroke(String s) { // XXX } public boolean mouse(MouseEvent e, VobScene oldVobScene) { // XXX return false; } }