/* 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.Graphics; import java.awt.Color; import javax.swing.*; /** A horizontal rule. */ public class HorizontalRule extends AbstractRigidBox { private final int margin = 2; private final int thickness = 2; /** Creates a new horizontal rule. */ public HorizontalRule() { height = thickness + 2*margin; } public void doLayout(Graphics g, JComponent c, int w) { // We pretend that we need all the space available so that we // get a line for ourselves. width = w; Browser.debug("" + this); } /** A horizontal rule doesn't have a minimum width, as it will * resize itself as the available width changes. * @return always <code>0</code>, as a horizontal rule doesn't * have a minimum width. */ public int getMinimumWidth() { return 0; } /** A horizontal rule doesn't have a preferred width, as it will * resize itself as the available width changes. A horizontal * rule doesn't take require any horizontal space. * @return always <code>0</code>, as a horizontal rule doesn't * have a preferred width. */ public int getPreferredWidth() { return 0; } /** Returns <code>false</code>, as a horizantal rule can't be split. * @return always <code>false</code>. */ public boolean splitIsPossible(int w) { // A horizontal rule can't be split. return false; } public void drawAt(int x, int y, DocumentView v) { v.fillRect(x + margin, y + margin, width - 2*margin, height - 2*margin, Color.black); } }