/* dIntProg Browser. A webbrowser written in Java. * Copyright (C) 2001 Martin Geisler <gimpster@gimpster.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program 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 * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the * * Free Software Foundation, Inc., * 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ import java.awt.*; import javax.swing.*; /** Adaptor class that implements {@link Box} by supplying reasonable * default for most of the methods. */ public abstract class AbstractBox implements Box { /** The width of the box, defaults to <code>-1</code>. */ protected int width = -1; /** The height of the box, defaults to <code>-1</code>. */ protected int height = -1; /** The minimum width of this box, defaults to <code>-1</code>. */ protected int min_width = -1; /** The preferred width of the box, defaults to <code>-1</code>. * The preferred width is used when someone needs to get an * indication of the size of a box. */ protected int pref_width = -1; public int getWidth() { return width; } public int getMinimumWidth() { return min_width; } public int getPreferredWidth() { return pref_width; } public int getHeight() { return height; } public abstract void doLayout(Graphics g, JComponent c, int w); public abstract void drawAt(int x, int y, DocumentView v); /** Returns a representation of the box. The string contains the * widht, height, and class-name of the box. It is only meant to * be used when debugging. * @return information about the box. */ public String toString() { return "" + width + "x" + height + " box: " + this.getClass().getName(); } }