/* EnumVanishingView.zob * * Copyright (c) 1999-2000, Ted Nelson and Tuomas 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 Benjamin Fallenstein, based on VanishingView by Tuomas Lukka */ package org.gzigzag; import java.awt.*; import java.awt.event.*; import java.util.*; /** A reimplementation of the vanishing raster. * Much simpler than the original one since this one does not try * to do the hard rasters as well. */ public class EnumVanishingView implements FlobView, ZOb { public static final String rcsid = "$Id: EnumVanishingView.zob,v 1.1 2002/10/07 12:37:34 tuukkah Exp $"; public static boolean dbg = false; static final void p(String s) { if(dbg) System.out.println(s); } static final void pa(String s) { System.out.println(s); } // Following are the parameters out of which the constructor // is created. STRUCTPARAMS { /** The factor to shrink the cells with when moving away from * center. */ float[] shrink // 2..2 = new float[] {(float)0.9, (float)0.9}; /** The factor the center cell is enlarged with from default. */ float[] initmul // 2..2 = new float[] {(float)1.6, (float)1.6}; /** The factor to enlarge the center cell on top of initmul. * This only has an effect on the center cell whereas initmul * affects all cells. */ float[] centermul // 2..2 = new float[] {(float)1.0, (float)1.0}; /** The distance between neighbouring cells. */ int gap = 5; /** The depth to raster to. */ int depth = 5; /** The precedence order of dimensions. */ int[] pref // 2..5 = new int[] {0, 1, 2}; /** Whether to allow cell sizes to vary. */ boolean varsize = false; } // XXX This should be a structparam later on. FlobDecorator linker = new StdLinks(); public void raster(FlobSet into, FlobFactory fact, ZZCell view, String[] dims, ZZCell accursed) { Dimension fs = into.getSize(); // Precalculate sizes and gaps. int[] gaps = new int[depth]; Dimension[] size = new Dimension[depth+1]; float[] sizfact = new float[depth+1]; float xf = initmul[0], xf0 = xf; float yf = initmul[1], yf0 = yf; sizfact[0] = yf; Dimension d0 = fact.getSize(null, yf); Dimension d = (varsize ? fact.getSize(accursed, yf) : d0); for(int i=0; i0 ? 1 : -1; int dpt = once.here.nth; // Alignments int fxa, fya, txa, tya; if(dim.dim == 0) { fxa=dir; txa=-dir; fya=0; tya=0; } else if(dim.dim == 1) { fxa=0; txa=0; fya=dir; tya=-dir; } else { fxa=dir; fya=dir; txa=-dir; tya=-dir; } Point p = f.getPoint(fxa, fya); Point q = ZZUtil.movePoint(p, fxa, fya, gaps[dpt]); Flob g = fact.centerFlob(into, c, c, sizfact[dpt], q, txa, tya, d1+dpt*dm, size[dpt]); once.here.info = g; p("To "+once.here+" assign "+g); } linker.decorate(into, "", view); // Do the dimensions. if(true) ZZUtil.showFlobDims(into, fact, view, 3); } }