📄 tablecellbackground.java
字号:
/**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://www.jfree.org/jfreereport/index.html
* Project Lead: Thomas Morgner;
*
* (C) Copyright 2000-2003, by Simba Management Limited and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* ------------------------
* TableCellBackground.java
* ------------------------
* (C)opyright 2003, by Thomas Morgner and Contributors.
*
* Original Author: Thomas Morgner;
* Contributor(s): David Gilbert (for Simba Management Limited);
*
* $Id: TableCellBackground.java,v 1.11.2.1 2003/12/21 23:28:46 taqua Exp $
*
* Changes
* -------
* 27-Jan-2003 : Initial version
* 24-Feb-2003 : Fixed Checkstyle issues (DG);
*
*/
package org.jfree.report.modules.output.table.base;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
/**
* Encapsulates all TableCellBackground informations, such as borders and background color.
* <p>
* The TableCellBackground contains the format information for the table cells.
* Background information is used to format the tablecells in the {@link TableWriter}.
* CellBackgrounds can be shared for multiple cells.
*
* @author Thomas Morgner
*/
public strictfp class TableCellBackground extends TableCellData implements Cloneable
{
/** The top border's size. */
private float borderSizeTop;
/** The bottom border's size. */
private float borderSizeBottom;
/** The left border's size. */
private float borderSizeLeft;
/** The right border's size. */
private float borderSizeRight;
/** The top border's color. */
private Color colorTop;
/** The left border's color. */
private Color colorLeft;
/** The bottom border's color. */
private Color colorBottom;
/** The right border's color. */
private Color colorRight;
/** The cell background color. */
private Color color;
/**
* Creates a table cell background with the given bounds, no borders and the specified
* color as background. If the color is <code>null</code>, no background is set.
*
* @param outerBounds the background cell size
* @param color the background color, <code>null</code> for no background.
*/
public TableCellBackground(final Rectangle2D outerBounds, final Color color)
{
super(outerBounds);
this.color = color;
}
/**
* Returns <code>true</code>, as this is a cell background definition.
*
* @return always true, this is a data cell.
*
* @see TableCellData#isBackground
*/
public boolean isBackground()
{
return true;
}
/**
* Gets the background color for this cell, or <code>null</code> if this cell has no background.
*
* @return the background color or <code>null</code>.
*/
public Color getColor()
{
return color;
}
/**
* Defines the top border. If color is null or the size is 0, then no top border
* is drawn.
*
* @param color the color of the top border.
* @param size the line width of the top border.
*/
public void setBorderTop(final Color color, final float size)
{
colorTop = color;
borderSizeTop = size;
}
/**
* Defines the left border. If color is null or the size is 0, then no left border
* is drawn.
*
* @param color the color of the left border.
* @param size the line width of the left border.
*/
public void setBorderLeft(final Color color, final float size)
{
colorLeft = color;
borderSizeLeft = size;
}
/**
* Defines the bottom border. If color is null or the size is 0, then no bottom border
* is drawn.
*
* @param color the color of the bottom border.
* @param size the line width of the bottom border.
*/
public void setBorderBottom(final Color color, final float size)
{
colorBottom = color;
borderSizeBottom = size;
}
/**
* Defines the right border. If color is null or the size is 0, then no right border
* is drawn.
*
* @param color the color of the right border.
* @param size the line width of the right border.
*/
public void setBorderRight(final Color color, final float size)
{
colorRight = color;
borderSizeRight = size;
}
/**
* Returns the line width of the top border.
*
* @return the line width of the top border.
*/
public float getBorderSizeTop()
{
return borderSizeTop;
}
/**
* Returns the line width of the bottom border.
*
* @return the line width of the bottom border.
*/
public float getBorderSizeBottom()
{
return borderSizeBottom;
}
/**
* Returns the line width of the left border.
*
* @return the line width of the left border.
*/
public float getBorderSizeLeft()
{
return borderSizeLeft;
}
/**
* Returns the line width of the right border.
*
* @return the line width of the right border.
*/
public float getBorderSizeRight()
{
return borderSizeRight;
}
/**
* Returns the line color of the top border.
*
* @return the color of the top border.
*/
public Color getColorTop()
{
return colorTop;
}
/**
* Returns the line color of the left border.
*
* @return the color of the left border.
*/
public Color getColorLeft()
{
return colorLeft;
}
/**
* Returns the line color of the bottom border.
*
* @return the color of the bottom border.
*/
public Color getColorBottom()
{
return colorBottom;
}
/**
* Returns the line color of the right border.
*
* @return the color of the right border.
*/
public Color getColorRight()
{
return colorRight;
}
/**
* Merges this background with the given background and returns the
* result. The given background is considered to be overlayed by this
* background.
*
* @param background the other background cell
* @param cellBounds the bounds of the cell for which to form the background.
* @return a union of the background informations.
*/
public TableCellBackground merge(final TableCellBackground background,
final Rectangle2D cellBounds)
{
Color color = getColor();
if (color == null)
{
color = background.getColor();
}
else
{
if (background.getColor() != null)
{
color = addColor(color, background.getColor());
}
}
if (isBottomBorderDefinition(cellBounds, this))
{
final TableCellBackground merged = background.createMergedInstance(cellBounds);
merged.color = color;
merged.mergeBottomBorder(this);
return merged;
}
if (isBottomBorderDefinition(cellBounds, background))
{
final TableCellBackground merged = createMergedInstance(cellBounds);
merged.color = color;
merged.mergeBottomBorder(background);
return merged;
}
if (isRightBorderDefinition(cellBounds, this))
{
final TableCellBackground merged = background.createMergedInstance(cellBounds);
merged.color = color;
merged.mergeRightBorder(this);
return merged;
}
if (isRightBorderDefinition(cellBounds, background))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -