/* dIntProg Browser. A webbrowser written in Java.
* Copyright (C) 2001 Martin Geisler <[email protected]>
*
* 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 linebreak. This is an invisible box with a height of 0 pixels.
* The width is equal to whatever it can get. This means that there
* will never be room for this on a line, unless it's the only box on
* that line. And when it's places on a line it doesn't leave a gap
* to the line above, as it has a height of 0 pixels. */
public class Break extends AbstractRigidBox {
/** Constructs a new linebreak. The height is initialized to 0
* pixels. */
public Break() {
height = 0;
}
public void doLayout(Graphics g, JComponent c, int w) {
// A break has a width equal to the allowed width, but a
// height of 0 pixesl. This forces a linebreak. */
width = w;
}
/** The minimum width of the break.
* @return always 0 pixes, as a break doesn't take up any space.
* This ensures that breaks won't affect the calculations made in
* places like {@link Table tables} and so on. */
public int getMinimumWidth() {
return 0;
}
/** The preferred width of the break.
* @return always 0 pixels, as a break doesn't take up any space.
* This ensures that breaks won't affect the calculations made in
* places like {@link Table tables} and so on. */
public int getPreferredWidth() {
return 0;
}
/** Reports wether or not a split is possible.
* @return always false, as a break can't be splitted. */
public boolean splitIsPossible(int w) {
// A break can't be split.
return false;
}
public void drawAt(int x, int y, DocumentView v) {
// A break is invisible.
}
}