/* MagGrid.java * * Copyright (c) 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 Tuomas Lukka */ package org.gzigzag; import java.awt.*; /** A grid magnified from the center. */ public class MagGrid extends GridGeom implements ZOb { public static final String rcsid = "$Id: MagGrid.zob,v 1.2.10.1 2001/08/24 19:58:24 bfallenstein Exp $"; STRUCTPARAMS { float[] shrink // 2..2 = new float[] {(float)1, (float)1}; float[] initmul // 2..2 = new float[] {(float)1.4, (float)1.55}; int[] gap // 2..2 = new int[] {6, 6}; /** Whether to fit all cells into view or leave * edges hanging outside. */ boolean fit = false; } int[] xs; int[] ys; public Dimension setSizes(Dimension normalcell, Dimension canvas) { Dimension ret = new Dimension(); ret.width = 1; int cur = (int)(normalcell.width * initmul[0]); int xw; for(xw = cur; xw <= canvas.width && cur > 1; xw += 2*cur+2*gap[0]) { ret.width +=2; cur = (int)(cur * shrink[0]); } if(fit) { xw -= 2*cur+2*gap[0]; ret.width -= 2; } xs = new int[ret.width + 1]; cur = (int)(normalcell.width * initmul[0]); xs[ret.width / 2] = cur; for(int i=1; i 1; yw += 2*cur+2*gap[1]) { ret.height +=2; cur = (int)(cur * shrink[1]); } if(fit) { yw -= 2*cur+2*gap[1]; ret.height -= 2; } ys = new int[ret.height + 1]; cur = (int)(normalcell.height * initmul[1]); ys[ret.height / 2] = cur; for(int i=1; i