/* HBroken.java * * Copyright (c) 2002, Benja Fallenstein * * 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 Benja Fallenstein */ package gzz.vob; /** A way to break an HChain into lines. * Currently simplistic, not fit for billowing. Simply lists * all the positions where there's a line break. */ public class HBroken { protected HChain chain; protected float scale; protected int[] breaks = new int[10]; protected int length; public HBroken(HChain chain, float scale) { this.chain = chain; this.scale = scale; } /** Add a break. * pos == hbox before which to break */ public void addBreak(int pos) { try { breaks[length] = pos; } catch(ArrayIndexOutOfBoundsException e) { int[] nbreaks = new int[length * 2]; System.arraycopy(breaks, 0, nbreaks, 0, breaks.length); breaks = nbreaks; breaks[length] = pos; } length++; } public void put(VobScene vs, int coordsys) { int x = 0, y = 0; for(int i=1; i<=length; i++) { int from = breaks[i-1]; int to; if(i